drivers/opp/ti-opp-supply.c
Source file repositories/reference/linux-study-clean/drivers/opp/ti-opp-supply.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/opp/ti-opp-supply.c- Extension
.c- Size
- 11782 bytes
- Lines
- 415
- Domain
- Driver Families
- Bucket
- drivers/opp
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/cpufreq.hlinux/device.hlinux/io.hlinux/module.hlinux/notifier.hlinux/of_device.hlinux/of.hlinux/platform_device.hlinux/pm_opp.hlinux/property.hlinux/regulator/consumer.hlinux/slab.h
Detected Declarations
struct ti_opp_supply_optimum_voltage_tablestruct ti_opp_supply_datastruct ti_opp_supply_of_datafunction _store_optimized_voltagesfunction _free_optimized_voltagesfunction _get_optimal_vdd_voltagefunction _opp_set_voltagefunction ti_opp_config_regulatorsfunction ti_opp_supply_probe
Annotated Snippet
struct ti_opp_supply_optimum_voltage_table {
unsigned int reference_uv;
unsigned int optimized_uv;
};
/**
* struct ti_opp_supply_data - OMAP specific opp supply data
* @vdd_table: Optimized voltage mapping table
* @num_vdd_table: number of entries in vdd_table
* @vdd_absolute_max_voltage_uv: absolute maximum voltage in UV for the supply
* @old_supplies: Placeholder for supplies information for old OPP.
* @new_supplies: Placeholder for supplies information for new OPP.
*/
struct ti_opp_supply_data {
struct ti_opp_supply_optimum_voltage_table *vdd_table;
u32 num_vdd_table;
u32 vdd_absolute_max_voltage_uv;
struct dev_pm_opp_supply old_supplies[2];
struct dev_pm_opp_supply new_supplies[2];
};
static struct ti_opp_supply_data opp_data;
/**
* struct ti_opp_supply_of_data - device tree match data
* @flags: specific type of opp supply
* @efuse_voltage_mask: mask required for efuse register representing voltage
* @efuse_voltage_uv: Are the efuse entries in micro-volts? if not, assume
* milli-volts.
*/
struct ti_opp_supply_of_data {
#define OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE BIT(1)
#define OPPDM_HAS_NO_ABB BIT(2)
const u8 flags;
const u32 efuse_voltage_mask;
const bool efuse_voltage_uv;
};
/**
* _store_optimized_voltages() - store optimized voltages
* @dev: ti opp supply device for which we need to store info
* @data: data specific to the device
*
* Picks up efuse based optimized voltages for VDD unique per device and
* stores it in internal data structure for use during transition requests.
*
* Return: If successful, 0, else appropriate error value.
*/
static int _store_optimized_voltages(struct device *dev,
struct ti_opp_supply_data *data)
{
void __iomem *base;
struct property *prop;
struct resource *res;
const __be32 *val;
int proplen, i;
int ret = 0;
struct ti_opp_supply_optimum_voltage_table *table;
const struct ti_opp_supply_of_data *of_data = dev_get_drvdata(dev);
/* pick up Efuse based voltages */
res = platform_get_resource(to_platform_device(dev), IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "Unable to get IO resource\n");
ret = -ENODEV;
goto out_map;
}
base = ioremap(res->start, resource_size(res));
if (!base) {
dev_err(dev, "Unable to map Efuse registers\n");
ret = -ENOMEM;
goto out_map;
}
/* Fetch efuse-settings. */
prop = of_find_property(dev->of_node, "ti,efuse-settings", NULL);
if (!prop) {
dev_err(dev, "No 'ti,efuse-settings' property found\n");
ret = -EINVAL;
goto out;
}
proplen = prop->length / sizeof(int);
data->num_vdd_table = proplen / 2;
/* Verify for corrupted OPP entries in dt */
if (data->num_vdd_table * 2 * sizeof(int) != prop->length) {
dev_err(dev, "Invalid 'ti,efuse-settings'\n");
ret = -EINVAL;
goto out;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/cpufreq.h`, `linux/device.h`, `linux/io.h`, `linux/module.h`, `linux/notifier.h`, `linux/of_device.h`, `linux/of.h`.
- Detected declarations: `struct ti_opp_supply_optimum_voltage_table`, `struct ti_opp_supply_data`, `struct ti_opp_supply_of_data`, `function _store_optimized_voltages`, `function _free_optimized_voltages`, `function _get_optimal_vdd_voltage`, `function _opp_set_voltage`, `function ti_opp_config_regulators`, `function ti_opp_supply_probe`.
- Atlas domain: Driver Families / drivers/opp.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.