mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] sp804: introduce amba_is_arm_sp804 to detect if the sp804 is present at the address
Date: Tue, 12 Feb 2013 14:03:26 +0100	[thread overview]
Message-ID: <1360674207-12078-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1360674207-12078-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/clocksource/amba-sp804.c |    6 +++---
 include/linux/amba/sp804.h       |   30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 include/linux/amba/sp804.h

diff --git a/drivers/clocksource/amba-sp804.c b/drivers/clocksource/amba-sp804.c
index d9a30c2..fedcb64 100644
--- a/drivers/clocksource/amba-sp804.c
+++ b/drivers/clocksource/amba-sp804.c
@@ -9,7 +9,7 @@
 #include <io.h>
 #include <driver.h>
 #include <errno.h>
-#include <linux/amba/bus.h>
+#include <linux/amba/sp804.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 
@@ -73,8 +73,8 @@ static int sp804_probe(struct amba_device *dev, const struct amba_id *id)
 
 static struct amba_id sp804_ids[] = {
 	{
-		.id	= 0x00141804,
-		.mask	= 0x00ffffff,
+		.id	= AMBA_ARM_SP804_ID,
+		.mask	= AMBA_ARM_SP804_ID_MASK,
 	},
 	{ 0, 0 },
 };
diff --git a/include/linux/amba/sp804.h b/include/linux/amba/sp804.h
new file mode 100644
index 0000000..aba550c
--- /dev/null
+++ b/include/linux/amba/sp804.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __AMBA_SP804_H__
+#define __AMBA_SP804_H__
+
+#include <linux/amba/bus.h>
+#include <sizes.h>
+
+#define AMBA_ARM_SP804_ID	0x00141804
+#define AMBA_ARM_SP804_ID_MASK	0x00ffffff
+
+static inline bool amba_is_arm_sp804(void __iomem *base)
+{
+	u32 pid, cid;
+	u32 size = SZ_4K;
+
+	cid = amba_device_get_cid(base, size);
+
+	if (cid != AMBA_CID)
+		return false;
+
+	pid = amba_device_get_pid(base, size);
+
+	return (pid & AMBA_ARM_SP804_ID_MASK) == AMBA_ARM_SP804_ID;
+}
+#endif /* __AMBA_SP804_H__ */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-02-12 13:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-12 13:00 [PATCH 0/3] vexpress: detect the mapping based on the amba devices Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 13:03 ` [PATCH 1/3] amba: introduce amba_device_get_pid/cid Jean-Christophe PLAGNIOL-VILLARD
2013-02-12 13:03   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-02-12 13:03   ` [PATCH 3/3] vexpress: detect the board periph mapping and detecting the sp804 mapping Jean-Christophe PLAGNIOL-VILLARD

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=1360674207-12078-2-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.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