diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-02-12 14:03:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-12 20:35:52 +0100 |
commit | a59a5acf68e6a46aee285f3f2d95d64854cbf115 (patch) | |
tree | 23884cbc4da413bb952b06319f2a386bf18f5d0d /include/linux/amba/bus.h | |
parent | 2738f723521e299b38ab882a85e11f246b38dad2 (diff) | |
download | barebox-a59a5acf68e6a46aee285f3f2d95d64854cbf115.tar.gz barebox-a59a5acf68e6a46aee285f3f2d95d64854cbf115.tar.xz |
amba: introduce amba_device_get_pid/cid
so we can use it on vexpress to detect the hardware mapping
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux/amba/bus.h')
-rw-r--r-- | include/linux/amba/bus.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index cb3e3bd3b1..a7bbae0bd6 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 |