Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Thomas Abraham | 1c4c5fe | 2013-03-09 17:02:48 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 4 | * Copyright (c) 2013 Linaro Ltd. |
| 5 | * |
Thomas Abraham | 1c4c5fe | 2013-03-09 17:02:48 +0900 | [diff] [blame] | 6 | * 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 Brar | 07dc76f | 2013-06-11 15:01:07 +0530 | [diff] [blame] | 12 | enum samsung_pll_type { |
Heiko Stuebner | a951b1d | 2014-02-19 09:25:41 +0900 | [diff] [blame] | 13 | pll_2126, |
| 14 | pll_3000, |
Yadwinder Singh Brar | 07dc76f | 2013-06-11 15:01:07 +0530 | [diff] [blame] | 15 | pll_35xx, |
| 16 | pll_36xx, |
| 17 | pll_2550, |
| 18 | pll_2650, |
Tomasz Figa | 52b0601 | 2013-08-26 19:09:04 +0200 | [diff] [blame] | 19 | pll_4500, |
| 20 | pll_4502, |
| 21 | pll_4508, |
Tomasz Figa | c50d11f | 2013-08-26 19:09:06 +0200 | [diff] [blame] | 22 | pll_4600, |
| 23 | pll_4650, |
| 24 | pll_4650c, |
Tomasz Figa | 40ef723 | 2013-08-21 02:33:21 +0200 | [diff] [blame] | 25 | pll_6552, |
Heiko Stuebner | 06654ac | 2014-02-19 09:25:36 +0900 | [diff] [blame] | 26 | pll_6552_s3c2416, |
Tomasz Figa | 40ef723 | 2013-08-21 02:33:21 +0200 | [diff] [blame] | 27 | pll_6553, |
Heiko Stuebner | ea5d6a8 | 2014-02-25 09:50:43 +0900 | [diff] [blame] | 28 | pll_s3c2410_mpll, |
| 29 | pll_s3c2410_upll, |
| 30 | pll_s3c2440_mpll, |
Sylwester Nawrocki | 1d9aa64 | 2016-08-18 17:01:20 +0200 | [diff] [blame] | 31 | pll_2550x, |
Pankaj Dubey | 8432984 | 2014-03-12 20:26:45 +0530 | [diff] [blame] | 32 | pll_2550xx, |
Sylwester Nawrocki | be95d2c | 2016-09-09 10:09:05 +0200 | [diff] [blame] | 33 | pll_2650x, |
Rahul Sharma | eefe119 | 2014-03-12 20:26:46 +0530 | [diff] [blame] | 34 | pll_2650xx, |
David Virag | c703a2f | 2021-12-06 16:31:19 +0100 | [diff] [blame] | 35 | pll_1417x, |
Naveen Krishna Ch | 0c23e2a | 2014-09-22 10:17:01 +0530 | [diff] [blame] | 36 | pll_1450x, |
| 37 | pll_1451x, |
| 38 | pll_1452x, |
| 39 | pll_1460x, |
Sam Protsenko | 8f90f43 | 2021-10-08 18:43:48 +0300 | [diff] [blame] | 40 | pll_0822x, |
Sam Protsenko | 6a734b3 | 2021-10-08 18:43:49 +0300 | [diff] [blame] | 41 | pll_0831x, |
Yadwinder Singh Brar | 07dc76f | 2013-06-11 15:01:07 +0530 | [diff] [blame] | 42 | }; |
| 43 | |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 44 | #define PLL_RATE(_fin, _m, _p, _s, _k, _ks) \ |
| 45 | ((u64)(_fin) * (BIT(_ks) * (_m) + (_k)) / BIT(_ks) / ((_p) << (_s))) |
| 46 | #define PLL_VALID_RATE(_fin, _fout, _m, _p, _s, _k, _ks) ((_fout) + \ |
| 47 | BUILD_BUG_ON_ZERO(PLL_RATE(_fin, _m, _p, _s, _k, _ks) != (_fout))) |
| 48 | |
| 49 | #define PLL_35XX_RATE(_fin, _rate, _m, _p, _s) \ |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 50 | { \ |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 51 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 52 | _m, _p, _s, 0, 16), \ |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 53 | .mdiv = (_m), \ |
| 54 | .pdiv = (_p), \ |
| 55 | .sdiv = (_s), \ |
| 56 | } |
| 57 | |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 58 | #define PLL_S3C2410_MPLL_RATE(_fin, _rate, _m, _p, _s) \ |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 59 | { \ |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 60 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 61 | _m + 8, _p + 2, _s, 0, 16), \ |
| 62 | .mdiv = (_m), \ |
| 63 | .pdiv = (_p), \ |
| 64 | .sdiv = (_s), \ |
| 65 | } |
| 66 | |
| 67 | #define PLL_S3C2440_MPLL_RATE(_fin, _rate, _m, _p, _s) \ |
| 68 | { \ |
| 69 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 70 | 2 * (_m + 8), _p + 2, _s, 0, 16), \ |
| 71 | .mdiv = (_m), \ |
| 72 | .pdiv = (_p), \ |
| 73 | .sdiv = (_s), \ |
| 74 | } |
| 75 | |
| 76 | #define PLL_36XX_RATE(_fin, _rate, _m, _p, _s, _k) \ |
| 77 | { \ |
| 78 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 79 | _m, _p, _s, _k, 16), \ |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 80 | .mdiv = (_m), \ |
| 81 | .pdiv = (_p), \ |
| 82 | .sdiv = (_s), \ |
| 83 | .kdiv = (_k), \ |
| 84 | } |
| 85 | |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 86 | #define PLL_4508_RATE(_fin, _rate, _m, _p, _s, _afc) \ |
Tomasz Figa | b4054ac | 2013-08-26 19:09:05 +0200 | [diff] [blame] | 87 | { \ |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 88 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 89 | _m, _p, _s - 1, 0, 16), \ |
Tomasz Figa | b4054ac | 2013-08-26 19:09:05 +0200 | [diff] [blame] | 90 | .mdiv = (_m), \ |
| 91 | .pdiv = (_p), \ |
| 92 | .sdiv = (_s), \ |
| 93 | .afc = (_afc), \ |
| 94 | } |
| 95 | |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 96 | #define PLL_4600_RATE(_fin, _rate, _m, _p, _s, _k, _vsel) \ |
Tomasz Figa | 5c89658 | 2013-08-26 19:09:07 +0200 | [diff] [blame] | 97 | { \ |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 98 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 99 | _m, _p, _s, _k, 16), \ |
Tomasz Figa | 5c89658 | 2013-08-26 19:09:07 +0200 | [diff] [blame] | 100 | .mdiv = (_m), \ |
| 101 | .pdiv = (_p), \ |
| 102 | .sdiv = (_s), \ |
| 103 | .kdiv = (_k), \ |
| 104 | .vsel = (_vsel), \ |
| 105 | } |
| 106 | |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 107 | #define PLL_4650_RATE(_fin, _rate, _m, _p, _s, _k, _mfr, _mrr, _vsel) \ |
Tomasz Figa | 5c89658 | 2013-08-26 19:09:07 +0200 | [diff] [blame] | 108 | { \ |
Andrzej Hajda | 1d5013f | 2018-02-20 08:05:39 +0100 | [diff] [blame] | 109 | .rate = PLL_VALID_RATE(_fin, _rate, \ |
| 110 | _m, _p, _s, _k, 10), \ |
Tomasz Figa | 5c89658 | 2013-08-26 19:09:07 +0200 | [diff] [blame] | 111 | .mdiv = (_m), \ |
| 112 | .pdiv = (_p), \ |
| 113 | .sdiv = (_s), \ |
| 114 | .kdiv = (_k), \ |
| 115 | .mfr = (_mfr), \ |
| 116 | .mrr = (_mrr), \ |
| 117 | .vsel = (_vsel), \ |
| 118 | } |
| 119 | |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 120 | /* NOTE: Rate table should be kept sorted in descending order. */ |
| 121 | |
| 122 | struct samsung_pll_rate_table { |
| 123 | unsigned int rate; |
| 124 | unsigned int pdiv; |
| 125 | unsigned int mdiv; |
| 126 | unsigned int sdiv; |
| 127 | unsigned int kdiv; |
Tomasz Figa | b4054ac | 2013-08-26 19:09:05 +0200 | [diff] [blame] | 128 | unsigned int afc; |
Tomasz Figa | 5c89658 | 2013-08-26 19:09:07 +0200 | [diff] [blame] | 129 | unsigned int mfr; |
| 130 | unsigned int mrr; |
| 131 | unsigned int vsel; |
Yadwinder Singh Brar | 3ff6e0d | 2013-06-11 15:01:12 +0530 | [diff] [blame] | 132 | }; |
| 133 | |
Thomas Abraham | 1c4c5fe | 2013-03-09 17:02:48 +0900 | [diff] [blame] | 134 | #endif /* __SAMSUNG_CLK_PLL_H */ |