Skip to contentSkip to conversation

dm: omap-timer: Make timer driver SoC independent

PATCH New Lokesh Vutla 2 participants 10 messages Aug 16, 2018 – Sep 11, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover dm: omap-timer: Make timer driver SoC independent

Make omap timer driver independent of SoC, so that new generation TI SoCs can use this driver without any dependencies.

Lokesh Vutla (4):
arm: omap4+: Move SCLK to include/configs
dm: omap-timer: Do not include asm/arch/clock.h
dm: omap-timer: Use 64bit for counter values
dm: omap-timer: Update clock rate only if not populated

 arch/arm/include/asm/arch-omap4/clock.h | 4 ----
 arch/arm/include/asm/arch-omap5/clock.h | 8 --------
 drivers/timer/omap-timer.c              | 7 ++++---
 include/configs/ti_omap4_common.h       | 4 ++++
 include/configs/ti_omap5_common.h       | 8 ++++++++
 5 files changed, 16 insertions(+), 15 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/4 arm: omap4+: Move SCLK to include/configs

Similar to every other SoCs define oscillator clock definitions for OMAP4+ SoCs to include/configs/. This will allow to not depend on SoC clock.h header file for getting default timer frequency.

---
 arch/arm/include/asm/arch-omap4/clock.h | 4 ----
 arch/arm/include/asm/arch-omap5/clock.h | 8 --------
 include/configs/ti_omap4_common.h       | 4 ++++
 include/configs/ti_omap5_common.h       | 8 ++++++++
 4 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/include/asm/arch-omap4/clock.h +0 -4
index 037045ca31..ba92ca8ee9 100644
@@ -205,10 +205,6 @@
 #define DPLL_NO_LOCK	0
 #define DPLL_LOCK	1
 
