summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2020-07-30 18:28:08 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2020-08-18 02:01:14 +0900
commit351b74cb6d8787fb3f5f338a761bded7a1d445f5 (patch)
tree322d5a39ab93ea8f31a692ae70e773de0642516e
parent26f0c8600e482b94da4dc00d8f4de367726a1683 (diff)
downloadu-boot-351b74cb6d8787fb3f5f338a761bded7a1d445f5.tar.gz
u-boot-351b74cb6d8787fb3f5f338a761bded7a1d445f5.tar.xz
u-boot-351b74cb6d8787fb3f5f338a761bded7a1d445f5.zip
ARM: uniphier: use FIELD_GET() to get access to revision register fields
Define register fields as macros, and use FIELD_GET(). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--arch/arm/mach-uniphier/sg-regs.h5
-rw-r--r--arch/arm/mach-uniphier/soc-info.c21
2 files changed, 15 insertions, 11 deletions
diff --git a/arch/arm/mach-uniphier/sg-regs.h b/arch/arm/mach-uniphier/sg-regs.h
index f47d101949..a0fa51a8b7 100644
--- a/arch/arm/mach-uniphier/sg-regs.h
+++ b/arch/arm/mach-uniphier/sg-regs.h
@@ -10,6 +10,8 @@
#ifndef UNIPHIER_SG_REGS_H
#define UNIPHIER_SG_REGS_H
+#include <linux/bitops.h>
+
#ifndef __ASSEMBLY__
#include <linux/compiler.h>
#ifdef CONFIG_ARCH_UNIPHIER_V8_MULTI
@@ -24,6 +26,9 @@ extern void __iomem *sg_base;
/* Revision */
#define SG_REVISION 0x0000
+#define SG_REVISION_TYPE_MASK GENMASK(23, 16)
+#define SG_REVISION_MODEL_MASK GENMASK(10, 8)
+#define SG_REVISION_REV_MASK GENMASK(4, 0)
/* Memory Configuration */
#define SG_MEMCONF 0x0400
diff --git a/arch/arm/mach-uniphier/soc-info.c b/arch/arm/mach-uniphier/soc-info.c
index f021a8cab3..b0221016d1 100644
--- a/arch/arm/mach-uniphier/soc-info.c
+++ b/arch/arm/mach-uniphier/soc-info.c
@@ -4,31 +4,30 @@
* Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*/
+#include <linux/bitfield.h>
#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_base + SG_REVISION);
-
- return (revision >> shift) & mask;
-}
-
unsigned int uniphier_get_soc_id(void)
{
- return __uniphier_get_revision_field(0xff, 16);
+ u32 rev = readl(sg_base + SG_REVISION);
+
+ return FIELD_GET(SG_REVISION_TYPE_MASK, rev);
}
unsigned int uniphier_get_soc_model(void)
{
- return __uniphier_get_revision_field(0x7, 8);
+ u32 rev = readl(sg_base + SG_REVISION);
+
+ return FIELD_GET(SG_REVISION_MODEL_MASK, rev);
}
unsigned int uniphier_get_soc_revision(void)
{
- return __uniphier_get_revision_field(0x1f, 0);
+ u32 rev = readl(sg_base + SG_REVISION);
+
+ return FIELD_GET(SG_REVISION_REV_MASK, rev);
}