From patchwork Mon Nov 5 14:44:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Six X-Patchwork-Id: 993117 X-Patchwork-Delegate: mario.six@gdsys.cc Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gdsys.cc Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42pbcD2sxMz9sCQ for ; Tue, 6 Nov 2018 02:06:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 20E6EC226D9; Mon, 5 Nov 2018 15:02:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0A46AC2268C; Mon, 5 Nov 2018 14:55:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F275EC2225A; Mon, 5 Nov 2018 14:55:26 +0000 (UTC) Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.99]) by lists.denx.de (Postfix) with ESMTPS id 33D00C2268A for ; Mon, 5 Nov 2018 14:54:57 +0000 (UTC) Received: from [80.151.34.241] (helo=bob3.testumgebung.local) by smtprelay07.ispgateway.de with esmtpa (Exim 4.90_1) (envelope-from ) id 1gJgHH-0004E5-RQ; Mon, 05 Nov 2018 15:54:56 +0100 From: Mario Six To: U-Boot Mailing List , Wolfgang Denk , Reinhard Arlt , Sinan Akman , Holger Brunck , York Sun , Heiko Schocher , Paul Gortmaker , Peter Tyser , Bin Meng Date: Mon, 5 Nov 2018 15:44:43 +0100 Message-Id: <20181105144512.16727-29-mario.six@gdsys.cc> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105144512.16727-1-mario.six@gdsys.cc> References: <20181105144512.16727-1-mario.six@gdsys.cc> MIME-Version: 1.0 X-Df-Sender: bWFyaW8uc2l4QGdkc3lzLmNj Subject: [U-Boot] [PATCH v2 29/58] mpc83xx: Replace CONFIG_83XX_CLKIN in calculations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- v1 -> v2: No changes --- 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 746f1febba0..3315ee05e11 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 c373a0ab4c1..adb2bb6c2d8 100644 --- a/include/configs/MPC8315ERDB.h +++ b/include/configs/MPC8315ERDB.h @@ -271,7 +271,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 f1d8990a886..e6c0b89fa3e 100644 --- a/include/configs/ids8313.h +++ b/include/configs/ids8313.h @@ -311,7 +311,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