Skip to content

Commit 1b31719

Browse files
committed
Merge tag 'ti-driver-soc-for-v6.8' of https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux into soc/drivers
TI SoC driver updates for v6.8 - ti_sci: Minor fixup for off by one error in debugfs_create - k3-socinfo: Refactoring and add j721e detection, j722s * tag 'ti-driver-soc-for-v6.8' of https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux: soc: ti: k3-socinfo: Add JTAG ID for J722S soc: ti: k3-socinfo: Revamp driver to accommodate different rev structs firmware: ti_sci: Fix an off-by-one in ti_sci_debugfs_create() Link: https://lore.kernel.org/r/20231218153043.r5psxbjjpccusjg4@september Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents c55a498 + 2c22352 commit 1b31719

2 files changed

Lines changed: 62 additions & 21 deletions

File tree

drivers/firmware/ti_sci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
164164
{
165165
struct device *dev = &pdev->dev;
166166
struct resource *res;
167-
char debug_name[50] = "ti_sci_debug@";
167+
char debug_name[50];
168168

169169
/* Debug region is optional */
170170
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -181,10 +181,10 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
181181
/* Setup NULL termination */
182182
info->debug_buffer[info->debug_region_size] = 0;
183183

184-
info->d = debugfs_create_file(strncat(debug_name, dev_name(dev),
185-
sizeof(debug_name) -
186-
sizeof("ti_sci_debug@")),
187-
0444, NULL, info, &ti_sci_debug_fops);
184+
snprintf(debug_name, sizeof(debug_name), "ti_sci_debug@%s",
185+
dev_name(dev));
186+
info->d = debugfs_create_file(debug_name, 0444, NULL, info,
187+
&ti_sci_debug_fops);
188188
if (IS_ERR(info->d))
189189
return PTR_ERR(info->d);
190190

drivers/soc/ti/k3-socinfo.c

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,35 @@
3333

3434
#define CTRLMMR_WKUP_JTAGID_MFG_TI 0x17
3535

36+
#define JTAG_ID_PARTNO_AM65X 0xBB5A
37+
#define JTAG_ID_PARTNO_J721E 0xBB64
38+
#define JTAG_ID_PARTNO_J7200 0xBB6D
39+
#define JTAG_ID_PARTNO_AM64X 0xBB38
40+
#define JTAG_ID_PARTNO_J721S2 0xBB75
41+
#define JTAG_ID_PARTNO_AM62X 0xBB7E
42+
#define JTAG_ID_PARTNO_J784S4 0xBB80
43+
#define JTAG_ID_PARTNO_AM62AX 0xBB8D
44+
#define JTAG_ID_PARTNO_AM62PX 0xBB9D
45+
#define JTAG_ID_PARTNO_J722S 0xBBA0
46+
3647
static const struct k3_soc_id {
3748
unsigned int id;
3849
const char *family_name;
3950
} k3_soc_ids[] = {
40-
{ 0xBB5A, "AM65X" },
41-
{ 0xBB64, "J721E" },
42-
{ 0xBB6D, "J7200" },
43-
{ 0xBB38, "AM64X" },
44-
{ 0xBB75, "J721S2"},
45-
{ 0xBB7E, "AM62X" },
46-
{ 0xBB80, "J784S4" },
47-
{ 0xBB8D, "AM62AX" },
48-
{ 0xBB9D, "AM62PX" },
51+
{ JTAG_ID_PARTNO_AM65X, "AM65X" },
52+
{ JTAG_ID_PARTNO_J721E, "J721E" },
53+
{ JTAG_ID_PARTNO_J7200, "J7200" },
54+
{ JTAG_ID_PARTNO_AM64X, "AM64X" },
55+
{ JTAG_ID_PARTNO_J721S2, "J721S2"},
56+
{ JTAG_ID_PARTNO_AM62X, "AM62X" },
57+
{ JTAG_ID_PARTNO_J784S4, "J784S4" },
58+
{ JTAG_ID_PARTNO_AM62AX, "AM62AX" },
59+
{ JTAG_ID_PARTNO_AM62PX, "AM62PX" },
60+
{ JTAG_ID_PARTNO_J722S, "J722S" },
61+
};
62+
63+
static const char * const j721e_rev_string_map[] = {
64+
"1.0", "1.1",
4965
};
5066

5167
static int
@@ -63,6 +79,32 @@ k3_chipinfo_partno_to_names(unsigned int partno,
6379
return -ENODEV;
6480
}
6581

82+
static int
83+
k3_chipinfo_variant_to_sr(unsigned int partno, unsigned int variant,
84+
struct soc_device_attribute *soc_dev_attr)
85+
{
86+
switch (partno) {
87+
case JTAG_ID_PARTNO_J721E:
88+
if (variant >= ARRAY_SIZE(j721e_rev_string_map))
89+
goto err_unknown_variant;
90+
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%s",
91+
j721e_rev_string_map[variant]);
92+
break;
93+
default:
94+
variant++;
95+
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0",
96+
variant);
97+
}
98+
99+
if (!soc_dev_attr->revision)
100+
return -ENOMEM;
101+
102+
return 0;
103+
104+
err_unknown_variant:
105+
return -ENODEV;
106+
}
107+
66108
static int k3_chipinfo_probe(struct platform_device *pdev)
67109
{
68110
struct device_node *node = pdev->dev.of_node;
@@ -94,7 +136,6 @@ static int k3_chipinfo_probe(struct platform_device *pdev)
94136

95137
variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >>
96138
CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT;
97-
variant++;
98139

99140
partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >>
100141
CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT;
@@ -103,16 +144,16 @@ static int k3_chipinfo_probe(struct platform_device *pdev)
103144
if (!soc_dev_attr)
104145
return -ENOMEM;
105146

106-
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant);
107-
if (!soc_dev_attr->revision) {
108-
ret = -ENOMEM;
147+
ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr);
148+
if (ret) {
149+
dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret);
109150
goto err;
110151
}
111152

112-
ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr);
153+
ret = k3_chipinfo_variant_to_sr(partno_id, variant, soc_dev_attr);
113154
if (ret) {
114-
dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret);
115-
goto err_free_rev;
155+
dev_err(dev, "Unknown SoC SR[0x%08X]: %d\n", jtag_id, ret);
156+
goto err;
116157
}
117158

118159
node = of_find_node_by_path("/");

0 commit comments

Comments
 (0)