PM / OPP: Introduce ti-opp-supply driver
Subsystems (3)
cover PM / OPP: Introduce ti-opp-supply driver
Some SoCs, such as Texas Instruments DRA7 family, have complex requirements for scaling voltages and supplies when doing things like DVFS. For example, for cpufreq on dra7xx, the cpu-supply must be scaled as is normally done however there is also an Adaptive Body Bias (ABB) regulator that should be scaled at the same time as the main supply in sequence depending on the transition, explained earlier by Nishanth Menon here [1]. In addition to this, each possible operating point has a corresponding optimized voltage value stored in a register (Adaptive Voltage Scaling Class 0) that can be used instead of the nominal value.
The OPP framework is now able to to handle DVFS transitions through the provided dev_pm_opp_set_rate API and cpufreq-dt is doing this. Viresh Kumar extended this to allow platforms to register a transition helper through the use of dev_pm_opp_register_set_opp_helper and has also extended the OPP core to support registering multiple regulators. By providing a TI platform specific opp_helper function and registering the proepr regulators with the OPP core we can meet the above requirements for properly changing DVFS state of the cpu device.
This series introduces a ti-opp-supply driver that overrides the standard single regulator DVFS transition handler to handle scaling the ABB regulator in sequence with the normal supply and programing AVS voltages through a custom opp_helper that is registered. The ti-cpufreq driver is extended to allow registering the proper regulators needed for the CPU if the platform supports multi regulators and is also changed to a regular driver so that it can defer probe if needed as it now may have to if the regulators are not ready.
This series only contains driver changes and binding docs, DT patches will be sent later but I have pushed them all here for anyone curious [2].
This series is required to enable the highest 1.5GHz OPP on dra7/am57 platforms that support it but all dra7/am57 platforms will make use of this for all OPPs.
Regards,
Dave
[1] https://marc.info/?l=linux-pm&m=145684495832764&w=2
[2] https://github.com/dgerlach/linux-pm/tree/upstream/v4.15/ti-multireg-support
Dave Gerlach (4):
cpufreq: ti-cpufreq: Convert to module_platform_driver
cpufreq: ti-cpufreq: Add support for multiple regulators
dt-bindings: opp: Introduce ti-opp-supply bindings PM / OPP: Add ti-opp-supply driver
.../bindings/opp/ti-omap5-opp-supply.txt | 63 +++ drivers/cpufreq/ti-cpufreq.c | 51 ++- drivers/opp/Makefile | 1 + drivers/opp/ti-opp-supply.c | 428 +++++++++++++++++++++ 4 files changed, 537 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt create mode 100644 drivers/opp/ti-opp-supply.c
Signature · 1 line
2.15.1
PATCH 1/4 cpufreq: ti-cpufreq: Convert to module_platform_driver
ti-cpufreq will be responsible for calling dev_pm_opp_set_regulators on platforms that require AVS and ABB regulator support so we must be able to defer probe if regulators are not yet available, so change ti-cpufreq to be a module_platform_driver to allow for probe defer.
--- drivers/cpufreq/ti-cpufreq.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/cpufreq/ti-cpufreq.c +21 -2
@@ -17,6 +17,7 @@#include <linux/cpu.h> #include <linux/io.h> #include <linux/mfd/syscon.h> +#include <linux/module.h> #include <linux/init.h> #include <linux/of.h> #include <linux/of_platform.h>
@@ -195,7 +196,7 @@ static const struct of_device_id ti_cpufreq_of_match[] = { {}, }; -static int ti_cpufreq_init (void ) +static int ti_cpufreq_probe (struct platform_device *pdev) {u32 version[VERSION_COUNT ];struct device_node *np;
@@ -269,4 +270,22 @@ static int ti_cpufreq_init(void)return ret; } -device_initcall (ti_cpufreq_init); + +static int ti_cpufreq_init (void ) +{ +platform_device_register_simple ("ti-cpufreq" ,-1 ,NULL ,0 ); +return 0 ; +} +module_init (ti_cpufreq_init); + +static struct platform_driver ti_cpufreq_driver = { + .probe = ti_cpufreq_probe, + .driver = { + .name ="ti-cpufreq" , + }, +}; +module_platform_driver (ti_cpufreq_driver); + +MODULE_DESCRIPTION ("TI CPUFreq/OPP hw-supported driver" ); +MODULE_AUTHOR ("Dave Gerlach <[email protected]>" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.15.1
Viresh Kumar
maintainerPATCH 1/4 cpufreq: ti-cpufreq: Convert to module_platform_driver
Quoted 45 lines · Dave Gerlach
ti-cpufreq will be responsible for calling
dev_pm_opp_set_regulatorson platforms that require AVS and ABB regulator support so we must be able to defer probe if regulators are not yet available, so change ti-cpufreq to be amodule_platform_driverto allow for probe defer.Signed-off-by Dave Gerlach <[email protected]>--- drivers/cpufreq/ti-cpufreq.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)drivers/cpufreq/ti-cpufreq.c +11
-2@@ -17,6 +17,7 @@#include <linux/cpu.h> #include <linux/io.h> #include <linux/mfd/syscon.h> +#include <linux/module.h> #include <linux/init.h> #include <linux/of.h> #include <linux/of_platform.h> @@ -195,7 +196,7 @@ static const struct of_device_id ti_cpufreq_of_match[] = { {}, }; -static int ti_cpufreq_init (void ) +static int ti_cpufreq_probe (struct platform_device *pdev) {u32 version[VERSION_COUNT ];struct device_node *np;@@ -269,4 +270,22 @@ static int ti_cpufreq_init(void)return ret; } -device_initcall (ti_cpufreq_init); + +static int ti_cpufreq_init (void ) +{ +platform_device_register_simple ("ti-cpufreq" ,-1 ,NULL ,0 ); +return 0 ; +} +module_init (ti_cpufreq_init); + +static struct platform_driver ti_cpufreq_driver = {
drivers/cpufreq/ti-cpufreq.c static int ti_cpufreq_init(void) · line 291
Quoted 10 lines
drivers/cpufreq/ti-cpufreq.c +10
-0+ .probe = ti_cpufreq_probe, + .driver = { + .name = "ti-cpufreq", + }, +}; +module_platform_driver (ti_cpufreq_driver); + +MODULE_DESCRIPTION ("TI CPUFreq/OPP hw-supported driver" ); +MODULE_AUTHOR ("Dave Gerlach <[email protected]>" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
viresh
PATCH 2/4 cpufreq: ti-cpufreq: Add support for multiple regulators
In reply to Dave GerlachSome platforms, like those in the DRA7 and AM57 families, require the scaling of multiple regulators in order to properly support higher OPPs. Let the ti-cpufreq driver determine when this is required and pass the appropriate regulator names to the OPP core so that they can be properly managed.
--- drivers/cpufreq/ti-cpufreq.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/cpufreq/ti-cpufreq.c +24 -4
@@ -51,6 +51,7 @@ struct ti_cpufreq_soc_data {unsigned long efuse_mask;unsigned long efuse_shift;unsigned long rev_offset; +bool multi_regulator; };struct ti_cpufreq_data {
@@ -58,6 +59,7 @@ struct ti_cpufreq_data {struct device_node *opp_node;struct regmap *syscon;const struct ti_cpufreq_soc_data *soc_data; +struct opp_table *opp_table; }; static unsigned long amx3_efuse_xlate(struct ti_cpufreq_data *opp_data,
@@ -96,6 +98,7 @@ static struct ti_cpufreq_soc_data am3x_soc_data = { .efuse_offset = 0x07fc, .efuse_mask = 0x1fff, .rev_offset = 0x600, + .multi_regulator = false, };static struct ti_cpufreq_soc_data am4x_soc_data = {
@@ -104,6 +107,7 @@ static struct ti_cpufreq_soc_data am4x_soc_data = { .efuse_offset = 0x0610, .efuse_mask = 0x3f, .rev_offset = 0x600, + .multi_regulator = false, };static struct ti_cpufreq_soc_data dra7_soc_data = {
@@ -112,6 +116,7 @@ static struct ti_cpufreq_soc_data dra7_soc_data = { .efuse_mask = 0xf80000, .efuse_shift = 19, .rev_offset = 0x204, + .multi_regulator = true, };/**
@@ -201,7 +206,9 @@ static int ti_cpufreq_probe(struct platform_device *pdev)u32 version[VERSION_COUNT ];struct device_node *np;const struct of_device_id *match; +struct opp_table *ti_opp_table;struct ti_cpufreq_data *opp_data; +const char *const reg_names[] = {"vdd" ,"vbb" };int ret; np =of_find_node_by_path ("/" );
@@ -248,16 +255,29 @@ static int ti_cpufreq_probe(struct platform_device *pdev)if (ret) goto fail_put_node; - ret =PTR_ERR_OR_ZERO (dev_pm_opp_set_supported_hw (opp_data->cpu_dev, - version,VERSION_COUNT )); -if (ret) { + ti_opp_table =dev_pm_opp_set_supported_hw (opp_data->cpu_dev, + version,VERSION_COUNT ); +if (IS_ERR (ti_opp_table)) {dev_err (opp_data->cpu_dev,"Failed to set supported hardware\n" ); + ret =PTR_ERR (ti_opp_table); goto fail_put_node; } -of_node_put (opp_data->opp_node); + opp_data->opp_table = ti_opp_table; + +if (opp_data->soc_data->multi_regulator) { + ti_opp_table =dev_pm_opp_set_regulators (opp_data->cpu_dev, + reg_names, +ARRAY_SIZE (reg_names)); +if (IS_ERR (ti_opp_table)) { +dev_pm_opp_put_supported_hw (opp_data->opp_table); + ret =PTR_ERR (ti_opp_table); + goto fail_put_node; + } + } +of_node_put (opp_data->opp_node); register_cpufreq_dt:platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 );
Signature · 1 line
2.15.1
Viresh Kumar
maintainerPATCH 2/4 cpufreq: ti-cpufreq: Add support for multiple regulators
Quoted 88 lines · Dave Gerlach
Some platforms, like those in the DRA7 and AM57 families, require the scaling of multiple regulators in order to properly support higher OPPs. Let the ti-cpufreq driver determine when this is required and pass the appropriate regulator names to the OPP core so that they can be properly managed.
Signed-off-by Dave Gerlach <[email protected]>--- drivers/cpufreq/ti-cpufreq.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)drivers/cpufreq/ti-cpufreq.c +17
-4@@ -51,6 +51,7 @@ struct ti_cpufreq_soc_data {unsigned long efuse_mask;unsigned long efuse_shift;unsigned long rev_offset; +bool multi_regulator; };struct ti_cpufreq_data {@@ -58,6 +59,7 @@ struct ti_cpufreq_data {struct device_node *opp_node;struct regmap *syscon;const struct ti_cpufreq_soc_data *soc_data; +struct opp_table *opp_table; }; static unsigned long amx3_efuse_xlate(struct ti_cpufreq_data *opp_data,@@ -96,6 +98,7 @@ static struct ti_cpufreq_soc_data am3x_soc_data = { .efuse_offset = 0x07fc, .efuse_mask = 0x1fff, .rev_offset = 0x600, + .multi_regulator = false, };static struct ti_cpufreq_soc_data am4x_soc_data = {@@ -104,6 +107,7 @@ static struct ti_cpufreq_soc_data am4x_soc_data = { .efuse_offset = 0x0610, .efuse_mask = 0x3f, .rev_offset = 0x600, + .multi_regulator = false, };static struct ti_cpufreq_soc_data dra7_soc_data = {@@ -112,6 +116,7 @@ static struct ti_cpufreq_soc_data dra7_soc_data = { .efuse_mask = 0xf80000, .efuse_shift = 19, .rev_offset = 0x204, + .multi_regulator = true, };/** @@ -201,7 +206,9 @@ static int ti_cpufreq_probe(struct platform_device *pdev)u32 version[VERSION_COUNT ];struct device_node *np;const struct of_device_id *match; +struct opp_table *ti_opp_table;struct ti_cpufreq_data *opp_data; +const char *const reg_names[] = {"vdd" ,"vbb" };int ret; np =of_find_node_by_path ("/" );@@ -248,16 +255,29 @@ static int ti_cpufreq_probe(struct platform_device *pdev)if (ret) goto fail_put_node; - ret =PTR_ERR_OR_ZERO (dev_pm_opp_set_supported_hw (opp_data->cpu_dev, - version,VERSION_COUNT )); -if (ret) { + ti_opp_table =dev_pm_opp_set_supported_hw (opp_data->cpu_dev, + version,VERSION_COUNT ); +if (IS_ERR (ti_opp_table)) {dev_err (opp_data->cpu_dev,"Failed to set supported hardware\n" ); + ret =PTR_ERR (ti_opp_table); goto fail_put_node; } -of_node_put (opp_data->opp_node); + opp_data->opp_table = ti_opp_table; + +if (opp_data->soc_data->multi_regulator) { + ti_opp_table =dev_pm_opp_set_regulators (opp_data->cpu_dev, + reg_names, +ARRAY_SIZE (reg_names));
drivers/cpufreq/ti-cpufreq.c static int ti_cpufreq_probe(struct platform_device *pdev) · line 282
Quoted 10 lines
drivers/cpufreq/ti-cpufreq.c +7
-0+if (IS_ERR (ti_opp_table)) { +dev_pm_opp_put_supported_hw (opp_data->opp_table); + ret =PTR_ERR (ti_opp_table); + goto fail_put_node; + } + } +of_node_put (opp_data->opp_node); register_cpufreq_dt:platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 );
Signature · 1 line
viresh
PATCH 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings
In reply to Dave GerlachDocument the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.
--- .../bindings/opp/ti-omap5-opp-supply.txt | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt new file +63 -0
@@ -0,0 +1,63 @@ +Texas Instruments OMAP compatible OPP supply description + +OMAP5, DRA7, and AM57 family of SoCs have Class0 AVS eFuse registers which +contain data that can be used to adjust voltages programmed for some of their +supplies for more efficient operation. This binding provides the information +needed to read these values and use them to program the main regulator during +an OPP transitions. + +Also, some supplies may have an associated vbb-supply which is an Adaptive Body +Bias regulator which much be transitioned in a specific sequence with regards +to the vdd-supply and clk when making an OPP transition. By supplying two +regulators to the device that will undergo OPP transitions we can make use +of the multi regulator binding that is part of the OPP core described here [1] +to describe both regulators needed by the platform. + +[1] Documentation/devicetree/bindings/opp/opp.txt + +Required Properties for Device Node: +- vdd-supply: phandle to regulator controlling VDD supply +- vbb-supply: phandle to regulator controlling Body Bias supply + (Usually Adaptive Body Bias regulator) + +Required Properties for opp-supply node: +- compatible: Should be one of: + "ti,omap-opp-supply" - basic OPP supply controlling VDD and VBB + "ti,omap5-opp-supply" - OMAP5+ optimized voltages in efuse(class0)VDD + along with VBB + "ti,omap5-core-opp-supply" - OMAP5+ optimized voltages in efuse(class0) VDD + but no VBB. +- reg: Address and length of the efuse register set for the device (mandatory + only for "ti,omap5-opp-supply") +- ti,efuse-settings: An array of u32 tuple items providing information about + optimized efuse configuration. Each item consists of the following: + volt: voltage in uV - reference voltage (OPP voltage) + efuse_offseet: efuse offset from reg where the optimized voltage is stored. +- ti,absolute-max-voltage-uv: absolute maximum voltage for the OPP supply. + +Example: + +/* Device Node (CPU) */ +cpus { + cpu0: cpu at 0 { + device_type = "cpu"; + + ... + + vdd-supply = <&vcc>; + vbb-supply = <&abb_mpu>; + }; +}; + +/* OMAP OPP Supply with Class0 registers */ +opp_supply_mpu: opp_supply at 4a003b20 { + compatible = "ti,omap5-opp-supply"; + reg = <0x4a003b20 0x8>; + ti,efuse-settings = < + /* uV offset */ + 1060000 0x0 + 1160000 0x4 + 1210000 0x8 + >; + ti,absolute-max-voltage-uv = <1500000>; +};
Signature · 1 line
2.15.1
PATCH 4/4 PM / OPP: Add ti-opp-supply driver
In reply to Dave GerlachIntroduce a ti-opp-supply driver that will use new multiple regulator support that is part of the OPP core This is needed on TI platforms like DRA7/AM57 in order to control both CPU regulator and Adaptive Body Bias (ABB) regulator. These regulators must be scaled in sequence during an OPP transition depending on whether or not the frequency is being scaled up or down.
This driver also implements AVS Class0 for these parts by looking up the required values from registers in the SoC and programming adjusted optimal voltage values for each OPP.
--- drivers/opp/Makefile | 1 + drivers/opp/ti-opp-supply.c | 428 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 drivers/opp/ti-opp-supply.c
drivers/opp/Makefile +1 -0
@@ -2,3 +2,4 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG obj-y += core.o cpu.o obj-$(CONFIG_OF) += of.o obj-$(CONFIG_DEBUG_FS) += debugfs.o +obj-$(CONFIG_ARM_TI_CPUFREQ) += ti-opp-supply.o
drivers/opp/ti-opp-supply.c new file +428 -0
428 lines not on this page · raw message
Signature · 1 line
2.15.1
Viresh Kumar
maintainerPATCH 4/4 PM / OPP: Add ti-opp-supply driver
Quoted 7 lines · Dave Gerlach
Introduce a ti-opp-supply driver that will use new multiple regulator support that is part of the OPP core This is needed on TI platforms like DRA7/AM57 in order to control both CPU regulator and Adaptive Body Bias (ABB) regulator. These regulators must be scaled in sequence during an OPP transition depending on whether or not the frequency is being scaled up or down.
Quoted 8 lines
This driver also implements AVS Class0 for these parts by looking up the required values from registers in the SoC and programming adjusted optimal voltage values for each OPP.
Signed-off-by Dave Gerlach <[email protected]>--- drivers/opp/Makefile | 1 + drivers/opp/ti-opp-supply.c | 428 ++++++++++++++++++++++++++++++++++++++++++++
Why is this added as a separate driver and not part of the same ti-cpufreq.c file?
Quoted 18 lines
2 files changed, 429 insertions(+) create mode 100644 drivers/opp/ti-opp-supply.cdrivers/opp/Makefile +1
-0@@ -2,3 +2,4 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG obj-y += core.o cpu.o obj-$(CONFIG_OF) += of.o obj-$(CONFIG_DEBUG_FS) += debugfs.o +obj-$(CONFIG_ARM_TI_CPUFREQ) += ti-opp-supply.odrivers/opp/ti-opp-supply.c new file +0
-0
drivers/opp/ti-opp-supply.c line 8
Quoted 8 lines
drivers/opp/ti-opp-supply.c new file +8
-0@@ -0,0 +1,428 @@ +/* +* Copyright (C) 2016-2017 Texas Instruments Incorporated - http://www.ti.com/ +* Nishanth Menon <[email protected]> +* Dave Gerlach <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation.
Please use the new SPDX format for licenses.
Quoted 409 lines
drivers/opp/ti-opp-supply.c new file +409
-0+* 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/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 { +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 +*/ +struct ti_opp_supply_data { +struct ti_opp_supply_optimum_voltage_table *vdd_table; +u32 num_vdd_table; +u32 vdd_absolute_max_voltage_uv; +}; + +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_nocache (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; + } + + ret =of_property_read_u32 (dev->of_node,"ti,absolute-max-voltage-uv" , + &data->vdd_absolute_max_voltage_uv); +if (ret) { +dev_err (dev,"ti,absolute-max-voltage-uv is missing\n" ); + ret = -EINVAL ; + goto out; + } + + table =kzalloc (sizeof (*data->vdd_table) * + data->num_vdd_table,GFP_KERNEL ); +if (!table) { + ret = -ENOMEM ; + goto out; + } + data->vdd_table = table; + + val = prop->value; +for (i =0 ; i < data->num_vdd_table; i++, table++) { +u32 efuse_offset; +u32 tmp; + + table->reference_uv =be32_to_cpup (val++); + efuse_offset =be32_to_cpup (val++); + + tmp =readl (base + efuse_offset); + tmp &= of_data->efuse_voltage_mask; + tmp >>=__ffs (of_data->efuse_voltage_mask); + + table->optimized_uv = of_data->efuse_voltage_uv ? tmp : + tmp *1000 ; + +dev_dbg (dev,"[%d] efuse=0x%08x volt_table=%d vset=%d\n" , + i, efuse_offset, table->reference_uv, + table->optimized_uv); + +/* +* Some older samples might not have optimized efuse +* Use reference voltage for those - just add debug message +* for them. +*/ +if (!table->optimized_uv) { +dev_dbg (dev,"[%d] efuse=0x%08x volt_table=%d:vset0\n" , + i, efuse_offset, table->reference_uv); + table->optimized_uv = table->reference_uv; + } + } +out: +iounmap (base); +out_map: +return ret; +} + +/** +* _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) +{ +kfree (data->vdd_table); + data->vdd_table =NULL ; + data->num_vdd_table =0 ; +} + +/** +* _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) +{ +int i; +struct ti_opp_supply_optimum_voltage_table *table; + +if (!data->num_vdd_table) +return reference_uv; + + table = data->vdd_table; +if (!table) +return -EINVAL ; + +/* Find a exact match - this list is usually very small */ +for (i =0 ; i < data->num_vdd_table; i++, table++) +if (table->reference_uv == reference_uv) +return table->optimized_uv; + +/* IF things are screwed up, we'd make a mess on console.. ratelimit */ +dev_err_ratelimited (dev,"%s: Failed optimized voltage match for %d\n" , + __func__, reference_uv); +return 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) +{ +int ret; +unsigned long vdd_uv, uv_max; + +if (new_target_uv) + vdd_uv = new_target_uv; +else + vdd_uv = supply->u_volt; + +/* +* If we do have an absolute max voltage specified, then we should +* use that voltage instead to allow for cases where the voltage rails +* are ganged (example if we set the max for an opp as 1.12v, and +* the absolute max is 1.5v, for another rail to get 1.25v, it cannot +* be achieved if the regulator is constrainted to max of 1.12v, even +* if it can function at 1.25v +*/ +if (opp_data.vdd_absolute_max_voltage_uv) + uv_max = opp_data.vdd_absolute_max_voltage_uv; +else + uv_max = supply->u_volt_max; + +if (vdd_uv > uv_max || + vdd_uv < supply->u_volt_min || + supply->u_volt_min > uv_max) { +dev_warn (dev, +"Invalid range voltages [Min:%lu target:%lu Max:%lu]\n" , + supply->u_volt_min, vdd_uv, uv_max); +return -EINVAL ; + } + +dev_dbg (dev,"%s scaling to %luuV[min %luuV max %luuV]\n" , reg_name, + vdd_uv, supply->u_volt_min, + uv_max); + + ret =regulator_set_voltage_triplet (reg, + supply->u_volt_min, + vdd_uv, + uv_max); +if (ret) { +dev_err (dev,"%s failed for %luuV[min %luuV max %luuV]\n" , + reg_name, vdd_uv, supply->u_volt_min, + uv_max); +return ret; + } + +return 0 ; +} + +/** +* ti_opp_supply_set_opp() - do the opp supply transition +* @data: information on regulators and new and old opps provided by +* opp core to use in transition +* +* Return: If successful, 0, else appropriate error value. +*/ +int ti_opp_supply_set_opp (struct dev_pm_set_opp_data *data) +{ +struct dev_pm_opp_supply *old_supply_vdd = &data->old_opp.supplies[0 ]; +struct dev_pm_opp_supply *old_supply_vbb = &data->old_opp.supplies[1 ]; +struct dev_pm_opp_supply *new_supply_vdd = &data->new_opp.supplies[0 ]; +struct dev_pm_opp_supply *new_supply_vbb = &data->new_opp.supplies[1 ]; +struct device *dev = data->dev; +unsigned long old_freq = data->old_opp.rate, freq = data->new_opp.rate; +struct clk *clk = data->clk; +struct regulator *vdd_reg = data->regulators[0 ]; +struct regulator *vbb_reg = data->regulators[1 ]; +int vdd_uv; +int ret; + + vdd_uv =_get_optimal_vdd_voltage (dev, &opp_data, + new_supply_vbb->u_volt); + +/* Scaling up? Scale voltage before frequency */ +if (freq > old_freq) { + ret =_opp_set_voltage (dev, new_supply_vdd, vdd_uv, vdd_reg, +"vdd" ); +if (ret) + goto restore_voltage; + + ret =_opp_set_voltage (dev, new_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) + goto restore_voltage; + } + +/* Change frequency */ +dev_dbg (dev,"%s: switching OPP: %lu Hz --> %lu Hz\n" , + __func__, old_freq, freq); + + ret =clk_set_rate (clk, freq); +if (ret) { +dev_err (dev,"%s: failed to set clock rate: %d\n" , __func__, + ret); + goto restore_voltage; + } + +/* Scaling down? Scale voltage after frequency */ +if (freq < old_freq) { + ret =_opp_set_voltage (dev, new_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) + goto restore_freq; + + ret =_opp_set_voltage (dev, new_supply_vdd, vdd_uv, vdd_reg, +"vdd" ); +if (ret) + goto restore_freq; + } + +return 0 ; + +restore_freq: + ret =clk_set_rate (clk, old_freq); +if (ret) +dev_err (dev,"%s: failed to restore old-freq (%lu Hz)\n" , + __func__, old_freq); +restore_voltage: +/* This shouldn't harm even if the voltages weren't updated earlier */ +if (old_supply_vdd->u_volt) { + ret =_opp_set_voltage (dev, old_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) +return ret; + + ret =_opp_set_voltage (dev, old_supply_vdd,0 , vdd_reg, +"vdd" ); +if (ret) +return ret; + } + +return ret; +} + +static const struct ti_opp_supply_of_data omap_generic_of_data = { +}; + +static const struct ti_opp_supply_of_data omap_omap5_of_data = { + .flags =OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE , + .efuse_voltage_mask =0xFFF , + .efuse_voltage_uv = false, +}; + +static const struct ti_opp_supply_of_data omap_omap5core_of_data = { + .flags =OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE |OPPDM_HAS_NO_ABB , + .efuse_voltage_mask =0xFFF , + .efuse_voltage_uv = false, +}; + +static const struct of_device_id ti_opp_supply_of_match[] = { + {.compatible ="ti,omap-opp-supply" , .data = &omap_generic_of_data}, + {.compatible ="ti,omap5-opp-supply" , .data = &omap_omap5_of_data}, + {.compatible ="ti,omap5-core-opp-supply" , + .data = &omap_omap5core_of_data}, + {}, +}; +MODULE_DEVICE_TABLE (of, ti_opp_supply_of_match); + +static int ti_opp_supply_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device *cpu_dev =get_cpu_device (0 ); +const struct of_device_id *match; +const struct ti_opp_supply_of_data *of_data; +int ret =0 ; + + match =of_match_device (ti_opp_supply_of_match, dev); +if (!match) { +/* We do not expect this to happen */ +dev_err (dev,"%s: Unable to match device\n" , __func__); +return -ENODEV ; + } +if (!match->data) { +/* Again, unlikely.. but mistakes do happen */ +dev_err (dev,"%s: Bad data in match\n" , __func__); +return -EINVAL ; + } + of_data = match->data; + +dev_set_drvdata (dev, (void *)of_data); + +/* If we need optimized voltage */ +if (of_data->flags &OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE ) { + ret =_store_optimized_voltages (dev, &opp_data); +if (ret) +return ret; + } + + ret =PTR_ERR_OR_ZERO (dev_pm_opp_register_set_opp_helper (cpu_dev, + ti_opp_supply_set_opp)); +if (ret) +_free_optimized_voltages (dev, &opp_data); + +return ret; +} + +static struct platform_driver ti_opp_supply_driver = { + .probe = ti_opp_supply_probe, + .driver = {
drivers/opp/ti-opp-supply.c line 428
Quoted 10 lines
drivers/opp/ti-opp-supply.c new file +10
-0+ .name = "ti_opp_supply", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(ti_opp_supply_of_match), + }, +}; +module_platform_driver (ti_opp_supply_driver); + +MODULE_DESCRIPTION ("Texas Instruments OMAP OPP Supply driver" ); +MODULE_AUTHOR ("Texas Instruments Inc." ); +MODULE_LICENSE ("GPL v2" );
Looks fine otherwise.
Signature · 1 line
viresh
PATCH 4/4 PM / OPP: Add ti-opp-supply driver
Hi,
Quoted 12 lines · Viresh Kumar
Quoted 11 lines · Dave Gerlach
Introduce a ti-opp-supply driver that will use new multiple regulator support that is part of the OPP core This is needed on TI platforms like DRA7/AM57 in order to control both CPU regulator and Adaptive Body Bias (ABB) regulator. These regulators must be scaled in sequence during an OPP transition depending on whether or not the frequency is being scaled up or down.
This driver also implements AVS Class0 for these parts by looking up the required values from registers in the SoC and programming adjusted optimal voltage values for each OPP.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Dave Gerlach <[email protected]>--- drivers/opp/Makefile | 1 + drivers/opp/ti-opp-supply.c | 428 ++++++++++++++++++++++++++++++++++++++++++++Why is this added as a separate driver and not part of the same
ti-cpufreq.cfile?
Although we are only currently using this for cpufreq, in the future it can be used for the other voltage domains that are unrelated to the CPU that support AVS Class0. Table 5-7 in http://www.ti.com/lit/ds/symlink/am5728.pdf shows the support for each voltage domain.
Quoted 20 lines
Quoted 20 lines
2 files changed, 429 insertions(+) create mode 100644 drivers/opp/ti-opp-supply.cdrivers/opp/Makefile +1
-0@@ -2,3 +2,4 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG obj-y += core.o cpu.o obj-$(CONFIG_OF) += of.o obj-$(CONFIG_DEBUG_FS) += debugfs.o +obj-$(CONFIG_ARM_TI_CPUFREQ) += ti-opp-supply.odrivers/opp/ti-opp-supply.c new file +2
-0@@ -0,0 +1,428 @@ +/* +* Copyright (C) 2016-2017 Texas Instruments Incorporated - http://www.ti.com/
Quoted 8 lines
drivers/opp/ti-opp-supply.c line 8
Quoted 6 lines
drivers/opp/ti-opp-supply.c new file +6
-0+* Nishanth Menon <[email protected]> +* Dave Gerlach <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. Please use the new SPDX format for licenses.
Ah ok, will do.
Quoted 414 lines
Quoted 414 lines
drivers/opp/ti-opp-supply.c new file +413
-0+* 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/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 { +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 +*/ +struct ti_opp_supply_data { +struct ti_opp_supply_optimum_voltage_table *vdd_table; +u32 num_vdd_table; +u32 vdd_absolute_max_voltage_uv; +}; + +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_nocache (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; + } + + ret =of_property_read_u32 (dev->of_node,"ti,absolute-max-voltage-uv" , + &data->vdd_absolute_max_voltage_uv); +if (ret) { +dev_err (dev,"ti,absolute-max-voltage-uv is missing\n" ); + ret = -EINVAL ; + goto out; + } + + table =kzalloc (sizeof (*data->vdd_table) * + data->num_vdd_table,GFP_KERNEL ); +if (!table) { + ret = -ENOMEM ; + goto out; + } + data->vdd_table = table; + + val = prop->value; +for (i =0 ; i < data->num_vdd_table; i++, table++) { +u32 efuse_offset; +u32 tmp; + + table->reference_uv =be32_to_cpup (val++); + efuse_offset =be32_to_cpup (val++); + + tmp =readl (base + efuse_offset); + tmp &= of_data->efuse_voltage_mask; + tmp >>=__ffs (of_data->efuse_voltage_mask); + + table->optimized_uv = of_data->efuse_voltage_uv ? tmp : + tmp *1000 ; + +dev_dbg (dev,"[%d] efuse=0x%08x volt_table=%d vset=%d\n" , + i, efuse_offset, table->reference_uv, + table->optimized_uv); + +/* +* Some older samples might not have optimized efuse +* Use reference voltage for those - just add debug message +* for them. +*/ +if (!table->optimized_uv) { +dev_dbg (dev,"[%d] efuse=0x%08x volt_table=%d:vset0\n" , + i, efuse_offset, table->reference_uv); + table->optimized_uv = table->reference_uv; + } + } +out: +iounmap (base); +out_map: +return ret; +} + +/** +* _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) +{ +kfree (data->vdd_table); + data->vdd_table =NULL ; + data->num_vdd_table =0 ; +} + +/** +* _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) +{ +int i; +struct ti_opp_supply_optimum_voltage_table *table; + +if (!data->num_vdd_table) +return reference_uv; + + table = data->vdd_table; +if (!table) +return -EINVAL ; + +/* Find a exact match - this list is usually very small */ +for (i =0 ; i < data->num_vdd_table; i++, table++) +if (table->reference_uv == reference_uv) +return table->optimized_uv; + +/* IF things are screwed up, we'd make a mess on console.. ratelimit */ +dev_err_ratelimited (dev,"%s: Failed optimized voltage match for %d\n" , + __func__, reference_uv); +return 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) +{ +int ret; +unsigned long vdd_uv, uv_max; + +if (new_target_uv) + vdd_uv = new_target_uv; +else + vdd_uv = supply->u_volt; + +/* +* If we do have an absolute max voltage specified, then we should +* use that voltage instead to allow for cases where the voltage rails +* are ganged (example if we set the max for an opp as 1.12v, and +* the absolute max is 1.5v, for another rail to get 1.25v, it cannot +* be achieved if the regulator is constrainted to max of 1.12v, even +* if it can function at 1.25v +*/ +if (opp_data.vdd_absolute_max_voltage_uv) + uv_max = opp_data.vdd_absolute_max_voltage_uv; +else + uv_max = supply->u_volt_max; + +if (vdd_uv > uv_max || + vdd_uv < supply->u_volt_min || + supply->u_volt_min > uv_max) { +dev_warn (dev, +"Invalid range voltages [Min:%lu target:%lu Max:%lu]\n" , + supply->u_volt_min, vdd_uv, uv_max); +return -EINVAL ; + } + +dev_dbg (dev,"%s scaling to %luuV[min %luuV max %luuV]\n" , reg_name, + vdd_uv, supply->u_volt_min, + uv_max); + + ret =regulator_set_voltage_triplet (reg, + supply->u_volt_min, + vdd_uv, + uv_max); +if (ret) { +dev_err (dev,"%s failed for %luuV[min %luuV max %luuV]\n" , + reg_name, vdd_uv, supply->u_volt_min, + uv_max); +return ret; + } + +return 0 ; +} + +/** +* ti_opp_supply_set_opp() - do the opp supply transition +* @data: information on regulators and new and old opps provided by +* opp core to use in transition +* +* Return: If successful, 0, else appropriate error value. +*/ +int ti_opp_supply_set_opp (struct dev_pm_set_opp_data *data) +{ +struct dev_pm_opp_supply *old_supply_vdd = &data->old_opp.supplies[0 ]; +struct dev_pm_opp_supply *old_supply_vbb = &data->old_opp.supplies[1 ]; +struct dev_pm_opp_supply *new_supply_vdd = &data->new_opp.supplies[0 ]; +struct dev_pm_opp_supply *new_supply_vbb = &data->new_opp.supplies[1 ]; +struct device *dev = data->dev; +unsigned long old_freq = data->old_opp.rate, freq = data->new_opp.rate; +struct clk *clk = data->clk; +struct regulator *vdd_reg = data->regulators[0 ]; +struct regulator *vbb_reg = data->regulators[1 ]; +int vdd_uv; +int ret; + + vdd_uv =_get_optimal_vdd_voltage (dev, &opp_data, + new_supply_vbb->u_volt); + +/* Scaling up? Scale voltage before frequency */ +if (freq > old_freq) { + ret =_opp_set_voltage (dev, new_supply_vdd, vdd_uv, vdd_reg, +"vdd" ); +if (ret) + goto restore_voltage; + + ret =_opp_set_voltage (dev, new_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) + goto restore_voltage; + } + +/* Change frequency */ +dev_dbg (dev,"%s: switching OPP: %lu Hz --> %lu Hz\n" , + __func__, old_freq, freq); + + ret =clk_set_rate (clk, freq); +if (ret) { +dev_err (dev,"%s: failed to set clock rate: %d\n" , __func__, + ret); + goto restore_voltage; + } + +/* Scaling down? Scale voltage after frequency */ +if (freq < old_freq) { + ret =_opp_set_voltage (dev, new_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) + goto restore_freq; + + ret =_opp_set_voltage (dev, new_supply_vdd, vdd_uv, vdd_reg, +"vdd" ); +if (ret) + goto restore_freq; + } + +return 0 ; + +restore_freq: + ret =clk_set_rate (clk, old_freq); +if (ret) +dev_err (dev,"%s: failed to restore old-freq (%lu Hz)\n" , + __func__, old_freq); +restore_voltage: +/* This shouldn't harm even if the voltages weren't updated earlier */ +if (old_supply_vdd->u_volt) { + ret =_opp_set_voltage (dev, old_supply_vbb,0 , vbb_reg,"vbb" ); +if (ret) +return ret; + + ret =_opp_set_voltage (dev, old_supply_vdd,0 , vdd_reg, +"vdd" ); +if (ret) +return ret; + } + +return ret; +} + +static const struct ti_opp_supply_of_data omap_generic_of_data = { +}; + +static const struct ti_opp_supply_of_data omap_omap5_of_data = { + .flags =OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE , + .efuse_voltage_mask =0xFFF , + .efuse_voltage_uv = false, +}; + +static const struct ti_opp_supply_of_data omap_omap5core_of_data = { + .flags =OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE |OPPDM_HAS_NO_ABB , + .efuse_voltage_mask =0xFFF , + .efuse_voltage_uv = false, +}; + +static const struct of_device_id ti_opp_supply_of_match[] = { + {.compatible ="ti,omap-opp-supply" , .data = &omap_generic_of_data}, + {.compatible ="ti,omap5-opp-supply" , .data = &omap_omap5_of_data}, + {.compatible ="ti,omap5-core-opp-supply" , + .data = &omap_omap5core_of_data}, + {}, +}; +MODULE_DEVICE_TABLE (of, ti_opp_supply_of_match); + +static int ti_opp_supply_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device *cpu_dev =get_cpu_device (0 ); +const struct of_device_id *match; +const struct ti_opp_supply_of_data *of_data; +int ret =0 ; + + match =of_match_device (ti_opp_supply_of_match, dev); +if (!match) { +/* We do not expect this to happen */ +dev_err (dev,"%s: Unable to match device\n" , __func__); +return -ENODEV ; + } +if (!match->data) { +/* Again, unlikely.. but mistakes do happen */ +dev_err (dev,"%s: Bad data in match\n" , __func__); +return -EINVAL ; + } + of_data = match->data; + +dev_set_drvdata (dev, (void *)of_data); + +/* If we need optimized voltage */ +if (of_data->flags &OPPDM_EFUSE_CLASS0_OPTIMIZED_VOLTAGE ) { + ret =_store_optimized_voltages (dev, &opp_data); +if (ret) +return ret; + } + + ret =PTR_ERR_OR_ZERO (dev_pm_opp_register_set_opp_helper (cpu_dev, + ti_opp_supply_set_opp)); +if (ret) +_free_optimized_voltages (dev, &opp_data); + +return ret; +} + +static struct platform_driver ti_opp_supply_driver = { + .probe = ti_opp_supply_probe, + .driver = { + .name ="ti_opp_supply" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (ti_opp_supply_of_match), + },
Quoted 9 lines
drivers/opp/ti-opp-supply.c line 428
Quoted 6 lines
drivers/opp/ti-opp-supply.c new file +6
-0+}; +module_platform_driver (ti_opp_supply_driver); + +MODULE_DESCRIPTION ("Texas Instruments OMAP OPP Supply driver" ); +MODULE_AUTHOR ("Texas Instruments Inc." ); +MODULE_LICENSE ("GPL v2" );Looks fine otherwise.
Thanks, appreciate the review, will resend with fixed license.
Regards,
Dave