Lines Matching refs:otp

78 static int sp_otp_read_real(struct sp_ocotp_priv *otp, int addr, char *value)  in sp_otp_read_real()  argument
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()
119 struct sp_ocotp_priv *otp = priv; in sp_ocotp_read() local
125 ret = clk_enable(otp->clk); in sp_ocotp_read()
131 ret = sp_otp_read_real(otp, addr, val); 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()
160 struct sp_ocotp_priv *otp; in sp_ocotp_probe() local
164 otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL); in sp_ocotp_probe()
165 if (!otp) in sp_ocotp_probe()
168 otp->dev = dev; in sp_ocotp_probe()
171 otp->base[HB_GPIO] = devm_ioremap_resource(dev, res); in sp_ocotp_probe()
172 if (IS_ERR(otp->base[HB_GPIO])) in sp_ocotp_probe()
173 return PTR_ERR(otp->base[HB_GPIO]); in sp_ocotp_probe()
176 otp->base[OTPRX] = devm_ioremap_resource(dev, res); in sp_ocotp_probe()
177 if (IS_ERR(otp->base[OTPRX])) in sp_ocotp_probe()
178 return PTR_ERR(otp->base[OTPRX]); in sp_ocotp_probe()
180 otp->clk = devm_clk_get(&pdev->dev, NULL); in sp_ocotp_probe()
181 if (IS_ERR(otp->clk)) in sp_ocotp_probe()
182 return dev_err_probe(&pdev->dev, PTR_ERR(otp->clk), in sp_ocotp_probe()
185 ret = clk_prepare(otp->clk); in sp_ocotp_probe()
191 sp_ocotp_nvmem_config.priv = otp; in sp_ocotp_probe()