Skip to content

Commit 83436f2

Browse files
committed
Merge tag 'renesas-clk-for-v6.20-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: - Fix s2ram on Renesas RZ/T2H and RZ/N2H - Add CAN-FD clocks and resets on Renesas RZ/T2H, RZ/N2H, RZ/V2H, and RZ/V2N * tag 'renesas-clk-for-v6.20-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers: clk: renesas: Add missing log message terminators clk: renesas: rzg2l: Remove DSI clock rate restrictions clk: renesas: rzv2h: Deassert reset on assert timeout clk: renesas: rzg2l: Deassert reset on assert timeout clk: renesas: cpg-mssr: Unlock before reset verification clk: renesas: r9a09g056: Add entries for CANFD clk: renesas: r9a09g057: Add entries for CANFD clk: renesas: r9a09g077: Add CANFD clocks clk: renesas: cpg-mssr: Handle RZ/T2H register layout in PM callbacks dt-bindings: clock: renesas,r9a09g077/87: Add PCLKCAN ID clk: renesas: cpg-mssr: Simplify pointer math in cpg_rzt2h_mstp_read()
2 parents a46a9cd + 4fef3fd commit 83436f2

10 files changed

Lines changed: 237 additions & 71 deletions

File tree

drivers/clk/renesas/clk-vbattb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ static void vbattb_clk_action(void *data)
6969

7070
ret = reset_control_assert(rstc);
7171
if (ret)
72-
dev_err(dev, "Failed to de-assert reset!");
72+
dev_err(dev, "Failed to de-assert reset!\n");
7373

7474
ret = pm_runtime_put_sync(dev);
7575
if (ret < 0)
76-
dev_err(dev, "Failed to runtime suspend!");
76+
dev_err(dev, "Failed to runtime suspend!\n");
7777

7878
of_clk_del_provider(dev->of_node);
7979
}

