From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 4/6] ARM: i.MX8MQ: Replace magic numbers with named constants
Date: Fri, 10 Aug 2018 12:04:27 -0700 [thread overview]
Message-ID: <20180810190429.10823-5-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20180810190429.10823-1-andrew.smirnov@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/mach-imx/imx8mq.c | 6 +++---
arch/arm/mach-imx/include/mach/imx8mq.h | 11 ++++++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-imx/imx8mq.c b/arch/arm/mach-imx/imx8mq.c
index bc463ee75..95839f31d 100644
--- a/arch/arm/mach-imx/imx8mq.c
+++ b/arch/arm/mach-imx/imx8mq.c
@@ -47,13 +47,13 @@ core_initcall(imx8mq_init_syscnt_frequency);
int imx8mq_init(void)
{
void __iomem *anatop = IOMEM(MX8MQ_ANATOP_BASE_ADDR);
- uint32_t reg = readl(anatop + MX8MQ_ANATOP_DIGPROG);
- uint32_t type = (reg >> 16) & 0xff;
+ uint32_t type = FIELD_GET(DIGPROG_MAJOR,
+ readl(anatop + MX8MQ_ANATOP_DIGPROG));
struct arm_smccc_res res;
const char *cputypestr;
switch (type) {
- case 0x82:
+ case IMX8M_CPUTYPE_IMX8MQ:
cputypestr = "i.MX8MQ";
break;
default:
diff --git a/arch/arm/mach-imx/include/mach/imx8mq.h b/arch/arm/mach-imx/include/mach/imx8mq.h
index f51d4e664..f4a537d2b 100644
--- a/arch/arm/mach-imx/include/mach/imx8mq.h
+++ b/arch/arm/mach-imx/include/mach/imx8mq.h
@@ -5,18 +5,23 @@
#include <mach/generic.h>
#include <mach/imx8mq-regs.h>
#include <mach/revision.h>
+#include <linux/bitfield.h>
#define IMX8MQ_ROM_VERSION_A0 0x800
#define IMX8MQ_ROM_VERSION_B0 0x83C
#define MX8MQ_ANATOP_DIGPROG 0x6c
+#define DIGPROG_MAJOR GENMASK(23, 8)
+#define DIGPROG_MINOR GENMASK(7, 0)
+
+#define IMX8M_CPUTYPE_IMX8MQ 0x8240
+
static inline int imx8mq_cpu_revision(void)
{
void __iomem *anatop = IOMEM(MX8MQ_ANATOP_BASE_ADDR);
- uint32_t revision = readl(anatop + MX8MQ_ANATOP_DIGPROG);
-
- revision &= 0xff;
+ uint32_t revision = FIELD_GET(DIGPROG_MINOR,
+ readl(anatop + MX8MQ_ANATOP_DIGPROG));
if (revision == IMX_CHIP_REV_1_0) {
uint32_t rom_version;
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-10 19:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 19:04 [PATCH 0/6] i.MX8MQ boot source, reset reason, etc Andrey Smirnov
2018-08-10 19:04 ` [PATCH 1/6] ARM: i.MX8M: Expose code to query cpu revision Andrey Smirnov
2018-08-10 19:04 ` [PATCH 2/6] ARM: i.MX: boot: Fix accidental comma Andrey Smirnov
2018-08-10 19:04 ` [PATCH 3/6] ARM: i.MX: boot: Rework boot source detection for i.MX7 and i.MX8MQ Andrey Smirnov
2018-08-13 7:10 ` Sascha Hauer
2018-08-13 14:15 ` Andrey Smirnov
2018-08-10 19:04 ` Andrey Smirnov [this message]
2018-08-10 19:04 ` [PATCH 5/6] ARM: i.MX8MQ: Add code to detect reset reason Andrey Smirnov
2018-08-10 19:04 ` [PATCH 6/6] ARM: i.MX8MQ: Save boot location during initialization Andrey Smirnov
2018-08-13 7:12 ` [PATCH 0/6] i.MX8MQ boot source, reset reason, etc Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180810190429.10823-5-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox