Skip to contentSkip to conversation

arm: mvebu: Automatically detect CONFIG_SYS_TCLK

PATCH In review Pali Rohár 4 participants 20 messages Jul 31, 2021 – Aug 16, 2022

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

cover arm: mvebu: Automatically detect CONFIG_SYS_TCLK

This patch series automatically detects CONFIG_SYS_TCLK value, set it in global mach/soc.h file and remove manual CONFIG_SYS_TCLK value from all mvebu/kirkwood board config files.

So it just a cleanup to avoid defining custom macros in board config files which can be automatically detected.

Could you test these patches on a38x and a37x platforms that nothing is broken? I tested them on a38x Turris Omnia.

Pali Rohár (5):
arm: mvebu: a38x: Detect CONFIG_SYS_TCLK from SAR register
arm: mvebu: a37x: Detect CONFIG_SYS_TCLK from SAR register
arm: mvebu: msys: Set CONFIG_SYS_TCLK globally
arm: mvebu: axp: Set CONFIG_SYS_TCLK globally
arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

 arch/arm/mach-kirkwood/include/mach/kw88f6281.h |  2 --
 arch/arm/mach-mvebu/include/mach/soc.h          | 15 ++++++++++-----
 include/configs/clearfog.h                      |  1 -
 include/configs/controlcenterdc.h               |  2 --
 include/configs/crs3xx-98dx3236.h               |  1 -
 include/configs/db-88f6720.h                    |  1 -
 include/configs/db-88f6820-amc.h                |  2 --
 include/configs/db-88f6820-gp.h                 |  2 --
 include/configs/db-mv784mp-gp.h                 |  1 -
 include/configs/db-xc3-24g4xg.h                 |  1 -
 include/configs/ds414.h                         |  1 -
 include/configs/helios4.h                       |  1 -
 include/configs/lacie_kw.h                      |  5 -----
 include/configs/lsxl.h                          |  2 --
 include/configs/maxbcm.h                        |  1 -
 include/configs/theadorable.h                   |  1 -
 include/configs/turris_omnia.h                  |  1 -
 include/configs/x530.h                          |  2 --
 18 files changed, 10 insertions(+), 32 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/5 arm: mvebu: a38x: Detect CONFIG_SYS_TCLK from SAR register

Bit 15 in SAR register specifies if TCLK is running at 200 MHz or 250 MHz. Use this information instead of manual configuration in every board file.

---
 arch/arm/mach-mvebu/include/mach/soc.h | 13 ++++++++-----
 include/configs/clearfog.h             |  1 -
 include/configs/controlcenterdc.h      |  2 --
 include/configs/db-88f6820-amc.h       |  2 --
 include/configs/db-88f6820-gp.h        |  2 --
 include/configs/helios4.h              |  1 -
 include/configs/turris_omnia.h         |  1 -
 include/configs/x530.h                 |  2 --
 8 files changed, 8 insertions(+), 16 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +8 -5
index 3f3b15aa8ab6..cb323aa59a76 100644
@@ -33,11 +33,6 @@
 #define MV_88F68XX_A0_ID	0x4
 #define MV_88F68XX_B0_ID	0xa
 
-/* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-#endif
-
 /* SOC specific definations */
 #define INTREG_BASE		0xd0000000
 #define INTREG_BASE_ADDR_REG	(INTREG_BASE + 0x20080)
@@ -170,6 +165,9 @@
 #define BOOT_FROM_SPI		0x32
 #define BOOT_FROM_MMC		0x30
 #define BOOT_FROM_MMC_ALT	0x31
+
+#define CONFIG_SYS_TCLK		((readl(CONFIG_SAR_REG) & BIT(15)) ? \
+				 200000000 : 250000000)
 #elif defined(CONFIG_ARMADA_MSYS)
 /* SAR values for MSYS */
 #define CONFIG_SAR_REG		(MBUS_DFX_BASE  + 0xf8200)
@@ -207,4 +205,9 @@
 #define BOOT_FROM_SPI		0x3
 #endif
 
+/* TCLK Core Clock definition */
+#ifndef CONFIG_SYS_TCLK
+#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
+#endif
+
 #endif /* _MVEBU_SOC_H */
include/configs/clearfog.h +0 -1
index fbdd2f0a244c..705217067b30 100644
@@ -17,7 +17,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
include/configs/controlcenterdc.h +0 -2
index e81d05aa2e83..d9802d2a3b8d 100644
@@ -20,8 +20,6 @@
  * U-Boot into it.
  */
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
 #define CONFIG_LOADADDR 		1000000
 
 /*
include/configs/db-88f6820-amc.h +0 -2
index 757fbc0b9bcd..83f5b71839e2 100644
@@ -10,8 +10,6 @@
  * High Level Configuration Options (easy to change)
  */
 
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
-
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
 
