From patchwork Sun Jan 15 05:59:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 91516 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp888573qgi; Sat, 14 Jan 2017 22:00:14 -0800 (PST) X-Received: by 10.223.167.3 with SMTP id c3mr21149798wrd.103.1484460014078; Sat, 14 Jan 2017 22:00:14 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id w91si4736843wrb.163.2017.01.14.22.00.13; Sat, 14 Jan 2017 22:00:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92774B3864; Sun, 15 Jan 2017 07:00:06 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vRPueEaz61QH; Sun, 15 Jan 2017 07:00:06 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8B3FFB387F; Sun, 15 Jan 2017 06:59:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F37AA75E6 for ; Sun, 15 Jan 2017 06:59:40 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JKQ7ZOMVnyCc for ; Sun, 15 Jan 2017 06:59:40 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 36778A75F3 for ; Sun, 15 Jan 2017 06:59:36 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-10.nifty.com with ESMTP id v0F5xD3i016694; Sun, 15 Jan 2017 14:59:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v0F5xD3i016694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1484459959; bh=1LqHcWDH4EoMqf6nJ883HHjmqVthJWcYtUiWM1TID2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxelzFWy66KlgITlvK6RfofJU7AfyvT9jGDDeJB7TynY9iofzsfSw/TU2XMIau2qY pI+NQ8dMeYg3n2Qz6HZyD1aGkGmxA3VqcbmmRF6/j87FLjRHaAqSLeQPlygXdkWxmG YEnMiOpYG9SihYf4ktl0kB2o5gCumTiJ2b8m7u788htzY/efyBW13hR2PMChl1boCm WLk74NjxNzLrgQyEttZPIz7ANNrBmsby8N9DEa9i5DsvIdX+nSdGJJswoQnpl1Y13t teODvLXorPo+VcdJt5DXQbXSg+V/uK/73l148IlbB0OTeeHnctE2eMFRDEpCgvhA8Y dS+NuWHAjPRmg== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sun, 15 Jan 2017 14:59:05 +0900 Message-Id: <1484459950-8644-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484459950-8644-1-git-send-email-yamada.masahiro@socionext.com> References: <1484459950-8644-1-git-send-email-yamada.masahiro@socionext.com> Cc: Albert Aribaud Subject: [U-Boot] [PATCH 4/9] ARM: uniphier: refactor SBC init code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Merge sbc-admulti.c and sbc-savepin.c into a single file to avoid code duplication. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/init.h | 27 ++++++----- arch/arm/mach-uniphier/init/init-ld11.c | 6 +-- arch/arm/mach-uniphier/init/init-ld20.c | 6 +-- arch/arm/mach-uniphier/init/init-ld4.c | 3 +- arch/arm/mach-uniphier/init/init-pro4.c | 2 +- arch/arm/mach-uniphier/init/init-pro5.c | 2 +- arch/arm/mach-uniphier/init/init-pxs2.c | 3 +- arch/arm/mach-uniphier/init/init-sld3.c | 2 +- arch/arm/mach-uniphier/init/init-sld8.c | 3 +- arch/arm/mach-uniphier/sbc/Makefile | 17 ++++--- arch/arm/mach-uniphier/sbc/sbc-admulti.c | 53 ---------------------- arch/arm/mach-uniphier/sbc/sbc-ld11.c | 25 ++++++++++ arch/arm/mach-uniphier/sbc/sbc-ld4.c | 6 +-- arch/arm/mach-uniphier/sbc/sbc-pxs2.c | 6 +-- .../arm/mach-uniphier/sbc/{sbc-savepin.c => sbc.c} | 36 ++++++++++++--- 15 files changed, 89 insertions(+), 108 deletions(-) delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-admulti.c create mode 100644 arch/arm/mach-uniphier/sbc/sbc-ld11.c rename arch/arm/mach-uniphier/sbc/{sbc-savepin.c => sbc.c} (58%) -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h index 0708aa0..78c2eee 100644 --- a/arch/arm/mach-uniphier/init.h +++ b/arch/arm/mach-uniphier/init.h @@ -46,31 +46,30 @@ int uniphier_ld11_init(const struct uniphier_board_data *bd); int uniphier_ld20_init(const struct uniphier_board_data *bd); #if defined(CONFIG_MICRO_SUPPORT_CARD) -int uniphier_sbc_init_admulti(const struct uniphier_board_data *bd); -int uniphier_sbc_init_savepin(const struct uniphier_board_data *bd); -int uniphier_ld4_sbc_init(const struct uniphier_board_data *bd); -int uniphier_pxs2_sbc_init(const struct uniphier_board_data *bd); +void uniphier_sbc_init_admulti(void); +void uniphier_sbc_init_savepin(void); +void uniphier_ld4_sbc_init(void); +void uniphier_pxs2_sbc_init(void); +void uniphier_ld11_sbc_init(void); #else -static inline int uniphier_sbc_init_admulti( - const struct uniphier_board_data *bd) +static inline void uniphier_sbc_init_admulti(void) { - return 0; } -static inline int uniphier_sbc_init_savepin( - const struct uniphier_board_data *bd) +static inline void uniphier_sbc_init_savepin(void) { - return 0; } -static inline int uniphier_ld4_sbc_init(const struct uniphier_board_data *bd) +static inline void uniphier_ld4_sbc_init(void) { - return 0; } -static inline int uniphier_pxs2_sbc_init(const struct uniphier_board_data *bd) +static inline void uniphier_pxs2_sbc_init(void) +{ +} + +static inline void uniphier_ld11_sbc_init(void) { - return 0; } #endif diff --git a/arch/arm/mach-uniphier/init/init-ld11.c b/arch/arm/mach-uniphier/init/init-ld11.c index 93b2162..64fe000 100644 --- a/arch/arm/mach-uniphier/init/init-ld11.c +++ b/arch/arm/mach-uniphier/init/init-ld11.c @@ -13,11 +13,7 @@ int uniphier_ld11_init(const struct uniphier_board_data *bd) { - uniphier_sbc_init_savepin(bd); - uniphier_pxs2_sbc_init(bd); - /* pins for NAND and System Bus are multiplexed */ - if (spl_boot_device() != BOOT_DEVICE_NAND) - uniphier_pin_init("system_bus_grp"); + uniphier_ld11_sbc_init(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-ld20.c b/arch/arm/mach-uniphier/init/init-ld20.c index de39b9a..ec4563b 100644 --- a/arch/arm/mach-uniphier/init/init-ld20.c +++ b/arch/arm/mach-uniphier/init/init-ld20.c @@ -13,11 +13,7 @@ int uniphier_ld20_init(const struct uniphier_board_data *bd) { - uniphier_sbc_init_savepin(bd); - uniphier_pxs2_sbc_init(bd); - /* pins for NAND and System Bus are multiplexed */ - if (spl_boot_device() != BOOT_DEVICE_NAND) - uniphier_pin_init("system_bus_grp"); + uniphier_ld11_sbc_init(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-ld4.c b/arch/arm/mach-uniphier/init/init-ld4.c index caf02a5..a56fb7f 100644 --- a/arch/arm/mach-uniphier/init/init-ld4.c +++ b/arch/arm/mach-uniphier/init/init-ld4.c @@ -16,8 +16,7 @@ int uniphier_ld4_init(const struct uniphier_board_data *bd) { uniphier_ld4_bcu_init(bd); - uniphier_sbc_init_savepin(bd); - uniphier_ld4_sbc_init(bd); + uniphier_ld4_sbc_init(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-pro4.c b/arch/arm/mach-uniphier/init/init-pro4.c index 32d09bb..8e2ebc7 100644 --- a/arch/arm/mach-uniphier/init/init-pro4.c +++ b/arch/arm/mach-uniphier/init/init-pro4.c @@ -14,7 +14,7 @@ int uniphier_pro4_init(const struct uniphier_board_data *bd) { - uniphier_sbc_init_savepin(bd); + uniphier_sbc_init_savepin(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-pro5.c b/arch/arm/mach-uniphier/init/init-pro5.c index 3fc09a4..37c62ef 100644 --- a/arch/arm/mach-uniphier/init/init-pro5.c +++ b/arch/arm/mach-uniphier/init/init-pro5.c @@ -12,7 +12,7 @@ int uniphier_pro5_init(const struct uniphier_board_data *bd) { - uniphier_sbc_init_savepin(bd); + uniphier_sbc_init_savepin(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-pxs2.c b/arch/arm/mach-uniphier/init/init-pxs2.c index 38e37e4..d080b9b 100644 --- a/arch/arm/mach-uniphier/init/init-pxs2.c +++ b/arch/arm/mach-uniphier/init/init-pxs2.c @@ -14,8 +14,7 @@ int uniphier_pxs2_init(const struct uniphier_board_data *bd) { int ret; - uniphier_sbc_init_savepin(bd); - uniphier_pxs2_sbc_init(bd); + uniphier_pxs2_sbc_init(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-sld3.c b/arch/arm/mach-uniphier/init/init-sld3.c index 9dc51bf..0b8d6c5 100644 --- a/arch/arm/mach-uniphier/init/init-sld3.c +++ b/arch/arm/mach-uniphier/init/init-sld3.c @@ -16,7 +16,7 @@ int uniphier_sld3_init(const struct uniphier_board_data *bd) { uniphier_sld3_bcu_init(bd); - uniphier_sbc_init_admulti(bd); + uniphier_sbc_init_admulti(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/init/init-sld8.c b/arch/arm/mach-uniphier/init/init-sld8.c index 8e8d62b..075ac27 100644 --- a/arch/arm/mach-uniphier/init/init-sld8.c +++ b/arch/arm/mach-uniphier/init/init-sld8.c @@ -16,8 +16,7 @@ int uniphier_sld8_init(const struct uniphier_board_data *bd) { uniphier_ld4_bcu_init(bd); - uniphier_sbc_init_savepin(bd); - uniphier_ld4_sbc_init(bd); + uniphier_ld4_sbc_init(); support_card_reset(); diff --git a/arch/arm/mach-uniphier/sbc/Makefile b/arch/arm/mach-uniphier/sbc/Makefile index ec3c22c..b85b1fe 100644 --- a/arch/arm/mach-uniphier/sbc/Makefile +++ b/arch/arm/mach-uniphier/sbc/Makefile @@ -2,12 +2,11 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += sbc-admulti.o -obj-$(CONFIG_ARCH_UNIPHIER_LD4) += sbc-savepin.o sbc-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += sbc-savepin.o -obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += sbc-savepin.o sbc-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += sbc-savepin.o -obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += sbc-savepin.o sbc-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += sbc-savepin.o sbc-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD11) += sbc-savepin.o sbc-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD20) += sbc-savepin.o sbc-pxs2.o +obj-y += sbc.o + +obj-$(CONFIG_ARCH_UNIPHIER_LD4) += sbc-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += sbc-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += sbc-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += sbc-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_LD11) += sbc-ld11.o +obj-$(CONFIG_ARCH_UNIPHIER_LD20) += sbc-ld11.o diff --git a/arch/arm/mach-uniphier/sbc/sbc-admulti.c b/arch/arm/mach-uniphier/sbc/sbc-admulti.c deleted file mode 100644 index 05108dd..0000000 --- a/arch/arm/mach-uniphier/sbc/sbc-admulti.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2011-2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../sg-regs.h" -#include "sbc-regs.h" - -#define SBCTRL0_ADMULTIPLX_PERI_VALUE 0x33120000 -#define SBCTRL1_ADMULTIPLX_PERI_VALUE 0x03005500 -#define SBCTRL2_ADMULTIPLX_PERI_VALUE 0x14000020 - -#define SBCTRL0_ADMULTIPLX_MEM_VALUE 0x33120000 -#define SBCTRL1_ADMULTIPLX_MEM_VALUE 0x03005500 -#define SBCTRL2_ADMULTIPLX_MEM_VALUE 0x14000010 - -int uniphier_sbc_init_admulti(const struct uniphier_board_data *bd) -{ - /* - * Only CS1 is connected to support card. - * BKSZ[1:0] should be set to "01". - */ - writel(SBCTRL0_ADMULTIPLX_MEM_VALUE, SBCTRL10); - writel(SBCTRL1_ADMULTIPLX_MEM_VALUE, SBCTRL11); - writel(SBCTRL2_ADMULTIPLX_MEM_VALUE, SBCTRL12); - - if (boot_is_swapped()) { - /* - * Boot Swap On: boot from external NOR/SRAM - * 0x42000000-0x43ffffff is a mirror of 0x40000000-0x41ffffff. - * - * 0x40000000-0x41efffff, 0x42000000-0x43efffff: memory bank - * 0x41f00000-0x41ffffff, 0x43f00000-0x43ffffff: peripherals - */ - writel(0x0000bc01, SBBASE0); - } else { - /* - * Boot Swap Off: boot from mask ROM - * 0x40000000-0x41ffffff: mask ROM - * 0x42000000-0x43efffff: memory bank (31MB) - * 0x43f00000-0x43ffffff: peripherals (1MB) - */ - writel(0x0000be01, SBBASE0); /* dummy */ - writel(0x0200be01, SBBASE1); - } - - return 0; -} diff --git a/arch/arm/mach-uniphier/sbc/sbc-ld11.c b/arch/arm/mach-uniphier/sbc/sbc-ld11.c new file mode 100644 index 0000000..41adc94 --- /dev/null +++ b/arch/arm/mach-uniphier/sbc/sbc-ld11.c @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015-2016 Masahiro Yamada + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +#include "../init.h" +#include "sbc-regs.h" + +void uniphier_ld11_sbc_init(void) +{ + uniphier_sbc_init_savepin(); + + /* necessary for ROM boot ?? */ + /* system bus output enable */ + writel(0x17, PC0CTRL); + + /* pins for NAND and System Bus are multiplexed */ + if (spl_boot_device() != BOOT_DEVICE_NAND) + uniphier_pin_init("system_bus_grp"); +} diff --git a/arch/arm/mach-uniphier/sbc/sbc-ld4.c b/arch/arm/mach-uniphier/sbc/sbc-ld4.c index 12bee79..7520e2a 100644 --- a/arch/arm/mach-uniphier/sbc/sbc-ld4.c +++ b/arch/arm/mach-uniphier/sbc/sbc-ld4.c @@ -9,14 +9,14 @@ #include "../init.h" #include "sbc-regs.h" -int uniphier_ld4_sbc_init(const struct uniphier_board_data *bd) +void uniphier_ld4_sbc_init(void) { u32 tmp; + uniphier_sbc_init_savepin(); + /* system bus output enable */ tmp = readl(PC0CTRL); tmp &= 0xfffffcff; writel(tmp, PC0CTRL); - - return 0; } diff --git a/arch/arm/mach-uniphier/sbc/sbc-pxs2.c b/arch/arm/mach-uniphier/sbc/sbc-pxs2.c index acbf4c5..677a974 100644 --- a/arch/arm/mach-uniphier/sbc/sbc-pxs2.c +++ b/arch/arm/mach-uniphier/sbc/sbc-pxs2.c @@ -9,11 +9,11 @@ #include "../init.h" #include "sbc-regs.h" -int uniphier_pxs2_sbc_init(const struct uniphier_board_data *bd) +void uniphier_pxs2_sbc_init(void) { + uniphier_sbc_init_savepin(); + /* necessary for ROM boot ?? */ /* system bus output enable */ writel(0x17, PC0CTRL); - - return 0; } diff --git a/arch/arm/mach-uniphier/sbc/sbc-savepin.c b/arch/arm/mach-uniphier/sbc/sbc.c similarity index 58% rename from arch/arm/mach-uniphier/sbc/sbc-savepin.c rename to arch/arm/mach-uniphier/sbc/sbc.c index 41e9796..b43d933 100644 --- a/arch/arm/mach-uniphier/sbc/sbc-savepin.c +++ b/arch/arm/mach-uniphier/sbc/sbc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2016 Masahiro Yamada + * Copyright (C) 2011-2015 Masahiro Yamada * * SPDX-License-Identifier: GPL-2.0+ */ @@ -9,6 +9,14 @@ #include "../init.h" #include "sbc-regs.h" +#define SBCTRL0_ADMULTIPLX_PERI_VALUE 0x33120000 +#define SBCTRL1_ADMULTIPLX_PERI_VALUE 0x03005500 +#define SBCTRL2_ADMULTIPLX_PERI_VALUE 0x14000020 + +#define SBCTRL0_ADMULTIPLX_MEM_VALUE 0x33120000 +#define SBCTRL1_ADMULTIPLX_MEM_VALUE 0x03005500 +#define SBCTRL2_ADMULTIPLX_MEM_VALUE 0x14000010 + /* slower but LED works */ #define SBCTRL0_SAVEPIN_PERI_VALUE 0x55450000 #define SBCTRL1_SAVEPIN_PERI_VALUE 0x07168d00 @@ -22,16 +30,22 @@ #define SBCTRL2_SAVEPIN_MEM_VALUE 0x34000009 #define SBCTRL4_SAVEPIN_MEM_VALUE 0x02110210 -int uniphier_sbc_init_savepin(const struct uniphier_board_data *bd) +static void __uniphier_sbc_init(int savepin) { /* * Only CS1 is connected to support card. * BKSZ[1:0] should be set to "01". */ - writel(SBCTRL0_SAVEPIN_PERI_VALUE, SBCTRL10); - writel(SBCTRL1_SAVEPIN_PERI_VALUE, SBCTRL11); - writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12); - writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14); + if (savepin) { + writel(SBCTRL0_SAVEPIN_PERI_VALUE, SBCTRL10); + writel(SBCTRL1_SAVEPIN_PERI_VALUE, SBCTRL11); + writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12); + writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14); + } else { + writel(SBCTRL0_ADMULTIPLX_MEM_VALUE, SBCTRL10); + writel(SBCTRL1_ADMULTIPLX_MEM_VALUE, SBCTRL11); + writel(SBCTRL2_ADMULTIPLX_MEM_VALUE, SBCTRL12); + } if (boot_is_swapped()) { /* @@ -52,6 +66,14 @@ int uniphier_sbc_init_savepin(const struct uniphier_board_data *bd) writel(0x0000be01, SBBASE0); /* dummy */ writel(0x0200be01, SBBASE1); } +} - return 0; +void uniphier_sbc_init_admulti(void) +{ + __uniphier_sbc_init(0); +} + +void uniphier_sbc_init_savepin(void) +{ + __uniphier_sbc_init(1); }