Skip to contentSkip to conversation

Add drivers for Intel Keem Bay SoC timer block

PATCH Superseded [email protected] 4 participants 9 messages Nov 26, 2020 – Dec 16, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add drivers for Intel Keem Bay SoC timer block

From: Vijayakannan Ayyathurai <[email protected]>

Hi.

This patch set adds the driver for Intel Keem Bay SoC timer block, which contains 32-bit general purpose timers, a 64 bit free running counter and a random number generator.

Patch 1 holds the Device Tree binding documentation and Patch 2 holds the Device Driver.

This driver was tested on the Keem Bay evaluation module board.

Thanks,
Vijay

Vijayakannan Ayyathurai (2):
dt-bindings: timer: Add bindings for Intel Keem Bay SoC timer
clocksource: Add Intel Keem Bay Timer Support

 .../bindings/timer/intel,keembay-timer.yaml   |  72 ++++++
 drivers/clocksource/Kconfig                   |  10 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-keembay.c           | 221 ++++++++++++++++++
 4 files changed, 304 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml
 create mode 100644 drivers/clocksource/timer-keembay.c

base-commit: 418baf2c28f3473039f2f7377760bd8f6897ae18
prerequisite-patch-id: 822987dcf4c969ef6ac70359b088af06ba39042b
prerequisite-patch-id: 0a348762b660d0d817b8e70cc71647e83173c78c
prerequisite-patch-id: 54c661a006c7362053cb7602448d6c77419d5cf9
prerequisite-patch-id: d140d8534fb828778e0652fe5fcf6282e027f985

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 dt-bindings: timer: Add bindings for Intel Keem Bay SoC timer

From: Vijayakannan Ayyathurai <[email protected]>

Add Device Tree bindings for the Timer IP, which used as clocksource and clockevent in the Intel Keem Bay SoC.

---
 .../bindings/timer/intel,keembay-timer.yaml   | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +72 -0
new file mode 100644
index 000000000000..396a698967ca
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/intel,keembay-timer.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel Keem Bay SoC Timers
+
+maintainers:
+  - Wan Ahmad Zainie <[email protected]>
+
+description:
+  Intel Keem Bay SoC Timers block contains 8 32-bit general purpose timers,
+  a free running 64-bit counter, a random number generator and a watchdog
+  timer. Each gpt can generate an individual interrupt.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          enum:
+            - intel,keembay-timer
+            - intel,keembay-counter
+
+  reg:
+    maxItems: 2
+
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - intel,keembay-timer
+    then:
+      properties:
+        interrupts:
+          maxItems: 1
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #define KEEM_BAY_A53_TIM
+
+    timer@20330010 {
+        compatible = "intel,keembay-timer";
+        reg = <0x20330010 0xc>,
+              <0x20331000 0xc>;
+        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
+
+    counter@203300e8 {
+        compatible = "intel,keembay-counter";
+        reg = <0x203300e8 0xc>,
+              <0x20331000 0xc>;
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
Signature · 1 line
2.17.1
#5 lore raw

PATCH 2/2 clocksource: Add Intel Keem Bay Timer Support

In reply to [email protected]

From: Vijayakannan Ayyathurai <[email protected]>

Add generic clocksource and clockevent driver for the timer IP used in Intel Keem Bay SoC.

One free running Counter used as a clocksource device and one Timer used as a clockevent device. Both are enabled through TIM_GEN_CONFIG register. This register is in the DT resource index 1.

Timer/Counter base register is in the DT resource index 0 and it's map/unmap handled by TIMER OF api.

---
 drivers/clocksource/Kconfig         |  10 ++
 drivers/clocksource/Makefile        |   1 +
 drivers/clocksource/timer-keembay.c | 221 ++++++++++++++++++++++++++++
 3 files changed, 232 insertions(+)
 create mode 100644 drivers/clocksource/timer-keembay.c
drivers/clocksource/Kconfig +10 -0
index 68b087bff59c..b1f29e12c571 100644
@@ -738,4 +738,14 @@ config MICROCHIP_PIT64B
 	  modes and high resolution. It is used as a clocksource
 	  and a clockevent.
 
+config KEEMBAY_TIMER
+	bool "Intel Keem Bay timer driver"
+	depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST)
+	select TIMER_OF
+	help
+	  This option enables the support for the Intel Keem Bay general
+	  purpose timer and free running counter driver. Each timer can
+	  generate an individual interrupt and the 64 bit counter can also
+	  be used as one of the clock source.
+
 endmenu
drivers/clocksource/Makefile +1 -0
index 1c444cc3bb44..f6cfc362b406 100644
@@ -94,3 +94,4 @@ obj-$(CONFIG_CSKY_MP_TIMER)		+= timer-mp-csky.o
 obj-$(CONFIG_GX6605S_TIMER)		+= timer-gx6605s.o
 obj-$(CONFIG_HYPERV_TIMER)		+= hyperv_timer.o
 obj-$(CONFIG_MICROCHIP_PIT64B)		+= timer-microchip-pit64b.o
+obj-$(CONFIG_KEEMBAY_TIMER)		+= timer-keembay.o
drivers/clocksource/timer-keembay.c new file +221 -0

221 lines not on this page · raw message

Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH v1 2/2] clocksource: Add Intel Keem Bay Timer Support