-/* Clock Defines */
-#define V_OSCK			38400000	/* Clock output from T2 */
-#define V_SCLK                   V_OSCK
-
 struct omap4_scrm_regs {
 	u32 revision;           /* 0x0000 */
 	u32 pad00[63];
arch/arm/include/asm/arch-omap5/clock.h +0 -8
index e261bd43f2..b5da576e70 100644
@@ -391,14 +391,6 @@
 #define DPLL_NO_LOCK	0
 #define DPLL_LOCK	1
 
-#if defined(CONFIG_DRA7XX)
-#define V_OSCK			20000000	/* Clock output from T2 */
-#else
-#define V_OSCK			19200000	/* Clock output from T2 */
-#endif
-
-#define V_SCLK	V_OSCK
-
 /* CKO buffer control */
 #define CKOBUFFER_CLK_ENABLE_MASK	(1 << 28)
 
include/configs/ti_omap4_common.h +4 -0
index 33761c65e9..53982f0246 100644
@@ -22,6 +22,10 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/omap.h>
 
+/* Clock Defines */
+#define V_OSCK			38400000	/* Clock output from T2 */
+#define V_SCLK                   V_OSCK
+
 /* Use General purpose timer 1 */
 #define CONFIG_SYS_TIMERBASE		GPT2_BASE
 
include/configs/ti_omap5_common.h +8 -0
index 8bf4a6b7e9..6ae725d413 100644
@@ -37,6 +37,14 @@
 
 #include <configs/ti_armv7_omap.h>
 
+#if defined(CONFIG_DRA7XX)
+#define V_OSCK			20000000	/* Clock output from T2 */
+#else
+#define V_OSCK			19200000	/* Clock output from T2 */
+#endif
+
+#define V_SCLK	V_OSCK
+
 /*
  * Hardware drivers
  */
Signature · 1 line
2.18.0
#2 lore raw

PATCH 1/4 arm: omap4+: Move SCLK to include/configs

Quoted 11 lines · Lokesh Vutla

Similar to every other SoCs define oscillator clock definitions for OMAP4+ SoCs to include/configs/. This will allow to not depend on SoC clock.h header file for getting default timer frequency.

---
 arch/arm/include/asm/arch-omap4/clock.h | 4 ----
 arch/arm/include/asm/arch-omap5/clock.h | 8 --------
 include/configs/ti_omap4_common.h       | 4 ++++
 include/configs/ti_omap5_common.h       | 8 ++++++++
 4 files changed, 12 insertions(+), 12 deletions(-)

Nak. Long term, include/configs/ files are going away.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180816/8810dac6/attachment.sig>
#3 lore raw

PATCH 1/4 arm: omap4+: Move SCLK to include/configs

Quoted 14 lines · Tom Rini
Quoted 11 lines · Lokesh Vutla

Similar to every other SoCs define oscillator clock definitions for OMAP4+ SoCs to include/configs/. This will allow to not depend on SoC clock.h header file for getting default timer frequency.

---
 arch/arm/include/asm/arch-omap4/clock.h | 4 ----
 arch/arm/include/asm/arch-omap5/clock.h | 8 --------
 include/configs/ti_omap4_common.h       | 4 ++++
 include/configs/ti_omap5_common.h       | 8 ++++++++
 4 files changed, 12 insertions(+), 12 deletions(-)
Quoted 2 lines

Nak. Long term, include/configs/ files are going away.

okay. patch 3/4 and 4/4 are independent of this and are still valid. Any objections on them?

Thanks and regards,
Lokesh

#4 lore raw

PATCH 1/4 arm: omap4+: Move SCLK to include/configs

Quoted 17 lines · Lokesh Vutla
Quoted 14 lines · Tom Rini
Quoted 11 lines · Lokesh Vutla

Similar to every other SoCs define oscillator clock definitions for OMAP4+ SoCs to include/configs/. This will allow to not depend on SoC clock.h header file for getting default timer frequency.

---
 arch/arm/include/asm/arch-omap4/clock.h | 4 ----
 arch/arm/include/asm/arch-omap5/clock.h | 8 --------
 include/configs/ti_omap4_common.h       | 4 ++++
 include/configs/ti_omap5_common.h       | 8 ++++++++
 4 files changed, 12 insertions(+), 12 deletions(-)
Quoted 5 lines
Quoted 2 lines

Nak. Long term, include/configs/ files are going away.

okay. patch 3/4 and 4/4 are independent of this and are still valid. Any objections on them?

Nope, those are fine. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180817/875fa3c8/attachment.sig>
#5 lore raw

PATCH 2/4 dm: omap-timer: Do not include asm/arch/clock.h

In reply to Lokesh Vutla

asm/arch/clock.h is not used by timer driver anymore. So drop this header file.

---
 drivers/timer/omap-timer.c | 1 -
 1 file changed, 1 deletion(-)
drivers/timer/omap-timer.c +0 -1
index 3f847984cb..313eda54b5 100644
@@ -10,7 +10,6 @@
 #include <errno.h>
 #include <timer.h>
 #include <asm/io.h>
-#include <asm/arch/clock.h>
 
 /* Timer register bits */
 #define TCLR_START			BIT(0)	/* Start=1 */
Signature · 1 line
2.18.0
#6 lore raw

PATCH 3/4 dm: omap-timer: Use 64bit for counter values

In reply to Lokesh Vutla

In order to handle counter overflows use 64 bit values for counter. Also load the initial value during probe.

---
 drivers/timer/omap-timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/omap-timer.c +2 -1
index 313eda54b5..b8f52ef2e4 100644
@@ -50,7 +50,7 @@ static int omap_timer_get_count(struct udevice *dev, u64 *count)
 {
 	struct omap_timer_priv *priv = dev_get_priv(dev);
 
-	*count = readl(&priv->regs->tcrr);
+	*count = timer_conv_64(readl(&priv->regs->tcrr));
 
 	return 0;
 }
@@ -64,6 +64,7 @@ static int omap_timer_probe(struct udevice *dev)
 
 	/* start the counter ticking up, reload value on overflow */
 	writel(0, &priv->regs->tldr);
+	writel(0, &priv->regs->tcrr);
 	/* enable timer */
 	writel((CONFIG_SYS_PTV << 2) | TCLR_PRE_EN | TCLR_AUTO_RELOAD |
 	       TCLR_START, &priv->regs->tclr);
Signature · 1 line
2.18.0
#7 lore raw

PATCH 3/4 dm: omap-timer: Use 64bit for counter values

Quoted 4 lines · Lokesh Vutla

In order to handle counter overflows use 64 bit values for counter. Also load the initial value during probe.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/f07562cc/attachment.sig>
#8 lore raw

PATCH 4/4 dm: omap-timer: Update clock rate only if not populated

In reply to Lokesh Vutla

timer_pre_probe() tries to populate the clock rate from DT. omap timer driver tries to overwrite this value irrespective of the value populated fro DT. So update this value only when DT doesn't populate the clock rate.

---
 drivers/timer/omap-timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/omap-timer.c +2 -1
index b8f52ef2e4..59154b5158 100644
@@ -60,7 +60,8 @@ static int omap_timer_probe(struct udevice *dev)
 	struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 	struct omap_timer_priv *priv = dev_get_priv(dev);
 
-	uc_priv->clock_rate = TIMER_CLOCK;
+	if (!uc_priv->clock_rate)
+		uc_priv->clock_rate = TIMER_CLOCK;
 
 	/* start the counter ticking up, reload value on overflow */
 	writel(0, &priv->regs->tldr);
Signature · 1 line
2.18.0
#9 lore raw

PATCH 4/4 dm: omap-timer: Update clock rate only if not populated

Quoted 6 lines · Lokesh Vutla

timer_pre_probe() tries to populate the clock rate from DT. omap timer driver tries to overwrite this value irrespective of the value populated fro DT. So update this value only when DT doesn't populate the clock rate.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/802c0c90/attachment.sig>