[U-Boot] [PATCH v2 10/22] ARM: uniphier: make boot_is_swapped() code optional
Masahiro Yamada
yamada.masahiro at socionext.com
Wed Jul 10 11:07:38 UTC 2019
The planned new SoC does not have SBC (System Bus Controller) block.
Make boot_is_swapped() an optional hook.
Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---
arch/arm/mach-uniphier/boot-device/boot-device.c | 16 ++++++++++++++--
arch/arm/mach-uniphier/sbc/Makefile | 2 +-
arch/arm/mach-uniphier/sbc/sbc-boot.c | 13 +++++++++++++
arch/arm/mach-uniphier/sbc/sbc-regs.h | 9 +--------
arch/arm/mach-uniphier/sbc/sbc.c | 2 +-
5 files changed, 30 insertions(+), 12 deletions(-)
create mode 100644 arch/arm/mach-uniphier/sbc/sbc-boot.c
diff --git a/arch/arm/mach-uniphier/boot-device/boot-device.c b/arch/arm/mach-uniphier/boot-device/boot-device.c
index 59302150b89c..3c2e7b660f3e 100644
--- a/arch/arm/mach-uniphier/boot-device/boot-device.c
+++ b/arch/arm/mach-uniphier/boot-device/boot-device.c
@@ -23,6 +23,7 @@ struct uniphier_boot_device_info {
const unsigned int *boot_device_count;
int (*boot_device_is_usb)(u32 pinmon);
unsigned int (*boot_device_fixup)(unsigned int mode);
+ int (*boot_is_swapped)(void);
bool have_internal_stm;
};
@@ -33,6 +34,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_sel_shift = 1,
.boot_device_table = uniphier_ld4_boot_device_table,
.boot_device_count = &uniphier_ld4_boot_device_count,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = true,
},
#endif
@@ -42,6 +44,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_sel_shift = 1,
.boot_device_table = uniphier_ld4_boot_device_table,
.boot_device_count = &uniphier_ld4_boot_device_count,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = false,
},
#endif
@@ -51,6 +54,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_sel_shift = 1,
.boot_device_table = uniphier_ld4_boot_device_table,
.boot_device_count = &uniphier_ld4_boot_device_count,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = true,
},
#endif
@@ -60,6 +64,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_sel_shift = 1,
.boot_device_table = uniphier_pro5_boot_device_table,
.boot_device_count = &uniphier_pro5_boot_device_count,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = false,
},
#endif
@@ -71,6 +76,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_count = &uniphier_pxs2_boot_device_count,
.boot_device_is_usb = uniphier_pxs2_boot_device_is_usb,
.boot_device_fixup = uniphier_pxs2_boot_device_fixup,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = false,
},
#endif
@@ -82,6 +88,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_count = &uniphier_pxs2_boot_device_count,
.boot_device_is_usb = uniphier_pxs2_boot_device_is_usb,
.boot_device_fixup = uniphier_pxs2_boot_device_fixup,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = true, /* STM on A-chip */
},
#endif
@@ -92,6 +99,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_table = uniphier_ld11_boot_device_table,
.boot_device_count = &uniphier_ld11_boot_device_count,
.boot_device_is_usb = uniphier_ld11_boot_device_is_usb,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = true,
},
#endif
@@ -102,6 +110,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_table = uniphier_ld11_boot_device_table,
.boot_device_count = &uniphier_ld11_boot_device_count,
.boot_device_is_usb = uniphier_ld20_boot_device_is_usb,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = true,
},
#endif
@@ -112,6 +121,7 @@ static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
.boot_device_table = uniphier_pxs3_boot_device_table,
.boot_device_count = &uniphier_pxs3_boot_device_count,
.boot_device_is_usb = uniphier_pxs3_boot_device_is_usb,
+ .boot_is_swapped = uniphier_sbc_boot_is_swapped,
.have_internal_stm = false,
},
#endif
@@ -125,7 +135,7 @@ static unsigned int __uniphier_boot_device_raw(
u32 pinmon;
unsigned int boot_sel;
- if (boot_is_swapped())
+ if (info->boot_is_swapped && info->boot_is_swapped())
return BOOT_DEVICE_NOR;
pinmon = readl(SG_PINMON0);
@@ -208,7 +218,9 @@ static int do_pinmon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("STB Micon: %s\n",
uniphier_boot_from_backend() ? "OFF" : "ON");
- printf("Boot Swap: %s\n", boot_is_swapped() ? "ON" : "OFF");
+ if (info->boot_is_swapped)
+ printf("Boot Swap: %s\n",
+ info->boot_is_swapped() ? "ON" : "OFF");
pinmon = readl(SG_PINMON0);
diff --git a/arch/arm/mach-uniphier/sbc/Makefile b/arch/arm/mach-uniphier/sbc/Makefile
index 4efdd419f046..6c698a392257 100644
--- a/arch/arm/mach-uniphier/sbc/Makefile
+++ b/arch/arm/mach-uniphier/sbc/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0+
-obj- += dummy.o
+obj-y += sbc-boot.o
ifndef CONFIG_SPL_BUILD
obj-y += sbc.o
diff --git a/arch/arm/mach-uniphier/sbc/sbc-boot.c b/arch/arm/mach-uniphier/sbc/sbc-boot.c
new file mode 100644
index 000000000000..ec22b453e0fb
--- /dev/null
+++ b/arch/arm/mach-uniphier/sbc/sbc-boot.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright (C) 2011-2014 Panasonic Corporation
+// Copyright (C) 2015-2019 Socionext Inc.
+
+#include <linux/io.h>
+
+#include "sbc-regs.h"
+
+int uniphier_sbc_boot_is_swapped(void)
+{
+ return !(readl(SBBASE0) & SBBASE_BANK_ENABLE);
+}
diff --git a/arch/arm/mach-uniphier/sbc/sbc-regs.h b/arch/arm/mach-uniphier/sbc/sbc-regs.h
index e866816472b5..1e9618653f2d 100644
--- a/arch/arm/mach-uniphier/sbc/sbc-regs.h
+++ b/arch/arm/mach-uniphier/sbc/sbc-regs.h
@@ -76,14 +76,7 @@
#define PC0CTRL 0x598000c0
-#ifndef __ASSEMBLY__
-#include <linux/io.h>
-static inline int boot_is_swapped(void)
-{
- return !(readl(SBBASE0) & SBBASE_BANK_ENABLE);
-}
-#endif
-
+int uniphier_sbc_boot_is_swapped(void);
int uniphier_sbc_is_enabled(void);
#endif /* ARCH_SBC_REGS_H */
diff --git a/arch/arm/mach-uniphier/sbc/sbc.c b/arch/arm/mach-uniphier/sbc/sbc.c
index 6cf8cf2af80f..af8d6f4f9dc5 100644
--- a/arch/arm/mach-uniphier/sbc/sbc.c
+++ b/arch/arm/mach-uniphier/sbc/sbc.c
@@ -64,7 +64,7 @@ static void __uniphier_sbc_init(int savepin)
writel(SBCTRL2_ADMULTIPLX_MEM_VALUE, SBCTRL12);
}
- if (boot_is_swapped()) {
+ if (uniphier_sbc_boot_is_swapped()) {
/*
* Boot Swap On: boot from external NOR/SRAM
* 0x42000000-0x43ffffff is a mirror of 0x40000000-0x41ffffff.
--
2.17.1
More information about the U-Boot
mailing list