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

Merge tag 'clk-renesas-for-v4.7-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into rcar-sysc-for-v4.7

clk: renesas: R-Car SYSC PM Domain Preparation

- Export the CPG/MSSR and CPG/MSTP attach/detach_dev callbacks, so
they can be called by the R-Car SYSC PM Domain driver.

+102 -51
+1
drivers/clk/Kconfig
··· 201 201 source "drivers/clk/hisilicon/Kconfig" 202 202 source "drivers/clk/mvebu/Kconfig" 203 203 source "drivers/clk/qcom/Kconfig" 204 + source "drivers/clk/renesas/Kconfig" 204 205 source "drivers/clk/samsung/Kconfig" 205 206 source "drivers/clk/tegra/Kconfig" 206 207 source "drivers/clk/ti/Kconfig"
+16
drivers/clk/renesas/Kconfig
··· 1 + config CLK_RENESAS_CPG_MSSR 2 + bool 3 + default y if ARCH_R8A7795 4 + 5 + config CLK_RENESAS_CPG_MSTP 6 + bool 7 + default y if ARCH_R7S72100 8 + default y if ARCH_R8A73A4 9 + default y if ARCH_R8A7740 10 + default y if ARCH_R8A7778 11 + default y if ARCH_R8A7779 12 + default y if ARCH_R8A7790 13 + default y if ARCH_R8A7791 14 + default y if ARCH_R8A7793 15 + default y if ARCH_R8A7794 16 + default y if ARCH_SH73A0
+14 -12
drivers/clk/renesas/Makefile
··· 1 1 obj-$(CONFIG_ARCH_EMEV2) += clk-emev2.o 2 - obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o clk-mstp.o 3 - obj-$(CONFIG_ARCH_R8A73A4) += clk-r8a73a4.o clk-mstp.o clk-div6.o 4 - obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o clk-mstp.o clk-div6.o 5 - obj-$(CONFIG_ARCH_R8A7778) += clk-r8a7778.o clk-mstp.o 6 - obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o clk-mstp.o 7 - obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o clk-mstp.o clk-div6.o 8 - obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o clk-mstp.o clk-div6.o 9 - obj-$(CONFIG_ARCH_R8A7793) += clk-rcar-gen2.o clk-mstp.o clk-div6.o 10 - obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o clk-mstp.o clk-div6.o 11 - obj-$(CONFIG_ARCH_R8A7795) += renesas-cpg-mssr.o \ 12 - r8a7795-cpg-mssr.o clk-div6.o 13 - obj-$(CONFIG_ARCH_SH73A0) += clk-sh73a0.o clk-mstp.o clk-div6.o 2 + obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o 3 + obj-$(CONFIG_ARCH_R8A73A4) += clk-r8a73a4.o clk-div6.o 4 + obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o clk-div6.o 5 + obj-$(CONFIG_ARCH_R8A7778) += clk-r8a7778.o 6 + obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o 7 + obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o clk-div6.o 8 + obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o clk-div6.o 9 + obj-$(CONFIG_ARCH_R8A7793) += clk-rcar-gen2.o clk-div6.o 10 + obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o clk-div6.o 11 + obj-$(CONFIG_ARCH_R8A7795) += r8a7795-cpg-mssr.o 12 + obj-$(CONFIG_ARCH_SH73A0) += clk-sh73a0.o clk-div6.o 13 + 14 + obj-$(CONFIG_CLK_RENESAS_CPG_MSSR) += renesas-cpg-mssr.o clk-div6.o 15 + obj-$(CONFIG_CLK_RENESAS_CPG_MSTP) += clk-mstp.o
+2 -5
drivers/clk/renesas/clk-mstp.c
··· 243 243 } 244 244 CLK_OF_DECLARE(cpg_mstp_clks, "renesas,cpg-mstp-clocks", cpg_mstp_clocks_init); 245 245 246 - 247 - #ifdef CONFIG_PM_GENERIC_DOMAINS_OF 248 - int cpg_mstp_attach_dev(struct generic_pm_domain *domain, struct device *dev) 246 + int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev) 249 247 { 250 248 struct device_node *np = dev->of_node; 251 249 struct of_phandle_args clkspec; ··· 295 297 return error; 296 298 } 297 299 298 - void cpg_mstp_detach_dev(struct generic_pm_domain *domain, struct device *dev) 300 + void cpg_mstp_detach_dev(struct generic_pm_domain *unused, struct device *dev) 299 301 { 300 302 if (!list_empty(&dev->power.subsys_data->clock_list)) 301 303 pm_clk_destroy(dev); ··· 324 326 325 327 of_genpd_add_provider_simple(np, pd); 326 328 } 327 - #endif /* !CONFIG_PM_GENERIC_DOMAINS_OF */
+30 -4
drivers/clk/renesas/r8a7795-cpg-mssr.c
··· 13 13 */ 14 14 15 15 #include <linux/bug.h> 16 + #include <linux/clk.h> 16 17 #include <linux/clk-provider.h> 17 18 #include <linux/device.h> 18 19 #include <linux/err.h> ··· 27 26 28 27 #include "renesas-cpg-mssr.h" 29 28 29 + #define CPG_RCKCR 0x240 30 30 31 31 enum clk_ids { 32 32 /* Core Clock Outputs exported to DT */ ··· 52 50 CLK_S3, 53 51 CLK_SDSRC, 54 52 CLK_SSPSRC, 53 + CLK_RINT, 55 54 56 55 /* Module Clocks */ 57 56 MOD_CLK_BASE ··· 66 63 CLK_TYPE_GEN3_PLL3, 67 64 CLK_TYPE_GEN3_PLL4, 68 65 CLK_TYPE_GEN3_SD, 66 + CLK_TYPE_GEN3_R, 69 67 }; 68 + 69 + #define DEF_GEN3_SD(_name, _id, _parent, _offset) \ 70 + DEF_BASE(_name, _id, CLK_TYPE_GEN3_SD, _parent, .offset = _offset) 70 71 71 72 static const struct cpg_core_clk r8a7795_core_clks[] __initconst = { 72 73 /* External Clock Inputs */ ··· 109 102 DEF_FIXED("s3d2", R8A7795_CLK_S3D2, CLK_S3, 2, 1), 110 103 DEF_FIXED("s3d4", R8A7795_CLK_S3D4, CLK_S3, 4, 1), 111 104 112 - DEF_SD("sd0", R8A7795_CLK_SD0, CLK_PLL1_DIV2, 0x0074), 113 - DEF_SD("sd1", R8A7795_CLK_SD1, CLK_PLL1_DIV2, 0x0078), 114 - DEF_SD("sd2", R8A7795_CLK_SD2, CLK_PLL1_DIV2, 0x0268), 115 - DEF_SD("sd3", R8A7795_CLK_SD3, CLK_PLL1_DIV2, 0x026c), 105 + DEF_GEN3_SD("sd0", R8A7795_CLK_SD0, CLK_PLL1_DIV2, 0x0074), 106 + DEF_GEN3_SD("sd1", R8A7795_CLK_SD1, CLK_PLL1_DIV2, 0x0078), 107 + DEF_GEN3_SD("sd2", R8A7795_CLK_SD2, CLK_PLL1_DIV2, 0x0268), 108 + DEF_GEN3_SD("sd3", R8A7795_CLK_SD3, CLK_PLL1_DIV2, 0x026c), 116 109 117 110 DEF_FIXED("cl", R8A7795_CLK_CL, CLK_PLL1_DIV2, 48, 1), 118 111 DEF_FIXED("cp", R8A7795_CLK_CP, CLK_EXTAL, 2, 1), ··· 120 113 DEF_DIV6P1("mso", R8A7795_CLK_MSO, CLK_PLL1_DIV4, 0x014), 121 114 DEF_DIV6P1("hdmi", R8A7795_CLK_HDMI, CLK_PLL1_DIV2, 0x250), 122 115 DEF_DIV6P1("canfd", R8A7795_CLK_CANFD, CLK_PLL1_DIV4, 0x244), 116 + 117 + DEF_DIV6_RO("osc", R8A7795_CLK_OSC, CLK_EXTAL, CPG_RCKCR, 8), 118 + DEF_DIV6_RO("r_int", CLK_RINT, CLK_EXTAL, CPG_RCKCR, 32), 119 + 120 + DEF_BASE("r", R8A7795_CLK_R, CLK_TYPE_GEN3_R, CLK_RINT), 123 121 }; 124 122 125 123 static const struct mssr_mod_clk r8a7795_mod_clks[] __initconst = { ··· 151 139 DEF_MOD("usb3-if0", 328, R8A7795_CLK_S3D1), 152 140 DEF_MOD("usb-dmac0", 330, R8A7795_CLK_S3D1), 153 141 DEF_MOD("usb-dmac1", 331, R8A7795_CLK_S3D1), 142 + DEF_MOD("rwdt0", 402, R8A7795_CLK_R), 154 143 DEF_MOD("intc-ex", 407, R8A7795_CLK_CP), 155 144 DEF_MOD("intc-ap", 408, R8A7795_CLK_S3D1), 156 145 DEF_MOD("audmac0", 502, R8A7795_CLK_S3D4), ··· 161 148 DEF_MOD("hscif2", 518, R8A7795_CLK_S3D1), 162 149 DEF_MOD("hscif1", 519, R8A7795_CLK_S3D1), 163 150 DEF_MOD("hscif0", 520, R8A7795_CLK_S3D1), 151 + DEF_MOD("pwm", 523, R8A7795_CLK_S3D4), 164 152 DEF_MOD("fcpvd3", 600, R8A7795_CLK_S2D1), 165 153 DEF_MOD("fcpvd2", 601, R8A7795_CLK_S2D1), 166 154 DEF_MOD("fcpvd1", 602, R8A7795_CLK_S2D1), ··· 591 577 592 578 case CLK_TYPE_GEN3_SD: 593 579 return cpg_sd_clk_register(core, base, __clk_get_name(parent)); 580 + 581 + case CLK_TYPE_GEN3_R: 582 + /* RINT is default. Only if EXTALR is populated, we switch to it */ 583 + value = readl(base + CPG_RCKCR) & 0x3f; 584 + 585 + if (clk_get_rate(clks[CLK_EXTALR])) { 586 + parent = clks[CLK_EXTALR]; 587 + value |= BIT(15); 588 + } 589 + 590 + writel(value, base + CPG_RCKCR); 591 + break; 594 592 595 593 default: 596 594 return ERR_PTR(-EINVAL);
+24 -23
drivers/clk/renesas/renesas-cpg-mssr.c
··· 15 15 16 16 #include <linux/clk.h> 17 17 #include <linux/clk-provider.h> 18 + #include <linux/clk/renesas.h> 18 19 #include <linux/device.h> 19 20 #include <linux/init.h> 20 21 #include <linux/mod_devicetable.h> ··· 254 253 { 255 254 struct clk *clk = NULL, *parent; 256 255 struct device *dev = priv->dev; 257 - unsigned int id = core->id; 256 + unsigned int id = core->id, div = core->div; 258 257 const char *parent_name; 259 258 260 259 WARN_DEBUG(id >= priv->num_core_clks); ··· 267 266 268 267 case CLK_TYPE_FF: 269 268 case CLK_TYPE_DIV6P1: 269 + case CLK_TYPE_DIV6_RO: 270 270 WARN_DEBUG(core->parent >= priv->num_core_clks); 271 271 parent = priv->clks[core->parent]; 272 272 if (IS_ERR(parent)) { ··· 276 274 } 277 275 278 276 parent_name = __clk_get_name(parent); 279 - if (core->type == CLK_TYPE_FF) { 280 - clk = clk_register_fixed_factor(NULL, core->name, 281 - parent_name, 0, 282 - core->mult, core->div); 283 - } else { 277 + 278 + if (core->type == CLK_TYPE_DIV6_RO) 279 + /* Multiply with the DIV6 register value */ 280 + div *= (readl(priv->base + core->offset) & 0x3f) + 1; 281 + 282 + if (core->type == CLK_TYPE_DIV6P1) { 284 283 clk = cpg_div6_register(core->name, 1, &parent_name, 285 284 priv->base + core->offset); 285 + } else { 286 + clk = clk_register_fixed_factor(NULL, core->name, 287 + parent_name, 0, 288 + core->mult, div); 286 289 } 287 290 break; 288 291 ··· 382 375 kfree(clock); 383 376 } 384 377 385 - 386 - #ifdef CONFIG_PM_GENERIC_DOMAINS_OF 387 378 struct cpg_mssr_clk_domain { 388 379 struct generic_pm_domain genpd; 389 380 struct device_node *np; 390 381 unsigned int num_core_pm_clks; 391 382 unsigned int core_pm_clks[0]; 392 383 }; 384 + 385 + static struct cpg_mssr_clk_domain *cpg_mssr_clk_domain; 393 386 394 387 static bool cpg_mssr_is_pm_clk(const struct of_phandle_args *clkspec, 395 388 struct cpg_mssr_clk_domain *pd) ··· 414 407 } 415 408 } 416 409 417 - static int cpg_mssr_attach_dev(struct generic_pm_domain *genpd, 418 - struct device *dev) 410 + int cpg_mssr_attach_dev(struct generic_pm_domain *unused, struct device *dev) 419 411 { 420 - struct cpg_mssr_clk_domain *pd = 421 - container_of(genpd, struct cpg_mssr_clk_domain, genpd); 412 + struct cpg_mssr_clk_domain *pd = cpg_mssr_clk_domain; 422 413 struct device_node *np = dev->of_node; 423 414 struct of_phandle_args clkspec; 424 415 struct clk *clk; 425 416 int i = 0; 426 417 int error; 418 + 419 + if (!pd) { 420 + dev_dbg(dev, "CPG/MSSR clock domain not yet available\n"); 421 + return -EPROBE_DEFER; 422 + } 427 423 428 424 while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i, 429 425 &clkspec)) { ··· 467 457 return error; 468 458 } 469 459 470 - static void cpg_mssr_detach_dev(struct generic_pm_domain *genpd, 471 - struct device *dev) 460 + void cpg_mssr_detach_dev(struct generic_pm_domain *unused, struct device *dev) 472 461 { 473 462 if (!list_empty(&dev->power.subsys_data->clock_list)) 474 463 pm_clk_destroy(dev); ··· 496 487 pm_genpd_init(genpd, &simple_qos_governor, false); 497 488 genpd->attach_dev = cpg_mssr_attach_dev; 498 489 genpd->detach_dev = cpg_mssr_detach_dev; 490 + cpg_mssr_clk_domain = pd; 499 491 500 492 of_genpd_add_provider_simple(np, genpd); 501 493 return 0; 502 494 } 503 - #else 504 - static inline int cpg_mssr_add_clk_domain(struct device *dev, 505 - const unsigned int *core_pm_clks, 506 - unsigned int num_core_pm_clks) 507 - { 508 - return 0; 509 - } 510 - #endif /* !CONFIG_PM_GENERIC_DOMAINS_OF */ 511 - 512 495 513 496 static const struct of_device_id cpg_mssr_match[] = { 514 497 #ifdef CONFIG_ARCH_R8A7795
+3 -3
drivers/clk/renesas/renesas-cpg-mssr.h
··· 37 37 CLK_TYPE_IN, /* External Clock Input */ 38 38 CLK_TYPE_FF, /* Fixed Factor Clock */ 39 39 CLK_TYPE_DIV6P1, /* DIV6 Clock with 1 parent clock */ 40 + CLK_TYPE_DIV6_RO, /* DIV6 Clock read only with extra divisor */ 40 41 41 42 /* Custom definitions start here */ 42 43 CLK_TYPE_CUSTOM, ··· 54 53 DEF_BASE(_name, _id, CLK_TYPE_FF, _parent, .div = _div, .mult = _mult) 55 54 #define DEF_DIV6P1(_name, _id, _parent, _offset) \ 56 55 DEF_BASE(_name, _id, CLK_TYPE_DIV6P1, _parent, .offset = _offset) 57 - #define DEF_SD(_name, _id, _parent, _offset) \ 58 - DEF_BASE(_name, _id, CLK_TYPE_GEN3_SD, _parent, .offset = _offset) 59 - 56 + #define DEF_DIV6_RO(_name, _id, _parent, _offset, _div) \ 57 + DEF_BASE(_name, _id, CLK_TYPE_DIV6_RO, _parent, .offset = _offset, .div = _div, .mult = 1) 60 58 61 59 /* 62 60 * Definitions of Module Clocks
+12 -4
include/linux/clk/renesas.h
··· 24 24 void r8a7779_clocks_init(u32 mode); 25 25 void rcar_gen2_clocks_init(u32 mode); 26 26 27 - #ifdef CONFIG_PM_GENERIC_DOMAINS_OF 28 27 void cpg_mstp_add_clk_domain(struct device_node *np); 29 - int cpg_mstp_attach_dev(struct generic_pm_domain *domain, struct device *dev); 30 - void cpg_mstp_detach_dev(struct generic_pm_domain *domain, struct device *dev); 28 + #ifdef CONFIG_CLK_RENESAS_CPG_MSTP 29 + int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev); 30 + void cpg_mstp_detach_dev(struct generic_pm_domain *unused, struct device *dev); 31 31 #else 32 - static inline void cpg_mstp_add_clk_domain(struct device_node *np) {} 32 + #define cpg_mstp_attach_dev NULL 33 + #define cpg_mstp_detach_dev NULL 33 34 #endif 34 35 36 + #ifdef CONFIG_CLK_RENESAS_CPG_MSSR 37 + int cpg_mssr_attach_dev(struct generic_pm_domain *unused, struct device *dev); 38 + void cpg_mssr_detach_dev(struct generic_pm_domain *unused, struct device *dev); 39 + #else 40 + #define cpg_mssr_attach_dev NULL 41 + #define cpg_mssr_detach_dev NULL 42 + #endif 35 43 #endif