This is first big chunk of Rockchip clock-related changes for 4.7.

Main change is probably the added support for the new rk3399 soc
 and necessary infrastructure changes surrounding it.
 
 The biggest chunk is probably that clock code is now able to
 handle multiple clock providers in one system, as the rk3399
 has two of those. A general one and another smaller one in a
 separate power domain. The rk3399 also uses another new pll type.
 Thankfully it just fits nicely into our current structure.
 It also needs some parts like the cpuclk mux parameters to be
 a bit more flexible and an new fractional divider subtype without
 gate.
 
 Apart from this big change we have some more fixes and removal
 of forgotten variables.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABCAAGBQJXDHdWAAoJEPOmecmc0R2BrSAIAIf3g2D84lSEYPDfjLCPHKWQ
 vdmBG/J53+OqFfk0IgYFPcgFfXsgXX0iv34WgtxDOQ1uF+uPDC1KQFlyNrg3E8Mu
 7yUzHewphWumgtun/niThjhKTH+fRAZV4koo35KndXpsOXAy87uW+PZc+0f33ocD
 FzF8mu3eQGsXNkZ3NM/BlLN38gfQVFLiiBNxg/yPmIGqI4VcWJPVUWr51nOURL78
 5NozCjr1giUXPazat0IzsvGdO9szben7al2MixufnpkojjQkB+C8r2lxVXPSC7xH
 EWHPj8WVS0eLYLPW6T3t27zvLNRuORzv5y7cHS8TMc4en1qFS5NJ56ruRv7SzNQ=
 =kC1q
 -----END PGP SIGNATURE-----

Merge tag 'v4.7-rockchip-clk1' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into clk-next

Pull rockchip clk updates from Heiko Stuebner:

This is first big chunk of Rockchip clock-related changes for 4.7.

Main change is probably the added support for the new rk3399 soc
and necessary infrastructure changes surrounding it.

The biggest chunk is probably that clock code is now able to
handle multiple clock providers in one system, as the rk3399
has two of those. A general one and another smaller one in a
separate power domain. The rk3399 also uses another new pll type.
Thankfully it just fits nicely into our current structure.
It also needs some parts like the cpuclk mux parameters to be
a bit more flexible and an new fractional divider subtype without
gate.

Apart from this big change we have some more fixes and removal
of forgotten variables.

* tag 'v4.7-rockchip-clk1' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip:
  clk: rockchip: add clock controller for the RK3399
  dt-bindings: add bindings for rk3399 clock controller
  clk: rockchip: add dt-binding header for rk3399
  clk: rockchip: release io resource when failing to init clk
  clk: rockchip: remove redundant checking of device_node
  clk: rockchip: fix warning reported by kernel-doc
  clk: rockchip: remove mux_core_reg from rockchip_cpuclk_reg_data
  clk: rockchip: add new pll-type for rk3399 and similar socs
  clk: rockchip: Add support for multiple clock providers
  clk: rockchip: allow varying mux parameters for cpuclk pll-sources
  clk: rockchip: add a COMPOSITE_FRACMUX_NOGATE type
This commit is contained in:
Stephen Boyd 2016-04-15 15:47:54 -07:00
commit ab98e20af5
13 changed files with 2945 additions and 136 deletions

View File

