Skip to contentSkip to conversation

sh: sh7723: ap325rxa: Drop duplicate HIZCRB macro

PATCH New Marek Vasut 1 participant 11 messages Aug 30, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/11 sh: sh7723: ap325rxa: Drop duplicate HIZCRB macro

Drop the macro as it is defined in sh7723.h already.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 board/renesas/ap325rxa/cpld-ap325rxa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
board/renesas/ap325rxa/cpld-ap325rxa.c +1 -3
index 16fadcbca7..5d9dc9387e 100644
@@ -61,8 +61,6 @@
 #define CPLD_DONE_ADR	((vu_char *)0xA4050132)
 #define CPLD_DONE_DAT	0x20
 
-#define	HIZCRB			((vu_short *)0xA405015A)
-
 /* data */
 #define CPLD_NOMAL_START	0xA0A80000
 #define CPLD_SAFE_START		0xA0AC0000
@@ -191,7 +189,7 @@ void init_cpld(void)
 	if (*CPLD_DONE_ADR & CPLD_DONE_DAT)	/* Already DONE */
 		return;
 
-	*HIZCRB = 0x0000;
+	*((vu_short *)HIZCRB) = 0x0000;
 	*CPLD_PFC_ADR = 0x7c00;			/* FPGA PROG = OUTPUT */
 
 	/* write CPLD data from NOR flash to device */
Signature · 1 line
2.18.0
#1 lore raw

PATCH 2/11 sh: sh7724: Drop EDMR macro

Drop the macro as it is never used and it collides with sh_eth.h macros.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 arch/sh/include/asm/cpu_sh7724.h | 3 ---
 1 file changed, 3 deletions(-)
arch/sh/include/asm/cpu_sh7724.h +0 -3
index 7a81e1677e..7b217959ed 100644
@@ -203,9 +203,6 @@
 #define PYDR        0xA405016A
 #define PZDR        0xA405016C
 
-/* Ether */
-#define EDMR		0xA4600000
-
 /* UBC */
 /* H-UDI */
 
Signature · 1 line
2.18.0
#2 lore raw

PATCH 3/11 sh: tmu: Clean up CONFIG_SYS_TMU_CLK_DIV

In reply to Marek Vasut

This constant is always 4 , for all boards that exist. Define it once in arch/sh/lib/time.c and remove it from the configs.

---
 arch/sh/lib/time.c                 | 1 +
 include/configs/MigoR.h            | 1 -
 include/configs/alt.h              | 1 -
 include/configs/ap325rxa.h         | 1 -
 include/configs/ap_sh4a_4a.h       | 1 -
 include/configs/armadillo-800eva.h | 1 -
 include/configs/blanche.h          | 1 -
 include/configs/ecovec.h           | 1 -
 include/configs/espt.h             | 1 -
 include/configs/gose.h             | 1 -
 include/configs/koelsch.h          | 1 -
 include/configs/lager.h            | 1 -
 include/configs/mpr2.h             | 1 -
 include/configs/ms7720se.h         | 1 -
 include/configs/ms7722se.h         | 1 -
 include/configs/ms7750se.h         | 1 -
 include/configs/porter.h           | 1 -
 include/configs/r0p7734.h          | 1 -
 include/configs/r2dplus.h          | 1 -
 include/configs/r7780mp.h          | 1 -
 include/configs/sh7752evb.h        | 1 -
 include/configs/sh7753evb.h        | 1 -
 include/configs/sh7757lcr.h        | 1 -
 include/configs/sh7763rdp.h        | 1 -
 include/configs/sh7785lcr.h        | 1 -
 include/configs/shmin.h            | 1 -
 include/configs/silk.h             | 1 -
 include/configs/stout.h            | 1 -
 scripts/config_whitelist.txt       | 1 -
 29 files changed, 1 insertion(+), 28 deletions(-)
arch/sh/lib/time.c +1 -0
index eb642969aa..aac79889dc 100644
@@ -16,6 +16,7 @@
 #include <sh_tmu.h>
 
 #define TCR_TPSC 0x07
+#define CONFIG_SYS_TMU_CLK_DIV	4
 
 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
include/configs/MigoR.h +0 -1
index 5cb23482fe..57e36e8605 100644
@@ -93,6 +93,5 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		(4)	/* 4 (default), 16, 64, 256 or 1024 */
 
 #endif	/* __MIGO_R_H */
include/configs/alt.h +0 -1
index d44a0b3007..d884831d96 100644
@@ -39,7 +39,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/ap325rxa.h +0 -1
index 8680eb6ef5..a6e6a436b0 100644
@@ -114,6 +114,5 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		(4)	/* 4 (default), 16, 64, 256 or 1024 */
 
 #endif	/* __AP325RXA_H */
include/configs/ap_sh4a_4a.h +0 -1
index a4bdd44a9e..c8e22de4b8 100644
@@ -102,6 +102,5 @@
 #endif
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV      4
 
 #endif	/* __AP_SH4A_4A_H */
include/configs/armadillo-800eva.h +0 -1
index c0e1740219..f14ea9a4b1 100644
@@ -93,6 +93,5 @@
 #define CONFIG_SYS_CLK_FREQ	50000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #endif	/* __ARMADILLO_800EVA_H */
include/configs/blanche.h +0 -1
index 6df0e9bcc0..7a5abf99de 100644
@@ -53,7 +53,6 @@
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2) /* EXT / 2 */
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 /* ENV setting */
 #if !defined(CONFIG_MTD_NOR_FLASH)
include/configs/ecovec.h +0 -1
index e99564dbdf..9084d2e4c3 100644
@@ -133,6 +133,5 @@
 #define CONFIG_SYS_CLK_FREQ 41666666
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV      4
 
 #endif	/* __ECOVEC_H */
include/configs/espt.h +0 -1
index 978a9e006b..fe8b84c7a5 100644
@@ -71,7 +71,6 @@
 #define CONFIG_SYS_CLK_FREQ	66666666
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV      4
 
 /* Ether */
 #define CONFIG_SH_ETHER_USE_PORT (1)
include/configs/gose.h +0 -1
index 00523d2fc4..53d9322967 100644
@@ -35,7 +35,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/koelsch.h +0 -1
index e5e667ce33..2479b7c74a 100644
@@ -35,7 +35,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/lager.h +0 -1
index ebcd179ffd..4bff60fbe3 100644
@@ -36,7 +36,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/mpr2.h +0 -1
index c6023a1e1b..762d83c0e5 100644
@@ -51,7 +51,6 @@
 #define CONFIG_SYS_CLK_FREQ	24000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4	/* 4 (default), 16, 64, 256 or 1024 */
 
 /* UART */
 #define CONFIG_CONS_SCIF0	1
include/configs/ms7720se.h +0 -1
index e7179705c9..60cc3efcdc 100644
@@ -62,7 +62,6 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4	/* 4 (default), 16, 64, 256 or 1024 */
 
 /* PCMCIA */
 #define CONFIG_IDE_PCMCIA	1
include/configs/ms7722se.h +0 -1
index 12327641fb..8a5fa97b3d 100644
@@ -84,6 +84,5 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		(4)	/* 4 (default), 16, 64, 256 or 1024 */
 
 #endif	/* __MS7722SE_H */
include/configs/ms7750se.h +0 -1
index b2cb6bab7c..4cad167205 100644
@@ -64,6 +64,5 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4
 
 #endif /* __MS7750SE_H */
include/configs/porter.h +0 -1
index 42b9073006..be1b5ff7f0 100644
@@ -40,7 +40,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/r0p7734.h +0 -1
index 523764d8e9..9c4468ce70 100644
@@ -100,6 +100,5 @@
 #endif
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV      4
 
 #endif	/* __R0P7734_H */
include/configs/r2dplus.h +0 -1
index 129dcf3398..33a4420cd2 100644
@@ -48,7 +48,6 @@
 #define CONFIG_SYS_CLK_FREQ	60000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4
 #define	CONFIG_SYS_PLL_SETTLING_TIME	100/* in us */
 
 /*
include/configs/r7780mp.h +0 -1
index 8068ca7957..a89e621b86 100644
@@ -73,7 +73,6 @@
 #define CONFIG_SYS_CLK_FREQ	33333333
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4
 
 /* PCI Controller */
 #if defined(CONFIG_CMD_PCI)
