* [PATCH v4 0/4] stm32 clocksource driver rework
@ 2017-10-02 15:51 Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of Benjamin Gaignard
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-02 15:51 UTC (permalink / raw)
To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
linux-I+IVW8TIWO2tmTQ+vhA3Yw,
mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w,
alexandre.torgue-qxv4g6HH51o,
daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
tglx-hfZtesqFncYOwBW4kG4KsQ, ludovic.barre-qxv4g6HH51o
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Benjamin Gaignard
version 4:
- split patch in 3 parts
- convert code to timer_of
- only use 32 bits timers
- add clocksource support
version 3:
- fix comments done by Daniel
- use timer_of helper functions
version 2:
- fix uninitialized variable
These patches implements clocksource and clockevent by using only one hardware block.
Getting both clock source and events on the same hardware lead to change quite
a lot driver code.
It also limits usage of clocksource to 32 bits timers because 16 bits ones
aren't enough accurate.
Thanks to timer_fo helpers this series includes minor clean up in structures,
function prototypes and driver name.
Since 16 bits timers become useless it also removes them from stm32f4 and
stm32f7 devicetree.
Benjamin Gaignard (4):
clocksource: stm32: convert driver to timer_of
clocksource: stm32: only use 32 bits timers
clocksource: stm32: add clocksource support
arm: dts: stm32: remove useless clocksource nodes
arch/arm/boot/dts/stm32f429.dtsi | 32 ------
arch/arm/boot/dts/stm32f746.dtsi | 32 ------
drivers/clocksource/Kconfig | 1 +
drivers/clocksource/timer-stm32.c | 229 ++++++++++++++++++--------------------
4 files changed, 112 insertions(+), 182 deletions(-)
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of
2017-10-02 15:51 [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
@ 2017-10-02 15:51 ` Benjamin Gaignard
2017-10-17 17:09 ` Daniel Lezcano
2017-10-02 15:51 ` [PATCH v4 2/4] clocksource: stm32: only use 32 bits timers Benjamin Gaignard
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-02 15:51 UTC (permalink / raw)
To: robh+dt, mark.rutland, linux, mcoquelin.stm32, alexandre.torgue,
daniel.lezcano, tglx, ludovic.barre
Cc: devicetree, linux-arm-kernel, linux-kernel, Benjamin Gaignard
Convert driver to use timer_of helpers. This allow to remove
custom proprietary structure.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
drivers/clocksource/Kconfig | 1 +
drivers/clocksource/timer-stm32.c | 162 +++++++++++++-------------------------
2 files changed, 57 insertions(+), 106 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index cc60620..755c0cc 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -289,6 +289,7 @@ config CLKSRC_STM32
bool "Clocksource for STM32 SoCs" if !ARCH_STM32
depends on OF && ARM && (ARCH_STM32 || COMPILE_TEST)
select CLKSRC_MMIO
+ select TIMER_OF
config CLKSRC_MPS2
bool "Clocksource for MPS2 SoCs" if COMPILE_TEST
diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index 8f24237..abff21c 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -17,6 +17,8 @@
#include <linux/clk.h>
#include <linux/reset.h>
+#include "timer-of.h"
+
#define TIM_CR1 0x00
#define TIM_DIER 0x0c
#define TIM_SR 0x10
@@ -34,117 +36,84 @@
#define TIM_EGR_UG BIT(0)
-struct stm32_clock_event_ddata {
- struct clock_event_device evtdev;
- unsigned periodic_top;
- void __iomem *base;
-};
-
-static int stm32_clock_event_shutdown(struct clock_event_device *evtdev)
+static int stm32_clock_event_shutdown(struct clock_event_device *evt)
{
- struct stm32_clock_event_ddata *data =
- container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
- void *base = data->base;
+ struct timer_of *to = to_timer_of(evt);
- writel_relaxed(0, base + TIM_CR1);
+ writel_relaxed(0, timer_of_base(to) + TIM_CR1);
return 0;
}
-static int stm32_clock_event_set_periodic(struct clock_event_device *evtdev)
+static int stm32_clock_event_set_periodic(struct clock_event_device *evt)
{
- struct stm32_clock_event_ddata *data =
- container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
- void *base = data->base;
+ struct timer_of *to = to_timer_of(evt);
+
+ writel_relaxed(timer_of_period(to), timer_of_base(to) + TIM_ARR);
+ writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, timer_of_base(to) + TIM_CR1);
- writel_relaxed(data->periodic_top, base + TIM_ARR);
- writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, base + TIM_CR1);
return 0;
}
static int stm32_clock_event_set_next_event(unsigned long evt,
- struct clock_event_device *evtdev)
+ struct clock_event_device *clkevt)
{
- struct stm32_clock_event_ddata *data =
- container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
+ struct timer_of *to = to_timer_of(clkevt);
- writel_relaxed(evt, data->base + TIM_ARR);
+ writel_relaxed(evt, timer_of_base(to) + TIM_ARR);
writel_relaxed(TIM_CR1_ARPE | TIM_CR1_OPM | TIM_CR1_CEN,
- data->base + TIM_CR1);
+ timer_of_base(to) + TIM_CR1);
return 0;
}
static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id)
{
- struct stm32_clock_event_ddata *data = dev_id;
+ struct clock_event_device *evt = (struct clock_event_device *)dev_id;
+ struct timer_of *to = to_timer_of(evt);
- writel_relaxed(0, data->base + TIM_SR);
+ writel_relaxed(0, timer_of_base(to) + TIM_SR);
- data->evtdev.event_handler(&data->evtdev);
+ evt->event_handler(evt);
return IRQ_HANDLED;
}
-static struct stm32_clock_event_ddata clock_event_ddata = {
- .evtdev = {
- .name = "stm32 clockevent",
- .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
- .set_state_shutdown = stm32_clock_event_shutdown,
- .set_state_periodic = stm32_clock_event_set_periodic,
- .set_state_oneshot = stm32_clock_event_shutdown,
- .tick_resume = stm32_clock_event_shutdown,
- .set_next_event = stm32_clock_event_set_next_event,
- .rating = 200,
- },
-};
-
-static int __init stm32_clockevent_init(struct device_node *np)
+static int __init stm32_clockevent_init(struct device_node *node)
{
- struct stm32_clock_event_ddata *data = &clock_event_ddata;
- struct clk *clk;
struct reset_control *rstc;
- unsigned long rate, max_delta;
- int irq, ret, bits, prescaler = 1;
-
- clk = of_clk_get(np, 0);
- if (IS_ERR(clk)) {
- ret = PTR_ERR(clk);
- pr_err("failed to get clock for clockevent (%d)\n", ret);
- goto err_clk_get;
- }
-
- ret = clk_prepare_enable(clk);
- if (ret) {
- pr_err("failed to enable timer clock for clockevent (%d)\n",
- ret);
- goto err_clk_enable;
- }
-
- rate = clk_get_rate(clk);
-
- rstc = of_reset_control_get(np, NULL);
+ unsigned long max_delta;
+ int ret, bits, prescaler = 1;
+ struct timer_of *to;
+
+ to = kzalloc(sizeof(*to), GFP_KERNEL);
+ if (!to)
+ return -ENOMEM;
+
+ to->flags = TIMER_OF_IRQ | TIMER_OF_CLOCK | TIMER_OF_BASE;
+ to->clkevt.name = "stm32_clockevent";
+ to->clkevt.rating = 200;
+ to->clkevt.features = CLOCK_EVT_FEAT_PERIODIC;
+ to->clkevt.set_state_shutdown = stm32_clock_event_shutdown;
+ to->clkevt.set_state_periodic = stm32_clock_event_set_periodic;
+ to->clkevt.set_state_oneshot = stm32_clock_event_shutdown;
+ to->clkevt.tick_resume = stm32_clock_event_shutdown;
+ to->clkevt.set_next_event = stm32_clock_event_set_next_event;
+
+ to->of_irq.handler = stm32_clock_event_handler;
+
+ ret = timer_of_init(node, to);
+ if (ret)
+ return ret;
+
+ rstc = of_reset_control_get(node, NULL);
if (!IS_ERR(rstc)) {
reset_control_assert(rstc);
reset_control_deassert(rstc);
}
- data->base = of_iomap(np, 0);
- if (!data->base) {
- ret = -ENXIO;
- pr_err("failed to map registers for clockevent\n");
- goto err_iomap;
- }
-
- irq = irq_of_parse_and_map(np, 0);
- if (!irq) {
- ret = -EINVAL;
- pr_err("%pOF: failed to get irq.\n", np);
- goto err_get_irq;
- }
-
/* Detect whether the timer is 16 or 32 bits */
- writel_relaxed(~0U, data->base + TIM_ARR);
- max_delta = readl_relaxed(data->base + TIM_ARR);
+ writel_relaxed(~0U, timer_of_base(to) + TIM_ARR);
+ max_delta = readl_relaxed(timer_of_base(to) + TIM_ARR);
if (max_delta == ~0U) {
prescaler = 1;
bits = 32;
@@ -152,39 +121,20 @@ static int __init stm32_clockevent_init(struct device_node *np)
prescaler = 1024;
bits = 16;
}
- writel_relaxed(0, data->base + TIM_ARR);
-
- writel_relaxed(prescaler - 1, data->base + TIM_PSC);
- writel_relaxed(TIM_EGR_UG, data->base + TIM_EGR);
- writel_relaxed(TIM_DIER_UIE, data->base + TIM_DIER);
- writel_relaxed(0, data->base + TIM_SR);
+ writel_relaxed(0, timer_of_base(to) + TIM_ARR);
- data->periodic_top = DIV_ROUND_CLOSEST(rate, prescaler * HZ);
+ writel_relaxed(prescaler - 1, timer_of_base(to) + TIM_PSC);
+ writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR);
+ writel_relaxed(TIM_DIER_UIE, timer_of_base(to) + TIM_DIER);
+ writel_relaxed(0, timer_of_base(to) + TIM_SR);
- clockevents_config_and_register(&data->evtdev,
- DIV_ROUND_CLOSEST(rate, prescaler),
- 0x1, max_delta);
-
- ret = request_irq(irq, stm32_clock_event_handler, IRQF_TIMER,
- "stm32 clockevent", data);
- if (ret) {
- pr_err("%pOF: failed to request irq.\n", np);
- goto err_get_irq;
- }
+ clockevents_config_and_register(&to->clkevt,
+ timer_of_period(to), 0x60, max_delta);
pr_info("%pOF: STM32 clockevent driver initialized (%d bits)\n",
- np, bits);
-
- return ret;
-
-err_get_irq:
- iounmap(data->base);
-err_iomap:
- clk_disable_unprepare(clk);
-err_clk_enable:
- clk_put(clk);
-err_clk_get:
- return ret;
+ node, bits);
+
+ return 0;
}
TIMER_OF_DECLARE(stm32, "st,stm32-timer", stm32_clockevent_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 2/4] clocksource: stm32: only use 32 bits timers
2017-10-02 15:51 [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of Benjamin Gaignard
@ 2017-10-02 15:51 ` Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 3/4] clocksource: stm32: add clocksource support Benjamin Gaignard
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-02 15:51 UTC (permalink / raw)
To: robh+dt, mark.rutland, linux, mcoquelin.stm32, alexandre.torgue,
daniel.lezcano, tglx, ludovic.barre
Cc: devicetree, linux-arm-kernel, linux-kernel, Benjamin Gaignard
16 bits hardware are not enough accure to be used.
Do no allow them to be probed by tested max counter value.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
drivers/clocksource/timer-stm32.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index abff21c..f7e4eec 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -81,9 +81,9 @@ static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id)
static int __init stm32_clockevent_init(struct device_node *node)
{
struct reset_control *rstc;
- unsigned long max_delta;
- int ret, bits, prescaler = 1;
+ unsigned long max_arr;
struct timer_of *to;
+ int ret;
to = kzalloc(sizeof(*to), GFP_KERNEL);
if (!to)
@@ -113,26 +113,21 @@ static int __init stm32_clockevent_init(struct device_node *node)
/* Detect whether the timer is 16 or 32 bits */
writel_relaxed(~0U, timer_of_base(to) + TIM_ARR);
- max_delta = readl_relaxed(timer_of_base(to) + TIM_ARR);
- if (max_delta == ~0U) {
- prescaler = 1;
- bits = 32;
- } else {
- prescaler = 1024;
- bits = 16;
+ max_arr = readl_relaxed(timer_of_base(to) + TIM_ARR);
+ if (max_arr != ~0U) {
+ pr_err("32 bits timer is needed\n");
+ return -EINVAL;
}
+
writel_relaxed(0, timer_of_base(to) + TIM_ARR);
- writel_relaxed(prescaler - 1, timer_of_base(to) + TIM_PSC);
+ writel_relaxed(0, timer_of_base(to) + TIM_PSC);
writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR);
writel_relaxed(TIM_DIER_UIE, timer_of_base(to) + TIM_DIER);
writel_relaxed(0, timer_of_base(to) + TIM_SR);
clockevents_config_and_register(&to->clkevt,
- timer_of_period(to), 0x60, max_delta);
-
- pr_info("%pOF: STM32 clockevent driver initialized (%d bits)\n",
- node, bits);
+ timer_of_period(to), 0x60, ~0U);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 3/4] clocksource: stm32: add clocksource support
2017-10-02 15:51 [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 2/4] clocksource: stm32: only use 32 bits timers Benjamin Gaignard
@ 2017-10-02 15:51 ` Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 4/4] arm: dts: stm32: remove useless clocksource nodes Benjamin Gaignard
[not found] ` <1506959513-16851-1-git-send-email-benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
4 siblings, 0 replies; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-02 15:51 UTC (permalink / raw)
To: robh+dt, mark.rutland, linux, mcoquelin.stm32, alexandre.torgue,
daniel.lezcano, tglx, ludovic.barre
Cc: devicetree, linux-arm-kernel, linux-kernel, Benjamin Gaignard
Rework driver code to be able to implement clocksource and clockevent
on the same hardware block.
Before this patch only the counter of the hardware block was used to
generate clock events. Now counter will be used to provide a 32 bits
clock source and a comparator will provide clock events.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
drivers/clocksource/timer-stm32.c | 104 ++++++++++++++++++++++++++++----------
1 file changed, 76 insertions(+), 28 deletions(-)
diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index f7e4eec..fb84252 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -16,6 +16,8 @@
#include <linux/of_irq.h>
#include <linux/clk.h>
#include <linux/reset.h>
+#include <linux/sched_clock.h>
+#include <linux/slab.h>
#include "timer-of.h"
@@ -23,16 +25,16 @@
#define TIM_DIER 0x0c
#define TIM_SR 0x10
#define TIM_EGR 0x14
+#define TIM_CNT 0x24
#define TIM_PSC 0x28
#define TIM_ARR 0x2c
+#define TIM_CCR1 0x34
#define TIM_CR1_CEN BIT(0)
-#define TIM_CR1_OPM BIT(3)
+#define TIM_CR1_UDIS BIT(1)
#define TIM_CR1_ARPE BIT(7)
-#define TIM_DIER_UIE BIT(0)
-
-#define TIM_SR_UIF BIT(0)
+#define TIM_DIER_CC1IE BIT(1)
#define TIM_EGR_UG BIT(0)
@@ -40,30 +42,34 @@ static int stm32_clock_event_shutdown(struct clock_event_device *evt)
{
struct timer_of *to = to_timer_of(evt);
- writel_relaxed(0, timer_of_base(to) + TIM_CR1);
+ writel_relaxed(0, timer_of_base(to) + TIM_DIER);
+
return 0;
}
-static int stm32_clock_event_set_periodic(struct clock_event_device *evt)
+static int stm32_clock_event_set_next_event(unsigned long evt,
+ struct clock_event_device *clkevt)
{
- struct timer_of *to = to_timer_of(evt);
+ struct timer_of *to = to_timer_of(clkevt);
+ unsigned long cnt;
- writel_relaxed(timer_of_period(to), timer_of_base(to) + TIM_ARR);
- writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, timer_of_base(to) + TIM_CR1);
+ cnt = readl_relaxed(timer_of_base(to) + TIM_CNT);
+ writel_relaxed(cnt + evt, timer_of_base(to) + TIM_CCR1);
+ writel_relaxed(TIM_DIER_CC1IE, timer_of_base(to) + TIM_DIER);
return 0;
}
-static int stm32_clock_event_set_next_event(unsigned long evt,
- struct clock_event_device *clkevt)
+static int stm32_clock_event_set_periodic(struct clock_event_device *evt)
{
- struct timer_of *to = to_timer_of(clkevt);
+ struct timer_of *to = to_timer_of(evt);
- writel_relaxed(evt, timer_of_base(to) + TIM_ARR);
- writel_relaxed(TIM_CR1_ARPE | TIM_CR1_OPM | TIM_CR1_CEN,
- timer_of_base(to) + TIM_CR1);
+ return stm32_clock_event_set_next_event(timer_of_period(to), evt);
+}
- return 0;
+static int stm32_clock_event_set_oneshot(struct clock_event_device *evt)
+{
+ return stm32_clock_event_set_next_event(0, evt);
}
static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id)
@@ -73,12 +79,57 @@ static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id)
writel_relaxed(0, timer_of_base(to) + TIM_SR);
+ if (clockevent_state_periodic(evt))
+ stm32_clock_event_set_periodic(evt);
+ else
+ stm32_clock_event_shutdown(evt);
+
evt->event_handler(evt);
return IRQ_HANDLED;
}
-static int __init stm32_clockevent_init(struct device_node *node)
+static void __init stm32_clockevent_init(struct timer_of *to)
+{
+ writel_relaxed(0, timer_of_base(to) + TIM_DIER);
+ writel_relaxed(0, timer_of_base(to) + TIM_SR);
+
+ clockevents_config_and_register(&to->clkevt,
+ timer_of_rate(to), 0x60, ~0U);
+}
+
+static void __iomem *stm32_timer_cnt __read_mostly;
+static u64 notrace stm32_read_sched_clock(void)
+{
+ return readl_relaxed(stm32_timer_cnt);
+}
+
+static int __init stm32_clocksource_init(struct timer_of *to)
+{
+ writel_relaxed(~0U, timer_of_base(to) + TIM_ARR);
+ writel_relaxed(0, timer_of_base(to) + TIM_PSC);
+ writel_relaxed(0, timer_of_base(to) + TIM_SR);
+ writel_relaxed(0, timer_of_base(to) + TIM_DIER);
+ writel_relaxed(0, timer_of_base(to) + TIM_SR);
+ writel_relaxed(TIM_CR1_ARPE | TIM_CR1_UDIS,
+ timer_of_base(to) + TIM_CR1);
+
+ /* Make sure that registers are updated */
+ writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR);
+
+ /* Enable controller */
+ writel_relaxed(TIM_CR1_ARPE | TIM_CR1_UDIS | TIM_CR1_CEN,
+ timer_of_base(to) + TIM_CR1);
+
+ stm32_timer_cnt = timer_of_base(to) + TIM_CNT;
+ sched_clock_register(stm32_read_sched_clock, 32, timer_of_rate(to));
+
+ return clocksource_mmio_init(stm32_timer_cnt, "stm32_timer",
+ timer_of_rate(to), 250, 32,
+ clocksource_mmio_readl_up);
+}
+
+static int __init stm32_timer_init(struct device_node *node)
{
struct reset_control *rstc;
unsigned long max_arr;
@@ -90,12 +141,13 @@ static int __init stm32_clockevent_init(struct device_node *node)
return -ENOMEM;
to->flags = TIMER_OF_IRQ | TIMER_OF_CLOCK | TIMER_OF_BASE;
+
to->clkevt.name = "stm32_clockevent";
to->clkevt.rating = 200;
- to->clkevt.features = CLOCK_EVT_FEAT_PERIODIC;
+ to->clkevt.features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC;
to->clkevt.set_state_shutdown = stm32_clock_event_shutdown;
to->clkevt.set_state_periodic = stm32_clock_event_set_periodic;
- to->clkevt.set_state_oneshot = stm32_clock_event_shutdown;
+ to->clkevt.set_state_oneshot = stm32_clock_event_set_oneshot;
to->clkevt.tick_resume = stm32_clock_event_shutdown;
to->clkevt.set_next_event = stm32_clock_event_set_next_event;
@@ -119,17 +171,13 @@ static int __init stm32_clockevent_init(struct device_node *node)
return -EINVAL;
}
- writel_relaxed(0, timer_of_base(to) + TIM_ARR);
-
- writel_relaxed(0, timer_of_base(to) + TIM_PSC);
- writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR);
- writel_relaxed(TIM_DIER_UIE, timer_of_base(to) + TIM_DIER);
- writel_relaxed(0, timer_of_base(to) + TIM_SR);
+ ret = stm32_clocksource_init(to);
+ if (ret)
+ return ret;
- clockevents_config_and_register(&to->clkevt,
- timer_of_period(to), 0x60, ~0U);
+ stm32_clockevent_init(to);
return 0;
}
-TIMER_OF_DECLARE(stm32, "st,stm32-timer", stm32_clockevent_init);
+TIMER_OF_DECLARE(stm32, "st,stm32-timer", stm32_timer_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 4/4] arm: dts: stm32: remove useless clocksource nodes
2017-10-02 15:51 [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
` (2 preceding siblings ...)
2017-10-02 15:51 ` [PATCH v4 3/4] clocksource: stm32: add clocksource support Benjamin Gaignard
@ 2017-10-02 15:51 ` Benjamin Gaignard
[not found] ` <1506959513-16851-1-git-send-email-benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
4 siblings, 0 replies; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-02 15:51 UTC (permalink / raw)
To: robh+dt, mark.rutland, linux, mcoquelin.stm32, alexandre.torgue,
daniel.lezcano, tglx, ludovic.barre
Cc: devicetree, linux-arm-kernel, linux-kernel, Benjamin Gaignard
16 bits timers aren't accurate enough to be used as
clocksource, remove them from stm32f4 and stm32f7 devicetree.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
arch/arm/boot/dts/stm32f429.dtsi | 32 --------------------------------
arch/arm/boot/dts/stm32f746.dtsi | 32 --------------------------------
2 files changed, 64 deletions(-)
diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index dd7e99b..ac9a3e6 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -108,14 +108,6 @@
};
};
- timer3: timer@40000400 {
- compatible = "st,stm32-timer";
- reg = <0x40000400 0x400>;
- interrupts = <29>;
- clocks = <&rcc 0 STM32F4_APB1_CLOCK(TIM3)>;
- status = "disabled";
- };
-
timers3: timers@40000400 {
#address-cells = <1>;
#size-cells = <0>;
@@ -137,14 +129,6 @@
};
};
- timer4: timer@40000800 {
- compatible = "st,stm32-timer";
- reg = <0x40000800 0x400>;
- interrupts = <30>;
- clocks = <&rcc 0 STM32F4_APB1_CLOCK(TIM4)>;
- status = "disabled";
- };
-
timers4: timers@40000800 {
#address-cells = <1>;
#size-cells = <0>;
@@ -194,14 +178,6 @@
};
};
- timer6: timer@40001000 {
- compatible = "st,stm32-timer";
- reg = <0x40001000 0x400>;
- interrupts = <54>;
- clocks = <&rcc 0 STM32F4_APB1_CLOCK(TIM6)>;
- status = "disabled";
- };
-
timers6: timers@40001000 {
#address-cells = <1>;
#size-cells = <0>;
@@ -218,14 +194,6 @@
};
};
- timer7: timer@40001400 {
- compatible = "st,stm32-timer";
- reg = <0x40001400 0x400>;
- interrupts = <55>;
- clocks = <&rcc 0 STM32F4_APB1_CLOCK(TIM7)>;
- status = "disabled";
- };
-
timers7: timers@40001400 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi
index 5633860..a9077e6 100644
--- a/arch/arm/boot/dts/stm32f746.dtsi
+++ b/arch/arm/boot/dts/stm32f746.dtsi
@@ -82,22 +82,6 @@
status = "disabled";
};
- timer3: timer@40000400 {
- compatible = "st,stm32-timer";
- reg = <0x40000400 0x400>;
- interrupts = <29>;
- clocks = <&rcc 0 STM32F7_APB1_CLOCK(TIM3)>;
- status = "disabled";
- };
-
- timer4: timer@40000800 {
- compatible = "st,stm32-timer";
- reg = <0x40000800 0x400>;
- interrupts = <30>;
- clocks = <&rcc 0 STM32F7_APB1_CLOCK(TIM4)>;
- status = "disabled";
- };
-
timer5: timer@40000c00 {
compatible = "st,stm32-timer";
reg = <0x40000c00 0x400>;
@@ -105,22 +89,6 @@
clocks = <&rcc 0 STM32F7_APB1_CLOCK(TIM5)>;
};
- timer6: timer@40001000 {
- compatible = "st,stm32-timer";
- reg = <0x40001000 0x400>;
- interrupts = <54>;
- clocks = <&rcc 0 STM32F7_APB1_CLOCK(TIM6)>;
- status = "disabled";
- };
-
- timer7: timer@40001400 {
- compatible = "st,stm32-timer";
- reg = <0x40001400 0x400>;
- interrupts = <55>;
- clocks = <&rcc 0 STM32F7_APB1_CLOCK(TIM7)>;
- status = "disabled";
- };
-
rtc: rtc@40002800 {
compatible = "st,stm32-rtc";
reg = <0x40002800 0x400>;
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 0/4] stm32 clocksource driver rework
[not found] ` <1506959513-16851-1-git-send-email-benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2017-10-09 9:23 ` Benjamin Gaignard
2017-10-09 9:27 ` Daniel Lezcano
0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-09 9:23 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Russell King - ARM Linux,
Maxime Coquelin, Alexandre Torgue, Daniel Lezcano,
Thomas Gleixner, Ludovic Barre
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Linux Kernel Mailing List, Benjamin Gaignard
2017-10-02 17:51 GMT+02:00 Benjamin Gaignard <benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>:
> version 4:
> - split patch in 3 parts
> - convert code to timer_of
> - only use 32 bits timers
> - add clocksource support
Hello Daniel,
Does the patches split sound good for you ?
Regards,
Benjamin
>
> version 3:
> - fix comments done by Daniel
> - use timer_of helper functions
>
> version 2:
> - fix uninitialized variable
>
> These patches implements clocksource and clockevent by using only one hardware block.
> Getting both clock source and events on the same hardware lead to change quite
> a lot driver code.
> It also limits usage of clocksource to 32 bits timers because 16 bits ones
> aren't enough accurate.
> Thanks to timer_fo helpers this series includes minor clean up in structures,
> function prototypes and driver name.
>
> Since 16 bits timers become useless it also removes them from stm32f4 and
> stm32f7 devicetree.
>
> Benjamin Gaignard (4):
> clocksource: stm32: convert driver to timer_of
> clocksource: stm32: only use 32 bits timers
> clocksource: stm32: add clocksource support
> arm: dts: stm32: remove useless clocksource nodes
>
> arch/arm/boot/dts/stm32f429.dtsi | 32 ------
> arch/arm/boot/dts/stm32f746.dtsi | 32 ------
> drivers/clocksource/Kconfig | 1 +
> drivers/clocksource/timer-stm32.c | 229 ++++++++++++++++++--------------------
> 4 files changed, 112 insertions(+), 182 deletions(-)
>
> --
> 2.7.4
>
--
Benjamin Gaignard
Graphic Study Group
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 0/4] stm32 clocksource driver rework
2017-10-09 9:23 ` [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
@ 2017-10-09 9:27 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2017-10-09 9:27 UTC (permalink / raw)
To: Benjamin Gaignard, Rob Herring, Mark Rutland,
Russell King - ARM Linux, Maxime Coquelin, Alexandre Torgue,
Thomas Gleixner, Ludovic Barre
Cc: devicetree, linux-arm-kernel, Linux Kernel Mailing List
On 09/10/2017 11:23, Benjamin Gaignard wrote:
> 2017-10-02 17:51 GMT+02:00 Benjamin Gaignard <benjamin.gaignard@linaro.org>:
>> version 4:
>> - split patch in 3 parts
>> - convert code to timer_of
>> - only use 32 bits timers
>> - add clocksource support
>
> Hello Daniel,
>
> Does the patches split sound good for you ?
Hi Benjamin,
Yes, the split is ok. I will go for the details as soon as I can.
Thanks.
-- Daniel
--
<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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of
2017-10-02 15:51 ` [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of Benjamin Gaignard
@ 2017-10-17 17:09 ` Daniel Lezcano
2017-10-17 17:34 ` Benjamin Gaignard
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Lezcano @ 2017-10-17 17:09 UTC (permalink / raw)
To: Benjamin Gaignard, robh+dt, mark.rutland, linux, mcoquelin.stm32,
alexandre.torgue, tglx, ludovic.barre
Cc: devicetree, linux-arm-kernel, linux-kernel
On 02/10/2017 17:51, Benjamin Gaignard wrote:
> Convert driver to use timer_of helpers. This allow to remove
> custom proprietary structure.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> ---
[ ... ]
> - clockevents_config_and_register(&data->evtdev,
> - DIV_ROUND_CLOSEST(rate, prescaler),
> - 0x1, max_delta);
> -
> - ret = request_irq(irq, stm32_clock_event_handler, IRQF_TIMER,
> - "stm32 clockevent", data);
> - if (ret) {
> - pr_err("%pOF: failed to request irq.\n", np);
> - goto err_get_irq;
> - }
> + clockevents_config_and_register(&to->clkevt,
> + timer_of_period(to), 0x60, max_delta);
Why 0x1 -> 0x60 ?
--
<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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of
2017-10-17 17:09 ` Daniel Lezcano
@ 2017-10-17 17:34 ` Benjamin Gaignard
2017-10-17 17:53 ` Daniel Lezcano
0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gaignard @ 2017-10-17 17:34 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Rob Herring, Mark Rutland, Russell King - ARM Linux,
Maxime Coquelin, Alexandre Torgue, Thomas Gleixner, Ludovic Barre,
devicetree, Linux ARM, Linux Kernel Mailing List
2017-10-17 19:09 GMT+02:00 Daniel Lezcano <daniel.lezcano@linaro.org>:
> On 02/10/2017 17:51, Benjamin Gaignard wrote:
>> Convert driver to use timer_of helpers. This allow to remove
>> custom proprietary structure.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>> ---
>
> [ ... ]
>
>> - clockevents_config_and_register(&data->evtdev,
>> - DIV_ROUND_CLOSEST(rate, prescaler),
>> - 0x1, max_delta);
>> -
>> - ret = request_irq(irq, stm32_clock_event_handler, IRQF_TIMER,
>> - "stm32 clockevent", data);
>> - if (ret) {
>> - pr_err("%pOF: failed to request irq.\n", np);
>> - goto err_get_irq;
>> - }
>> + clockevents_config_and_register(&to->clkevt,
>> + timer_of_period(to), 0x60, max_delta);
>
>
> Why 0x1 -> 0x60 ?
Because if the min delta is too small it could generate too much interrupts
and the system will not be able to catch all of them.
>
> --
> <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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of
2017-10-17 17:34 ` Benjamin Gaignard
@ 2017-10-17 17:53 ` Daniel Lezcano
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2017-10-17 17:53 UTC (permalink / raw)
To: Benjamin Gaignard
Cc: Rob Herring, Mark Rutland, Russell King - ARM Linux,
Maxime Coquelin, Alexandre Torgue, Thomas Gleixner, Ludovic Barre,
devicetree, Linux ARM, Linux Kernel Mailing List
On 17/10/2017 19:34, Benjamin Gaignard wrote:
> 2017-10-17 19:09 GMT+02:00 Daniel Lezcano <daniel.lezcano@linaro.org>:
>> On 02/10/2017 17:51, Benjamin Gaignard wrote:
>>> Convert driver to use timer_of helpers. This allow to remove
>>> custom proprietary structure.
>>>
>>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>>> ---
>>
>> [ ... ]
>>
>>> - clockevents_config_and_register(&data->evtdev,
>>> - DIV_ROUND_CLOSEST(rate, prescaler),
>>> - 0x1, max_delta);
>>> -
>>> - ret = request_irq(irq, stm32_clock_event_handler, IRQF_TIMER,
>>> - "stm32 clockevent", data);
>>> - if (ret) {
>>> - pr_err("%pOF: failed to request irq.\n", np);
>>> - goto err_get_irq;
>>> - }
>>> + clockevents_config_and_register(&to->clkevt,
>>> + timer_of_period(to), 0x60, max_delta);
>>
>>
>> Why 0x1 -> 0x60 ?
>
> Because if the min delta is too small it could generate too much interrupts
> and the system will not be able to catch all of them.
You did a change not related to what is described in the log.
Shame on you! 50 push-ups! Reply to this email when it is done.
--
<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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-10-17 17:53 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02 15:51 [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 1/4] clocksource: stm32: convert driver to timer_of Benjamin Gaignard
2017-10-17 17:09 ` Daniel Lezcano
2017-10-17 17:34 ` Benjamin Gaignard
2017-10-17 17:53 ` Daniel Lezcano
2017-10-02 15:51 ` [PATCH v4 2/4] clocksource: stm32: only use 32 bits timers Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 3/4] clocksource: stm32: add clocksource support Benjamin Gaignard
2017-10-02 15:51 ` [PATCH v4 4/4] arm: dts: stm32: remove useless clocksource nodes Benjamin Gaignard
[not found] ` <1506959513-16851-1-git-send-email-benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-10-09 9:23 ` [PATCH v4 0/4] stm32 clocksource driver rework Benjamin Gaignard
2017-10-09 9:27 ` Daniel Lezcano
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).