All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Kochetkov <al.kochet@gmail.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Mark Rutland <mark.rutland@arm.com>,
	Rob Herring <robh+dt@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Caesar Wang <wxt@rock-chips.com>,
	Huang Tao <huangtao@rock-chips.com>,
	Alexander Kochetkov <al.kochet@gmail.com>
Subject: [PATCH v7 1/7] clocksource/drivers/clksrc-evt-probe: Describe with the DT both the clocksource and the clockevent
Date: Wed, 22 Mar 2017 18:48:28 +0300	[thread overview]
Message-ID: <1490197714-25415-2-git-send-email-al.kochet@gmail.com> (raw)
In-Reply-To: <1490197714-25415-1-git-send-email-al.kochet@gmail.com>

From: Daniel Lezcano <daniel.lezcano@linaro.org>

The CLOCKSOURCE_OF_DECLARE() was introduced before the
CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the
clockevent and the clocksource are both initialized in the same init
routine.

With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can
now split the clocksource and the clockevent init code. However, the
device tree may specify a single node, so the same node will be passed
to the clockevent/clocksource's init function, with the same base
address.

with this patch it is possible to specify an attribute to the timer's node to
specify if it is a clocksource or a clockevent and define two timers node.

For example:

        timer: timer@98400000 {
                compatible = "moxa,moxart-timer";
                reg = <0x98400000 0x42>;
                interrupts = <19 1>;
                clocks = <&coreclk>;
                clockevent;
        };

        timer: timer@98400010 {
                compatible = "moxa,moxart-timer";
                reg = <0x98400010 0x42>;
                clocks = <&coreclk>;
                clocksource;
        };

With this approach, we allow a mechanism to clearly define a clocksource or a
clockevent without aerobatics we can find around in some drivers:
	timer-sp804.c, arc-timer.c, dw_apb_timer_of.c, mps2-timer.c,
	renesas-ostm.c, time-efm32.c, time-lpc32xx.c.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 Documentation/devicetree/bindings/timer/timer.txt |   38 +++++++++++++++++++++
 drivers/clocksource/clkevt-probe.c                |    7 ++++
 drivers/clocksource/clksrc-probe.c                |    7 ++++
 3 files changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/timer.txt

diff --git a/Documentation/devicetree/bindings/timer/timer.txt b/Documentation/devicetree/bindings/timer/timer.txt
new file mode 100644
index 0000000..f1ee0cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/timer.txt
@@ -0,0 +1,38 @@
+
+Specifying timer information for devices
+========================================
+
+The timer can be declared via the macro:
+
+CLOCKSOURCE_OF_DECLARE(name, init) if it is a clocksource
+CLOCKEVENT_OF_DECLARE(name, init) if it is a clockevent
+
+The CLOCKSOURCE_OF_DECLARE() was introduced before the
+CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the
+clockevent and the clocksource are both initialized in the same init
+routine.
+
+With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can
+now split the clocksource and the clockevent init code. However, the
+device tree may specify a single node, so the same node will be passed
+to the clockevent/clocksource's init function, with the same base
+address. It is possible to specify an attribute to the timer's node to
+specify if it is a clocksource or a clockevent and define two timers
+node.
+
+Example:
+
+	timer: timer@98400000 {
+		compatible = "moxa,moxart-timer";
+		reg = <0x98400000 0x42>;
+		interrupts = <19 1>;
+		clocks = <&coreclk>;
+		clockevent;
+	};
+
+	timer: timer@98400010 {
+		compatible = "moxa,moxart-timer";
+		reg = <0x98400010 0x42>;
+		clocks = <&coreclk>;
+		clocksource;
+	};
diff --git a/drivers/clocksource/clkevt-probe.c b/drivers/clocksource/clkevt-probe.c
index eb89b50..fa02ac1 100644
--- a/drivers/clocksource/clkevt-probe.c
+++ b/drivers/clocksource/clkevt-probe.c
@@ -37,6 +37,13 @@ int __init clockevent_probe(void)
 
 		init_func = match->data;
 
