// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2016-2017 Texas Instruments Incorporated - https://www.ti.com/ * Nishanth Menon <[email protected]> * Dave Gerlach <[email protected]> * * TI OPP supply driver that provides override into the regulator control * for generic opp core to handle devices with ABB regulator and/or * SmartReflex Class0. */ #include <linux/clk.h> #include <linux/cpufreq.h> #include <linux/device.h> #include <linux/io.h> #include <linux/module.h> #include <linux/notifier.h> #include <linux/of_device.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_opp.h> #include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> /** * struct ti_opp_supply_optimum_voltage_table - optimized voltage table * @reference_uv: reference voltage (usually Nominal voltage) * @optimized_uv: Optimized voltage from efuse */ struct ti_opp_supply_optimum_voltage_table { … }; /** * 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 { … }; 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 { … }; /** * _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) { … } /** * _free_optimized_voltages() - free resources for optvoltages * @dev: device for which we need to free info * @data: data specific to the device */ static void _free_optimized_voltages(struct device *dev, struct ti_opp_supply_data *data) { … } /** * _get_optimal_vdd_voltage() - Finds optimal voltage for the supply * @dev: device for which we need to find info * @data: data specific to the device * @reference_uv: reference voltage (OPP voltage) for which we need value * * Return: if a match is found, return optimized voltage, else return * reference_uv, also return reference_uv if no optimization is needed. */ static int _get_optimal_vdd_voltage(struct device *dev, struct ti_opp_supply_data *data, int reference_uv) { … } static int _opp_set_voltage(struct device *dev, struct dev_pm_opp_supply *supply, int new_target_uv, struct regulator *reg, char *reg_name) { … } /* Do the opp supply transition */ static int ti_opp_config_regulators(struct device *dev, struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, struct regulator **regulators, unsigned int count) { … } static const struct ti_opp_supply_of_data omap_generic_of_data = …; static const struct ti_opp_supply_of_data omap_omap5_of_data = …; static const struct ti_opp_supply_of_data omap_omap5core_of_data = …; static const struct of_device_id ti_opp_supply_of_match[] = …; MODULE_DEVICE_TABLE(of, ti_opp_supply_of_match); static int ti_opp_supply_probe(struct platform_device *pdev) { … } static struct platform_driver ti_opp_supply_driver = …; module_platform_driver(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;