diff options
author | Simon Glass <sjg@chromium.org> | 2016-01-21 19:44:05 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-01-21 20:42:35 -0700 |
commit | 5ddf5d7705d2c2b59282ebd37aa2018460274e89 (patch) | |
tree | 2bd2229d25df111ee9b93c384d90c94e43df7224 /drivers/clk | |
parent | 2b9fe111ec47750d9d7912246d983a7f9e096df6 (diff) |
rockchip: clk: Make rkclk_get_clk() SoC-specific
The current method assumes that clocks are numbered from 0 and we can
determine a clock by its number. It is safer to use an ID in the clock's
platform data to avoid the situation where another clock is bound before
the one we expect.
Move the existing code into rk3036 since it still works there. Add a new
implementation for rk3288.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk_rk3036.c | 17 | ||||
-rw-r--r-- | drivers/clk/clk_rk3288.c | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/clk/clk_rk3036.c b/drivers/clk/clk_rk3036.c index dfecc24ece6..bd5f22a753a 100644 --- a/drivers/clk/clk_rk3036.c +++ b/drivers/clk/clk_rk3036.c @@ -57,6 +57,23 @@ static inline unsigned int log2(unsigned int value) return fls(value) - 1; } +void *rockchip_get_cru(void) +{ + struct udevice *dev; + fdt_addr_t addr; + int ret; + + ret = uclass_get_device(UCLASS_CLK, 0, &dev); + if (ret) + return ERR_PTR(ret); + + addr = dev_get_addr(dev); + if (addr == FDT_ADDR_T_NONE) + return ERR_PTR(-EINVAL); + + return (void *)addr; +} + static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id, const struct pll_div *div) { diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c index d294788f9ce..5a8f175e4b0 100644 --- a/drivers/clk/clk_rk3288.c +++ b/drivers/clk/clk_rk3288.c @@ -159,6 +159,19 @@ int rkclk_get_clk(enum rk_clk_id clk_id, struct udevice **devp) return -ENODEV; } +void *rockchip_get_cru(void) +{ + struct rk3288_clk_priv *priv; + struct udevice *dev; + int ret; + + ret = rkclk_get_clk(CLK_GENERAL, &dev); + if (ret) + return ERR_PTR(ret); + priv = dev_get_priv(dev); + return priv->cru; +} + static int rkclk_set_pll(struct rk3288_cru *cru, enum rk_clk_id clk_id, const struct pll_div *div) { |