clk: renesas: Updates for v5.3 (take two)

- Add CMM (Color Management Module) clocks on R-Car H3, M3-N, E3, and
     D3,
   - Add TPU (Timer Pulse Unit / PWM) clocks on RZ/G2M,
   - Small cleanups and fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQ9qaHoIs/1I4cXmEiKwlD9ZEnxcAUCXQy+1AAKCRCKwlD9ZEnx
 cC8LAQCsE32MMF2iAfKikxhz37b/KRGTvDd44qkSyQNH2KWZDwD/UF6UAvuTOkTe
 nxlojcNfZyoVPboCq455tBQHxnSThgU=
 =VDNs
 -----END PGP SIGNATURE-----

Merge tag 'clk-renesas-for-v5.3-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into clk-renesas

Pull Renesas clk driver updates from Geert Uytterhoeven:

  - Add CMM (Color Management Module) clocks on R-Car H3, M3-N, E3, and D3
  - Add TPU (Timer Pulse Unit / PWM) clocks on RZ/G2M
  - Small cleanups and fixes

* tag 'clk-renesas-for-v5.3-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers:
  clk: renesas: cpg-mssr: Use [] to denote a flexible array member
  clk: renesas: cpg-mssr: Combine driver-private and clock array allocation
  clk: renesas: mstp: Combine group-private and clock array allocation
  clk: renesas: div6: Combine clock-private and parent array allocation
  clk: renesas: cpg-mssr: Update kerneldoc for struct cpg_mssr_priv
  clk: renesas: r8a774a1: Add TMU clock
  clk: renesas: r8a77995: Add CMM clocks
  clk: renesas: r8a77990: Add CMM clocks
  clk: renesas: r8a77965: Add CMM clocks
  clk: renesas: r8a7795: Add CMM clocks
This commit is contained in:
Stephen Boyd 2019-06-24 20:04:57 -07:00
commit 5b68f22c3e
8 changed files with 36 additions and 36 deletions

View File

