Lines Matching +full:sp7021 +full:- +full:ocotp
1 // SPDX-License-Identifier: GPL-2.0
4 * The OCOTP driver for Sunplus SP7021
17 #include <linux/nvmem-provider.h>
94 writel(readl(otp->base[OTPRX] + OTP_STATUS) & OTP_READ_DONE_MASK & in sp_otp_read_real()
95 OTP_LOAD_SECURE_DONE_MASK, otp->base[OTPRX] + OTP_STATUS); in sp_otp_read_real()
96 writel(addr, otp->base[OTPRX] + OTP_READ_ADDRESS); in sp_otp_read_real()
97 writel(readl(otp->base[OTPRX] + OTP_CONTROL_2) | OTP_READ, in sp_otp_read_real()
98 otp->base[OTPRX] + OTP_CONTROL_2); in sp_otp_read_real()
99 writel(readl(otp->base[OTPRX] + OTP_CONTROL_2) & SEL_BAK_KEY2_MASK & SW_TRIM_EN_MASK in sp_otp_read_real()
101 otp->base[OTPRX] + OTP_CONTROL_2); in sp_otp_read_real()
102 writel((readl(otp->base[OTPRX] + OTP_CONTROL_2) & OTP_RD_PERIOD_MASK) | CPU_CLOCK, in sp_otp_read_real()
103 otp->base[OTPRX] + OTP_CONTROL_2); in sp_otp_read_real()
105 ret = readl_poll_timeout(otp->base[OTPRX] + OTP_STATUS, status, in sp_otp_read_real()
111 *value = (readl(otp->base[HB_GPIO] + ADDRESS_8_DATA + addr_data * OTP_WORD_SIZE) in sp_otp_read_real()
125 ret = clk_enable(otp->clk); in sp_ocotp_read()
133 dev_err(otp->dev, "OTP read fail:%d at %d", ret, addr); in sp_ocotp_read()
141 clk_disable(otp->clk); in sp_ocotp_read()
147 .name = "sp-ocotp",
159 struct device *dev = &pdev->dev; in sp_ocotp_probe()
166 return -ENOMEM; in sp_ocotp_probe()
168 otp->dev = dev; in sp_ocotp_probe()
170 otp->base[HB_GPIO] = devm_platform_ioremap_resource_byname(pdev, "hb_gpio"); in sp_ocotp_probe()
171 if (IS_ERR(otp->base[HB_GPIO])) in sp_ocotp_probe()
172 return PTR_ERR(otp->base[HB_GPIO]); in sp_ocotp_probe()
174 otp->base[OTPRX] = devm_platform_ioremap_resource_byname(pdev, "otprx"); in sp_ocotp_probe()
175 if (IS_ERR(otp->base[OTPRX])) in sp_ocotp_probe()
176 return PTR_ERR(otp->base[OTPRX]); in sp_ocotp_probe()
178 otp->clk = devm_clk_get(&pdev->dev, NULL); in sp_ocotp_probe()
179 if (IS_ERR(otp->clk)) in sp_ocotp_probe()
180 return dev_err_probe(&pdev->dev, PTR_ERR(otp->clk), in sp_ocotp_probe()
183 ret = clk_prepare(otp->clk); in sp_ocotp_probe()
194 ret = dev_err_probe(&pdev->dev, PTR_ERR(nvmem), in sp_ocotp_probe()
207 clk_unprepare(otp->clk); in sp_ocotp_probe()
212 { .compatible = "sunplus,sp7021-ocotp", .data = &sp_otp_v0 },
220 .name = "sunplus,sp7021-ocotp",
227 MODULE_DESCRIPTION("Sunplus On-Chip OTP driver");