include/configs/sh7752evb.h +0 -1
index 9b40e0f063..289630a9ee 100644
@@ -77,5 +77,4 @@
 #define CONFIG_SYS_CLK_FREQ	48000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV	4
 #endif	/* __SH7752EVB_H */
include/configs/sh7753evb.h +0 -1
index 080b4055cf..b58673a230 100644
@@ -77,5 +77,4 @@
 #define CONFIG_SYS_CLK_FREQ	48000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV	4
 #endif	/* __SH7753EVB_H */
include/configs/sh7757lcr.h +0 -1
index 95d70bc6e7..78606f3f6c 100644
@@ -89,5 +89,4 @@
 #define CONFIG_SYS_CLK_FREQ	48000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV	4
 #endif	/* __SH7757LCR_H */
include/configs/sh7763rdp.h +0 -1
index 4015fb2d2a..53fe45009e 100644
@@ -71,7 +71,6 @@
 #define CONFIG_SYS_CLK_FREQ	66666666
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		(4)	/* 4 (default), 16, 64, 256 or 1024 */
 
 /* Ether */
 #define CONFIG_SH_ETHER_USE_PORT (1)
include/configs/sh7785lcr.h +0 -1
index 38ae66b90c..6585298f18 100644
@@ -128,6 +128,5 @@
 #define CONFIG_SYS_CLK_FREQ	50000000
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV		4
 
 #endif	/* __SH7785LCR_H */
include/configs/shmin.h +0 -1
index aada22df5c..df98f5566c 100644
@@ -80,7 +80,6 @@
 #endif /* CONFIG_T_SH7706LSR */
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 /* Network device */
 #define CONFIG_DRIVER_NE2000
include/configs/silk.h +0 -1
index 549aa79233..ad14c5ccf2 100644
@@ -40,7 +40,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/stout.h +0 -1
index eab0ef213a..cc1cc84fc0 100644
@@ -44,7 +44,6 @@
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
 #define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
 
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
scripts/config_whitelist.txt +0 -1
index fc37099cbe..c2f3782fe4 100644
@@ -4277,7 +4277,6 @@ CONFIG_SYS_TMRINTR_PEND
 CONFIG_SYS_TMRINTR_PRI
 CONFIG_SYS_TMRPND_REG
 CONFIG_SYS_TMR_BASE
-CONFIG_SYS_TMU_CLK_DIV
 CONFIG_SYS_TSEC1
 CONFIG_SYS_TSEC1_OFFSET
 CONFIG_SYS_TSEC2
Signature · 1 line
2.18.0
#3 lore raw

PATCH 4/11 sh: tmu: Simplify the tmu_bit math

In reply to Marek Vasut

The tmu_bit value evaluates to (ffs(4) >> 1) - 1 = (3 >> 1) - 1 = 0. Just drop the tmu_bit completely as well as CONFIG_SYS_TMU_CLK_DIV.

---
 arch/sh/lib/time.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
arch/sh/lib/time.c +2 -5
index aac79889dc..302f6bed83 100644
@@ -16,14 +16,12 @@
 #include <sh_tmu.h>
 
 #define TCR_TPSC 0x07
-#define CONFIG_SYS_TMU_CLK_DIV	4
 
 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
 unsigned long get_tbclk(void)
 {
-	u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
-	return get_tmu0_clk_rate() >> ((tmu_bit + 1) * 2);
+	return get_tmu0_clk_rate() >> 2;
 }
 
 unsigned long timer_read_counter(void)
