linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/3] clocksource/drivers/sysctr: Add optional clock-frequency property
@ 2019-06-23 12:04 Anson.Huang
  2019-06-23 12:04 ` [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option Anson.Huang
  2019-06-23 12:04 ` [PATCH V2 3/3] arm64: dts: imx8mq: Add system counter node Anson.Huang
  0 siblings, 2 replies; 5+ messages in thread
From: Anson.Huang @ 2019-06-23 12:04 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, l.stach, abel.vesa, ccaione, angus,
	andrew.smirnov, agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

From: Anson Huang <Anson.Huang@nxp.com>

Systems which use platform driver model for clock driver require the
clock frequency to be supplied via device tree when system counter
driver is enabled.

This is necessary as in the platform driver model the of_clk operations
do not work correctly because system counter driver is initialized in
early phase of system boot up, and clock driver using platform driver
model is NOT ready at that time, it will cause system counter driver
initialization failed.

Add the optinal clock-frequency to the device tree bindings of the NXP
system counter, so the frequency can be handed in and the of_clk
operations can be skipped.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
Changes since V1:
	- improve commit log, no content change.
---
 Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
index d576599..c9907a0 100644
--- a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
+++ b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
@@ -14,6 +14,11 @@ Required properties:
 - clocks : 	    Specifies the counter clock.
 - clock-names: 	    Specifies the clock's name of this module
 
+Optional properties:
+
+- clock-frequency : Specifies system counter clock frequency and indicates system
+		    counter driver to skip clock operations.
+
 Example:
 
 	system_counter: timer@306a0000 {
@@ -22,4 +27,5 @@ Example:
 		clocks = <&clk_8m>;
 		clock-names = "per";
 		interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+		clock-frequency = <8333333>;
 	};
-- 
2.7.4


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

