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/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);
+}