Lines Matching full:efuse
3 * Amlogic Meson6, Meson8 and Meson8b eFuse Driver
49 static void meson_mx_efuse_mask_bits(struct meson_mx_efuse *efuse, u32 reg, in meson_mx_efuse_mask_bits() argument
54 data = readl(efuse->base + reg); in meson_mx_efuse_mask_bits()
58 writel(data, efuse->base + reg); in meson_mx_efuse_mask_bits()
61 static int meson_mx_efuse_hw_enable(struct meson_mx_efuse *efuse) in meson_mx_efuse_hw_enable() argument
65 err = clk_prepare_enable(efuse->core_clk); in meson_mx_efuse_hw_enable()
69 /* power up the efuse */ in meson_mx_efuse_hw_enable()
70 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_hw_enable()
73 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL4, in meson_mx_efuse_hw_enable()
79 static void meson_mx_efuse_hw_disable(struct meson_mx_efuse *efuse) in meson_mx_efuse_hw_disable() argument
81 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_hw_disable()
85 clk_disable_unprepare(efuse->core_clk); in meson_mx_efuse_hw_disable()
88 static int meson_mx_efuse_read_addr(struct meson_mx_efuse *efuse, in meson_mx_efuse_read_addr() argument
96 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
100 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
103 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
107 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
110 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
117 readl(efuse->base + MESON_MX_EFUSE_CNTL1); in meson_mx_efuse_read_addr()
119 err = readl_poll_timeout_atomic(efuse->base + MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read_addr()
124 dev_err(efuse->config.dev, in meson_mx_efuse_read_addr()
125 "Timeout while reading efuse address %u\n", addr); in meson_mx_efuse_read_addr()
129 *value = readl(efuse->base + MESON_MX_EFUSE_CNTL2); in meson_mx_efuse_read_addr()
137 struct meson_mx_efuse *efuse = context; in meson_mx_efuse_read() local
141 err = meson_mx_efuse_hw_enable(efuse); in meson_mx_efuse_read()
145 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read()
149 for (i = 0; i < bytes; i += efuse->config.word_size) { in meson_mx_efuse_read()
150 addr = (offset + i) / efuse->config.word_size; in meson_mx_efuse_read()
152 err = meson_mx_efuse_read_addr(efuse, addr, &tmp); in meson_mx_efuse_read()
157 min_t(size_t, bytes - i, efuse->config.word_size)); in meson_mx_efuse_read()
160 meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1, in meson_mx_efuse_read()
163 meson_mx_efuse_hw_disable(efuse); in meson_mx_efuse_read()
169 .name = "meson6-efuse",
174 .name = "meson8-efuse",
179 .name = "meson8b-efuse",
184 { .compatible = "amlogic,meson6-efuse", .data = &meson6_efuse_data },
185 { .compatible = "amlogic,meson8-efuse", .data = &meson8_efuse_data },
186 { .compatible = "amlogic,meson8b-efuse", .data = &meson8b_efuse_data },
194 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 nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); in meson_mx_efuse_probe()
234 .name = "meson-mx-efuse",
242 MODULE_DESCRIPTION("Amlogic Meson MX eFuse NVMEM driver");