public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation
@ 2016-04-13 14:44 Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 1/3] clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support Geert Uytterhoeven
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-13 14:44 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm
  Cc: Laurent Pinchart, linux-clk, linux-renesas-soc,
	Geert Uytterhoeven

	Hi Mike, Stephen, Simon, Magnus,

This patch series prepares the Renesas CPG/MSSR and CPG/MSTP drivers for
the advent of R-Car SYSC PM Domains.

Support for the latter will be introduced in 3 patch series:
  1. "[PATCH v5 0/7] PM / Domains: Add DT bindings for the R-Car System
      Controller",
  2. "[PATCH v5 00/11] soc: renesas: Add R-Car SYSC PM Domain Support",
  3. "[PATCH v5 00/12] ARM/arm64: dts: rcar: Add SYSC PM domains".

This patch series is against the pull request I've sent earlier today
("[git pull] clk: renesas: Updates for v4.7").

Changes compared to v1:
  - Drop cleanups that are already included in the pull request,
  - Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support,
  - Provide dummy attach/detach_dev callbacks, so the rcar-sysc driver
    won't have to care about support being included or not.

As this series is a hard dependency for the second R-Car SYSC series, I
think it's best that I just queue this series in my clk-renesas-for-v4.7
branch, and ask both Mike/Stephen and Simon to pull from it.
Would that be OK for you?

Thanks!

Geert Uytterhoeven (3):
  clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP
    support
  clk: renesas: mstp: Provide dummy attach/detach_dev callbacks
  clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev()

 drivers/clk/Kconfig                    |  1 +
 drivers/clk/renesas/Kconfig            | 16 ++++++++++++++++
 drivers/clk/renesas/Makefile           | 26 ++++++++++++++------------
 drivers/clk/renesas/renesas-cpg-mssr.c | 18 ++++++++++++------
 include/linux/clk/renesas.h            | 12 ++++++++++++
 5 files changed, 55 insertions(+), 18 deletions(-)
 create mode 100644 drivers/clk/renesas/Kconfig

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support
  2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