+		/*
+		 * The device node describes a clocksource, ignore it
+		 * as we are in the clockevent init routine.
+		 */
+		if (of_property_read_bool(np, "clocksource"))
+			continue;
+
 		ret = init_func(np);
 		if (ret) {
 			pr_warn("Failed to initialize '%s' (%d)\n",
diff --git a/drivers/clocksource/clksrc-probe.c b/drivers/clocksource/clksrc-probe.c
index bc62be9..ce50f33 100644
--- a/drivers/clocksource/clksrc-probe.c
+++ b/drivers/clocksource/clksrc-probe.c
@@ -38,6 +38,13 @@ void __init clocksource_probe(void)
 
 		init_func_ret = match->data;
 
+		/*
+		 * The device node describes a clockevent, ignore it
+		 * as we are in the clocksource init routine.
+		 */
+		if (of_property_read_bool(np, "clockevent"))
+			continue;
+
 		ret = init_func_ret(np);
 		if (ret) {
 			pr_err("Failed to initialize '%s': %d",
-- 
1.7.9.5

WARNING: multiple messages have this Message-ID (diff)
From: al.kochet@gmail.com (Alexander Kochetkov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 1/7] clocksource/drivers/clksrc-evt-probe: Describe with the DT both the clocksource and the clockevent
Date: Wed, 22 Mar 2017 18:48:28 +0300	[thread overview]
Message-ID: <1490197714-25415-2-git-send-email-al.kochet@gmail.com> (raw)
In-Reply-To: <1490197714-25415-1-git-send-email-al.kochet@gmail.com>

From: Daniel Lezcano <daniel.lezcano@linaro.org>

The CLOCKSOURCE_OF_DECLARE() was introduced before the
CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the
clockevent and the clocksource are both initialized in the same init
routine.

With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can
now split the clocksource and the clockevent init code. However, the
device tree may specify a single node, so the same node will be passed
to the clockevent/clocksource's init function, with the same base
address.

with this patch it is possible to specify an attribute to the timer's node to
specify if it is a clocksource or a clockevent and define two timers node.

For example:

        timer: timer at 98400000 {
                compatible = "moxa,moxart-timer";
                reg = <0x98400000 0x42>;
                interrupts = <19 1>;
                clocks = <&coreclk>;
                clockevent;
        };

        timer: timer at 98400010 {
                compatible = "moxa,moxart-timer";
                reg = <0x98400010 0x42>;
                clocks = <&coreclk>;
                clocksource;
        };

With this approach, we allow a mechanism to clearly define a clocksource or a
clockevent without aerobatics we can find around in some drivers:
	timer-sp804.c, arc-timer.c, dw_apb_timer_of.c, mps2-timer.c,
	renesas-ostm.c, time-efm32.c, time-lpc32xx.c.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 Documentation/devicetree/bindings/timer/timer.txt |   38 +++++++++++++++++++++
 drivers/clocksource/clkevt-probe.c                |    7 ++++
 drivers/clocksource/clksrc-probe.c                |    7 ++++
 3 files changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/timer.txt

diff --git a/Documentation/devicetree/bindings/timer/timer.txt b/Documentation/devicetree/bindings/timer/timer.txt
new file mode 100644
index 0000000..f1ee0cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/timer.txt
@@ -0,0 +1,38 @@
+
+Specifying timer information for devices
+========================================
+
+The timer can be declared via the macro:
+
+CLOCKSOURCE_OF_DECLARE(name, init) if it is a clocksource
+CLOCKEVENT_OF_DECLARE(name, init) if it is a clockevent
+
+The CLOCKSOURCE_OF_DECLARE() was introduced before the
+CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the
+clockevent and the clocksource are both initialized in the same init
+routine.
+
+With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can
+now split the clocksource and the clockevent init code. However, the
+device tree may specify a single node, so the same node will be passed
+to the clockevent/clocksource's init function, with the same base
+address. It is possible to specify an attribute to the timer's node to
+specify if it is a clocksource or a clockevent and define two timers
+node.
+
+Example:
+
+	timer: timer at 98400000 {
+		compatible = "moxa,moxart-timer";
+		reg = <0x98400000 0x42>;
+		interrupts = <19 1>;
+		clocks = <&coreclk>;
+		clockevent;
+	};
+
+	timer: timer at 98400010 {
+		compatible = "moxa,moxart-timer";
+		reg = <0x98400010 0x42>;
+		clocks = <&coreclk>;
+		clocksource;
+	};
diff --git a/drivers/clocksource/clkevt-probe.c b/drivers/clocksource/clkevt-probe.c
index eb89b50..fa02ac1 100644
--- a/drivers/clocksource/clkevt-probe.c
+++ b/drivers/clocksource/clkevt-probe.c
@@ -37,6 +37,13 @@ int __init clockevent_probe(void)
 
 		init_func = match->data;
 
+		/*
+		 * The device node describes a clocksource, ignore it
+		 * as we are in the clockevent init routine.
+		 */
+		if (of_property_read_bool(np, "clocksource"))
+			continue;
+
 		ret = init_func(np);
 		if (ret) {
 			pr_warn("Failed to initialize '%s' (%d)\n",
diff --git a/drivers/clocksource/clksrc-probe.c b/drivers/clocksource/clksrc-probe.c
index bc62be9..ce50f33 100644
--- a/drivers/clocksource/clksrc-probe.c
+++ b/drivers/clocksource/clksrc-probe.c
@@ -38,6 +38,13 @@ void __init clocksource_probe(void)
 
 		init_func_ret = match->data;
 
+		/*
+		 * The device node describes a clockevent, ignore it
+		 * as we are in the clocksource init routine.
+		 */
+		if (of_property_read_bool(np, "clockevent"))
+			continue;
+
 		ret = init_func_ret(np);
 		if (ret) {
 			pr_err("Failed to initialize '%s': %d",
-- 
1.7.9.5

  reply	other threads:[~2017-03-22 15:50 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 15:48 [PATCH v7 0/7] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2017-03-22 15:48 ` Alexander Kochetkov
2017-03-22 15:48 ` Alexander Kochetkov
2017-03-22 15:48 ` Alexander Kochetkov [this message]
2017-03-22 15:48   ` [PATCH v7 1/7] clocksource/drivers/clksrc-evt-probe: Describe with the DT both the clocksource and the clockevent Alexander Kochetkov
2017-03-29  1:51   ` Rob Herring
2017-03-29  1:51     ` Rob Herring
2017-03-29  1:51     ` Rob Herring
2017-03-29  9:22     ` Daniel Lezcano
2017-03-29  9:22       ` Daniel Lezcano
2017-03-29  9:22       ` Daniel Lezcano
2017-03-29 10:49       ` Mark Rutland
2017-03-29 10:49         ` Mark Rutland
2017-03-29 10:49         ` Mark Rutland
2017-03-29 12:36         ` Daniel Lezcano
2017-03-29 12:36           ` Daniel Lezcano
2017-03-29 12:36           ` Daniel Lezcano
2017-03-29 12:57           ` Mark Rutland
2017-03-29 12:57             ` Mark Rutland
2017-03-29 13:41             ` Daniel Lezcano
2017-03-29 13:41               ` Daniel Lezcano
2017-03-29 13:41               ` Daniel Lezcano
2017-03-29 14:34               ` Mark Rutland
2017-03-29 14:34                 ` Mark Rutland
2017-03-29 14:34                 ` Mark Rutland
2017-03-22 15:48 ` [PATCH v7 2/7] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48 ` [PATCH v7 3/7] ARM: dts: rockchip: update compatible property for rk322x timer Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48 ` [PATCH v7 4/7] ARM: dts: rockchip: add clockevent attribute to rockchip timers Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48 ` [PATCH v7 5/7] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-24  8:29   ` kbuild test robot
2017-03-24  8:29     ` kbuild test robot
2017-03-24  8:29     ` kbuild test robot
2017-03-24  8:41     ` Alexander Kochetkov
2017-03-24  8:41       ` Alexander Kochetkov
2017-03-24  8:41       ` Alexander Kochetkov
2017-03-24  8:55       ` Daniel Lezcano
2017-03-24  8:55         ` Daniel Lezcano
2017-03-24  8:55         ` Daniel Lezcano
2017-03-22 15:48 ` [PATCH v7 6/7] ARM: dts: rockchip: add timer entries to rk3188 SoC Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48 ` [PATCH v7 7/7] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-22 15:48   ` Alexander Kochetkov
2017-03-29 13:22 ` [PATCH v7 0/7] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2017-03-29 13:22   ` Alexander Kochetkov
2017-03-30  9:26   ` Daniel Lezcano
2017-03-30  9:26     ` Daniel Lezcano
2017-03-30  9:26     ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490197714-25415-2-git-send-email-al.kochet@gmail.com \
    --to=al.kochet@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=huangtao@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wxt@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.