* [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option
  2019-06-23 12:04 [PATCH V2 1/3] clocksource/drivers/sysctr: Add optional clock-frequency property Anson.Huang
@ 2019-06-23 12:04 ` Anson.Huang
  2019-06-23 12:17   ` Thomas Gleixner
  2019-06-23 12:04 ` [PATCH V2 3/3] arm64: dts: imx8mq: Add system counter node Anson.Huang
  1 sibling, 1 reply; 5+ messages in thread
From: Anson.Huang @ 2019-06-23 12:04 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, l.stach, abel.vesa, ccaione, angus,
	andrew.smirnov, agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

From: Anson Huang <Anson.Huang@nxp.com>

On some i.MX8M platforms, clock driver uses platform driver
model and it is NOT ready during timer initialization phase,
the clock operations will fail and system counter driver will
fail too. As all the i.MX8M platforms' system counter clock
are from OSC which is always enabled, so it is no need to enable
clock for system counter driver, the ONLY thing is to pass
clock frequence to driver.

This patch adds an option of skipping of_clk operation for
system counter driver, an optional property "clock-frequency"
is introduced to pass the frequency value to system counter
driver and indicate driver to skip of_clk operations.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
No change.
---
 drivers/clocksource/timer-imx-sysctr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/clocksource/timer-imx-sysctr.c b/drivers/clocksource/timer-imx-sysctr.c
index fd7d680..8ff3d7e 100644
--- a/drivers/clocksource/timer-imx-sysctr.c
+++ b/drivers/clocksource/timer-imx-sysctr.c
@@ -129,6 +129,14 @@ static void __init sysctr_clockevent_init(void)
 static int __init sysctr_timer_init(struct device_node *np)
 {
 	int ret = 0;
+	u32 rate;
+
+	if (!of_property_read_u32(np, "clock-frequency",
+				  &rate)) {
+		to_sysctr.of_clk.rate = rate;
+		to_sysctr.of_clk.period = DIV_ROUND_UP(rate, HZ);
+		to_sysctr.flags &= ~TIMER_OF_CLOCK;
+	}
 
 	ret = timer_of_init(np, &to_sysctr);
 	if (ret)
-- 
2.7.4


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

* [PATCH V2 3/3] arm64: dts: imx8mq: Add system counter node
  2019-06-23 12:04 [PATCH V2 1/3] clocksource/drivers/sysctr: Add optional clock-frequency property Anson.Huang
  2019-06-23 12:04 ` [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option Anson.Huang
@ 2019-06-23 12:04 ` Anson.Huang
  1 sibling, 0 replies; 5+ messages in thread
From: Anson.Huang @ 2019-06-23 12:04 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, l.stach, abel.vesa, ccaione, angus,
	andrew.smirnov, agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

From: Anson Huang <Anson.Huang@nxp.com>

Add i.MX8MQ system counter node to enable timer-imx-sysctr
broadcast timer driver.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
No change.
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index d09b808..9d99191 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -635,6 +635,14 @@
 				#pwm-cells = <2>;
 				status = "disabled";
 			};
+
+			system_counter: timer@306a0000 {
+				compatible = "nxp,sysctr-timer";
+				reg = <0x306a0000 0x30000>;
+				interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+				clock-frequency = <8333333>;
+			};
 		};
 
 		bus@30800000 { /* AIPS3 */
-- 
2.7.4


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

* Re: [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option
  2019-06-23 12:04 ` [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option Anson.Huang
@ 2019-06-23 12:17   ` Thomas Gleixner
  2019-06-23 12:24     ` Anson Huang
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2019-06-23 12:17 UTC (permalink / raw)
  To: Anson.Huang
  Cc: daniel.lezcano, robh+dt, mark.rutland, shawnguo, s.hauer, kernel,
	festevam, l.stach, abel.vesa, ccaione, angus, andrew.smirnov,
	agx, linux-kernel, devicetree, linux-arm-kernel, Linux-imx

On Sun, 23 Jun 2019, Anson.Huang@nxp.com wrote:

Again the short summary could be more informative. Instead of 'Add foo' you
could say:

    .....: Make timer work with platform driver model

That sums up the real meat of the patch. 'Add some option' is pretty
uninformative.

> On some i.MX8M platforms, clock driver uses platform driver
> model and it is NOT ready during timer initialization phase,
> the clock operations will fail and system counter driver will
> fail too. As all the i.MX8M platforms' system counter clock
> are from OSC which is always enabled, so it is no need to enable
> clock for system counter driver, the ONLY thing is to pass
> clock frequence to driver.
> 
> This patch adds an option of skipping of_clk operation for
> system counter driver, an optional property "clock-frequency"
> is introduced to pass the frequency value to system counter
> driver and indicate driver to skip of_clk operations.

The comments to the changelog of patch 1 apply here as well :)

Hint: 'This patch'

Thanks,

	tglx



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

* RE: [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option
  2019-06-23 12:17   ` Thomas Gleixner
@ 2019-06-23 12:24     ` Anson Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Anson Huang @ 2019-06-23 12:24 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: daniel.lezcano, robh+dt, mark.rutland, shawnguo, s.hauer, kernel,
	festevam, l.stach, Abel Vesa, ccaione, angus, andrew.smirnov,
	agx, linux-kernel, devicetree, linux-arm-kernel, dl-linux-imx

Hi, Thomas

> On Sun, 23 Jun 2019, Anson.Huang@nxp.com wrote:
> 
> Again the short summary could be more informative. Instead of 'Add foo'
> you could say:
> 
>     .....: Make timer work with platform driver model
> 
> That sums up the real meat of the patch. 'Add some option' is pretty
> uninformative.

Makes sense.

> 
> > On some i.MX8M platforms, clock driver uses platform driver model and
> > it is NOT ready during timer initialization phase, the clock
> > operations will fail and system counter driver will fail too. As all
> > the i.MX8M platforms' system counter clock are from OSC which is
> > always enabled, so it is no need to enable clock for system counter
> > driver, the ONLY thing is to pass clock frequence to driver.
> >
> > This patch adds an option of skipping of_clk operation for system
> > counter driver, an optional property "clock-frequency"
> > is introduced to pass the frequency value to system counter driver and
> > indicate driver to skip of_clk operations.
> 
> The comments to the changelog of patch 1 apply here as well :)
> 
> Hint: 'This patch'

Oops...did NOT notice that, I will resend the V2 patch series as they are actually
similar issues.

Thanks,
Anson

> 
> Thanks,
> 
> 	tglx
> 


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

end of thread, other threads:[~2019-06-23 12:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-23 12:04 [PATCH V2 1/3] clocksource/drivers/sysctr: Add optional clock-frequency property Anson.Huang
2019-06-23 12:04 ` [PATCH V2 2/3] clocksource: imx-sysctr: Add of_clk skip option Anson.Huang
2019-06-23 12:17   ` Thomas Gleixner
2019-06-23 12:24     ` Anson Huang
2019-06-23 12:04 ` [PATCH V2 3/3] arm64: dts: imx8mq: Add system counter node Anson.Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).