@ 2016-04-13 14:44 ` Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 2/3] clk: renesas: mstp: Provide dummy attach/detach_dev callbacks Geert Uytterhoeven
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-13 14:44 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm
  Cc: Laurent Pinchart, linux-clk, linux-renesas-soc,
	Geert Uytterhoeven

Currently the decision whether to build the renesas-cpg-mssr and
clk-mstp drivers is handled by Makefile logic.  However, the rcar-sysc
driver will need to know whether CPG/MSSR and/or CPG/MSTP support are
available or not.

To avoid having to duplicate this logic, move it to Kconfig. Provide
non-visible CLK_RENESAS_CPG_MSSR and CLK_RENESAS_CPG_MSTP Kconfig
symbols, which can be used by both Makefiles and C code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 drivers/clk/Kconfig          |  1 +
 drivers/clk/renesas/Kconfig  | 16 ++++++++++++++++
 drivers/clk/renesas/Makefile | 26 ++++++++++++++------------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 drivers/clk/renesas/Kconfig

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 16f7d33421d8b63b..c45554957499ea60 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -201,6 +201,7 @@ source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/qcom/Kconfig"
+source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/samsung/Kconfig"
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/ti/Kconfig"
diff --git a/drivers/clk/renesas/Kconfig b/drivers/clk/renesas/Kconfig
new file mode 100644
index 0000000000000000..2115ce410cfb4bc9
--- /dev/null
+++ b/drivers/clk/renesas/Kconfig
@@ -0,0 +1,16 @@
+config CLK_RENESAS_CPG_MSSR
+	bool
+	default y if ARCH_R8A7795
+
+config CLK_RENESAS_CPG_MSTP
+	bool
+	default y if ARCH_R7S72100
+	default y if ARCH_R8A73A4
+	default y if ARCH_R8A7740
+	default y if ARCH_R8A7778
+	default y if ARCH_R8A7779
+	default y if ARCH_R8A7790
+	default y if ARCH_R8A7791
+	default y if ARCH_R8A7793
+	default y if ARCH_R8A7794
+	default y if ARCH_SH73A0
diff --git a/drivers/clk/renesas/Makefile b/drivers/clk/renesas/Makefile
index 7e2579b303267d8b..ead8bb8435249493 100644
--- a/drivers/clk/renesas/Makefile
+++ b/drivers/clk/renesas/Makefile
@@ -1,13 +1,15 @@
 obj-$(CONFIG_ARCH_EMEV2)		+= clk-emev2.o
-obj-$(CONFIG_ARCH_R7S72100)		+= clk-rz.o clk-mstp.o
-obj-$(CONFIG_ARCH_R8A73A4)		+= clk-r8a73a4.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7740)		+= clk-r8a7740.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7778)		+= clk-r8a7778.o clk-mstp.o
-obj-$(CONFIG_ARCH_R8A7779)		+= clk-r8a7779.o clk-mstp.o
-obj-$(CONFIG_ARCH_R8A7790)		+= clk-rcar-gen2.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7791)		+= clk-rcar-gen2.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7793)		+= clk-rcar-gen2.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7794)		+= clk-rcar-gen2.o clk-mstp.o clk-div6.o
-obj-$(CONFIG_ARCH_R8A7795)		+= renesas-cpg-mssr.o \
-					   r8a7795-cpg-mssr.o clk-div6.o
-obj-$(CONFIG_ARCH_SH73A0)		+= clk-sh73a0.o clk-mstp.o clk-div6.o
+obj-$(CONFIG_ARCH_R7S72100)		+= clk-rz.o
+obj-$(CONFIG_ARCH_R8A73A4)		+= clk-r8a73a4.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7740)		+= clk-r8a7740.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7778)		+= clk-r8a7778.o
+obj-$(CONFIG_ARCH_R8A7779)		+= clk-r8a7779.o
+obj-$(CONFIG_ARCH_R8A7790)		+= clk-rcar-gen2.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7791)		+= clk-rcar-gen2.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7793)		+= clk-rcar-gen2.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7794)		+= clk-rcar-gen2.o clk-div6.o
+obj-$(CONFIG_ARCH_R8A7795)		+= r8a7795-cpg-mssr.o
+obj-$(CONFIG_ARCH_SH73A0)		+= clk-sh73a0.o clk-div6.o
+
+obj-$(CONFIG_CLK_RENESAS_CPG_MSSR)	+= renesas-cpg-mssr.o clk-div6.o
+obj-$(CONFIG_CLK_RENESAS_CPG_MSTP)	+= clk-mstp.o
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] clk: renesas: mstp: Provide dummy attach/detach_dev callbacks
  2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 1/3] clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support Geert Uytterhoeven
@ 2016-04-13 14:44 ` Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 3/3] clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev() Geert Uytterhoeven
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-13 14:44 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm
  Cc: Laurent Pinchart, linux-clk, linux-renesas-soc,
	Geert Uytterhoeven

Provide dummy cpg_mstp_{at,de}tach_dev() PM Domain callbacks if CPG/MSTP
support is not included, so the rcar-sysc driver won't have to care
about this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 include/linux/clk/renesas.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/clk/renesas.h b/include/linux/clk/renesas.h
index 095b1681daf46faf..ab57a298a3740c5c 100644
--- a/include/linux/clk/renesas.h
+++ b/include/linux/clk/renesas.h
@@ -25,7 +25,12 @@ void r8a7779_clocks_init(u32 mode);
 void rcar_gen2_clocks_init(u32 mode);
 
 void cpg_mstp_add_clk_domain(struct device_node *np);
+#ifdef CONFIG_CLK_RENESAS_CPG_MSTP
 int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev);
 void cpg_mstp_detach_dev(struct generic_pm_domain *unused, struct device *dev);
+#else
+#define cpg_mstp_attach_dev	NULL
+#define cpg_mstp_detach_dev	NULL
+#endif
 
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev()
  2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 1/3] clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support Geert Uytterhoeven
  2016-04-13 14:44 ` [PATCH v2 2/3] clk: renesas: mstp: Provide dummy attach/detach_dev callbacks Geert Uytterhoeven
@ 2016-04-13 14:44 ` Geert Uytterhoeven
  2016-04-14 21:41 ` [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Laurent Pinchart
  2016-04-18 11:32 ` Geert Uytterhoeven
  4 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-13 14:44 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm
  Cc: Laurent Pinchart, linux-clk, linux-renesas-soc,
	Geert Uytterhoeven

