ARM: uniphier: simplify SoC ID get function
Currently, uniphier_get_soc_type() converts the SoC ID (this is
read from the revision register) to an enum symbol to use it for SoC
identification. Come to think of it, there is no need for the
conversion in the first place. Using the SoC ID from the register
as-is a straightforward way.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index ab2c6dc..abfdccc 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -10,7 +10,7 @@
else
-obj-$(CONFIG_DISPLAY_CPUINFO) += cpu_info.o
+obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o
obj-y += dram_init.o
obj-y += board_init.o
obj-$(CONFIG_BOARD_LATE_INIT) += board_late_init.o
@@ -22,7 +22,7 @@
endif
obj-y += boards.o
-obj-y += soc_info.o
+obj-y += soc-info.o
obj-y += boot-mode/
obj-y += clk/
obj-y += dram/
diff --git a/arch/arm/mach-uniphier/arm32/psci.c b/arch/arm/mach-uniphier/arm32/psci.c
index e668265..65a468d 100644
--- a/arch/arm/mach-uniphier/arm32/psci.c
+++ b/arch/arm/mach-uniphier/arm32/psci.c
@@ -28,13 +28,13 @@
static int uniphier_get_nr_cpus(void)
{
- switch (uniphier_get_soc_type()) {
- case SOC_UNIPHIER_SLD3:
- case SOC_UNIPHIER_PRO4:
- case SOC_UNIPHIER_PRO5:
+ switch (uniphier_get_soc_id()) {
+ case UNIPHIER_SLD3_ID:
+ case UNIPHIER_PRO4_ID:
+ case UNIPHIER_PRO5_ID:
return 2;
- case SOC_UNIPHIER_PXS2:
- case SOC_UNIPHIER_LD6B:
+ case UNIPHIER_PXS2_ID:
+ case UNIPHIER_LD6B_ID:
return 4;
default:
return 1;
diff --git a/arch/arm/mach-uniphier/board_init.c b/arch/arm/mach-uniphier/board_init.c
index 2269291..413b338 100644
--- a/arch/arm/mach-uniphier/board_init.c
+++ b/arch/arm/mach-uniphier/board_init.c
@@ -80,7 +80,7 @@
#endif
struct uniphier_initdata {
- enum uniphier_soc_id soc_id;
+ unsigned int soc_id;
bool nand_2cs;
void (*sbc_init)(void);
void (*pll_init)(void);
@@ -91,7 +91,7 @@
static const struct uniphier_initdata uniphier_initdata[] = {
#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
{
- .soc_id = SOC_UNIPHIER_SLD3,
+ .soc_id = UNIPHIER_SLD3_ID,
.nand_2cs = true,
.sbc_init = uniphier_sbc_init_admulti,
.pll_init = uniphier_sld3_pll_init,
@@ -100,7 +100,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD4)
{
- .soc_id = SOC_UNIPHIER_LD4,
+ .soc_id = UNIPHIER_LD4_ID,
.nand_2cs = true,
.sbc_init = uniphier_ld4_sbc_init,
.pll_init = uniphier_ld4_pll_init,
@@ -109,7 +109,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
{
- .soc_id = SOC_UNIPHIER_PRO4,
+ .soc_id = UNIPHIER_PRO4_ID,
.nand_2cs = false,
.sbc_init = uniphier_sbc_init_savepin,
.pll_init = uniphier_pro4_pll_init,
@@ -118,7 +118,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
{
- .soc_id = SOC_UNIPHIER_SLD8,
+ .soc_id = UNIPHIER_SLD8_ID,
.nand_2cs = true,
.sbc_init = uniphier_ld4_sbc_init,
.pll_init = uniphier_ld4_pll_init,
@@ -127,7 +127,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
{
- .soc_id = SOC_UNIPHIER_PRO5,
+ .soc_id = UNIPHIER_PRO5_ID,
.nand_2cs = true,
.sbc_init = uniphier_sbc_init_savepin,
.clk_init = uniphier_pro5_clk_init,
@@ -135,7 +135,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
{
- .soc_id = SOC_UNIPHIER_PXS2,
+ .soc_id = UNIPHIER_PXS2_ID,
.nand_2cs = true,
.sbc_init = uniphier_pxs2_sbc_init,
.clk_init = uniphier_pxs2_clk_init,
@@ -143,7 +143,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
{
- .soc_id = SOC_UNIPHIER_LD6B,
+ .soc_id = UNIPHIER_LD6B_ID,
.nand_2cs = true,
.sbc_init = uniphier_pxs2_sbc_init,
.clk_init = uniphier_pxs2_clk_init,
@@ -151,7 +151,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11)
{
- .soc_id = SOC_UNIPHIER_LD11,
+ .soc_id = UNIPHIER_LD11_ID,
.nand_2cs = false,
.sbc_init = uniphier_ld11_sbc_init,
.pll_init = uniphier_ld11_pll_init,
@@ -161,7 +161,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD20)
{
- .soc_id = SOC_UNIPHIER_LD20,
+ .soc_id = UNIPHIER_LD20_ID,
.nand_2cs = false,
.sbc_init = uniphier_ld11_sbc_init,
.pll_init = uniphier_ld20_pll_init,
@@ -171,7 +171,7 @@
};
static const struct uniphier_initdata *uniphier_get_initdata(
- enum uniphier_soc_id soc_id)
+ unsigned int soc_id)
{
int i;
@@ -186,12 +186,12 @@
int board_init(void)
{
const struct uniphier_initdata *initdata;
- enum uniphier_soc_id soc_id;
+ unsigned int soc_id;
int ret;
led_puts("U0");
- soc_id = uniphier_get_soc_type();
+ soc_id = uniphier_get_soc_id();
initdata = uniphier_get_initdata(soc_id);
if (!initdata) {
pr_err("unsupported board\n");
diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c b/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c
index 24255a0f..2992fd7 100644
--- a/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c
+++ b/arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
+ * Copyright (C) 2016-2017 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -57,14 +58,14 @@
int boot_mode;
u32 usb_boot_mask;
- switch (uniphier_get_soc_type()) {
+ switch (uniphier_get_soc_id()) {
#if defined(CONFIG_ARCH_UNIPHIER_LD11)
- case SOC_UNIPHIER_LD11:
+ case UNIPHIER_LD11_ID:
usb_boot_mask = 0x00000080;
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD20)
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD20_ID:
usb_boot_mask = 0x00000780;
break;
#endif
diff --git a/arch/arm/mach-uniphier/boot-mode/boot-mode.c b/arch/arm/mach-uniphier/boot-mode/boot-mode.c
index ebe0578..a552770 100644
--- a/arch/arm/mach-uniphier/boot-mode/boot-mode.c
+++ b/arch/arm/mach-uniphier/boot-mode/boot-mode.c
@@ -18,30 +18,30 @@
if (boot_is_swapped())
return BOOT_DEVICE_NOR;
- switch (uniphier_get_soc_type()) {
+ switch (uniphier_get_soc_id()) {
#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
- case SOC_UNIPHIER_SLD3:
+ case UNIPHIER_SLD3_ID:
return uniphier_sld3_boot_device();
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \
defined(CONFIG_ARCH_UNIPHIER_SLD8)
- case SOC_UNIPHIER_LD4:
- case SOC_UNIPHIER_PRO4:
- case SOC_UNIPHIER_SLD8:
+ case UNIPHIER_LD4_ID:
+ case UNIPHIER_PRO4_ID:
+ case UNIPHIER_SLD8_ID:
return uniphier_ld4_boot_device();
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
- case SOC_UNIPHIER_PRO5:
+ case UNIPHIER_PRO5_ID:
return uniphier_pro5_boot_device();
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
- case SOC_UNIPHIER_PXS2:
- case SOC_UNIPHIER_LD6B:
+ case UNIPHIER_PXS2_ID:
+ case UNIPHIER_LD6B_ID:
return uniphier_pxs2_boot_device();
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
- case SOC_UNIPHIER_LD11:
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD11_ID:
+ case UNIPHIER_LD20_ID:
return uniphier_ld20_boot_device();
#endif
default:
@@ -55,17 +55,17 @@
mode = spl_boot_device_raw();
- switch (uniphier_get_soc_type()) {
+ switch (uniphier_get_soc_id()) {
#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
- case SOC_UNIPHIER_PXS2:
- case SOC_UNIPHIER_LD6B:
+ case UNIPHIER_PXS2_ID:
+ case UNIPHIER_LD6B_ID:
if (mode == BOOT_DEVICE_USB)
mode = BOOT_DEVICE_NOR;
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
- case SOC_UNIPHIER_LD11:
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD11_ID:
+ case UNIPHIER_LD20_ID:
if (mode == BOOT_DEVICE_MMC1 || mode == BOOT_DEVICE_USB)
mode = BOOT_DEVICE_BOARD;
break;
diff --git a/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c b/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c
index a8ee382..670d4f6 100644
--- a/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c
+++ b/arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c
@@ -14,34 +14,34 @@
{
printf("Boot Swap: %s\n\n", boot_is_swapped() ? "ON" : "OFF");
- switch (uniphier_get_soc_type()) {
+ switch (uniphier_get_soc_id()) {
#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
- case SOC_UNIPHIER_SLD3:
+ case UNIPHIER_SLD3_ID:
uniphier_sld3_boot_mode_show();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \
defined(CONFIG_ARCH_UNIPHIER_SLD8)
- case SOC_UNIPHIER_LD4:
- case SOC_UNIPHIER_PRO4:
- case SOC_UNIPHIER_SLD8:
+ case UNIPHIER_LD4_ID:
+ case UNIPHIER_PRO4_ID:
+ case UNIPHIER_SLD8_ID:
uniphier_ld4_boot_mode_show();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
- case SOC_UNIPHIER_PRO5:
+ case UNIPHIER_PRO5_ID:
uniphier_pro5_boot_mode_show();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
- case SOC_UNIPHIER_PXS2:
- case SOC_UNIPHIER_LD6B:
+ case UNIPHIER_PXS2_ID:
+ case UNIPHIER_LD6B_ID:
uniphier_pxs2_boot_mode_show();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
- case SOC_UNIPHIER_LD11:
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD11_ID:
+ case UNIPHIER_LD20_ID:
uniphier_ld20_boot_mode_show();
break;
#endif
diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c
index a6b6686..0aac924 100644
--- a/arch/arm/mach-uniphier/boot-mode/spl_board.c
+++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c
@@ -40,11 +40,11 @@
{
const struct uniphier_romfunc_table *table;
- switch (uniphier_get_soc_type()) {
- case SOC_UNIPHIER_LD11:
+ switch (uniphier_get_soc_id()) {
+ case UNIPHIER_LD11_ID:
table = &uniphier_ld11_romfunc_table;
break;
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD20_ID:
table = &uniphier_ld20_romfunc_table;
break;
default:
diff --git a/arch/arm/mach-uniphier/cpu-info.c b/arch/arm/mach-uniphier/cpu-info.c
new file mode 100644
index 0000000..a9c8167
--- /dev/null
+++ b/arch/arm/mach-uniphier/cpu-info.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013-2014 Panasonic Corporation
+ * Copyright (C) 2015-2017 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+
+#include "soc-info.h"
+
+int print_cpuinfo(void)
+{
+ unsigned int id, model, rev, required_model = 1, required_rev = 1;
+
+ id = uniphier_get_soc_id();
+ model = uniphier_get_soc_model();
+ rev = uniphier_get_soc_revision();
+
+ puts("CPU: ");
+
+ switch (id) {
+ case UNIPHIER_SLD3_ID:
+ puts("sLD3 (MN2WS0220)");
+ required_model = 2;
+ break;
+ case UNIPHIER_LD4_ID:
+ puts("LD4 (MN2WS0250)");
+ required_rev = 2;
+ break;
+ case UNIPHIER_PRO4_ID:
+ puts("Pro4 (MN2WS0230)");
+ break;
+ case UNIPHIER_SLD8_ID:
+ puts("sLD8 (MN2WS0270)");
+ break;
+ case UNIPHIER_PRO5_ID:
+ puts("Pro5 (MN2WS0300)");
+ break;
+ case UNIPHIER_PXS2_ID:
+ puts("PXs2 (MN2WS0310)");
+ break;
+ case UNIPHIER_LD6B_ID:
+ puts("LD6b (MN2WS0320)");
+ break;
+ case UNIPHIER_LD11_ID:
+ puts("LD11 (SC1405AP1)");
+ break;
+ case UNIPHIER_LD20_ID:
+ puts("LD20 (SC1401AJ1)");
+ break;
+ default:
+ printf("Unknown Processor ID (0x%x)\n", id);
+ return -ENOTSUPP;
+ }
+
+ printf(" model %d (revision %d)\n", model, rev);
+
+ if (model < required_model) {
+ printf("Only model %d or newer is supported.\n",
+ required_model);
+ return -ENOTSUPP;
+ } else if (rev < required_rev) {
+ printf("Only revision %d or newer is supported.\n",
+ required_rev);
+ return -ENOTSUPP;
+ }
+
+ return 0;
+}
diff --git a/arch/arm/mach-uniphier/cpu_info.c b/arch/arm/mach-uniphier/cpu_info.c
deleted file mode 100644
index 6ad4c76..0000000
--- a/arch/arm/mach-uniphier/cpu_info.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2013-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <common.h>
-#include <linux/io.h>
-
-#include "sg-regs.h"
-
-int print_cpuinfo(void)
-{
- u32 revision, type, model, rev, required_model = 1, required_rev = 1;
-
- revision = readl(SG_REVISION);
- type = (revision & SG_REVISION_TYPE_MASK) >> SG_REVISION_TYPE_SHIFT;
- model = (revision & SG_REVISION_MODEL_MASK) >> SG_REVISION_MODEL_SHIFT;
- rev = (revision & SG_REVISION_REV_MASK) >> SG_REVISION_REV_SHIFT;
-
- puts("CPU: ");
-
- switch (type) {
- case 0x25:
- puts("PH1-sLD3 (MN2WS0220)");
- required_model = 2;
- break;
- case 0x26:
- puts("PH1-LD4 (MN2WS0250)");
- required_rev = 2;
- break;
- case 0x28:
- puts("PH1-Pro4 (MN2WS0230)");
- break;
- case 0x29:
- puts("PH1-sLD8 (MN2WS0270)");
- break;
- case 0x2A:
- puts("PH1-Pro5 (MN2WS0300)");
- break;
- case 0x2E:
- puts("ProXstream2 (MN2WS0310)");
- break;
- case 0x2F:
- puts("PH1-LD6b (MN2WS0320)");
- break;
- case 0x31:
- puts("PH1-LD11 (SC1405AP1)");
- break;
- case 0x32:
- puts("PH1-LD20 (SC1401AJ1)");
- break;
- default:
- printf("Unknown Processor ID (0x%x)\n", revision);
- return -1;
- }
-
- printf(" model %d", model);
-
- printf(" (rev. %d)\n", rev);
-
- if (model < required_model) {
- printf("Sorry, this model is not supported.\n");
- printf("Required model is %d.", required_model);
- return -1;
- } else if (rev < required_rev) {
- printf("Sorry, this revision is not supported.\n");
- printf("Required revision is %d.", required_rev);
- return -1;
- }
-
- return 0;
-}
diff --git a/arch/arm/mach-uniphier/debug-uart/debug-uart.c b/arch/arm/mach-uniphier/debug-uart/debug-uart.c
index d884785..72a514d 100644
--- a/arch/arm/mach-uniphier/debug-uart/debug-uart.c
+++ b/arch/arm/mach-uniphier/debug-uart/debug-uart.c
@@ -32,45 +32,45 @@
void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
unsigned int divisor;
- switch (uniphier_get_soc_type()) {
+ switch (uniphier_get_soc_id()) {
#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
- case SOC_UNIPHIER_SLD3:
+ case UNIPHIER_SLD3_ID:
divisor = uniphier_sld3_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD4)
- case SOC_UNIPHIER_LD4:
+ case UNIPHIER_LD4_ID:
divisor = uniphier_ld4_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
- case SOC_UNIPHIER_PRO4:
+ case UNIPHIER_PRO4_ID:
divisor = uniphier_pro4_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
- case SOC_UNIPHIER_SLD8:
+ case UNIPHIER_SLD8_ID:
divisor = uniphier_sld8_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
- case SOC_UNIPHIER_PRO5:
+ case UNIPHIER_PRO5_ID:
divisor = uniphier_pro5_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
- case SOC_UNIPHIER_PXS2:
+ case UNIPHIER_PXS2_ID:
divisor = uniphier_pxs2_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
- case SOC_UNIPHIER_LD6B:
+ case UNIPHIER_LD6B_ID:
divisor = uniphier_ld6b_debug_uart_init();
break;
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
- case SOC_UNIPHIER_LD11:
- case SOC_UNIPHIER_LD20:
+ case UNIPHIER_LD11_ID:
+ case UNIPHIER_LD20_ID:
divisor = uniphier_ld20_debug_uart_init();
break;
#endif
diff --git a/arch/arm/mach-uniphier/dram/cmd_ddrphy.c b/arch/arm/mach-uniphier/dram/cmd_ddrphy.c
index 9730330..d6d9db3 100644
--- a/arch/arm/mach-uniphier/dram/cmd_ddrphy.c
+++ b/arch/arm/mach-uniphier/dram/cmd_ddrphy.c
@@ -245,17 +245,17 @@
char *cmd = argv[1];
const struct phy_param *phy_param;
- switch (uniphier_get_soc_type()) {
- case SOC_UNIPHIER_LD4:
+ switch (uniphier_get_soc_id()) {
+ case UNIPHIER_LD4_ID:
phy_param = uniphier_ld4_phy_param;
break;
- case SOC_UNIPHIER_PRO4:
+ case UNIPHIER_PRO4_ID:
phy_param = uniphier_pro4_phy_param;
break;
- case SOC_UNIPHIER_SLD8:
+ case UNIPHIER_SLD8_ID:
phy_param = uniphier_sld8_phy_param;
break;
- case SOC_UNIPHIER_LD11:
+ case UNIPHIER_LD11_ID:
phy_param = uniphier_ld11_phy_param;
break;
default:
diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c
index 87418f4..2cf5f36 100644
--- a/arch/arm/mach-uniphier/dram_init.c
+++ b/arch/arm/mach-uniphier/dram_init.c
@@ -97,7 +97,7 @@
const unsigned long rsv_size = 64;
int ch, ret;
- if (uniphier_get_soc_type() != SOC_UNIPHIER_LD20)
+ if (uniphier_get_soc_id() != UNIPHIER_LD20_ID)
return 0;
param = uniphier_get_board_param();
diff --git a/arch/arm/mach-uniphier/sg-regs.h b/arch/arm/mach-uniphier/sg-regs.h
index a179d61..4d7e6f7 100644
--- a/arch/arm/mach-uniphier/sg-regs.h
+++ b/arch/arm/mach-uniphier/sg-regs.h
@@ -1,13 +1,15 @@
/*
* UniPhier SG (SoC Glue) block registers
*
- * Copyright (C) 2011-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
+ * Copyright (C) 2011-2015 Copyright (C) 2011-2015 Panasonic Corporation
+ * Copyright (C) 2016-2017 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
-#ifndef ARCH_SG_REGS_H
-#define ARCH_SG_REGS_H
+#ifndef UNIPHIER_SG_REGS_H
+#define UNIPHIER_SG_REGS_H
/* Base Address */
#define SG_CTRL_BASE 0x5f800000
@@ -15,12 +17,6 @@
/* Revision */
#define SG_REVISION (SG_CTRL_BASE | 0x0000)
-#define SG_REVISION_TYPE_SHIFT 16
-#define SG_REVISION_TYPE_MASK (0xff << SG_REVISION_TYPE_SHIFT)
-#define SG_REVISION_MODEL_SHIFT 8
-#define SG_REVISION_MODEL_MASK (0x3 << SG_REVISION_MODEL_SHIFT)
-#define SG_REVISION_REV_SHIFT 0
-#define SG_REVISION_REV_MASK (0x1f << SG_REVISION_REV_SHIFT)
/* Memory Configuration */
#define SG_MEMCONF (SG_CTRL_BASE | 0x0400)
@@ -140,4 +136,4 @@
#endif /* __ASSEMBLY__ */
-#endif /* ARCH_SG_REGS_H */
+#endif /* UNIPHIER_SG_REGS_H */
diff --git a/arch/arm/mach-uniphier/soc-info.c b/arch/arm/mach-uniphier/soc-info.c
new file mode 100644
index 0000000..baf1be6
--- /dev/null
+++ b/arch/arm/mach-uniphier/soc-info.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <linux/io.h>
+#include <linux/types.h>
+
+#include "sg-regs.h"
+#include "soc-info.h"
+
+static unsigned int __uniphier_get_revision_field(unsigned int mask,
+ unsigned int shift)
+{
+ u32 revision = readl(SG_REVISION);
+
+ return (revision >> shift) & mask;
+}
+
+unsigned int uniphier_get_soc_id(void)
+{
+ return __uniphier_get_revision_field(0xff, 16);
+}
+
+unsigned int uniphier_get_soc_model(void)
+{
+ return __uniphier_get_revision_field(0x3, 8);
+}
+
+unsigned int uniphier_get_soc_revision(void)
+{
+ return __uniphier_get_revision_field(0x1f, 0);
+}
diff --git a/arch/arm/mach-uniphier/soc-info.h b/arch/arm/mach-uniphier/soc-info.h
index d9b38b3..b528fa9 100644
--- a/arch/arm/mach-uniphier/soc-info.h
+++ b/arch/arm/mach-uniphier/soc-info.h
@@ -1,76 +1,25 @@
/*
- * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
+ * Copyright (C) 2017 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
-#ifndef __MACH_SOC_INFO_H__
-#define __MACH_SOC_INFO_H__
+#ifndef __UNIPHIER_SOC_INFO_H__
+#define __UNIPHIER_SOC_INFO_H__
-enum uniphier_soc_id {
- SOC_UNIPHIER_SLD3,
- SOC_UNIPHIER_LD4,
- SOC_UNIPHIER_PRO4,
- SOC_UNIPHIER_SLD8,
- SOC_UNIPHIER_PRO5,
- SOC_UNIPHIER_PXS2,
- SOC_UNIPHIER_LD6B,
- SOC_UNIPHIER_LD11,
- SOC_UNIPHIER_LD20,
- SOC_UNIPHIER_UNKNOWN,
-};
+#define UNIPHIER_SLD3_ID 0x25
+#define UNIPHIER_LD4_ID 0x26
+#define UNIPHIER_PRO4_ID 0x28
+#define UNIPHIER_SLD8_ID 0x29
+#define UNIPHIER_PRO5_ID 0x2a
+#define UNIPHIER_PXS2_ID 0x2e
+#define UNIPHIER_LD6B_ID 0x2f
+#define UNIPHIER_LD11_ID 0x31
+#define UNIPHIER_LD20_ID 0x32
-#define UNIPHIER_NR_ENABLED_SOCS \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_SLD3) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD4) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_PRO4) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_SLD8) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_PRO5) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_PXS2) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD6B) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD11) + \
- IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD20)
-
-#define UNIPHIER_MULTI_SOC ((UNIPHIER_NR_ENABLED_SOCS) > 1)
-
-#if UNIPHIER_MULTI_SOC
-enum uniphier_soc_id uniphier_get_soc_type(void);
-#else
-static inline enum uniphier_soc_id uniphier_get_soc_type(void)
-{
-#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
- return SOC_UNIPHIER_SLD3;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_LD4)
- return SOC_UNIPHIER_LD4;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
- return SOC_UNIPHIER_PRO4;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
- return SOC_UNIPHIER_SLD8;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
- return SOC_UNIPHIER_PRO5;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
- return SOC_UNIPHIER_PXS2;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
- return SOC_UNIPHIER_LD6B;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_LD11)
- return SOC_UNIPHIER_LD11;
-#endif
-#if defined(CONFIG_ARCH_UNIPHIER_LD20)
- return SOC_UNIPHIER_LD20;
-#endif
-
- return SOC_UNIPHIER_UNKNOWN;
-}
-#endif
-
-int uniphier_get_soc_model(void);
-int uniphier_get_soc_revision(void);
+unsigned int uniphier_get_soc_id(void);
+unsigned int uniphier_get_soc_model(void);
+unsigned int uniphier_get_soc_revision(void);
-#endif /* __MACH_SOC_INFO_H__ */
+#endif /* __UNIPHIER_SOC_INFO_H__ */
diff --git a/arch/arm/mach-uniphier/soc_info.c b/arch/arm/mach-uniphier/soc_info.c
deleted file mode 100644
index 046104b..0000000
--- a/arch/arm/mach-uniphier/soc_info.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <linux/io.h>
-#include <linux/types.h>
-
-#include "sg-regs.h"
-#include "soc-info.h"
-
-#if UNIPHIER_MULTI_SOC
-enum uniphier_soc_id uniphier_get_soc_type(void)
-{
- u32 revision = readl(SG_REVISION);
- enum uniphier_soc_id ret;
-
- switch ((revision & SG_REVISION_TYPE_MASK) >> SG_REVISION_TYPE_SHIFT) {
-#ifdef CONFIG_ARCH_UNIPHIER_SLD3
- case 0x25:
- ret = SOC_UNIPHIER_SLD3;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_LD4
- case 0x26:
- ret = SOC_UNIPHIER_LD4;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_PRO4
- case 0x28:
- ret = SOC_UNIPHIER_PRO4;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_SLD8
- case 0x29:
- ret = SOC_UNIPHIER_SLD8;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_PRO5
- case 0x2A:
- ret = SOC_UNIPHIER_PRO5;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_PXS2
- case 0x2E:
- ret = SOC_UNIPHIER_PXS2;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_LD6B
- case 0x2F:
- ret = SOC_UNIPHIER_LD6B;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_LD11
- case 0x31:
- ret = SOC_UNIPHIER_LD11;
- break;
-#endif
-#ifdef CONFIG_ARCH_UNIPHIER_LD20
- case 0x32:
- ret = SOC_UNIPHIER_LD20;
- break;
-#endif
- default:
- ret = SOC_UNIPHIER_UNKNOWN;
- break;
- }
-
- return ret;
-}
-#endif
-
-int uniphier_get_soc_model(void)
-{
- return (readl(SG_REVISION) & SG_REVISION_MODEL_MASK) >>
- SG_REVISION_MODEL_SHIFT;
-}
-
-int uniphier_get_soc_revision(void)
-{
- return (readl(SG_REVISION) & SG_REVISION_REV_MASK) >>
- SG_REVISION_REV_SHIFT;
-}
diff --git a/arch/arm/mach-uniphier/spl_board_init.c b/arch/arm/mach-uniphier/spl_board_init.c
index f4e1cb9..83851ef 100644
--- a/arch/arm/mach-uniphier/spl_board_init.c
+++ b/arch/arm/mach-uniphier/spl_board_init.c
@@ -14,7 +14,7 @@
#include "soc-info.h"
struct uniphier_spl_initdata {
- enum uniphier_soc_id soc_id;
+ unsigned int soc_id;
void (*bcu_init)(const struct uniphier_board_data *bd);
void (*early_clk_init)(void);
int (*dpll_init)(const struct uniphier_board_data *bd);
@@ -26,7 +26,7 @@
static const struct uniphier_spl_initdata uniphier_spl_initdata[] = {
#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
{
- .soc_id = SOC_UNIPHIER_SLD3,
+ .soc_id = UNIPHIER_SLD3_ID,
.bcu_init = uniphier_sld3_bcu_init,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_sld3_dpll_init,
@@ -37,7 +37,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD4)
{
- .soc_id = SOC_UNIPHIER_LD4,
+ .soc_id = UNIPHIER_LD4_ID,
.bcu_init = uniphier_ld4_bcu_init,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_ld4_dpll_init,
@@ -48,7 +48,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
{
- .soc_id = SOC_UNIPHIER_PRO4,
+ .soc_id = UNIPHIER_PRO4_ID,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_pro4_dpll_init,
.memconf_init = uniphier_memconf_2ch_init,
@@ -58,7 +58,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
{
- .soc_id = SOC_UNIPHIER_SLD8,
+ .soc_id = UNIPHIER_SLD8_ID,
.bcu_init = uniphier_ld4_bcu_init,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_sld8_dpll_init,
@@ -69,7 +69,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
{
- .soc_id = SOC_UNIPHIER_PRO5,
+ .soc_id = UNIPHIER_PRO5_ID,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_pro5_dpll_init,
.memconf_init = uniphier_memconf_2ch_init,
@@ -79,7 +79,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
{
- .soc_id = SOC_UNIPHIER_PXS2,
+ .soc_id = UNIPHIER_PXS2_ID,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_pxs2_dpll_init,
.memconf_init = uniphier_memconf_3ch_init,
@@ -89,7 +89,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
{
- .soc_id = SOC_UNIPHIER_LD6B,
+ .soc_id = UNIPHIER_LD6B_ID,
.early_clk_init = uniphier_sld3_early_clk_init,
.dpll_init = uniphier_pxs2_dpll_init,
.memconf_init = uniphier_memconf_3ch_init,
@@ -99,7 +99,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD11)
{
- .soc_id = SOC_UNIPHIER_LD11,
+ .soc_id = UNIPHIER_LD11_ID,
.early_clk_init = uniphier_ld11_early_clk_init,
.dpll_init = uniphier_ld11_dpll_init,
.memconf_init = uniphier_memconf_2ch_init,
@@ -109,7 +109,7 @@
#endif
#if defined(CONFIG_ARCH_UNIPHIER_LD20)
{
- .soc_id = SOC_UNIPHIER_LD20,
+ .soc_id = UNIPHIER_LD20_ID,
.early_clk_init = uniphier_ld11_early_clk_init,
.dpll_init = uniphier_ld20_dpll_init,
.memconf_init = uniphier_memconf_3ch_init,
@@ -120,7 +120,7 @@
};
static const struct uniphier_spl_initdata *uniphier_get_spl_initdata(
- enum uniphier_soc_id soc_id)
+ unsigned int soc_id)
{
int i;
@@ -136,7 +136,7 @@
{
const struct uniphier_board_data *bd;
const struct uniphier_spl_initdata *initdata;
- enum uniphier_soc_id soc_id;
+ unsigned int soc_id;
int ret;
#ifdef CONFIG_DEBUG_UART
@@ -147,7 +147,7 @@
if (!bd)
hang();
- soc_id = uniphier_get_soc_type();
+ soc_id = uniphier_get_soc_id();
initdata = uniphier_get_spl_initdata(soc_id);
if (!initdata)
hang();