Skip to contentSkip to conversation

Update omaps to use drivers/clocksource timers

PATCH Superseded Tony Lindgren 4 participants 25 messages Apr 17, 2020 – May 1, 2020

Subsystems (8)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

cover Update omaps to use drivers/clocksource timers

Hi all,

Here's a series of changes to udpate omaps to use drivers/clocksource timers for the 32k counter and dmtimer and to remove the old legacy platform code. Please review and test.

Daniel, if the the first two patches look OK after review, maybe you can again set up an immutable branch for the first two patches against v5.7-rc1 that I can merge in?

Regards,

Tony

Tony Lindgren (14):
clocksource/drivers/timer-ti-32k: Add support for initializing
directly
clocksource/drivers/timer-ti-dm: Add clockevent and clocksource
support
clk: ti: dm816: enable sysclk6_ck on init
bus: ti-sysc: Ignore timer12 on secure omap3
ARM: OMAP2+: Add omap_init_time_of()
ARM: dts: Configure system timers for am335x
ARM: dts: Configure system timers for am437x
ARM: dts: Configure system timers for omap4
ARM: dts: Configure system timers for omap5 and dra7
ARM: dts: Configure system timers for omap3
ARM: dts: Configure system timers for ti81xx
ARM: dts: Configure system timers for omap2
ARM: OMAP2+: Drop old timer code for dmtimer and 32k counter
bus: ti-sysc: Timers no longer need legacy quirk handling

 .../devicetree/bindings/timer/ti,timer.txt    |   2 +
 arch/arm/boot/dts/am33xx-l4.dtsi              |   2 -
 arch/arm/boot/dts/am33xx.dtsi                 |  12 +
 arch/arm/boot/dts/am3517.dtsi                 |  16 +-
 arch/arm/boot/dts/am4372.dtsi                 |  12 +
 arch/arm/boot/dts/am437x-l4.dtsi              |   3 -
 arch/arm/boot/dts/dm814x.dtsi                 |  66 +-
 arch/arm/boot/dts/dm816x.dtsi                 |  70 ++-
 arch/arm/boot/dts/dra7-l4.dtsi                |   5 -
 arch/arm/boot/dts/dra7.dtsi                   |   6 +
 arch/arm/boot/dts/omap2.dtsi                  |  38 +-
 arch/arm/boot/dts/omap2420.dtsi               |  65 +-
 arch/arm/boot/dts/omap2430.dtsi               |  65 +-
 arch/arm/boot/dts/omap3-beagle.dts            |  16 +
 arch/arm/boot/dts/omap3-devkit8000.dts        |  16 +
 arch/arm/boot/dts/omap3.dtsi                  | 130 +++-
 arch/arm/boot/dts/omap4-l4.dtsi               |   2 -
 arch/arm/boot/dts/omap4.dtsi                  |   6 +
 arch/arm/boot/dts/omap5-l4.dtsi               |   2 -
 arch/arm/boot/dts/omap5.dtsi                  |   6 +
 arch/arm/mach-omap2/Makefile                  |   4 +-
 arch/arm/mach-omap2/board-generic.c           |  32 +-
 arch/arm/mach-omap2/common.h                  |   7 +
 arch/arm/mach-omap2/omap_hwmod_2420_data.c    |  20 -
 arch/arm/mach-omap2/omap_hwmod_2430_data.c    |  19 -
 .../omap_hwmod_2xxx_interconnect_data.c       |   8 -
 .../mach-omap2/omap_hwmod_2xxx_ipblock_data.c |  47 --
 .../omap_hwmod_33xx_43xx_common_data.h        |   2 -
 .../omap_hwmod_33xx_43xx_interconnect_data.c  |   8 -
 .../omap_hwmod_33xx_43xx_ipblock_data.c       |  62 --
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c    |  10 -
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c    | 146 +----
 arch/arm/mach-omap2/omap_hwmod_43xx_data.c    |  45 --
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c    |  90 ---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c    |  89 ---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c     | 176 ------
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c    |  74 ---
 arch/arm/mach-omap2/omap_hwmod_common_data.h  |   3 -
 arch/arm/mach-omap2/timer.c                   | 568 +-----------------
 drivers/bus/ti-sysc.c                         |  25 +-
 drivers/clk/ti/clk-816x.c                     |   1 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-ti-32k.c            |  48 +-
 drivers/clocksource/timer-ti-dm-systimer.c    | 468 +++++++++++++++
 include/clocksource/timer-ti-dm.h             |   1 +
 45 files changed, 1016 insertions(+), 1478 deletions(-)
 create mode 100644 drivers/clocksource/timer-ti-dm-systimer.c
Signature · 1 line
2.26.1
author maintainer
#1 lore raw

PATCH 1/14 clocksource/drivers/timer-ti-32k: Add support for initializing directly

Let's allow probing the 32k counter directly based on devicetree data to prepare for dropping the related legacy platform code. Let's only do this if the parent node is compatible with ti-sysc to make sure we have the related devicetree data available.

Let's also show the 32k counter information before registering the clocksource, now we see it after the clocksource information which is a bit confusing.

Cc Daniel Lezcano <[email protected]>
Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 drivers/clocksource/timer-ti-32k.c | 48 +++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-32k.c +47 -1
@@ -24,6 +24,7 @@
  * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
  */
 
+#include <linux/clk.h>
 #include <linux/init.h>
 #include <linux/time.h>
 #include <linux/sched_clock.h>
@@ -76,6 +77,49 @@ static u64 notrace omap_32k_read_sched_clock(void)
 	return ti_32k_read_cycles(&ti_32k_timer.cs);
 }
 
+static void __init ti_32k_timer_enable_clock(struct device_node *np,
+					     const char *name)
+{
+	struct clk *clock;
+	int error;
+
+	clock = of_clk_get_by_name(np->parent, name);
+	if (IS_ERR(clock)) {
+		/* Only some SoCs have a separate interface clock */
+		if (PTR_ERR(clock) == -EINVAL && !strncmp("ick", name, 3))
+			return;
+
+		pr_warn("%s: could not get clock %s %li\n",
+			__func__, name, PTR_ERR(clock));
+		return;
+	}
+
+	error = clk_prepare_enable(clock);
+	if (error) {
+		pr_warn("%s: could not enable %s: %i\n",
+			__func__, name, error);
+		return;
+	}
+}
+
+static void __init ti_32k_timer_module_init(struct device_node *np,
+					    void __iomem *base)
+{
+	void __iomem *sysc = base + 4;
+
+	if (!of_device_is_compatible(np->parent, "ti,sysc"))
+		return;
+
+	ti_32k_timer_enable_clock(np, "fck");
+	ti_32k_timer_enable_clock(np, "ick");
+
+	/*
+	 * Force idle module as wkup domain is active with MPU.
+	 * No need to tag the module disabled for ti-sysc probe.
+	 */
+	writel_relaxed(0, sysc);
+}
+
 static int __init ti_32k_timer_init(struct device_node *np)
 {
 	int ret;
@@ -90,6 +134,7 @@ static int __init ti_32k_timer_init(struct device_node *np)
 		ti_32k_timer.cs.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
 
 	ti_32k_timer.counter = ti_32k_timer.base;
+	ti_32k_timer_module_init(np, ti_32k_timer.base);
 
 	/*
 	 * 32k sync Counter IP register offsets vary between the highlander
@@ -104,6 +149,8 @@ static int __init ti_32k_timer_init(struct device_node *np)
 	else
 		ti_32k_timer.counter += OMAP2_32KSYNCNT_CR_OFF_LOW;
 
+	pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n");
+
 	ret = clocksource_register_hz(&ti_32k_timer.cs, 32768);
 	if (ret) {
 		pr_err("32k_counter: can't register clocksource\n");
@@ -111,7 +158,6 @@ static int __init ti_32k_timer_init(struct device_node *np)
 	}
 
 	sched_clock_register(omap_32k_read_sched_clock, 32, 32768);
-	pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n");
 
 	return 0;
 }
Signature · 1 line
2.26.1
author maintainer
#2 lore raw

PATCH 2/14 clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

In reply to Tony Lindgren

We can move the TI dmtimer clockevent and clocksource to live under drivers/clocksource if we rely only on the clock framework, and handle the module configuration directly in the clocksource driver.

This removes the early dependency with system timers to the interconnect related code, and we can probe pretty much everything else later on at the module_init level.

Let's first add a new driver for timer-ti-dm-systimer based on existing arch/arm/mach-omap2/timer.c. Then let's start moving SoCs to probe with device tree data while still keeping the old timer.c. And eventually we can just drop the old timer.c.

Note the boards can optionally configure the timer source clock in using assigned-clock-parents.

Cc Daniel Lezcano <[email protected]>
Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 .../devicetree/bindings/timer/ti,timer.txt    |   2 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-ti-dm-systimer.c    | 468 ++++++++++++++++++
 include/clocksource/timer-ti-dm.h             |   1 +
 4 files changed, 472 insertions(+)
 create mode 100644 drivers/clocksource/timer-ti-dm-systimer.c
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)
 
 - reg:			Contains timer register address range (base address and
 			length).
drivers/clocksource/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
 obj-$(CONFIG_DAVINCI_TIMER)	+= timer-davinci.o
 obj-$(CONFIG_DIGICOLOR_TIMER)	+= timer-digicolor.o
 obj-$(CONFIG_OMAP_DM_TIMER)	+= timer-ti-dm.o
+obj-$(CONFIG_OMAP_DM_TIMER)	+= timer-ti-dm-systimer.o
 obj-$(CONFIG_DW_APB_TIMER)	+= dw_apb_timer.o
 obj-$(CONFIG_DW_APB_TIMER_OF)	+= dw_apb_timer_of.o
 obj-$(CONFIG_FTTMR010_TIMER)	+= timer-fttmr010.o
drivers/clocksource/timer-ti-dm-systimer.c new file +468 -0

468 lines not on this page · raw message

include/clocksource/timer-ti-dm.h +1 -0
@@ -97,6 +97,7 @@ struct omap_dm_timer {
 	int id;
 	int irq;
 	struct clk *fclk;
+	struct clk *iclk;
 
 	void __iomem	*io_base;
 	void __iomem	*irq_stat;	/* TISR/IRQSTATUS interrupt status */
Signature · 1 line
2.26.1
#3 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Hi Tony,

Quoted 36 lines · Tony Lindgren

We can move the TI dmtimer clockevent and clocksource to live under drivers/clocksource if we rely only on the clock framework, and handle the module configuration directly in the clocksource driver.

This removes the early dependency with system timers to the interconnect related code, and we can probe pretty much everything else later on at the module_init level.

Let's first add a new driver for timer-ti-dm-systimer based on existing arch/arm/mach-omap2/timer.c. Then let's start moving SoCs to probe with device tree data while still keeping the old timer.c. And eventually we can just drop the old timer.c.

Note the boards can optionally configure the timer source clock in using assigned-clock-parents.

Cc Daniel Lezcano <[email protected]>
Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 .../devicetree/bindings/timer/ti,timer.txt    |   2 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-ti-dm-systimer.c    | 468 ++++++++++++++++++
 include/clocksource/timer-ti-dm.h             |   1 +
 4 files changed, 472 insertions(+)
 create mode 100644 drivers/clocksource/timer-ti-dm-systimer.c

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 5 lines
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Quoted 41 lines
Documentation/devicetree/bindings/timer/ti,timer.txt +0 -0
 - reg:			Contains timer register address range (base address and
 			length).
drivers/clocksource/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
 obj-$(CONFIG_DAVINCI_TIMER)	+= timer-davinci.o
 obj-$(CONFIG_DIGICOLOR_TIMER)	+= timer-digicolor.o
 obj-$(CONFIG_OMAP_DM_TIMER)	+= timer-ti-dm.o
+obj-$(CONFIG_OMAP_DM_TIMER)	+= timer-ti-dm-systimer.o
 obj-$(CONFIG_DW_APB_TIMER)	+= dw_apb_timer.o
 obj-$(CONFIG_DW_APB_TIMER_OF)	+= dw_apb_timer_of.o
 obj-$(CONFIG_FTTMR010_TIMER)	+= timer-fttmr010.o
drivers/clocksource/timer-ti-dm-systimer.c new file +23 -0
new file mode 100644
@@ -0,0 +1,468 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include <linux/clk.h>
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/sched_clock.h>
+
+#include <linux/clk/clk-conf.h>
+
+#include <clocksource/timer-ti-dm.h>
+#include <dt-bindings/bus/ti-sysc.h>
+
+/* For type1, set SYSC_OMAP2_CLOCKACTIVITY for fck off on idle, l4 clock on */
+#define DMTIMER_TYPE1_ENABLE	((1 << 9) | (SYSC_IDLE_SMART << 3) | \
+				 SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_AUTOIDLE)
+
+#define DMTIMER_TYPE2_ENABLE	(SYSC_IDLE_SMART_WKUP << 2)

