Skip to content

Commit 732af51

Browse files
ambaruskrzk
authored andcommitted
soc: samsung: exynos-chipid: add google,gs101-otp support
GS101 is different (but also e850 and autov9 I assume) from the SoCs that are currently handled by the exynos-chipid driver because the chip ID info is part of the OTP registers. GS101 OTP has a clock, an interrupt line, a register space (that contains product and chip ID, TMU data, ASV, etc) and a 32Kbit memory space that can be read/program/locked with specific commands. On GS101 the "ChipID block" is just an abstraction, it's not a physical device. When the power-on sequence progresses, the OTP chipid values are loaded to the OTP registers. Add the GS101 chip ID support. The support is intentionally added in the exynos-chipid driver, and not in a dedicated Exynos OTP driver, because we estimate that there will not be any OTP consumers in the kernel other than the chip ID/SoC interface. The downstream GS101 drivers confirm this supposition. Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Reviewed-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20251222-gs101-chipid-v4-4-aa8e20ce7bb3@linaro.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
1 parent c38cfc3 commit 732af51

1 file changed

Lines changed: 61 additions & 9 deletions

File tree

drivers/soc/samsung/exynos-chipid.c

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include <linux/array_size.h>
1616
#include <linux/device.h>
1717
#include <linux/device/devres.h>
18-
#include <linux/errno.h>
18+
#include <linux/err.h>
19+
#include <linux/ioport.h>
1920
#include <linux/mfd/syscon.h>
2021
#include <linux/module.h>
2122
#include <linux/of.h>
@@ -28,9 +29,11 @@
2829
#include "exynos-asv.h"
2930

3031
struct exynos_chipid_variant {
31-
unsigned int rev_reg; /* revision register offset */
32+
unsigned int main_rev_reg; /* main revision register offset */
33+
unsigned int sub_rev_reg; /* sub revision register offset */
3234
unsigned int main_rev_shift; /* main revision offset in rev_reg */
3335
unsigned int sub_rev_shift; /* sub revision offset in rev_reg */
36+
bool efuse;
3437
};
3538

3639
struct exynos_chipid_info {
@@ -69,6 +72,8 @@ static const struct exynos_soc_id {
6972
{ "EXYNOS990", 0xE9830000 },
7073
{ "EXYNOSAUTOV9", 0xAAA80000 },
7174
{ "EXYNOSAUTOV920", 0x0A920000 },
75+
/* Compatible with: google,gs101-otp */
76+
{ "GS101", 0x9845000 },
7277
};
7378

7479
static const char *exynos_product_id_to_name(unsigned int product_id)
@@ -93,19 +98,53 @@ static int exynos_chipid_get_chipid_info(struct device *dev,
9398
return dev_err_probe(dev, ret, "failed to read Product ID\n");
9499
soc_info->product_id = val & EXYNOS_MASK;
95100

96-
if (data->rev_reg != EXYNOS_CHIPID_REG_PRO_ID) {
97-
ret = regmap_read(regmap, data->rev_reg, &val);
101+
if (data->sub_rev_reg == EXYNOS_CHIPID_REG_PRO_ID) {
102+
/* exynos4210 case */
103+
main_rev = (val >> data->main_rev_shift) & EXYNOS_REV_PART_MASK;
104+
sub_rev = (val >> data->sub_rev_shift) & EXYNOS_REV_PART_MASK;
105+
} else {
106+
unsigned int val2;
107+
108+
ret = regmap_read(regmap, data->sub_rev_reg, &val2);
98109
if (ret < 0)
99110
return dev_err_probe(dev, ret,
100111
"failed to read revision\n");
112+
113+
if (data->main_rev_reg == EXYNOS_CHIPID_REG_PRO_ID)
114+
/* gs101 case */
115+
main_rev = (val >> data->main_rev_shift) & EXYNOS_REV_PART_MASK;
116+
else
117+
/* exynos850 case */
118+
main_rev = (val2 >> data->main_rev_shift) & EXYNOS_REV_PART_MASK;
119+
120+
sub_rev = (val2 >> data->sub_rev_shift) & EXYNOS_REV_PART_MASK;
101121
}
102-
main_rev = (val >> data->main_rev_shift) & EXYNOS_REV_PART_MASK;
103-
sub_rev = (val >> data->sub_rev_shift) & EXYNOS_REV_PART_MASK;
122+
104123
soc_info->revision = (main_rev << EXYNOS_REV_PART_SHIFT) | sub_rev;
105124

106125
return 0;
107126
}
108127

128+
static struct regmap *exynos_chipid_get_efuse_regmap(struct platform_device *pdev)
129+
{
130+
struct resource *res;
131+
void __iomem *base;
132+
133+
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
134+
if (IS_ERR(base))
135+
return ERR_CAST(base);
136+
137+
const struct regmap_config reg_config = {
138+
.reg_bits = 32,
139+
.reg_stride = 4,
140+
.val_bits = 32,
141+
.use_relaxed_mmio = true,
142+
.max_register = (resource_size(res) - reg_config.reg_stride),
143+
};
144+
145+
return devm_regmap_init_mmio_clk(&pdev->dev, "pclk", base, &reg_config);
146+
}
147+
109148
static void exynos_chipid_unregister_soc(void *data)
110149
{
111150
soc_device_unregister(data);
@@ -127,7 +166,11 @@ static int exynos_chipid_probe(struct platform_device *pdev)
127166
return dev_err_probe(dev, -EINVAL,
128167
"failed to get match data\n");
129168

130-
regmap = device_node_to_regmap(dev->of_node);
169+
if (drv_data->efuse)
170+
regmap = exynos_chipid_get_efuse_regmap(pdev);
171+
else
172+
regmap = device_node_to_regmap(dev->of_node);
173+
131174
if (IS_ERR(regmap))
132175
return dev_err_probe(dev, PTR_ERR(regmap),
133176
"failed to get regmap\n");
@@ -177,19 +220,28 @@ static int exynos_chipid_probe(struct platform_device *pdev)
177220
}
178221

179222
static const struct exynos_chipid_variant exynos4210_chipid_drv_data = {
180-
.rev_reg = 0x0,
181223
.main_rev_shift = 4,
182224
.sub_rev_shift = 0,
183225
};
184226

185227
static const struct exynos_chipid_variant exynos850_chipid_drv_data = {
186-
.rev_reg = 0x10,
228+
.main_rev_reg = 0x10,
229+
.sub_rev_reg = 0x10,
187230
.main_rev_shift = 20,
188231
.sub_rev_shift = 16,
189232
};
190233

234+
static const struct exynos_chipid_variant gs101_chipid_drv_data = {
235+
.sub_rev_reg = 0x10,
236+
.sub_rev_shift = 16,
237+
.efuse = true,
238+
};
239+
191240
static const struct of_device_id exynos_chipid_of_device_ids[] = {
192241
{
242+
.compatible = "google,gs101-otp",
243+
.data = &gs101_chipid_drv_data,
244+
}, {
193245
.compatible = "samsung,exynos4210-chipid",
194246
.data = &exynos4210_chipid_drv_data,
195247
}, {

0 commit comments

Comments
 (0)