Quoted 27 lines · On 26/11/2020 11:34, [email protected] wrote:

From: Vijayakannan Ayyathurai <[email protected]>

Add generic clocksource and clockevent driver for the timer IP used in Intel Keem Bay SoC.

One free running Counter used as a clocksource device and one Timer used as a clockevent device. Both are enabled through TIM_GEN_CONFIG register. This register is in the DT resource index 1.

Timer/Counter base register is in the DT resource index 0 and it's map/unmap handled by TIMER OF api.

---
 drivers/clocksource/Kconfig         |  10 ++
 drivers/clocksource/Makefile        |   1 +
 drivers/clocksource/timer-keembay.c | 221 ++++++++++++++++++++++++++++
 3 files changed, 232 insertions(+)
 create mode 100644 drivers/clocksource/timer-keembay.c
drivers/clocksource/Kconfig +0 -0
index 68b087bff59c..b1f29e12c571 100644

drivers/clocksource/Kconfig config MICROCHIP_PIT64B · line 743

Quoted 6 lines
drivers/clocksource/Kconfig +3 -0
@@ -738,4 +738,14 @@ config MICROCHIP_PIT64B
 	  modes and high resolution. It is used as a clocksource
 	  and a clockevent.
 
+config KEEMBAY_TIMER
+	bool "Intel Keem Bay timer driver"
+	depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST)

The timer drivers subsystem wants silent options and let the platform to select the timer.

Please select the timer in arch/arm64/Kconfig.platforms in the ARCH_KEEMBAY section.

So it would come:

config KEEMBAY_TIMER
bool "bla bla" if COMPILE_TEST

Quoted 7 lines
drivers/clocksource/Kconfig +7 -0
+	select TIMER_OF
+	help
+	  This option enables the support for the Intel Keem Bay general
+	  purpose timer and free running counter driver. Each timer can
+	  generate an individual interrupt and the 64 bit counter can also
+	  be used as one of the clock source.
+

[ ... ]

drivers/clocksource/Kconfig