@@ -47,8 +45,7 @@ static void tmu_timer_stop(unsigned int timer)
 
 int timer_init(void)
 {
-	u16 tmu_bit = (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1;
-	writew((readw(&tmu->tcr0) & ~TCR_TPSC) | tmu_bit, &tmu->tcr0);
+	writew(readw(&tmu->tcr0) & ~TCR_TPSC, &tmu->tcr0);
 
 	tmu_timer_stop(0);
 	tmu_timer_start(0);
Signature · 1 line
2.18.0
#4 lore raw

PATCH 5/11 sh: tmu: Inline tmu_timer_{start,stop}()

In reply to Marek Vasut

These functions are always called for timer = 0, so drop the timer check. Since these functions are called from one place only and they are reduced to one line of code, just inline them.

---
 arch/sh/lib/time.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
arch/sh/lib/time.c +3 -17
index 302f6bed83..6273f39f21 100644
@@ -16,6 +16,7 @@
 #include <sh_tmu.h>
 
 #define TCR_TPSC 0x07
+#define TSTR_STR0	BIT(0)
 
 static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
@@ -29,26 +30,11 @@ unsigned long timer_read_counter(void)
 	return ~readl(&tmu->tcnt0);
 }
 
-static void tmu_timer_start(unsigned int timer)
-{
-	if (timer > 2)
-		return;
-	writeb(readb(&tmu->tstr) | (1 << timer), &tmu->tstr);
-}
-
-static void tmu_timer_stop(unsigned int timer)
-{
-	if (timer > 2)
-		return;
-	writeb(readb(&tmu->tstr) & ~(1 << timer), &tmu->tstr);
-}
-
 int timer_init(void)
 {
 	writew(readw(&tmu->tcr0) & ~TCR_TPSC, &tmu->tcr0);
-
-	tmu_timer_stop(0);
-	tmu_timer_start(0);
+	writeb(readb(&tmu->tstr) & ~TSTR_STR0, &tmu->tstr);
+	writeb(readb(&tmu->tstr) | TSTR_STR0, &tmu->tstr);
 
 	return 0;
 }
Signature · 1 line
2.18.0
#5 lore raw

PATCH 6/11 sh: tmu: Inline get_tmu0_clk_rate()

In reply to Marek Vasut

This function just returns CONFIG_SH_TMU_CLK_FREQ, use the constant directly instead.

---
 arch/sh/lib/time.c | 2 +-
 include/sh_tmu.h   | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
arch/sh/lib/time.c +1 -1
index 6273f39f21..0f3127106a 100644
@@ -22,7 +22,7 @@ static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
 unsigned long get_tbclk(void)
 {
-	return get_tmu0_clk_rate() >> 2;
+	return CONFIG_SH_TMU_CLK_FREQ / 4;
 }
 
 unsigned long timer_read_counter(void)
include/sh_tmu.h +0 -5
index aa60c98750..70aca2149a 100644
@@ -67,9 +67,4 @@ struct tmu_regs {
 };
 #endif /* CONFIG_CPU_SH4 */
 
-static inline unsigned long get_tmu0_clk_rate(void)
-{
-	return CONFIG_SH_TMU_CLK_FREQ;
-}
-
 #endif	/* __SH_TMU_H */
Signature · 1 line
2.18.0
#6 lore raw

PATCH 7/11 sh: tmu: Clean up CONFIG_SH_TMU_CLK_FREQ

In reply to Marek Vasut

The R-Car Gen2 feeds the TMU with CONFIG_SYS_CLK_FREQ / 2, while the old SH parts use CONFIG_SYS_CLK_FREQ directly. Just put this into the TMU implementation and drop the CONFIG_SH_TMU_CLK_FREQ config option.

---
 arch/sh/lib/time.c                 | 6 +++++-
 include/configs/MigoR.h            | 1 -
 include/configs/alt.h              | 2 --
 include/configs/ap325rxa.h         | 1 -
 include/configs/ap_sh4a_4a.h       | 1 -
 include/configs/armadillo-800eva.h | 1 -
 include/configs/blanche.h          | 1 -
 include/configs/ecovec.h           | 1 -
 include/configs/espt.h             | 1 -
 include/configs/gose.h             | 2 --
 include/configs/koelsch.h          | 2 --
 include/configs/lager.h            | 2 --
 include/configs/mpr2.h             | 1 -
 include/configs/ms7720se.h         | 1 -
 include/configs/ms7722se.h         | 1 -
 include/configs/ms7750se.h         | 1 -
 include/configs/porter.h           | 2 --
 include/configs/r0p7734.h          | 1 -
 include/configs/r2dplus.h          | 1 -
 include/configs/r7780mp.h          | 1 -
 include/configs/rsk7203.h          | 1 -
 include/configs/rsk7264.h          | 1 -
 include/configs/rsk7269.h          | 1 -
 include/configs/sh7752evb.h        | 1 -
 include/configs/sh7753evb.h        | 1 -
 include/configs/sh7757lcr.h        | 1 -
 include/configs/sh7763rdp.h        | 1 -
 include/configs/sh7785lcr.h        | 1 -
 include/configs/shmin.h            | 1 -
 include/configs/silk.h             | 2 --
 include/configs/stout.h            | 2 --
 31 files changed, 5 insertions(+), 38 deletions(-)
arch/sh/lib/time.c +5 -1
index 0f3127106a..9a1d3fb013 100644
@@ -22,7 +22,11 @@ static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
 
 unsigned long get_tbclk(void)
 {
-	return CONFIG_SH_TMU_CLK_FREQ / 4;
+#ifdef CONFIG_RCAR_GEN2
+	return CONFIG_SYS_CLK_FREQ / 8;
+#else
+	return CONFIG_SYS_CLK_FREQ / 4;
+#endif
 }
 
 unsigned long timer_read_counter(void)
include/configs/MigoR.h +0 -1
index 57e36e8605..1ff04c3794 100644
@@ -91,7 +91,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __MIGO_R_H */
include/configs/alt.h +0 -2
index d884831d96..cc6a7bf638 100644
@@ -37,8 +37,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/ap325rxa.h +0 -1
index a6e6a436b0..40a843a95e 100644
@@ -112,7 +112,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __AP325RXA_H */
include/configs/ap_sh4a_4a.h +0 -1
index c8e22de4b8..b9ff965b92 100644
@@ -100,7 +100,6 @@
 #else
 #define CONFIG_SYS_CLK_FREQ 44444444
 #endif
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __AP_SH4A_4A_H */
include/configs/armadillo-800eva.h +0 -1
index f14ea9a4b1..b17d597766 100644
@@ -91,7 +91,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	50000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __ARMADILLO_800EVA_H */
include/configs/blanche.h +0 -1
index 7a5abf99de..e0acde3f91 100644
@@ -52,7 +52,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2) /* EXT / 2 */
 
 /* ENV setting */
 #if !defined(CONFIG_MTD_NOR_FLASH)