@ -0,0 +1,62 @@
* Rockchip RK3399 Clock and Reset Unit
The RK3399 clock controller generates and supplies clock to various
controllers within the SoC and also implements a reset controller for SoC
peripherals.
Required Properties:
- compatible: PMU for CRU should be "rockchip,rk3399-pmucru"
- compatible: CRU should be "rockchip,rk3399-cru"
- reg: physical base address of the controller and length of memory mapped
region.
- #clock-cells: should be 1.
- #reset-cells: should be 1.
Each clock is assigned an identifier and client nodes can use this identifier
to specify the clock which they consume. All available clocks are defined as
preprocessor macros in the dt-bindings/clock/rk3399-cru.h headers and can be
used in device tree sources. Similar macros exist for the reset sources in
these files.
External clocks:
There are several clocks that are generated outside the SoC. It is expected
that they are defined using standard clock bindings with following
clock-output-names:
- "xin24m" - crystal input - required,
- "xin32k" - rtc clock - optional,
- "clkin_gmac" - external GMAC clock - optional,
- "clkin_i2s" - external I2S clock - optional,
- "pclkin_cif" - external ISP clock - optional,
- "clk_usbphy0_480m" - output clock of the pll in the usbphy0
- "clk_usbphy1_480m" - output clock of the pll in the usbphy1
Example: Clock controller node:
pmucru: pmu-clock-controller@ff750000 {
compatible = "rockchip,rk3399-pmucru";
reg = <0x0 0xff750000 0x0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
cru: clock-controller@ff760000 {
compatible = "rockchip,rk3399-cru";
reg = <0x0 0xff760000 0x0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
Example: UART controller node that consumes the clock generated by the clock
controller:
uart0: serial@ff1a0000 {
compatible = "rockchip,rk3399-uart", "snps,dw-apb-uart";
reg = <0x0 0xff180000 0x0 0x100>;
clocks = <&cru SCLK_UART0>, <&cru PCLK_UART0>;
clock-names = "baudclk", "apb_pclk";
interrupts = <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
reg-shift = <2>;
reg-io-width = <4>;
};

View File

@ -15,3 +15,4 @@ obj-y += clk-rk3188.o
obj-y += clk-rk3228.o
obj-y += clk-rk3288.o
obj-y += clk-rk3368.o
obj-y += clk-rk3399.o

View File

@ -158,12 +158,16 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
writel(HIWORD_UPDATE(alt_div, reg_data->div_core_mask,
reg_data->div_core_shift) |
HIWORD_UPDATE(1, 1, reg_data->mux_core_shift),
HIWORD_UPDATE(reg_data->mux_core_alt,
reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg);
} else {
/* select alternate parent */
writel(HIWORD_UPDATE(1, 1, reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg);
writel(HIWORD_UPDATE(reg_data->mux_core_alt,
reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg);
}
spin_unlock_irqrestore(cpuclk->lock, flags);
@ -198,7 +202,9 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk,
writel(HIWORD_UPDATE(0, reg_data->div_core_mask,
reg_data->div_core_shift) |
HIWORD_UPDATE(0, 1, reg_data->mux_core_shift),
HIWORD_UPDATE(reg_data->mux_core_main,
reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg);
if (ndata->old_rate > ndata->new_rate)
@ -252,7 +258,7 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
return ERR_PTR(-ENOMEM);
init.name = name;
init.parent_names = &parent_names[0];
init.parent_names = &parent_names[reg_data->mux_core_main];
init.num_parents = 1;
init.ops = &rockchip_cpuclk_ops;
@ -270,10 +276,10 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
cpuclk->clk_nb.notifier_call = rockchip_cpuclk_notifier_cb;
cpuclk->hw.init = &init;
cpuclk->alt_parent = __clk_lookup(parent_names[1]);
cpuclk->alt_parent = __clk_lookup(parent_names[reg_data->mux_core_alt]);
if (!cpuclk->alt_parent) {
pr_err("%s: could not lookup alternate parent\n",
__func__);
pr_err("%s: could not lookup alternate parent: (%d)\n",
__func__, reg_data->mux_core_alt);
ret = -EINVAL;
goto free_cpuclk;
}
@ -285,10 +291,11 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
goto free_cpuclk;
}
clk = __clk_lookup(parent_names[0]);
clk = __clk_lookup(parent_names[reg_data->mux_core_main]);
if (!clk) {
pr_err("%s: could not lookup parent clock %s\n",
__func__, parent_names[0]);
pr_err("%s: could not lookup parent clock: (%d) %s\n",
__func__, reg_data->mux_core_main,
parent_names[reg_data->mux_core_main]);
ret = -EINVAL;
goto free_alt_parent;
}

View File

@ -46,6 +46,8 @@ struct rockchip_clk_pll {
const struct rockchip_pll_rate_table *rate_table;
unsigned int rate_count;
spinlock_t *lock;
struct rockchip_clk_provider *ctx;
};
#define to_rockchip_clk_pll(_hw) container_of(_hw, struct rockchip_clk_pll, hw)
@ -90,7 +92,7 @@ static long rockchip_pll_round_rate(struct clk_hw *hw,
*/
static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll)
{
struct regmap *grf = rockchip_clk_get_grf();
struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
unsigned int val;
int delay = 24000000, ret;
@ -251,7 +253,7 @@ static int rockchip_rk3036_pll_set_rate(struct clk_hw *hw, unsigned long drate,
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
const struct rockchip_pll_rate_table *rate;
unsigned long old_rate = rockchip_rk3036_pll_recalc_rate(hw, prate);
struct regmap *grf = rockchip_clk_get_grf();
struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
if (IS_ERR(grf)) {
pr_debug("%s: grf regmap not available, aborting rate change\n",
@ -490,7 +492,7 @@ static int rockchip_rk3066_pll_set_rate(struct clk_hw *hw, unsigned long drate,
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
const struct rockchip_pll_rate_table *rate;
unsigned long old_rate = rockchip_rk3066_pll_recalc_rate(hw, prate);
struct regmap *grf = rockchip_clk_get_grf();
struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
if (IS_ERR(grf)) {
pr_debug("%s: grf regmap not available, aborting rate change\n",
@ -563,7 +565,7 @@ static void rockchip_rk3066_pll_init(struct clk_hw *hw)
rate->no, cur.no, rate->nf, cur.nf, rate->nb, cur.nb);
if (rate->nr != cur.nr || rate->no != cur.no || rate->nf != cur.nf
|| rate->nb != cur.nb) {
struct regmap *grf = rockchip_clk_get_grf();
struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
if (IS_ERR(grf))
return;
@ -591,16 +593,278 @@ static const struct clk_ops rockchip_rk3066_pll_clk_ops = {
.init = rockchip_rk3066_pll_init,
};
/**
* PLL used in RK3399
*/
#define RK3399_PLLCON(i) (i * 0x4)
#define RK3399_PLLCON0_FBDIV_MASK 0xfff
#define RK3399_PLLCON0_FBDIV_SHIFT 0
#define RK3399_PLLCON1_REFDIV_MASK 0x3f
#define RK3399_PLLCON1_REFDIV_SHIFT 0
#define RK3399_PLLCON1_POSTDIV1_MASK 0x7
#define RK3399_PLLCON1_POSTDIV1_SHIFT 8
#define RK3399_PLLCON1_POSTDIV2_MASK 0x7
#define RK3399_PLLCON1_POSTDIV2_SHIFT 12
#define RK3399_PLLCON2_FRAC_MASK 0xffffff
#define RK3399_PLLCON2_FRAC_SHIFT 0
#define RK3399_PLLCON2_LOCK_STATUS BIT(31)
#define RK3399_PLLCON3_PWRDOWN BIT(0)
#define RK3399_PLLCON3_DSMPD_MASK 0x1
#define RK3399_PLLCON3_DSMPD_SHIFT 3
static int rockchip_rk3399_pll_wait_lock(struct rockchip_clk_pll *pll)
{
u32 pllcon;
int delay = 24000000;
/* poll check the lock status in rk3399 xPLLCON2 */
while (delay > 0) {
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(2));
if (pllcon & RK3399_PLLCON2_LOCK_STATUS)
return 0;
delay--;
}
pr_err("%s: timeout waiting for pll to lock\n", __func__);
return -ETIMEDOUT;
}
static void rockchip_rk3399_pll_get_params(struct rockchip_clk_pll *pll,
struct rockchip_pll_rate_table *rate)
{
u32 pllcon;
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(0));
rate->fbdiv = ((pllcon >> RK3399_PLLCON0_FBDIV_SHIFT)
& RK3399_PLLCON0_FBDIV_MASK);
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(1));
rate->refdiv = ((pllcon >> RK3399_PLLCON1_REFDIV_SHIFT)
& RK3399_PLLCON1_REFDIV_MASK);
rate->postdiv1 = ((pllcon >> RK3399_PLLCON1_POSTDIV1_SHIFT)
& RK3399_PLLCON1_POSTDIV1_MASK);
rate->postdiv2 = ((pllcon >> RK3399_PLLCON1_POSTDIV2_SHIFT)
& RK3399_PLLCON1_POSTDIV2_MASK);
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(2));
rate->frac = ((pllcon >> RK3399_PLLCON2_FRAC_SHIFT)
& RK3399_PLLCON2_FRAC_MASK);
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(3));
rate->dsmpd = ((pllcon >> RK3399_PLLCON3_DSMPD_SHIFT)
& RK3399_PLLCON3_DSMPD_MASK);
}
static unsigned long rockchip_rk3399_pll_recalc_rate(struct clk_hw *hw,
unsigned long prate)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
struct rockchip_pll_rate_table cur;
u64 rate64 = prate;
rockchip_rk3399_pll_get_params(pll, &cur);
rate64 *= cur.fbdiv;
do_div(rate64, cur.refdiv);
if (cur.dsmpd == 0) {
/* fractional mode */
u64 frac_rate64 = prate * cur.frac;
do_div(frac_rate64, cur.refdiv);
rate64 += frac_rate64 >> 24;
}
do_div(rate64, cur.postdiv1);
do_div(rate64, cur.postdiv2);
return (unsigned long)rate64;
}
static int rockchip_rk3399_pll_set_params(struct rockchip_clk_pll *pll,
const struct rockchip_pll_rate_table *rate)
{
const struct clk_ops *pll_mux_ops = pll->pll_mux_ops;
struct clk_mux *pll_mux = &pll->pll_mux;
struct rockchip_pll_rate_table cur;
u32 pllcon;
int rate_change_remuxed = 0;
int cur_parent;
int ret;
pr_debug("%s: rate settings for %lu fbdiv: %d, postdiv1: %d, refdiv: %d, postdiv2: %d, dsmpd: %d, frac: %d\n",
__func__, rate->rate, rate->fbdiv, rate->postdiv1, rate->refdiv,
rate->postdiv2, rate->dsmpd, rate->frac);
rockchip_rk3399_pll_get_params(pll, &cur);
cur.rate = 0;
cur_parent = pll_mux_ops->get_parent(&pll_mux->hw);
if (cur_parent == PLL_MODE_NORM) {
pll_mux_ops->set_parent(&pll_mux->hw, PLL_MODE_SLOW);
rate_change_remuxed = 1;
}
/* update pll values */
writel_relaxed(HIWORD_UPDATE(rate->fbdiv, RK3399_PLLCON0_FBDIV_MASK,
RK3399_PLLCON0_FBDIV_SHIFT),
pll->reg_base + RK3399_PLLCON(0));
writel_relaxed(HIWORD_UPDATE(rate->refdiv, RK3399_PLLCON1_REFDIV_MASK,
RK3399_PLLCON1_REFDIV_SHIFT) |
HIWORD_UPDATE(rate->postdiv1, RK3399_PLLCON1_POSTDIV1_MASK,
RK3399_PLLCON1_POSTDIV1_SHIFT) |
HIWORD_UPDATE(rate->postdiv2, RK3399_PLLCON1_POSTDIV2_MASK,
RK3399_PLLCON1_POSTDIV2_SHIFT),
pll->reg_base + RK3399_PLLCON(1));
/* xPLL CON2 is not HIWORD_MASK */
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(2));
pllcon &= ~(RK3399_PLLCON2_FRAC_MASK << RK3399_PLLCON2_FRAC_SHIFT);
pllcon |= rate->frac << RK3399_PLLCON2_FRAC_SHIFT;
writel_relaxed(pllcon, pll->reg_base + RK3399_PLLCON(2));
writel_relaxed(HIWORD_UPDATE(rate->dsmpd, RK3399_PLLCON3_DSMPD_MASK,
RK3399_PLLCON3_DSMPD_SHIFT),
pll->reg_base + RK3399_PLLCON(3));
/* wait for the pll to lock */
ret = rockchip_rk3399_pll_wait_lock(pll);
if (ret) {
pr_warn("%s: pll update unsuccessful, trying to restore old params\n",
__func__);
rockchip_rk3399_pll_set_params(pll, &cur);
}
if (rate_change_remuxed)
pll_mux_ops->set_parent(&pll_mux->hw, PLL_MODE_NORM);
return ret;
}
static int rockchip_rk3399_pll_set_rate(struct clk_hw *hw, unsigned long drate,
unsigned long prate)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
const struct rockchip_pll_rate_table *rate;
unsigned long old_rate = rockchip_rk3399_pll_recalc_rate(hw, prate);
pr_debug("%s: changing %s from %lu to %lu with a parent rate of %lu\n",
__func__, __clk_get_name(hw->clk), old_rate, drate, prate);
/* Get required rate settings from table */
rate = rockchip_get_pll_settings(pll, drate);
if (!rate) {
pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__,
drate, __clk_get_name(hw->clk));
return -EINVAL;
}
return rockchip_rk3399_pll_set_params(pll, rate);
}
static int rockchip_rk3399_pll_enable(struct clk_hw *hw)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
writel(HIWORD_UPDATE(0, RK3399_PLLCON3_PWRDOWN, 0),
pll->reg_base + RK3399_PLLCON(3));
return 0;
}
static void rockchip_rk3399_pll_disable(struct clk_hw *hw)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
writel(HIWORD_UPDATE(RK3399_PLLCON3_PWRDOWN,
RK3399_PLLCON3_PWRDOWN, 0),
pll->reg_base + RK3399_PLLCON(3));
}
static int rockchip_rk3399_pll_is_enabled(struct clk_hw *hw)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
u32 pllcon = readl(pll->reg_base + RK3399_PLLCON(3));
return !(pllcon & RK3399_PLLCON3_PWRDOWN);
}
static void rockchip_rk3399_pll_init(struct clk_hw *hw)
{
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
const struct rockchip_pll_rate_table *rate;
struct rockchip_pll_rate_table cur;
unsigned long drate;
if (!(pll->flags & ROCKCHIP_PLL_SYNC_RATE))
return;
drate = clk_hw_get_rate(hw);
rate = rockchip_get_pll_settings(pll, drate);
/* when no rate setting for the current rate, rely on clk_set_rate */
if (!rate)
return;
rockchip_rk3399_pll_get_params(pll, &cur);
pr_debug("%s: pll %s@%lu: Hz\n", __func__, __clk_get_name(hw->clk),
drate);
pr_debug("old - fbdiv: %d, postdiv1: %d, refdiv: %d, postdiv2: %d, dsmpd: %d, frac: %d\n",
cur.fbdiv, cur.postdiv1, cur.refdiv, cur.postdiv2,
cur.dsmpd, cur.frac);
pr_debug("new - fbdiv: %d, postdiv1: %d, refdiv: %d, postdiv2: %d, dsmpd: %d, frac: %d\n",
rate->fbdiv, rate->postdiv1, rate->refdiv, rate->postdiv2,
rate->dsmpd, rate->frac);
if (rate->fbdiv != cur.fbdiv || rate->postdiv1 != cur.postdiv1 ||
rate->refdiv != cur.refdiv || rate->postdiv2 != cur.postdiv2 ||
rate->dsmpd != cur.dsmpd || rate->frac != cur.frac) {
struct clk *parent = clk_get_parent(hw->clk);
if (!parent) {
pr_warn("%s: parent of %s not available\n",
__func__, __clk_get_name(hw->clk));
return;
}
pr_debug("%s: pll %s: rate params do not match rate table, adjusting\n",
__func__, __clk_get_name(hw->clk));
rockchip_rk3399_pll_set_params(pll, rate);
}
}
static const struct clk_ops rockchip_rk3399_pll_clk_norate_ops = {
.recalc_rate = rockchip_rk3399_pll_recalc_rate,
.enable = rockchip_rk3399_pll_enable,
.disable = rockchip_rk3399_pll_disable,
.is_enabled = rockchip_rk3399_pll_is_enabled,
};
static const struct clk_ops rockchip_rk3399_pll_clk_ops = {
.recalc_rate = rockchip_rk3399_pll_recalc_rate,
.round_rate = rockchip_pll_round_rate,
.set_rate = rockchip_rk3399_pll_set_rate,
.enable = rockchip_rk3399_pll_enable,
.disable = rockchip_rk3399_pll_disable,
.is_enabled = rockchip_rk3399_pll_is_enabled,
.init = rockchip_rk3399_pll_init,
};
/*
* Common registering of pll clocks
*/
struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type,
struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
enum rockchip_pll_type pll_type,
const char *name, const char *const *parent_names,
u8 num_parents, void __iomem *base, int con_offset,
int grf_lock_offset, int lock_shift, int mode_offset,
int mode_shift, struct rockchip_pll_rate_table *rate_table,
u8 clk_pll_flags, spinlock_t *lock)
u8 num_parents, int con_offset, int grf_lock_offset,
int lock_shift, int mode_offset, int mode_shift,
struct rockchip_pll_rate_table *rate_table,
u8 clk_pll_flags)
{
const char *pll_parents[3];
struct clk_init_data init;
@ -624,14 +888,16 @@ struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type,
/* create the mux on top of the real pll */
pll->pll_mux_ops = &clk_mux_ops;
pll_mux = &pll->pll_mux;
pll_mux->reg = base + mode_offset;
pll_mux->reg = ctx->reg_base + mode_offset;
pll_mux->shift = mode_shift;
pll_mux->mask = PLL_MODE_MASK;
pll_mux->flags = 0;
pll_mux->lock = lock;
pll_mux->lock = &ctx->lock;
pll_mux->hw.init = &init;
if (pll_type == pll_rk3036 || pll_type == pll_rk3066)
if (pll_type == pll_rk3036 ||
pll_type == pll_rk3066 ||
pll_type == pll_rk3399)
pll_mux->flags |= CLK_MUX_HIWORD_MASK;
/* the actual muxing is xin24m, pll-output, xin32k */
@ -688,6 +954,12 @@ struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type,
else
init.ops = &rockchip_rk3066_pll_clk_ops;
break;
case pll_rk3399:
if (!pll->rate_table)
init.ops = &rockchip_rk3399_pll_clk_norate_ops;
else
init.ops = &rockchip_rk3399_pll_clk_ops;
break;
default:
pr_warn("%s: Unknown pll type for pll clk %s\n",
__func__, name);
@ -695,11 +967,12 @@ struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type,
pll->hw.init = &init;
pll->type = pll_type;
pll->reg_base = base + con_offset;
pll->reg_base = ctx->reg_base + con_offset;
pll->lock_offset = grf_lock_offset;
pll->lock_shift = lock_shift;
pll->flags = clk_pll_flags;
pll->lock = lock;
pll->lock = &ctx->lock;
pll->ctx = ctx;
pll_clk = clk_register(NULL, &pll->hw);
if (IS_ERR(pll_clk)) {

View File

@ -113,7 +113,10 @@ static const struct rockchip_cpuclk_reg_data rk3036_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 7,
.mux_core_mask = 0x1,
};
PNAME(mux_pll_p) = { "xin24m", "xin24m" };
@ -437,6 +440,7 @@ static const char *const rk3036_critical_clocks[] __initconst = {
static void __init rk3036_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
void __iomem *reg_base;
struct clk *clk;
@ -446,22 +450,27 @@ static void __init rk3036_clk_init(struct device_node *np)
return;
}
rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
iounmap(reg_base);
return;
}
clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
if (IS_ERR(clk))
pr_warn("%s: could not register clock usb480m: %ld\n",
__func__, PTR_ERR(clk));
rockchip_clk_register_plls(rk3036_pll_clks,
rockchip_clk_register_plls(ctx, rk3036_pll_clks,
ARRAY_SIZE(rk3036_pll_clks),
RK3036_GRF_SOC_STATUS0);
rockchip_clk_register_branches(rk3036_clk_branches,
rockchip_clk_register_branches(ctx, rk3036_clk_branches,
ARRAY_SIZE(rk3036_clk_branches));
rockchip_clk_protect_critical(rk3036_critical_clocks,
ARRAY_SIZE(rk3036_critical_clocks));
rockchip_clk_register_armclk(ARMCLK, "armclk",
rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
&rk3036_cpuclk_data, rk3036_cpuclk_rates,
ARRAY_SIZE(rk3036_cpuclk_rates));
@ -469,6 +478,8 @@ static void __init rk3036_clk_init(struct device_node *np)
rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);
rockchip_register_restart_notifier(RK2928_GLB_SRST_FST, NULL);
rockchip_register_restart_notifier(ctx, RK2928_GLB_SRST_FST, NULL);
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3036_cru, "rockchip,rk3036-cru", rk3036_clk_init);

