Lines Matching +full:clk +full:- +full:delay +full:- +full:cycles

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Freescale MXS On-Chip OTP driver
9 #include <linux/clk.h>
10 #include <linux/delay.h>
15 #include <linux/nvmem-provider.h>
32 struct clk *clk; member
42 while (timeout--) { in mxs_ocotp_wait()
43 status = readl(otp->base); in mxs_ocotp_wait()
52 return -EBUSY; in mxs_ocotp_wait()
54 return -EIO; in mxs_ocotp_wait()
66 ret = clk_enable(otp->clk); in mxs_ocotp_read()
70 writel(BM_OCOTP_CTRL_ERROR, otp->base + STMP_OFFSET_REG_CLR); in mxs_ocotp_read()
77 writel(BM_OCOTP_CTRL_RD_BANK_OPEN, otp->base + STMP_OFFSET_REG_SET); in mxs_ocotp_read()
79 /* approximately wait 33 hclk cycles */ in mxs_ocotp_read()
88 /* fill up non-data register */ in mxs_ocotp_read()
91 *buf++ = readl(otp->base + offset); in mxs_ocotp_read()
94 bytes -= 4; in mxs_ocotp_read()
100 writel(BM_OCOTP_CTRL_RD_BANK_OPEN, otp->base + STMP_OFFSET_REG_CLR); in mxs_ocotp_read()
103 clk_disable(otp->clk); in mxs_ocotp_read()
109 .name = "mxs-ocotp",
128 { .compatible = "fsl,imx23-ocotp", .data = &imx23_data },
129 { .compatible = "fsl,imx28-ocotp", .data = &imx28_data },
141 struct device *dev = &pdev->dev; in mxs_ocotp_probe()
148 return -EINVAL; in mxs_ocotp_probe()
152 return -ENOMEM; in mxs_ocotp_probe()
154 otp->base = devm_platform_ioremap_resource(pdev, 0); in mxs_ocotp_probe()
155 if (IS_ERR(otp->base)) in mxs_ocotp_probe()
156 return PTR_ERR(otp->base); in mxs_ocotp_probe()
158 otp->clk = devm_clk_get(&pdev->dev, NULL); in mxs_ocotp_probe()
159 if (IS_ERR(otp->clk)) in mxs_ocotp_probe()
160 return PTR_ERR(otp->clk); in mxs_ocotp_probe()
162 ret = clk_prepare(otp->clk); in mxs_ocotp_probe()
164 dev_err(dev, "failed to prepare clk: %d\n", ret); in mxs_ocotp_probe()
168 ret = devm_add_action_or_reset(&pdev->dev, mxs_ocotp_action, otp->clk); in mxs_ocotp_probe()
172 ocotp_config.size = data->size; in mxs_ocotp_probe()
175 otp->nvmem = devm_nvmem_register(dev, &ocotp_config); in mxs_ocotp_probe()
176 if (IS_ERR(otp->nvmem)) in mxs_ocotp_probe()
177 return PTR_ERR(otp->nvmem); in mxs_ocotp_probe()
187 .name = "mxs-ocotp",