Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: renesas: rcar-gen2: Centralize quirks handling

Introduce centralized quirks handling like on R-Car Gen3, and convert
the RZ/G1C SD clock table handling over to it.

This makes it easier to add more quirks later, if/when needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>

+16 -4
+16 -4
drivers/clk/renesas/rcar-gen2-cpg.c
··· 261 261 static const struct rcar_gen2_cpg_pll_config *cpg_pll_config __initdata; 262 262 static unsigned int cpg_pll0_div __initdata; 263 263 static u32 cpg_mode __initdata; 264 + static u32 cpg_quirks __initdata; 264 265 265 - static const struct soc_device_attribute soc_r8a77470[] = { 266 - { .soc_id = "r8a77470" }, 266 + #define SD_SKIP_FIRST BIT(0) /* Skip first clock in SD table */ 267 + 268 + static const struct soc_device_attribute cpg_quirks_match[] __initconst = { 269 + { 270 + .soc_id = "r8a77470", 271 + .data = (void *)SD_SKIP_FIRST, 272 + }, 267 273 { /* sentinel */ } 268 274 }; 269 275 ··· 339 333 340 334 case CLK_TYPE_GEN2_SD0: 341 335 table = cpg_sd01_div_table; 342 - if (soc_device_match(soc_r8a77470)) 336 + if (cpg_quirks & SD_SKIP_FIRST) 343 337 table++; 344 338 345 339 shift = 4; ··· 347 341 348 342 case CLK_TYPE_GEN2_SD1: 349 343 table = cpg_sd01_div_table; 350 - if (soc_device_match(soc_r8a77470)) 344 + if (cpg_quirks & SD_SKIP_FIRST) 351 345 table++; 352 346 353 347 shift = 0; ··· 378 372 int __init rcar_gen2_cpg_init(const struct rcar_gen2_cpg_pll_config *config, 379 373 unsigned int pll0_div, u32 mode) 380 374 { 375 + const struct soc_device_attribute *attr; 376 + 381 377 cpg_pll_config = config; 382 378 cpg_pll0_div = pll0_div; 383 379 cpg_mode = mode; 380 + attr = soc_device_match(cpg_quirks_match); 381 + if (attr) 382 + cpg_quirks = (uintptr_t)attr->data; 383 + pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks); 384 384 385 385 spin_lock_init(&cpg_lock); 386 386