Lines Matching +full:otp +full:- +full:size
19 #include <linux/nvmem-provider.h>
25 * # of tries for OTP Status. The time to execute a command varies. The slowest
31 /* Sequence to enable OTP program */
56 #define OTPC_CMD_MASK (BIT(OTPC_COMMAND_COMMAND_WIDTH) - 1)
57 #define OTPC_ADDR_MASK (BIT(OTPC_CPUADDR_REG_OTPC_CPU_ADDRESS_WIDTH) - 1)
125 return -EAGAIN; in poll_cpu_status()
168 u32 address = offset / priv->config->word_size; in bcm_otpc_read()
172 set_command(priv->base, OTPC_CMD_READ); in bcm_otpc_read()
173 set_cpu_address(priv->base, address++); in bcm_otpc_read()
174 set_start_bit(priv->base); in bcm_otpc_read()
175 ret = poll_cpu_status(priv->base, OTPC_STAT_CMD_DONE); in bcm_otpc_read()
177 dev_err(priv->dev, "otp read error: 0x%x", ret); in bcm_otpc_read()
178 return -EIO; in bcm_otpc_read()
181 for (i = 0; i < priv->map->otpc_row_size; i++) { in bcm_otpc_read()
182 *buf++ = readl(priv->base + in bcm_otpc_read()
183 priv->map->data_r_offset[i]); in bcm_otpc_read()
187 reset_start_bit(priv->base); in bcm_otpc_read()
199 u32 address = offset / priv->config->word_size; in bcm_otpc_write()
202 if (offset % priv->config->word_size) in bcm_otpc_write()
203 return -EINVAL; in bcm_otpc_write()
205 ret = enable_ocotp_program(priv->base); in bcm_otpc_write()
207 return -EIO; in bcm_otpc_write()
210 set_command(priv->base, OTPC_CMD_PROGRAM); in bcm_otpc_write()
211 set_cpu_address(priv->base, address++); in bcm_otpc_write()
212 for (i = 0; i < priv->map->otpc_row_size; i++) { in bcm_otpc_write()
213 writel(*buf, priv->base + priv->map->data_w_offset[i]); in bcm_otpc_write()
217 set_start_bit(priv->base); in bcm_otpc_write()
218 ret = poll_cpu_status(priv->base, OTPC_STAT_CMD_DONE); in bcm_otpc_write()
219 reset_start_bit(priv->base); in bcm_otpc_write()
221 dev_err(priv->dev, "otp write error: 0x%x", ret); in bcm_otpc_write()
222 return -EIO; in bcm_otpc_write()
226 disable_ocotp_program(priv->base); in bcm_otpc_write()
232 .name = "bcm-ocotp",
242 { .compatible = "brcm,ocotp-v2", .data = &otp_map_v2 },
256 struct device *dev = &pdev->dev; in bcm_otpc_probe()
265 return -ENOMEM; in bcm_otpc_probe()
267 priv->map = device_get_match_data(dev); in bcm_otpc_probe()
268 if (!priv->map) in bcm_otpc_probe()
269 return -ENODEV; in bcm_otpc_probe()
271 /* Get OTP base address register. */ in bcm_otpc_probe()
273 priv->base = devm_ioremap_resource(dev, res); in bcm_otpc_probe()
274 if (IS_ERR(priv->base)) { in bcm_otpc_probe()
276 return PTR_ERR(priv->base); in bcm_otpc_probe()
280 writel(readl(priv->base + OTPC_MODE_REG_OFFSET) | in bcm_otpc_probe()
282 priv->base + OTPC_MODE_REG_OFFSET); in bcm_otpc_probe()
283 reset_start_bit(priv->base); in bcm_otpc_probe()
285 /* Read size of memory in words. */ in bcm_otpc_probe()
286 err = device_property_read_u32(dev, "brcm,ocotp-size", &num_words); in bcm_otpc_probe()
288 dev_err(dev, "size parameter not specified\n"); in bcm_otpc_probe()
289 return -EINVAL; in bcm_otpc_probe()
291 dev_err(dev, "size must be > 0\n"); in bcm_otpc_probe()
292 return -EINVAL; in bcm_otpc_probe()
295 bcm_otpc_nvmem_config.size = 4 * num_words; in bcm_otpc_probe()
299 if (priv->map == &otp_map_v2) { in bcm_otpc_probe()
304 priv->config = &bcm_otpc_nvmem_config; in bcm_otpc_probe()
318 .name = "brcm-otpc",