include/configs/db-88f6820-gp.h +0 -2
index d50eb2c12011..feab46cbcbc5 100644
@@ -10,8 +10,6 @@
  * High Level Configuration Options (easy to change)
  */
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
 /* I2C */
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_I2C_MVTWSI
include/configs/helios4.h +0 -1
index 1368080f036b..b5814ed55cf2 100644
@@ -17,7 +17,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
include/configs/turris_omnia.h +0 -1
index 0a824b79397c..18b9861160b0 100644
@@ -16,7 +16,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
include/configs/x530.h +0 -2
index 515c6e7ff45c..64d68276234c 100644
@@ -12,8 +12,6 @@
 
 #define CONFIG_DISPLAY_BOARDINFO_LATE
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
 /*
  * NS16550 Configuration
  */
Signature · 1 line
2.20.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] arm: mvebu: a38x: Detect CONFIG_SYS_TCLK from SAR register

Quoted 4 lines · Pali Rohár

Bit 15 in SAR register specifies if TCLK is running at 200 MHz or 250 MHz. Use this information instead of manual configuration in every board file.

Thanks,
Stefan

Quoted 128 lines
---
  arch/arm/mach-mvebu/include/mach/soc.h | 13 ++++++++-----
  include/configs/clearfog.h             |  1 -
  include/configs/controlcenterdc.h      |  2 --
  include/configs/db-88f6820-amc.h       |  2 --
  include/configs/db-88f6820-gp.h        |  2 --
  include/configs/helios4.h              |  1 -
  include/configs/turris_omnia.h         |  1 -
  include/configs/x530.h                 |  2 --
  8 files changed, 8 insertions(+), 16 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +8 -5
index 3f3b15aa8ab6..cb323aa59a76 100644
@@ -33,11 +33,6 @@
  #define MV_88F68XX_A0_ID	0x4
  #define MV_88F68XX_B0_ID	0xa
 
-/* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-#endif
-
  /* SOC specific definations */
  #define INTREG_BASE		0xd0000000
  #define INTREG_BASE_ADDR_REG	(INTREG_BASE + 0x20080)
@@ -170,6 +165,9 @@
  #define BOOT_FROM_SPI		0x32
  #define BOOT_FROM_MMC		0x30
  #define BOOT_FROM_MMC_ALT	0x31
+
+#define CONFIG_SYS_TCLK		((readl(CONFIG_SAR_REG) & BIT(15)) ? \
+				 200000000 : 250000000)
  #elif defined(CONFIG_ARMADA_MSYS)
  /* SAR values for MSYS */
  #define CONFIG_SAR_REG		(MBUS_DFX_BASE  + 0xf8200)
@@ -207,4 +205,9 @@
  #define BOOT_FROM_SPI		0x3
  #endif
 
+/* TCLK Core Clock definition */
+#ifndef CONFIG_SYS_TCLK
+#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
+#endif
+
  #endif /* _MVEBU_SOC_H */
include/configs/clearfog.h +0 -1
index fbdd2f0a244c..705217067b30 100644
@@ -17,7 +17,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI
include/configs/controlcenterdc.h +0 -2
index e81d05aa2e83..d9802d2a3b8d 100644
@@ -20,8 +20,6 @@
   * U-Boot into it.
   */
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
  #define CONFIG_LOADADDR 		1000000
 
  /*
include/configs/db-88f6820-amc.h +0 -2
index 757fbc0b9bcd..83f5b71839e2 100644
@@ -10,8 +10,6 @@
   * High Level Configuration Options (easy to change)
   */
 
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
-
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI
 
include/configs/db-88f6820-gp.h +0 -2
index d50eb2c12011..feab46cbcbc5 100644
@@ -10,8 +10,6 @@
   * High Level Configuration Options (easy to change)
   */
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
  /* I2C */
  #define CONFIG_SYS_I2C
  #define CONFIG_SYS_I2C_MVTWSI
include/configs/helios4.h +0 -1
index 1368080f036b..b5814ed55cf2 100644
@@ -17,7 +17,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI
include/configs/turris_omnia.h +0 -1
index 0a824b79397c..18b9861160b0 100644
@@ -16,7 +16,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI
include/configs/x530.h +0 -0
index 515c6e7ff45c..64d68276234c 100644

include/configs/x530.h line 17

Quoted 8 lines
include/configs/x530.h +0 -2
@@ -12,8 +12,6 @@
 
  #define CONFIG_DISPLAY_BOARDINFO_LATE
 
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
-
  /*
   * NS16550 Configuration
   */

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#3 lore raw

PATCH 2/5 arm: mvebu: a37x: Detect CONFIG_SYS_TCLK from SAR register

In reply to Pali Rohár

Bit 20 in SAR register specifies if TCLK is running at 200 MHz or 166 MHz. Use this information instead of manual configuration in every board file.

---
 arch/arm/mach-mvebu/include/mach/soc.h | 3 +++
 include/configs/db-88f6720.h           | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/include/mach/soc.h +3 -0
index cb323aa59a76..eb6906ad8027 100644
@@ -145,6 +145,9 @@
 
 #define BOOT_FROM_UART		0x30
 #define BOOT_FROM_SPI		0x38
+
+#define CONFIG_SYS_TCLK		((readl(CONFIG_SAR_REG) & BIT(20)) ? \
+				 200000000 : 166000000)
 #elif defined(CONFIG_ARMADA_38X)
 /* SAR values for Armada 38x */
 #define CONFIG_SAR_REG		(MVEBU_REGISTER(0x18600))
include/configs/db-88f6720.h +0 -1
index cbb9270f9327..67d8cd42d1c2 100644
@@ -15,7 +15,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
 /* I2C */
 #define CONFIG_SYS_I2C
Signature · 1 line
2.20.1
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] arm: mvebu: a37x: Detect CONFIG_SYS_TCLK from SAR register

Quoted 4 lines · Pali Rohár

Bit 20 in SAR register specifies if TCLK is running at 200 MHz or 166 MHz. Use this information instead of manual configuration in every board file.

Thanks,
Stefan

Quoted 25 lines
---
  arch/arm/mach-mvebu/include/mach/soc.h | 3 +++
  include/configs/db-88f6720.h           | 1 -
  2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/include/mach/soc.h +3 -0
index cb323aa59a76..eb6906ad8027 100644
@@ -145,6 +145,9 @@
 
  #define BOOT_FROM_UART		0x30
  #define BOOT_FROM_SPI		0x38
+
+#define CONFIG_SYS_TCLK		((readl(CONFIG_SAR_REG) & BIT(20)) ? \
+				 200000000 : 166000000)
  #elif defined(CONFIG_ARMADA_38X)
  /* SAR values for Armada 38x */
  #define CONFIG_SAR_REG		(MVEBU_REGISTER(0x18600))
include/configs/db-88f6720.h +0 -0
index cbb9270f9327..67d8cd42d1c2 100644

include/configs/db-88f6720.h line 20

Quoted 7 lines
include/configs/db-88f6720.h +0 -1
@@ -15,7 +15,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
  /* I2C */
  #define CONFIG_SYS_I2C

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#5 lore raw

PATCH 3/5 arm: mvebu: msys: Set CONFIG_SYS_TCLK globally

In reply to Pali Rohár

This mvebu msys platform always uses fixed 200 MHz TCLK. So specify this CONFIG_SYS_TCLK option in msys section of global file soc.h file instead of manual configuration in every board file.

---
 arch/arm/mach-mvebu/include/mach/soc.h | 2 ++
 include/configs/crs3xx-98dx3236.h      | 1 -
 include/configs/db-xc3-24g4xg.h        | 1 -
 3 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +2 -0
index eb6906ad8027..e29c0f32c3de 100644
@@ -187,6 +187,8 @@
 #define BOOT_FROM_NAND		0x1
 #define BOOT_FROM_UART		0x2
 #define BOOT_FROM_SPI		0x3
+
+#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 #else
 /* SAR values for Armada XP */
 #define CONFIG_SAR_REG		(MVEBU_REGISTER(0x18230))
include/configs/crs3xx-98dx3236.h +0 -1
index e2ba7b81263f..3feaa60edad8 100644
@@ -12,7 +12,6 @@
 
 #define CONFIG_SYS_BOOTM_LEN	(64 * 1024 * 1024) /* 64 MB */
 #define CONFIG_SYS_KWD_CONFIG	$(CONFIG_BOARDDIR)/kwbimage.cfg
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
include/configs/db-xc3-24g4xg.h +0 -1
index 0e9ccd9b4419..f04ae487b76a 100644
@@ -11,7 +11,6 @@
  */
 
 #define CONFIG_SYS_KWD_CONFIG	$(CONFIG_BOARDDIR)/kwbimage.cfg
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
 /* USB/EHCI configuration */
 #define CONFIG_EHCI_IS_TDI
Signature · 1 line
2.20.1
Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] arm: mvebu: msys: Set CONFIG_SYS_TCLK globally

Quoted 5 lines · Pali Rohár

This mvebu msys platform always uses fixed 200 MHz TCLK. So specify this CONFIG_SYS_TCLK option in msys section of global file soc.h file instead of manual configuration in every board file.

Thanks,
Stefan

Quoted 37 lines
---
  arch/arm/mach-mvebu/include/mach/soc.h | 2 ++
  include/configs/crs3xx-98dx3236.h      | 1 -
  include/configs/db-xc3-24g4xg.h        | 1 -
  3 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +2 -0
index eb6906ad8027..e29c0f32c3de 100644
@@ -187,6 +187,8 @@
  #define BOOT_FROM_NAND		0x1
  #define BOOT_FROM_UART		0x2
  #define BOOT_FROM_SPI		0x3
+
+#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
  #else
  /* SAR values for Armada XP */
  #define CONFIG_SAR_REG		(MVEBU_REGISTER(0x18230))
include/configs/crs3xx-98dx3236.h +0 -1
index e2ba7b81263f..3feaa60edad8 100644
@@ -12,7 +12,6 @@
 
  #define CONFIG_SYS_BOOTM_LEN	(64 * 1024 * 1024) /* 64 MB */
  #define CONFIG_SYS_KWD_CONFIG	$(CONFIG_BOARDDIR)/kwbimage.cfg
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI
include/configs/db-xc3-24g4xg.h +0 -0
index 0e9ccd9b4419..f04ae487b76a 100644

include/configs/db-xc3-24g4xg.h line 16

Quoted 7 lines
include/configs/db-xc3-24g4xg.h +0 -1
@@ -11,7 +11,6 @@
   */
 
  #define CONFIG_SYS_KWD_CONFIG	$(CONFIG_BOARDDIR)/kwbimage.cfg
-#define CONFIG_SYS_TCLK		200000000	/* 200MHz */
 
  /* USB/EHCI configuration */
  #define CONFIG_EHCI_IS_TDI

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#7 lore raw

PATCH 4/5 arm: mvebu: axp: Set CONFIG_SYS_TCLK globally

In reply to Pali Rohár

This mvebu axp platform always uses fixed 250 MHz TCLK. So specify this CONFIG_SYS_TCLK option in msys section of global file soc.h file instead of manual configuration in every board file.

Now every #if-#else case of soc.h file defines CONFIG_SYS_TCLK, so remove useless default CONFIG_SYS_TCLK value from the end of soc.h file.

---
 arch/arm/mach-mvebu/include/mach/soc.h | 3 ---
 include/configs/db-mv784mp-gp.h        | 1 -
 include/configs/ds414.h                | 1 -
 include/configs/maxbcm.h               | 1 -
 include/configs/theadorable.h          | 1 -
 5 files changed, 7 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +0 -3
index e29c0f32c3de..8e8a4058550e 100644
@@ -208,10 +208,7 @@
 
 #define BOOT_FROM_UART		0x2
 #define BOOT_FROM_SPI		0x3
-#endif
 
-/* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 #endif
 
include/configs/db-mv784mp-gp.h +0 -1
index ef7eebd081f9..f1b79e8a1fb8 100644
@@ -16,7 +16,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* I2C */
 #define CONFIG_SYS_I2C
include/configs/ds414.h +0 -1
index 4bbb244fa227..9fe830965854 100644
@@ -18,7 +18,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* I2C */
 #define CONFIG_SYS_I2C
include/configs/maxbcm.h +0 -1
index 0c2185c529f7..a8cffcb82d43 100644
@@ -15,7 +15,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /* I2C */
 #define CONFIG_SYS_I2C
include/configs/theadorable.h +0 -1
index 31852fb24801..54e60a4094f8 100644
@@ -15,7 +15,6 @@
  * for DDR ECC byte filling in the SPL before loading the main
  * U-Boot into it.
  */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
 /*
  * The debugging version enables USB support via defconfig.
Signature · 1 line
2.20.1
Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] arm: mvebu: axp: Set CONFIG_SYS_TCLK globally

Quoted 8 lines · Pali Rohár

This mvebu axp platform always uses fixed 250 MHz TCLK. So specify this CONFIG_SYS_TCLK option in msys section of global file soc.h file instead of manual configuration in every board file.

Now every #if-#else case of soc.h file defines CONFIG_SYS_TCLK, so remove useless default CONFIG_SYS_TCLK value from the end of soc.h file.

Thanks,
Stefan

Quoted 65 lines
---
  arch/arm/mach-mvebu/include/mach/soc.h | 3 ---
  include/configs/db-mv784mp-gp.h        | 1 -
  include/configs/ds414.h                | 1 -
  include/configs/maxbcm.h               | 1 -
  include/configs/theadorable.h          | 1 -
  5 files changed, 7 deletions(-)
arch/arm/mach-mvebu/include/mach/soc.h +0 -3
index e29c0f32c3de..8e8a4058550e 100644
@@ -208,10 +208,7 @@
 
  #define BOOT_FROM_UART		0x2
  #define BOOT_FROM_SPI		0x3
-#endif
 
-/* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
  #define CONFIG_SYS_TCLK		250000000	/* 250MHz */
  #endif
 
include/configs/db-mv784mp-gp.h +0 -1
index ef7eebd081f9..f1b79e8a1fb8 100644
@@ -16,7 +16,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* I2C */
  #define CONFIG_SYS_I2C
include/configs/ds414.h +0 -1
index 4bbb244fa227..9fe830965854 100644
@@ -18,7 +18,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* I2C */
  #define CONFIG_SYS_I2C
include/configs/maxbcm.h +0 -1
index 0c2185c529f7..a8cffcb82d43 100644
@@ -15,7 +15,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /* I2C */
  #define CONFIG_SYS_I2C
include/configs/theadorable.h +0 -0
index 31852fb24801..54e60a4094f8 100644

include/configs/theadorable.h line 20

Quoted 7 lines
include/configs/theadorable.h +0 -1
@@ -15,7 +15,6 @@
   * for DDR ECC byte filling in the SPL before loading the main
   * U-Boot into it.
   */
-#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 
  /*
   * The debugging version enables USB support via defconfig.

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#9 lore raw

PATCH 5/5 arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

In reply to Pali Rohár

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK	200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK			166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -2
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
Signature · 1 line
2.20.1
#10 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Quoted 8 lines · Pali Rohár

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK. If I understand correctly the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Quoted 55 lines
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK        200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK                        166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -3
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
--

2.20.1

#11 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Quoted 6 lines · On Sunday 01 August 2021 20:07:16 Chris Packham wrote:
Quoted 5 lines · Pali Rohár

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Quoted 6 lines
Quoted 3 lines

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK.

Interesting... Because I took above information from Kirkwood hardware specifications...

88F6180: https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
88F6192: https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
88F6281: https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

And there are specified fixed TCLK values.

Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

Quoted 55 lines
Quoted 55 lines
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK        200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK                        166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -3
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
--

2.20.1

#12 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Hi!

Quoted 14 lines · On Sunday 01 August 2021 20:07:16 Chris Packham wrote:
Quoted 6 lines · Pali Rohár
Quoted 5 lines

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Quoted 6 lines
Quoted 3 lines

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK.

Quoted 7 lines

Interesting... Because I took above information from Kirkwood hardware specifications...

88F6180: https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
88F6192: https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
88F6281: https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

And there are specified fixed TCLK values.

Nope, this breaks my lsxl (specifically the LSCHLv2) board. The TCLK is 166MHz there.

Quoted 7 lines
Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

At least for the lsxl and the NET2BIG_V2 this is not correct. Both have the 88F6281 and both use have a 166MHz TCLK clock.

Anyway, I'm reverting this patch. The only open question is, should I convert the TCLK to a Kconfig option?

-michael

Quoted 55 lines
Quoted 55 lines
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK        200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK                        166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -3
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
--

2.20.1

#13 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Hello!

Quoted 18 lines · On Tuesday 16 August 2022 11:37:48 Michael Walle wrote:

Hi!

Quoted 16 lines · On Sunday 01 August 2021 20:07:16 Chris Packham wrote:
Quoted 6 lines · Pali Rohár
Quoted 5 lines

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Quoted 6 lines
Quoted 3 lines

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK.

Interesting... Because I took above information from Kirkwood hardware specifications...

Quoted 8 lines
Quoted 5 lines

88F6180: https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
88F6192: https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
88F6281: https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

And there are specified fixed TCLK values.

Nope, this breaks my lsxl (specifically the LSCHLv2) board. The TCLK is 166MHz there.

Ou, sorry for that.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

At least for the lsxl and the NET2BIG_V2 this is not correct. Both have the 88F6281 and both use have a 166MHz TCLK clock.

Interesting... because this contradicts publicly available documentation. Maybe in NDA doc is some more details?

Quoted 2 lines

Anyway, I'm reverting this patch. The only open question is, should I convert the TCLK to a Kconfig option?

In this case it would be better to detect TCLK from some SAR register, like it is already implemented for other Armada SoCs.

Just by a chance, do you have some "better" 88F6281 documentation? If there is some TCLK information or SAR register description. In publicly available FS_88F6180_9x_6281_OpenSource.pdf there is 0x10030 Sample at Reset Register, but nothing TCLK related.

At least BootROM has to detect TCLK because UART clock is derived from TCLK and BootROM supports UART booting via 115200 baudrate. In case you can provide me 88F6281 BootROM dump from your board, I can try to find code which configures UART and detect TCLK. I have already did it for 88F6820 (A385) to verify that U-Boot code detects TCLK in the same way as BootROM.

Quoted 58 lines

-michael

Quoted 55 lines
Quoted 55 lines
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK        200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK                        166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -3
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
--

2.20.1

#14 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Quoted 57 lines · On Tuesday 16 August 2022 20:17:08 Pali Rohár wrote:

Hello!

Quoted 18 lines · On Tuesday 16 August 2022 11:37:48 Michael Walle wrote:

Hi!

Quoted 16 lines · On Sunday 01 August 2021 20:07:16 Chris Packham wrote:
Quoted 6 lines · Pali Rohár
Quoted 5 lines

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Quoted 6 lines
Quoted 3 lines

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK.

Interesting... Because I took above information from Kirkwood hardware specifications...

Quoted 8 lines
Quoted 5 lines

88F6180: https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
88F6192: https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
88F6281: https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

And there are specified fixed TCLK values.

Nope, this breaks my lsxl (specifically the LSCHLv2) board. The TCLK is 166MHz there.

Ou, sorry for that.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

At least for the lsxl and the NET2BIG_V2 this is not correct. Both have the 88F6281 and both use have a 166MHz TCLK clock.

Interesting... because this contradicts publicly available documentation. Maybe in NDA doc is some more details?

Quoted 2 lines

Anyway, I'm reverting this patch. The only open question is, should I convert the TCLK to a Kconfig option?

In this case it would be better to detect TCLK from some SAR register, like it is already implemented for other Armada SoCs.

Just by a chance, do you have some "better" 88F6281 documentation? If there is some TCLK information or SAR register description. In publicly available FS_88F6180_9x_6281_OpenSource.pdf there is 0x10030 Sample at Reset Register, but nothing TCLK related.

Quoted 6 lines

At least BootROM has to detect TCLK because UART clock is derived from TCLK and BootROM supports UART booting via 115200 baudrate. In case you can provide me 88F6281 BootROM dump from your board, I can try to find code which configures UART and detect TCLK. I have already did it for 88F6820 (A385) to verify that U-Boot code detects TCLK in the same way as BootROM.

Meanwhile I have found following email thread:
https://lore.kernel.org/linux-arm-kernel/[email protected]/t/#u

Where are more 6281 boards with 166 MHz TCLK and there is interesting output:

$ dmesg | grep -i tclk
[    5.851008] Kirkwood: MV88F6281-A0, TCLK=200000000

Which means that old kernel version had TCLK detection code. I grepped git linux history and I successfully found it:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542

#define SAMPLE_AT_RESET (DEV_BUS_VIRT_BASE + 0x0030)

static int __init kirkwood_find_tclk(void)

{
	u32 dev, rev;

	kirkwood_pcie_id(&dev, &rev);

	if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
		if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
			return 200000000;

	return 166666667;
}

So for TCLK detection is used BIT 21 of already mentioned 0x10030 Sample at Reset Register.

I'm going to prepare a patch which will fix this issue for 88F6281 SoCs.

Quoted 58 lines
Quoted 58 lines

-michael

Quoted 55 lines
Quoted 55 lines
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
 include/configs/lacie_kw.h                      | 5 -----
 include/configs/lsxl.h                          | 2 --
 3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
 #define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
 #define CONFIG_SYS_TCLK        200000000 /* 200MHz */
-#endif
 
 #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
 #endif
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK                        166000000 /* 166MHz */
-
 /*
  * SDRAM configuration
  */
include/configs/lsxl.h +0 -3
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
 #if defined(CONFIG_LSCHLV2)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
 #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
 #elif defined(CONFIG_LSXHL)
 #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
 #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
 #else
 #error "unknown board"
 #endif
--

2.20.1

#15 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Quoted 26 lines · On Tuesday 16 August 2022 21:38:51 Pali Rohár wrote:

Meanwhile I have found following email thread:
https://lore.kernel.org/linux-arm-kernel/[email protected]/t/#u

Where are more 6281 boards with 166 MHz TCLK and there is interesting output:

$ dmesg | grep -i tclk
[    5.851008] Kirkwood: MV88F6281-A0, TCLK=200000000

Which means that old kernel version had TCLK detection code. I grepped git linux history and I successfully found it:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542

#define SAMPLE_AT_RESET (DEV_BUS_VIRT_BASE + 0x0030)

static int __init kirkwood_find_tclk(void)

{
	u32 dev, rev;

	kirkwood_pcie_id(&dev, &rev);

	if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
		if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
			return 200000000;

	return 166666667;
}
Quoted 4 lines

So for TCLK detection is used BIT 21 of already mentioned 0x10030 Sample at Reset Register.

I'm going to prepare a patch which will fix this issue for 88F6281 SoCs.

Done! Please test it!
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#16 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

In reply to Pali Rohár

Am 2022-08-16 21:38, schrieb Pali Rohár:

Quoted 91 lines · On Tuesday 16 August 2022 20:17:08 Pali Rohár wrote:
Quoted 57 lines

Hello!

Quoted 18 lines · On Tuesday 16 August 2022 11:37:48 Michael Walle wrote:

Hi!

Quoted 16 lines · On Sunday 01 August 2021 20:07:16 Chris Packham wrote:
Quoted 6 lines · Pali Rohár
Quoted 5 lines

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Quoted 6 lines
Quoted 3 lines

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

It's been a while since I worked with kirkwood but I thought that there was hardware strapping for the TCLK.

Interesting... Because I took above information from Kirkwood hardware specifications...

Quoted 8 lines
Quoted 5 lines

88F6180: https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
88F6192: https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
88F6281: https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

And there are specified fixed TCLK values.

Nope, this breaks my lsxl (specifically the LSCHLv2) board. The TCLK is 166MHz there.

Ou, sorry for that.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

At least for the lsxl and the NET2BIG_V2 this is not correct. Both have the 88F6281 and both use have a 166MHz TCLK clock.

Interesting... because this contradicts publicly available documentation. Maybe in NDA doc is some more details?

Quoted 2 lines

Anyway, I'm reverting this patch. The only open question is, should I convert the TCLK to a Kconfig option?

In this case it would be better to detect TCLK from some SAR register, like it is already implemented for other Armada SoCs.

Just by a chance, do you have some "better" 88F6281 documentation? If there is some TCLK information or SAR register description. In publicly available FS_88F6180_9x_6281_OpenSource.pdf there is 0x10030 Sample at Reset Register, but nothing TCLK related.

Quoted 6 lines

At least BootROM has to detect TCLK because UART clock is derived from TCLK and BootROM supports UART booting via 115200 baudrate. In case you can provide me 88F6281 BootROM dump from your board, I can try to find code which configures UART and detect TCLK. I have already did it for 88F6820 (A385) to verify that U-Boot code detects TCLK in the same way as BootROM.

Meanwhile I have found following email thread:
https://lore.kernel.org/linux-arm-kernel/[email protected]/t/#u

Where are more 6281 boards with 166 MHz TCLK and there is interesting output:

$ dmesg | grep -i tclk
[    5.851008] Kirkwood: MV88F6281-A0, TCLK=200000000

Which means that old kernel version had TCLK detection code. I grepped git linux history and I successfully found it:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542

#define SAMPLE_AT_RESET (DEV_BUS_VIRT_BASE + 0x0030)

static int __init kirkwood_find_tclk(void)

{
	u32 dev, rev;

	kirkwood_pcie_id(&dev, &rev);

	if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
		if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
			return 200000000;

	return 166666667;
}
Quoted 2 lines

So for TCLK detection is used BIT 21 of already mentioned 0x10030 Sample at Reset Register.

Seems like you beat me, while I was typing my former mail ;)

-michael

#17 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

In reply to Pali Rohár

Am 2022-08-16 20:17, schrieb Pali Rohár:

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

If I understand correctly
the defines in kw88f6281.h/kw88f6192.h were sensible defaults but boards were able to override it to reflect the hardware configuration.

Anyway, I think that this patch should not cause issue as it is changing only two board config files and removing redefinition of CONFIG_SYS_TCLK macro which is set to the same value as in kw88f61**.h files.

Quoted 5 lines
Quoted 2 lines

At least for the lsxl and the NET2BIG_V2 this is not correct. Both have the 88F6281 and both use have a 166MHz TCLK clock.

Interesting... because this contradicts publicly available documentation. Maybe in NDA doc is some more details?

No, the board support was entirely done by reverse engineering the original bootloader, back in 2012..

Quoted 5 lines
Quoted 2 lines

Anyway, I'm reverting this patch. The only open question is, should I convert the TCLK to a Kconfig option?

In this case it would be better to detect TCLK from some SAR register, like it is already implemented for other Armada SoCs.

Maybe a bit of a background: The LS-XHL and the LS-CHLv2 share the same PCB, labeled LSXL (thus the board name). the LS-CHLv2 being the low-budget version, i.e. only 64MiB of memory and a slower CPU clock. The LS-XHL has 256MiB memory.

I have both boards and I've dumped the SAR:

On the LS-XHL (TCLK 200MHz):

# busybox devmem 0xf1010030 32
0x0093CE96

On the LS-CHLv2 (TCLK 166MHz):

# busybox devmem 0xf1010030 32
0x00B2CA4C
Quoted 1 line

md f1040000 1

f1040000: 628111ab

Quoted 4 lines

Just by a chance, do you have some "better" 88F6281 documentation? If there is some TCLK information or SAR register description. In publicly available FS_88F6180_9x_6281_OpenSource.pdf there is 0x10030 Sample at Reset Register, but nothing TCLK related.

This made me look closer, and linux is reporting:

[    0.000017] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 21474836475ns
and on the other board:
[    0.000015] sched_clock: 32 bits at 166MHz, resolution 6ns, wraps every 12884901885ns

I've digged into it and the kirkwood-core-clock has more information:
https://elixir.bootlin.com/linux/v5.19.1/source/drivers/clk/mvebu/kirkwood.c#L59

I'll take a look at how this could then be determined at runtime.

Quoted 6 lines

At least BootROM has to detect TCLK because UART clock is derived from TCLK and BootROM supports UART booting via 115200 baudrate. In case you can provide me 88F6281 BootROM dump from your board, I can try to find code which configures UART and detect TCLK. I have already did it for 88F6820 (A385) to verify that U-Boot code detects TCLK in the same way as BootROM.

If you still need the bootrom and it is readable in u-boot, I can provide you the dump.

-michael

Reviewed-by on v1 5/5
#18 lore raw

Re: [PATCH 5/5] arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

Config option CONFIG_SYS_TCLK is set by kw88f6281.h and kw88f6192.h files to correct SOC/platform value. So do not overwrite it in board config include files.

Kirkwood 88F6180 and 88F6192 uses 166 MHz TCLK and Kirkwood 88F6281 uses 200 MHz TCLK.

Thanks,
Stefan

Quoted 42 lines
---
  arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 2 --
  include/configs/lacie_kw.h                      | 5 -----
  include/configs/lsxl.h                          | 2 --
  3 files changed, 9 deletions(-)
arch/arm/mach-kirkwood/include/mach/kw88f6281.h +0 -2
index 33e741420781..87406081cf54 100644
@@ -15,8 +15,6 @@
  #define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
 
  /* TCLK Core Clock definition */
-#ifndef CONFIG_SYS_TCLK
  #define CONFIG_SYS_TCLK	200000000 /* 200MHz */
-#endif
 
  #endif /* _ASM_ARCH_KW88F6281_H */
include/configs/lacie_kw.h +0 -5
index 420c1d49b08e..88f784f1f0fd 100644
@@ -39,11 +39,6 @@
  #endif
  #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
 
-/*
- * Core clock definition
- */
-#define CONFIG_SYS_TCLK			166000000 /* 166MHz */
-
  /*
   * SDRAM configuration
   */
include/configs/lsxl.h +0 -0
index 0c0ab2486e23..a4a4739d0dd7 100644
@@ -13,11 +13,9 @@
  #if defined(CONFIG_LSCHLV2)

include/configs/lsxl.h line 21

Quoted 10 lines
include/configs/lsxl.h +0 -2
  #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lschl.cfg
  #define CONFIG_MACH_TYPE 3006
-#define CONFIG_SYS_TCLK 166666667 /* 166 MHz */
  #elif defined(CONFIG_LSXHL)
  #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage-lsxhl.cfg
  #define CONFIG_MACH_TYPE 2663
-/* CONFIG_SYS_TCLK is 200000000 by default */
  #else
  #error "unknown board"
  #endif

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#19 lore raw
In reply to Pali Rohár
Quoted 10 lines · Pali Rohár

This patch series automatically detects CONFIG_SYS_TCLK value, set it in global mach/soc.h file and remove manual CONFIG_SYS_TCLK value from all mvebu/kirkwood board config files.

So it just a cleanup to avoid defining custom macros in board config files which can be automatically detected.

Could you test these patches on a38x and a37x platforms that nothing is broken? I tested them on a38x Turris Omnia.

Quoted 6 lines

Pali Rohár (5):
arm: mvebu: a38x: Detect CONFIG_SYS_TCLK from SAR register
arm: mvebu: a37x: Detect CONFIG_SYS_TCLK from SAR register
arm: mvebu: msys: Set CONFIG_SYS_TCLK globally
arm: mvebu: axp: Set CONFIG_SYS_TCLK globally
arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 11 lines
  arch/arm/mach-kirkwood/include/mach/kw88f6281.h |  2 --
  arch/arm/mach-mvebu/include/mach/soc.h          | 15 ++++++++++-----
  include/configs/clearfog.h                      |  1 -
  include/configs/controlcenterdc.h               |  2 --
  include/configs/crs3xx-98dx3236.h               |  1 -
  include/configs/db-88f6720.h                    |  1 -
  include/configs/db-88f6820-amc.h                |  2 --
  include/configs/db-88f6820-gp.h                 |  2 --
  include/configs/db-mv784mp-gp.h                 |  1 -
  include/configs/db-xc3-24g4xg.h                 |  1 -
  include/configs/ds414.h                         |  1 -
Quoted 9 lines
  include/configs/helios4.h                       |  1 -
  include/configs/lacie_kw.h                      |  5 -----
  include/configs/lsxl.h                          |  2 --
  include/configs/maxbcm.h                        |  1 -
  include/configs/theadorable.h                   |  1 -
  include/configs/turris_omnia.h                  |  1 -
  include/configs/x530.h                          |  2 --
  18 files changed, 10 insertions(+), 32 deletions(-)

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]