drivers/clocksource/timer-ti-dm-systimer.c line 33

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+#define DMTIMER_RESET_WAIT	100000
+
+struct dmtimer_clockevent {
+	struct clock_event_device dev;
+	struct omap_dm_timer timer;
+};
+
+struct dmtimer_clocksource {
+	struct clocksource dev;
+	struct omap_dm_timer timer;

The usage of the timer field is to use the __omap_dm_timer_* helpers function which does a busy looping on the status before read/write the register. AFAICS, for the clocksource, the posted argument is zero, thus it is possible to replace the calls to these helpers to a write / read and perhaps the struct omap_dm_timer could be removed from the clocksource structure.

The driver gets obfuscated by calls to helpers which does 'posted' things.

Why not remove those and handle the case in the driver to make it self-encapsuled and remove the omap_dm_timer structure usage in this driver.

drivers/clocksource/timer-ti-dm-systimer.c line 43

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+	unsigned int loadval;
+};
+
+static int dmtimer_systimer_type1_reset(struct omap_dm_timer *timer)
+{
+	void __iomem *syss = timer->io_base + OMAP_TIMER_V1_SYS_STAT_OFFSET;
+	int ret;
+	u32 l;
+
+	__omap_dm_timer_write(timer, OMAP_TIMER_IF_CTRL_REG, 0x06, 0);

As the last argument is zero, may be take the opportunity to do a direct call to writel?

drivers/clocksource/timer-ti-dm-systimer.c line 55

Quoted 12 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +12 -0
+	ret = readl_poll_timeout_atomic(syss, l, l & BIT(0), 100,
+					DMTIMER_RESET_WAIT);
+
+	return ret;
+}
+
+/* Note we must use io_base instead of func_base for type2 OCP regs */
+static int dmtimer_systimer_type2_reset(struct omap_dm_timer *timer)
+{
+	void __iomem *sysc = timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET;
+	u32 l;
+

Isn't missing a write here ?

Quoted 15 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +15 -0
+	return readl_poll_timeout_atomic(sysc, l, !(l & BIT(0)), 100,
+					 DMTIMER_RESET_WAIT);
+}
+
+static int dmtimer_systimer_reset(struct omap_dm_timer *timer)
+{
+	int ret;
+
+	if (timer->revision == 1)
+		ret = dmtimer_systimer_type1_reset(timer);
+	else
+		ret = dmtimer_systimer_type2_reset(timer);
+	if (ret < 0) {
+		pr_err("%s failed with %i\n", __func__, ret);
+

drivers/clocksource/timer-ti-dm-systimer.c line 80

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+		return ret;
+	}
+
+	timer->posted = 0;
+
+	return 0;
+}
+
+/* Interface clocks are only available on some SoCs variants */
+static int __init dmtimer_systimer_init_clock(struct omap_dm_timer *timer,

The timer argument is not used

Quoted 45 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +45 -0
+					      struct device_node *np,
+					      struct clk **clk,
+					      const char *name)
+{
+	struct clk *clock;
+	int error;
+
+	clock = of_clk_get_by_name(np, name);
+	if ((PTR_ERR(clock) == -EINVAL) && !strncmp(name, "ick", 3))
+		return 0;
+	else if (IS_ERR(clock))
+		return PTR_ERR(clock);
+
+	error = clk_prepare_enable(clock);
+	if (error)
+		return error;
+
+	*clk = clock;
+
+	return 0;
+}
+
+static void dmtimer_systimer_enable(struct omap_dm_timer *timer)
+{
+	void __iomem *sysc = timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET;
+	u32 val;
+
+	if (timer->revision == 1)
+		val = DMTIMER_TYPE1_ENABLE;
+	else
+		val = DMTIMER_TYPE2_ENABLE;
+
+	writel_relaxed(val, sysc);
+}
+
+static void dmtimer_systimer_disable(struct omap_dm_timer *timer)
+{
+	void __iomem *sysc = timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET;
+
+	writel_relaxed(0, sysc);
+}
+
+static int __init dmtimer_systimer_tag_disabled(struct device_node *np)
+{
+	struct property *prop;

drivers/clocksource/timer-ti-dm-systimer.c line 135

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+
+	prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+	if (!prop)
+		return -ENOMEM;
+
+	prop->name = "status";
+	prop->value = "disabled";
+	prop->length = strlen(prop->value);
+
+	return of_add_property(np, prop);

Why not add this property in the DT instead ? That sounds hackish

Quoted 16 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +16 -0
+}
+
+static int __init dmtimer_systimer_init(struct omap_dm_timer *timer,
+					struct device_node *np)
+{
+	int error;
+
+	if (!of_device_is_compatible(np->parent, "ti,sysc"))
+		return -EINVAL;
+
+	/*
+	 * Enable optional assigned-clock-parents configured at the timer
+	 * node level. For regular device drivers, this is done automatically
+	 * by bus related code such as platform_drv_probe().
+	 */
+	error = of_clk_set_defaults(np, false);

drivers/clocksource/timer-ti-dm-systimer.c line 161

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+	if (error < 0)
+		pr_err("%s: clock source init failed: %i\n", __func__, error);
+
+	/* For ti-sysc, we have timer clocks at the parent module level */
+	error = dmtimer_systimer_init_clock(timer, np->parent,
+					    &timer->fclk, "fck");
+	if (error)
+		return error;
+
+	timer->rate = clk_get_rate(timer->fclk);

check rate == 0 for error ?

drivers/clocksource/timer-ti-dm-systimer.c line 168

Quoted 7 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +7 -0
+
+	error = dmtimer_systimer_init_clock(timer, np->parent,
+					    &timer->iclk, "ick");
+	if (error)
+		return error;
+
+	__omap_dm_timer_init_regs(timer);

readl_relaxed(timer->io_base) to get the revision ? And then get rid of all the helpers thing ?

drivers/clocksource/timer-ti-dm-systimer.c line 175

Quoted 7 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +7 -0
+	dmtimer_systimer_enable(timer);
+	dmtimer_systimer_reset(timer);
+	pr_debug("dmtimer rev %08x sysc %08x\n", readl_relaxed(timer->io_base),
+		 readl_relaxed(timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET));
+
+	if (of_find_property(np, "ti,timer-alwon", NULL))
+		timer->capability |= OMAP_TIMER_ALWON;

Where is used this capability in this driver ?

Quoted 19 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +19 -0
+	/* Tag parent interconnect target module disabled for ti-sysc */
+	error = dmtimer_systimer_tag_disabled(np->parent);
+	if (error)
+		pr_err("%s: failed to set %pOF disabled: %i\n",
+		       __func__, np, error);
+
+	return 0;
+}
+
+/* Clockevent */
+static struct dmtimer_clockevent *
+to_dmtimer_clockevent(struct clock_event_device *clockevent)
+{
+	return container_of(clockevent, struct dmtimer_clockevent, dev);
+}
+
+static struct omap_dm_timer *
+clockevent_to_dm_timer(struct clock_event_device *evt)
+{

drivers/clocksource/timer-ti-dm-systimer.c line 205

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+	struct dmtimer_clockevent *dmtce = to_dmtimer_clockevent(evt);
+
+	return &dmtce->timer;
+}
+
+static irqreturn_t dmtimer_clockevent_interrupt(int irq, void *data)
+{
+	struct dmtimer_clockevent *dmtce = data;
+
+	__omap_dm_timer_write_status(&dmtce->timer, OMAP_TIMER_INT_OVERFLOW);

Please replace with a writel()

drivers/clocksource/timer-ti-dm-systimer.c line 213

Quoted 8 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +8 -0
+	dmtce->dev.event_handler(&dmtce->dev);
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction dmtimer_clockevent_irq = {
+	.name		= "gp_timer",
+	.flags		= IRQF_TIMER | IRQF_IRQPOLL,

Why do you need IRQF_IRQPOLL ?

Quoted 22 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +22 -0
+	.handler	= dmtimer_clockevent_interrupt,
+};
+
+static int dmtimer_set_next_event(unsigned long cycles,
+				  struct clock_event_device *evt)
+{
+	struct omap_dm_timer *timer = clockevent_to_dm_timer(evt);
+
+	__omap_dm_timer_load_start(timer, OMAP_TIMER_CTRL_ST,
+				   0xffffffff - cycles, OMAP_TIMER_POSTED);
+
+	return 0;
+}
+
+static int dmtimer_clockevent_shutdown(struct clock_event_device *evt)
+{
+	struct omap_dm_timer *timer = clockevent_to_dm_timer(evt);
+
+	__omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate);
+
+	return 0;
+}

drivers/clocksource/timer-ti-dm-systimer.c line 245

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+
+static int dmtimer_set_periodic(struct clock_event_device *evt)
+{
+	struct omap_dm_timer *timer = clockevent_to_dm_timer(evt);
+	u32 period;
+
+	__omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate);
+
+	period = timer->rate / HZ;
+	period -= 1;

DIV_ROUND_CLOSEST(rate, HZ); ?

Quoted 23 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +23 -0
+	/* Looks like we need to first set the load value separately */
+	__omap_dm_timer_write(timer, OMAP_TIMER_LOAD_REG, 0xffffffff - period,
+			      OMAP_TIMER_POSTED);
+	__omap_dm_timer_load_start(timer,
+				   OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST,
+				   0xffffffff - period, OMAP_TIMER_POSTED);
+	return 0;
+}
+
+static void omap_clockevent_idle(struct clock_event_device *evt)
+{
+	struct omap_dm_timer *timer = clockevent_to_dm_timer(evt);
+
+	dmtimer_systimer_disable(timer);
+}
+
+static void omap_clockevent_unidle(struct clock_event_device *evt)
+{
+	struct omap_dm_timer *timer = clockevent_to_dm_timer(evt);
+
+	dmtimer_systimer_enable(timer);
+	__omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW);
+}

