Lines Matching +full:opp +full:- +full:v2 +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2016-2017 Texas Instruments Incorporated - https://www.ti.com/
5 * Dave Gerlach <d-gerlach@ti.com>
7 * TI OPP supply driver that provides override into the regulator control
8 * for generic opp core to handle devices with ABB regulator and/or
26 * struct ti_opp_supply_optimum_voltage_table - optimized voltage table
36 * struct ti_opp_supply_data - OMAP specific opp supply data
40 * @old_supplies: Placeholder for supplies information for old OPP.
41 * @new_supplies: Placeholder for supplies information for new OPP.
54 * struct ti_opp_supply_of_data - device tree match data
55 * @flags: specific type of opp supply
57 * @efuse_voltage_uv: Are the efuse entries in micro-volts? if not, assume
58 * milli-volts.
69 * _store_optimized_voltages() - store optimized voltages
70 * @dev: ti opp supply device for which we need to store info
81 void __iomem *base; in _store_optimized_voltages() local
94 ret = -ENODEV; in _store_optimized_voltages()
98 base = ioremap(res->start, resource_size(res)); in _store_optimized_voltages()
99 if (!base) { in _store_optimized_voltages()
101 ret = -ENOMEM; in _store_optimized_voltages()
105 /* Fetch efuse-settings. */ in _store_optimized_voltages()
106 prop = of_find_property(dev->of_node, "ti,efuse-settings", NULL); in _store_optimized_voltages()
108 dev_err(dev, "No 'ti,efuse-settings' property found\n"); in _store_optimized_voltages()
109 ret = -EINVAL; in _store_optimized_voltages()
113 proplen = prop->length / sizeof(int); in _store_optimized_voltages()
114 data->num_vdd_table = proplen / 2; in _store_optimized_voltages()
115 /* Verify for corrupted OPP entries in dt */ in _store_optimized_voltages()
116 if (data->num_vdd_table * 2 * sizeof(int) != prop->length) { in _store_optimized_voltages()
117 dev_err(dev, "Invalid 'ti,efuse-settings'\n"); in _store_optimized_voltages()
118 ret = -EINVAL; in _store_optimized_voltages()
122 ret = of_property_read_u32(dev->of_node, "ti,absolute-max-voltage-uv", in _store_optimized_voltages()
123 &data->vdd_absolute_max_voltage_uv); in _store_optimized_voltages()
125 dev_err(dev, "ti,absolute-max-voltage-uv is missing\n"); in _store_optimized_voltages()
126 ret = -EINVAL; in _store_optimized_voltages()
130 table = kcalloc(data->num_vdd_table, sizeof(*data->vdd_table), in _store_optimized_voltages()
133 ret = -ENOMEM; in _store_optimized_voltages()
136 data->vdd_table = table; in _store_optimized_voltages()
138 val = prop->value; in _store_optimized_voltages()
139 for (i = 0; i < data->num_vdd_table; i++, table++) { in _store_optimized_voltages()
143 table->reference_uv = be32_to_cpup(val++); in _store_optimized_voltages()
146 tmp = readl(base + efuse_offset); in _store_optimized_voltages()
147 tmp &= of_data->efuse_voltage_mask; in _store_optimized_voltages()
148 tmp >>= __ffs(of_data->efuse_voltage_mask); in _store_optimized_voltages()
150 table->optimized_uv = of_data->efuse_voltage_uv ? tmp : in _store_optimized_voltages()
154 i, efuse_offset, table->reference_uv, in _store_optimized_voltages()
155 table->optimized_uv); in _store_optimized_voltages()
159 * Use reference voltage for those - just add debug message in _store_optimized_voltages()
162 if (!table->optimized_uv) { in _store_optimized_voltages()
164 i, efuse_offset, table->reference_uv); in _store_optimized_voltages()
165 table->optimized_uv = table->reference_uv; in _store_optimized_voltages()
169 iounmap(base); in _store_optimized_voltages()
175 * _free_optimized_voltages() - free resources for optvoltages
182 kfree(data->vdd_table); in _free_optimized_voltages()
183 data->vdd_table = NULL; in _free_optimized_voltages()
184 data->num_vdd_table = 0; in _free_optimized_voltages()
188 * _get_optimal_vdd_voltage() - Finds optimal voltage for the supply
191 * @reference_uv: reference voltage (OPP voltage) for which we need value
203 if (!data->num_vdd_table) in _get_optimal_vdd_voltage()
206 table = data->vdd_table; in _get_optimal_vdd_voltage()
208 return -EINVAL; in _get_optimal_vdd_voltage()
210 /* Find a exact match - this list is usually very small */ in _get_optimal_vdd_voltage()
211 for (i = 0; i < data->num_vdd_table; i++, table++) in _get_optimal_vdd_voltage()
212 if (table->reference_uv == reference_uv) in _get_optimal_vdd_voltage()
213 return table->optimized_uv; in _get_optimal_vdd_voltage()
232 vdd_uv = supply->u_volt; in _opp_set_voltage()
237 * are ganged (example if we set the max for an opp as 1.12v, and in _opp_set_voltage()
245 uv_max = supply->u_volt_max; in _opp_set_voltage()
248 vdd_uv < supply->u_volt_min || in _opp_set_voltage()
249 supply->u_volt_min > uv_max) { in _opp_set_voltage()
252 supply->u_volt_min, vdd_uv, uv_max); in _opp_set_voltage()
253 return -EINVAL; in _opp_set_voltage()
257 vdd_uv, supply->u_volt_min, in _opp_set_voltage()
261 supply->u_volt_min, in _opp_set_voltage()
266 reg_name, vdd_uv, supply->u_volt_min, in _opp_set_voltage()
274 /* Do the opp supply transition */
292 /* Fetch supplies and freq information from OPP core */ in ti_opp_config_regulators()
301 new_supply_vdd->u_volt); in ti_opp_config_regulators()
303 if (new_supply_vdd->u_volt_min < vdd_uv) in ti_opp_config_regulators()
304 new_supply_vdd->u_volt_min = vdd_uv; in ti_opp_config_regulators()
335 if (old_supply_vdd->u_volt) { in ti_opp_config_regulators()
365 {.compatible = "ti,omap-opp-supply", .data = &omap_generic_of_data},
366 {.compatible = "ti,omap5-opp-supply", .data = &omap_omap5_of_data},
367 {.compatible = "ti,omap5-core-opp-supply",
375 struct device *dev = &pdev->dev; in ti_opp_supply_probe()
384 return -EINVAL; in ti_opp_supply_probe()
389 if (of_data->flags & OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE) { in ti_opp_supply_probe()
413 MODULE_DESCRIPTION("Texas Instruments OMAP OPP Supply driver");
415 MODULE_LICENSE("GPL v2");