Lines Matching full:otp

3  * Rockchip OTP Driver
22 /* OTP Register Offsets */
35 /* OTP Register bits and masks */
85 static int rockchip_otp_reset(struct rockchip_otp *otp) in rockchip_otp_reset() argument
89 ret = reset_control_assert(otp->rst); in rockchip_otp_reset()
91 dev_err(otp->dev, "failed to assert otp phy %d\n", ret); in rockchip_otp_reset()
97 ret = reset_control_deassert(otp->rst); in rockchip_otp_reset()
99 dev_err(otp->dev, "failed to deassert otp phy %d\n", ret); in rockchip_otp_reset()
106 static int rockchip_otp_wait_status(struct rockchip_otp *otp, in rockchip_otp_wait_status() argument
112 ret = readl_poll_timeout_atomic(otp->base + reg, status, in rockchip_otp_wait_status()
118 writel(flag, otp->base + reg); in rockchip_otp_wait_status()
123 static int rockchip_otp_ecc_enable(struct rockchip_otp *otp, bool enable) in rockchip_otp_ecc_enable() argument
128 otp->base + OTPC_SBPI_CTRL); in rockchip_otp_ecc_enable()
130 writel(SBPI_CMD_VALID_MASK | 0x1, otp->base + OTPC_SBPI_CMD_VALID_PRE); in rockchip_otp_ecc_enable()
132 otp->base + OTPC_SBPI_CMD0_OFFSET); in rockchip_otp_ecc_enable()
134 writel(SBPI_ECC_ENABLE, otp->base + OTPC_SBPI_CMD1_OFFSET); in rockchip_otp_ecc_enable()
136 writel(SBPI_ECC_DISABLE, otp->base + OTPC_SBPI_CMD1_OFFSET); in rockchip_otp_ecc_enable()
138 writel(SBPI_ENABLE_MASK | SBPI_ENABLE, otp->base + OTPC_SBPI_CTRL); in rockchip_otp_ecc_enable()
140 ret = rockchip_otp_wait_status(otp, OTPC_INT_STATUS, OTPC_SBPI_DONE); in rockchip_otp_ecc_enable()
142 dev_err(otp->dev, "timeout during ecc_enable\n"); in rockchip_otp_ecc_enable()
150 struct rockchip_otp *otp = context; in px30_otp_read() local
154 ret = rockchip_otp_reset(otp); in px30_otp_read()
156 dev_err(otp->dev, "failed to reset otp phy\n"); in px30_otp_read()
160 ret = rockchip_otp_ecc_enable(otp, false); in px30_otp_read()
162 dev_err(otp->dev, "rockchip_otp_ecc_enable err\n"); in px30_otp_read()
166 writel(OTPC_USE_USER | OTPC_USE_USER_MASK, otp->base + OTPC_USER_CTRL); in px30_otp_read()
170 otp->base + OTPC_USER_ADDR); in px30_otp_read()
172 otp->base + OTPC_USER_ENABLE); in px30_otp_read()
173 ret = rockchip_otp_wait_status(otp, OTPC_INT_STATUS, OTPC_USER_DONE); in px30_otp_read()
175 dev_err(otp->dev, "timeout during read setup\n"); in px30_otp_read()
178 *buf++ = readb(otp->base + OTPC_USER_Q); in px30_otp_read()
182 writel(0x0 | OTPC_USE_USER_MASK, otp->base + OTPC_USER_CTRL); in px30_otp_read()
190 struct rockchip_otp *otp = context; in rk3588_otp_read() local
208 otp->base + RK3588_OTPC_AUTO_CTRL); in rk3588_otp_read()
209 writel(RK3588_AUTO_EN, otp->base + RK3588_OTPC_AUTO_EN); in rk3588_otp_read()
211 ret = rockchip_otp_wait_status(otp, RK3588_OTPC_INT_ST, in rk3588_otp_read()
214 dev_err(otp->dev, "timeout during read setup\n"); in rk3588_otp_read()
218 data = readl(otp->base + RK3588_OTPC_DOUT0); in rk3588_otp_read()
236 struct rockchip_otp *otp = context; in rockchip_otp_read() local
239 if (!otp->data || !otp->data->reg_read) in rockchip_otp_read()
242 ret = clk_bulk_prepare_enable(otp->data->num_clks, otp->clks); in rockchip_otp_read()
244 dev_err(otp->dev, "failed to prepare/enable clks\n"); in rockchip_otp_read()
248 ret = otp->data->reg_read(context, offset, val, bytes); in rockchip_otp_read()
250 clk_bulk_disable_unprepare(otp->data->num_clks, otp->clks); in rockchip_otp_read()
256 .name = "rockchip-otp",
267 "otp", "apb_pclk", "phy",
278 "otp", "apb_pclk", "phy", "arb",
290 .compatible = "rockchip,px30-otp",
294 .compatible = "rockchip,rk3308-otp",
298 .compatible = "rockchip,rk3588-otp",
308 struct rockchip_otp *otp; in rockchip_otp_probe() local
317 otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp), in rockchip_otp_probe()
319 if (!otp) in rockchip_otp_probe()
322 otp->data = data; in rockchip_otp_probe()
323 otp->dev = dev; in rockchip_otp_probe()
324 otp->base = devm_platform_ioremap_resource(pdev, 0); in rockchip_otp_probe()
325 if (IS_ERR(otp->base)) in rockchip_otp_probe()
326 return dev_err_probe(dev, PTR_ERR(otp->base), in rockchip_otp_probe()
329 otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks), in rockchip_otp_probe()
331 if (!otp->clks) in rockchip_otp_probe()
335 otp->clks[i].id = data->clks[i]; in rockchip_otp_probe()
337 ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks); in rockchip_otp_probe()
341 otp->rst = devm_reset_control_array_get_exclusive(dev); in rockchip_otp_probe()
342 if (IS_ERR(otp->rst)) in rockchip_otp_probe()
343 return dev_err_probe(dev, PTR_ERR(otp->rst), in rockchip_otp_probe()
347 otp_config.priv = otp; in rockchip_otp_probe()
360 .name = "rockchip-otp",
366 MODULE_DESCRIPTION("Rockchip OTP driver");