@ -30,8 +30,8 @@
* @div: divisor value (1-64) * @div: divisor value (1-64)
* @src_shift: Shift to access the register bits to select the parent clock * @src_shift: Shift to access the register bits to select the parent clock
* @src_width: Number of register bits to select the parent clock (may be 0) * @src_width: Number of register bits to select the parent clock (may be 0)
* @parents: Array to map from valid parent clocks indices to hardware indices
* @nb: Notifier block to save/restore clock state for system resume * @nb: Notifier block to save/restore clock state for system resume
* @parents: Array to map from valid parent clocks indices to hardware indices
*/ */
struct div6_clock { struct div6_clock {
struct clk_hw hw; struct clk_hw hw;
@ -39,8 +39,8 @@ struct div6_clock {
unsigned int div; unsigned int div;
u32 src_shift; u32 src_shift;
u32 src_width; u32 src_width;
u8 *parents;
struct notifier_block nb; struct notifier_block nb;
u8 parents[];
}; };
#define to_div6_clock(_hw) container_of(_hw, struct div6_clock, hw) #define to_div6_clock(_hw) container_of(_hw, struct div6_clock, hw)
@ -221,17 +221,10 @@ struct clk * __init cpg_div6_register(const char *name,
struct clk *clk; struct clk *clk;
unsigned int i; unsigned int i;
clock = kzalloc(sizeof(*clock), GFP_KERNEL); clock = kzalloc(struct_size(clock, parents, num_parents), GFP_KERNEL);
if (!clock) if (!clock)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
clock->parents = kmalloc_array(num_parents, sizeof(*clock->parents),
GFP_KERNEL);
if (!clock->parents) {
clk = ERR_PTR(-ENOMEM);
goto free_clock;
}
clock->reg = reg; clock->reg = reg;
/* /*
@ -259,7 +252,7 @@ struct clk * __init cpg_div6_register(const char *name,
pr_err("%s: invalid number of parents for DIV6 clock %s\n", pr_err("%s: invalid number of parents for DIV6 clock %s\n",
__func__, name); __func__, name);
clk = ERR_PTR(-EINVAL); clk = ERR_PTR(-EINVAL);
goto free_parents; goto free_clock;
} }
/* Filter out invalid parents */ /* Filter out invalid parents */
@ -282,7 +275,7 @@ struct clk * __init cpg_div6_register(const char *name,
clk = clk_register(NULL, &clock->hw); clk = clk_register(NULL, &clock->hw);
if (IS_ERR(clk)) if (IS_ERR(clk))
goto free_parents; goto free_clock;
if (notifiers) { if (notifiers) {
clock->nb.notifier_call = cpg_div6_clock_notifier_call; clock->nb.notifier_call = cpg_div6_clock_notifier_call;
@ -291,8 +284,6 @@ struct clk * __init cpg_div6_register(const char *name,
return clk; return clk;
free_parents:
kfree(clock->parents);
free_clock: free_clock:
kfree(clock); kfree(clock);
return clk; return clk;

View File

@ -30,11 +30,12 @@
/** /**
* struct mstp_clock_group - MSTP gating clocks group * struct mstp_clock_group - MSTP gating clocks group
* *
* @data: clocks in this group * @data: clock specifier translation for clocks in this group
* @smstpcr: module stop control register * @smstpcr: module stop control register
* @mstpsr: module stop status register (optional) * @mstpsr: module stop status register (optional)
* @lock: protects writes to SMSTPCR * @lock: protects writes to SMSTPCR
* @width_8bit: registers are 8-bit, not 32-bit * @width_8bit: registers are 8-bit, not 32-bit
* @clks: clocks in this group
*/ */
struct mstp_clock_group { struct mstp_clock_group {
struct clk_onecell_data data; struct clk_onecell_data data;
@ -42,6 +43,7 @@ struct mstp_clock_group {
void __iomem *mstpsr; void __iomem *mstpsr;
spinlock_t lock; spinlock_t lock;
bool width_8bit; bool width_8bit;
struct clk *clks[];
}; };
/** /**
@ -186,14 +188,13 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
struct clk **clks; struct clk **clks;
unsigned int i; unsigned int i;
group = kzalloc(sizeof(*group), GFP_KERNEL); group = kzalloc(struct_size(group, clks, MSTP_MAX_CLOCKS), GFP_KERNEL);
clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL); if (group == NULL) {
if (group == NULL || clks == NULL) {
kfree(group); kfree(group);
kfree(clks);
return; return;
} }
clks = group->clks;
spin_lock_init(&group->lock); spin_lock_init(&group->lock);
group->data.clks = clks; group->data.clks = clks;
@ -203,7 +204,6 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
if (group->smstpcr == NULL) { if (group->smstpcr == NULL) {
pr_err("%s: failed to remap SMSTPCR\n", __func__); pr_err("%s: failed to remap SMSTPCR\n", __func__);
kfree(group); kfree(group);
kfree(clks);
return; return;
} }

View File

@ -113,6 +113,11 @@ static const struct cpg_core_clk r8a774a1_core_clks[] __initconst = {
}; };
static const struct mssr_mod_clk r8a774a1_mod_clks[] __initconst = { static const struct mssr_mod_clk r8a774a1_mod_clks[] __initconst = {
DEF_MOD("tmu4", 121, R8A774A1_CLK_S0D6),
DEF_MOD("tmu3", 122, R8A774A1_CLK_S3D2),
DEF_MOD("tmu2", 123, R8A774A1_CLK_S3D2),
DEF_MOD("tmu1", 124, R8A774A1_CLK_S3D2),
DEF_MOD("tmu0", 125, R8A774A1_CLK_CP),
DEF_MOD("fdp1-0", 119, R8A774A1_CLK_S0D1), DEF_MOD("fdp1-0", 119, R8A774A1_CLK_S0D1),
DEF_MOD("scif5", 202, R8A774A1_CLK_S3D4), DEF_MOD("scif5", 202, R8A774A1_CLK_S3D4),
DEF_MOD("scif4", 203, R8A774A1_CLK_S3D4), DEF_MOD("scif4", 203, R8A774A1_CLK_S3D4),

View File

@ -202,6 +202,10 @@ static struct mssr_mod_clk r8a7795_mod_clks[] __initdata = {
DEF_MOD("ehci0", 703, R8A7795_CLK_S3D2), DEF_MOD("ehci0", 703, R8A7795_CLK_S3D2),
DEF_MOD("hsusb", 704, R8A7795_CLK_S3D2), DEF_MOD("hsusb", 704, R8A7795_CLK_S3D2),
DEF_MOD("hsusb3", 705, R8A7795_CLK_S3D2), DEF_MOD("hsusb3", 705, R8A7795_CLK_S3D2),
DEF_MOD("cmm3", 708, R8A7795_CLK_S2D1),
DEF_MOD("cmm2", 709, R8A7795_CLK_S2D1),
DEF_MOD("cmm1", 710, R8A7795_CLK_S2D1),
DEF_MOD("cmm0", 711, R8A7795_CLK_S2D1),
DEF_MOD("csi21", 713, R8A7795_CLK_CSI0), /* ES1.x */ DEF_MOD("csi21", 713, R8A7795_CLK_CSI0), /* ES1.x */
DEF_MOD("csi20", 714, R8A7795_CLK_CSI0), DEF_MOD("csi20", 714, R8A7795_CLK_CSI0),
DEF_MOD("csi41", 715, R8A7795_CLK_CSI0), DEF_MOD("csi41", 715, R8A7795_CLK_CSI0),

View File

@ -180,6 +180,9 @@ static const struct mssr_mod_clk r8a77965_mod_clks[] __initconst = {
DEF_MOD("ehci1", 702, R8A77965_CLK_S3D2), DEF_MOD("ehci1", 702, R8A77965_CLK_S3D2),
DEF_MOD("ehci0", 703, R8A77965_CLK_S3D2), DEF_MOD("ehci0", 703, R8A77965_CLK_S3D2),
DEF_MOD("hsusb", 704, R8A77965_CLK_S3D2), DEF_MOD("hsusb", 704, R8A77965_CLK_S3D2),
DEF_MOD("cmm3", 708, R8A77965_CLK_S2D1),
DEF_MOD("cmm1", 710, R8A77965_CLK_S2D1),
DEF_MOD("cmm0", 711, R8A77965_CLK_S2D1),
DEF_MOD("csi20", 714, R8A77965_CLK_CSI0), DEF_MOD("csi20", 714, R8A77965_CLK_CSI0),
DEF_MOD("csi40", 716, R8A77965_CLK_CSI0), DEF_MOD("csi40", 716, R8A77965_CLK_CSI0),
DEF_MOD("du3", 721, R8A77965_CLK_S2D1), DEF_MOD("du3", 721, R8A77965_CLK_S2D1),

View File

@ -183,6 +183,8 @@ static const struct mssr_mod_clk r8a77990_mod_clks[] __initconst = {
DEF_MOD("ehci0", 703, R8A77990_CLK_S3D2), DEF_MOD("ehci0", 703, R8A77990_CLK_S3D2),
DEF_MOD("hsusb", 704, R8A77990_CLK_S3D2), DEF_MOD("hsusb", 704, R8A77990_CLK_S3D2),
DEF_MOD("cmm1", 710, R8A77990_CLK_S1D1),
DEF_MOD("cmm0", 711, R8A77990_CLK_S1D1),
DEF_MOD("csi40", 716, R8A77990_CLK_CSI0), DEF_MOD("csi40", 716, R8A77990_CLK_CSI0),
DEF_MOD("du1", 723, R8A77990_CLK_S1D1), DEF_MOD("du1", 723, R8A77990_CLK_S1D1),
DEF_MOD("du0", 724, R8A77990_CLK_S1D1), DEF_MOD("du0", 724, R8A77990_CLK_S1D1),

View File

@ -146,6 +146,8 @@ static const struct mssr_mod_clk r8a77995_mod_clks[] __initconst = {
DEF_MOD("vspbs", 627, R8A77995_CLK_S0D1), DEF_MOD("vspbs", 627, R8A77995_CLK_S0D1),
DEF_MOD("ehci0", 703, R8A77995_CLK_S3D2), DEF_MOD("ehci0", 703, R8A77995_CLK_S3D2),
DEF_MOD("hsusb", 704, R8A77995_CLK_S3D2), DEF_MOD("hsusb", 704, R8A77995_CLK_S3D2),
DEF_MOD("cmm1", 710, R8A77995_CLK_S1D1),
DEF_MOD("cmm0", 711, R8A77995_CLK_S1D1),
DEF_MOD("du1", 723, R8A77995_CLK_S1D1), DEF_MOD("du1", 723, R8A77995_CLK_S1D1),
DEF_MOD("du0", 724, R8A77995_CLK_S1D1), DEF_MOD("du0", 724, R8A77995_CLK_S1D1),
DEF_MOD("lvds", 727, R8A77995_CLK_S2D1), DEF_MOD("lvds", 727, R8A77995_CLK_S2D1),

View File

@ -112,14 +112,15 @@ static const u16 srcr[] = {
* @dev: CPG/MSSR device * @dev: CPG/MSSR device
* @base: CPG/MSSR register block base address * @base: CPG/MSSR register block base address
* @rmw_lock: protects RMW register accesses * @rmw_lock: protects RMW register accesses
* @clks: Array containing all Core and Module Clocks * @np: Device node in DT for this CPG/MSSR module
* @num_core_clks: Number of Core Clocks in clks[] * @num_core_clks: Number of Core Clocks in clks[]
* @num_mod_clks: Number of Module Clocks in clks[] * @num_mod_clks: Number of Module Clocks in clks[]
* @last_dt_core_clk: ID of the last Core Clock exported to DT * @last_dt_core_clk: ID of the last Core Clock exported to DT
* @stbyctrl: This device has Standby Control Registers
* @notifiers: Notifier chain to save/restore clock state for system resume * @notifiers: Notifier chain to save/restore clock state for system resume
* @smstpcr_saved[].mask: Mask of SMSTPCR[] bits under our control * @smstpcr_saved[].mask: Mask of SMSTPCR[] bits under our control
* @smstpcr_saved[].val: Saved values of SMSTPCR[] * @smstpcr_saved[].val: Saved values of SMSTPCR[]
* @stbyctrl: This device has Standby Control Registers * @clks: Array containing all Core and Module Clocks
*/ */
struct cpg_mssr_priv { struct cpg_mssr_priv {
#ifdef CONFIG_RESET_CONTROLLER #ifdef CONFIG_RESET_CONTROLLER
@ -130,7 +131,6 @@ struct cpg_mssr_priv {
spinlock_t rmw_lock; spinlock_t rmw_lock;
struct device_node *np; struct device_node *np;
struct clk **clks;
unsigned int num_core_clks; unsigned int num_core_clks;
unsigned int num_mod_clks; unsigned int num_mod_clks;
unsigned int last_dt_core_clk; unsigned int last_dt_core_clk;
@ -141,6 +141,8 @@ struct cpg_mssr_priv {
u32 mask; u32 mask;
u32 val; u32 val;
} smstpcr_saved[ARRAY_SIZE(smstpcr)]; } smstpcr_saved[ARRAY_SIZE(smstpcr)];
struct clk *clks[];
}; };
static struct cpg_mssr_priv *cpg_mssr_priv; static struct cpg_mssr_priv *cpg_mssr_priv;
@ -448,7 +450,7 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod,
struct cpg_mssr_clk_domain { struct cpg_mssr_clk_domain {
struct generic_pm_domain genpd; struct generic_pm_domain genpd;
unsigned int num_core_pm_clks; unsigned int num_core_pm_clks;
unsigned int core_pm_clks[0]; unsigned int core_pm_clks[];
}; };
static struct cpg_mssr_clk_domain *cpg_mssr_clk_domain; static struct cpg_mssr_clk_domain *cpg_mssr_clk_domain;
@ -890,7 +892,6 @@ static int __init cpg_mssr_common_init(struct device *dev,
const struct cpg_mssr_info *info) const struct cpg_mssr_info *info)
{ {
struct cpg_mssr_priv *priv; struct cpg_mssr_priv *priv;
struct clk **clks = NULL;
unsigned int nclks, i; unsigned int nclks, i;
int error; int error;
@ -900,7 +901,8 @@ static int __init cpg_mssr_common_init(struct device *dev,
return error; return error;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); nclks = info->num_total_core_clks + info->num_hw_mod_clks;
priv = kzalloc(struct_size(priv, clks, nclks), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -914,15 +916,7 @@ static int __init cpg_mssr_common_init(struct device *dev,
goto out_err; goto out_err;
} }
nclks = info->num_total_core_clks + info->num_hw_mod_clks;
clks = kmalloc_array(nclks, sizeof(*clks), GFP_KERNEL);
if (!clks) {
error = -ENOMEM;
goto out_err;
}
cpg_mssr_priv = priv; cpg_mssr_priv = priv;
priv->clks = clks;
priv->num_core_clks = info->num_total_core_clks; priv->num_core_clks = info->num_total_core_clks;
priv->num_mod_clks = info->num_hw_mod_clks; priv->num_mod_clks = info->num_hw_mod_clks;
priv->last_dt_core_clk = info->last_dt_core_clk; priv->last_dt_core_clk = info->last_dt_core_clk;
@ -930,7 +924,7 @@ static int __init cpg_mssr_common_init(struct device *dev,
priv->stbyctrl = info->stbyctrl; priv->stbyctrl = info->stbyctrl;
for (i = 0; i < nclks; i++) for (i = 0; i < nclks; i++)
clks[i] = ERR_PTR(-ENOENT); priv->clks[i] = ERR_PTR(-ENOENT);
error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv); error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv);
if (error) if (error)
@ -939,7 +933,6 @@ static int __init cpg_mssr_common_init(struct device *dev,
return 0; return 0;
out_err: out_err:
kfree(clks);
if (priv->base) if (priv->base)
iounmap(priv->base); iounmap(priv->base);
kfree(priv); kfree(priv);