include/configs/ecovec.h +0 -1
index 9084d2e4c3..1e358ec6ad 100644
@@ -131,7 +131,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ 41666666
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __ECOVEC_H */
include/configs/espt.h +0 -1
index fe8b84c7a5..6bb23c6ad4 100644
@@ -69,7 +69,6 @@
 
 /* Clock */
 #define CONFIG_SYS_CLK_FREQ	66666666
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* Ether */
include/configs/gose.h +0 -2
index 53d9322967..36ac88a20d 100644
@@ -33,8 +33,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/koelsch.h +0 -2
index 2479b7c74a..ef26a144a9 100644
@@ -33,8 +33,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/lager.h +0 -2
index 4bff60fbe3..08498c6d81 100644
@@ -34,8 +34,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/mpr2.h +0 -1
index 762d83c0e5..901a302873 100644
@@ -49,7 +49,6 @@
 
 /* Clocks */
 #define CONFIG_SYS_CLK_FREQ	24000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* UART */
include/configs/ms7720se.h +0 -1
index 60cc3efcdc..b159c10bbf 100644
@@ -60,7 +60,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* PCMCIA */
include/configs/ms7722se.h +0 -1
index 8a5fa97b3d..230b86b821 100644
@@ -82,7 +82,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __MS7722SE_H */
include/configs/ms7750se.h +0 -1
index 4cad167205..35849069eb 100644
@@ -62,7 +62,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif /* __MS7750SE_H */
include/configs/porter.h +0 -2
index be1b5ff7f0..e56dc3f1ec 100644
@@ -38,8 +38,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/r0p7734.h +0 -1
index 9c4468ce70..88476850ff 100644
@@ -98,7 +98,6 @@
 #else
 #define CONFIG_SYS_CLK_FREQ 44444444
 #endif
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __R0P7734_H */
include/configs/r2dplus.h +0 -1
index 33a4420cd2..b39b13b7cd 100644
@@ -46,7 +46,6 @@
  * SuperH Clock setting
  */
 #define CONFIG_SYS_CLK_FREQ	60000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define	CONFIG_SYS_PLL_SETTLING_TIME	100/* in us */
 
include/configs/r7780mp.h +0 -1
index a89e621b86..a819e1bfb3 100644
@@ -71,7 +71,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* PCI Controller */
include/configs/rsk7203.h +0 -1
index a40b7bae21..ef2b79e2e0 100644
@@ -58,7 +58,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	33333333
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER	32	/* 8 (default), 32, 128 or 512 */
 #define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
