Skip to content

Commit 4a2910f

Browse files
mikel-armbbRussell King
authored andcommitted
ARM: 8836/1: drivers: amba: Update component matching to use the CoreSight UCI values.
The patches provide an update of amba_device and matching code to handle the additional registers required for the Class 0x9 (CoreSight) UCI. The *data pointer in the amba_id is used by the driver to provide extended ID register values for matching. CoreSight components where PID/CID pair is currently sufficient for unique identification need not provide this additional information. Signed-off-by: Mike Leach <mike.leach@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Tested-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent e85fa28 commit 4a2910f

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

drivers/amba/bus.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,36 @@
2626

2727
#define to_amba_driver(d) container_of(d, struct amba_driver, drv)
2828

29-
static const struct amba_id *
30-
amba_lookup(const struct amba_id *table, struct amba_device *dev)
29+
/* called on periphid match and class 0x9 coresight device. */
30+
static int
31+
amba_cs_uci_id_match(const struct amba_id *table, struct amba_device *dev)
3132
{
3233
int ret = 0;
34+
struct amba_cs_uci_id *uci;
35+
36+
uci = table->data;
3337

38+
/* no table data or zero mask - return match on periphid */
39+
if (!uci || (uci->devarch_mask == 0))
40+
return 1;
41+
42+
/* test against read devtype and masked devarch value */
43+
ret = (dev->uci.devtype == uci->devtype) &&
44+
((dev->uci.devarch & uci->devarch_mask) == uci->devarch);
45+
return ret;
46+
}
47+
48+
static const struct amba_id *
49+
amba_lookup(const struct amba_id *table, struct amba_device *dev)
50+
{
3451
while (table->mask) {
35-
ret = (dev->periphid & table->mask) == table->id;
36-
if (ret)
37-
break;
52+
if (((dev->periphid & table->mask) == table->id) &&
53+
((dev->cid != CORESIGHT_CID) ||
54+
(amba_cs_uci_id_match(table, dev))))
55+
return table;
3856
table++;
3957
}
40-
41-
return ret ? table : NULL;
58+
return NULL;
4259
}
4360

4461
static int amba_match(struct device *dev, struct device_driver *drv)
@@ -399,10 +416,22 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
399416
cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
400417
(i * 8);
401418

419+
if (cid == CORESIGHT_CID) {
420+
/* set the base to the start of the last 4k block */
421+
void __iomem *csbase = tmp + size - 4096;
422+
423+
dev->uci.devarch =
424+
readl(csbase + UCI_REG_DEVARCH_OFFSET);
425+
dev->uci.devtype =
426+
readl(csbase + UCI_REG_DEVTYPE_OFFSET) & 0xff;
427+
}
428+
402429
amba_put_disable_pclk(dev);
403430

404-
if (cid == AMBA_CID || cid == CORESIGHT_CID)
431+
if (cid == AMBA_CID || cid == CORESIGHT_CID) {
405432
dev->periphid = pid;
433+
dev->cid = cid;
434+
}
406435

407436
if (!dev->periphid)
408437
ret = -ENODEV;

include/linux/amba/bus.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,19 @@ struct amba_cs_uci_id {
5858
void *data;
5959
};
6060

61+
/* define offsets for registers used by UCI */
62+
#define UCI_REG_DEVTYPE_OFFSET 0xFCC
63+
#define UCI_REG_DEVARCH_OFFSET 0xFBC
64+
6165
struct clk;
6266

6367
struct amba_device {
6468
struct device dev;
6569
struct resource res;
6670
struct clk *pclk;
6771
unsigned int periphid;
72+
unsigned int cid;
73+
struct amba_cs_uci_id uci;
6874
unsigned int irq[AMBA_NR_IRQS];
6975
char *driver_override;
7076
};

0 commit comments

Comments
 (0)