|
26 | 26 |
|
27 | 27 | #define to_amba_driver(d) container_of(d, struct amba_driver, drv)
|
28 | 28 |
|
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) |
31 | 32 | {
|
32 | 33 | int ret = 0;
|
| 34 | + struct amba_cs_uci_id *uci; |
| 35 | + |
| 36 | + uci = table->data; |
33 | 37 |
|
| 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 | +{ |
34 | 51 | 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; |
38 | 56 | table++;
|
39 | 57 | }
|
40 |
| - |
41 |
| - return ret ? table : NULL; |
| 58 | + return NULL; |
42 | 59 | }
|
43 | 60 |
|
44 | 61 | 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)
|
399 | 416 | cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
|
400 | 417 | (i * 8);
|
401 | 418 |
|
| 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 | + |
402 | 429 | amba_put_disable_pclk(dev);
|
403 | 430 |
|
404 |
| - if (cid == AMBA_CID || cid == CORESIGHT_CID) |
| 431 | + if (cid == AMBA_CID || cid == CORESIGHT_CID) { |
405 | 432 | dev->periphid = pid;
|
| 433 | + dev->cid = cid; |
| 434 | + } |
406 | 435 |
|
407 | 436 | if (!dev->periphid)
|
408 | 437 | ret = -ENODEV;
|
|
0 commit comments