Lines Matching full:efuse

3  * Amlogic Meson6, Meson8 and Meson8b eFuse Driver
50 static void meson_mx_efuse_mask_bits(struct meson_mx_efuse *efuse, u32 reg, in meson_mx_efuse_mask_bits() argument
55 data = readl(efuse->base + reg); in meson_mx_efuse_mask_bits()
59 writel(data, efuse->base + reg); in meson_mx_efuse_mask_bits()
62 static int meson_mx_efuse_hw_enable(struct meson_mx_efuse *efuse) in meson_mx_efuse_hw_enable() argument
66 err = clk_prepare_enable(efuse->core_clk); in meson_mx_efuse_hw_enable()
70 /* power up the efuse */ in meson_mx_efuse_hw_enable()
71 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_hw_enable()
74 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL4, in meson_mx_efuse_hw_enable()
80 static void meson_mx_efuse_hw_disable(struct meson_mx_efuse *efuse) in meson_mx_efuse_hw_disable() argument
82 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_hw_disable()
86 clk_disable_unprepare(efuse->core_clk); in meson_mx_efuse_hw_disable()
89 static int meson_mx_efuse_read_addr(struct meson_mx_efuse *efuse, in meson_mx_efuse_read_addr() argument
97 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
101 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
104 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
108 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
111 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
118 readl(efuse->base + MESON_MX_EFUSE_CNTL1); in meson_mx_efuse_read_addr()
120 err = readl_poll_timeout_atomic(efuse->base + MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
125 dev_err(efuse->config.dev, in meson_mx_efuse_read_addr()
126 "Timeout while reading efuse address %u\n", addr); in meson_mx_efuse_read_addr()
130 *value = readl(efuse->base + MESON_MX_EFUSE_CNTL2); in meson_mx_efuse_read_addr()
138 struct meson_mx_efuse *efuse = context; in meson_mx_efuse_read() local
142 err = meson_mx_efuse_hw_enable(efuse); in meson_mx_efuse_read()
146 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read()
150 for (i = 0; i < bytes; i += efuse->config.word_size) { in meson_mx_efuse_read()
151 addr = (offset + i) / efuse->config.word_size; in meson_mx_efuse_read()
153 err = meson_mx_efuse_read_addr(efuse, addr, &tmp); in meson_mx_efuse_read()
158 min_t(size_t, bytes - i, efuse->config.word_size)); in meson_mx_efuse_read()
161 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read()
164 meson_mx_efuse_hw_disable(efuse); in meson_mx_efuse_read()
170 .name = "meson6-efuse",
175 .name = "meson8-efuse",
180 .name = "meson8b-efuse",
185 { .compatible = "amlogic,meson6-efuse", .data = &meson6_efuse_data },
186 { .compatible = "amlogic,meson8-efuse", .data = &meson8_efuse_data },
187 { .compatible = "amlogic,meson8b-efuse", .data = &meson8b_efuse_data },
195 struct meson_mx_efuse *efuse; in meson_mx_efuse_probe() local
201 efuse = devm_kzalloc(&pdev->dev, sizeof(*efuse), GFP_KERNEL); in meson_mx_efuse_probe()
202 if (!efuse) in meson_mx_efuse_probe()
205 efuse->base = devm_platform_ioremap_resource(pdev, 0); in meson_mx_efuse_probe()
206 if (IS_ERR(efuse->base)) in meson_mx_efuse_probe()
207 return PTR_ERR(efuse->base); in meson_mx_efuse_probe()
209 efuse->config.name = drvdata->name; in meson_mx_efuse_probe()
210 efuse->config.owner = THIS_MODULE; in meson_mx_efuse_probe()
211 efuse->config.dev = &pdev->dev; in meson_mx_efuse_probe()
212 efuse->config.priv = efuse; in meson_mx_efuse_probe()
213 efuse->config.add_legacy_fixed_of_cells = true; in meson_mx_efuse_probe()
214 efuse->config.stride = drvdata->word_size; in meson_mx_efuse_probe()
215 efuse->config.word_size = drvdata->word_size; in meson_mx_efuse_probe()
216 efuse->config.size = SZ_512; in meson_mx_efuse_probe()
217 efuse->config.read_only = true; in meson_mx_efuse_probe()
218 efuse->config.reg_read = meson_mx_efuse_read; in meson_mx_efuse_probe()
220 efuse->core_clk = devm_clk_get(&pdev->dev, "core"); in meson_mx_efuse_probe()
221 if (IS_ERR(efuse->core_clk)) { in meson_mx_efuse_probe()
223 return PTR_ERR(efuse->core_clk); in meson_mx_efuse_probe()
226 efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); in meson_mx_efuse_probe()
228 return PTR_ERR_OR_ZERO(efuse->nvmem); in meson_mx_efuse_probe()
234 .name = "meson-mx-efuse",
242 MODULE_DESCRIPTION("Amlogic Meson MX eFuse NVMEM driver");