drivers/clocksource/timer-ti-dm-systimer.c line 278

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+
+static int __init dmtimer_clockevent_init(struct device_node *np)
+{
+	struct dmtimer_clockevent *clkevt;
+	struct clock_event_device *evt;
+	struct omap_dm_timer *timer;
+	int error;
+	u32 pa;
+
+	clkevt = kzalloc(sizeof(*clkevt), GFP_KERNEL | __GFP_NOFAIL);

Remove __GFP_NOFAIL

Quoted 5 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +5 -0
+	if (!clkevt)
+		return -ENOMEM;
+
+	timer = &clkevt->timer;
+	evt = &clkevt->dev;

drivers/clocksource/timer-ti-dm-systimer.c line 293

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+
+	evt->features = CLOCK_EVT_FEAT_PERIODIC |
+			CLOCK_EVT_FEAT_ONESHOT;
+	evt->rating = 300;
+	evt->set_next_event = dmtimer_set_next_event;
+	evt->set_state_shutdown = dmtimer_clockevent_shutdown;
+	evt->set_state_periodic = dmtimer_set_periodic;
+	evt->set_state_oneshot = dmtimer_clockevent_shutdown;
+	evt->tick_resume = dmtimer_clockevent_shutdown;
+	evt->cpumask = cpu_possible_mask;

You may consider the CLOCK_EVT_FEAT_DYNIRQ flag

Quoted 14 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +14 -0
+	evt->irq = timer->irq;
+
+	timer->irq = irq_of_parse_and_map(np, 0);
+	if (!timer->irq) {
+		error = -ENXIO;
+		goto err_out_free;
+	}
+
+	timer->io_base = of_iomap(np, 0);
+	if (!timer->io_base) {
+		error = -ENXIO;
+		goto err_out_free;
+	}
+

drivers/clocksource/timer-ti-dm-systimer.c line 317

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+	error = dmtimer_systimer_init(timer, np);
+	if (error)
+		goto err_out_unmap;
+
+	/*
+	 * For clock-event timers we never read the timer counter and
+	 * so we are not impacted by errata i103 and i767. Therefore,
+	 * we can safely ignore this errata for clock-event timers.
+	 */
+	__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);

Without all these omap_... helpers you would not have to set this

drivers/clocksource/timer-ti-dm-systimer.c line 320

Quoted 2 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +2 -0
+	dmtimer_clockevent_irq.dev_id = clkevt;
+	setup_irq(timer->irq, &dmtimer_clockevent_irq);

request_irq

drivers/clocksource/timer-ti-dm-systimer.c line 327

Quoted 6 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +6 -0
+	__omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW);
+
+	pa = of_translate_address(np, of_get_address(np, 0, NULL, NULL));
+	pr_info("TI gptimer clockevent: %stimer@%08x at %lu Hz\n",
+		timer->capability & OMAP_TIMER_ALWON ? "always-on " : "",
+		pa, timer->rate);

%pOF instead of of_translate_address ?

Quoted 104 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +104 -0
+	clockevents_config_and_register(evt, timer->rate,
+					3, /* Timer internal resynch latency */
+					0xffffffff);
+
+	if (of_device_is_compatible(np, "ti,am33xx") ||
+	    of_device_is_compatible(np, "ti,am43")) {
+		evt->suspend = omap_clockevent_idle;
+		evt->resume = omap_clockevent_unidle;
+	}
+
+	return 0;
+
+err_out_unmap:
+	iounmap(timer->io_base);
+err_out_free:
+	kfree(clkevt);
+
+	return error;
+}
+
+/* Clocksource */
+static struct dmtimer_clocksource *
+to_dmtimer_clocksource(struct clocksource *cs)
+{
+	return container_of(cs, struct dmtimer_clocksource, dev);
+}
+
+static struct omap_dm_timer *
+clocksource_to_dmtimer(struct clocksource *cs)
+{
+	struct dmtimer_clocksource *clksrc = to_dmtimer_clocksource(cs);
+
+	return &clksrc->timer;
+}
+
+static u64 dmtimer_clocksource_read_cycles(struct clocksource *cs)
+{
+	struct omap_dm_timer *timer = clocksource_to_dmtimer(cs);
+
+	return (u64)__omap_dm_timer_read_counter(timer,
+						 OMAP_TIMER_NONPOSTED);
+}
+
+static void __iomem *dmtimer_sched_clock_counter;
+
+static u64 notrace dmtimer_read_sched_clock(void)
+{
+	return readl_relaxed(dmtimer_sched_clock_counter);
+}
+
+static void dmtimer_clocksource_suspend(struct clocksource *cs)
+{
+	struct dmtimer_clocksource *clksrc = to_dmtimer_clocksource(cs);
+	struct omap_dm_timer *timer = &clksrc->timer;
+
+	clksrc->loadval =
+		__omap_dm_timer_read_counter(timer, OMAP_TIMER_NONPOSTED);
+	dmtimer_systimer_disable(timer);
+}
+
+static void dmtimer_clocksource_resume(struct clocksource *cs)
+{
+	struct dmtimer_clocksource *clksrc = to_dmtimer_clocksource(cs);
+	struct omap_dm_timer *timer = &clksrc->timer;
+
+	dmtimer_systimer_enable(timer);
+	__omap_dm_timer_load_start(timer,
+				   OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR,
+				   clksrc->loadval,
+				   OMAP_TIMER_NONPOSTED);
+}
+
+static int __init dmtimer_clocksource_init(struct device_node *np)
+{
+	struct dmtimer_clocksource *clksrc;
+	struct omap_dm_timer *timer;
+	struct clocksource *dev;
+	int error;
+	u32 pa;
+
+	clksrc = kzalloc(sizeof(*clksrc), GFP_KERNEL | __GFP_NOFAIL);
+	if (!clksrc)
+		return -ENOMEM;
+
+	timer = &clksrc->timer;
+	dev = &clksrc->dev;
+
+	timer->io_base = of_iomap(np, 0);
+	if (!timer->io_base) {
+		pr_err("%s: could not iomap\n", __func__);
+		return -ENODEV;
+	}
+
+	error = dmtimer_systimer_init(timer, np);
+	if (error)
+		goto err_out_unmap;
+
+	dev->name = "dmtimer";
+	dev->rating = 300;
+	dev->read = dmtimer_clocksource_read_cycles;
+	dev->mask = CLOCKSOURCE_MASK(32);
+	dev->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+
+	if (of_device_is_compatible(np, "ti,am33xx") ||

drivers/clocksource/timer-ti-dm-systimer.c line 443

Quoted 10 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +10 -0
+	    of_device_is_compatible(np, "ti,am43")) {
+		dev->suspend = dmtimer_clocksource_suspend;
+		dev->resume = dmtimer_clocksource_resume;
+	}
+	__omap_dm_timer_load_start(timer,
+				   OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0,
+				   OMAP_TIMER_NONPOSTED);
+
+	pa = of_translate_address(np, of_get_address(np, 0, NULL, NULL));
+	pr_info("TI gptimer clocksource: %stimer@%08x %lu at Hz\n",

%pOF instead of of_translate_address ?

Quoted 29 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +25 -0
+		timer->capability & OMAP_TIMER_ALWON ?
+		"always-on " : "", pa, timer->rate);
+
+	if (!dmtimer_sched_clock_counter) {
+		/* Mask out write pending bits for raw OMAP_TIMER_COUNTER_REG */
+		dmtimer_sched_clock_counter =
+			timer->func_base + (OMAP_TIMER_COUNTER_REG & 0xff);
+		sched_clock_register(dmtimer_read_sched_clock, 32, timer->rate);
+	}
+
+	if (clocksource_register_hz(dev, timer->rate))
+		pr_err("Could not register clocksource %pOF\n", np);
+
+	return 0;
+
+err_out_unmap:
+	iounmap(timer->io_base);
+
+	return -ENODEV;
+}
+
+TIMER_OF_DECLARE(dmtimer_clockevent, "ti,dmtimer-clockevent",
+		 dmtimer_clockevent_init);
+TIMER_OF_DECLARE(dmtimer_clocksource, "ti,dmtimer-clocksource",
+		 dmtimer_clocksource_init);