The R-Car SYSC PM Domain driver has to power manage devices in power
areas using clocks. To reuse code and to share knowledge of clocks
suitable for power management, this is ideally done through the existing
cpg_mssr_attach_dev() and cpg_mssr_detach_dev() callbacks.

Hence these callbacks can no longer rely on their "domain" parameter
pointing to the CPG/MSSR Clock Domain. To handle this, keep a pointer to
the clock domain in a static variable. cpg_mssr_attach_dev() has to
support probe deferral, as the R-Car SYSC PM Domain may be initialized,
and devices may be added to it, before the CPG/MSSR Clock Domain is
initialized.

Dummy callbacks are provided for the case where CPG/MSTP support is not
included, so the rcar-sysc driver won't have to care about this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
The probe deferral path was tested by initializing the renesas,fcpv
driver from an arch_initcall.

v2:
  - Provide dummy callbacks if CPG/MSSR support is not included.
---
 drivers/clk/renesas/renesas-cpg-mssr.c | 18 ++++++++++++------
 include/linux/clk/renesas.h            |  7 +++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
index 703bdb157528eecb..1f2dc3629f0e02a0 100644
--- a/drivers/clk/renesas/renesas-cpg-mssr.c
+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
@@ -15,6 +15,7 @@
 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
+#include <linux/clk/renesas.h>
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/mod_devicetable.h>
@@ -388,6 +389,8 @@ struct cpg_mssr_clk_domain {
 	unsigned int core_pm_clks[0];
 };
 
+static struct cpg_mssr_clk_domain *cpg_mssr_clk_domain;
+
 static bool cpg_mssr_is_pm_clk(const struct of_phandle_args *clkspec,
 			       struct cpg_mssr_clk_domain *pd)
 {
@@ -411,17 +414,20 @@ static bool cpg_mssr_is_pm_clk(const struct of_phandle_args *clkspec,
 	}
 }
 
-static int cpg_mssr_attach_dev(struct generic_pm_domain *genpd,
-			       struct device *dev)
+int cpg_mssr_attach_dev(struct generic_pm_domain *unused, struct device *dev)
 {
-	struct cpg_mssr_clk_domain *pd =
-		container_of(genpd, struct cpg_mssr_clk_domain, genpd);
+	struct cpg_mssr_clk_domain *pd = cpg_mssr_clk_domain;
 	struct device_node *np = dev->of_node;
 	struct of_phandle_args clkspec;
 	struct clk *clk;
 	int i = 0;
 	int error;
 
+	if (!pd) {
+		dev_dbg(dev, "CPG/MSSR clock domain not yet available\n");
+		return -EPROBE_DEFER;
+	}
+
 	while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i,
 					   &clkspec)) {
 		if (cpg_mssr_is_pm_clk(&clkspec, pd))
@@ -461,8 +467,7 @@ fail_put:
 	return error;
 }
 
