Skip to content

Commit 38a7eb9

Browse files
bijudasgeertu
authored andcommitted
clk: renesas: r9a09g047: Add support for xspi mux and divider
The mux smux2_xspi_clk{0,1} used for selecting spi and spix2 clocks and pllcm33_xspi divider to select different clock rates. Add support for both. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/20250424081400.135028-3-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent d4da08e commit 38a7eb9

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

drivers/clk/renesas/r9a09g047-cpg.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
enum clk_ids {
1818
/* Core Clock Outputs exported to DT */
19-
LAST_DT_CORE_CLK = R9A09G047_IOTOP_0_SHCLK,
19+
LAST_DT_CORE_CLK = R9A09G047_GBETH_1_CLK_PTP_REF_I,
2020

2121
/* External Input Clocks */
2222
CLK_AUDIO_EXTAL,
@@ -31,7 +31,13 @@ enum clk_ids {
3131
CLK_PLLVDO,
3232

3333
/* Internal Core Clocks */
34+
CLK_PLLCM33_DIV3,
35+
CLK_PLLCM33_DIV4,
36+
CLK_PLLCM33_DIV5,
3437
CLK_PLLCM33_DIV16,
38+
CLK_SMUX2_XSPI_CLK0,
39+
CLK_SMUX2_XSPI_CLK1,
40+
CLK_PLLCM33_XSPI,
3541
CLK_PLLCLN_DIV2,
3642
CLK_PLLCLN_DIV8,
3743
CLK_PLLCLN_DIV16,
@@ -61,6 +67,14 @@ static const struct clk_div_table dtable_2_4[] = {
6167
{0, 0},
6268
};
6369

70+
static const struct clk_div_table dtable_2_16[] = {
71+
{0, 2},
72+
{1, 4},
73+
{2, 8},
74+
{3, 16},
75+
{0, 0},
76+
};
77+
6478
static const struct clk_div_table dtable_2_64[] = {
6579
{0, 2},
6680
{1, 4},
@@ -70,6 +84,10 @@ static const struct clk_div_table dtable_2_64[] = {
7084
{0, 0},
7185
};
7286

87+
/* Mux clock tables */
88+
static const char * const smux2_xspi_clk0[] = { ".pllcm33_div3", ".pllcm33_div4" };
89+
static const char * const smux2_xspi_clk1[] = { ".smux2_xspi_clk0", ".pllcm33_div5" };
90+
7391
static const struct cpg_core_clk r9a09g047_core_clks[] __initconst = {
7492
/* External Clock Inputs */
7593
DEF_INPUT("audio_extal", CLK_AUDIO_EXTAL),
@@ -84,8 +102,15 @@ static const struct cpg_core_clk r9a09g047_core_clks[] __initconst = {
84102
DEF_FIXED(".pllvdo", CLK_PLLVDO, CLK_QEXTAL, 105, 2),
85103

86104
/* Internal Core Clocks */
105+
DEF_FIXED(".pllcm33_div3", CLK_PLLCM33_DIV3, CLK_PLLCM33, 1, 3),
106+
DEF_FIXED(".pllcm33_div4", CLK_PLLCM33_DIV4, CLK_PLLCM33, 1, 4),
107+
DEF_FIXED(".pllcm33_div5", CLK_PLLCM33_DIV5, CLK_PLLCM33, 1, 5),
87108
DEF_FIXED(".pllcm33_div16", CLK_PLLCM33_DIV16, CLK_PLLCM33, 1, 16),
88109

110+
DEF_SMUX(".smux2_xspi_clk0", CLK_SMUX2_XSPI_CLK0, SSEL1_SELCTL2, smux2_xspi_clk0),
111+
DEF_SMUX(".smux2_xspi_clk1", CLK_SMUX2_XSPI_CLK1, SSEL1_SELCTL3, smux2_xspi_clk1),
112+
DEF_CSDIV(".pllcm33_xspi", CLK_PLLCM33_XSPI, CLK_SMUX2_XSPI_CLK1, CSDIV0_DIVCTL3,
113+
dtable_2_16),
89114
DEF_FIXED(".pllcln_div2", CLK_PLLCLN_DIV2, CLK_PLLCLN, 1, 2),
90115
DEF_FIXED(".pllcln_div8", CLK_PLLCLN_DIV8, CLK_PLLCLN, 1, 8),
91116
DEF_FIXED(".pllcln_div16", CLK_PLLCLN_DIV16, CLK_PLLCLN, 1, 16),

drivers/clk/renesas/rzv2h-cpg.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ struct smuxed {
9393
.width = (_width), \
9494
})
9595

96+
#define CPG_SSEL1 (0x304)
9697
#define CPG_CDDIV0 (0x400)
9798
#define CPG_CDDIV1 (0x404)
9899
#define CPG_CDDIV3 (0x40C)
99100
#define CPG_CDDIV4 (0x410)
101+
#define CPG_CSDIV0 (0x500)
100102

101103
#define CDDIV0_DIVCTL1 DDIV_PACK(CPG_CDDIV0, 4, 3, 1)
102104
#define CDDIV0_DIVCTL2 DDIV_PACK(CPG_CDDIV0, 8, 3, 2)
@@ -111,6 +113,11 @@ struct smuxed {
111113
#define CDDIV4_DIVCTL1 DDIV_PACK(CPG_CDDIV4, 4, 1, 17)
112114
#define CDDIV4_DIVCTL2 DDIV_PACK(CPG_CDDIV4, 8, 1, 18)
113115

116+
#define CSDIV0_DIVCTL3 DDIV_PACK_NO_RMW(CPG_CSDIV0, 12, 2, CSDIV_NO_MON)
117+
118+
#define SSEL1_SELCTL2 SMUX_PACK(CPG_SSEL1, 8, 1)
119+
#define SSEL1_SELCTL3 SMUX_PACK(CPG_SSEL1, 12, 1)
120+
114121
#define BUS_MSTOP_IDX_MASK GENMASK(31, 16)
115122
#define BUS_MSTOP_BITS_MASK GENMASK(15, 0)
116123
#define BUS_MSTOP(idx, mask) (FIELD_PREP_CONST(BUS_MSTOP_IDX_MASK, (idx)) | \

0 commit comments

Comments
 (0)