Lines Matching +full:rk3288 +full:- +full:efuse
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Rockchip eFuse Driver
6 * Author: Caesar Wang <wxt@rock-chips.com>
14 #include <linux/nvmem-provider.h>
58 struct rockchip_efuse_chip *efuse = context; in rockchip_rk3288_efuse_read() local
62 ret = clk_prepare_enable(efuse->clk); in rockchip_rk3288_efuse_read()
64 dev_err(efuse->dev, "failed to prepare/enable efuse clk\n"); in rockchip_rk3288_efuse_read()
68 writel(RK3288_LOAD | RK3288_PGENB, efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
70 while (bytes--) { in rockchip_rk3288_efuse_read()
71 writel(readl(efuse->base + REG_EFUSE_CTRL) & in rockchip_rk3288_efuse_read()
73 efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
74 writel(readl(efuse->base + REG_EFUSE_CTRL) | in rockchip_rk3288_efuse_read()
76 efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
78 writel(readl(efuse->base + REG_EFUSE_CTRL) | in rockchip_rk3288_efuse_read()
79 RK3288_STROBE, efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
81 *buf++ = readb(efuse->base + REG_EFUSE_DOUT); in rockchip_rk3288_efuse_read()
82 writel(readl(efuse->base + REG_EFUSE_CTRL) & in rockchip_rk3288_efuse_read()
83 (~RK3288_STROBE), efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
88 writel(RK3288_PGENB | RK3288_CSB, efuse->base + REG_EFUSE_CTRL); in rockchip_rk3288_efuse_read()
90 clk_disable_unprepare(efuse->clk); in rockchip_rk3288_efuse_read()
98 struct rockchip_efuse_chip *efuse = context; in rockchip_rk3328_efuse_read() local
104 ret = clk_prepare_enable(efuse->clk); in rockchip_rk3328_efuse_read()
106 dev_err(efuse->dev, "failed to prepare/enable efuse clk\n"); in rockchip_rk3328_efuse_read()
110 /* 128 Byte efuse, 96 Byte for secure, 32 Byte for non-secure */ in rockchip_rk3328_efuse_read()
115 addr_len = addr_end - addr_start; in rockchip_rk3328_efuse_read()
120 ret = -ENOMEM; in rockchip_rk3328_efuse_read()
124 while (addr_len--) { in rockchip_rk3328_efuse_read()
127 efuse->base + RK3328_AUTO_CTRL); in rockchip_rk3328_efuse_read()
129 status = readl(efuse->base + RK3328_INT_STATUS); in rockchip_rk3328_efuse_read()
131 ret = -EIO; in rockchip_rk3328_efuse_read()
134 out_value = readl(efuse->base + RK3328_DOUT); in rockchip_rk3328_efuse_read()
135 writel(RK3328_INT_FINISH, efuse->base + RK3328_INT_STATUS); in rockchip_rk3328_efuse_read()
145 clk_disable_unprepare(efuse->clk); in rockchip_rk3328_efuse_read()
153 struct rockchip_efuse_chip *efuse = context; in rockchip_rk3399_efuse_read() local
159 ret = clk_prepare_enable(efuse->clk); in rockchip_rk3399_efuse_read()
161 dev_err(efuse->dev, "failed to prepare/enable efuse clk\n"); in rockchip_rk3399_efuse_read()
168 addr_len = addr_end - addr_start; in rockchip_rk3399_efuse_read()
173 clk_disable_unprepare(efuse->clk); in rockchip_rk3399_efuse_read()
174 return -ENOMEM; in rockchip_rk3399_efuse_read()
178 efuse->base + REG_EFUSE_CTRL); in rockchip_rk3399_efuse_read()
180 while (addr_len--) { in rockchip_rk3399_efuse_read()
181 writel(readl(efuse->base + REG_EFUSE_CTRL) | RK3399_STROBE | in rockchip_rk3399_efuse_read()
183 efuse->base + REG_EFUSE_CTRL); in rockchip_rk3399_efuse_read()
185 out_value = readl(efuse->base + REG_EFUSE_DOUT); in rockchip_rk3399_efuse_read()
186 writel(readl(efuse->base + REG_EFUSE_CTRL) & (~RK3399_STROBE), in rockchip_rk3399_efuse_read()
187 efuse->base + REG_EFUSE_CTRL); in rockchip_rk3399_efuse_read()
195 writel(RK3399_PD | RK3399_CSB, efuse->base + REG_EFUSE_CTRL); in rockchip_rk3399_efuse_read()
201 clk_disable_unprepare(efuse->clk); in rockchip_rk3399_efuse_read()
207 .name = "rockchip-efuse",
218 .compatible = "rockchip,rockchip-efuse",
222 .compatible = "rockchip,rk3066a-efuse",
226 .compatible = "rockchip,rk3188-efuse",
230 .compatible = "rockchip,rk3228-efuse",
234 .compatible = "rockchip,rk3288-efuse",
238 .compatible = "rockchip,rk3368-efuse",
242 .compatible = "rockchip,rk3328-efuse",
246 .compatible = "rockchip,rk3399-efuse",
257 struct rockchip_efuse_chip *efuse; in rockchip_efuse_probe() local
259 struct device *dev = &pdev->dev; in rockchip_efuse_probe()
264 return -EINVAL; in rockchip_efuse_probe()
267 efuse = devm_kzalloc(dev, sizeof(struct rockchip_efuse_chip), in rockchip_efuse_probe()
269 if (!efuse) in rockchip_efuse_probe()
270 return -ENOMEM; in rockchip_efuse_probe()
272 efuse->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in rockchip_efuse_probe()
273 if (IS_ERR(efuse->base)) in rockchip_efuse_probe()
274 return PTR_ERR(efuse->base); in rockchip_efuse_probe()
276 efuse->clk = devm_clk_get(dev, "pclk_efuse"); in rockchip_efuse_probe()
277 if (IS_ERR(efuse->clk)) in rockchip_efuse_probe()
278 return PTR_ERR(efuse->clk); in rockchip_efuse_probe()
280 efuse->dev = dev; in rockchip_efuse_probe()
281 if (of_property_read_u32(dev->of_node, "rockchip,efuse-size", in rockchip_efuse_probe()
285 econfig.priv = efuse; in rockchip_efuse_probe()
286 econfig.dev = efuse->dev; in rockchip_efuse_probe()
295 .name = "rockchip-efuse",