Skip to content

Commit 9536a31

Browse files
committed
Merge tag 'drivers_soc_for_5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone into arm/drivers
soc: ARM TI update for v5.8 - Platform chipid driver support and associated dts doc update - Sparse warning fix in Navigator driver * tag 'drivers_soc_for_5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone: drivers: soc: ti: knav_qmss_queue: Make knav_gp_range_ops static soc: ti: add k3 platforms chipid module driver dt-bindings: soc: ti: add binding for k3 platforms chipid module Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 1f46d85 + b8b38a8 commit 9536a31

File tree

5 files changed

+204
-1
lines changed

5 files changed

+204
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/soc/ti/k3-socinfo.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Texas Instruments K3 Multicore SoC platforms chipid module
8+
9+
maintainers:
10+
- Tero Kristo <[email protected]>
11+
- Nishanth Menon <[email protected]>
12+
13+
description: |
14+
Texas Instruments (ARM64) K3 Multicore SoC platforms chipid module is
15+
represented by CTRLMMR_xxx_JTAGID register which contains information about
16+
SoC id and revision.
17+
18+
properties:
19+
$nodename:
20+
pattern: "^chipid@[0-9a-f]+$"
21+
22+
compatible:
23+
items:
24+
- const: ti,am654-chipid
25+
26+
reg:
27+
maxItems: 1
28+
29+
required:
30+
- compatible
31+
- reg
32+
33+
additionalProperties: false
34+
35+
examples:
36+
- |
37+
chipid@43000014 {
38+
compatible = "ti,am654-chipid";
39+
reg = <0x43000014 0x4>;
40+
};

drivers/soc/ti/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ config TI_K3_RINGACC
9191
and a consumer. There is one RINGACC module per NAVSS on TI AM65x SoCs
9292
If unsure, say N.
9393

94+
config TI_K3_SOCINFO
95+
bool
96+
depends on ARCH_K3 || COMPILE_TEST
97+
select SOC_BUS
98+
select MFD_SYSCON
99+
help
100+
Include support for the SoC bus socinfo for the TI K3 Multicore SoC
101+
platforms to provide information about the SoC family and
102+
variant to user space.
103+
94104
endif # SOC_TI
95105

96106
config TI_SCI_INTA_MSI_DOMAIN

drivers/soc/ti/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ obj-$(CONFIG_WKUP_M3_IPC) += wkup_m3_ipc.o
1111
obj-$(CONFIG_TI_SCI_PM_DOMAINS) += ti_sci_pm_domains.o
1212
obj-$(CONFIG_TI_SCI_INTA_MSI_DOMAIN) += ti_sci_inta_msi.o
1313
obj-$(CONFIG_TI_K3_RINGACC) += k3-ringacc.o
14+
obj-$(CONFIG_TI_K3_SOCINFO) += k3-socinfo.o