Quoted 6 lines
drivers/clocksource/Kconfig +6 -0
+static struct timer_of keembay_ce_to = {
+	.flags	= TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK,
+	.clkevt = {
+		.name			= "keembay_timer",
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,

May be consider CLOCK_EVT_FEAT_DYNIRQ ?

see commit d2348fb6fdc6d67

Other than that, LGTM

Thanks

-- Daniel

Signature · 5 lines
<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
#7 lore raw

Re: [PATCH v1 2/2] clocksource: Add Intel Keem Bay Timer Support

In reply to [email protected]
Quoted 27 lines · On 26/11/2020 11:34, [email protected] wrote:

From: Vijayakannan Ayyathurai <[email protected]>

Add generic clocksource and clockevent driver for the timer IP used in Intel Keem Bay SoC.

One free running Counter used as a clocksource device and one Timer used as a clockevent device. Both are enabled through TIM_GEN_CONFIG register. This register is in the DT resource index 1.

Timer/Counter base register is in the DT resource index 0 and it's map/unmap handled by TIMER OF api.

---
 drivers/clocksource/Kconfig         |  10 ++
 drivers/clocksource/Makefile        |   1 +
 drivers/clocksource/timer-keembay.c | 221 ++++++++++++++++++++++++++++
 3 files changed, 232 insertions(+)
 create mode 100644 drivers/clocksource/timer-keembay.c
drivers/clocksource/Kconfig +0 -0
index 68b087bff59c..b1f29e12c571 100644

drivers/clocksource/Kconfig config MICROCHIP_PIT64B · line 743

Quoted 6 lines
drivers/clocksource/Kconfig +3 -0
@@ -738,4 +738,14 @@ config MICROCHIP_PIT64B
 	  modes and high resolution. It is used as a clocksource
 	  and a clockevent.
 
+config KEEMBAY_TIMER
+	bool "Intel Keem Bay timer driver"
+	depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST)

The timer drivers subsystem wants silent options and let the platform to select the timer.

Please select the timer in arch/arm64/Kconfig.platforms in the ARCH_KEEMBAY section.

So it would come:

config KEEMBAY_TIMER
bool "bla bla" if COMPILE_TEST

Quoted 7 lines
drivers/clocksource/Kconfig +7 -0
+	select TIMER_OF
+	help
+	  This option enables the support for the Intel Keem Bay general
+	  purpose timer and free running counter driver. Each timer can
+	  generate an individual interrupt and the 64 bit counter can also
+	  be used as one of the clock source.
+

[ ... ]

drivers/clocksource/Kconfig

Quoted 6 lines
drivers/clocksource/Kconfig +6 -0
+static struct timer_of keembay_ce_to = {
+	.flags	= TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK,
+	.clkevt = {
+		.name			= "keembay_timer",
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,

May be consider CLOCK_EVT_FEAT_DYNIRQ ?

see commit d2348fb6fdc6d67

Other than that, LGTM

Thanks

-- Daniel

Signature · 5 lines
<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
#8 lore raw

RE: [PATCH v1 2/2] clocksource: Add Intel Keem Bay Timer Support

Hi Daniel,
Thanks for reviewing this patch.

Quoted 14 lines

From: Daniel Lezcano <[email protected]>

drivers/clocksource/Kconfig config MICROCHIP_PIT64B · line 743

Quoted 9 lines

+++ b/drivers/clocksource/Kconfig

drivers/clocksource/Kconfig +3 -0
@@ -738,4 +738,14 @@ config MICROCHIP_PIT64B
 	  modes and high resolution. It is used as a clocksource
 	  and a clockevent.
 
+config KEEMBAY_TIMER
+	bool "Intel Keem Bay timer driver"
+	depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST)

The timer drivers subsystem wants silent options and let the platform to select the timer.

Quoted 8 lines

Please select the timer in arch/arm64/Kconfig.platforms in the ARCH_KEEMBAY section.

So it would come:

config KEEMBAY_TIMER
bool "bla bla" if COMPILE_TEST

Ok. I will check that and update in next version.

Quoted 21 lines
Quoted 9 lines
drivers/clocksource/Kconfig +7 -0
+	select TIMER_OF
+	help
+	  This option enables the support for the Intel Keem Bay general
+	  purpose timer and free running counter driver. Each timer can
+	  generate an individual interrupt and the 64 bit counter can also
+	  be used as one of the clock source.
+

[ ... ]

drivers/clocksource/timer-keembay.c line 145

Quoted 6 lines
drivers/clocksource/timer-keembay.c new file +6 -0
+static struct timer_of keembay_ce_to = {
+	.flags	= TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK,
+	.clkevt = {
+		.name			= "keembay_timer",
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,

May be consider CLOCK_EVT_FEAT_DYNIRQ ?

Quoted 2 lines

see commit d2348fb6fdc6d67

Sure. I will add it in the next version.

Quoted 6 lines

Other than that, LGTM

Thanks

-- Daniel

Thanks,
Vijay

maintainer
#2 lore raw

Re: [PATCH v1 1/2] dt-bindings: timer: Add bindings for Intel Keem Bay SoC timer

In reply to [email protected]
Quoted 79 lines · On Thu, Nov 26, 2020 at 06:34:08PM +0800, [email protected]…

From: Vijayakannan Ayyathurai <[email protected]>

Add Device Tree bindings for the Timer IP, which used as clocksource and clockevent in the Intel Keem Bay SoC.

---
 .../bindings/timer/intel,keembay-timer.yaml   | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +60 -0
new file mode 100644
index 000000000000..396a698967ca
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/intel,keembay-timer.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel Keem Bay SoC Timers
+
+maintainers:
+  - Wan Ahmad Zainie <[email protected]>
+
+description:
+  Intel Keem Bay SoC Timers block contains 8 32-bit general purpose timers,
+  a free running 64-bit counter, a random number generator and a watchdog
+  timer. Each gpt can generate an individual interrupt.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          enum:
+            - intel,keembay-timer
+            - intel,keembay-counter
+
+  reg:
+    maxItems: 2
+
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - intel,keembay-timer
+    then:
+      properties:
+        interrupts:
+          maxItems: 1
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #define KEEM_BAY_A53_TIM
+
+    timer@20330010 {
+        compatible = "intel,keembay-timer";

Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml line 70

Quoted 10 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +10 -0
+        reg = <0x20330010 0xc>,
+              <0x20331000 0xc>;
+        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
+
+    counter@203300e8 {
+        compatible = "intel,keembay-counter";
+        reg = <0x203300e8 0xc>,
+              <0x20331000 0xc>;

You have overlapping reg regions here. Don't do that. Define the DT in terms of the h/w, not how you want to split things for Linux.

It looks like a single h/w block providing multiple functions.

Quoted 5 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +2 -0
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v1 1/2] dt-bindings: timer: Add bindings for Intel Keem Bay SoC timer

Quoted 5 lines · Rob Herring
Quoted 4 lines · On Thu, Nov 26, 2020 at 06:34:08PM +0800, [email protected]…

From: Vijayakannan Ayyathurai <[email protected]>

Add Device Tree bindings for the Timer IP, which used as clocksource and clockevent in the Intel Keem Bay SoC.

...

Quoted 22 lines
Quoted 8 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +8 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #define KEEM_BAY_A53_TIM
+
+    timer@20330010 {
+        compatible = "intel,keembay-timer";

Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml line 70

Quoted 10 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +10 -0
+        reg = <0x20330010 0xc>,
+              <0x20331000 0xc>;
+        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
+
+    counter@203300e8 {
+        compatible = "intel,keembay-counter";
+        reg = <0x203300e8 0xc>,
+              <0x20331000 0xc>;

You have overlapping reg regions here. Don't do that. Define the DT in terms of the h/w, not how you want to split things for Linux.

Quoted 1 line

It looks like a single h/w block providing multiple functions.

Actually a good catch.

Perhaps it needs to have a parent device that provides three resources (one common and one per each of two functions) and in the driver it should consume them accordingly. Though I'm not an expert in DT, does it sound correct from your perspective?

Quoted 2 lines
Quoted 2 lines
(quoted diff) +2 -0
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

RE: [PATCH v1 1/2] dt-bindings: timer: Add bindings for Intel Keem Bay SoC timer

Hi Rob,

Quoted 33 lines

From: Andy Shevchenko <[email protected]>

Quoted 4 lines · Rob Herring
Quoted 4 lines

From: Vijayakannan Ayyathurai <[email protected]>

Add Device Tree bindings for the Timer IP, which used as clocksource and clockevent in the Intel Keem Bay SoC.

...

Quoted 22 lines
Quoted 8 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +8 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #define KEEM_BAY_A53_TIM
+
+    timer@20330010 {
+        compatible = "intel,keembay-timer";

Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml line 70

Quoted 10 lines
Documentation/devicetree/bindings/timer/intel,keembay-timer.yaml new file +10 -0
+        reg = <0x20330010 0xc>,
+              <0x20331000 0xc>;
+        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
+    };
+
+    counter@203300e8 {
+        compatible = "intel,keembay-counter";
+        reg = <0x203300e8 0xc>,
+              <0x20331000 0xc>;

You have overlapping reg regions here. Don't do that. Define the DT in terms of the h/w, not how you want to split things for Linux.

Quoted 1 line

It looks like a single h/w block providing multiple functions.

Quoted 8 lines

Actually a good catch.

Perhaps it needs to have a parent device that provides three resources (one common and one per each of two functions) and in the driver it should consume
them accordingly. Though I'm not an expert in DT, does it sound correct from your perspective?

May I know your feedback for the below way, which Andy suggested. I will adapt the driver based on this in the next version.

timer@20331000 {
    compatible = "intel,keembay-timer";
    reg = <20331000 0xc>;
    
    gpt@20330010 {
        compatible = "intel,keembay-gpt";
        reg = <20330010 0xc>;
        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
    };

    counter@203300e8 {
        compatible = "intel,keembay-counter";
        reg = <203300e8 0xc>;
        clocks = <&scmi_clk KEEM_BAY_A53_TIM>;
    };
};

Thanks,
Vijay