include/configs/rsk7264.h +0 -1
index b936b13df1..54ca87996b 100644
@@ -47,7 +47,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	36000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER		32	/* 8 (default), 32, 128 or 512 */
 #define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
include/configs/rsk7269.h +0 -1
index 0c0b773858..f8e66e67da 100644
@@ -46,7 +46,6 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	66125000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER		32	/* 8 (default), 32, 128 or 512 */
 #define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
include/configs/sh7752evb.h +0 -1
index 289630a9ee..1f29e3d221 100644
@@ -75,6 +75,5 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	48000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #endif	/* __SH7752EVB_H */
include/configs/sh7753evb.h +0 -1
index b58673a230..0693fb5a3c 100644
@@ -75,6 +75,5 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	48000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #endif	/* __SH7753EVB_H */
include/configs/sh7757lcr.h +0 -1
index 78606f3f6c..05b2f01c15 100644
@@ -87,6 +87,5 @@
 
 /* Board Clock */
 #define CONFIG_SYS_CLK_FREQ	48000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #endif	/* __SH7757LCR_H */
include/configs/sh7763rdp.h +0 -1
index 53fe45009e..2aefc69606 100644
@@ -69,7 +69,6 @@
 
 /* Clock */
 #define CONFIG_SYS_CLK_FREQ	66666666
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* Ether */
include/configs/sh7785lcr.h +0 -1
index 6585298f18..6cb0ef3389 100644
@@ -126,7 +126,6 @@
 /* Board Clock */
 /* The SCIF used external clock. system clock only used timer. */
 #define CONFIG_SYS_CLK_FREQ	50000000
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 #endif	/* __SH7785LCR_H */
include/configs/shmin.h +0 -1
index df98f5566c..5eabdf5bb0 100644
@@ -78,7 +78,6 @@
 #else
 #define CONFIG_SYS_CLK_FREQ 33333333
 #endif /* CONFIG_T_SH7706LSR */
-#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 
 /* Network device */
include/configs/silk.h +0 -2
index ad14c5ccf2..a94928bd16 100644
@@ -38,8 +38,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
include/configs/stout.h +0 -2
index cc1cc84fc0..b72b565c33 100644
@@ -42,8 +42,6 @@
 /* Board Clock */
 #define RMOBILE_XTAL_CLK	20000000u
 #define CONFIG_SYS_CLK_FREQ	RMOBILE_XTAL_CLK
-#define CONFIG_SH_TMU_CLK_FREQ	(CONFIG_SYS_CLK_FREQ / 2)
-
 
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"fdt_high=0xffffffff\0"		\
Signature · 1 line
2.18.0
#7 lore raw

PATCH 8/11 sh: tmu: Inline sh_tmu.h

In reply to Marek Vasut

The header contains only the TMU register layout, just inline it into the TMU timer implementation and drop the header completely.

---
 arch/sh/lib/time.c | 43 +++++++++++++++++++++++++++-
 include/sh_tmu.h   | 70 ----------------------------------------------
 2 files changed, 42 insertions(+), 71 deletions(-)
 delete mode 100644 include/sh_tmu.h
arch/sh/lib/time.c +42 -1
index 9a1d3fb013..a650c9478c 100644
@@ -13,7 +13,48 @@
 #include <common.h>
 #include <asm/processor.h>
 #include <asm/io.h>
-#include <sh_tmu.h>
+
+#if defined(CONFIG_CPU_SH3)
+struct tmu_regs {
+	u8	tocr;
+	u8	reserved0;
+	u8	tstr;
+	u8	reserved1;
+	u32	tcor0;
+	u32	tcnt0;
+	u16	tcr0;
+	u16	reserved2;
+	u32	tcor1;
+	u32	tcnt1;
+	u16	tcr1;
+	u16	reserved3;
+	u32	tcor2;
+	u32	tcnt2;
+	u16	tcr2;
+	u16	reserved4;
+	u32	tcpr2;
+};
+#endif /* CONFIG_CPU_SH3 */
+
+#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
+struct tmu_regs {
+	u32	reserved;
+	u8	tstr;
+	u8	reserved2[3];
+	u32	tcor0;
+	u32	tcnt0;
+	u16	tcr0;
+	u16	reserved3;
+	u32	tcor1;
+	u32	tcnt1;
+	u16	tcr1;
+	u16	reserved4;
+	u32	tcor2;
+	u32	tcnt2;
+	u16	tcr2;
+	u16	reserved5;
+};
+#endif /* CONFIG_CPU_SH4 */
 
 #define TCR_TPSC 0x07
 #define TSTR_STR0	BIT(0)
