blob: c83a20195f6da61964897ef20b78d6759d46df84 [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,
David Viragc703a2f2021-12-06 16:31:19 +010035 pll_1417x,
Naveen Krishna Ch0c23e2a2014-09-22 10:17:01 +053036 pll_1450x,
37 pll_1451x,
38 pll_1452x,
39 pll_1460x,
Sam Protsenko8f90f432021-10-08 18:43:48 +030040 pll_0822x,
Sam Protsenko6a734b32021-10-08 18:43:49 +030041 pll_0831x,
Yadwinder Singh Brar07dc76f2013-06-11 15:01:07 +053042};
43
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010044#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 Brar3ff6e0d2013-06-11 15:01:12 +053050 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010051 .rate = PLL_VALID_RATE(_fin, _rate, \
52 _m, _p, _s, 0, 16), \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053053 .mdiv = (_m), \
54 .pdiv = (_p), \
55 .sdiv = (_s), \
56 }
57
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010058#define PLL_S3C2410_MPLL_RATE(_fin, _rate, _m, _p, _s) \
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +053059 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010060 .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 Brar3ff6e0d2013-06-11 15:01:12 +053080 .mdiv = (_m), \
81 .pdiv = (_p), \
82 .sdiv = (_s), \
83 .kdiv = (_k), \
84 }
85
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010086#define PLL_4508_RATE(_fin, _rate, _m, _p, _s, _afc) \
Tomasz Figab4054ac2013-08-26 19:09:05 +020087 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010088 .rate = PLL_VALID_RATE(_fin, _rate, \
89 _m, _p, _s - 1, 0, 16), \
Tomasz Figab4054ac2013-08-26 19:09:05 +020090 .mdiv = (_m), \
91 .pdiv = (_p), \
92 .sdiv = (_s), \
93 .afc = (_afc), \
94 }
95
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010096#define PLL_4600_RATE(_fin, _rate, _m, _p, _s, _k, _vsel) \
Tomasz Figa5c896582013-08-26 19:09:07 +020097 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +010098 .rate = PLL_VALID_RATE(_fin, _rate, \
99 _m, _p, _s, _k, 16), \
Tomasz Figa5c896582013-08-26 19:09:07 +0200100 .mdiv = (_m), \
101 .pdiv = (_p), \
102 .sdiv = (_s), \
103 .kdiv = (_k), \
104 .vsel = (_vsel), \
105 }
106
Andrzej Hajda1d5013f2018-02-20 08:05:39 +0100107#define PLL_4650_RATE(_fin, _rate, _m, _p, _s, _k, _mfr, _mrr, _vsel) \
Tomasz Figa5c896582013-08-26 19:09:07 +0200108 { \
Andrzej Hajda1d5013f2018-02-20 08:05:39 +0100109 .rate = PLL_VALID_RATE(_fin, _rate, \
110 _m, _p, _s, _k, 10), \
Tomasz Figa5c896582013-08-26 19:09:07 +0200111 .mdiv = (_m), \
112 .pdiv = (_p), \
113 .sdiv = (_s), \
114 .kdiv = (_k), \
115 .mfr = (_mfr), \
116 .mrr = (_mrr), \
117 .vsel = (_vsel), \
118 }
119
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +0530120/* NOTE: Rate table should be kept sorted in descending order. */
121
122struct 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 Figab4054ac2013-08-26 19:09:05 +0200128 unsigned int afc;
Tomasz Figa5c896582013-08-26 19:09:07 +0200129 unsigned int mfr;
130 unsigned int mrr;
131 unsigned int vsel;
Yadwinder Singh Brar3ff6e0d2013-06-11 15:01:12 +0530132};
133
Thomas Abraham1c4c5fe2013-03-09 17:02:48 +0900134#endif /* __SAMSUNG_CLK_PLL_H */