View File

@ -155,7 +155,10 @@ static const struct rockchip_cpuclk_reg_data rk3066_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 8,
.mux_core_mask = 0x1,
};
#define RK3188_DIV_ACLK_CORE_MASK 0x7
@ -191,7 +194,10 @@ static const struct rockchip_cpuclk_reg_data rk3188_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 9,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 8,
.mux_core_mask = 0x1,
};
PNAME(mux_pll_p) = { "xin24m", "xin32k" };
@ -753,57 +759,75 @@ static const char *const rk3188_critical_clocks[] __initconst = {
"hclk_cpubus"
};
static void __init rk3188_common_clk_init(struct device_node *np)
static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
void __iomem *reg_base;
reg_base = of_iomap(np, 0);
if (!reg_base) {
pr_err("%s: could not map cru region\n", __func__);
return;
return ERR_PTR(-ENOMEM);
}
rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
iounmap(reg_base);
return ERR_PTR(-ENOMEM);
}
rockchip_clk_register_branches(common_clk_branches,
rockchip_clk_register_branches(ctx, common_clk_branches,
ARRAY_SIZE(common_clk_branches));
rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);
rockchip_register_restart_notifier(RK2928_GLB_SRST_FST, NULL);
rockchip_register_restart_notifier(ctx, RK2928_GLB_SRST_FST, NULL);
return ctx;
}
static void __init rk3066a_clk_init(struct device_node *np)
{
rk3188_common_clk_init(np);
rockchip_clk_register_plls(rk3066_pll_clks,
struct rockchip_clk_provider *ctx;
ctx = rk3188_common_clk_init(np);
if (IS_ERR(ctx))
return;
rockchip_clk_register_plls(ctx, rk3066_pll_clks,
ARRAY_SIZE(rk3066_pll_clks),
RK3066_GRF_SOC_STATUS);
rockchip_clk_register_branches(rk3066a_clk_branches,
rockchip_clk_register_branches(ctx, rk3066a_clk_branches,
ARRAY_SIZE(rk3066a_clk_branches));
rockchip_clk_register_armclk(ARMCLK, "armclk",
rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
&rk3066_cpuclk_data, rk3066_cpuclk_rates,
ARRAY_SIZE(rk3066_cpuclk_rates));
rockchip_clk_protect_critical(rk3188_critical_clocks,
ARRAY_SIZE(rk3188_critical_clocks));
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3066a_cru, "rockchip,rk3066a-cru", rk3066a_clk_init);
static void __init rk3188a_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
struct clk *clk1, *clk2;
unsigned long rate;
int ret;
rk3188_common_clk_init(np);
rockchip_clk_register_plls(rk3188_pll_clks,
ctx = rk3188_common_clk_init(np);
if (IS_ERR(ctx))
return;
rockchip_clk_register_plls(ctx, rk3188_pll_clks,
ARRAY_SIZE(rk3188_pll_clks),
RK3188_GRF_SOC_STATUS);
rockchip_clk_register_branches(rk3188_clk_branches,
rockchip_clk_register_branches(ctx, rk3188_clk_branches,
ARRAY_SIZE(rk3188_clk_branches));
rockchip_clk_register_armclk(ARMCLK, "armclk",
rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
&rk3188_cpuclk_data, rk3188_cpuclk_rates,
ARRAY_SIZE(rk3188_cpuclk_rates));
@ -827,6 +851,7 @@ static void __init rk3188a_clk_init(struct device_node *np)
rockchip_clk_protect_critical(rk3188_critical_clocks,
ARRAY_SIZE(rk3188_critical_clocks));
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3188a_cru, "rockchip,rk3188a-cru", rk3188a_clk_init);

View File

@ -111,7 +111,10 @@ static const struct rockchip_cpuclk_reg_data rk3228_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 6,
.mux_core_mask = 0x1,
};
PNAME(mux_pll_p) = { "clk_24m", "xin24m" };
@ -625,6 +628,7 @@ static const char *const rk3228_critical_clocks[] __initconst = {
static void __init rk3228_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
void __iomem *reg_base;
reg_base = of_iomap(np, 0);
@ -633,17 +637,22 @@ static void __init rk3228_clk_init(struct device_node *np)
return;
}
rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
iounmap(reg_base);
return;
}
rockchip_clk_register_plls(rk3228_pll_clks,
rockchip_clk_register_plls(ctx, rk3228_pll_clks,
ARRAY_SIZE(rk3228_pll_clks),
RK3228_GRF_SOC_STATUS0);
rockchip_clk_register_branches(rk3228_clk_branches,
rockchip_clk_register_branches(ctx, rk3228_clk_branches,
ARRAY_SIZE(rk3228_clk_branches));
rockchip_clk_protect_critical(rk3228_critical_clocks,
ARRAY_SIZE(rk3228_critical_clocks));
rockchip_clk_register_armclk(ARMCLK, "armclk",
rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
&rk3228_cpuclk_data, rk3228_cpuclk_rates,
ARRAY_SIZE(rk3228_cpuclk_rates));
@ -651,6 +660,8 @@ static void __init rk3228_clk_init(struct device_node *np)
rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);
rockchip_register_restart_notifier(RK3228_GLB_SRST_FST, NULL);
rockchip_register_restart_notifier(ctx, RK3228_GLB_SRST_FST, NULL);
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3228_cru, "rockchip,rk3228-cru", rk3228_clk_init);

View File

@ -165,7 +165,10 @@ static const struct rockchip_cpuclk_reg_data rk3288_cpuclk_data = {
.core_reg = RK3288_CLKSEL_CON(0),
.div_core_shift = 8,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 15,
.mux_core_mask = 0x1,
};
PNAME(mux_pll_p) = { "xin24m", "xin32k" };
@ -878,6 +881,7 @@ static struct syscore_ops rk3288_clk_syscore_ops = {
static void __init rk3288_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
struct clk *clk;
rk3288_cru_base = of_iomap(np, 0);
@ -886,7 +890,12 @@ static void __init rk3288_clk_init(struct device_node *np)
return;
}
rockchip_clk_init(np, rk3288_cru_base, CLK_NR_CLKS);
ctx = rockchip_clk_init(np, rk3288_cru_base, CLK_NR_CLKS);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
iounmap(rk3288_cru_base);
return;
}
/* Watchdog pclk is controlled by RK3288_SGRF_SOC_CON0[1]. */
clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1);
@ -894,17 +903,17 @@ static void __init rk3288_clk_init(struct device_node *np)
pr_warn("%s: could not register clock pclk_wdt: %ld\n",
__func__, PTR_ERR(clk));
else
rockchip_clk_add_lookup(clk, PCLK_WDT);
rockchip_clk_add_lookup(ctx, clk, PCLK_WDT);
rockchip_clk_register_plls(rk3288_pll_clks,
rockchip_clk_register_plls(ctx, rk3288_pll_clks,
ARRAY_SIZE(rk3288_pll_clks),
RK3288_GRF_SOC_STATUS1);
rockchip_clk_register_branches(rk3288_clk_branches,
rockchip_clk_register_branches(ctx, rk3288_clk_branches,
ARRAY_SIZE(rk3288_clk_branches));
rockchip_clk_protect_critical(rk3288_critical_clocks,
ARRAY_SIZE(rk3288_critical_clocks));
rockchip_clk_register_armclk(ARMCLK, "armclk",
rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
&rk3288_cpuclk_data, rk3288_cpuclk_rates,
ARRAY_SIZE(rk3288_cpuclk_rates));
@ -913,8 +922,10 @@ static void __init rk3288_clk_init(struct device_node *np)
rk3288_cru_base + RK3288_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);
rockchip_register_restart_notifier(RK3288_GLB_SRST_FST,
rockchip_register_restart_notifier(ctx, RK3288_GLB_SRST_FST,
rk3288_clk_shutdown);
register_syscore_ops(&rk3288_clk_syscore_ops);
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);

View File

@ -165,14 +165,20 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = {
.core_reg = RK3368_CLKSEL_CON(0),
.div_core_shift = 0,
.div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 7,
.mux_core_mask = 0x1,
};
static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = {
.core_reg = RK3368_CLKSEL_CON(2),
.div_core_shift = 0,
.mux_core_alt = 1,
.mux_core_main = 0,
.div_core_mask = 0x1f,
.mux_core_shift = 7,
.mux_core_mask = 0x1,
};
#define RK3368_DIV_ACLKM_MASK 0x1f
@ -856,6 +862,7 @@ static const char *const rk3368_critical_clocks[] __initconst = {
static void __init rk3368_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
void __iomem *reg_base;
struct clk *clk;
@ -865,7 +872,12 @@ static void __init rk3368_clk_init(struct device_node *np)
return;
}
rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
iounmap(reg_base);
return;
}
/* Watchdog pclk is controlled by sgrf_soc_con3[7]. */
clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1);
@ -873,22 +885,22 @@ static void __init rk3368_clk_init(struct device_node *np)
pr_warn("%s: could not register clock pclk_wdt: %ld\n",
__func__, PTR_ERR(clk));
else
rockchip_clk_add_lookup(clk, PCLK_WDT);
rockchip_clk_add_lookup(ctx, clk, PCLK_WDT);
rockchip_clk_register_plls(rk3368_pll_clks,
rockchip_clk_register_plls(ctx, rk3368_pll_clks,
ARRAY_SIZE(rk3368_pll_clks),
RK3368_GRF_SOC_STATUS0);
rockchip_clk_register_branches(rk3368_clk_branches,
rockchip_clk_register_branches(ctx, rk3368_clk_branches,
ARRAY_SIZE(rk3368_clk_branches));
rockchip_clk_protect_critical(rk3368_critical_clocks,
ARRAY_SIZE(rk3368_critical_clocks));
rockchip_clk_register_armclk(ARMCLKB, "armclkb",
rockchip_clk_register_armclk(ctx, ARMCLKB, "armclkb",
mux_armclkb_p, ARRAY_SIZE(mux_armclkb_p),
&rk3368_cpuclkb_data, rk3368_cpuclkb_rates,
ARRAY_SIZE(rk3368_cpuclkb_rates));
rockchip_clk_register_armclk(ARMCLKL, "armclkl",
rockchip_clk_register_armclk(ctx, ARMCLKL, "armclkl",
mux_armclkl_p, ARRAY_SIZE(mux_armclkl_p),
&rk3368_cpuclkl_data, rk3368_cpuclkl_rates,
ARRAY_SIZE(rk3368_cpuclkl_rates));
@ -896,6 +908,8 @@ static void __init rk3368_clk_init(struct device_node *np)
rockchip_register_softrst(np, 15, reg_base + RK3368_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);
rockchip_register_restart_notifier(RK3368_GLB_SRST_FST, NULL);
rockchip_register_restart_notifier(ctx, RK3368_GLB_SRST_FST, NULL);
rockchip_clk_of_add_provider(np, ctx);
}
CLK_OF_DECLARE(rk3368_cru, "rockchip,rk3368-cru", rk3368_clk_init);

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,9 @@
* Copyright (c) 2014 MundoReader S.L.
* Author: Heiko Stuebner <heiko@sntech.de>
*
* Copyright (c) 2016 Rockchip Electronics Co. Ltd.
* Author: Xing Zheng <zhengxing@rock-chips.com>
*
* based on
*
* samsung/clk.c
@ -157,7 +160,8 @@ static int rockchip_clk_frac_notifier_cb(struct notifier_block *nb,
return notifier_from_errno(ret);
}
static struct clk *rockchip_clk_register_frac_branch(const char *name,
static struct clk *rockchip_clk_register_frac_branch(
struct rockchip_clk_provider *ctx, const char *name,
const char *const *parent_names, u8 num_parents,
void __iomem *base, int muxdiv_offset, u8 div_flags,
int gate_offset, u8 gate_shift, u8 gate_flags,
@ -250,7 +254,7 @@ static struct clk *rockchip_clk_register_frac_branch(const char *name,
if (IS_ERR(mux_clk))
return clk;
rockchip_clk_add_lookup(mux_clk, child->id);
rockchip_clk_add_lookup(ctx, mux_clk, child->id);
/* notifier on the fraction divider to catch rate changes */
if (frac->mux_frac_idx >= 0) {
@ -314,66 +318,92 @@ static struct clk *rockchip_clk_register_factor_branch(const char *name,
return clk;
}
static DEFINE_SPINLOCK(clk_lock);
static struct clk **clk_table;
static void __iomem *reg_base;
static struct clk_onecell_data clk_data;
static struct device_node *cru_node;
static struct regmap *grf;
void __init rockchip_clk_init(struct device_node *np, void __iomem *base,
unsigned long nr_clks)
struct rockchip_clk_provider * __init rockchip_clk_init(struct device_node *np,
void __iomem *base, unsigned long nr_clks)
{
reg_base = base;
cru_node = np;
grf = ERR_PTR(-EPROBE_DEFER);
struct rockchip_clk_provider *ctx;
struct clk **clk_table;
int i;
ctx = kzalloc(sizeof(struct rockchip_clk_provider), GFP_KERNEL);
if (!ctx) {
pr_err("%s: Could not allocate clock provider context\n",
__func__);
return ERR_PTR(-ENOMEM);
}
clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
if (!clk_table)
pr_err("%s: could not allocate clock lookup table\n", __func__);
if (!clk_table) {
pr_err("%s: Could not allocate clock lookup table\n",
__func__);
goto err_free;
}
clk_data.clks = clk_table;
clk_data.clk_num = nr_clks;
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
for (i = 0; i < nr_clks; ++i)
clk_table[i] = ERR_PTR(-ENOENT);
ctx->reg_base = base;
ctx->clk_data.clks = clk_table;
ctx->clk_data.clk_num = nr_clks;
ctx->cru_node = np;
ctx->grf = ERR_PTR(-EPROBE_DEFER);
spin_lock_init(&ctx->lock);
return ctx;
err_free:
kfree(ctx);
return ERR_PTR(-ENOMEM);
}
struct regmap *rockchip_clk_get_grf(void)
void __init rockchip_clk_of_add_provider(struct device_node *np,
struct rockchip_clk_provider *ctx)
{
if (IS_ERR(grf))
grf = syscon_regmap_lookup_by_phandle(cru_node, "rockchip,grf");
return grf;
if (of_clk_add_provider(np, of_clk_src_onecell_get,
&ctx->clk_data))
pr_err("%s: could not register clk provider\n", __func__);
}
void rockchip_clk_add_lookup(struct clk *clk, unsigned int id)
struct regmap *rockchip_clk_get_grf(struct rockchip_clk_provider *ctx)
{
if (clk_table && id)
clk_table[id] = clk;
if (IS_ERR(ctx->grf))
ctx->grf = syscon_regmap_lookup_by_phandle(ctx->cru_node, "rockchip,grf");
return ctx->grf;
}
void __init rockchip_clk_register_plls(struct rockchip_pll_clock *list,
void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
struct clk *clk, unsigned int id)
{
if (ctx->clk_data.clks && id)
ctx->clk_data.clks[id] = clk;
}
void __init rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
struct rockchip_pll_clock *list,
unsigned int nr_pll, int grf_lock_offset)
{
struct clk *clk;
int idx;
for (idx = 0; idx < nr_pll; idx++, list++) {
clk = rockchip_clk_register_pll(list->type, list->name,
clk = rockchip_clk_register_pll(ctx, list->type, list->name,
list->parent_names, list->num_parents,
reg_base, list->con_offset, grf_lock_offset,
list->con_offset, grf_lock_offset,
list->lock_shift, list->mode_offset,
list->mode_shift, list->rate_table,
list->pll_flags, &clk_lock);
list->pll_flags);
if (IS_ERR(clk)) {
pr_err("%s: failed to register clock %s\n", __func__,
list->name);
continue;
}
rockchip_clk_add_lookup(clk, list->id);
rockchip_clk_add_lookup(ctx, clk, list->id);
}
}
void __init rockchip_clk_register_branches(
struct rockchip_clk_provider *ctx,
struct rockchip_clk_branch *list,
unsigned int nr_clk)
{
@ -389,56 +419,56 @@ void __init rockchip_clk_register_branches(
case branch_mux:
clk = clk_register_mux(NULL, list->name,
list->parent_names, list->num_parents,
flags, reg_base + list->muxdiv_offset,
flags, ctx->reg_base + list->muxdiv_offset,
list->mux_shift, list->mux_width,
list->mux_flags, &clk_lock);
list->mux_flags, &ctx->lock);
break;
case branch_divider:
if (list->div_table)
clk = clk_register_divider_table(NULL,
list->name, list->parent_names[0],
flags, reg_base + list->muxdiv_offset,
flags, ctx->reg_base + list->muxdiv_offset,
list->div_shift, list->div_width,
list->div_flags, list->div_table,
&clk_lock);
&ctx->lock);
else
clk = clk_register_divider(NULL, list->name,
list->parent_names[0], flags,
reg_base + list->muxdiv_offset,
ctx->reg_base + list->muxdiv_offset,
list->div_shift, list->div_width,
list->div_flags, &clk_lock);
list->div_flags, &ctx->lock);
break;
case branch_fraction_divider:
clk = rockchip_clk_register_frac_branch(list->name,
clk = rockchip_clk_register_frac_branch(ctx, list->name,
list->parent_names, list->num_parents,
reg_base, list->muxdiv_offset, list->div_flags,
ctx->reg_base, list->muxdiv_offset, list->div_flags,
list->gate_offset, list->gate_shift,
list->gate_flags, flags, list->child,
&clk_lock);
&ctx->lock);
break;
case branch_gate:
flags |= CLK_SET_RATE_PARENT;
clk = clk_register_gate(NULL, list->name,
list->parent_names[0], flags,
reg_base + list->gate_offset,
list->gate_shift, list->gate_flags, &clk_lock);
ctx->reg_base + list->gate_offset,
list->gate_shift, list->gate_flags, &ctx->lock);
break;
case branch_composite:
clk = rockchip_clk_register_branch(list->name,
list->parent_names, list->num_parents,
reg_base, list->muxdiv_offset, list->mux_shift,
ctx->reg_base, list->muxdiv_offset, list->mux_shift,
list->mux_width, list->mux_flags,
list->div_shift, list->div_width,
list->div_flags, list->div_table,
list->gate_offset, list->gate_shift,
list->gate_flags, flags, &clk_lock);
list->gate_flags, flags, &ctx->lock);
break;
case branch_mmc:
clk = rockchip_clk_register_mmc(
list->name,
list->parent_names, list->num_parents,
reg_base + list->muxdiv_offset,
ctx->reg_base + list->muxdiv_offset,
list->div_shift
);
break;
@ -446,16 +476,16 @@ void __init rockchip_clk_register_branches(
clk = rockchip_clk_register_inverter(
list->name, list->parent_names,
list->num_parents,
reg_base + list->muxdiv_offset,
list->div_shift, list->div_flags, &clk_lock);
ctx->reg_base + list->muxdiv_offset,
list->div_shift, list->div_flags, &ctx->lock);
break;
case branch_factor:
clk = rockchip_clk_register_factor_branch(
list->name, list->parent_names,
list->num_parents, reg_base,
list->num_parents, ctx->reg_base,
list->div_shift, list->div_width,
list->gate_offset, list->gate_shift,
list->gate_flags, flags, &clk_lock);
list->gate_flags, flags, &ctx->lock);
break;
}
@ -472,11 +502,12 @@ void __init rockchip_clk_register_branches(
continue;
}
rockchip_clk_add_lookup(clk, list->id);
rockchip_clk_add_lookup(ctx, clk, list->id);
}
}
void __init rockchip_clk_register_armclk(unsigned int lookup_id,
void __init rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx,
unsigned int lookup_id,
const char *name, const char *const *parent_names,
u8 num_parents,
const struct rockchip_cpuclk_reg_data *reg_data,
@ -486,15 +517,15 @@ void __init rockchip_clk_register_armclk(unsigned int lookup_id,
struct clk *clk;
clk = rockchip_clk_register_cpuclk(name, parent_names, num_parents,
reg_data, rates, nrates, reg_base,
&clk_lock);
reg_data, rates, nrates, ctx->reg_base,
&ctx->lock);
if (IS_ERR(clk)) {
pr_err("%s: failed to register clock %s: %ld\n",
__func__, name, PTR_ERR(clk));
return;
}
rockchip_clk_add_lookup(clk, lookup_id);
rockchip_clk_add_lookup(ctx, clk, lookup_id);
}
void __init rockchip_clk_protect_critical(const char *const clocks[],
@ -511,6 +542,7 @@ void __init rockchip_clk_protect_critical(const char *const clocks[],
}
}
static void __iomem *rst_base;
static unsigned int reg_restart;
static void (*cb_restart)(void);
static int rockchip_restart_notify(struct notifier_block *this,
@ -519,7 +551,7 @@ static int rockchip_restart_notify(struct notifier_block *this,
if (cb_restart)
cb_restart();
writel(0xfdb9, reg_base + reg_restart);
writel(0xfdb9, rst_base + reg_restart);
return NOTIFY_DONE;
}
@ -528,10 +560,12 @@ static struct notifier_block rockchip_restart_handler = {
.priority = 128,
};
void __init rockchip_register_restart_notifier(unsigned int reg, void (*cb)(void))
void __init rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx,
unsigned int reg, void (*cb)(void))
{
int ret;
rst_base = ctx->reg_base;
reg_restart = reg;
cb_restart = cb;
ret = register_restart_handler(&rockchip_restart_handler);

View File

@ -27,13 +27,14 @@
#define CLK_ROCKCHIP_CLK_H
#include <linux/io.h>
#include <linux/clk-provider.h>
struct clk;
#define HIWORD_UPDATE(val, mask, shift) \
((val) << (shift) | (mask) << ((shift) + 16))
/* register positions shared by RK2928, RK3036, RK3066, RK3188 and RK3228 */
/* register positions shared by RK2928, RK3036, RK3066, RK3188, RK3228, RK3399 */
#define RK2928_PLL_CON(x) ((x) * 0x4)
#define RK2928_MODE_CON 0x40
#define RK2928_CLKSEL_CON(x) ((x) * 0x4 + 0x44)
@ -92,9 +93,30 @@ struct clk;
#define RK3368_EMMC_CON0 0x418
#define RK3368_EMMC_CON1 0x41c
#define RK3399_PLL_CON(x) RK2928_PLL_CON(x)
#define RK3399_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
#define RK3399_CLKGATE_CON(x) ((x) * 0x4 + 0x300)
#define RK3399_SOFTRST_CON(x) ((x) * 0x4 + 0x400)
#define RK3399_GLB_SRST_FST 0x500
#define RK3399_GLB_SRST_SND 0x504
#define RK3399_GLB_CNT_TH 0x508
#define RK3399_MISC_CON 0x50c
#define RK3399_RST_CON 0x510
#define RK3399_RST_ST 0x514
#define RK3399_SDMMC_CON0 0x580
#define RK3399_SDMMC_CON1 0x584
#define RK3399_SDIO_CON0 0x588
#define RK3399_SDIO_CON1 0x58c
#define RK3399_PMU_PLL_CON(x) RK2928_PLL_CON(x)
#define RK3399_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x80)
#define RK3399_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x100)
#define RK3399_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x110)
enum rockchip_pll_type {
pll_rk3036,
pll_rk3066,
pll_rk3399,
};
#define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \
@ -127,13 +149,29 @@ enum rockchip_pll_type {
.nb = _nb, \
}
/**
* struct rockchip_clk_provider - information about clock provider
* @reg_base: virtual address for the register base.
* @clk_data: holds clock related data like clk* and number of clocks.
* @cru_node: device-node of the clock-provider
* @grf: regmap of the general-register-files syscon
* @lock: maintains exclusion between callbacks for a given clock-provider.
*/
struct rockchip_clk_provider {
void __iomem *reg_base;
struct clk_onecell_data clk_data;
struct device_node *cru_node;
struct regmap *grf;
spinlock_t lock;
};
struct rockchip_pll_rate_table {
unsigned long rate;
unsigned int nr;
unsigned int nf;
unsigned int no;
unsigned int nb;
/* for RK3036 */
/* for RK3036/RK3399 */
unsigned int fbdiv;
unsigned int postdiv1;
unsigned int refdiv;
@ -143,10 +181,11 @@ struct rockchip_pll_rate_table {
};
/**
* struct rockchip_pll_clock: information about pll clock
* struct rockchip_pll_clock - information about pll clock
* @id: platform specific id of the clock.
* @name: name of this pll clock.
* @parent_name: name of the parent clock.
* @parent_names: name of the parent clock.
* @num_parents: number of parents
* @flags: optional flags for basic clock.
* @con_offset: offset of the register for configuring the PLL.
* @mode_offset: offset of the register for configuring the PLL-mode.
@ -194,12 +233,13 @@ struct rockchip_pll_clock {
.rate_table = _rtable, \
}
struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type,
struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
enum rockchip_pll_type pll_type,
const char *name, const char *const *parent_names,
u8 num_parents, void __iomem *base, int con_offset,
int grf_lock_offset, int lock_shift, int reg_mode,
int mode_shift, struct rockchip_pll_rate_table *rate_table,
u8 clk_pll_flags, spinlock_t *lock);
u8 num_parents, int con_offset, int grf_lock_offset,
int lock_shift, int mode_offset, int mode_shift,
struct rockchip_pll_rate_table *rate_table,
u8 clk_pll_flags);
struct rockchip_cpuclk_clksel {
int reg;
@ -213,18 +253,23 @@ struct rockchip_cpuclk_rate_table {
};
/**
* struct rockchip_cpuclk_reg_data: describes register offsets and masks of the cpuclock
* struct rockchip_cpuclk_reg_data - describes register offsets and masks of the cpuclock
* @core_reg: register offset of the core settings register
* @div_core_shift: core divider offset used to divide the pll value
* @div_core_mask: core divider mask
* @mux_core_alt: mux value to select alternate parent
* @mux_core_main: mux value to select main parent of core
* @mux_core_shift: offset of the core multiplexer
* @mux_core_mask: core multiplexer mask
*/
struct rockchip_cpuclk_reg_data {
int core_reg;
u8 div_core_shift;
u32 div_core_mask;
int mux_core_reg;
u8 mux_core_alt;
u8 mux_core_main;
u8 mux_core_shift;
u32 mux_core_mask;
};
struct clk *rockchip_clk_register_cpuclk(const char *name,
@ -428,6 +473,22 @@ struct rockchip_clk_branch {
.child = ch, \
}
#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch) \
{ \
.id = _id, \
.branch_type = branch_fraction_divider, \
.name = cname, \
.parent_names = (const char *[]){ pname }, \
.num_parents = 1, \
.flags = f, \
.muxdiv_offset = mo, \
.div_shift = 16, \
.div_width = 16, \
.div_flags = df, \
.gate_offset = -1, \
.child = ch, \
}
#define MUX(_id, cname, pnames, f, o, s, w, mf) \
{ \
.id = _id, \
@ -536,21 +597,28 @@ struct rockchip_clk_branch {
.gate_flags = gf, \
}
void rockchip_clk_init(struct device_node *np, void __iomem *base,
unsigned long nr_clks);
struct regmap *rockchip_clk_get_grf(void);
void rockchip_clk_add_lookup(struct clk *clk, unsigned int id);
void rockchip_clk_register_branches(struct rockchip_clk_branch *clk_list,
struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
void __iomem *base, unsigned long nr_clks);
void rockchip_clk_of_add_provider(struct device_node *np,
struct rockchip_clk_provider *ctx);
struct regmap *rockchip_clk_get_grf(struct rockchip_clk_provider *ctx);
void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
struct clk *clk, unsigned int id);
void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
struct rockchip_clk_branch *list,
unsigned int nr_clk);
void rockchip_clk_register_plls(struct rockchip_pll_clock *pll_list,
void rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
struct rockchip_pll_clock *pll_list,
unsigned int nr_pll, int grf_lock_offset);
void rockchip_clk_register_armclk(unsigned int lookup_id, const char *name,
void rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx,
unsigned int lookup_id, const char *name,
const char *const *parent_names, u8 num_parents,
const struct rockchip_cpuclk_reg_data *reg_data,
const struct rockchip_cpuclk_rate_table *rates,
int nrates);
void rockchip_clk_protect_critical(const char *const clocks[], int nclocks);
void rockchip_register_restart_notifier(unsigned int reg, void (*cb)(void));
void rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx,
unsigned int reg, void (*cb)(void));
#define ROCKCHIP_SOFTRST_HIWORD_MASK BIT(0)

View File

@ -0,0 +1,752 @@
/*
* Copyright (c) 2016 Rockchip Electronics Co. Ltd.
* Author: Xing Zheng <zhengxing@rock-chips.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _DT_BINDINGS_CLK_ROCKCHIP_RK3399_H
#define _DT_BINDINGS_CLK_ROCKCHIP_RK3399_H
/* core clocks */
#define PLL_APLLL 1
#define PLL_APLLB 2
#define PLL_DPLL 3
#define PLL_CPLL 4
#define PLL_GPLL 5
#define PLL_NPLL 6
#define PLL_VPLL 7
#define ARMCLKL 8
#define ARMCLKB 9
/* sclk gates (special clocks) */
#define SCLK_I2C1 65
#define SCLK_I2C2 66
#define SCLK_I2C3 67
#define SCLK_I2C5 68
#define SCLK_I2C6 69
#define SCLK_I2C7 70
#define SCLK_SPI0 71
#define SCLK_SPI1 72
#define SCLK_SPI2 73
#define SCLK_SPI4 74
#define SCLK_SPI5 75
#define SCLK_SDMMC 76
#define SCLK_SDIO 77
#define SCLK_EMMC 78
#define SCLK_TSADC 79
#define SCLK_SARADC 80
#define SCLK_UART0 81
#define SCLK_UART1 82
#define SCLK_UART2 83
#define SCLK_UART3 84
#define SCLK_SPDIF_8CH 85
#define SCLK_I2S0_8CH 86
#define SCLK_I2S1_8CH 87
#define SCLK_I2S2_8CH 88
#define SCLK_I2S_8CH_OUT 89
#define SCLK_TIMER00 90
#define SCLK_TIMER01 91
#define SCLK_TIMER02 92
#define SCLK_TIMER03 93
#define SCLK_TIMER04 94
#define SCLK_TIMER05 95
#define SCLK_TIMER06 96
#define SCLK_TIMER07 97
#define SCLK_TIMER08 98
#define SCLK_TIMER09 99
#define SCLK_TIMER10 100
#define SCLK_TIMER11 101
#define SCLK_MACREF 102
#define SCLK_MAC_RX 103
#define SCLK_MAC_TX 104
#define SCLK_MAC 105
#define SCLK_MACREF_OUT 106
#define SCLK_VOP0_PWM 107
#define SCLK_VOP1_PWM 108
#define SCLK_RGA 109
#define SCLK_ISP0 110
#define SCLK_ISP1 111
#define SCLK_HDMI_CEC 112
#define SCLK_HDMI_SFR 113
#define SCLK_DP_CORE 114
#define SCLK_PVTM_CORE_L 115
#define SCLK_PVTM_CORE_B 116
#define SCLK_PVTM_GPU 117
#define SCLK_PVTM_DDR 118
#define SCLK_MIPIDPHY_REF 119
#define SCLK_MIPIDPHY_CFG 120
#define SCLK_HSICPHY 121
#define SCLK_USBPHY480M 122
#define SCLK_USB2PHY0_REF 123
#define SCLK_USB2PHY1_REF 124
#define SCLK_UPHY0_TCPDPHY_REF 125
#define SCLK_UPHY0_TCPDCORE 126
#define SCLK_UPHY1_TCPDPHY_REF 127
#define SCLK_UPHY1_TCPDCORE 128
#define SCLK_USB3OTG0_REF 129
#define SCLK_USB3OTG1_REF 130
#define SCLK_USB3OTG0_SUSPEND 131
#define SCLK_USB3OTG1_SUSPEND 132
#define SCLK_CRYPTO0 133
#define SCLK_CRYPTO1 134
#define SCLK_CCI_TRACE 135
#define SCLK_CS 136
#define SCLK_CIF_OUT 137
#define SCLK_PCIEPHY_REF 138
#define SCLK_PCIE_CORE 139
#define SCLK_M0_PERILP 140
#define SCLK_M0_PERILP_DEC 141
#define SCLK_CM0S 142
#define SCLK_DBG_NOC 143
#define SCLK_DBG_PD_CORE_B 144
#define SCLK_DBG_PD_CORE_L 145
#define SCLK_DFIMON0_TIMER 146
#define SCLK_DFIMON1_TIMER 147
#define SCLK_INTMEM0 148
#define SCLK_INTMEM1 149
#define SCLK_INTMEM2 150
#define SCLK_INTMEM3 151
#define SCLK_INTMEM4 152
#define SCLK_INTMEM5 153
#define SCLK_SDMMC_DRV 154
#define SCLK_SDMMC_SAMPLE 155
#define SCLK_SDIO_DRV 156
#define SCLK_SDIO_SAMPLE 157
#define SCLK_VDU_CORE 158
#define SCLK_VDU_CA 159
#define SCLK_PCIE_PM 160
#define SCLK_SPDIF_REC_DPTX 161
#define SCLK_DPHY_PLL 162
#define SCLK_DPHY_TX0_CFG 163
#define SCLK_DPHY_TX1RX1_CFG 164
#define SCLK_DPHY_RX0_CFG 165
#define DCLK_VOP0 180
#define DCLK_VOP1 181
#define DCLK_VOP0_DIV 182
#define DCLK_VOP1_DIV 183
#define DCLK_M0_PERILP 184
#define FCLK_CM0S 190
/* aclk gates */
#define ACLK_PERIHP 192
#define ACLK_PERIHP_NOC 193
#define ACLK_PERILP0 194
#define ACLK_PERILP0_NOC 195
#define ACLK_PERF_PCIE 196
#define ACLK_PCIE 197
#define ACLK_INTMEM 198
#define ACLK_TZMA 199
#define ACLK_DCF 200
#define ACLK_CCI 201
#define ACLK_CCI_NOC0 202
#define ACLK_CCI_NOC1 203
#define ACLK_CCI_GRF 204
#define ACLK_CENTER 205
#define ACLK_CENTER_MAIN_NOC 206
#define ACLK_CENTER_PERI_NOC 207
#define ACLK_GPU 208
#define ACLK_PERF_GPU 209
#define ACLK_GPU_GRF 210
#define ACLK_DMAC0_PERILP 211
#define ACLK_DMAC1_PERILP 212
#define ACLK_GMAC 213
#define ACLK_GMAC_NOC 214
#define ACLK_PERF_GMAC 215
#define ACLK_VOP0_NOC 216
#define ACLK_VOP0 217
#define ACLK_VOP1_NOC 218
#define ACLK_VOP1 219
#define ACLK_RGA 220
#define ACLK_RGA_NOC 221
#define ACLK_HDCP 222
#define ACLK_HDCP_NOC 223
#define ACLK_HDCP22 224
#define ACLK_IEP 225
#define ACLK_IEP_NOC 226
#define ACLK_VIO 227
#define ACLK_VIO_NOC 228
#define ACLK_ISP0 229
#define ACLK_ISP1 230
#define ACLK_ISP0_NOC 231
#define ACLK_ISP1_NOC 232
#define ACLK_ISP0_WRAPPER 233
#define ACLK_ISP1_WRAPPER 234
#define ACLK_VCODEC 235
#define ACLK_VCODEC_NOC 236
#define ACLK_VDU 237
#define ACLK_VDU_NOC 238
#define ACLK_PERI 239
#define ACLK_EMMC 240
#define ACLK_EMMC_CORE 241
#define ACLK_EMMC_NOC 242
#define ACLK_EMMC_GRF 243
#define ACLK_USB3 244
#define ACLK_USB3_NOC 245
#define ACLK_USB3OTG0 246
#define ACLK_USB3OTG1 247
#define ACLK_USB3_RKSOC_AXI_PERF 248
#define ACLK_USB3_GRF 249
#define ACLK_GIC 250
#define ACLK_GIC_NOC 251
#define ACLK_GIC_ADB400_CORE_L_2_GIC 252
#define ACLK_GIC_ADB400_CORE_B_2_GIC 253
#define ACLK_GIC_ADB400_GIC_2_CORE_L 254
#define ACLK_GIC_ADB400_GIC_2_CORE_B 255
#define ACLK_CORE_ADB400_CORE_L_2_CCI500 256
#define ACLK_CORE_ADB400_CORE_B_2_CCI500 257
#define ACLK_ADB400M_PD_CORE_L 258
#define ACLK_ADB400M_PD_CORE_B 259
#define ACLK_PERF_CORE_L 260
#define ACLK_PERF_CORE_B 261
#define ACLK_GIC_PRE 262
#define ACLK_VOP0_PRE 263
#define ACLK_VOP1_PRE 264
/* pclk gates */
#define PCLK_PERIHP 320
#define PCLK_PERIHP_NOC 321
#define PCLK_PERILP0 322
#define PCLK_PERILP1 323
#define PCLK_PERILP1_NOC 324
#define PCLK_PERILP_SGRF 325
#define PCLK_PERIHP_GRF 326
#define PCLK_PCIE 327
#define PCLK_SGRF 328
#define PCLK_INTR_ARB 329
#define PCLK_CENTER_MAIN_NOC 330
#define PCLK_CIC 331
#define PCLK_COREDBG_B 332
#define PCLK_COREDBG_L 333
#define PCLK_DBG_CXCS_PD_CORE_B 334
#define PCLK_DCF 335
#define PCLK_GPIO2 336
#define PCLK_GPIO3 337
#define PCLK_GPIO4 338
#define PCLK_GRF 339
#define PCLK_HSICPHY 340
#define PCLK_I2C1 341
#define PCLK_I2C2 342
#define PCLK_I2C3 343
#define PCLK_I2C5 344
#define PCLK_I2C6 345
#define PCLK_I2C7 346
#define PCLK_SPI0 347
#define PCLK_SPI1 348
#define PCLK_SPI2 349
#define PCLK_SPI4 350
#define PCLK_SPI5 351
#define PCLK_UART0 352
#define PCLK_UART1 353
#define PCLK_UART2 354
#define PCLK_UART3 355
#define PCLK_TSADC 356
#define PCLK_SARADC 357
#define PCLK_GMAC 358
#define PCLK_GMAC_NOC 359
#define PCLK_TIMER0 360
#define PCLK_TIMER1 361
#define PCLK_EDP 362
#define PCLK_EDP_NOC 363
#define PCLK_EDP_CTRL 364
#define PCLK_VIO 365
#define PCLK_VIO_NOC 366
#define PCLK_VIO_GRF 367
#define PCLK_MIPI_DSI0 368
#define PCLK_MIPI_DSI1 369
#define PCLK_HDCP 370
#define PCLK_HDCP_NOC 371
#define PCLK_HDMI_CTRL 372
#define PCLK_DP_CTRL 373
#define PCLK_HDCP22 374
#define PCLK_GASKET 375
#define PCLK_DDR 376
#define PCLK_DDR_MON 377
#define PCLK_DDR_SGRF 378
#define PCLK_ISP1_WRAPPER 379
#define PCLK_WDT 380
#define PCLK_EFUSE1024NS 381
#define PCLK_EFUSE1024S 382
#define PCLK_PMU_INTR_ARB 383
#define PCLK_MAILBOX0 384
#define PCLK_USBPHY_MUX_G 385
#define PCLK_UPHY0_TCPHY_G 386
#define PCLK_UPHY0_TCPD_G 387
#define PCLK_UPHY1_TCPHY_G 388
#define PCLK_UPHY1_TCPD_G 389
#define PCLK_ALIVE 390
/* hclk gates */
#define HCLK_PERIHP 448
#define HCLK_PERILP0 449
#define HCLK_PERILP1 450
#define HCLK_PERILP0_NOC 451
#define HCLK_PERILP1_NOC 452
#define HCLK_M0_PERILP 453
#define HCLK_M0_PERILP_NOC 454
#define HCLK_AHB1TOM 455
#define HCLK_HOST0 456
#define HCLK_HOST0_ARB 457
#define HCLK_HOST1 458
#define HCLK_HOST1_ARB 459
#define HCLK_HSIC 460
#define HCLK_SD 461
#define HCLK_SDMMC 462
#define HCLK_SDMMC_NOC 463
#define HCLK_M_CRYPTO0 464
#define HCLK_M_CRYPTO1 465
#define HCLK_S_CRYPTO0 466
#define HCLK_S_CRYPTO1 467
#define HCLK_I2S0_8CH 468
#define HCLK_I2S1_8CH 469
#define HCLK_I2S2_8CH 470
#define HCLK_SPDIF 471
#define HCLK_VOP0_NOC 472
#define HCLK_VOP0 473
#define HCLK_VOP1_NOC 474
#define HCLK_VOP1 475
#define HCLK_ROM 476
#define HCLK_IEP 477
#define HCLK_IEP_NOC 478
#define HCLK_ISP0 479
#define HCLK_ISP1 480
#define HCLK_ISP0_NOC 481
#define HCLK_ISP1_NOC 482
#define HCLK_ISP0_WRAPPER 483
#define HCLK_ISP1_WRAPPER 484
#define HCLK_RGA 485
#define HCLK_RGA_NOC 486
#define HCLK_HDCP 487
#define HCLK_HDCP_NOC 488
#define HCLK_HDCP22 489
#define HCLK_VCODEC 490
#define HCLK_VCODEC_NOC 491
#define HCLK_VDU 492
#define HCLK_VDU_NOC 493
#define HCLK_SDIO 494
#define HCLK_SDIO_NOC 495
#define HCLK_SDIOAUDIO_NOC 496
#define CLK_NR_CLKS (HCLK_SDIOAUDIO_NOC + 1)
/* pmu-clocks indices */
#define PLL_PPLL 1
#define SCLK_32K_SUSPEND_PMU 2
#define SCLK_SPI3_PMU 3
#define SCLK_TIMER12_PMU 4
#define SCLK_TIMER13_PMU 5
#define SCLK_UART4_PMU 6
#define SCLK_PVTM_PMU 7
#define SCLK_WIFI_PMU 8
#define SCLK_I2C0_PMU 9
#define SCLK_I2C4_PMU 10
#define SCLK_I2C8_PMU 11
#define PCLK_SRC_PMU 19
#define PCLK_PMU 20
#define PCLK_PMUGRF_PMU 21
#define PCLK_INTMEM1_PMU 22
#define PCLK_GPIO0_PMU 23
#define PCLK_GPIO1_PMU 24
#define PCLK_SGRF_PMU 25
#define PCLK_NOC_PMU 26
#define PCLK_I2C0_PMU 27
#define PCLK_I2C4_PMU 28
#define PCLK_I2C8_PMU 29
#define PCLK_RKPWM_PMU 30
#define PCLK_SPI3_PMU 31
#define PCLK_TIMER_PMU 32
#define PCLK_MAILBOX_PMU 33
#define PCLK_UART4_PMU 34
#define PCLK_WDT_M0_PMU 35
#define FCLK_CM0S_SRC_PMU 44
#define FCLK_CM0S_PMU 45
#define SCLK_CM0S_PMU 46
#define HCLK_CM0S_PMU 47
#define DCLK_CM0S_PMU 48
#define PCLK_INTR_ARB_PMU 49
#define HCLK_NOC_PMU 50
#define CLKPMU_NR_CLKS (HCLK_NOC_PMU + 1)
/* soft-reset indices */
/* cru_softrst_con0 */
#define SRST_CORE_L0 0
#define SRST_CORE_B0 1
#define SRST_CORE_PO_L0 2
#define SRST_CORE_PO_B0 3
#define SRST_L2_L 4
#define SRST_L2_B 5
#define SRST_ADB_L 6
#define SRST_ADB_B 7
#define SRST_A_CCI 8
#define SRST_A_CCIM0_NOC 9
#define SRST_A_CCIM1_NOC 10
#define SRST_DBG_NOC 11
/* cru_softrst_con1 */
#define SRST_CORE_L0_T 16
#define SRST_CORE_L1 17
#define SRST_CORE_L2 18
#define SRST_CORE_L3 19
#define SRST_CORE_PO_L0_T 20
#define SRST_CORE_PO_L1 21
#define SRST_CORE_PO_L2 22
#define SRST_CORE_PO_L3 23
#define SRST_A_ADB400_GIC2COREL 24
#define SRST_A_ADB400_COREL2GIC 25
#define SRST_P_DBG_L 26
#define SRST_L2_L_T 28
#define SRST_ADB_L_T 29
#define SRST_A_RKPERF_L 30
#define SRST_PVTM_CORE_L 31
/* cru_softrst_con2 */
#define SRST_CORE_B0_T 32
#define SRST_CORE_B1 33
#define SRST_CORE_PO_B0_T 36
#define SRST_CORE_PO_B1 37
#define SRST_A_ADB400_GIC2COREB 40
#define SRST_A_ADB400_COREB2GIC 41
#define SRST_P_DBG_B 42
#define SRST_L2_B_T 43
#define SRST_ADB_B_T 45
#define SRST_A_RKPERF_B 46
#define SRST_PVTM_CORE_B 47
/* cru_softrst_con3 */
#define SRST_A_CCI_T 50
#define SRST_A_CCIM0_NOC_T 51
#define SRST_A_CCIM1_NOC_T 52
#define SRST_A_ADB400M_PD_CORE_B_T 53
#define SRST_A_ADB400M_PD_CORE_L_T 54
#define SRST_DBG_NOC_T 55
#define SRST_DBG_CXCS 56
#define SRST_CCI_TRACE 57
#define SRST_P_CCI_GRF 58
/* cru_softrst_con4 */
#define SRST_A_CENTER_MAIN_NOC 64
#define SRST_A_CENTER_PERI_NOC 65
#define SRST_P_CENTER_MAIN 66
#define SRST_P_DDRMON 67
#define SRST_P_CIC 68
#define SRST_P_CENTER_SGRF 69
#define SRST_DDR0_MSCH 70
#define SRST_DDRCFG0_MSCH 71
#define SRST_DDR0 72
#define SRST_DDRPHY0 73
#define SRST_DDR1_MSCH 74
#define SRST_DDRCFG1_MSCH 75
#define SRST_DDR1 76
#define SRST_DDRPHY1 77
#define SRST_DDR_CIC 78
#define SRST_PVTM_DDR 79
/* cru_softrst_con5 */
#define SRST_A_VCODEC_NOC 80
#define SRST_A_VCODEC 81
#define SRST_H_VCODEC_NOC 82
#define SRST_H_VCODEC 83
#define SRST_A_VDU_NOC 88
#define SRST_A_VDU 89
#define SRST_H_VDU_NOC 90
#define SRST_H_VDU 91
#define SRST_VDU_CORE 92
#define SRST_VDU_CA 93
/* cru_softrst_con6 */
#define SRST_A_IEP_NOC 96
#define SRST_A_VOP_IEP 97
#define SRST_A_IEP 98
#define SRST_H_IEP_NOC 99
#define SRST_H_IEP 100
#define SRST_A_RGA_NOC 102
#define SRST_A_RGA 103
#define SRST_H_RGA_NOC 104
#define SRST_H_RGA 105
#define SRST_RGA_CORE 106
#define SRST_EMMC_NOC 108
#define SRST_EMMC 109
#define SRST_EMMC_GRF 110
/* cru_softrst_con7 */
#define SRST_A_PERIHP_NOC 112
#define SRST_P_PERIHP_GRF 113
#define SRST_H_PERIHP_NOC 114
#define SRST_USBHOST0 115
#define SRST_HOSTC0_AUX 116
#define SRST_HOST0_ARB 117
#define SRST_USBHOST1 118
#define SRST_HOSTC1_AUX 119
#define SRST_HOST1_ARB 120
#define SRST_SDIO0 121
#define SRST_SDMMC 122
#define SRST_HSIC 123
#define SRST_HSIC_AUX 124
#define SRST_AHB1TOM 125
#define SRST_P_PERIHP_NOC 126
#define SRST_HSICPHY 127
/* cru_softrst_con8 */
#define SRST_A_PCIE 128
#define SRST_P_PCIE 129
#define SRST_PCIE_CORE 130
#define SRST_PCIE_MGMT 131
#define SRST_PCIE_MGMT_STICKY 132
#define SRST_PCIE_PIPE 133
#define SRST_PCIE_PM 134
#define SRST_PCIEPHY 135
#define SRST_A_GMAC_NOC 136
#define SRST_A_GMAC 137
#define SRST_P_GMAC_NOC 138
#define SRST_P_GMAC_GRF 140
#define SRST_HSICPHY_POR 142
#define SRST_HSICPHY_UTMI 143
/* cru_softrst_con9 */
#define SRST_USB2PHY0_POR 144
#define SRST_USB2PHY0_UTMI_PORT0 145
#define SRST_USB2PHY0_UTMI_PORT1 146
#define SRST_USB2PHY0_EHCIPHY 147
#define SRST_UPHY0_PIPE_L00 148
#define SRST_UPHY0 149
#define SRST_UPHY0_TCPDPWRUP 150
#define SRST_USB2PHY1_POR 152
#define SRST_USB2PHY1_UTMI_PORT0 153
#define SRST_USB2PHY1_UTMI_PORT1 154
#define SRST_USB2PHY1_EHCIPHY 155
#define SRST_UPHY1_PIPE_L00 156
#define SRST_UPHY1 157
#define SRST_UPHY1_TCPDPWRUP 158
/* cru_softrst_con10 */
#define SRST_A_PERILP0_NOC 160
#define SRST_A_DCF 161
#define SRST_GIC500 162
#define SRST_DMAC0_PERILP0 163
#define SRST_DMAC1_PERILP0 164
#define SRST_TZMA 165
#define SRST_INTMEM 166
#define SRST_ADB400_MST0 167
#define SRST_ADB400_MST1 168
#define SRST_ADB400_SLV0 169
#define SRST_ADB400_SLV1 170
#define SRST_H_PERILP0 171
#define SRST_H_PERILP0_NOC 172
#define SRST_ROM 173
#define SRST_CRYPTO_S 174
#define SRST_CRYPTO_M 175
/* cru_softrst_con11 */
#define SRST_P_DCF 176
#define SRST_CM0S_NOC 177
#define SRST_CM0S 178
#define SRST_CM0S_DBG 179
#define SRST_CM0S_PO 180
#define SRST_CRYPTO 181
#define SRST_P_PERILP1_SGRF 182
#define SRST_P_PERILP1_GRF 183
#define SRST_CRYPTO1_S 184
#define SRST_CRYPTO1_M 185
#define SRST_CRYPTO1 186
#define SRST_GIC_NOC 188
#define SRST_SD_NOC 189
#define SRST_SDIOAUDIO_BRG 190
/* cru_softrst_con12 */
#define SRST_H_PERILP1 192
#define SRST_H_PERILP1_NOC 193
#define SRST_H_I2S0_8CH 194
#define SRST_H_I2S1_8CH 195
#define SRST_H_I2S2_8CH 196
#define SRST_H_SPDIF_8CH 197
#define SRST_P_PERILP1_NOC 198
#define SRST_P_EFUSE_1024 199
#define SRST_P_EFUSE_1024S 200
#define SRST_P_I2C0 201
#define SRST_P_I2C1 202
#define SRST_P_I2C2 203
#define SRST_P_I2C3 204
#define SRST_P_I2C4 205
#define SRST_P_I2C5 206
#define SRST_P_MAILBOX0 207
/* cru_softrst_con13 */
#define SRST_P_UART0 208
#define SRST_P_UART1 209
#define SRST_P_UART2 210
#define SRST_P_UART3 211
#define SRST_P_SARADC 212
#define SRST_P_TSADC 213
#define SRST_P_SPI0 214
#define SRST_P_SPI1 215
#define SRST_P_SPI2 216
#define SRST_P_SPI3 217
#define SRST_P_SPI4 218
#define SRST_SPI0 219
#define SRST_SPI1 220
#define SRST_SPI2 221
#define SRST_SPI3 222
#define SRST_SPI4 223
/* cru_softrst_con14 */
#define SRST_I2S0_8CH 224
#define SRST_I2S1_8CH 225
#define SRST_I2S2_8CH 226
#define SRST_SPDIF_8CH 227
#define SRST_UART0 228
#define SRST_UART1 229
#define SRST_UART2 230
#define SRST_UART3 231
#define SRST_TSADC 232
#define SRST_I2C0 233
#define SRST_I2C1 234
#define SRST_I2C2 235
#define SRST_I2C3 236
#define SRST_I2C4 237
#define SRST_I2C5 238
#define SRST_SDIOAUDIO_NOC 239
/* cru_softrst_con15 */
#define SRST_A_VIO_NOC 240
#define SRST_A_HDCP_NOC 241
#define SRST_A_HDCP 242
#define SRST_H_HDCP_NOC 243
#define SRST_H_HDCP 244
#define SRST_P_HDCP_NOC 245
#define SRST_P_HDCP 246
#define SRST_P_HDMI_CTRL 247
#define SRST_P_DP_CTRL 248
#define SRST_S_DP_CTRL 249
#define SRST_C_DP_CTRL 250
#define SRST_P_MIPI_DSI0 251
#define SRST_P_MIPI_DSI1 252
#define SRST_DP_CORE 253
#define SRST_DP_I2S 254
/* cru_softrst_con16 */
#define SRST_GASKET 256
#define SRST_VIO_GRF 258
#define SRST_DPTX_SPDIF_REC 259
#define SRST_HDMI_CTRL 260
#define SRST_HDCP_CTRL 261
#define SRST_A_ISP0_NOC 262
#define SRST_A_ISP1_NOC 263
#define SRST_H_ISP0_NOC 266
#define SRST_H_ISP1_NOC 267
#define SRST_H_ISP0 268
#define SRST_H_ISP1 269
#define SRST_ISP0 270
#define SRST_ISP1 271
/* cru_softrst_con17 */
#define SRST_A_VOP0_NOC 272
#define SRST_A_VOP1_NOC 273
#define SRST_A_VOP0 274
#define SRST_A_VOP1 275
#define SRST_H_VOP0_NOC 276
#define SRST_H_VOP1_NOC 277
#define SRST_H_VOP0 278
#define SRST_H_VOP1 279
#define SRST_D_VOP0 280
#define SRST_D_VOP1 281
#define SRST_VOP0_PWM 282
#define SRST_VOP1_PWM 283
#define SRST_P_EDP_NOC 284
#define SRST_P_EDP_CTRL 285
/* cru_softrst_con18 */
#define SRST_A_GPU_NOC 289
#define SRST_A_GPU_GRF 290
#define SRST_PVTM_GPU 291
#define SRST_A_USB3_NOC 292
#define SRST_A_USB3_OTG0 293
#define SRST_A_USB3_OTG1 294
#define SRST_A_USB3_GRF 295
#define SRST_PMU 296
/* cru_softrst_con19 */
#define SRST_P_TIMER0_5 304
#define SRST_TIMER0 305
#define SRST_TIMER1 306
#define SRST_TIMER2 307
#define SRST_TIMER3 308
#define SRST_TIMER4 309
#define SRST_TIMER5 310
#define SRST_P_TIMER6_11 311
#define SRST_TIMER6 312
#define SRST_TIMER7 313
#define SRST_TIMER8 314
#define SRST_TIMER9 315
#define SRST_TIMER10 316
#define SRST_TIMER11 317
#define SRST_P_INTR_ARB_PMU 318
#define SRST_P_ALIVE_SGRF 319
/* cru_softrst_con20 */
#define SRST_P_GPIO2 320
#define SRST_P_GPIO3 321
#define SRST_P_GPIO4 322
#define SRST_P_GRF 323
#define SRST_P_ALIVE_NOC 324
#define SRST_P_WDT0 325
#define SRST_P_WDT1 326
#define SRST_P_INTR_ARB 327
#define SRST_P_UPHY0_DPTX 328
#define SRST_P_UPHY0_APB 330
#define SRST_P_UPHY0_TCPHY 332
#define SRST_P_UPHY1_TCPHY 333
#define SRST_P_UPHY0_TCPDCTRL 334
#define SRST_P_UPHY1_TCPDCTRL 335
/* pmu soft-reset indices */
/* pmu_cru_softrst_con0 */
#define SRST_P_NOC 0
#define SRST_P_INTMEM 1
#define SRST_H_CM0S 2
#define SRST_H_CM0S_NOC 3
#define SRST_DBG_CM0S 4
#define SRST_PO_CM0S 5
#define SRST_P_SPI6 6
#define SRST_SPI6 7
#define SRST_P_TIMER_0_1 8
#define SRST_P_TIMER_0 9
#define SRST_P_TIMER_1 10
#define SRST_P_UART4 11
#define SRST_UART4 12
#define SRST_P_WDT 13
/* pmu_cru_softrst_con1 */
#define SRST_P_I2C6 16
#define SRST_P_I2C7 17
#define SRST_P_I2C8 18
#define SRST_P_MAILBOX 19
#define SRST_P_RKPWM 20
#define SRST_P_PMUGRF 21
#define SRST_P_SGRF 22
#define SRST_P_GPIO0 23
#define SRST_P_GPIO1 24
#define SRST_P_CRU 25
#define SRST_P_INTR 26
#define SRST_PVTM 27
#define SRST_I2C6 28
#define SRST_I2C7 29
#define SRST_I2C8 30
#endif