include/clocksource/timer-ti-dm.h struct omap_dm_timer { · line 100

Quoted 4 lines
include/clocksource/timer-ti-dm.h +1 -0
@@ -97,6 +97,7 @@ struct omap_dm_timer {
 	int id;
 	int irq;
 	struct clk *fclk;
+	struct clk *iclk;

No need of these clocks in the structure as they are used only to initialize.

Quoted 3 lines
include/clocksource/timer-ti-dm.h +0 -0
 	void __iomem	*io_base;
 	void __iomem	*irq_stat;	/* TISR/IRQSTATUS interrupt status */
 
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
author maintainer
#4 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

Or do we already have something similar that can be used?

Quoted 15 lines

drivers/clocksource/timer-ti-dm-systimer.c line 33

Quoted 7 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +3 -0
new file mode 100644
+struct dmtimer_clocksource {
+	struct clocksource dev;
+	struct omap_dm_timer timer;

The usage of the timer field is to use the __omap_dm_timer_* helpers function which does a busy looping on the status before read/write the register. AFAICS, for the clocksource, the posted argument is zero, thus it is possible to replace the calls to these helpers to a write / read and perhaps the struct omap_dm_timer could be removed from the clocksource structure.

Quoted 4 lines

The driver gets obfuscated by calls to helpers which does 'posted' things.

Why not remove those and handle the case in the driver to make it self-encapsuled and remove the omap_dm_timer structure usage in this driver.

Hmm that's a good comment indeed. If we can just use readl/writel for clockevent and clocksource driver without worrying about the posted mode flags, we can make all the old helpers static for the generic dmtimer driver. I'll take a look.

Quoted 7 lines

drivers/clocksource/timer-ti-dm-systimer.c line 55

Quoted 5 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +5 -0
+static int dmtimer_systimer_type2_reset(struct omap_dm_timer *timer)
+{
+	void __iomem *sysc = timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET;
+	u32 l;
+

Isn't missing a write here ?

Oops thanks for spotting it. Without that the mode can be whatever left over from the bootloader.

Quoted 7 lines
Quoted 7 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +7 -0
+static int __init dmtimer_systimer_tag_disabled(struct device_node *np)
+{
+	struct property *prop;
+
+	prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+	if (!prop)
+		return -ENOMEM;
Quoted 8 lines

drivers/clocksource/timer-ti-dm-systimer.c line 135

Quoted 6 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +6 -0
+
+	prop->name = "status";
+	prop->value = "disabled";
+	prop->length = strlen(prop->value);
+
+	return of_add_property(np, prop);

Why not add this property in the DT instead ? That sounds hackish

Yes that's a good point too. We need to configure the source clock anyways for the clocksource and clockevent in devicetree anyways, so setting it disabled there totally makes sense.

Quoted 9 lines

drivers/clocksource/timer-ti-dm-systimer.c line 175

Quoted 7 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +7 -0
+	dmtimer_systimer_enable(timer);
+	dmtimer_systimer_reset(timer);
+	pr_debug("dmtimer rev %08x sysc %08x\n", readl_relaxed(timer->io_base),
+		 readl_relaxed(timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET));
+
+	if (of_find_property(np, "ti,timer-alwon", NULL))
+		timer->capability |= OMAP_TIMER_ALWON;

Where is used this capability in this driver ?

That is just something we should show in dmesg for info as that helps to understand the board specific system timer configuration for PM related issues folks end up reporting.

Quoted 5 lines

drivers/clocksource/timer-ti-dm-systimer.c line 213

Quoted 3 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +3 -0
+static struct irqaction dmtimer_clockevent_irq = {
+	.name		= "gp_timer",
+	.flags		= IRQF_TIMER | IRQF_IRQPOLL,

Why do you need IRQF_IRQPOLL ?

I'll check if that's needed. Probably just something that has mutated into the old timer code somehow.

Quoted 6 lines

drivers/clocksource/timer-ti-dm-systimer.c line 327

Quoted 4 lines
drivers/clocksource/timer-ti-dm-systimer.c new file +4 -0
+	pa = of_translate_address(np, of_get_address(np, 0, NULL, NULL));
+	pr_info("TI gptimer clockevent: %stimer@%08x at %lu Hz\n",
+		timer->capability & OMAP_TIMER_ALWON ? "always-on " : "",
+		pa, timer->rate);

%pOF instead of of_translate_address ?

That just 0 from the interconnect target module here. But doing %pOF on the np->parent should work here and for the clocksource.

Quoted 11 lines

include/clocksource/timer-ti-dm.h struct omap_dm_timer { · line 100

Quoted 8 lines
include/clocksource/timer-ti-dm.h +1 -0
@@ -97,6 +97,7 @@ struct omap_dm_timer {
 	int id;
 	int irq;
 	struct clk *fclk;
+	struct clk *iclk;

No need of these clocks in the structure as they are used only to initialize.

OK I'll make them local.

Thanks for the review! I'll fix up the other issues you spotted too, they all seem good comments.

Regards,

Tony

#5 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 23 lines · Tony Lindgren

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Quoted 7 lines

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

I think that will be the same problem :/

Is it possible to check the interrupt for the clockevent ? A timer node with the interrrupt is the clockevent, without it is a clocksource.

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
author maintainer
#6 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 27 lines · Daniel Lezcano
Quoted 26 lines · Tony Lindgren

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Quoted 6 lines
Quoted 4 lines

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

I think that will be the same problem :/

Seems like other SoCs have the same issue too with multiple timers to configure.

Quoted 2 lines

Is it possible to check the interrupt for the clockevent ? A timer node with the interrrupt is the clockevent, without it is a clocksource.

OK let's try that. So the configuration would become then:

compatible = "ti,dmtimer; /* reserved for system timers */
/delete-property/interrupts; /* ok so it's a clocksource */
/delete-property/interrupts-extended;

Regards,

Tony

maintainer
#7 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 38 lines · Tony Lindgren
Quoted 27 lines · Daniel Lezcano
Quoted 26 lines · Tony Lindgren

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Quoted 6 lines
Quoted 4 lines

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

I think that will be the same problem :/

Seems like other SoCs have the same issue too with multiple timers to configure.

Quoted 8 lines
Quoted 2 lines

Is it possible to check the interrupt for the clockevent ? A timer node with the interrrupt is the clockevent, without it is a clocksource.

OK let's try that. So the configuration would become then:

compatible = "ti,dmtimer; /* reserved for system timers */
/delete-property/interrupts; /* ok so it's a clocksource */
/delete-property/interrupts-extended;

That's not really what was meant.

Let's say you have N timers. Either every timer is exactly the same and the OS can just assign them however it wants or there is some difference in the h/w making certain timer better for certain functions. Describe that difference. It could be clock rate, number of counter bits, always on, secure mode access only, has or doesn't have output compare or input capture, etc.

Rob

author maintainer
#8 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 42 lines · Rob Herring
Quoted 41 lines · Tony Lindgren
Quoted 27 lines · Daniel Lezcano
Quoted 26 lines · Tony Lindgren

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 			ti,omap5430-timer (applicable to OMAP543x devices)
 			ti,am335x-timer	(applicable to AM335x devices)
 			ti,am335x-timer-1ms (applicable to AM335x devices)
+			ti,dmtimer-clockevent (when used as for clockevent)
+			ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Quoted 6 lines
Quoted 4 lines

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

I think that will be the same problem :/

Seems like other SoCs have the same issue too with multiple timers to configure.

Quoted 2 lines

Is it possible to check the interrupt for the clockevent ? A timer node with the interrrupt is the clockevent, without it is a clocksource.

Quoted 7 lines
Quoted 5 lines

OK let's try that. So the configuration would become then:

compatible = "ti,dmtimer; /* reserved for system timers */
/delete-property/interrupts; /* ok so it's a clocksource */
/delete-property/interrupts-extended;

That's not really what was meant.

OK, so let's figure out something better then.

Quoted 6 lines

Let's say you have N timers. Either every timer is exactly the same and the OS can just assign them however it wants or there is some difference in the h/w making certain timer better for certain functions. Describe that difference. It could be clock rate, number of counter bits, always on, secure mode access only, has or doesn't have output compare or input capture, etc.

Hmm. Trying to detect this automatically will get messy. For example, we have few omap3 boards with the following options that also need to consider if the separate 32KiHz counter is available:

1. The best case scenario

ti,omap-counter32k clocksource ti,sysc-omap2-timer ti,timer-alwon clockevent (timer1)

2. Boards relying on internal clock with unusable 32k counter

ti,sysc-omap2-timer ti,timer-alwon clocksource (timer12) ti,sysc-omap2-timer clockevent (typically gpt2)

In the second case, the 32k counter is unusable, and timer1 is unusable with the external 32k always on clock. But timer1 can be used with the system clock just fine for other purposes. So ideally we would not tag timer1 as disabled :)

For the second case, we could remove ti,timer-alwon property for timer1, and tag the 32k counter as disabled as the source clock is unreliable. Then somewhere in the code we would need to check if ti,omap-counter32k is availabe, then check if timer1 is always-on, then use timer12 if not a secure device like n900.

If the board wants to use the system clock as the source for a higher resolution with assigned-clock-parents, then we'd need to ignore the always-on property and not use the 32k counter as the clocksource. Basically to somehow figure out that a higher resolution configuration is preferred over a low-power configuration.

So what's your take on just adding the generic properties for assigned-system-clocksource and clockevent?

Regards,

Tony

maintainer
#9 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 72 lines · Tony Lindgren
Quoted 42 lines · Rob Herring
Quoted 41 lines · Tony Lindgren
Quoted 27 lines · Daniel Lezcano
Quoted 26 lines · Tony Lindgren

Hi,

Quoted 12 lines · Daniel Lezcano

Documentation/devicetree/bindings/timer/ti,timer.txt Required properties: · line 18

Quoted 8 lines · Tony Lindgren
Documentation/devicetree/bindings/timer/ti,timer.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
                      ti,omap5430-timer (applicable to OMAP543x devices)
                      ti,am335x-timer (applicable to AM335x devices)
                      ti,am335x-timer-1ms (applicable to AM335x devices)
+                     ti,dmtimer-clockevent (when used as for clockevent)
+                     ti,dmtimer-clocksource (when used as for clocksource)

Please, submit a separate patch for this.

Quoted 7 lines

Before you resend as is, this will be nacked as clocksource / clockevent is not a hardware description but a Linux thing.

Finding a way to characterize that from the DT is an endless discussion since years, so I suggest to use a single property for the timer eg <ti,dmtimer> and initialize the clocksource and the clockevent in the driver.

Hmm good point. We still need to specify which timer is a clocksource and which one a clockevent somehow.

Quoted 6 lines
Quoted 4 lines

Maybe we could have a generic properties like the clock framework such as:

assigned-system-clocksource
assigned-system-clockevent

I think that will be the same problem :/

Seems like other SoCs have the same issue too with multiple timers to configure.

Quoted 2 lines

Is it possible to check the interrupt for the clockevent ? A timer node with the interrrupt is the clockevent, without it is a clocksource.

Quoted 7 lines
Quoted 5 lines

OK let's try that. So the configuration would become then:

compatible = "ti,dmtimer; /* reserved for system timers */
/delete-property/interrupts; /* ok so it's a clocksource */
/delete-property/interrupts-extended;

That's not really what was meant.

OK, so let's figure out something better then.

Quoted 6 lines

Let's say you have N timers. Either every timer is exactly the same and the OS can just assign them however it wants or there is some difference in the h/w making certain timer better for certain functions. Describe that difference. It could be clock rate, number of counter bits, always on, secure mode access only, has or doesn't have output compare or input capture, etc.

Hmm. Trying to detect this automatically will get messy. For example, we have few omap3 boards with the following options that also need to consider if the separate 32KiHz counter is available:

1. The best case scenario

ti,omap-counter32k clocksource ti,sysc-omap2-timer ti,timer-alwon clockevent (timer1)

2. Boards relying on internal clock with unusable 32k counter

Quoted 7 lines

ti,sysc-omap2-timer ti,timer-alwon clocksource (timer12) ti,sysc-omap2-timer clockevent (typically gpt2)

In the second case, the 32k counter is unusable, and timer1 is unusable with the external 32k always on clock. But timer1 can be used with the system clock just fine for other purposes. So ideally we would not tag timer1 as disabled :)

I'm perfectly fine with a 'broken 32k clk' type property.

Though I think the compatibility story is not good changing DT for stuff needed to boot and needed early in boot. It's one thing to break something not required to get a system booted.

Quoted 6 lines

For the second case, we could remove ti,timer-alwon property for timer1, and tag the 32k counter as disabled as the source clock is unreliable. Then somewhere in the code we would need to check if ti,omap-counter32k is availabe, then check if timer1 is always-on, then use timer12 if not a secure device like n900.

IIRC, there's some OMAP timer properties for secure vs. non-secure. (It's not the first time we've had this discussion on TI timers.)

Quoted 6 lines

If the board wants to use the system clock as the source for a higher resolution with assigned-clock-parents, then we'd need to ignore the always-on property and not use the 32k counter as the clocksource. Basically to somehow figure out that a higher resolution configuration is preferred over a low-power configuration.

That could be something you want to pick at run-time.

Quoted 2 lines

So what's your take on just adding the generic properties for assigned-system-clocksource and clockevent?

I'm tired of discussing this for 10 years...

Rob

author maintainer
#10 lore raw

Re: [PATCH 02/14] clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support

Quoted 15 lines · Rob Herring
Quoted 14 lines · Tony Lindgren

Hmm. Trying to detect this automatically will get messy. For example, we have few omap3 boards with the following options that also need to consider if the separate 32KiHz counter is available:

1. The best case scenario

ti,omap-counter32k clocksource ti,sysc-omap2-timer ti,timer-alwon clockevent (timer1)

2. Boards relying on internal clock with unusable 32k counter

ti,sysc-omap2-timer ti,timer-alwon clocksource (timer12) ti,sysc-omap2-timer clockevent (typically gpt2)

Quoted 6 lines
Quoted 4 lines

In the second case, the 32k counter is unusable, and timer1 is unusable with the external 32k always on clock. But timer1 can be used with the system clock just fine for other purposes. So ideally we would not tag timer1 as disabled :)

I'm perfectly fine with a 'broken 32k clk' type property.

OK. Maybe "unreliable-oscillator" type property or something like that. Or maybe "shrodingers-cat-oscillator" :)

Quoted 3 lines

Though I think the compatibility story is not good changing DT for stuff needed to boot and needed early in boot. It's one thing to break something not required to get a system booted.

For the boards with the 32k clock issue the system boots but is unreliable. I'm not sure how long a 32k clock based timer would have to be monitored with another system clock based timer to detect it.. I recall the issues start popping up with PM and that much later and the system clock may not even be active..

Anyways, the issue is related to how the board is wired, so a property for it makes sense here.

Quoted 9 lines
Quoted 6 lines

For the second case, we could remove ti,timer-alwon property for timer1, and tag the 32k counter as disabled as the source clock is unreliable. Then somewhere in the code we would need to check if ti,omap-counter32k is availabe, then check if timer1 is always-on, then use timer12 if not a secure device like n900.

IIRC, there's some OMAP timer properties for secure vs. non-secure. (It's not the first time we've had this discussion on TI timers.)

Yes.

Quoted 8 lines
Quoted 6 lines

If the board wants to use the system clock as the source for a higher resolution with assigned-clock-parents, then we'd need to ignore the always-on property and not use the 32k counter as the clocksource. Basically to somehow figure out that a higher resolution configuration is preferred over a low-power configuration.

That could be something you want to pick at run-time.

OK

Quoted 4 lines
Quoted 2 lines

So what's your take on just adding the generic properties for assigned-system-clocksource and clockevent?

I'm tired of discussing this for 10 years...

Well luckly most system have basic timers integrated nowadays rather than each SoC vendor doing their own timers :)

Regards,

Tony

author maintainer
#11 lore raw

PATCH 3/14 clk: ti: dm816: enable sysclk6_ck on init

In reply to Tony Lindgren

We need sysclk6_ck enabled early as it is needed by l4_ls and system timers early on boot. This removes the dependency of system timers to the interconnect related code that can be then probed later on when suitable at module_init time.

Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Tero Kristo <[email protected]>
---
 drivers/clk/ti/clk-816x.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/ti/clk-816x.c +1 -0
@@ -73,6 +73,7 @@ static const char *enable_init_clks[] = {
 	"ddr_pll_clk1",
 	"ddr_pll_clk2",
 	"ddr_pll_clk3",
+	"sysclk6_ck",
 };
 
 int __init dm816x_dt_clk_init(void)
Signature · 1 line
2.26.1
maintainer Acked-by on v1 3/14
#12 lore raw

Re: [PATCH 03/14] clk: ti: dm816: enable sysclk6_ck on init

Quoting Tony Lindgren (2020-04-17 09:55:08)

Quoted 11 lines

We need sysclk6_ck enabled early as it is needed by l4_ls and system timers early on boot. This removes the dependency of system timers to the interconnect related code that can be then probed later on when suitable at module_init time.

Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Tero Kristo <[email protected]>

---

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#13 lore raw

PATCH 4/14 bus: ti-sysc: Ignore timer12 on secure omap3

In reply to Tony Lindgren

Some early omap3 boards use timer12 for system timer, but for secure SoCs like on n900 it's not accessible. Likely we will be configuring unavailable devices for other SoCs too based on runtime SoC detection, so let's use a switch to start with.

Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 drivers/bus/ti-sysc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/bus/ti-sysc.c +11 -0
@@ -2744,6 +2744,17 @@ static int sysc_init_soc(struct sysc *ddata)
 	if (match && match->data)
 		sysc_soc->soc = (int)match->data;
 
+	/* Ignore devices that are not available on HS and EMU SoCs */
+	if (!sysc_soc->general_purpose) {
+		switch (sysc_soc->soc) {
+		case SOC_3430 ... SOC_3630:
+			sysc_add_disabled(0x48304000);	/* timer12 */
+			break;
+		default:
+			break;
+		};
+	}
+
 	match = soc_device_match(sysc_soc_feat_match);
 	if (!match)
 		return 0;
Signature · 1 line
2.26.1
author maintainer
#14 lore raw

PATCH 5/14 ARM: OMAP2+: Add omap_init_time_of()

In reply to Tony Lindgren

This allows us to move the SoCs to probe system timers one SoC at at time. As arch/arm/mach-omap2/timer.c will be eventually gone, let's just add omap_init_time_of() to board-generic.c directly.

Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/mach-omap2/board-generic.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/mach-omap2/board-generic.c +8 -0
@@ -12,6 +12,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/irqdomain.h>
+#include <linux/clocksource.h>
 
 #include <asm/setup.h>
 #include <asm/mach/arch.h>
@@ -31,6 +32,13 @@ static void __init __maybe_unused omap_generic_init(void)
 	omap_soc_device_init();
 }
 
+/* Clocks are needed early, see drivers/clocksource for the rest */
+void __init __maybe_unused omap_init_time_of(void)
+{
+	omap_clk_init();
+	timer_probe();
+}
+
 #ifdef CONFIG_SOC_OMAP2420
 static const char *const omap242x_boards_compat[] __initconst = {
 	"ti,omap2420",
Signature · 1 line
2.26.1
author maintainer
#15 lore raw

PATCH 6/14 ARM: dts: Configure system timers for am335x

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

---
 arch/arm/boot/dts/am33xx-l4.dtsi                     |  2 --
 arch/arm/boot/dts/am33xx.dtsi                        | 12 ++++++++++++
 arch/arm/mach-omap2/board-generic.c                  |  2 +-
 .../mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c   |  2 --
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c           | 10 ----------
 5 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/boot/dts/am33xx-l4.dtsi +0 -2
@@ -332,7 +332,6 @@ scm_clockdomains: clockdomains {
 
 		target-module@31000 {			/* 0x44e31000, ap 25 40.0 */
 			compatible = "ti,sysc-omap2-timer", "ti,sysc";
-			ti,hwmods = "timer1";
 			reg = <0x31000 0x4>,
 			      <0x31010 0x4>,
 			      <0x31014 0x4>;
@@ -1119,7 +1118,6 @@ mcasp1: mcasp@0 {
 
 		target-module@40000 {			/* 0x48040000, ap 22 1e.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer2";
 			reg = <0x40000 0x4>,
 			      <0x40010 0x4>,
 			      <0x40014 0x4>;
arch/arm/boot/dts/am33xx.dtsi +12 -0
@@ -619,3 +619,15 @@ prm_gfx: prm@1100 {
 		#reset-cells = <1>;
 	};
 };
+
+&timer1 {
+	compatible = "ti,dmtimer-clocksource";
+	assigned-clocks = <&timer1_fck>;
+	assigned-clock-parents = <&sys_clkin_ck>;
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&timer2_fck>;
+	assigned-clock-parents = <&sys_clkin_ck>;
+};
arch/arm/mach-omap2/board-generic.c +1 -1
@@ -236,7 +236,7 @@ DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
 	.init_early	= am33xx_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= am33xx_init_late,
-	.init_time	= omap3_gptimer_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= am33xx_boards_compat,
 	.restart	= am33xx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c +0 -2
@@ -367,12 +367,10 @@ struct omap_hwmod am33xx_timer2_hwmod = {
 
 static void omap_hwmod_am33xx_clkctrl(void)
 {
-	CLKCTRL(am33xx_timer2_hwmod, AM33XX_CM_PER_TIMER2_CLKCTRL_OFFSET);
 	CLKCTRL(am33xx_smartreflex0_hwmod,
 		AM33XX_CM_WKUP_SMARTREFLEX0_CLKCTRL_OFFSET);
 	CLKCTRL(am33xx_smartreflex1_hwmod,
 		AM33XX_CM_WKUP_SMARTREFLEX1_CLKCTRL_OFFSET);
-	CLKCTRL(am33xx_timer1_hwmod, AM33XX_CM_WKUP_TIMER1_CLKCTRL_OFFSET);
 	CLKCTRL(am33xx_rtc_hwmod, AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET);
 	PRCM_FLAGS(am33xx_rtc_hwmod, HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET);
 	CLKCTRL(am33xx_gpmc_hwmod, AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET);
arch/arm/mach-omap2/omap_hwmod_33xx_data.c +0 -10
@@ -265,14 +265,6 @@ static struct omap_hwmod_ocp_if am33xx_l4_wkup__control = {
 	.user		= OCP_USER_MPU,
 };
 
-/* l4 wkup -> timer1 */
-static struct omap_hwmod_ocp_if am33xx_l4_wkup__timer1 = {
-	.master		= &am33xx_l4_wkup_hwmod,
-	.slave		= &am33xx_timer1_hwmod,
-	.clk		= "dpll_core_m4_div2_ck",
-	.user		= OCP_USER_MPU,
-};
-
 static struct omap_hwmod_ocp_if *am33xx_hwmod_ocp_ifs[] __initdata = {
 	&am33xx_l3_main__emif,
 	&am33xx_mpu__l3_main,
@@ -291,9 +283,7 @@ static struct omap_hwmod_ocp_if *am33xx_hwmod_ocp_ifs[] __initdata = {
 	&am33xx_l4_wkup__control,
 	&am33xx_l4_wkup__smartreflex0,
 	&am33xx_l4_wkup__smartreflex1,
-	&am33xx_l4_wkup__timer1,
 	&am33xx_l4_wkup__rtc,
-	&am33xx_l4_ls__timer2,
 	&am33xx_l3_s__gpmc,
 	&am33xx_l3_main__ocmc,
 	NULL,
Signature · 1 line
2.26.1
author maintainer
#16 lore raw

PATCH 7/14 ARM: dts: Configure system timers for am437x

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

---
 arch/arm/boot/dts/am4372.dtsi                 | 12 ++++
 arch/arm/boot/dts/am437x-l4.dtsi              |  3 -
 arch/arm/mach-omap2/board-generic.c           |  2 +-
 .../omap_hwmod_33xx_43xx_common_data.h        |  2 -
 .../omap_hwmod_33xx_43xx_interconnect_data.c  |  8 ---
 .../omap_hwmod_33xx_43xx_ipblock_data.c       | 60 -------------------
 arch/arm/mach-omap2/omap_hwmod_43xx_data.c    | 45 --------------
 7 files changed, 13 insertions(+), 119 deletions(-)
arch/arm/boot/dts/am4372.dtsi +12 -0
@@ -553,3 +553,15 @@ prm_device: prm@4000 {
 		#reset-cells = <1>;
 	};
 };
+
+&timer1 {
+	compatible = "ti,dmtimer-clocksource";
+	assigned-clocks = <&timer1_fck>;
+	assigned-clock-parents = <&sys_clkin_ck>;
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&timer2_fck>;
+	assigned-clock-parents = <&sys_clkin_ck>;
+};
arch/arm/boot/dts/am437x-l4.dtsi +0 -3
@@ -330,7 +330,6 @@ scm_clockdomains: clockdomains {
 
 		target-module@31000 {			/* 0x44e31000, ap 24 40.0 */
 			compatible = "ti,sysc-omap2-timer", "ti,sysc";
-			ti,hwmods = "timer1";
 			reg = <0x31000 0x4>,
 			      <0x31010 0x4>,
 			      <0x31014 0x4>;
@@ -450,7 +449,6 @@ target-module@40000 {			/* 0x44e40000, ap 36 68.0 */
 
 		target-module@86000 {			/* 0x44e86000, ap 40 70.0 */
 			compatible = "ti,sysc-omap2", "ti,sysc";
-			ti,hwmods = "counter_32k";
 			reg = <0x86000 0x4>,
 			      <0x86004 0x4>;
 			reg-names = "rev", "sysc";
@@ -870,7 +868,6 @@ mcasp1: mcasp@0 {
 
 		target-module@40000 {			/* 0x48040000, ap 18 1e.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer2";
 			reg = <0x40000 0x4>,
 			      <0x40010 0x4>,
 			      <0x40014 0x4>;
arch/arm/mach-omap2/board-generic.c +1 -1
@@ -308,7 +308,7 @@ DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
 	.init_late	= am43xx_init_late,
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
-	.init_time	= omap3_gptimer_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= am43_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_common_data.h +0 -2
@@ -44,8 +44,6 @@ extern struct omap_hwmod am33xx_smartreflex0_hwmod;
 extern struct omap_hwmod am33xx_smartreflex1_hwmod;
 extern struct omap_hwmod am33xx_gpmc_hwmod;
 extern struct omap_hwmod am33xx_rtc_hwmod;
-extern struct omap_hwmod am33xx_timer1_hwmod;
-extern struct omap_hwmod am33xx_timer2_hwmod;
 
 extern struct omap_hwmod_class am33xx_emif_hwmod_class;
 extern struct omap_hwmod_class am33xx_l4_hwmod_class;
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_interconnect_data.c +0 -8
@@ -106,14 +106,6 @@ struct omap_hwmod_ocp_if am33xx_l3_s__gpmc = {
 	.user		= OCP_USER_MPU,
 };
 
-/* l4 per -> timer2 */
-struct omap_hwmod_ocp_if am33xx_l4_ls__timer2 = {
-	.master		= &am33xx_l4_ls_hwmod,
-	.slave		= &am33xx_timer2_hwmod,
-	.clk		= "l4ls_gclk",
-	.user		= OCP_USER_MPU,
-};
-
 /* l3 main -> ocmc */
 struct omap_hwmod_ocp_if am33xx_l3_main__ocmc = {
 	.master		= &am33xx_l3_main_hwmod,
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c +0 -60

76 lines not on this page · raw message

arch/arm/mach-omap2/omap_hwmod_43xx_data.c +0 -45

69 lines not on this page · raw message

Signature · 1 line
2.26.1
author maintainer
#17 lore raw

PATCH 8/14 ARM: dts: Configure system timers for omap4

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

---
 arch/arm/boot/dts/omap4-l4.dtsi            |  2 -
 arch/arm/boot/dts/omap4.dtsi               |  6 ++
 arch/arm/mach-omap2/board-generic.c        |  2 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 90 ----------------------
 4 files changed, 7 insertions(+), 93 deletions(-)
arch/arm/boot/dts/omap4-l4.dtsi +0 -2
@@ -974,7 +974,6 @@ segment@0 {					/* 0x4a300000 */
 
 		target-module@4000 {			/* 0x4a304000, ap 17 24.0 */
 			compatible = "ti,sysc-omap2", "ti,sysc";
-			ti,hwmods = "counter_32k";
 			reg = <0x4000 0x4>,
 			      <0x4004 0x4>;
 			reg-names = "rev", "sysc";
@@ -1141,7 +1140,6 @@ wdt2: wdt@0 {
 
 		target-module@8000 {			/* 0x4a318000, ap 9 1c.0 */
 			compatible = "ti,sysc-omap2-timer", "ti,sysc";
-			ti,hwmods = "timer1";
 			reg = <0x8000 0x4>,
 			      <0x8010 0x4>,
 			      <0x8014 0x4>;
arch/arm/boot/dts/omap4.dtsi +6 -0
@@ -655,3 +655,9 @@ prm_device: prm@1b00 {
 		#reset-cells = <1>;
 	};
 };
+
+&timer1 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&l4_wkup_clkctrl OMAP4_TIMER1_CLKCTRL 24>;
+	assigned-clock-parents = <&sys_clkin_ck>;
+};
arch/arm/mach-omap2/board-generic.c +1 -1
@@ -261,7 +261,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +0 -90

126 lines not on this page · raw message

Signature · 1 line
2.26.1
author maintainer
#18 lore raw

PATCH 9/14 ARM: dts: Configure system timers for omap5 and dra7

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

Note that similar to omap_init_time_of(), we now need to call omap_clk_init() also from omap5_realtime_timer_init().

---
 arch/arm/boot/dts/dra7-l4.dtsi             |   5 -
 arch/arm/boot/dts/dra7.dtsi                |   6 +
 arch/arm/boot/dts/omap5-l4.dtsi            |   2 -
 arch/arm/boot/dts/omap5.dtsi               |   6 +
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c |  89 -----------
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c  | 176 ---------------------
 arch/arm/mach-omap2/timer.c                |  17 +-
 7 files changed, 13 insertions(+), 288 deletions(-)
arch/arm/boot/dts/dra7-l4.dtsi +0 -5
@@ -1143,7 +1143,6 @@ uart3: serial@0 {
 
 		target-module@32000 {			/* 0x48032000, ap 5 3e.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer2";
 			reg = <0x32000 0x4>,
 			      <0x32010 0x4>;
 			reg-names = "rev", "sysc";
@@ -1171,7 +1170,6 @@ timer2: timer@0 {
 
 		target-module@34000 {			/* 0x48034000, ap 7 46.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer3";
 			reg = <0x34000 0x4>,
 			      <0x34010 0x4>;
 			reg-names = "rev", "sysc";
@@ -1199,7 +1197,6 @@ timer3: timer@0 {
 
 		target-module@36000 {			/* 0x48036000, ap 9 4e.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer4";
 			reg = <0x36000 0x4>,
 			      <0x36010 0x4>;
 			reg-names = "rev", "sysc";
@@ -4295,7 +4292,6 @@ segment@0 {					/* 0x4ae00000 */
 
 		target-module@4000 {			/* 0x4ae04000, ap 15 40.0 */
 			compatible = "ti,sysc-omap2", "ti,sysc";
-			ti,hwmods = "counter_32k";
 			reg = <0x4000 0x4>,
 			      <0x4010 0x4>;
 			reg-names = "rev", "sysc";
@@ -4432,7 +4428,6 @@ wdt2: wdt@0 {
 
 		target-module@8000 {			/* 0x4ae18000, ap 9 30.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer1";
 			reg = <0x8000 0x4>,
 			      <0x8010 0x4>;
 			reg-names = "rev", "sysc";
arch/arm/boot/dts/dra7.dtsi +6 -0
@@ -1044,3 +1044,9 @@ prm_eve4: prm@1c00 {
 		reg = <0x1c00 0x60>;
 	};
 };
+
+&timer1 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&wkupaon_clkctrl DRA7_TIMER1_CLKCTRL 24>;
+	assigned-clock-parents = <&sys_32k_ck>;
+};
arch/arm/boot/dts/omap5-l4.dtsi +0 -2
@@ -2150,7 +2150,6 @@ segment@0 {					/* 0x4ae00000 */
 
 		target-module@4000 {			/* 0x4ae04000, ap 17 20.0 */
 			compatible = "ti,sysc-omap2", "ti,sysc";
-			ti,hwmods = "counter_32k";
 			reg = <0x4000 0x4>,
 			      <0x4010 0x4>;
 			reg-names = "rev", "sysc";
@@ -2338,7 +2337,6 @@ wdt2: wdt@0 {
 
 		target-module@8000 {			/* 0x4ae18000, ap 9 18.0 */
 			compatible = "ti,sysc-omap4-timer", "ti,sysc";
-			ti,hwmods = "timer1";
 			reg = <0x8000 0x4>,
 			      <0x8010 0x4>;
 			reg-names = "rev", "sysc";
arch/arm/boot/dts/omap5.dtsi +6 -0
@@ -581,3 +581,9 @@ prm_device: prm@1c00 {
 		#reset-cells = <1>;
 	};
 };
+
+&timer1 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&wkupaon_clkctrl OMAP5_TIMER1_CLKCTRL 24>;
+	assigned-clock-parents = <&sys_32k_ck>;
+};
arch/arm/mach-omap2/omap_hwmod_54xx_data.c +0 -89

122 lines not on this page · raw message

arch/arm/mach-omap2/omap_hwmod_7xx_data.c +0 -176

212 lines not on this page · raw message

arch/arm/mach-omap2/timer.c +1 -16
@@ -576,21 +576,6 @@ void __init omap3_gptimer_timer_init(void)
 }
 #endif
 
-#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) ||		\
-	defined(CONFIG_SOC_DRA7XX)
-static void __init omap4_sync32k_timer_init(void)
-{
-	__omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
-				  0, NULL, NULL, false);
-}
-
-void __init omap4_local_timer_init(void)
-{
-	omap4_sync32k_timer_init();
-	timer_probe();
-}
-#endif
-
 #if defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX)
 
 /*
@@ -708,7 +693,7 @@ static void __init realtime_counter_init(void)
 
 void __init omap5_realtime_timer_init(void)
 {
-	omap4_sync32k_timer_init();
+	omap_clk_init();
 	realtime_counter_init();
 
 	timer_probe();
Signature · 1 line
2.26.1
author maintainer
#19 lore raw

PATCH 10/14 ARM: dts: Configure system timers for omap3

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

Let's also update the dts file to use #include while at it.

Cc Adam Ford <[email protected]>
Cc Andreas Kemnade <[email protected]>
Cc "H. Nikolaus Schaller" <[email protected]>
Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/boot/dts/am3517.dtsi              |  16 ++-
 arch/arm/boot/dts/omap3-beagle.dts         |  16 +++
 arch/arm/boot/dts/omap3-devkit8000.dts     |  16 +++
 arch/arm/boot/dts/omap3.dtsi               | 130 ++++++++++++++----
 arch/arm/mach-omap2/board-generic.c        |  10 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 146 +--------------------
 6 files changed, 159 insertions(+), 175 deletions(-)
arch/arm/boot/dts/am3517.dtsi +14 -2
@@ -169,5 +169,17 @@ &mmu_isp {
 	status = "disabled";
 };
 
-/include/ "am35xx-clocks.dtsi"
-/include/ "omap36xx-am35xx-omap3430es2plus-clocks.dtsi"
+#include "am35xx-clocks.dtsi"
+#include "omap36xx-am35xx-omap3430es2plus-clocks.dtsi"
+
+&timer1 {
+	compatible = "ti,dmtimer-clocksource";
+	assigned-clocks = <&gpt1_fck>;
+	assigned-clock-parents = <&sys_ck>;
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&gpt2_fck>;
+	assigned-clock-parents = <&sys_ck>;
+};
arch/arm/boot/dts/omap3-beagle.dts +16 -0
@@ -304,6 +304,22 @@ &usbhsehci {
 	phys = <0 &hsusb2_phy>;
 };
 
+&timer1 {
+	/* Unusable as clockevent */
+	compatible = "ti,omap3430-timer";
+};
+
+&timer12 {
+	compatible = "ti,dmtimer-clocksource";
+	/* Always clocked by secure_32k_fck */
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&gpt2_fck>;
+	assigned-clock-parents = <&sys_ck>;
+};
+
 &twl_gpio {
 	ti,use-leds;
 	/* pullups: BIT(1) */
arch/arm/boot/dts/omap3-devkit8000.dts +16 -0
@@ -14,3 +14,19 @@ aliases {
 		display2 = &tv0;
 	};
 };
+
+&timer1 {
+	/* Unusable as clockevent */
+	compatible = "ti,omap3430-timer";
+};
+
+&timer12 {
+	compatible = "ti,dmtimer-clocksource";
+	/* Always clocked by secure_32k_fck */
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&gpt2_fck>;
+	assigned-clock-parents = <&sys_ck>;
+};
arch/arm/boot/dts/omap3.dtsi +107 -23

153 lines not on this page · raw message

arch/arm/mach-omap2/board-generic.c +5 -5
@@ -114,7 +114,7 @@ DT_MACHINE_START(OMAP3_N900_DT, "Nokia RX-51 board")
 	.init_early	= omap3430_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap3_init_late,
-	.init_time	= omap_init_time,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= n900_boards_compat,
 	.restart	= omap3xxx_restart,
 MACHINE_END
@@ -132,7 +132,7 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
 	.init_early	= omap3430_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap3_init_late,
-	.init_time	= omap_init_time,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap3_boards_compat,
 	.restart	= omap3xxx_restart,
 MACHINE_END
@@ -149,7 +149,7 @@ DT_MACHINE_START(OMAP36XX_DT, "Generic OMAP36xx (Flattened Device Tree)")
 	.init_early	= omap3630_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap3_init_late,
-	.init_time	= omap_init_time,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap36xx_boards_compat,
 	.restart	= omap3xxx_restart,
 MACHINE_END
@@ -166,7 +166,7 @@ DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
 	.init_early	= omap3430_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap3_init_late,
-	.init_time	= omap3_secure_sync32k_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap3_gp_boards_compat,
 	.restart	= omap3xxx_restart,
 MACHINE_END
@@ -182,7 +182,7 @@ DT_MACHINE_START(AM3517_DT, "Generic AM3517 (Flattened Device Tree)")
 	.init_early	= am35xx_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap3_init_late,
-	.init_time	= omap3_gptimer_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= am3517_boards_compat,
 	.restart	= omap3xxx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +1 -145

225 lines not on this page · raw message

Signature · 1 line
2.26.1
author maintainer
#20 lore raw

PATCH 11/14 ARM: dts: Configure system timers for ti81xx

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

Note that for ti81xx, also timer1 is of type 2 unlike on am335x where timer1 is type1 while the rest of the timers are type 2.

---
 arch/arm/boot/dts/dm814x.dtsi              | 66 +++++++++++++++----
 arch/arm/boot/dts/dm816x.dtsi              | 70 ++++++++++++++++----
 arch/arm/mach-omap2/board-generic.c        |  4 +-
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 74 ----------------------
 4 files changed, 114 insertions(+), 100 deletions(-)
arch/arm/boot/dts/dm814x.dtsi +55 -11
@@ -308,14 +308,30 @@ mcspi4: spi@1a4000 {
 				ti,hwmods = "mcspi4";
 			};
 
-			timer1: timer@2e000 {
-				compatible = "ti,dm814-timer";
-				reg = <0x2e000 0x2000>;
-				interrupts = <67>;
-				ti,hwmods = "timer1";
-				ti,timer-alwon;
+			target-module@2e000 {
+				compatible = "ti,sysc-omap4-timer", "ti,sysc";
+				reg = <0x2e000 0x4>,
+				      <0x2e010 0x4>;
+				reg-names = "rev", "sysc";
+				ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>;
+				ti,sysc-sidle = <SYSC_IDLE_FORCE>,
+						<SYSC_IDLE_NO>,
+						<SYSC_IDLE_SMART>,
+						<SYSC_IDLE_SMART_WKUP>;
 				clocks = <&timer1_fck>;
 				clock-names = "fck";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x2e000 0x1000>;
+
+				timer1: timer@0 {
+					compatible = "ti,am335x-timer-1ms";
+					reg = <0x0 0x400>;
+					interrupts = <67>;
+					ti,timer-alwon;
+					clocks = <&timer1_fck>;
+					clock-names = "fck";
+				};
 			};
 
 			uart1: uart@20000 {
@@ -348,13 +364,29 @@ uart3: uart@24000 {
 				dma-names = "tx", "rx";
 			};
 
-			timer2: timer@40000 {
-				compatible = "ti,dm814-timer";
-				reg = <0x40000 0x2000>;
-				interrupts = <68>;
-				ti,hwmods = "timer2";
+			target-module@40000 {
+				compatible = "ti,sysc-omap4-timer", "ti,sysc";
+				reg = <0x40000 0x4>,
+				      <0x40010 0x4>;
+				reg-names = "rev", "sysc";
+				ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>;
+				ti,sysc-sidle = <SYSC_IDLE_FORCE>,
+						<SYSC_IDLE_NO>,
+						<SYSC_IDLE_SMART>,
+						<SYSC_IDLE_SMART_WKUP>;
 				clocks = <&timer2_fck>;
 				clock-names = "fck";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x40000 0x1000>;
+
+				timer2: timer@0 {
+					compatible = "ti,dm814-timer";
+					reg = <0 0x1000>;
+					interrupts = <68>;
+					clocks = <&timer2_fck>;
+					clock-names = "fck";
+				};
 			};
 
 			timer3: timer@42000 {
@@ -735,3 +767,15 @@ gpmc: gpmc@50000000 {
 };
 
 #include "dm814x-clocks.dtsi"
+
+&timer1 {
+	compatible = "ti,dmtimer-clocksource";
+	assigned-clocks = <&timer1_fck>;
+	assigned-clock-parents = <&devosc_ck>;
+};
+
+&timer2 {
+	compatible = "ti,dmtimer-clockevent";
+	assigned-clocks = <&timer2_fck>;
+	assigned-clock-parents = <&devosc_ck>;
+};
arch/arm/boot/dts/dm816x.dtsi +57 -13

83 lines not on this page · raw message

arch/arm/mach-omap2/board-generic.c +2 -2
@@ -201,7 +201,7 @@ DT_MACHINE_START(TI814X_DT, "Generic ti814x (Flattened Device Tree)")
 	.init_early	= ti814x_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= ti81xx_init_late,
-	.init_time	= omap3_gptimer_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= ti814x_boards_compat,
 	.restart	= ti81xx_restart,
 MACHINE_END
@@ -218,7 +218,7 @@ DT_MACHINE_START(TI816X_DT, "Generic ti816x (Flattened Device Tree)")
 	.init_early	= ti816x_init_early,
 	.init_machine	= omap_generic_init,
 	.init_late	= ti81xx_init_late,
-	.init_time	= omap3_gptimer_timer_init,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= ti816x_boards_compat,
 	.restart	= ti81xx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_81xx_data.c +0 -74

92 lines not on this page · raw message

Signature · 1 line
2.26.1
author maintainer
#21 lore raw

PATCH 12/14 ARM: dts: Configure system timers for omap2

In reply to Tony Lindgren

We can now init system timers using the dmtimer and 32k counter based on only devicetree data and drivers/clocksource timers. Let's configure the clocksource and clockevent, and drop the old unused platform data.

As we're just dropping platform data, and the early platform data init is based on the custom ti,hwmods property, we want to drop both the platform data and ti,hwmods property in a single patch.

Since the dmtimer can use both 32k clock and system clock as the source, let's also configure the SoC specific default values. The board specific dts files can reconfigure these with assigned-clocks and assigned-clock-parents as needed.

Let's also update the dts file to use #include while at it.

Cc Aaro Koskinen <[email protected]>
Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/boot/dts/omap2.dtsi                  | 38 +++++++++--
 arch/arm/boot/dts/omap2420.dtsi               | 65 +++++++++++++++----
 arch/arm/boot/dts/omap2430.dtsi               | 65 +++++++++++++++----
 arch/arm/mach-omap2/board-generic.c           |  4 +-
 arch/arm/mach-omap2/omap_hwmod_2420_data.c    | 20 ------
 arch/arm/mach-omap2/omap_hwmod_2430_data.c    | 19 ------
 .../omap_hwmod_2xxx_interconnect_data.c       |  8 ---
 .../mach-omap2/omap_hwmod_2xxx_ipblock_data.c | 47 --------------
 arch/arm/mach-omap2/omap_hwmod_common_data.h  |  3 -
 9 files changed, 141 insertions(+), 128 deletions(-)
arch/arm/boot/dts/omap2.dtsi +33 -5
@@ -201,11 +201,32 @@ uart3: serial@4806e000 {
 			clock-frequency = <48000000>;
 		};
 
-		timer2: timer@4802a000 {
-			compatible = "ti,omap2420-timer";
-			reg = <0x4802a000 0x400>;
-			interrupts = <38>;
-			ti,hwmods = "timer2";
+		target-module@4802a000 {
+			compatible = "ti,sysc-omap2-timer", "ti,sysc";
+			reg = <0x4802a000 0x4>,
+			      <0x4802a010 0x4>,
+			      <0x4802a014 0x4>;
+			reg-names = "rev", "sysc", "syss";
+			ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY |
+					 SYSC_OMAP2_EMUFREE |
+					 SYSC_OMAP2_ENAWAKEUP |
+					 SYSC_OMAP2_SOFTRESET |
+					 SYSC_OMAP2_AUTOIDLE)>;
+			ti,sysc-sidle = <SYSC_IDLE_FORCE>,
+					<SYSC_IDLE_NO>,
+					<SYSC_IDLE_SMART>;
+			ti,syss-mask = <1>;
+			clocks = <&gpt2_fck>, <&gpt2_ick>;
+			clock-names = "fck", "ick";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x0 0x4802a000 0x1000>;
+
+			timer2: timer@0 {
+				compatible = "ti,omap2420-timer";
+				reg = <0 0x400>;
+				interrupts = <38>;
+			};
 		};
 
 		timer3: timer@48078000 {
@@ -318,3 +339,10 @@ venc: encoder@48050c00 {
 		};
 	};
 };
+#if 0
+&timer2 {
+	compatible = "ti,dmtimer-clocksource";
+	assigned-clocks = <&gpt2_fck>;
+	assigned-clock-parents = <&sys_ck>;
+};
+#endif
arch/arm/boot/dts/omap2420.dtsi +53 -12

80 lines not on this page · raw message

arch/arm/boot/dts/omap2430.dtsi +53 -12

80 lines not on this page · raw message

arch/arm/mach-omap2/board-generic.c +2 -2
@@ -50,7 +50,7 @@ DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
 	.map_io		= omap242x_map_io,
 	.init_early	= omap2420_init_early,
 	.init_machine	= omap_generic_init,
-	.init_time	= omap_init_time,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap242x_boards_compat,
 	.restart	= omap2xxx_restart,
 MACHINE_END
@@ -67,7 +67,7 @@ DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
 	.map_io		= omap243x_map_io,
 	.init_early	= omap2430_init_early,
 	.init_machine	= omap_generic_init,
-	.init_time	= omap_init_time,
+	.init_time	= omap_init_time_of,
 	.dt_compat	= omap243x_boards_compat,
 	.restart	= omap2xxx_restart,
 MACHINE_END
arch/arm/mach-omap2/omap_hwmod_2420_data.c +0 -20
@@ -264,14 +264,6 @@ static struct omap_hwmod_ocp_if omap2420_l3__dsp = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
-/* l4_wkup -> timer1 */
-static struct omap_hwmod_ocp_if omap2420_l4_wkup__timer1 = {
-	.master		= &omap2xxx_l4_wkup_hwmod,
-	.slave		= &omap2xxx_timer1_hwmod,
-	.clk		= "gpt1_ick",
-	.user		= OCP_USER_MPU | OCP_USER_SDMA,
-};
-
 /* l4_wkup -> wd_timer2 */
 static struct omap_hwmod_ocp_if omap2420_l4_wkup__wd_timer2 = {
 	.master		= &omap2xxx_l4_wkup_hwmod,
@@ -352,15 +344,6 @@ static struct omap_hwmod_ocp_if omap2420_l4_core__hdq1w = {
 	.flags		= OMAP_FIREWALL_L4 | OCPIF_SWSUP_IDLE,
 };
 
-
-/* l4_wkup -> 32ksync_counter */
-static struct omap_hwmod_ocp_if omap2420_l4_wkup__counter_32k = {
-	.master		= &omap2xxx_l4_wkup_hwmod,
-	.slave		= &omap2xxx_counter_32k_hwmod,
-	.clk		= "sync_32k_ick",
-	.user		= OCP_USER_MPU | OCP_USER_SDMA,
-};
-
 static struct omap_hwmod_ocp_if omap2420_l3__gpmc = {
 	.master		= &omap2xxx_l3_main_hwmod,
 	.slave		= &omap2xxx_gpmc_hwmod,
@@ -382,8 +365,6 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
 	&omap2420_l4_core__i2c2,
 	&omap2420_l3__iva,
 	&omap2420_l3__dsp,
-	&omap2420_l4_wkup__timer1,
-	&omap2xxx_l4_core__timer2,
 	&omap2xxx_l4_core__timer3,
 	&omap2xxx_l4_core__timer4,
 	&omap2xxx_l4_core__timer5,
@@ -411,7 +392,6 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
 	&omap2xxx_l4_core__sham,
 	&omap2xxx_l4_core__aes,
 	&omap2420_l4_core__hdq1w,
-	&omap2420_l4_wkup__counter_32k,
 	&omap2420_l3__gpmc,
 	NULL,
 };
arch/arm/mach-omap2/omap_hwmod_2430_data.c +0 -19
@@ -436,14 +436,6 @@ static struct omap_hwmod_ocp_if omap2430_l3__iva = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
-/* l4_wkup -> timer1 */
-static struct omap_hwmod_ocp_if omap2430_l4_wkup__timer1 = {
-	.master		= &omap2xxx_l4_wkup_hwmod,
-	.slave		= &omap2xxx_timer1_hwmod,
-	.clk		= "gpt1_ick",
-	.user		= OCP_USER_MPU | OCP_USER_SDMA,
-};
-
 /* l4_wkup -> wd_timer2 */
 static struct omap_hwmod_ocp_if omap2430_l4_wkup__wd_timer2 = {
 	.master		= &omap2xxx_l4_wkup_hwmod,
@@ -548,14 +540,6 @@ static struct omap_hwmod_ocp_if omap2430_l4_core__hdq1w = {
 	.flags		= OMAP_FIREWALL_L4 | OCPIF_SWSUP_IDLE,
 };
 
-/* l4_wkup -> 32ksync_counter */
-static struct omap_hwmod_ocp_if omap2430_l4_wkup__counter_32k = {
-	.master		= &omap2xxx_l4_wkup_hwmod,
-	.slave		= &omap2xxx_counter_32k_hwmod,
-	.clk		= "sync_32k_ick",
-	.user		= OCP_USER_MPU | OCP_USER_SDMA,
-};
-
 static struct omap_hwmod_ocp_if omap2430_l3__gpmc = {
 	.master		= &omap2xxx_l3_main_hwmod,
 	.slave		= &omap2xxx_gpmc_hwmod,
@@ -581,8 +565,6 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
 	&omap2xxx_l4_core__mcspi2,
 	&omap2430_l4_core__mcspi3,
 	&omap2430_l3__iva,
-	&omap2430_l4_wkup__timer1,
-	&omap2xxx_l4_core__timer2,
 	&omap2xxx_l4_core__timer3,
 	&omap2xxx_l4_core__timer4,
 	&omap2xxx_l4_core__timer5,
@@ -613,7 +595,6 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
 	&omap2xxx_l4_core__rng,
 	&omap2xxx_l4_core__sham,
 	&omap2xxx_l4_core__aes,
-	&omap2430_l4_wkup__counter_32k,
 	&omap2430_l3__gpmc,
 	NULL,
 };
arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c +0 -8
@@ -95,14 +95,6 @@ struct omap_hwmod_ocp_if omap2xxx_l4_core__mcspi2 = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
-/* l4_core -> timer2 */
-struct omap_hwmod_ocp_if omap2xxx_l4_core__timer2 = {
-	.master		= &omap2xxx_l4_core_hwmod,
-	.slave		= &omap2xxx_timer2_hwmod,
-	.clk		= "gpt2_ick",
-	.user		= OCP_USER_MPU | OCP_USER_SDMA,
-};
-
 /* l4_core -> timer3 */
 struct omap_hwmod_ocp_if omap2xxx_l4_core__timer3 = {
 	.master		= &omap2xxx_l4_core_hwmod,
arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c +0 -47

59 lines not on this page · raw message

arch/arm/mach-omap2/omap_hwmod_common_data.h +0 -3
@@ -21,8 +21,6 @@ extern struct omap_hwmod omap2xxx_l4_core_hwmod;
 extern struct omap_hwmod omap2xxx_l4_wkup_hwmod;
 extern struct omap_hwmod omap2xxx_mpu_hwmod;
 extern struct omap_hwmod omap2xxx_iva_hwmod;
-extern struct omap_hwmod omap2xxx_timer1_hwmod;
-extern struct omap_hwmod omap2xxx_timer2_hwmod;
 extern struct omap_hwmod omap2xxx_timer3_hwmod;
 extern struct omap_hwmod omap2xxx_timer4_hwmod;
 extern struct omap_hwmod omap2xxx_timer5_hwmod;
@@ -47,7 +45,6 @@ extern struct omap_hwmod omap2xxx_gpio3_hwmod;
 extern struct omap_hwmod omap2xxx_gpio4_hwmod;
 extern struct omap_hwmod omap2xxx_mcspi1_hwmod;
 extern struct omap_hwmod omap2xxx_mcspi2_hwmod;
-extern struct omap_hwmod omap2xxx_counter_32k_hwmod;
 extern struct omap_hwmod omap2xxx_gpmc_hwmod;
 extern struct omap_hwmod omap2xxx_rng_hwmod;
 extern struct omap_hwmod omap2xxx_sham_hwmod;
Signature · 1 line
2.26.1
author maintainer
#22 lore raw

PATCH 13/14 ARM: OMAP2+: Drop old timer code for dmtimer and 32k counter

In reply to Tony Lindgren

With dmtimer and 32k counter being initialized based on devicetree data, we can just drop the old timer code.

This still leaves the omap5 and dra7 realtime_counter_init() that depend on the smc calls and control module platform code for the dra7 quirk init.

Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/mach-omap2/Makefile |   4 +-
 arch/arm/mach-omap2/common.h |   7 +
 arch/arm/mach-omap2/timer.c  | 551 -----------------------------------
 3 files changed, 10 insertions(+), 552 deletions(-)
arch/arm/mach-omap2/Makefile +3 -1
@@ -7,7 +7,7 @@ ccflags-y := -I$(srctree)/$(src)/include \
 	-I$(srctree)/arch/arm/plat-omap/include
 
 # Common support
-obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \
+obj-y := id.o io.o control.o devices.o fb.o pm.o \
 	 common.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
 	 omap_device.o omap-headsmp.o sram.o
 
@@ -16,6 +16,8 @@ hwmod-common				= omap_hwmod.o omap_hwmod_reset.o \
 clock-common				= clock.o
 secure-common				= omap-smc.o omap-secure.o
 
+obj-$(CONFIG_SOC_HAS_REALTIME_COUNTER)	+= timer.o
+
 obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(hwmod-common)
 obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(hwmod-common) $(secure-common)
 obj-$(CONFIG_ARCH_OMAP4) += $(hwmod-common) $(secure-common)
arch/arm/mach-omap2/common.h +7 -0
@@ -111,7 +111,14 @@ static inline int omap_l2_cache_init(void)
 #define OMAP_L2C_AUX_CTRL	0
 #define omap4_l2c310_write_sec	NULL
 #endif
+
+#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
 extern void omap5_realtime_timer_init(void);
+#else
+static inline void omap5_realtime_timer_init(void)
+{
+}
+#endif
 
 void omap2420_init_early(void);
 void omap2430_init_early(void);
arch/arm/mach-omap2/timer.c +0 -551

596 lines not on this page · raw message

Signature · 1 line
2.26.1
author maintainer
#23 lore raw

PATCH 14/14 bus: ti-sysc: Timers no longer need legacy quirk handling

In reply to Tony Lindgren

As timers no longer need legacy quirk handling, let's move them to the CONFIG_DEBUG section to make it easier to see which drivers still need more work.

Let's also add detection for few more older timer revisions while at it as that makes CONFIG_DEBUG output easier to read with proper names.

Cc Keerthy <[email protected]>
Cc Lokesh Vutla <[email protected]>
Cc Tero Kristo <[email protected]>
---
 drivers/bus/ti-sysc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/bus/ti-sysc.c +7 -7
@@ -1275,13 +1275,6 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
 		   SYSC_QUIRK_LEGACY_IDLE),
 	SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff,
 		   SYSC_QUIRK_LEGACY_IDLE),
-	SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
-		   0),
-	/* Some timers on omap4 and later */
-	SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x50002100, 0xffffffff,
-		   0),
-	SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x4fff1301, 0xffff00ff,
-		   0),
 	SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000046, 0xffffffff,
 		   SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
 	SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
@@ -1404,6 +1397,13 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
 	SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40002903, 0xffffffff, 0),
 	SYSC_QUIRK("spinlock", 0, 0, 0x10, -ENODEV, 0x50020000, 0xffffffff, 0),
 	SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -ENODEV, 0x00000020, 0xffffffff, 0),
+	SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000013, 0xffffffff, 0),
+	SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff, 0),
+	/* Some timers on omap4 and later */
+	SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x50002100, 0xffffffff, 0),
+	SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x4fff1301, 0xffff00ff, 0),
+	SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000040, 0xffffffff, 0),
+	SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000011, 0xffffffff, 0),
 	SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000060, 0xffffffff, 0),
 	SYSC_QUIRK("tpcc", 0, 0, -ENODEV, -ENODEV, 0x40014c00, 0xffffffff, 0),
 	SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
Signature · 1 line
2.26.1
#24 lore raw
In reply to Tony Lindgren

Hi Tony,

Quoted 9 lines · Tony Lindgren

Hi all,

Here's a series of changes to udpate omaps to use drivers/clocksource timers for the 32k counter and dmtimer and to remove the old legacy platform code. Please review and test.

Daniel, if the the first two patches look OK after review, maybe you can again set up an immutable branch for the first two patches against v5.7-rc1 that I can merge in?

Ok let me review the patches.

Quoted 66 lines

Tony Lindgren (14):
clocksource/drivers/timer-ti-32k: Add support for initializing
directly
clocksource/drivers/timer-ti-dm: Add clockevent and clocksource
support
clk: ti: dm816: enable sysclk6_ck on init
bus: ti-sysc: Ignore timer12 on secure omap3
ARM: OMAP2+: Add omap_init_time_of()
ARM: dts: Configure system timers for am335x
ARM: dts: Configure system timers for am437x
ARM: dts: Configure system timers for omap4
ARM: dts: Configure system timers for omap5 and dra7
ARM: dts: Configure system timers for omap3
ARM: dts: Configure system timers for ti81xx
ARM: dts: Configure system timers for omap2
ARM: OMAP2+: Drop old timer code for dmtimer and 32k counter
bus: ti-sysc: Timers no longer need legacy quirk handling

 .../devicetree/bindings/timer/ti,timer.txt    |   2 +
 arch/arm/boot/dts/am33xx-l4.dtsi              |   2 -
 arch/arm/boot/dts/am33xx.dtsi                 |  12 +
 arch/arm/boot/dts/am3517.dtsi                 |  16 +-
 arch/arm/boot/dts/am4372.dtsi                 |  12 +
 arch/arm/boot/dts/am437x-l4.dtsi              |   3 -
 arch/arm/boot/dts/dm814x.dtsi                 |  66 +-
 arch/arm/boot/dts/dm816x.dtsi                 |  70 ++-
 arch/arm/boot/dts/dra7-l4.dtsi                |   5 -
 arch/arm/boot/dts/dra7.dtsi                   |   6 +
 arch/arm/boot/dts/omap2.dtsi                  |  38 +-
 arch/arm/boot/dts/omap2420.dtsi               |  65 +-
 arch/arm/boot/dts/omap2430.dtsi               |  65 +-
 arch/arm/boot/dts/omap3-beagle.dts            |  16 +
 arch/arm/boot/dts/omap3-devkit8000.dts        |  16 +
 arch/arm/boot/dts/omap3.dtsi                  | 130 +++-
 arch/arm/boot/dts/omap4-l4.dtsi               |   2 -
 arch/arm/boot/dts/omap4.dtsi                  |   6 +
 arch/arm/boot/dts/omap5-l4.dtsi               |   2 -
 arch/arm/boot/dts/omap5.dtsi                  |   6 +
 arch/arm/mach-omap2/Makefile                  |   4 +-
 arch/arm/mach-omap2/board-generic.c           |  32 +-
 arch/arm/mach-omap2/common.h                  |   7 +
 arch/arm/mach-omap2/omap_hwmod_2420_data.c    |  20 -
 arch/arm/mach-omap2/omap_hwmod_2430_data.c    |  19 -
 .../omap_hwmod_2xxx_interconnect_data.c       |   8 -
 .../mach-omap2/omap_hwmod_2xxx_ipblock_data.c |  47 --
 .../omap_hwmod_33xx_43xx_common_data.h        |   2 -
 .../omap_hwmod_33xx_43xx_interconnect_data.c  |   8 -
 .../omap_hwmod_33xx_43xx_ipblock_data.c       |  62 --
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c    |  10 -
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c    | 146 +----
 arch/arm/mach-omap2/omap_hwmod_43xx_data.c    |  45 --
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c    |  90 ---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c    |  89 ---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c     | 176 ------
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c    |  74 ---
 arch/arm/mach-omap2/omap_hwmod_common_data.h  |   3 -
 arch/arm/mach-omap2/timer.c                   | 568 +-----------------
 drivers/bus/ti-sysc.c                         |  25 +-
 drivers/clk/ti/clk-816x.c                     |   1 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-ti-32k.c            |  48 +-
 drivers/clocksource/timer-ti-dm-systimer.c    | 468 +++++++++++++++
 include/clocksource/timer-ti-dm.h             |   1 +
 45 files changed, 1016 insertions(+), 1478 deletions(-)
 create mode 100644 drivers/clocksource/timer-ti-dm-systimer.c
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