[U-Boot] [PATCH 0/4] 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(-)

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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- 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(-)
diff --git a/arch/arm/include/asm/arch-omap4/clock.h b/arch/arm/include/asm/arch-omap4/clock.h index 037045ca31..ba92ca8ee9 100644 --- a/arch/arm/include/asm/arch-omap4/clock.h +++ b/arch/arm/include/asm/arch-omap4/clock.h @@ -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]; diff --git a/arch/arm/include/asm/arch-omap5/clock.h b/arch/arm/include/asm/arch-omap5/clock.h index e261bd43f2..b5da576e70 100644 --- a/arch/arm/include/asm/arch-omap5/clock.h +++ b/arch/arm/include/asm/arch-omap5/clock.h @@ -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)
diff --git a/include/configs/ti_omap4_common.h b/include/configs/ti_omap4_common.h index 33761c65e9..53982f0246 100644 --- a/include/configs/ti_omap4_common.h +++ b/include/configs/ti_omap4_common.h @@ -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
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index 8bf4a6b7e9..6ae725d413 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -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 */

On Thu, Aug 16, 2018 at 06:26:52PM +0530, Lokesh Vutla wrote:
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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
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.

On Friday 17 August 2018 06:24 AM, Tom Rini wrote:
On Thu, Aug 16, 2018 at 06:26:52PM +0530, Lokesh Vutla wrote:
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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
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.
okay. patch 3/4 and 4/4 are independent of this and are still valid. Any objections on them?
Thanks and regards, Lokesh

On Fri, Aug 17, 2018 at 11:22:22AM +0530, Lokesh Vutla wrote:
On Friday 17 August 2018 06:24 AM, Tom Rini wrote:
On Thu, Aug 16, 2018 at 06:26:52PM +0530, Lokesh Vutla wrote:
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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
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.
okay. patch 3/4 and 4/4 are independent of this and are still valid. Any objections on them?
Nope, those are fine. Thanks!

asm/arch/clock.h is not used by timer driver anymore. So drop this header file.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- drivers/timer/omap-timer.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index 3f847984cb..313eda54b5 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -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 */

In order to handle counter overflows use 64 bit values for counter. Also load the initial value during probe.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- drivers/timer/omap-timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index 313eda54b5..b8f52ef2e4 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -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);

On Thu, Aug 16, 2018 at 06:26:54PM +0530, Lokesh Vutla wrote:
In order to handle counter overflows use 64 bit values for counter. Also load the initial value during probe.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Applied to u-boot/master, thanks!

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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- drivers/timer/omap-timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index b8f52ef2e4..59154b5158 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -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);

On Thu, Aug 16, 2018 at 06:26:55PM +0530, Lokesh Vutla wrote:
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.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Applied to u-boot/master, thanks!
participants (2)
-
Lokesh Vutla
-
Tom Rini