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>
This commit is contained in:
parent
2738f72352
commit
a59a5acf68
|
@ -104,7 +104,7 @@ int amba_device_add(struct amba_device *dev)
|
||||||
{
|
{
|
||||||
u32 size;
|
u32 size;
|
||||||
void __iomem *tmp;
|
void __iomem *tmp;
|
||||||
int i, ret;
|
int ret;
|
||||||
struct resource *res = NULL;
|
struct resource *res = NULL;
|
||||||
|
|
||||||
dev->dev.bus = &amba_bustype;
|
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
|
* Read pid and cid based on size of resource
|
||||||
* they are located at end of region
|
* they are located at end of region
|
||||||
*/
|
*/
|
||||||
for (pid = 0, i = 0; i < 4; i++)
|
pid = amba_device_get_pid(tmp, size);
|
||||||
pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
|
cid = amba_device_get_cid(tmp, size);
|
||||||
(i * 8);
|
|
||||||
for (cid = 0, i = 0; i < 4; i++)
|
|
||||||
cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
|
|
||||||
(i * 8);
|
|
||||||
|
|
||||||
if (cid == AMBA_CID)
|
if (cid == AMBA_CID)
|
||||||
dev->periphid = pid;
|
dev->periphid = pid;
|
||||||
|
|
|
@ -150,4 +150,32 @@ struct amba_device name##_device = { \
|
||||||
.periphid = id, \
|
.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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue