Lines Matching +full:jz4780 +full:- +full:efuse
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * JZ4780 EFUSE Memory Support driver
10 * Currently supports JZ4780 efuse which has 8K programmable bit.
11 * Efuse is separated into seven segments as below:
13 * -----------------------------------------------------------------------
15 * -----------------------------------------------------------------------
27 #include <linux/nvmem-provider.h>
72 struct jz4780_efuse *efuse = context; in jz4780_efuse_read() local
75 size_t start = offset & ~(JZ_EFU_READ_SIZE - 1); in jz4780_efuse_read()
77 - offset); in jz4780_efuse_read()
84 | ((JZ_EFU_READ_SIZE - 1) << EFUCTRL_LEN_SHIFT) in jz4780_efuse_read()
87 regmap_update_bits(efuse->map, JZ_EFUCTRL, in jz4780_efuse_read()
94 ret = regmap_read_poll_timeout(efuse->map, JZ_EFUSTATE, in jz4780_efuse_read()
99 dev_err(efuse->dev, "Time out while reading efuse data"); in jz4780_efuse_read()
103 ret = regmap_bulk_read(efuse->map, JZ_EFUDATA(0), in jz4780_efuse_read()
108 memcpy(val, &buf[offset - start], chunk); in jz4780_efuse_read()
112 bytes -= chunk; in jz4780_efuse_read()
119 .name = "jz4780-efuse",
142 struct jz4780_efuse *efuse; in jz4780_efuse_probe() local
147 struct device *dev = &pdev->dev; in jz4780_efuse_probe()
151 efuse = devm_kzalloc(dev, sizeof(*efuse), GFP_KERNEL); in jz4780_efuse_probe()
152 if (!efuse) in jz4780_efuse_probe()
153 return -ENOMEM; in jz4780_efuse_probe()
159 efuse->map = devm_regmap_init_mmio(dev, regs, in jz4780_efuse_probe()
161 if (IS_ERR(efuse->map)) in jz4780_efuse_probe()
162 return PTR_ERR(efuse->map); in jz4780_efuse_probe()
164 efuse->clk = devm_clk_get(&pdev->dev, NULL); in jz4780_efuse_probe()
165 if (IS_ERR(efuse->clk)) in jz4780_efuse_probe()
166 return PTR_ERR(efuse->clk); in jz4780_efuse_probe()
168 ret = clk_prepare_enable(efuse->clk); in jz4780_efuse_probe()
172 ret = devm_add_action_or_reset(&pdev->dev, in jz4780_efuse_probe()
174 efuse->clk); in jz4780_efuse_probe()
178 clk_rate = clk_get_rate(efuse->clk); in jz4780_efuse_probe()
180 efuse->dev = dev; in jz4780_efuse_probe()
188 * i.e. rd_strobe >= 35 ns / clk_period - 5 - rd_adj + 1 in jz4780_efuse_probe()
195 rd_strobe = clk_rate / 28571429 - 5 - rd_adj + 1; in jz4780_efuse_probe()
199 dev_err(&pdev->dev, "Cannot set clock configuration\n"); in jz4780_efuse_probe()
200 return -EINVAL; in jz4780_efuse_probe()
203 regmap_update_bits(efuse->map, JZ_EFUCFG, in jz4780_efuse_probe()
210 cfg.dev = &pdev->dev; in jz4780_efuse_probe()
211 cfg.priv = efuse; in jz4780_efuse_probe()
219 { .compatible = "ingenic,jz4780-efuse" },
227 .name = "jz4780-efuse",
236 MODULE_DESCRIPTION("Ingenic JZ4780 efuse driver");