drivers/soc/ti/k3-socinfo.c

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* TI K3 SoC info driver
4+
*
5+
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
6+
*/
7+
8+
#include <linux/mfd/syscon.h>
9+
#include <linux/of.h>
10+
#include <linux/of_address.h>
11+
#include <linux/regmap.h>
12+
#include <linux/platform_device.h>
13+
#include <linux/slab.h>
14+
#include <linux/string.h>
15+
#include <linux/sys_soc.h>
16+
17+
#define CTRLMMR_WKUP_JTAGID_REG 0
18+
/*
19+
* Bits:
20+
* 31-28 VARIANT Device variant
21+
* 27-12 PARTNO Part number
22+
* 11-1 MFG Indicates TI as manufacturer (0x17)
23+
* 1 Always 1
24+
*/
25+
#define CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT (28)
26+
#define CTRLMMR_WKUP_JTAGID_VARIANT_MASK GENMASK(31, 28)
27+
28+
#define CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT (12)
29+
#define CTRLMMR_WKUP_JTAGID_PARTNO_MASK GENMASK(27, 12)
30+
31+
#define CTRLMMR_WKUP_JTAGID_MFG_SHIFT (1)
32+
#define CTRLMMR_WKUP_JTAGID_MFG_MASK GENMASK(11, 1)
33+
34+
#define CTRLMMR_WKUP_JTAGID_MFG_TI 0x17
35+
36+
static const struct k3_soc_id {
37+
unsigned int id;
38+
const char *family_name;
39+
} k3_soc_ids[] = {
40+
{ 0xBB5A, "AM65X" },
41+
{ 0xBB64, "J721E" },
42+
};
43+
44+
static int
45+
k3_chipinfo_partno_to_names(unsigned int partno,
46+
struct soc_device_attribute *soc_dev_attr)
47+
{
48+
int i;
49+
50+
for (i = 0; i < ARRAY_SIZE(k3_soc_ids); i++)
51+
if (partno == k3_soc_ids[i].id) {
52+
soc_dev_attr->family = k3_soc_ids[i].family_name;
53+
return 0;
54+
}
55+
56+
return -EINVAL;
57+
}
58+
59+
static int k3_chipinfo_probe(struct platform_device *pdev)
60+
{
61+
struct device_node *node = pdev->dev.of_node;
62+
struct soc_device_attribute *soc_dev_attr;
63+
struct device *dev = &pdev->dev;
64+
struct soc_device *soc_dev;
65+
struct regmap *regmap;
66+
u32 partno_id;
67+
u32 variant;
68+
u32 jtag_id;
69+
u32 mfg;
70+
int ret;
71+
72+
regmap = device_node_to_regmap(node);
73+
if (IS_ERR(regmap))
74+
return PTR_ERR(regmap);
75+
76+
ret = regmap_read(regmap, CTRLMMR_WKUP_JTAGID_REG, &jtag_id);
77+
if (ret < 0)
78+
return ret;
79+
80+
mfg = (jtag_id & CTRLMMR_WKUP_JTAGID_MFG_MASK) >>
81+
CTRLMMR_WKUP_JTAGID_MFG_SHIFT;
82+
83+
if (mfg != CTRLMMR_WKUP_JTAGID_MFG_TI) {
84+
dev_err(dev, "Invalid MFG SoC\n");
85+
return -ENODEV;
86+
}
87+
88+
variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >>
89+
CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT;
90+
variant++;
91+
92+
partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >>
93+
CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT;
94+
95+
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
96+
if (!soc_dev_attr)
97+
return -ENOMEM;
98+
99+
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant);
100+
if (!soc_dev_attr->revision) {
101+
ret = -ENOMEM;
102+
goto err;
103+
}
104+
105+
ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr);
106+
if (ret) {
107+
dev_err(dev, "Unknown SoC JTAGID[0x%08X]\n", jtag_id);
108+
ret = -ENODEV;
109+
goto err_free_rev;
110+
}
111+
112+
node = of_find_node_by_path("/");
113+
of_property_read_string(node, "model", &soc_dev_attr->machine);
114+
of_node_put(node);
115+
116+
soc_dev = soc_device_register(soc_dev_attr);
117+
if (IS_ERR(soc_dev)) {
118+
ret = PTR_ERR(soc_dev);
119+
goto err_free_rev;
120+
}
121+
122+
dev_info(dev, "Family:%s rev:%s JTAGID[0x%08x] Detected\n",
123+
soc_dev_attr->family,
124+
soc_dev_attr->revision, jtag_id);
125+
126+
return 0;
127+
128+
err_free_rev:
129+
kfree(soc_dev_attr->revision);
130+
err:
131+
kfree(soc_dev_attr);
132+
return ret;
133+
}
134+
135+
static const struct of_device_id k3_chipinfo_of_match[] = {
136+
{ .compatible = "ti,am654-chipid", },
137+
{ /* sentinel */ },
138+
};
139+
140+
static struct platform_driver k3_chipinfo_driver = {
141+
.driver = {
142+
.name = "k3-chipinfo",
143+
.of_match_table = k3_chipinfo_of_match,
144+
},
145+
.probe = k3_chipinfo_probe,
146+
};
147+
148+
static int __init k3_chipinfo_init(void)
149+
{
150+
return platform_driver_register(&k3_chipinfo_driver);
151+
}
152+
subsys_initcall(k3_chipinfo_init);

drivers/soc/ti/knav_qmss_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static int knav_gp_close_queue(struct knav_range_info *range,
409409
return 0;
410410
}
411411

412-
struct knav_range_ops knav_gp_range_ops = {
412+
static struct knav_range_ops knav_gp_range_ops = {
413413
.set_notify = knav_gp_set_notify,
414414
.open_queue = knav_gp_open_queue,
415415
.close_queue = knav_gp_close_queue,

0 commit comments

Comments
 (0)