drivers/clk/renesas/r9a09g056-cpg.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum clk_ids {
4646
CLK_PLLCLN_DIV2,
4747
CLK_PLLCLN_DIV8,
4848
CLK_PLLCLN_DIV16,
49+
CLK_PLLCLN_DIV20,
4950
CLK_PLLCLN_DIV64,
5051
CLK_PLLCLN_DIV256,
5152
CLK_PLLCLN_DIV1024,
@@ -183,6 +184,7 @@ static const struct cpg_core_clk r9a09g056_core_clks[] __initconst = {
183184
DEF_FIXED(".pllcln_div2", CLK_PLLCLN_DIV2, CLK_PLLCLN, 1, 2),
184185
DEF_FIXED(".pllcln_div8", CLK_PLLCLN_DIV8, CLK_PLLCLN, 1, 8),
185186
DEF_FIXED(".pllcln_div16", CLK_PLLCLN_DIV16, CLK_PLLCLN, 1, 16),
187+
DEF_FIXED(".pllcln_div20", CLK_PLLCLN_DIV20, CLK_PLLCLN, 1, 20),
186188
DEF_FIXED(".pllcln_div64", CLK_PLLCLN_DIV64, CLK_PLLCLN, 1, 64),
187189
DEF_FIXED(".pllcln_div256", CLK_PLLCLN_DIV256, CLK_PLLCLN, 1, 256),
188190
DEF_FIXED(".pllcln_div1024", CLK_PLLCLN_DIV1024, CLK_PLLCLN, 1, 1024),
@@ -431,6 +433,12 @@ static const struct rzv2h_mod_clk r9a09g056_mod_clks[] __initconst = {
431433
BUS_MSTOP(1, BIT(7))),
432434
DEF_MOD("riic_7_ckm", CLK_PLLCLN_DIV16, 9, 11, 4, 27,
433435
BUS_MSTOP(1, BIT(8))),
436+
DEF_MOD("canfd_0_pclk", CLK_PLLCLN_DIV16, 9, 12, 4, 28,
437+
BUS_MSTOP(10, BIT(14))),
438+
DEF_MOD("canfd_0_clk_ram", CLK_PLLCLN_DIV8, 9, 13, 4, 29,
439+
BUS_MSTOP(10, BIT(14))),
440+
DEF_MOD("canfd_0_clkc", CLK_PLLCLN_DIV20, 9, 14, 4, 30,
441+
BUS_MSTOP(10, BIT(14))),
434442
DEF_MOD("spi_hclk", CLK_PLLCM33_GEAR, 9, 15, 4, 31,
435443
BUS_MSTOP(4, BIT(5))),
436444
DEF_MOD("spi_aclk", CLK_PLLCM33_GEAR, 10, 0, 5, 0,
@@ -603,6 +611,8 @@ static const struct rzv2h_reset r9a09g056_resets[] __initconst = {
603611
DEF_RST(9, 14, 4, 15), /* RIIC_6_MRST */
604612
DEF_RST(9, 15, 4, 16), /* RIIC_7_MRST */
605613
DEF_RST(10, 0, 4, 17), /* RIIC_8_MRST */
614+
DEF_RST(10, 1, 4, 18), /* CANFD_0_RSTP_N */
615+
DEF_RST(10, 2, 4, 19), /* CANFD_0_RSTC_N */
606616
DEF_RST(10, 3, 4, 20), /* SPI_HRESETN */
607617
DEF_RST(10, 4, 4, 21), /* SPI_ARESETN */
608618
DEF_RST(10, 7, 4, 24), /* SDHI_0_IXRST */

drivers/clk/renesas/r9a09g057-cpg.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum clk_ids {
4646
CLK_PLLCLN_DIV2,
4747
CLK_PLLCLN_DIV8,
4848
CLK_PLLCLN_DIV16,
49+
CLK_PLLCLN_DIV20,
4950
CLK_PLLCLN_DIV64,
5051
CLK_PLLCLN_DIV256,
5152
CLK_PLLCLN_DIV1024,
@@ -185,6 +186,7 @@ static const struct cpg_core_clk r9a09g057_core_clks[] __initconst = {
185186
DEF_FIXED(".pllcln_div2", CLK_PLLCLN_DIV2, CLK_PLLCLN, 1, 2),
186187
DEF_FIXED(".pllcln_div8", CLK_PLLCLN_DIV8, CLK_PLLCLN, 1, 8),
187188
DEF_FIXED(".pllcln_div16", CLK_PLLCLN_DIV16, CLK_PLLCLN, 1, 16),
189+
DEF_FIXED(".pllcln_div20", CLK_PLLCLN_DIV20, CLK_PLLCLN, 1, 20),
188190
DEF_FIXED(".pllcln_div64", CLK_PLLCLN_DIV64, CLK_PLLCLN, 1, 64),
189191
DEF_FIXED(".pllcln_div256", CLK_PLLCLN_DIV256, CLK_PLLCLN, 1, 256),
190192
DEF_FIXED(".pllcln_div1024", CLK_PLLCLN_DIV1024, CLK_PLLCLN, 1, 1024),
@@ -440,6 +442,12 @@ static const struct rzv2h_mod_clk r9a09g057_mod_clks[] __initconst = {
440442
BUS_MSTOP(1, BIT(7))),
441443
DEF_MOD("riic_7_ckm", CLK_PLLCLN_DIV16, 9, 11, 4, 27,
442444
BUS_MSTOP(1, BIT(8))),
445+
DEF_MOD("canfd_0_pclk", CLK_PLLCLN_DIV16, 9, 12, 4, 28,
446+
BUS_MSTOP(10, BIT(14))),
447+
DEF_MOD("canfd_0_clk_ram", CLK_PLLCLN_DIV8, 9, 13, 4, 29,
448+
BUS_MSTOP(10, BIT(14))),
449+
DEF_MOD("canfd_0_clkc", CLK_PLLCLN_DIV20, 9, 14, 4, 30,
450+
BUS_MSTOP(10, BIT(14))),
443451
DEF_MOD("spi_hclk", CLK_PLLCM33_GEAR, 9, 15, 4, 31,
444452
BUS_MSTOP(4, BIT(5))),
445453
DEF_MOD("spi_aclk", CLK_PLLCM33_GEAR, 10, 0, 5, 0,
@@ -634,6 +642,8 @@ static const struct rzv2h_reset r9a09g057_resets[] __initconst = {
634642
DEF_RST(9, 14, 4, 15), /* RIIC_6_MRST */
635643
DEF_RST(9, 15, 4, 16), /* RIIC_7_MRST */
636644
DEF_RST(10, 0, 4, 17), /* RIIC_8_MRST */
645+
DEF_RST(10, 1, 4, 18), /* CANFD_0_RSTP_N */
646+
DEF_RST(10, 2, 4, 19), /* CANFD_0_RSTC_N */
637647
DEF_RST(10, 3, 4, 20), /* SPI_HRESETN */
638648
DEF_RST(10, 4, 4, 21), /* SPI_ARESETN */
639649
DEF_RST(10, 7, 4, 24), /* SDHI_0_IXRST */

drivers/clk/renesas/r9a09g077-cpg.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define FSELXSPI1 CONF_PACK(SCKCR, 8, 3)
4848
#define DIVSEL_XSPI0 CONF_PACK(SCKCR, 6, 1)
4949
#define DIVSEL_XSPI1 CONF_PACK(SCKCR, 14, 1)
50+
#define FSELCANFD CONF_PACK(SCKCR, 20, 1)
5051
#define SEL_PLL CONF_PACK(SCKCR, 22, 1)
5152

5253
#define DIVCA55C0 CONF_PACK(SCKCR2, 8, 1)
@@ -85,7 +86,7 @@ enum rzt2h_clk_types {
8586

8687
enum clk_ids {
8788
/* Core Clock Outputs exported to DT */
88-
LAST_DT_CORE_CLK = R9A09G077_XSPI_CLK1,
89+
LAST_DT_CORE_CLK = R9A09G077_PCLKCAN,
8990

9091
/* External Input Clocks */
9192
CLK_EXTAL,
@@ -103,6 +104,9 @@ enum clk_ids {
103104
CLK_PLL4D1,
104105
CLK_PLL4D1_DIV3,
105106
CLK_PLL4D1_DIV4,
107+
CLK_PLL4D3,
108+
CLK_PLL4D3_DIV10,
109+
CLK_PLL4D3_DIV20,
106110
CLK_SCI0ASYNC,
107111
CLK_SCI1ASYNC,
108112
CLK_SCI2ASYNC,
@@ -150,6 +154,7 @@ static const char * const sel_clk_pll1[] = { ".loco", ".pll1" };
150154
static const char * const sel_clk_pll2[] = { ".loco", ".pll2" };
151155
static const char * const sel_clk_pll4[] = { ".loco", ".pll4" };
152156
static const char * const sel_clk_pll4d1_div3_div4[] = { ".pll4d1_div3", ".pll4d1_div4" };
157+
static const char * const sel_clk_pll4d3_div10_div20[] = { ".pll4d3_div10", ".pll4d3_div20" };
153158

154159
static const struct cpg_core_clk r9a09g077_core_clks[] __initconst = {
155160
/* External Clock Inputs */
@@ -174,6 +179,9 @@ static const struct cpg_core_clk r9a09g077_core_clks[] __initconst = {
174179
DEF_FIXED(".pll4d1", CLK_PLL4D1, CLK_SEL_CLK_PLL4, 1, 1),
175180
DEF_FIXED(".pll4d1_div3", CLK_PLL4D1_DIV3, CLK_PLL4D1, 3, 1),
176181
DEF_FIXED(".pll4d1_div4", CLK_PLL4D1_DIV4, CLK_PLL4D1, 4, 1),
182+
DEF_FIXED(".pll4d3", CLK_PLL4D3, CLK_SEL_CLK_PLL4, 3, 1),
183+
DEF_FIXED(".pll4d3_div10", CLK_PLL4D3_DIV10, CLK_PLL4D3, 10, 1),
184+
DEF_FIXED(".pll4d3_div20", CLK_PLL4D3_DIV20, CLK_PLL4D3, 20, 1),
177185

178186
DEF_DIV(".sci0async", CLK_SCI0ASYNC, CLK_PLL4D1, DIVSCI0ASYNC,
179187
dtable_24_25_30_32),
@@ -232,6 +240,8 @@ static const struct cpg_core_clk r9a09g077_core_clks[] __initconst = {
232240
FSELXSPI0, dtable_6_8_16_32_64),
233241
DEF_DIV_FSELXSPI("XSPI_CLK1", R9A09G077_XSPI_CLK1, CLK_DIVSELXSPI1_SCKCR,
234242
FSELXSPI1, dtable_6_8_16_32_64),
243+
DEF_MUX("PCLKCAN", R9A09G077_PCLKCAN, FSELCANFD,
244+
sel_clk_pll4d3_div10_div20, ARRAY_SIZE(sel_clk_pll4d3_div10_div20), 0),
235245
};
236246

237247
static const struct mssr_mod_clk r9a09g077_mod_clks[] __initconst = {
@@ -251,6 +261,7 @@ static const struct mssr_mod_clk r9a09g077_mod_clks[] __initconst = {
251261
DEF_MOD("adc1", 207, R9A09G077_CLK_PCLKH),
252262
DEF_MOD("adc2", 225, R9A09G077_CLK_PCLKM),
253263
DEF_MOD("tsu", 307, R9A09G077_CLK_PCLKL),
264+
DEF_MOD("canfd", 310, R9A09G077_CLK_PCLKM),
254265
DEF_MOD("gmac0", 400, R9A09G077_CLK_PCLKM),
255266
DEF_MOD("ethsw", 401, R9A09G077_CLK_PCLKM),
256267
DEF_MOD("ethss", 403, R9A09G077_CLK_PCLKM),

drivers/clk/renesas/renesas-cpg-mssr.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,16 @@ struct mstp_clock {
237237

238238
#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw)
239239

240-
static u32 cpg_rzt2h_mstp_read(struct clk_hw *hw, u16 offset)
240+
static u32 cpg_rzt2h_mstp_read(struct cpg_mssr_priv *priv, u16 offset)
241241
{
242-
struct mstp_clock *clock = to_mstp_clock(hw);
243-
struct cpg_mssr_priv *priv = clock->priv;
244242
void __iomem *base =
245243
RZT2H_MSTPCR_BLOCK(offset) ? priv->pub.base1 : priv->pub.base0;
246244

247245
return readl(base + RZT2H_MSTPCR_OFFSET(offset));
248246
}
249247

250-
static void cpg_rzt2h_mstp_write(struct clk_hw *hw, u16 offset, u32 value)
248+
static void cpg_rzt2h_mstp_write(struct cpg_mssr_priv *priv, u16 offset, u32 value)
251249
{
252-
struct mstp_clock *clock = to_mstp_clock(hw);
253-
struct cpg_mssr_priv *priv = clock->priv;
254250
void __iomem *base =
255251
RZT2H_MSTPCR_BLOCK(offset) ? priv->pub.base1 : priv->pub.base0;
256252

@@ -286,17 +282,14 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
286282
barrier_data(priv->pub.base0 + priv->control_regs[reg]);
287283

288284
} else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) {
289-
value = cpg_rzt2h_mstp_read(hw,
290-
priv->control_regs[reg]);
285+
value = cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
291286

292287
if (enable)
293288
value &= ~bitmask;
294289
else
295290
value |= bitmask;
296291

297-
cpg_rzt2h_mstp_write(hw,
298-
priv->control_regs[reg],
299-
value);
292+
cpg_rzt2h_mstp_write(priv, priv->control_regs[reg], value);
300293
} else {
301294
value = readl(priv->pub.base0 + priv->control_regs[reg]);
302295
if (enable)
@@ -318,7 +311,7 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
318311
* the IP at least seven times. Instead of memory-mapping the IP
319312
* register, we simply add a delay after the read operation.
320313
*/
321-
cpg_rzt2h_mstp_read(hw, priv->control_regs[reg]);
314+
cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
322315
udelay(10);
323316
return 0;
324317
}
@@ -352,8 +345,7 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
352345
if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A)
353346
value = readb(priv->pub.base0 + priv->control_regs[reg]);
354347
else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H)
355-
value = cpg_rzt2h_mstp_read(hw,
356-
priv->control_regs[reg]);
348+
value = cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
357349
else
358350
value = readl(priv->pub.base0 + priv->status_regs[reg]);
359351

@@ -412,7 +404,7 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec,
412404
}
413405

414406
if (IS_ERR(clk))
415-
dev_err(dev, "Cannot get %s clock %u: %ld", type, clkidx,
407+
dev_err(dev, "Cannot get %s clock %u: %ld\n", type, clkidx,
416408
PTR_ERR(clk));
417409
else
418410
dev_dbg(dev, "clock (%u, %u) is %pC at %lu Hz\n",
@@ -802,14 +794,14 @@ static int cpg_mrcr_set_reset_state(struct reset_controller_dev *rcdev,
802794

803795
/* Verify the operation */
804796
val = readl(reg_addr);
797+
798+
spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
799+
805800
if (set == !(bitmask & val)) {
806801
dev_err(priv->dev, "Reset register %u%02u operation failed\n", reg, bit);
807-
spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
808802
return -EIO;
809803
}
810804

811-
spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
812-
813805
return 0;
814806
}
815807

@@ -1085,11 +1077,19 @@ static int cpg_mssr_suspend_noirq(struct device *dev)
10851077

10861078
/* Save module registers with bits under our control */
10871079
for (reg = 0; reg < ARRAY_SIZE(priv->smstpcr_saved); reg++) {
1088-
if (priv->smstpcr_saved[reg].mask)
1089-
priv->smstpcr_saved[reg].val =
1090-
priv->reg_layout == CLK_REG_LAYOUT_RZ_A ?
1091-
readb(priv->pub.base0 + priv->control_regs[reg]) :
1092-
readl(priv->pub.base0 + priv->control_regs[reg]);
1080+
u32 val;
1081+
1082+
if (!priv->smstpcr_saved[reg].mask)
1083+
continue;
1084+
1085+
if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A)
1086+
val = readb(priv->pub.base0 + priv->control_regs[reg]);
1087+
else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H)
1088+
val = cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
1089+
else
1090+
val = readl(priv->pub.base0 + priv->control_regs[reg]);
1091+
1092+
priv->smstpcr_saved[reg].val = val;
10931093
}
10941094

10951095
/* Save core clocks */
@@ -1120,6 +1120,8 @@ static int cpg_mssr_resume_noirq(struct device *dev)
11201120

11211121
if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A)
11221122
oldval = readb(priv->pub.base0 + priv->control_regs[reg]);
1123+
else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H)
1124+
oldval = cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
11231125
else
11241126
oldval = readl(priv->pub.base0 + priv->control_regs[reg]);
11251127
newval = oldval & ~mask;
@@ -1133,6 +1135,12 @@ static int cpg_mssr_resume_noirq(struct device *dev)
11331135
readb(priv->pub.base0 + priv->control_regs[reg]);
11341136
barrier_data(priv->pub.base0 + priv->control_regs[reg]);
11351137
continue;
1138+
} else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) {
1139+
cpg_rzt2h_mstp_write(priv, priv->control_regs[reg], newval);
1140+
/* See cpg_mstp_clock_endisable() on why this is necessary. */
1141+
cpg_rzt2h_mstp_read(priv, priv->control_regs[reg]);
1142+
udelay(10);
1143+
continue;
11361144
} else
11371145
writel(newval, priv->pub.base0 + priv->control_regs[reg]);
11381146

0 commit comments

Comments
 (0)