include/sh_tmu.h deleted +0 -70

70 lines not on this page · raw message

Signature · 1 line
2.18.0
#8 lore raw

PATCH 9/11 sh: tmu: Clean up register usage

In reply to Marek Vasut

The code uses all in all three TMU registers, drop the massive register layout structures and just define the required timer registers and use them throughout the code.

---
 arch/sh/lib/time.c | 54 ++++++++++------------------------------------
 1 file changed, 11 insertions(+), 43 deletions(-)
arch/sh/lib/time.c +11 -43
index a650c9478c..d531a4958e 100644
@@ -15,52 +15,20 @@
 #include <asm/io.h>
 
 #if defined(CONFIG_CPU_SH3)
-struct tmu_regs {
-	u8	tocr;
-	u8	reserved0;
-	u8	tstr;
-	u8	reserved1;
-	u32	tcor0;
-	u32	tcnt0;
-	u16	tcr0;
-	u16	reserved2;
-	u32	tcor1;
-	u32	tcnt1;
-	u16	tcr1;
-	u16	reserved3;
-	u32	tcor2;
-	u32	tcnt2;
-	u16	tcr2;
-	u16	reserved4;
-	u32	tcpr2;
-};
+#define TSTR	0x2
+#define TCNT0	0x8
+#define TCR0	0xc
 #endif /* CONFIG_CPU_SH3 */
 
 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
-struct tmu_regs {
-	u32	reserved;
-	u8	tstr;
-	u8	reserved2[3];
-	u32	tcor0;
-	u32	tcnt0;
-	u16	tcr0;
-	u16	reserved3;
-	u32	tcor1;
-	u32	tcnt1;
-	u16	tcr1;
-	u16	reserved4;
-	u32	tcor2;
-	u32	tcnt2;
-	u16	tcr2;
-	u16	reserved5;
-};
+#define TSTR	0x4
+#define TCNT0	0xc
+#define TCR0	0x10
 #endif /* CONFIG_CPU_SH4 */
 
-#define TCR_TPSC 0x07
+#define TCR_TPSC	0x07
 #define TSTR_STR0	BIT(0)
 
-static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE;
-
 unsigned long get_tbclk(void)
 {
 #ifdef CONFIG_RCAR_GEN2
@@ -72,14 +40,14 @@ unsigned long get_tbclk(void)
 
 unsigned long timer_read_counter(void)
 {
-	return ~readl(&tmu->tcnt0);
+	return ~readl(TMU_BASE + TCNT0);
 }
 
 int timer_init(void)
 {
-	writew(readw(&tmu->tcr0) & ~TCR_TPSC, &tmu->tcr0);
-	writeb(readb(&tmu->tstr) & ~TSTR_STR0, &tmu->tstr);
-	writeb(readb(&tmu->tstr) | TSTR_STR0, &tmu->tstr);
+	writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0);
+	writeb(readb(TMU_BASE + TSTR) & ~TSTR_STR0, TMU_BASE + TSTR);
+	writeb(readb(TMU_BASE + TSTR) | TSTR_STR0, TMU_BASE + TSTR);
 
 	return 0;
 }
Signature · 1 line
2.18.0
#9 lore raw

PATCH 10/11 sh: tmu: Zap get_tbclk and timer_read_counter

In reply to Marek Vasut

Replace those two functions with generic ones by defining the timer macros in include/config/*.h .

---
 arch/sh/include/asm/config.h       |  9 +++++++++
 arch/sh/lib/time.c                 | 16 ----------------
 include/configs/armadillo-800eva.h |  3 +++
 include/configs/rcar-gen2-common.h |  7 ++++++-
 4 files changed, 18 insertions(+), 17 deletions(-)
arch/sh/include/asm/config.h +9 -0
index bad0026648..d2862df4a5 100644
@@ -6,4 +6,13 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if !defined(CONFIG_CPU_SH2)
+#include <asm/processor.h>
+
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTS_DOWN
+#define CONFIG_SYS_TIMER_COUNTER	(TMU_BASE + 0x8)	/* TCNT0 */
+#define CONFIG_SYS_TIMER_RATE		(CONFIG_SYS_CLK_FREQ / 4)
+#endif
+
 #endif
