blob: a739f2b7ae80939f41d034ebbae94654ff05d0e1 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Thomas Abraham1c4c5fe2013-03-09 17:02:48 +09002/*
3 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 * Copyright (c) 2013 Linaro Ltd.
5 *
Thomas Abraham1c4c5fe2013-03-09 17:02:48 +09006 * Common Clock Framework support for all PLL's in Samsung platforms
7*/
8
9#ifndef __SAMSUNG_CLK_PLL_H
10#define __SAMSUNG_CLK_PLL_H
11
Yadwinder Singh Brar07dc76f2013-06-11 15:01:07 +053012enum samsung_pll_type {
Heiko Stuebnera951b1d2014-02-19 09:25:41 +090013 pll_2126,
14 pll_3000,
Yadwinder Singh Brar07dc76f2013-06-11 15:01:07 +053015 pll_35xx,
16 pll_36xx,
17 pll_2550,
18 pll_2650,
Tomasz Figa52b06012013-08-26 19:09:04 +020019 pll_4500,
20 pll_4502,
21 pll_4508,
Tomasz Figac50d11f2013-08-26 19:09:06 +020022 pll_4600,
23 pll_4650,
24 pll_4650c,
Tomasz Figa40ef7232013-08-21 02:33:21 +020025 pll_6552,
Heiko Stuebner06654ac2014-02-19 09:25:36 +090026 pll_6552_s3c2416,
Tomasz Figa40ef7232013-08-21 02:33:21 +020027 pll_6553,
Heiko Stuebnerea5d6a82014-02-25 09:50:43 +090028 pll_s3c2410_mpll,
29 pll_s3c2410_upll,
30 pll_s3c2440_mpll,
Sylwester Nawrocki1d9aa642016-08-18 17:01:20 +020031 pll_2550x,
Pankaj Dubey84329842014-03-12 20:26:45 +053032 pll_2550xx,
Sylwester Nawrockibe95d2c2016-09-09 10:09:05 +020033 pll_2650x,
Rahul Sharmaeefe1192014-03-12 20:26:46 +053034 pll_2650xx,
Naveen Krishna Ch0c23e2a2014-09-22 10:17:01 +053035 pll_1450x,
36 pll_1451x,
37 pll_1452x,
38 pll_1460x,
Sam Protsenko8f90f432021-10-08 18:43:48 +030039 pll_0822x,
Sam Protsenko6a734b32021-10-08 18:43:49 +030040 pll_0831x,
Yadwinder Singh Brar07dc76f2013-06-11 15:01:07 +053041};
42
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010043#define PLL_RATE(_fin, _m, _p, _s, _k, _ks) \
44 ((u64)(_fin) * (BIT(_ks) * (_m) + (_k)) / BIT(_ks) / ((_p) << (_s)))
45#define PLL_VALID_RATE(_fin, _fout, _m, _p, _s, _k, _ks) ((_fout) + \
46 BUILD_BUG_ON_ZERO(PLL_RATE(_fin, _m, _p, _s, _k, _ks) != (_fout)))
47
48#define PLL_35XX_RATE(_fin, _rate, _m, _p, _s) \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053049 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010050 .rate = PLL_VALID_RATE(_fin, _rate, \
51 _m, _p, _s, 0, 16), \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053052 .mdiv = (_m), \
53 .pdiv = (_p), \
54 .sdiv = (_s), \
55 }
56
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010057#define PLL_S3C2410_MPLL_RATE(_fin, _rate, _m, _p, _s) \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053058 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010059 .rate = PLL_VALID_RATE(_fin, _rate, \
60 _m + 8, _p + 2, _s, 0, 16), \
61 .mdiv = (_m), \
62 .pdiv = (_p), \
63 .sdiv = (_s), \
64 }
65
66#define PLL_S3C2440_MPLL_RATE(_fin, _rate, _m, _p, _s) \
67 { \
68 .rate = PLL_VALID_RATE(_fin, _rate, \
69 2 * (_m + 8), _p + 2, _s, 0, 16), \
70 .mdiv = (_m), \
71 .pdiv = (_p), \
72 .sdiv = (_s), \
73 }
74
75#define PLL_36XX_RATE(_fin, _rate, _m, _p, _s, _k) \
76 { \
77 .rate = PLL_VALID_RATE(_fin, _rate, \
78 _m, _p, _s, _k, 16), \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053079 .mdiv = (_m), \
80 .pdiv = (_p), \
81 .sdiv = (_s), \
82 .kdiv = (_k), \
83 }
84
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010085#define PLL_4508_RATE(_fin, _rate, _m, _p, _s, _afc) \
Tomasz Figab4054ac2013-08-26 19:09:05 +020086 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010087 .rate = PLL_VALID_RATE(_fin, _rate, \
88 _m, _p, _s - 1, 0, 16), \
Tomasz Figab4054ac2013-08-26 19:09:05 +020089 .mdiv = (_m), \
90 .pdiv = (_p), \
91 .sdiv = (_s), \
92 .afc = (_afc), \
93 }
94
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010095#define PLL_4600_RATE(_fin, _rate, _m, _p, _s, _k, _vsel) \
Tomasz Figa5c896582013-08-26 19:09:07 +020096 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010097 .rate = PLL_VALID_RATE(_fin, _rate, \
98 _m, _p, _s, _k, 16), \
Tomasz Figa5c896582013-08-26 19:09:07 +020099 .mdiv = (_m), \
100 .pdiv = (_p), \
101 .sdiv = (_s), \
102 .kdiv = (_k), \
103 .vsel = (_vsel), \
104 }
105
Andrzej Hajda1d5013f2018-02-20 08:05:39 +0100106#define PLL_4650_RATE(_fin, _rate, _m, _p, _s, _k, _mfr, _mrr, _vsel) \
Tomasz Figa5c896582013-08-26 19:09:07 +0200107 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +0100108 .rate = PLL_VALID_RATE(_fin, _rate, \
109 _m, _p, _s, _k, 10), \
Tomasz Figa5c896582013-08-26 19:09:07 +0200110 .mdiv = (_m), \
111 .pdiv = (_p), \
112 .sdiv = (_s), \
113 .kdiv = (_k), \
114 .mfr = (_mfr), \
115 .mrr = (_mrr), \
116 .vsel = (_vsel), \
117 }
118
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +0530119/* NOTE: Rate table should be kept sorted in descending order. */
120
121struct samsung_pll_rate_table {
122 unsigned int rate;
123 unsigned int pdiv;
124 unsigned int mdiv;
125 unsigned int sdiv;
126 unsigned int kdiv;
Tomasz Figab4054ac2013-08-26 19:09:05 +0200127 unsigned int afc;
Tomasz Figa5c896582013-08-26 19:09:07 +0200128 unsigned int mfr;
129 unsigned int mrr;
130 unsigned int vsel;
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +0530131};
132
Thomas Abraham1c4c5fe2013-03-09 17:02:48 +0900133#endif /* __SAMSUNG_CLK_PLL_H */