Skip to content

Commit e85fa28

Browse files
mikel-armbbRussell King
authored andcommitted
ARM: 8838/1: drivers: amba: Updates to component identification for driver matching.
The CoreSight specification (ARM IHI 0029E), updates the ID register requirements for components on an AMBA bus, to cover both traditional ARM Primecell type devices, and newer CoreSight and other components. The Peripheral ID (PID) / Component ID (CID) pair is extended in certain cases to uniquely identify components. CoreSight components related to a single function can share Peripheral ID values, and must be further identified using a Unique Component Identifier (UCI). e.g. the ETM, CTI, PMU and Debug hardware of the A35 all share the same PID. Bits 15:12 of the CID are defined to be the device class. Class 0xF remains for PrimeCell and legacy components. Class 0x9 defines the component as CoreSight (CORESIGHT_CID above) Class 0x0, 0x1, 0xB, 0xE define components that do not have driver support at present. Class 0x2-0x8,0xA and 0xD-0xD are presently reserved. The specification futher defines which classes of device use the standard CID/PID pair, and when additional ID registers are required. This patch introduces the amba_cs_uci_id structure which will be used in all coresight drivers for indentification via the private data pointer in the amba_id structure. Existing drivers that currently use the amba_id->data pointer for private data are updated to use the amba_cs_uci_id->data pointer. Macros and inline functions are added to simplify this code. 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 de9c0d4 commit e85fa28

File tree

5 files changed

+90
-63
lines changed

5 files changed

+90
-63
lines changed

drivers/hwtracing/coresight/coresight-etm3x.c

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
871871
}
872872

873873
pm_runtime_put(&adev->dev);
874-
dev_info(dev, "%s initialized\n", (char *)id->data);
874+
dev_info(dev, "%s initialized\n", (char *)coresight_get_uci_data(id));
875875
if (boot_enable) {
876876
coresight_enable(drvdata->csdev);
877877
drvdata->boot_enable = true;
@@ -915,36 +915,18 @@ static const struct dev_pm_ops etm_dev_pm_ops = {
915915
};
916916

917917
static const struct amba_id etm_ids[] = {
918-
{ /* ETM 3.3 */
919-
.id = 0x000bb921,
920-
.mask = 0x000fffff,
921-
.data = "ETM 3.3",
922-
},
923-
{ /* ETM 3.5 - Cortex-A5 */
924-
.id = 0x000bb955,
925-
.mask = 0x000fffff,
926-
.data = "ETM 3.5",
927-
},
928-
{ /* ETM 3.5 */
929-
.id = 0x000bb956,
930-
.mask = 0x000fffff,
931-
.data = "ETM 3.5",
932-
},
933-
{ /* PTM 1.0 */
934-
.id = 0x000bb950,
935-
.mask = 0x000fffff,
936-
.data = "PTM 1.0",
937-
},
938-
{ /* PTM 1.1 */
939-
.id = 0x000bb95f,
940-
.mask = 0x000fffff,
941-
.data = "PTM 1.1",
942-
},
943-
{ /* PTM 1.1 Qualcomm */
944-
.id = 0x000b006f,
945-
.mask = 0x000fffff,
946-
.data = "PTM 1.1",
947-
},
918+
/* ETM 3.3 */
919+
CS_AMBA_ID_DATA(0x000bb921, "ETM 3.3"),
920+
/* ETM 3.5 - Cortex-A5 */
921+
CS_AMBA_ID_DATA(0x000bb955, "ETM 3.5"),
922+
/* ETM 3.5 */
923+
CS_AMBA_ID_DATA(0x000bb956, "ETM 3.5"),
924+
/* PTM 1.0 */
925+
CS_AMBA_ID_DATA(0x000bb950, "PTM 1.0"),
926+
/* PTM 1.1 */
927+
CS_AMBA_ID_DATA(0x000bb95f, "PTM 1.1"),
928+
/* PTM 1.1 Qualcomm */
929+
CS_AMBA_ID_DATA(0x000b006f, "PTM 1.1"),
948930
{ 0, 0},
949931
};
950932

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef _CORESIGHT_PRIV_H
77
#define _CORESIGHT_PRIV_H
88

9+
#include <linux/amba/bus.h>
910
#include <linux/bitops.h>
1011
#include <linux/io.h>
1112
#include <linux/coresight.h>
@@ -159,4 +160,35 @@ static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
159160
static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
160161
#endif
161162

163+
/*
164+
* Macros and inline functions to handle CoreSight UCI data and driver
165+
* private data in AMBA ID table entries, and extract data values.
166+
*/
167+
168+
/* coresight AMBA ID, no UCI, no driver data: id table entry */
169+
#define CS_AMBA_ID(pid) \
170+
{ \
171+
.id = pid, \
172+
.mask = 0x000fffff, \
173+
}
174+
175+
/* coresight AMBA ID, UCI with driver data only: id table entry. */
176+
#define CS_AMBA_ID_DATA(pid, dval) \
177+
{ \
178+
.id = pid, \
179+
.mask = 0x000fffff, \
180+
.data = (void *)&(struct amba_cs_uci_id) \
181+
{ \
182+
.data = (void *)dval, \
183+
} \
184+
}
185+
186+
/* extract the data value from a UCI structure given amba_id pointer. */
187+
static inline void *coresight_get_uci_data(const struct amba_id *id)
188+
{
189+
if (id->data)
190+
return ((struct amba_cs_uci_id *)(id->data))->data;
191+
return 0;
192+
}
193+
162194
#endif

drivers/hwtracing/coresight/coresight-stm.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
874874

875875
pm_runtime_put(&adev->dev);
876876

877-
dev_info(dev, "%s initialized\n", (char *)id->data);
877+
dev_info(dev, "%s initialized\n", (char *)coresight_get_uci_data(id));
878878
return 0;
879879

880880
stm_unregister:
@@ -909,16 +909,8 @@ static const struct dev_pm_ops stm_dev_pm_ops = {
909909
};
910910

911911
static const struct amba_id stm_ids[] = {
912-
{
913-
.id = 0x000bb962,
914-
.mask = 0x000fffff,
915-
.data = "STM32",
916-
},
917-
{
918-
.id = 0x000bb963,
919-
.mask = 0x000fffff,
920-
.data = "STM500",
921-
},
912+
CS_AMBA_ID_DATA(0x000bb962, "STM32"),
913+
CS_AMBA_ID_DATA(0x000bb963, "STM500"),
922914
{ 0, 0},
923915
};
924916

drivers/hwtracing/coresight/coresight-tmc.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
443443
desc.type = CORESIGHT_DEV_TYPE_SINK;
444444
desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
445445
desc.ops = &tmc_etr_cs_ops;
446-
ret = tmc_etr_setup_caps(drvdata, devid, id->data);
446+
ret = tmc_etr_setup_caps(drvdata, devid,
447+
coresight_get_uci_data(id));
447448
if (ret)
448449
goto out;
449450
break;
@@ -475,26 +476,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
475476
}
476477

477478
static const struct amba_id tmc_ids[] = {
478-
{
479-
.id = 0x000bb961,
480-
.mask = 0x000fffff,
481-
},
482-
{
483-
/* Coresight SoC 600 TMC-ETR/ETS */
484-
.id = 0x000bb9e8,
485-
.mask = 0x000fffff,
486-
.data = (void *)(unsigned long)CORESIGHT_SOC_600_ETR_CAPS,
487-
},
488-
{
489-
/* Coresight SoC 600 TMC-ETB */
490-
.id = 0x000bb9e9,
491-
.mask = 0x000fffff,
492-
},
493-
{
494-
/* Coresight SoC 600 TMC-ETF */
495-
.id = 0x000bb9ea,
496-
.mask = 0x000fffff,
497-
},
479+
CS_AMBA_ID(0x000bb961),
480+
/* Coresight SoC 600 TMC-ETR/ETS */
481+
CS_AMBA_ID_DATA(0x000bb9e8, (unsigned long)CORESIGHT_SOC_600_ETR_CAPS),
482+
/* Coresight SoC 600 TMC-ETB */
483+
CS_AMBA_ID(0x000bb9e9),
484+
/* Coresight SoC 600 TMC-ETF */
485+
CS_AMBA_ID(0x000bb9ea),
498486
{ 0, 0},
499487
};
500488

include/linux/amba/bus.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@
2525
#define AMBA_CID 0xb105f00d
2626
#define CORESIGHT_CID 0xb105900d
2727

28+
/*
29+
* CoreSight Architecture specification updates the ID specification
30+
* for components on the AMBA bus. (ARM IHI 0029E)
31+
*
32+
* Bits 15:12 of the CID are the device class.
33+
*
34+
* Class 0xF remains for PrimeCell and legacy components. (AMBA_CID above)
35+
* Class 0x9 defines the component as CoreSight (CORESIGHT_CID above)
36+
* Class 0x0, 0x1, 0xB, 0xE define components that do not have driver support
37+
* at present.
38+
* Class 0x2-0x8,0xA and 0xD-0xD are presently reserved.
39+
*
40+
* Remaining CID bits stay as 0xb105-00d
41+
*/
42+
43+
/**
44+
* Class 0x9 components use additional values to form a Unique Component
45+
* Identifier (UCI), where peripheral ID values are identical for different
46+
* components. Passed to the amba bus code from the component driver via
47+
* the amba_id->data pointer.
48+
* @devarch : coresight devarch register value
49+
* @devarch_mask: mask bits used for matching. 0 indicates UCI not used.
50+
* @devtype : coresight device type value
51+
* @data : additional driver data. As we have usurped the original
52+
* pointer some devices may still need additional data
53+
*/
54+
struct amba_cs_uci_id {
55+
unsigned int devarch;
56+
unsigned int devarch_mask;
57+
unsigned int devtype;
58+
void *data;
59+
};
60+
2861
struct clk;
2962

3063
struct amba_device {

0 commit comments

Comments
 (0)