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 1/3] amba: introduce amba_device_get_pid/cid
Date: Tue, 12 Feb 2013 14:03:25 +0100	[thread overview]
Message-ID: <1360674207-12078-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20130212130012.GD19322@game.jcrosoft.org>

so we can use it on vexpress to detect the hardware mapping

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/amba/bus.c       |   10 +++-------
 include/linux/amba/bus.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index d1ab53c..65385be 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -104,7 +104,7 @@ int amba_device_add(struct amba_device *dev)
 {
 	u32 size;
 	void __iomem *tmp;
-	int i, ret;
+	int ret;
 	struct resource *res = NULL;
 
 	dev->dev.bus = &amba_bustype;
@@ -135,12 +135,8 @@ int amba_device_add(struct amba_device *dev)
 		 * Read pid and cid based on size of resource
 		 * they are located at end of region
 		 */
-		for (pid = 0, i = 0; i < 4; i++)
-			pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
-				(i * 8);
-		for (cid = 0, i = 0; i < 4; i++)
-			cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
-				(i * 8);
+		pid = amba_device_get_pid(tmp, size);
+		cid = amba_device_get_cid(tmp, size);
 
 		if (cid == AMBA_CID)
 			dev->periphid = pid;
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index cb3e3bd..a7bbae0 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -150,4 +150,32 @@ struct amba_device name##_device = {				\
 	.periphid = id,						\
 }
 
+#include <io.h>
+/*
+ * Read pid and cid based on size of resource
+ * they are located at end of region
+ */
+static inline u32 amba_device_get_pid(void *base, u32 size)
+{
+	int i;
+	u32 pid;
+
+	for (pid = 0, i = 0; i < 4; i++)
+		pid |= (readl(base + size - 0x20 + 4 * i) & 255) <<
+			(i * 8);
+
+	return pid;
+}
+
+static inline u32 amba_device_get_cid(void *base, u32 size)
+{
+	int i;
+	u32 cid;
+
+	for (cid = 0, i = 0; i < 4; i++)
+		cid |= (readl(base + size - 0x10 + 4 * i) & 255) <<
+			(i * 8);
+
+	return cid;
+}
 #endif
-- 
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 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-02-12 13:03   ` [PATCH 2/3] sp804: introduce amba_is_arm_sp804 to detect if the sp804 is present at the address Jean-Christophe PLAGNIOL-VILLARD
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-1-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