Skip to content

Commit 80b820c

Browse files
yurovskygregkh
authored andcommitted
nvmem: add i.MX7 support to snvs-lpgpr
The i.MX7 family has similar SNVS hardware so make the snvs-lpgpr support it along with the i.MX6 family. The register interface is the same except for the number and offset of the general purpose registers. Signed-off-by: Andrey Yurovsky <[email protected]> Reviewed-by: Oleksij Rempel <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b7743a9 commit 80b820c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

Documentation/devicetree/bindings/nvmem/snvs-lpgpr.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Device tree bindings for Low Power General Purpose Register found in i.MX6Q/D
2-
Secure Non-Volatile Storage.
2+
and i.MX7 Secure Non-Volatile Storage.
33

44
This DT node should be represented as a sub-node of a "syscon",
55
"simple-mfd" node.
@@ -8,6 +8,7 @@ Required properties:
88
- compatible: should be one of the fallowing variants:
99
"fsl,imx6q-snvs-lpgpr" for Freescale i.MX6Q/D/DL/S
1010
"fsl,imx6ul-snvs-lpgpr" for Freescale i.MX6UL
11+
"fsl,imx7d-snvs-lpgpr" for Freescale i.MX7D/S
1112

1213
Example:
1314
snvs: snvs@020cc000 {

drivers/nvmem/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ config MESON_MX_EFUSE
167167

168168
config NVMEM_SNVS_LPGPR
169169
tristate "Support for Low Power General Purpose Register"
170-
depends on SOC_IMX6 || COMPILE_TEST
170+
depends on SOC_IMX6 || SOC_IMX7D || COMPILE_TEST
171171
help
172172
This is a driver for Low Power General Purpose Register (LPGPR) available on
173-
i.MX6 SoCs in Secure Non-Volatile Storage (SNVS) of this chip.
173+
i.MX6 and i.MX7 SoCs in Secure Non-Volatile Storage (SNVS) of this chip.
174174

175175
This driver can also be built as a module. If so, the module
176176
will be called nvmem-snvs-lpgpr.

drivers/nvmem/snvs_lpgpr.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@
1414
#include <linux/regmap.h>
1515

1616
#define IMX6Q_SNVS_HPLR 0x00
17-
#define IMX6Q_GPR_SL BIT(5)
1817
#define IMX6Q_SNVS_LPLR 0x34
19-
#define IMX6Q_GPR_HL BIT(5)
2018
#define IMX6Q_SNVS_LPGPR 0x68
2119

20+
#define IMX7D_SNVS_HPLR 0x00
21+
#define IMX7D_SNVS_LPLR 0x34
22+
#define IMX7D_SNVS_LPGPR 0x90
23+
24+
#define IMX_GPR_SL BIT(5)
25+
#define IMX_GPR_HL BIT(5)
26+
2227
struct snvs_lpgpr_cfg {
2328
int offset;
2429
int offset_hplr;
2530
int offset_lplr;
31+
int size;
2632
};
2733

2834
struct snvs_lpgpr_priv {
@@ -36,6 +42,14 @@ static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx6q = {
3642
.offset = IMX6Q_SNVS_LPGPR,
3743
.offset_hplr = IMX6Q_SNVS_HPLR,
3844
.offset_lplr = IMX6Q_SNVS_LPLR,
45+
.size = 4,
46+
};
47+
48+
static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx7d = {
49+
.offset = IMX7D_SNVS_LPGPR,
50+
.offset_hplr = IMX7D_SNVS_HPLR,
51+
.offset_lplr = IMX7D_SNVS_LPLR,
52+
.size = 16,
3953
};
4054

4155
static int snvs_lpgpr_write(void *context, unsigned int offset, void *val,
@@ -50,14 +64,14 @@ static int snvs_lpgpr_write(void *context, unsigned int offset, void *val,
5064
if (ret < 0)
5165
return ret;
5266

53-
if (lock_reg & IMX6Q_GPR_SL)
67+
if (lock_reg & IMX_GPR_SL)
5468
return -EPERM;
5569

5670
ret = regmap_read(priv->regmap, dcfg->offset_lplr, &lock_reg);
5771
if (ret < 0)
5872
return ret;
5973

60-
if (lock_reg & IMX6Q_GPR_HL)
74+
if (lock_reg & IMX_GPR_HL)
6175
return -EPERM;
6276

6377
return regmap_bulk_write(priv->regmap, dcfg->offset + offset, val,
@@ -112,7 +126,7 @@ static int snvs_lpgpr_probe(struct platform_device *pdev)
112126
cfg->dev = dev;
113127
cfg->stride = 4;
114128
cfg->word_size = 4;
115-
cfg->size = 4;
129+
cfg->size = dcfg->size,
116130
cfg->owner = THIS_MODULE;
117131
cfg->reg_read = snvs_lpgpr_read;
118132
cfg->reg_write = snvs_lpgpr_write;
@@ -126,6 +140,7 @@ static const struct of_device_id snvs_lpgpr_dt_ids[] = {
126140
{ .compatible = "fsl,imx6q-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx6q },
127141
{ .compatible = "fsl,imx6ul-snvs-lpgpr",
128142
.data = &snvs_lpgpr_cfg_imx6q },
143+
{ .compatible = "fsl,imx7d-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx7d },
129144
{ },
130145
};
131146
MODULE_DEVICE_TABLE(of, snvs_lpgpr_dt_ids);
@@ -140,5 +155,5 @@ static struct platform_driver snvs_lpgpr_driver = {
140155
module_platform_driver(snvs_lpgpr_driver);
141156

142157
MODULE_AUTHOR("Oleksij Rempel <[email protected]>");
143-
MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 Secure Non-Volatile Storage");
158+
MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 and i.MX7 Secure Non-Volatile Storage");
144159
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)