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

nvmem: mxs-ocotp: remove nvmem regmap dependency

Regmap raw accessors are bus specific implementations, using regmap raw
apis in nvmem breaks nvmem providers based on regmap mmio.
This patch moves to nvmem support in the driver to use callback
instead of regmap, which is what the nvmem core supports now.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
7d8867d7 ba360fd0

+22 -61
+22 -61
drivers/nvmem/mxs-ocotp.c
··· 25 25 #include <linux/nvmem-provider.h> 26 26 #include <linux/of_device.h> 27 27 #include <linux/platform_device.h> 28 - #include <linux/regmap.h> 29 28 #include <linux/slab.h> 30 29 #include <linux/stmp_device.h> 31 30 ··· 65 66 return 0; 66 67 } 67 68 68 - static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size, 69 - void *val, size_t val_size) 69 + static int mxs_ocotp_read(void *context, unsigned int offset, 70 + void *val, size_t bytes) 70 71 { 71 72 struct mxs_ocotp *otp = context; 72 - unsigned int offset = *(u32 *)reg; 73 73 u32 *buf = val; 74 74 int ret; 75 75 ··· 92 94 if (ret) 93 95 goto close_banks; 94 96 95 - while (val_size >= reg_size) { 97 + while (bytes) { 96 98 if ((offset < OCOTP_DATA_OFFSET) || (offset % 16)) { 97 99 /* fill up non-data register */ 98 - *buf = 0; 100 + *buf++ = 0; 99 101 } else { 100 - *buf = readl(otp->base + offset); 102 + *buf++ = readl(otp->base + offset); 101 103 } 102 104 103 - buf++; 104 - val_size -= reg_size; 105 - offset += reg_size; 105 + bytes -= 4; 106 + offset += 4; 106 107 } 107 108 108 109 close_banks: ··· 114 117 return ret; 115 118 } 116 119 117 - static int mxs_ocotp_write(void *context, const void *data, size_t count) 118 - { 119 - /* We don't want to support writing */ 120 - return 0; 121 - } 122 - 123 - static bool mxs_ocotp_writeable_reg(struct device *dev, unsigned int reg) 124 - { 125 - return false; 126 - } 127 - 128 120 static struct nvmem_config ocotp_config = { 129 121 .name = "mxs-ocotp", 122 + .stride = 16, 123 + .word_size = 4, 130 124 .owner = THIS_MODULE, 125 + .reg_read = mxs_ocotp_read, 131 126 }; 132 127 133 - static const struct regmap_range imx23_ranges[] = { 134 - regmap_reg_range(OCOTP_DATA_OFFSET, 0x210), 128 + struct mxs_data { 129 + int size; 135 130 }; 136 131 137 - static const struct regmap_access_table imx23_access = { 138 - .yes_ranges = imx23_ranges, 139 - .n_yes_ranges = ARRAY_SIZE(imx23_ranges), 132 + static const struct mxs_data imx23_data = { 133 + .size = 0x220, 140 134 }; 141 135 142 - static const struct regmap_range imx28_ranges[] = { 143 - regmap_reg_range(OCOTP_DATA_OFFSET, 0x290), 144 - }; 145 - 146 - static const struct regmap_access_table imx28_access = { 147 - .yes_ranges = imx28_ranges, 148 - .n_yes_ranges = ARRAY_SIZE(imx28_ranges), 149 - }; 150 - 151 - static struct regmap_bus mxs_ocotp_bus = { 152 - .read = mxs_ocotp_read, 153 - .write = mxs_ocotp_write, /* make regmap_init() happy */ 154 - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, 155 - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 156 - }; 157 - 158 - static struct regmap_config mxs_ocotp_config = { 159 - .reg_bits = 32, 160 - .val_bits = 32, 161 - .reg_stride = 16, 162 - .writeable_reg = mxs_ocotp_writeable_reg, 136 + static const struct mxs_data imx28_data = { 137 + .size = 0x2a0, 163 138 }; 164 139 165 140 static const struct of_device_id mxs_ocotp_match[] = { 166 - { .compatible = "fsl,imx23-ocotp", .data = &imx23_access }, 167 - { .compatible = "fsl,imx28-ocotp", .data = &imx28_access }, 141 + { .compatible = "fsl,imx23-ocotp", .data = &imx23_data }, 142 + { .compatible = "fsl,imx28-ocotp", .data = &imx28_data }, 168 143 { /* sentinel */}, 169 144 }; 170 145 MODULE_DEVICE_TABLE(of, mxs_ocotp_match); ··· 144 175 static int mxs_ocotp_probe(struct platform_device *pdev) 145 176 { 146 177 struct device *dev = &pdev->dev; 178 + const struct mxs_data *data; 147 179 struct mxs_ocotp *otp; 148 180 struct resource *res; 149 181 const struct of_device_id *match; 150 - struct regmap *regmap; 151 - const struct regmap_access_table *access; 152 182 int ret; 153 183 154 184 match = of_match_device(dev->driver->of_match_table, dev); ··· 173 205 return ret; 174 206 } 175 207 176 - access = match->data; 177 - mxs_ocotp_config.rd_table = access; 178 - mxs_ocotp_config.max_register = access->yes_ranges[0].range_max; 208 + data = match->data; 179 209 180 - regmap = devm_regmap_init(dev, &mxs_ocotp_bus, otp, &mxs_ocotp_config); 181 - if (IS_ERR(regmap)) { 182 - dev_err(dev, "regmap init failed\n"); 183 - ret = PTR_ERR(regmap); 184 - goto err_clk; 185 - } 186 - 210 + ocotp_config.size = data->size; 211 + ocotp_config.priv = otp; 187 212 ocotp_config.dev = dev; 188 213 otp->nvmem = nvmem_register(&ocotp_config); 189 214 if (IS_ERR(otp->nvmem)) {