arch/sh/lib/time.c +0 -16
index d531a4958e..fb317f95d5 100644
@@ -16,33 +16,17 @@
 
 #if defined(CONFIG_CPU_SH3)
 #define TSTR	0x2
-#define TCNT0	0x8
 #define TCR0	0xc
 #endif /* CONFIG_CPU_SH3 */
 
 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RMOBILE)
 #define TSTR	0x4
-#define TCNT0	0xc
 #define TCR0	0x10
 #endif /* CONFIG_CPU_SH4 */
 
 #define TCR_TPSC	0x07
 #define TSTR_STR0	BIT(0)
 
-unsigned long get_tbclk(void)
-{
-#ifdef CONFIG_RCAR_GEN2
-	return CONFIG_SYS_CLK_FREQ / 8;
-#else
-	return CONFIG_SYS_CLK_FREQ / 4;
-#endif
-}
-
-unsigned long timer_read_counter(void)
-{
-	return ~readl(TMU_BASE + TCNT0);
-}
-
 int timer_init(void)
 {
 	writew(readw(TMU_BASE + TCR0) & ~TCR_TPSC, TMU_BASE + TCR0);
include/configs/armadillo-800eva.h +3 -0
index b17d597766..3c6b2c3cd7 100644
@@ -18,6 +18,9 @@
 
 #define CONFIG_ARCH_CPU_INIT
 #define CONFIG_TMU_TIMER
+#define CONFIG_SYS_TIMER_COUNTS_DOWN
+#define CONFIG_SYS_TIMER_COUNTER	(TMU_BASE + 0xc)	/* TCNT0 */
+#define CONFIG_SYS_TIMER_RATE		(CONFIG_SYS_CLK_FREQ / 4)
 #define CONFIG_SYS_DCACHE_OFF
 
 /* STACK */
include/configs/rcar-gen2-common.h +6 -1
index 2a5cd6b832..d606da8b0e 100644
@@ -22,7 +22,6 @@
 
 #define CONFIG_ARCH_CPU_INIT
 
-#define CONFIG_TMU_TIMER
 #ifndef CONFIG_PINCTRL_PFC
 #define CONFIG_SH_GPIO_PFC
 #endif
@@ -57,4 +56,10 @@
 #undef CONFIG_SPI_FLASH_MTD
 #endif
 
+/* Timer */
+#define CONFIG_TMU_TIMER
+#define CONFIG_SYS_TIMER_COUNTS_DOWN
+#define CONFIG_SYS_TIMER_COUNTER	(TMU_BASE + 0xc)	/* TCNT0 */
+#define CONFIG_SYS_TIMER_RATE		(CONFIG_SYS_CLK_FREQ / 8)
+
 #endif	/* __RCAR_GEN2_COMMON_H */
Signature · 1 line
2.18.0
#10 lore raw

PATCH 11/11 ARM: rmobile: Repair TMU clock on Gen2

In reply to Marek Vasut

The Gen2 TMU is fed with fixed 32.5 MHz signal from CP . This is then divided by 4 in TMU. Fix the timer clock setting in Gen2.

---
 include/configs/rcar-gen2-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/rcar-gen2-common.h +1 -1
index d606da8b0e..01583f8cc2 100644
@@ -60,6 +60,6 @@
 #define CONFIG_TMU_TIMER
 #define CONFIG_SYS_TIMER_COUNTS_DOWN
 #define CONFIG_SYS_TIMER_COUNTER	(TMU_BASE + 0xc)	/* TCNT0 */
-#define CONFIG_SYS_TIMER_RATE		(CONFIG_SYS_CLK_FREQ / 8)
+#define CONFIG_SYS_TIMER_RATE		(32500000 / 4)		/* CP/4 */
 
 #endif	/* __RCAR_GEN2_COMMON_H */
Signature · 1 line
2.18.0