linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT
@ 2019-07-02  7:55 Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property Anson.Huang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Anson.Huang @ 2019-07-02  7:55 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

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

More and more platforms use platform driver model for clock driver,
so the clock driver is NOT ready during timer initialization phase,
it will cause timer initialization failed.

To support those platforms with upper scenario, introducing a new
flag TIMER_OF_CLOCK_FREQUENCY which is mutually exclusive with
TIMER_OF_CLOCK flag to support getting timer clock frequency from
DT's timer node, the property name should be "clock-frequency",
then of_clk operations can be skipped.

User needs to select either TIMER_OF_CLOCK_FREQUENCY or TIMER_OF_CLOCK
flag if want to use timer-of driver to initialize the clock rate.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
Changes since V3:
	- use hardcoded "clock-frequency" instead of adding new variable prop_name;
	- add pre-condition check for TIMER_OF_CLOCK and TIMER_OF_CLOCK_FREQUENCY, they MUST be exclusive.
---
 drivers/clocksource/timer-of.c | 29 +++++++++++++++++++++++++++++
 drivers/clocksource/timer-of.h |  7 ++++---
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index 8054228..858f684 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -161,11 +161,30 @@ static __init int timer_of_base_init(struct device_node *np,
 	return 0;
 }
 
+static __init int timer_of_clk_frequency_init(struct device_node *np,
+					      struct of_timer_clk *of_clk)
+{
+	int ret;
+	u32 rate;
+
+	ret = of_property_read_u32(np, "clock-frequency", &rate);
+	if (!ret) {
+		of_clk->rate = rate;
+		of_clk->period = DIV_ROUND_UP(rate, HZ);
+	}
+
+	return ret;
+}
+
 int __init timer_of_init(struct device_node *np, struct timer_of *to)
 {
+	unsigned long clock_flags = TIMER_OF_CLOCK | TIMER_OF_CLOCK_FREQUENCY;
 	int ret = -EINVAL;
 	int flags = 0;
 
+	if ((to->flags & clock_flags) == clock_flags)
+		return ret;
+
 	if (to->flags & TIMER_OF_BASE) {
 		ret = timer_of_base_init(np, &to->of_base);
 		if (ret)
@@ -180,6 +199,13 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
 		flags |= TIMER_OF_CLOCK;
 	}
 
+	if (to->flags & TIMER_OF_CLOCK_FREQUENCY) {
+		ret = timer_of_clk_frequency_init(np, &to->of_clk);
+		if (ret)
+			goto out_fail;
+		flags |= TIMER_OF_CLOCK_FREQUENCY;
+	}
+
 	if (to->flags & TIMER_OF_IRQ) {
 		ret = timer_of_irq_init(np, &to->of_irq);
 		if (ret)
@@ -201,6 +227,9 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
 	if (flags & TIMER_OF_CLOCK)
 		timer_of_clk_exit(&to->of_clk);
 
+	if (flags & TIMER_OF_CLOCK_FREQUENCY)
+		to->of_clk.rate = 0;
+
 	if (flags & TIMER_OF_BASE)
 		timer_of_base_exit(&to->of_base);
 	return ret;
diff --git a/drivers/clocksource/timer-of.h b/drivers/clocksource/timer-of.h
index a5478f3..a08e108 100644
--- a/drivers/clocksource/timer-of.h
+++ b/drivers/clocksource/timer-of.h
@@ -4,9 +4,10 @@
 
 #include <linux/clockchips.h>
 
-#define TIMER_OF_BASE	0x1
-#define TIMER_OF_CLOCK	0x2
-#define TIMER_OF_IRQ	0x4
+#define TIMER_OF_BASE			0x1
+#define TIMER_OF_CLOCK			0x2
+#define TIMER_OF_IRQ			0x4
+#define TIMER_OF_CLOCK_FREQUENCY	0x8
 
 struct of_timer_irq {
 	int irq;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RESEND V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property
  2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
@ 2019-07-02  7:55 ` Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 3/5] clocksource: imx-sysctr: Make timer work with clock driver using platform driver model Anson.Huang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Anson.Huang @ 2019-07-02  7:55 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	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 clock-frequency property to the device tree bindings of the NXP
system counter, so the driver can tell timer-of driver to get clock
frequency from DT directly instead of doing of_clk operations via
clk APIs.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
No changes.
---
 .../devicetree/bindings/timer/nxp,sysctr-timer.txt        | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
index d576599..7088a0e 100644
--- a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
+++ b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
@@ -11,15 +11,18 @@ Required properties:
 - reg :             Specifies the base physical address and size of the comapre
                     frame and the counter control, read & compare.
 - interrupts :      should be the first compare frames' interrupt
-- clocks : 	    Specifies the counter clock.
-- clock-names: 	    Specifies the clock's name of this module
+- clocks :          Specifies the counter clock, mutually exclusive with clock-frequency.
+- clock-names :     Specifies the clock's name of this module, mutually exclusive with
+		    clock-frequency.
+- clock-frequency : Specifies system counter clock frequency, mutually exclusive with
+		    clocks/clock-names.
 
 Example:
 
 	system_counter: timer@306a0000 {
 		compatible = "nxp,sysctr-timer";
-		reg = <0x306a0000 0x20000>;/* system-counter-rd & compare */
-		clocks = <&clk_8m>;
-		clock-names = "per";
-		interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+		reg = <0x306a0000 0x30000>;
+		interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+		clock-frequency = <8333333>;
 	};
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RESEND V4 3/5] clocksource: imx-sysctr: Make timer work with clock driver using platform driver model
  2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property Anson.Huang
@ 2019-07-02  7:55 ` Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 4/5] arm64: dts: imx8mq: Add system counter node Anson.Huang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Anson.Huang @ 2019-07-02  7:55 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	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.

To make system counter driver work for upper scenario, if DT's
system counter node has property "clock-frequency" present,
setting TIMER_OF_CLOCK_FREQUENCY flag to indicate timer-of driver
to get clock frequency from DT directly instead of of_clk operation
via clk APIs.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
Changes since V3:
	- remove the .prop_name initialization acording to timer-of changes in V4.
---
 drivers/clocksource/timer-imx-sysctr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-imx-sysctr.c b/drivers/clocksource/timer-imx-sysctr.c
index fd7d680..b82a549 100644
--- a/drivers/clocksource/timer-imx-sysctr.c
+++ b/drivers/clocksource/timer-imx-sysctr.c
@@ -98,7 +98,7 @@ static irqreturn_t sysctr_timer_interrupt(int irq, void *dev_id)
 }
 
 static struct timer_of to_sysctr = {
-	.flags = TIMER_OF_IRQ | TIMER_OF_CLOCK | TIMER_OF_BASE,
+	.flags = TIMER_OF_IRQ | TIMER_OF_BASE,
 	.clkevt = {
 		.name			= "i.MX system counter timer",
 		.features		= CLOCK_EVT_FEAT_ONESHOT |
@@ -130,6 +130,9 @@ static int __init sysctr_timer_init(struct device_node *np)
 {
 	int ret = 0;
 
+	to_sysctr.flags |= of_find_property(np, "clock-frequency", NULL) ?
+			   TIMER_OF_CLOCK_FREQUENCY : TIMER_OF_CLOCK;
+
 	ret = timer_of_init(np, &to_sysctr);
 	if (ret)
 		return ret;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RESEND V4 4/5] arm64: dts: imx8mq: Add system counter node
  2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 3/5] clocksource: imx-sysctr: Make timer work with clock driver using platform driver model Anson.Huang
@ 2019-07-02  7:55 ` Anson.Huang
  2019-07-02  7:55 ` [PATCH RESEND V4 5/5] arm64: dts: imx8mm: " Anson.Huang
  2019-07-02  8:06 ` [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Daniel Lezcano
  4 siblings, 0 replies; 9+ messages in thread
From: Anson.Huang @ 2019-07-02  7:55 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	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 changes.
---
 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 50931da..3187428 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -639,6 +639,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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RESEND V4 5/5] arm64: dts: imx8mm: Add system counter node
  2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
                   ` (2 preceding siblings ...)
  2019-07-02  7:55 ` [PATCH RESEND V4 4/5] arm64: dts: imx8mq: Add system counter node Anson.Huang
@ 2019-07-02  7:55 ` Anson.Huang
  2019-07-02  8:06 ` [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Daniel Lezcano
  4 siblings, 0 replies; 9+ messages in thread
From: Anson.Huang @ 2019-07-02  7:55 UTC (permalink / raw)
  To: daniel.lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

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

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

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

diff --git a/arch/arm64/boot/dts/freescale/imx8mm.dtsi b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
index b726712..b11fc5e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
@@ -532,6 +532,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 = <8000000>;
+			};
 		};
 
 		aips3: bus@30800000 {
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT
  2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
                   ` (3 preceding siblings ...)
  2019-07-02  7:55 ` [PATCH RESEND V4 5/5] arm64: dts: imx8mm: " Anson.Huang
@ 2019-07-02  8:06 ` Daniel Lezcano
  2019-07-02  9:03   ` Anson Huang
  4 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2019-07-02  8:06 UTC (permalink / raw)
  To: Anson.Huang, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, leonard.crestez, viresh.kumar, daniel.baluta,
	ping.bai, l.stach, abel.vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: Linux-imx

Hi Anson,

why did you resend the series?


On 02/07/2019 09:55, Anson.Huang@nxp.com wrote:
> From: Anson Huang <Anson.Huang@nxp.com>
> 
> More and more platforms use platform driver model for clock driver,
> so the clock driver is NOT ready during timer initialization phase,
> it will cause timer initialization failed.
> 
> To support those platforms with upper scenario, introducing a new
> flag TIMER_OF_CLOCK_FREQUENCY which is mutually exclusive with
> TIMER_OF_CLOCK flag to support getting timer clock frequency from
> DT's timer node, the property name should be "clock-frequency",
> then of_clk operations can be skipped.
> 
> User needs to select either TIMER_OF_CLOCK_FREQUENCY or TIMER_OF_CLOCK
> flag if want to use timer-of driver to initialize the clock rate.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> Changes since V3:
> 	- use hardcoded "clock-frequency" instead of adding new variable prop_name;
> 	- add pre-condition check for TIMER_OF_CLOCK and TIMER_OF_CLOCK_FREQUENCY, they MUST be exclusive.
> ---
>  drivers/clocksource/timer-of.c | 29 +++++++++++++++++++++++++++++
>  drivers/clocksource/timer-of.h |  7 ++++---
>  2 files changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
> index 8054228..858f684 100644
> --- a/drivers/clocksource/timer-of.c
> +++ b/drivers/clocksource/timer-of.c
> @@ -161,11 +161,30 @@ static __init int timer_of_base_init(struct device_node *np,
>  	return 0;
>  }
>  
> +static __init int timer_of_clk_frequency_init(struct device_node *np,
> +					      struct of_timer_clk *of_clk)
> +{
> +	int ret;
> +	u32 rate;
> +
> +	ret = of_property_read_u32(np, "clock-frequency", &rate);
> +	if (!ret) {
> +		of_clk->rate = rate;
> +		of_clk->period = DIV_ROUND_UP(rate, HZ);
> +	}
> +
> +	return ret;
> +}
> +
>  int __init timer_of_init(struct device_node *np, struct timer_of *to)
>  {
> +	unsigned long clock_flags = TIMER_OF_CLOCK | TIMER_OF_CLOCK_FREQUENCY;
>  	int ret = -EINVAL;
>  	int flags = 0;
>  
> +	if ((to->flags & clock_flags) == clock_flags)
> +		return ret;
> +
>  	if (to->flags & TIMER_OF_BASE) {
>  		ret = timer_of_base_init(np, &to->of_base);
>  		if (ret)
> @@ -180,6 +199,13 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
>  		flags |= TIMER_OF_CLOCK;
>  	}
>  
> +	if (to->flags & TIMER_OF_CLOCK_FREQUENCY) {
> +		ret = timer_of_clk_frequency_init(np, &to->of_clk);
> +		if (ret)
> +			goto out_fail;
> +		flags |= TIMER_OF_CLOCK_FREQUENCY;
> +	}
> +
>  	if (to->flags & TIMER_OF_IRQ) {
>  		ret = timer_of_irq_init(np, &to->of_irq);
>  		if (ret)
> @@ -201,6 +227,9 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
>  	if (flags & TIMER_OF_CLOCK)
>  		timer_of_clk_exit(&to->of_clk);
>  
> +	if (flags & TIMER_OF_CLOCK_FREQUENCY)
> +		to->of_clk.rate = 0;
> +
>  	if (flags & TIMER_OF_BASE)
>  		timer_of_base_exit(&to->of_base);
>  	return ret;
> diff --git a/drivers/clocksource/timer-of.h b/drivers/clocksource/timer-of.h
> index a5478f3..a08e108 100644
> --- a/drivers/clocksource/timer-of.h
> +++ b/drivers/clocksource/timer-of.h
> @@ -4,9 +4,10 @@
>  
>  #include <linux/clockchips.h>
>  
> -#define TIMER_OF_BASE	0x1
> -#define TIMER_OF_CLOCK	0x2
> -#define TIMER_OF_IRQ	0x4
> +#define TIMER_OF_BASE			0x1
> +#define TIMER_OF_CLOCK			0x2
> +#define TIMER_OF_IRQ			0x4
> +#define TIMER_OF_CLOCK_FREQUENCY	0x8
>  
>  struct of_timer_irq {
>  	int irq;
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* RE: [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT
  2019-07-02  8:06 ` [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Daniel Lezcano
@ 2019-07-02  9:03   ` Anson Huang
  2019-07-02  9:07     ` Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Anson Huang @ 2019-07-02  9:03 UTC (permalink / raw)
  To: Daniel Lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, Leonard Crestez, viresh.kumar, Daniel Baluta,
	Jacky Bai, l.stach, Abel Vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: dl-linux-imx

Hi, Daniel

> Hi Anson,
> 
> why did you resend the series?

Previous patch series has build warning and I did NOT notice, sorry for that,

drivers/clocksource/timer-of.c: In function ‘timer_of_init’:
drivers/clocksource/timer-of.c:185:30: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
  if (to->flags & clock_flags == clock_flags)
                              ^

so I resend the patch series with below, sorry for missing mention of the changes in resent patch series.

 +	if ((to->flags & clock_flags) == clock_flags)

Sorry for mail storm...

Thanks,
Anson

> 
> 
> On 02/07/2019 09:55, Anson.Huang@nxp.com wrote:
> > From: Anson Huang <Anson.Huang@nxp.com>
> >
> > More and more platforms use platform driver model for clock driver, so
> > the clock driver is NOT ready during timer initialization phase, it
> > will cause timer initialization failed.
> >
> > To support those platforms with upper scenario, introducing a new flag
> > TIMER_OF_CLOCK_FREQUENCY which is mutually exclusive with
> > TIMER_OF_CLOCK flag to support getting timer clock frequency from DT's
> > timer node, the property name should be "clock-frequency", then of_clk
> > operations can be skipped.
> >
> > User needs to select either TIMER_OF_CLOCK_FREQUENCY or
> TIMER_OF_CLOCK
> > flag if want to use timer-of driver to initialize the clock rate.
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> > ---
> > Changes since V3:
> > 	- use hardcoded "clock-frequency" instead of adding new variable
> prop_name;
> > 	- add pre-condition check for TIMER_OF_CLOCK and
> TIMER_OF_CLOCK_FREQUENCY, they MUST be exclusive.
> > ---
> >  drivers/clocksource/timer-of.c | 29 +++++++++++++++++++++++++++++
> > drivers/clocksource/timer-of.h |  7 ++++---
> >  2 files changed, 33 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/clocksource/timer-of.c
> > b/drivers/clocksource/timer-of.c index 8054228..858f684 100644
> > --- a/drivers/clocksource/timer-of.c
> > +++ b/drivers/clocksource/timer-of.c
> > @@ -161,11 +161,30 @@ static __init int timer_of_base_init(struct
> device_node *np,
> >  	return 0;
> >  }
> >
> > +static __init int timer_of_clk_frequency_init(struct device_node *np,
> > +					      struct of_timer_clk *of_clk) {
> > +	int ret;
> > +	u32 rate;
> > +
> > +	ret = of_property_read_u32(np, "clock-frequency", &rate);
> > +	if (!ret) {
> > +		of_clk->rate = rate;
> > +		of_clk->period = DIV_ROUND_UP(rate, HZ);
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> >  int __init timer_of_init(struct device_node *np, struct timer_of *to)
> > {
> > +	unsigned long clock_flags = TIMER_OF_CLOCK |
> > +TIMER_OF_CLOCK_FREQUENCY;
> >  	int ret = -EINVAL;
> >  	int flags = 0;
> >
> > +	if ((to->flags & clock_flags) == clock_flags)
> > +		return ret;
> > +
> >  	if (to->flags & TIMER_OF_BASE) {
> >  		ret = timer_of_base_init(np, &to->of_base);
> >  		if (ret)
> > @@ -180,6 +199,13 @@ int __init timer_of_init(struct device_node *np,
> struct timer_of *to)
> >  		flags |= TIMER_OF_CLOCK;
> >  	}
> >
> > +	if (to->flags & TIMER_OF_CLOCK_FREQUENCY) {
> > +		ret = timer_of_clk_frequency_init(np, &to->of_clk);
> > +		if (ret)
> > +			goto out_fail;
> > +		flags |= TIMER_OF_CLOCK_FREQUENCY;
> > +	}
> > +
> >  	if (to->flags & TIMER_OF_IRQ) {
> >  		ret = timer_of_irq_init(np, &to->of_irq);
> >  		if (ret)
> > @@ -201,6 +227,9 @@ int __init timer_of_init(struct device_node *np,
> struct timer_of *to)
> >  	if (flags & TIMER_OF_CLOCK)
> >  		timer_of_clk_exit(&to->of_clk);
> >
> > +	if (flags & TIMER_OF_CLOCK_FREQUENCY)
> > +		to->of_clk.rate = 0;
> > +
> >  	if (flags & TIMER_OF_BASE)
> >  		timer_of_base_exit(&to->of_base);
> >  	return ret;
> > diff --git a/drivers/clocksource/timer-of.h
> > b/drivers/clocksource/timer-of.h index a5478f3..a08e108 100644
> > --- a/drivers/clocksource/timer-of.h
> > +++ b/drivers/clocksource/timer-of.h
> > @@ -4,9 +4,10 @@
> >
> >  #include <linux/clockchips.h>
> >
> > -#define TIMER_OF_BASE	0x1
> > -#define TIMER_OF_CLOCK	0x2
> > -#define TIMER_OF_IRQ	0x4
> > +#define TIMER_OF_BASE			0x1
> > +#define TIMER_OF_CLOCK			0x2
> > +#define TIMER_OF_IRQ			0x4
> > +#define TIMER_OF_CLOCK_FREQUENCY	0x8
> >
> >  struct of_timer_irq {
> >  	int irq;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT
  2019-07-02  9:03   ` Anson Huang
@ 2019-07-02  9:07     ` Daniel Lezcano
  2019-07-02  9:10       ` Anson Huang
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2019-07-02  9:07 UTC (permalink / raw)
  To: Anson Huang, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, Leonard Crestez, viresh.kumar, Daniel Baluta,
	Jacky Bai, l.stach, Abel Vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: dl-linux-imx

On 02/07/2019 11:03, Anson Huang wrote:
> Hi, Daniel
> 
>> Hi Anson,
>>
>> why did you resend the series?
> 
> Previous patch series has build warning and I did NOT notice, sorry for that,
> 
> drivers/clocksource/timer-of.c: In function ‘timer_of_init’:
> drivers/clocksource/timer-of.c:185:30: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
>   if (to->flags & clock_flags == clock_flags)
>                               ^
> 
> so I resend the patch series with below, sorry for missing mention of the changes in resent patch series.
> 
>  +	if ((to->flags & clock_flags) == clock_flags)
> 
> Sorry for mail storm...

No problem at all, I prefer this caught and fixed early :)

Next time just send a V5 because 'resend' means there is no change but
there was a problem with the email (could be also interpreted as a
gentle ping).

>> On 02/07/2019 09:55, Anson.Huang@nxp.com wrote:
>>> From: Anson Huang <Anson.Huang@nxp.com>
>>>
>>> More and more platforms use platform driver model for clock driver, so
>>> the clock driver is NOT ready during timer initialization phase, it
>>> will cause timer initialization failed.
>>>
>>> To support those platforms with upper scenario, introducing a new flag
>>> TIMER_OF_CLOCK_FREQUENCY which is mutually exclusive with
>>> TIMER_OF_CLOCK flag to support getting timer clock frequency from DT's
>>> timer node, the property name should be "clock-frequency", then of_clk
>>> operations can be skipped.
>>>
>>> User needs to select either TIMER_OF_CLOCK_FREQUENCY or
>> TIMER_OF_CLOCK
>>> flag if want to use timer-of driver to initialize the clock rate.
>>>
>>> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
>>> ---
>>> Changes since V3:
>>> 	- use hardcoded "clock-frequency" instead of adding new variable
>> prop_name;
>>> 	- add pre-condition check for TIMER_OF_CLOCK and
>> TIMER_OF_CLOCK_FREQUENCY, they MUST be exclusive.
>>> ---
>>>  drivers/clocksource/timer-of.c | 29 +++++++++++++++++++++++++++++
>>> drivers/clocksource/timer-of.h |  7 ++++---
>>>  2 files changed, 33 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/clocksource/timer-of.c
>>> b/drivers/clocksource/timer-of.c index 8054228..858f684 100644
>>> --- a/drivers/clocksource/timer-of.c
>>> +++ b/drivers/clocksource/timer-of.c
>>> @@ -161,11 +161,30 @@ static __init int timer_of_base_init(struct
>> device_node *np,
>>>  	return 0;
>>>  }
>>>
>>> +static __init int timer_of_clk_frequency_init(struct device_node *np,
>>> +					      struct of_timer_clk *of_clk) {
>>> +	int ret;
>>> +	u32 rate;
>>> +
>>> +	ret = of_property_read_u32(np, "clock-frequency", &rate);
>>> +	if (!ret) {
>>> +		of_clk->rate = rate;
>>> +		of_clk->period = DIV_ROUND_UP(rate, HZ);
>>> +	}
>>> +
>>> +	return ret;
>>> +}
>>> +
>>>  int __init timer_of_init(struct device_node *np, struct timer_of *to)
>>> {
>>> +	unsigned long clock_flags = TIMER_OF_CLOCK |
>>> +TIMER_OF_CLOCK_FREQUENCY;
>>>  	int ret = -EINVAL;
>>>  	int flags = 0;
>>>
>>> +	if ((to->flags & clock_flags) == clock_flags)
>>> +		return ret;
>>> +
>>>  	if (to->flags & TIMER_OF_BASE) {
>>>  		ret = timer_of_base_init(np, &to->of_base);
>>>  		if (ret)
>>> @@ -180,6 +199,13 @@ int __init timer_of_init(struct device_node *np,
>> struct timer_of *to)
>>>  		flags |= TIMER_OF_CLOCK;
>>>  	}
>>>
>>> +	if (to->flags & TIMER_OF_CLOCK_FREQUENCY) {
>>> +		ret = timer_of_clk_frequency_init(np, &to->of_clk);
>>> +		if (ret)
>>> +			goto out_fail;
>>> +		flags |= TIMER_OF_CLOCK_FREQUENCY;
>>> +	}
>>> +
>>>  	if (to->flags & TIMER_OF_IRQ) {
>>>  		ret = timer_of_irq_init(np, &to->of_irq);
>>>  		if (ret)
>>> @@ -201,6 +227,9 @@ int __init timer_of_init(struct device_node *np,
>> struct timer_of *to)
>>>  	if (flags & TIMER_OF_CLOCK)
>>>  		timer_of_clk_exit(&to->of_clk);
>>>
>>> +	if (flags & TIMER_OF_CLOCK_FREQUENCY)
>>> +		to->of_clk.rate = 0;
>>> +
>>>  	if (flags & TIMER_OF_BASE)
>>>  		timer_of_base_exit(&to->of_base);
>>>  	return ret;
>>> diff --git a/drivers/clocksource/timer-of.h
>>> b/drivers/clocksource/timer-of.h index a5478f3..a08e108 100644
>>> --- a/drivers/clocksource/timer-of.h
>>> +++ b/drivers/clocksource/timer-of.h
>>> @@ -4,9 +4,10 @@
>>>
>>>  #include <linux/clockchips.h>
>>>
>>> -#define TIMER_OF_BASE	0x1
>>> -#define TIMER_OF_CLOCK	0x2
>>> -#define TIMER_OF_IRQ	0x4
>>> +#define TIMER_OF_BASE			0x1
>>> +#define TIMER_OF_CLOCK			0x2
>>> +#define TIMER_OF_IRQ			0x4
>>> +#define TIMER_OF_CLOCK_FREQUENCY	0x8
>>>
>>>  struct of_timer_irq {
>>>  	int irq;


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* RE: [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT
  2019-07-02  9:07     ` Daniel Lezcano
@ 2019-07-02  9:10       ` Anson Huang
  0 siblings, 0 replies; 9+ messages in thread
From: Anson Huang @ 2019-07-02  9:10 UTC (permalink / raw)
  To: Daniel Lezcano, tglx, robh+dt, mark.rutland, shawnguo, s.hauer,
	kernel, festevam, Leonard Crestez, viresh.kumar, Daniel Baluta,
	Jacky Bai, l.stach, Abel Vesa, andrew.smirnov, ccaione, angus,
	agx, linux-kernel, devicetree, linux-arm-kernel
  Cc: dl-linux-imx

Hi, Daniel

> On 02/07/2019 11:03, Anson Huang wrote:
> > Hi, Daniel
> >
> >> Hi Anson,
> >>
> >> why did you resend the series?
> >
> > Previous patch series has build warning and I did NOT notice, sorry
> > for that,
> >
> > drivers/clocksource/timer-of.c: In function ‘timer_of_init’:
> > drivers/clocksource/timer-of.c:185:30: warning: suggest parentheses
> around comparison in operand of ‘&’ [-Wparentheses]
> >   if (to->flags & clock_flags == clock_flags)
> >                               ^
> >
> > so I resend the patch series with below, sorry for missing mention of the
> changes in resent patch series.
> >
> >  +	if ((to->flags & clock_flags) == clock_flags)
> >
> > Sorry for mail storm...
> 
> No problem at all, I prefer this caught and fixed early :)
> 
> Next time just send a V5 because 'resend' means there is no change but
> there was a problem with the email (could be also interpreted as a gentle
> ping).

OK, will keep it in mind, thanks for sharing useful experience!

Thanks,
Anson

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-07-02  9:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02  7:55 [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Anson.Huang
2019-07-02  7:55 ` [PATCH RESEND V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property Anson.Huang
2019-07-02  7:55 ` [PATCH RESEND V4 3/5] clocksource: imx-sysctr: Make timer work with clock driver using platform driver model Anson.Huang
2019-07-02  7:55 ` [PATCH RESEND V4 4/5] arm64: dts: imx8mq: Add system counter node Anson.Huang
2019-07-02  7:55 ` [PATCH RESEND V4 5/5] arm64: dts: imx8mm: " Anson.Huang
2019-07-02  8:06 ` [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT Daniel Lezcano
2019-07-02  9:03   ` Anson Huang
2019-07-02  9:07     ` Daniel Lezcano
2019-07-02  9:10       ` 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).