diff options
author | Tom Rini <trini@konsulko.com> | 2020-01-15 09:22:15 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-01-15 09:22:15 -0500 |
commit | fb537657d9e94a8d489eb9463451e9cf90cbe973 (patch) | |
tree | 17a2b750de2caee4b9d3da009da85037b410c126 /drivers/clk/imx/clk-pfd.c | |
parent | 59612e4f24d2ee120c4e20d42fa23ba8e3574c51 (diff) | |
parent | 8d9c0762a8cf0a5027e7cd3c6794693f2d64d007 (diff) |
Merge tag 'u-boot-imx-20200115' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
-----------------------------------
- imx8:
add capricorn giedi deneb boards
- imx6:
fixed fow wandboard
- imx7: DM_ETHER for pico-imx7d
- fsl_esdhc_imx: add broken-cd property
- New SOC: IMXRT10xx
Travis:
https://travis-ci.org/sbabic/u-boot-imx/builds/637126531
Diffstat (limited to 'drivers/clk/imx/clk-pfd.c')
-rw-r--r-- | drivers/clk/imx/clk-pfd.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/clk/imx/clk-pfd.c b/drivers/clk/imx/clk-pfd.c index 188b2b3b90..4ae55f5a07 100644 --- a/drivers/clk/imx/clk-pfd.c +++ b/drivers/clk/imx/clk-pfd.c @@ -52,8 +52,30 @@ static unsigned long clk_pfd_recalc_rate(struct clk *clk) return tmp; } +static unsigned long clk_pfd_set_rate(struct clk *clk, unsigned long rate) +{ + struct clk_pfd *pfd = to_clk_pfd(clk); + unsigned long parent_rate = clk_get_parent_rate(clk); + u64 tmp = parent_rate; + u8 frac; + + tmp = tmp * 18 + rate / 2; + do_div(tmp, rate); + frac = tmp; + if (frac < 12) + frac = 12; + else if (frac > 35) + frac = 35; + + writel(0x3f << (pfd->idx * 8), pfd->reg + CLR); + writel(frac << (pfd->idx * 8), pfd->reg + SET); + + return 0; +} + static const struct clk_ops clk_pfd_ops = { .get_rate = clk_pfd_recalc_rate, + .set_rate = clk_pfd_set_rate, }; struct clk *imx_clk_pfd(const char *name, const char *parent_name, |