Skip to content

Commit d5252d9

Browse files
dirkbehmegeertu
authored andcommitted
clk: renesas: rcar-gen3: Extend SDnH divider table
The clock dividers might be used with clock stop bit enabled or not. Current tables only support recommended values from the datasheet. This might result in warnings like below because no valid clock divider is found. Resulting in a 0 divider. There are Renesas ARM Trusted Firmware version out there which e.g. configure 0x201 (shifted logical right by 2: 0x80) and with this match the added { STPnHCK | 0, 1 }: https://github.com/renesas-rcar/arm-trusted-firmware/blob/rcar_gen3_v2.3/drivers/renesas/rcar/emmc/emmc_init.c#L108 ------------[ cut here ]------------ sd1h: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set WARNING: CPU: 1 PID: 1 at drivers/clk/clk-divider.c:141 divider_recalc_rate+0x48/0x70 Modules linked in: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.1.52 #1 Hardware name: Custom board based on r8a7796 (DT) pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : divider_recalc_rate+0x48/0x70 ... ------------[ cut here ]------------ Fixes: bb6d3fa ("clk: renesas: rcar-gen3: Switch to new SD clock handling") Signed-off-by: Dirk Behme <[email protected]> [wsa: extended the table to 5 entries, added comments, reword commit message a little] Signed-off-by: Wolfram Sang <[email protected]> Tested-by: Dirk Behme <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 8788252 commit d5252d9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/clk/renesas/rcar-cpg-lib.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,21 @@ void cpg_simple_notifier_register(struct raw_notifier_head *notifiers,
7070
#define STPnHCK BIT(9 - SDnSRCFC_SHIFT)
7171

7272
static const struct clk_div_table cpg_sdh_div_table[] = {
73+
/*
74+
* These values are recommended by the datasheet. Because they come
75+
* first, Linux will only use these.
76+
*/
7377
{ 0, 1 }, { 1, 2 }, { STPnHCK | 2, 4 }, { STPnHCK | 3, 8 },
74-
{ STPnHCK | 4, 16 }, { 0, 0 },
78+
{ STPnHCK | 4, 16 },
79+
/*
80+
* These values are not recommended because STPnHCK is wrong. But they
81+
* have been seen because of broken firmware. So, we support reading
82+
* them but Linux will sanitize them when initializing through
83+
* recalc_rate.
84+
*/
85+
{ STPnHCK | 0, 1 }, { STPnHCK | 1, 2 }, { 2, 4 }, { 3, 8 }, { 4, 16 },
86+
/* Sentinel */
87+
{ 0, 0 }
7588
};
7689

7790
struct clk * __init cpg_sdh_clk_register(const char *name,

0 commit comments

Comments
 (0)