-static void cpg_mssr_detach_dev(struct generic_pm_domain *genpd,
-				struct device *dev)
+void cpg_mssr_detach_dev(struct generic_pm_domain *unused, struct device *dev)
 {
 	if (!list_empty(&dev->power.subsys_data->clock_list))
 		pm_clk_destroy(dev);
@@ -491,6 +496,7 @@ static int __init cpg_mssr_add_clk_domain(struct device *dev,
 	pm_genpd_init(genpd, &simple_qos_governor, false);
 	genpd->attach_dev = cpg_mssr_attach_dev;
 	genpd->detach_dev = cpg_mssr_detach_dev;
+	cpg_mssr_clk_domain = pd;
 
 	of_genpd_add_provider_simple(np, genpd);
 	return 0;
diff --git a/include/linux/clk/renesas.h b/include/linux/clk/renesas.h
index ab57a298a3740c5c..ba6fa4148515e5c9 100644
--- a/include/linux/clk/renesas.h
+++ b/include/linux/clk/renesas.h
@@ -33,4 +33,11 @@ void cpg_mstp_detach_dev(struct generic_pm_domain *unused, struct device *dev);
 #define cpg_mstp_detach_dev	NULL
 #endif
 
+#ifdef CONFIG_CLK_RENESAS_CPG_MSSR
+int cpg_mssr_attach_dev(struct generic_pm_domain *unused, struct device *dev);
+void cpg_mssr_detach_dev(struct generic_pm_domain *unused, struct device *dev);
+#else
+#define cpg_mssr_attach_dev	NULL
+#define cpg_mssr_detach_dev	NULL
+#endif
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation
  2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2016-04-13 14:44 ` [PATCH v2 3/3] clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev() Geert Uytterhoeven
@ 2016-04-14 21:41 ` Laurent Pinchart
  2016-04-18 11:32 ` Geert Uytterhoeven
  4 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2016-04-14 21:41 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm,
	linux-clk, linux-renesas-soc

Hi Geert,

Thank you for the patches.

In the long term we could try to move the power domain handling code from the 
CPG drivers to the SYSC driver, after all platforms are switched to the MSSR 
driver. For now this looks good to me, so, for the whole series,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

On Wednesday 13 Apr 2016 16:44:14 Geert Uytterhoeven wrote:
> 	Hi Mike, Stephen, Simon, Magnus,
> 
> This patch series prepares the Renesas CPG/MSSR and CPG/MSTP drivers for
> the advent of R-Car SYSC PM Domains.
> 
> Support for the latter will be introduced in 3 patch series:
>   1. "[PATCH v5 0/7] PM / Domains: Add DT bindings for the R-Car System
>       Controller",
>   2. "[PATCH v5 00/11] soc: renesas: Add R-Car SYSC PM Domain Support",
>   3. "[PATCH v5 00/12] ARM/arm64: dts: rcar: Add SYSC PM domains".
> 
> This patch series is against the pull request I've sent earlier today
> ("[git pull] clk: renesas: Updates for v4.7").
> 
> Changes compared to v1:
>   - Drop cleanups that are already included in the pull request,
>   - Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support,
>   - Provide dummy attach/detach_dev callbacks, so the rcar-sysc driver
>     won't have to care about support being included or not.
> 
> As this series is a hard dependency for the second R-Car SYSC series, I
> think it's best that I just queue this series in my clk-renesas-for-v4.7
> branch, and ask both Mike/Stephen and Simon to pull from it.
> Would that be OK for you?
> 
> Thanks!
> 
> Geert Uytterhoeven (3):
>   clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP
>     support
>   clk: renesas: mstp: Provide dummy attach/detach_dev callbacks
>   clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev()
> 
>  drivers/clk/Kconfig                    |  1 +
>  drivers/clk/renesas/Kconfig            | 16 ++++++++++++++++
>  drivers/clk/renesas/Makefile           | 26 ++++++++++++++------------
>  drivers/clk/renesas/renesas-cpg-mssr.c | 18 ++++++++++++------
>  include/linux/clk/renesas.h            | 12 ++++++++++++
>  5 files changed, 55 insertions(+), 18 deletions(-)
>  create mode 100644 drivers/clk/renesas/Kconfig

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation
  2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
                   ` (3 preceding siblings ...)
  2016-04-14 21:41 ` [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Laurent Pinchart
@ 2016-04-18 11:32 ` Geert Uytterhoeven
  4 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-04-18 11:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Turquette, Stephen Boyd, Simon Horman, Magnus Damm,
	Laurent Pinchart, linux-clk, linux-renesas-soc

On Wed, Apr 13, 2016 at 4:44 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Geert Uytterhoeven (3):

In case his silly typo wasn't obvious: the subject should have been
"[PATCH v2 0/3] clk: renesas: R-Car SYSC PM Domain Preparation".
(i.e. "0/3" i.s.o. "0/4").

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-18 11:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-13 14:44 [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Geert Uytterhoeven
2016-04-13 14:44 ` [PATCH v2 1/3] clk: renesas: Provide Kconfig symbols for CPG/MSSR and CPG/MSTP support Geert Uytterhoeven
2016-04-13 14:44 ` [PATCH v2 2/3] clk: renesas: mstp: Provide dummy attach/detach_dev callbacks Geert Uytterhoeven
2016-04-13 14:44 ` [PATCH v2 3/3] clk: renesas: cpg-mssr: Export cpg_mssr_{at,de}tach_dev() Geert Uytterhoeven
2016-04-14 21:41 ` [PATCH v2 0/4] clk: renesas: R-Car SYSC PM Domain Preparation Laurent Pinchart
2016-04-18 11:32 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox