[U-Boot] [PATCH 37/48] mpc83xx: Replace CONFIG_83XX_CLKIN in calculations
Mario Six
mario.six at gdsys.cc
Fri Sep 28 11:20:27 UTC 2018
CONFIG_SYS_CLK_FREQ is the standard way to set the system clock
frequency. On MPC83xx, CONFIG_83XX_CLKIN is used for this purpose.
Hence, the obvious way is to replace CONFIG_83XX_CLKIN with
CONFIG_SYS_CLK_FREQ.
A few MPC83xx boards use the CONFIG_83XX_CLKIN variable for computing
CONFIG_SYS_NS16550_CLK. This makes it harder to replace
CONFIG_83XX_CLKIN.
But the value of the multiplicator can be read from the SPMR register.
Hence, replace the static calculations with a call to a new get_bus_freq
function, as other architectures do.
Signed-off-by: Mario Six <mario.six at gdsys.cc>
---
arch/powerpc/cpu/mpc83xx/spl_minimal.c | 8 ++++++++
include/configs/MPC8315ERDB.h | 2 +-
include/configs/ids8313.h | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/cpu/mpc83xx/spl_minimal.c b/arch/powerpc/cpu/mpc83xx/spl_minimal.c
index 746f1febba..3315ee05e1 100644
--- a/arch/powerpc/cpu/mpc83xx/spl_minimal.c
+++ b/arch/powerpc/cpu/mpc83xx/spl_minimal.c
@@ -89,3 +89,11 @@ void puts(const char *str)
while (*str)
putc(*str++);
}
+
+ulong get_bus_freq(ulong dummy)
+{
+ volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
+ u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
+
+ return CONFIG_83XX_CLKIN * spmf;
+}
diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h
index dd60ce8538..8466e867bb 100644
--- a/include/configs/MPC8315ERDB.h
+++ b/include/configs/MPC8315ERDB.h
@@ -274,7 +274,7 @@
*/
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE 1
-#define CONFIG_SYS_NS16550_CLK (CONFIG_83XX_CLKIN * 2)
+#define CONFIG_SYS_NS16550_CLK (get_bus_freq(0))
#define CONFIG_SYS_BAUDRATE_TABLE \
{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200}
diff --git a/include/configs/ids8313.h b/include/configs/ids8313.h
index 6a222e9757..b371b3b1ba 100644
--- a/include/configs/ids8313.h
+++ b/include/configs/ids8313.h
@@ -315,7 +315,7 @@
{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200}
#define CONFIG_SYS_NS16550_COM1 (CONFIG_SYS_IMMR + 0x4500)
#define CONFIG_SYS_NS16550_COM2 (CONFIG_SYS_IMMR + 0x4600)
-#define CONFIG_SYS_NS16550_CLK (CONFIG_83XX_CLKIN * 2)
+#define CONFIG_SYS_NS16550_CLK (get_bus_freq(0))
#define CONFIG_HAS_FSL_DR_USB
#define CONFIG_SYS_SCCR_USBDRCM 3
--
2.16.4
More information about the U-Boot
mailing list