2013-03-09 15:02:48 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
|
|
|
|
* Copyright (c) 2013 Linaro Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Common Clock Framework support for all PLL's in Samsung platforms
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SAMSUNG_CLK_PLL_H
|
|
|
|
#define __SAMSUNG_CLK_PLL_H
|
|
|
|
|
2013-06-11 16:31:07 +07:00
|
|
|
enum samsung_pll_type {
|
2014-02-19 07:25:41 +07:00
|
|
|
pll_2126,
|
|
|
|
pll_3000,
|
2013-06-11 16:31:07 +07:00
|
|
|
pll_35xx,
|
|
|
|
pll_36xx,
|
|
|
|
pll_2550,
|
|
|
|
pll_2650,
|
2013-08-27 00:09:04 +07:00
|
|
|
pll_4500,
|
|
|
|
pll_4502,
|
|
|
|
pll_4508,
|
2013-08-27 00:09:06 +07:00
|
|
|
pll_4600,
|
|
|
|
pll_4650,
|
|
|
|
pll_4650c,
|
2013-08-21 07:33:21 +07:00
|
|
|
pll_6552,
|
2014-02-19 07:25:36 +07:00
|
|
|
pll_6552_s3c2416,
|
2013-08-21 07:33:21 +07:00
|
|
|
pll_6553,
|
2014-02-25 07:50:43 +07:00
|
|
|
pll_s3c2410_mpll,
|
|
|
|
pll_s3c2410_upll,
|
|
|
|
pll_s3c2440_mpll,
|
2016-08-18 22:01:20 +07:00
|
|
|
pll_2550x,
|
2014-03-12 21:56:45 +07:00
|
|
|
pll_2550xx,
|
2016-09-09 15:09:05 +07:00
|
|
|
pll_2650x,
|
2014-03-12 21:56:46 +07:00
|
|
|
pll_2650xx,
|
2014-09-22 11:47:01 +07:00
|
|
|
pll_1450x,
|
|
|
|
pll_1451x,
|
|
|
|
pll_1452x,
|
|
|
|
pll_1460x,
|
2013-06-11 16:31:07 +07:00
|
|
|
};
|
|
|
|
|
2018-02-20 14:05:39 +07:00
|
|
|
#define PLL_RATE(_fin, _m, _p, _s, _k, _ks) \
|
|
|
|
((u64)(_fin) * (BIT(_ks) * (_m) + (_k)) / BIT(_ks) / ((_p) << (_s)))
|
|
|
|
#define PLL_VALID_RATE(_fin, _fout, _m, _p, _s, _k, _ks) ((_fout) + \
|
|
|
|
BUILD_BUG_ON_ZERO(PLL_RATE(_fin, _m, _p, _s, _k, _ks) != (_fout)))
|
|
|
|
|
|
|
|
#define PLL_35XX_RATE(_fin, _rate, _m, _p, _s) \
|
|
|
|
{ \
|
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m, _p, _s, 0, 16), \
|
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PLL_S3C2410_MPLL_RATE(_fin, _rate, _m, _p, _s) \
|
|
|
|
{ \
|
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m + 8, _p + 2, _s, 0, 16), \
|
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PLL_S3C2440_MPLL_RATE(_fin, _rate, _m, _p, _s) \
|
2013-06-11 16:31:12 +07:00
|
|
|
{ \
|
2018-02-20 14:05:39 +07:00
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
2 * (_m + 8), _p + 2, _s, 0, 16), \
|
2013-06-11 16:31:12 +07:00
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
}
|
|
|
|
|
2018-02-20 14:05:39 +07:00
|
|
|
#define PLL_36XX_RATE(_fin, _rate, _m, _p, _s, _k) \
|
2013-06-11 16:31:12 +07:00
|
|
|
{ \
|
2018-02-20 14:05:39 +07:00
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m, _p, _s, _k, 16), \
|
2013-06-11 16:31:12 +07:00
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
.kdiv = (_k), \
|
|
|
|
}
|
|
|
|
|
2018-02-20 14:05:39 +07:00
|
|
|
#define PLL_4508_RATE(_fin, _rate, _m, _p, _s, _afc) \
|
2013-08-27 00:09:05 +07:00
|
|
|
{ \
|
2018-02-20 14:05:39 +07:00
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m, _p, _s - 1, 0, 16), \
|
2013-08-27 00:09:05 +07:00
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
.afc = (_afc), \
|
|
|
|
}
|
|
|
|
|
2018-02-20 14:05:39 +07:00
|
|
|
#define PLL_4600_RATE(_fin, _rate, _m, _p, _s, _k, _vsel) \
|
2013-08-27 00:09:07 +07:00
|
|
|
{ \
|
2018-02-20 14:05:39 +07:00
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m, _p, _s, _k, 16), \
|
2013-08-27 00:09:07 +07:00
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
.kdiv = (_k), \
|
|
|
|
.vsel = (_vsel), \
|
|
|
|
}
|
|
|
|
|
2018-02-20 14:05:39 +07:00
|
|
|
#define PLL_4650_RATE(_fin, _rate, _m, _p, _s, _k, _mfr, _mrr, _vsel) \
|
2013-08-27 00:09:07 +07:00
|
|
|
{ \
|
2018-02-20 14:05:39 +07:00
|
|
|
.rate = PLL_VALID_RATE(_fin, _rate, \
|
|
|
|
_m, _p, _s, _k, 10), \
|
2013-08-27 00:09:07 +07:00
|
|
|
.mdiv = (_m), \
|
|
|
|
.pdiv = (_p), \
|
|
|
|
.sdiv = (_s), \
|
|
|
|
.kdiv = (_k), \
|
|
|
|
.mfr = (_mfr), \
|
|
|
|
.mrr = (_mrr), \
|
|
|
|
.vsel = (_vsel), \
|
|
|
|
}
|
|
|
|
|
2013-06-11 16:31:12 +07:00
|
|
|
/* NOTE: Rate table should be kept sorted in descending order. */
|
|
|
|
|
|
|
|
struct samsung_pll_rate_table {
|
|
|
|
unsigned int rate;
|
|
|
|
unsigned int pdiv;
|
|
|
|
unsigned int mdiv;
|
|
|
|
unsigned int sdiv;
|
|
|
|
unsigned int kdiv;
|
2013-08-27 00:09:05 +07:00
|
|
|
unsigned int afc;
|
2013-08-27 00:09:07 +07:00
|
|
|
unsigned int mfr;
|
|
|
|
unsigned int mrr;
|
|
|
|
unsigned int vsel;
|
2013-06-11 16:31:12 +07:00
|
|
|
};
|
|
|
|
|
2013-03-09 15:02:48 +07:00
|
|
|
#endif /* __SAMSUNG_CLK_PLL_H */
|