2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-11-17 06:20:16 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2015 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2016-06-17 15:44:00 +00:00
|
|
|
#include <clk-uclass.h>
|
2015-11-17 06:20:16 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <syscon.h>
|
|
|
|
#include <asm/io.h>
|
2019-03-28 03:01:23 +00:00
|
|
|
#include <asm/arch-rockchip/clock.h>
|
|
|
|
#include <asm/arch-rockchip/cru_rk3036.h>
|
|
|
|
#include <asm/arch-rockchip/hardware.h>
|
2015-11-17 06:20:16 +00:00
|
|
|
#include <dm/lists.h>
|
2016-01-22 02:43:38 +00:00
|
|
|
#include <dt-bindings/clock/rk3036-cru.h>
|
2016-07-22 21:51:06 +00:00
|
|
|
#include <linux/log2.h>
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
VCO_MAX_HZ = 2400U * 1000000,
|
|
|
|
VCO_MIN_HZ = 600 * 1000000,
|
|
|
|
OUTPUT_MAX_HZ = 2400U * 1000000,
|
|
|
|
OUTPUT_MIN_HZ = 24 * 1000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RATE_TO_DIV(input_rate, output_rate) \
|
|
|
|
((input_rate) / (output_rate) - 1);
|
|
|
|
|
|
|
|
#define DIV_TO_RATE(input_rate, div) ((input_rate) / ((div) + 1))
|
|
|
|
|
|
|
|
#define PLL_DIVISORS(hz, _refdiv, _postdiv1, _postdiv2) {\
|
|
|
|
.refdiv = _refdiv,\
|
|
|
|
.fbdiv = (u32)((u64)hz * _refdiv * _postdiv1 * _postdiv2 / OSC_HZ),\
|
|
|
|
.postdiv1 = _postdiv1, .postdiv2 = _postdiv2};\
|
|
|
|
_Static_assert(((u64)hz * _refdiv * _postdiv1 * _postdiv2 / OSC_HZ) *\
|
|
|
|
OSC_HZ / (_refdiv * _postdiv1 * _postdiv2) == hz,\
|
|
|
|
#hz "Hz cannot be hit with PLL "\
|
|
|
|
"divisors on line " __stringify(__LINE__));
|
|
|
|
|
2017-06-13 02:03:11 +00:00
|
|
|
/* use integer mode*/
|
2015-11-17 06:20:16 +00:00
|
|
|
static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 3, 1);
|
|
|
|
static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1);
|
|
|
|
|
|
|
|
static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id,
|
|
|
|
const struct pll_div *div)
|
|
|
|
{
|
|
|
|
int pll_id = rk_pll_id(clk_id);
|
|
|
|
struct rk3036_pll *pll = &cru->pll[pll_id];
|
|
|
|
|
|
|
|
/* All PLLs have same VCO and output frequency range restrictions. */
|
|
|
|
uint vco_hz = OSC_HZ / 1000 * div->fbdiv / div->refdiv * 1000;
|
|
|
|
uint output_hz = vco_hz / div->postdiv1 / div->postdiv2;
|
|
|
|
|
|
|
|
debug("PLL at %p: fbdiv=%d, refdiv=%d, postdiv1=%d, postdiv2=%d,\
|
|
|
|
vco=%u Hz, output=%u Hz\n",
|
|
|
|
pll, div->fbdiv, div->refdiv, div->postdiv1,
|
|
|
|
div->postdiv2, vco_hz, output_hz);
|
|
|
|
assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
|
|
|
|
output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ);
|
|
|
|
|
2017-06-13 02:03:11 +00:00
|
|
|
/* use integer mode */
|
|
|
|
rk_setreg(&pll->con1, 1 << PLL_DSMPD_SHIFT);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
rk_clrsetreg(&pll->con0,
|
2017-05-15 12:52:15 +00:00
|
|
|
PLL_POSTDIV1_MASK | PLL_FBDIV_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
(div->postdiv1 << PLL_POSTDIV1_SHIFT) | div->fbdiv);
|
2017-05-15 12:52:15 +00:00
|
|
|
rk_clrsetreg(&pll->con1, PLL_POSTDIV2_MASK | PLL_REFDIV_MASK,
|
|
|
|
(div->postdiv2 << PLL_POSTDIV2_SHIFT |
|
|
|
|
div->refdiv << PLL_REFDIV_SHIFT));
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
/* waiting for pll lock */
|
|
|
|
while (readl(&pll->con1) & (1 << PLL_LOCK_STATUS_SHIFT))
|
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rkclk_init(struct rk3036_cru *cru)
|
|
|
|
{
|
|
|
|
u32 aclk_div;
|
|
|
|
u32 hclk_div;
|
|
|
|
u32 pclk_div;
|
|
|
|
|
|
|
|
/* pll enter slow-mode */
|
|
|
|
rk_clrsetreg(&cru->cru_mode_con,
|
2017-05-15 12:52:15 +00:00
|
|
|
GPLL_MODE_MASK | APLL_MODE_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
GPLL_MODE_SLOW << GPLL_MODE_SHIFT |
|
|
|
|
APLL_MODE_SLOW << APLL_MODE_SHIFT);
|
|
|
|
|
|
|
|
/* init pll */
|
|
|
|
rkclk_set_pll(cru, CLK_ARM, &apll_init_cfg);
|
|
|
|
rkclk_set_pll(cru, CLK_GENERAL, &gpll_init_cfg);
|
|
|
|
|
|
|
|
/*
|
2017-05-15 12:52:15 +00:00
|
|
|
* select apll as cpu/core clock pll source and
|
|
|
|
* set up dependent divisors for PERI and ACLK clocks.
|
2015-11-17 06:20:16 +00:00
|
|
|
* core hz : apll = 1:1
|
|
|
|
*/
|
|
|
|
aclk_div = APLL_HZ / CORE_ACLK_HZ - 1;
|
|
|
|
assert((aclk_div + 1) * CORE_ACLK_HZ == APLL_HZ && aclk_div < 0x7);
|
|
|
|
|
|
|
|
pclk_div = APLL_HZ / CORE_PERI_HZ - 1;
|
|
|
|
assert((pclk_div + 1) * CORE_PERI_HZ == APLL_HZ && pclk_div < 0xf);
|
|
|
|
|
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[0],
|
2017-05-15 12:52:15 +00:00
|
|
|
CORE_CLK_PLL_SEL_MASK | CORE_DIV_CON_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
CORE_CLK_PLL_SEL_APLL << CORE_CLK_PLL_SEL_SHIFT |
|
|
|
|
0 << CORE_DIV_CON_SHIFT);
|
|
|
|
|
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[1],
|
2017-05-15 12:52:15 +00:00
|
|
|
CORE_ACLK_DIV_MASK | CORE_PERI_DIV_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
aclk_div << CORE_ACLK_DIV_SHIFT |
|
|
|
|
pclk_div << CORE_PERI_DIV_SHIFT);
|
|
|
|
|
|
|
|
/*
|
2017-05-15 12:52:16 +00:00
|
|
|
* select apll as pd_bus bus clock source and
|
2015-11-17 06:20:16 +00:00
|
|
|
* set up dependent divisors for PCLK/HCLK and ACLK clocks.
|
|
|
|
*/
|
2017-05-15 12:52:16 +00:00
|
|
|
aclk_div = GPLL_HZ / BUS_ACLK_HZ - 1;
|
|
|
|
assert((aclk_div + 1) * BUS_ACLK_HZ == GPLL_HZ && aclk_div <= 0x1f);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2017-05-15 12:52:16 +00:00
|
|
|
pclk_div = GPLL_HZ / BUS_PCLK_HZ - 1;
|
|
|
|
assert((pclk_div + 1) * BUS_PCLK_HZ == GPLL_HZ && pclk_div <= 0x7);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2017-05-15 12:52:16 +00:00
|
|
|
hclk_div = GPLL_HZ / BUS_HCLK_HZ - 1;
|
|
|
|
assert((hclk_div + 1) * BUS_HCLK_HZ == GPLL_HZ && hclk_div <= 0x3);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[0],
|
2017-05-15 12:52:15 +00:00
|
|
|
BUS_ACLK_PLL_SEL_MASK | BUS_ACLK_DIV_MASK,
|
2017-05-15 12:52:16 +00:00
|
|
|
BUS_ACLK_PLL_SEL_GPLL << BUS_ACLK_PLL_SEL_SHIFT |
|
2017-05-15 12:52:15 +00:00
|
|
|
aclk_div << BUS_ACLK_DIV_SHIFT);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[1],
|
2017-05-15 12:52:15 +00:00
|
|
|
BUS_PCLK_DIV_MASK | BUS_HCLK_DIV_MASK,
|
|
|
|
pclk_div << BUS_PCLK_DIV_SHIFT |
|
|
|
|
hclk_div << BUS_HCLK_DIV_SHIFT);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
/*
|
2017-05-15 12:52:15 +00:00
|
|
|
* select gpll as pd_peri bus clock source and
|
2015-11-17 06:20:16 +00:00
|
|
|
* set up dependent divisors for PCLK/HCLK and ACLK clocks.
|
|
|
|
*/
|
|
|
|
aclk_div = GPLL_HZ / PERI_ACLK_HZ - 1;
|
|
|
|
assert((aclk_div + 1) * PERI_ACLK_HZ == GPLL_HZ && aclk_div < 0x1f);
|
|
|
|
|
2016-07-22 21:51:06 +00:00
|
|
|
hclk_div = ilog2(PERI_ACLK_HZ / PERI_HCLK_HZ);
|
2015-11-17 06:20:16 +00:00
|
|
|
assert((1 << hclk_div) * PERI_HCLK_HZ ==
|
2017-05-15 12:52:16 +00:00
|
|
|
PERI_ACLK_HZ && (hclk_div < 0x4));
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2016-07-22 21:51:06 +00:00
|
|
|
pclk_div = ilog2(PERI_ACLK_HZ / PERI_PCLK_HZ);
|
2015-11-17 06:20:16 +00:00
|
|
|
assert((1 << pclk_div) * PERI_PCLK_HZ ==
|
|
|
|
PERI_ACLK_HZ && pclk_div < 0x8);
|
|
|
|
|
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[10],
|
2017-05-15 12:52:15 +00:00
|
|
|
PERI_PLL_SEL_MASK | PERI_PCLK_DIV_MASK |
|
|
|
|
PERI_HCLK_DIV_MASK | PERI_ACLK_DIV_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
PERI_PLL_GPLL << PERI_PLL_SEL_SHIFT |
|
|
|
|
pclk_div << PERI_PCLK_DIV_SHIFT |
|
|
|
|
hclk_div << PERI_HCLK_DIV_SHIFT |
|
|
|
|
aclk_div << PERI_ACLK_DIV_SHIFT);
|
|
|
|
|
|
|
|
/* PLL enter normal-mode */
|
|
|
|
rk_clrsetreg(&cru->cru_mode_con,
|
2017-05-15 12:52:15 +00:00
|
|
|
GPLL_MODE_MASK | APLL_MODE_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
GPLL_MODE_NORM << GPLL_MODE_SHIFT |
|
|
|
|
APLL_MODE_NORM << APLL_MODE_SHIFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get pll rate by id */
|
|
|
|
static uint32_t rkclk_pll_get_rate(struct rk3036_cru *cru,
|
|
|
|
enum rk_clk_id clk_id)
|
|
|
|
{
|
|
|
|
uint32_t refdiv, fbdiv, postdiv1, postdiv2;
|
|
|
|
uint32_t con;
|
|
|
|
int pll_id = rk_pll_id(clk_id);
|
|
|
|
struct rk3036_pll *pll = &cru->pll[pll_id];
|
|
|
|
static u8 clk_shift[CLK_COUNT] = {
|
|
|
|
0xff, APLL_MODE_SHIFT, DPLL_MODE_SHIFT, 0xff,
|
|
|
|
GPLL_MODE_SHIFT, 0xff
|
|
|
|
};
|
2017-05-15 12:52:15 +00:00
|
|
|
static u32 clk_mask[CLK_COUNT] = {
|
|
|
|
0xffffffff, APLL_MODE_MASK, DPLL_MODE_MASK, 0xffffffff,
|
|
|
|
GPLL_MODE_MASK, 0xffffffff
|
2015-11-17 06:20:16 +00:00
|
|
|
};
|
|
|
|
uint shift;
|
|
|
|
uint mask;
|
|
|
|
|
|
|
|
con = readl(&cru->cru_mode_con);
|
|
|
|
shift = clk_shift[clk_id];
|
|
|
|
mask = clk_mask[clk_id];
|
|
|
|
|
2017-05-15 12:52:15 +00:00
|
|
|
switch ((con & mask) >> shift) {
|
2015-11-17 06:20:16 +00:00
|
|
|
case GPLL_MODE_SLOW:
|
|
|
|
return OSC_HZ;
|
|
|
|
case GPLL_MODE_NORM:
|
|
|
|
|
|
|
|
/* normal mode */
|
|
|
|
con = readl(&pll->con0);
|
2017-05-15 12:52:15 +00:00
|
|
|
postdiv1 = (con & PLL_POSTDIV1_MASK) >> PLL_POSTDIV1_SHIFT;
|
|
|
|
fbdiv = (con & PLL_FBDIV_MASK) >> PLL_FBDIV_SHIFT;
|
2015-11-17 06:20:16 +00:00
|
|
|
con = readl(&pll->con1);
|
2017-05-15 12:52:15 +00:00
|
|
|
postdiv2 = (con & PLL_POSTDIV2_MASK) >> PLL_POSTDIV2_SHIFT;
|
|
|
|
refdiv = (con & PLL_REFDIV_MASK) >> PLL_REFDIV_SHIFT;
|
2015-11-17 06:20:16 +00:00
|
|
|
return (24 * fbdiv / (refdiv * postdiv1 * postdiv2)) * 1000000;
|
|
|
|
case GPLL_MODE_DEEP:
|
|
|
|
default:
|
|
|
|
return 32768;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulong rockchip_mmc_get_clk(struct rk3036_cru *cru, uint clk_general_rate,
|
2016-01-22 02:43:38 +00:00
|
|
|
int periph)
|
2015-11-17 06:20:16 +00:00
|
|
|
{
|
|
|
|
uint src_rate;
|
|
|
|
uint div, mux;
|
|
|
|
u32 con;
|
|
|
|
|
|
|
|
switch (periph) {
|
2016-01-22 02:43:38 +00:00
|
|
|
case HCLK_EMMC:
|
2017-04-16 09:44:43 +00:00
|
|
|
case SCLK_EMMC:
|
2015-11-17 06:20:16 +00:00
|
|
|
con = readl(&cru->cru_clksel_con[12]);
|
2017-05-15 12:52:15 +00:00
|
|
|
mux = (con & EMMC_PLL_MASK) >> EMMC_PLL_SHIFT;
|
|
|
|
div = (con & EMMC_DIV_MASK) >> EMMC_DIV_SHIFT;
|
2015-11-17 06:20:16 +00:00
|
|
|
break;
|
2016-01-22 02:43:38 +00:00
|
|
|
case HCLK_SDIO:
|
2017-04-16 09:44:43 +00:00
|
|
|
case SCLK_SDIO:
|
2015-11-17 06:20:16 +00:00
|
|
|
con = readl(&cru->cru_clksel_con[12]);
|
2017-05-15 12:52:15 +00:00
|
|
|
mux = (con & MMC0_PLL_MASK) >> MMC0_PLL_SHIFT;
|
|
|
|
div = (con & MMC0_DIV_MASK) >> MMC0_DIV_SHIFT;
|
2015-11-17 06:20:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
src_rate = mux == EMMC_SEL_24M ? OSC_HZ : clk_general_rate;
|
2017-07-27 04:54:01 +00:00
|
|
|
return DIV_TO_RATE(src_rate, div) / 2;
|
2015-11-17 06:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ulong rockchip_mmc_set_clk(struct rk3036_cru *cru, uint clk_general_rate,
|
2016-01-22 02:43:38 +00:00
|
|
|
int periph, uint freq)
|
2015-11-17 06:20:16 +00:00
|
|
|
{
|
|
|
|
int src_clk_div;
|
|
|
|
int mux;
|
|
|
|
|
|
|
|
debug("%s: clk_general_rate=%u\n", __func__, clk_general_rate);
|
|
|
|
|
|
|
|
/* mmc clock auto divide 2 in internal */
|
2017-07-27 04:54:01 +00:00
|
|
|
src_clk_div = DIV_ROUND_UP(clk_general_rate / 2, freq);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2017-07-27 04:54:02 +00:00
|
|
|
if (src_clk_div > 128) {
|
2017-07-27 04:54:01 +00:00
|
|
|
src_clk_div = DIV_ROUND_UP(OSC_HZ / 2, freq);
|
2017-07-27 04:54:02 +00:00
|
|
|
assert(src_clk_div - 1 < 128);
|
2015-11-17 06:20:16 +00:00
|
|
|
mux = EMMC_SEL_24M;
|
|
|
|
} else {
|
|
|
|
mux = EMMC_SEL_GPLL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (periph) {
|
2016-01-22 02:43:38 +00:00
|
|
|
case HCLK_EMMC:
|
2017-04-16 09:44:43 +00:00
|
|
|
case SCLK_EMMC:
|
2015-11-17 06:20:16 +00:00
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[12],
|
2017-05-15 12:52:15 +00:00
|
|
|
EMMC_PLL_MASK | EMMC_DIV_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
mux << EMMC_PLL_SHIFT |
|
|
|
|
(src_clk_div - 1) << EMMC_DIV_SHIFT);
|
|
|
|
break;
|
2016-01-22 02:43:38 +00:00
|
|
|
case HCLK_SDIO:
|
2017-04-16 09:44:43 +00:00
|
|
|
case SCLK_SDIO:
|
2015-11-17 06:20:16 +00:00
|
|
|
rk_clrsetreg(&cru->cru_clksel_con[11],
|
2017-05-15 12:52:15 +00:00
|
|
|
MMC0_PLL_MASK | MMC0_DIV_MASK,
|
2015-11-17 06:20:16 +00:00
|
|
|
mux << MMC0_PLL_SHIFT |
|
|
|
|
(src_clk_div - 1) << MMC0_DIV_SHIFT);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rockchip_mmc_get_clk(cru, clk_general_rate, periph);
|
|
|
|
}
|
|
|
|
|
2016-06-17 15:44:00 +00:00
|
|
|
static ulong rk3036_clk_get_rate(struct clk *clk)
|
2015-11-17 06:20:16 +00:00
|
|
|
{
|
2016-06-17 15:44:00 +00:00
|
|
|
struct rk3036_clk_priv *priv = dev_get_priv(clk->dev);
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2016-06-17 15:44:00 +00:00
|
|
|
switch (clk->id) {
|
|
|
|
case 0 ... 63:
|
|
|
|
return rkclk_pll_get_rate(priv->cru, clk->id);
|
|
|
|
default:
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2015-11-17 06:20:16 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 15:44:00 +00:00
|
|
|
static ulong rk3036_clk_set_rate(struct clk *clk, ulong rate)
|
2015-11-17 06:20:16 +00:00
|
|
|
{
|
2016-06-17 15:44:00 +00:00
|
|
|
struct rk3036_clk_priv *priv = dev_get_priv(clk->dev);
|
|
|
|
ulong new_rate, gclk_rate;
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2016-06-17 15:44:00 +00:00
|
|
|
gclk_rate = rkclk_pll_get_rate(priv->cru, CLK_GENERAL);
|
|
|
|
switch (clk->id) {
|
|
|
|
case 0 ... 63:
|
|
|
|
return 0;
|
2016-01-22 02:43:38 +00:00
|
|
|
case HCLK_EMMC:
|
2017-04-16 09:44:43 +00:00
|
|
|
case SCLK_EMMC:
|
2016-06-17 15:44:00 +00:00
|
|
|
new_rate = rockchip_mmc_set_clk(priv->cru, gclk_rate,
|
|
|
|
clk->id, rate);
|
2015-11-17 06:20:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct clk_ops rk3036_clk_ops = {
|
|
|
|
.get_rate = rk3036_clk_get_rate,
|
|
|
|
.set_rate = rk3036_clk_set_rate,
|
|
|
|
};
|
|
|
|
|
2018-04-24 03:27:06 +00:00
|
|
|
static int rk3036_clk_ofdata_to_platdata(struct udevice *dev)
|
2015-11-17 06:20:16 +00:00
|
|
|
{
|
|
|
|
struct rk3036_clk_priv *priv = dev_get_priv(dev);
|
|
|
|
|
2018-02-11 03:53:05 +00:00
|
|
|
priv->cru = dev_read_addr_ptr(dev);
|
2018-04-24 03:27:06 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rk3036_clk_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct rk3036_clk_priv *priv = dev_get_priv(dev);
|
|
|
|
|
2015-11-17 06:20:16 +00:00
|
|
|
rkclk_init(priv->cru);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rk3036_clk_bind(struct udevice *dev)
|
|
|
|
{
|
2016-06-17 15:44:00 +00:00
|
|
|
int ret;
|
2017-11-03 07:16:13 +00:00
|
|
|
struct udevice *sys_child;
|
|
|
|
struct sysreset_reg *priv;
|
2015-11-17 06:20:16 +00:00
|
|
|
|
|
|
|
/* The reset driver does not have a device node, so bind it here */
|
2017-11-03 07:16:13 +00:00
|
|
|
ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
|
|
|
|
&sys_child);
|
|
|
|
if (ret) {
|
|
|
|
debug("Warning: No sysreset driver: ret=%d\n", ret);
|
|
|
|
} else {
|
|
|
|
priv = malloc(sizeof(struct sysreset_reg));
|
|
|
|
priv->glb_srst_fst_value = offsetof(struct rk3036_cru,
|
|
|
|
cru_glb_srst_fst_value);
|
|
|
|
priv->glb_srst_snd_value = offsetof(struct rk3036_cru,
|
|
|
|
cru_glb_srst_snd_value);
|
|
|
|
sys_child->priv = priv;
|
|
|
|
}
|
2015-11-17 06:20:16 +00:00
|
|
|
|
2017-12-19 10:22:38 +00:00
|
|
|
#if CONFIG_IS_ENABLED(CONFIG_RESET_ROCKCHIP)
|
|
|
|
ret = offsetof(struct rk3036_cru, cru_softrst_con[0]);
|
|
|
|
ret = rockchip_reset_bind(dev, ret, 9);
|
|
|
|
if (ret)
|
|
|
|
debug("Warning: software reset driver bind faile\n");
|
|
|
|
#endif
|
|
|
|
|
2015-11-17 06:20:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id rk3036_clk_ids[] = {
|
|
|
|
{ .compatible = "rockchip,rk3036-cru" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-10-02 02:04:50 +00:00
|
|
|
U_BOOT_DRIVER(rockchip_rk3036_cru) = {
|
2015-11-17 06:20:16 +00:00
|
|
|
.name = "clk_rk3036",
|
|
|
|
.id = UCLASS_CLK,
|
|
|
|
.of_match = rk3036_clk_ids,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct rk3036_clk_priv),
|
2018-04-24 03:27:06 +00:00
|
|
|
.ofdata_to_platdata = rk3036_clk_ofdata_to_platdata,
|
2015-11-17 06:20:16 +00:00
|
|
|
.ops = &rk3036_clk_ops,
|
|
|
|
.bind = rk3036_clk_bind,
|
|
|
|
.probe = rk3036_clk_probe,
|
|
|
|
};
|