Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yurovsky@gmail.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrey Yurovsky and committed by
Greg Kroah-Hartman
80b820ca b7743a99

+25 -9
+2 -1
Documentation/devicetree/bindings/nvmem/snvs-lpgpr.txt
··· 1 1 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. 3 3 4 4 This DT node should be represented as a sub-node of a "syscon", 5 5 "simple-mfd" node. ··· 8 8 - compatible: should be one of the fallowing variants: 9 9 "fsl,imx6q-snvs-lpgpr" for Freescale i.MX6Q/D/DL/S 10 10 "fsl,imx6ul-snvs-lpgpr" for Freescale i.MX6UL 11 + "fsl,imx7d-snvs-lpgpr" for Freescale i.MX7D/S 11 12 12 13 Example: 13 14 snvs: snvs@020cc000 {
+2 -2
drivers/nvmem/Kconfig
··· 167 167 168 168 config NVMEM_SNVS_LPGPR 169 169 tristate "Support for Low Power General Purpose Register" 170 - depends on SOC_IMX6 || COMPILE_TEST 170 + depends on SOC_IMX6 || SOC_IMX7D || COMPILE_TEST 171 171 help 172 172 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. 174 174 175 175 This driver can also be built as a module. If so, the module 176 176 will be called nvmem-snvs-lpgpr.
+21 -6
drivers/nvmem/snvs_lpgpr.c
··· 14 14 #include <linux/regmap.h> 15 15 16 16 #define IMX6Q_SNVS_HPLR 0x00 17 - #define IMX6Q_GPR_SL BIT(5) 18 17 #define IMX6Q_SNVS_LPLR 0x34 19 - #define IMX6Q_GPR_HL BIT(5) 20 18 #define IMX6Q_SNVS_LPGPR 0x68 19 + 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) 21 26 22 27 struct snvs_lpgpr_cfg { 23 28 int offset; 24 29 int offset_hplr; 25 30 int offset_lplr; 31 + int size; 26 32 }; 27 33 28 34 struct snvs_lpgpr_priv { ··· 42 36 .offset = IMX6Q_SNVS_LPGPR, 43 37 .offset_hplr = IMX6Q_SNVS_HPLR, 44 38 .offset_lplr = IMX6Q_SNVS_LPLR, 39 + .size = 4, 40 + }; 41 + 42 + static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx7d = { 43 + .offset = IMX7D_SNVS_LPGPR, 44 + .offset_hplr = IMX7D_SNVS_HPLR, 45 + .offset_lplr = IMX7D_SNVS_LPLR, 46 + .size = 16, 45 47 }; 46 48 47 49 static int snvs_lpgpr_write(void *context, unsigned int offset, void *val, ··· 64 50 if (ret < 0) 65 51 return ret; 66 52 67 - if (lock_reg & IMX6Q_GPR_SL) 53 + if (lock_reg & IMX_GPR_SL) 68 54 return -EPERM; 69 55 70 56 ret = regmap_read(priv->regmap, dcfg->offset_lplr, &lock_reg); 71 57 if (ret < 0) 72 58 return ret; 73 59 74 - if (lock_reg & IMX6Q_GPR_HL) 60 + if (lock_reg & IMX_GPR_HL) 75 61 return -EPERM; 76 62 77 63 return regmap_bulk_write(priv->regmap, dcfg->offset + offset, val, ··· 126 112 cfg->dev = dev; 127 113 cfg->stride = 4; 128 114 cfg->word_size = 4; 129 - cfg->size = 4; 115 + cfg->size = dcfg->size, 130 116 cfg->owner = THIS_MODULE; 131 117 cfg->reg_read = snvs_lpgpr_read; 132 118 cfg->reg_write = snvs_lpgpr_write; ··· 140 126 { .compatible = "fsl,imx6q-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx6q }, 141 127 { .compatible = "fsl,imx6ul-snvs-lpgpr", 142 128 .data = &snvs_lpgpr_cfg_imx6q }, 129 + { .compatible = "fsl,imx7d-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx7d }, 143 130 { }, 144 131 }; 145 132 MODULE_DEVICE_TABLE(of, snvs_lpgpr_dt_ids); ··· 155 140 module_platform_driver(snvs_lpgpr_driver); 156 141 157 142 MODULE_AUTHOR("Oleksij Rempel <o.rempel@pengutronix.de>"); 158 - MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 Secure Non-Volatile Storage"); 143 + MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 and i.MX7 Secure Non-Volatile Storage"); 159 144 MODULE_LICENSE("GPL v2");