Lines Matching +full:syscon +full:- +full:efuse
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI CPUFreq/OPP hw-supported driver
5 * Copyright (C) 2016-2017 Texas Instruments, Inc.
6 * Dave Gerlach <d-gerlach@ti.com>
11 #include <linux/mfd/syscon.h>
57 unsigned long efuse);
64 /* Backward compatibility hack: Might have missing syscon */
72 struct regmap *syscon; member
77 unsigned long efuse) in amx3_efuse_xlate() argument
79 if (!efuse) in amx3_efuse_xlate()
80 efuse = opp_data->soc_data->efuse_fallback; in amx3_efuse_xlate()
82 return ~efuse; in amx3_efuse_xlate()
86 unsigned long efuse) in dra7_efuse_xlate() argument
91 * The efuse on dra7 and am57 parts contains a specific in dra7_efuse_xlate()
95 switch (efuse) { in dra7_efuse_xlate()
112 unsigned long efuse) in omap3_efuse_xlate() argument
115 return BIT(efuse); in omap3_efuse_xlate()
119 unsigned long efuse) in am625_efuse_xlate() argument
123 switch (efuse) { in am625_efuse_xlate()
173 * some eFuse values e.g. CONTROL_FUSE_OPP1_VDD1
174 * are stored in the SYSCON register range
183 .efuse_offset = OMAP34xx_ProdID_SKUID - OMAP3_SYSCON_BASE,
186 .rev_offset = OMAP3_CONTROL_IDCODE - OMAP3_SYSCON_BASE,
200 * some eFuse values e.g. CONTROL_FUSE_OPP 1G_VDD1
201 * are stored in the SYSCON register range.
211 .efuse_offset = OMAP3_CONTROL_DEVICE_STATUS - OMAP3_SYSCON_BASE,
214 .rev_offset = OMAP3_CONTROL_IDCODE - OMAP3_SYSCON_BASE,
221 * high speed grade eFuse and no abb ldo
226 .efuse_offset = OMAP3_CONTROL_DEVICE_STATUS - OMAP3_SYSCON_BASE,
229 .rev_offset = OMAP3_CONTROL_IDCODE - OMAP3_SYSCON_BASE,
244 * ti_cpufreq_get_efuse() - Parse and return efuse value present on SoC
246 * @efuse_value: Set to the value parsed from efuse
248 * Returns error code if efuse not read properly.
253 struct device *dev = opp_data->cpu_dev; in ti_cpufreq_get_efuse()
254 u32 efuse; in ti_cpufreq_get_efuse() local
257 ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset, in ti_cpufreq_get_efuse()
258 &efuse); in ti_cpufreq_get_efuse()
259 if (opp_data->soc_data->quirks & TI_QUIRK_SYSCON_MAY_BE_MISSING && ret == -EIO) { in ti_cpufreq_get_efuse()
260 /* not a syscon register! */ in ti_cpufreq_get_efuse()
262 opp_data->soc_data->efuse_offset, 4); in ti_cpufreq_get_efuse()
265 return -ENOMEM; in ti_cpufreq_get_efuse()
266 efuse = readl(regs); in ti_cpufreq_get_efuse()
271 "Failed to read the efuse value from syscon: %d\n", in ti_cpufreq_get_efuse()
276 efuse = (efuse & opp_data->soc_data->efuse_mask); in ti_cpufreq_get_efuse()
277 efuse >>= opp_data->soc_data->efuse_shift; in ti_cpufreq_get_efuse()
279 *efuse_value = opp_data->soc_data->efuse_xlate(opp_data, efuse); in ti_cpufreq_get_efuse()
285 * ti_cpufreq_get_rev() - Parse and return rev value present on SoC
294 struct device *dev = opp_data->cpu_dev; in ti_cpufreq_get_rev()
298 ret = regmap_read(opp_data->syscon, opp_data->soc_data->rev_offset, in ti_cpufreq_get_rev()
300 if (opp_data->soc_data->quirks & TI_QUIRK_SYSCON_MAY_BE_MISSING && ret == -EIO) { in ti_cpufreq_get_rev()
301 /* not a syscon register! */ in ti_cpufreq_get_rev()
303 opp_data->soc_data->rev_offset, 4); in ti_cpufreq_get_rev()
306 return -ENOMEM; in ti_cpufreq_get_rev()
312 "Failed to read the revision number from syscon: %d\n", in ti_cpufreq_get_rev()
324 struct device *dev = opp_data->cpu_dev; in ti_cpufreq_setup_syscon_register()
325 struct device_node *np = opp_data->opp_node; in ti_cpufreq_setup_syscon_register()
327 opp_data->syscon = syscon_regmap_lookup_by_phandle(np, in ti_cpufreq_setup_syscon_register()
328 "syscon"); in ti_cpufreq_setup_syscon_register()
329 if (IS_ERR(opp_data->syscon)) { in ti_cpufreq_setup_syscon_register()
331 "\"syscon\" is missing, cannot use OPPv2 table.\n"); in ti_cpufreq_setup_syscon_register()
332 return PTR_ERR(opp_data->syscon); in ti_cpufreq_setup_syscon_register()
377 match = dev_get_platdata(&pdev->dev); in ti_cpufreq_probe()
379 return -ENODEV; in ti_cpufreq_probe()
381 opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL); in ti_cpufreq_probe()
383 return -ENOMEM; in ti_cpufreq_probe()
385 opp_data->soc_data = match->data; in ti_cpufreq_probe()
387 opp_data->cpu_dev = get_cpu_device(0); in ti_cpufreq_probe()
388 if (!opp_data->cpu_dev) { in ti_cpufreq_probe()
390 return -ENODEV; in ti_cpufreq_probe()
393 opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev); in ti_cpufreq_probe()
394 if (!opp_data->opp_node) { in ti_cpufreq_probe()
395 dev_info(opp_data->cpu_dev, in ti_cpufreq_probe()
396 "OPP-v2 not supported, cpufreq-dt will attempt to use legacy tables.\n"); in ti_cpufreq_probe()
407 * 0 - SoC Revision in ti_cpufreq_probe()
408 * 1 - eFuse value in ti_cpufreq_probe()
418 if (opp_data->soc_data->multi_regulator) { in ti_cpufreq_probe()
419 if (opp_data->soc_data->reg_names) in ti_cpufreq_probe()
420 config.regulator_names = opp_data->soc_data->reg_names; in ti_cpufreq_probe()
425 ret = dev_pm_opp_set_config(opp_data->cpu_dev, &config); in ti_cpufreq_probe()
427 dev_err_probe(opp_data->cpu_dev, ret, "Failed to set OPP config\n"); in ti_cpufreq_probe()
431 of_node_put(opp_data->opp_node); in ti_cpufreq_probe()
434 platform_device_register_simple("cpufreq-dt", -1, NULL, 0); in ti_cpufreq_probe()
439 of_node_put(opp_data->opp_node); in ti_cpufreq_probe()
451 platform_device_register_data(NULL, "ti-cpufreq", -1, match, in ti_cpufreq_init()
461 .name = "ti-cpufreq",
466 MODULE_DESCRIPTION("TI CPUFreq/OPP hw-supported driver");
467 MODULE_AUTHOR("Dave Gerlach <d-gerlach@ti.com>");