ARM: uniphier: make boot_is_swapped() code optional
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 10 Jul 2019 11:07:38 +0000 (20:07 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 10 Jul 2019 13:41:58 +0000 (22:41 +0900)
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@socionext.com>
arch/arm/mach-uniphier/boot-device/boot-device.c
arch/arm/mach-uniphier/sbc/Makefile
arch/arm/mach-uniphier/sbc/sbc-boot.c [new file with mode: 0644]
arch/arm/mach-uniphier/sbc/sbc-regs.h
arch/arm/mach-uniphier/sbc/sbc.c

index 59302150b89c45905d3aa4bfdf3c18e161eb572b..3c2e7b660f3e32be59b63163e9b36033786e2e67 100644 (file)
@@ -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);
 
index 4efdd419f046c8ed4d05f94fc9d51991675f03cc..6c698a3922578cb72ab2a1bd6c6fac20d7ade04b 100644 (file)
@@ -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 (file)
index 0000000..ec22b45
--- /dev/null
@@ -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);
+}
index e866816472b50669eaf16b903a07bc1a81eb395e..1e9618653f2dbbff4f1d1c3722edc05f3e3c57c7 100644 (file)
 
 #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 */
index 6cf8cf2af80f013495b46bd3f7ce6641cfaa4e99..af8d6f4f9dc5bb90ca71d5e70fc5ee7c5c2ea9a5 100644 (file)
@@ -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.