diff options
Diffstat (limited to 'arch/arm/mach-uniphier/boot-device/boot-device.c')
-rw-r--r-- | arch/arm/mach-uniphier/boot-device/boot-device.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/arch/arm/mach-uniphier/boot-device/boot-device.c b/arch/arm/mach-uniphier/boot-device/boot-device.c index 23be8cfcf0..83f8c6a428 100644 --- a/arch/arm/mach-uniphier/boot-device/boot-device.c +++ b/arch/arm/mach-uniphier/boot-device/boot-device.c @@ -7,6 +7,7 @@ #include <common.h> #include <spl.h> #include <stdio.h> +#include <linux/io.h> #include <linux/log2.h> #include "../init.h" @@ -20,9 +21,11 @@ struct uniphier_boot_device_info { unsigned int boot_device_sel_shift; const struct uniphier_boot_device *boot_device_table; const unsigned int *boot_device_count; + int (*boot_device_is_sd)(u32 pinmon); int (*boot_device_is_usb)(u32 pinmon); unsigned int (*boot_device_fixup)(unsigned int mode); - int have_internal_stm; + int (*boot_is_swapped)(void); + bool have_internal_stm; }; static const struct uniphier_boot_device_info uniphier_boot_device_info[] = { @@ -32,7 +35,8 @@ 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, - .have_internal_stm = 1, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = true, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_PRO4) @@ -41,7 +45,8 @@ 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, - .have_internal_stm = 0, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = false, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_SLD8) @@ -50,7 +55,8 @@ 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, - .have_internal_stm = 1, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = true, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_PRO5) @@ -59,7 +65,8 @@ 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, - .have_internal_stm = 0, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = false, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_PXS2) @@ -70,7 +77,8 @@ 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, - .have_internal_stm = 0, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = false, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_LD6B) @@ -81,7 +89,8 @@ 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, - .have_internal_stm = 1, /* STM on A-chip */ + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = true, /* STM on A-chip */ }, #endif #if defined(CONFIG_ARCH_UNIPHIER_LD11) @@ -91,8 +100,8 @@ 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_device_fixup = uniphier_ld11_boot_device_fixup, - .have_internal_stm = 1, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = true, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_LD20) @@ -102,8 +111,8 @@ 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_device_fixup = uniphier_ld11_boot_device_fixup, - .have_internal_stm = 1, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = true, }, #endif #if defined(CONFIG_ARCH_UNIPHIER_PXS3) @@ -113,7 +122,8 @@ 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, - .have_internal_stm = 0, + .boot_is_swapped = uniphier_sbc_boot_is_swapped, + .have_internal_stm = false, }, #endif }; @@ -126,10 +136,13 @@ 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); + pinmon = readl(sg_base + SG_PINMON0); + + if (info->boot_device_is_sd && info->boot_device_is_sd(pinmon)) + return BOOT_DEVICE_MMC2; if (info->boot_device_is_usb && info->boot_device_is_usb(pinmon)) return BOOT_DEVICE_USB; @@ -187,7 +200,7 @@ int uniphier_have_internal_stm(void) int uniphier_boot_from_backend(void) { - return !!(readl(SG_PINMON0) & BIT(27)); + return !!(readl(sg_base + SG_PINMON0) & BIT(27)); } #ifndef CONFIG_SPL_BUILD @@ -209,9 +222,15 @@ 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_base + SG_PINMON0); - pinmon = readl(SG_PINMON0); + if (info->boot_device_is_sd) + printf("SD Boot: %s\n", + info->boot_device_is_sd(pinmon) ? "ON" : "OFF"); if (info->boot_device_is_usb) printf("USB Boot: %s\n", |