diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 10:34:56 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 10:34:56 -0700 |
commit | d15d76448bb58c7832e954b6a8f1e301720b7866 (patch) | |
tree | 7891c9e0779f5df33840be9cdba1f0331459e97c /drivers/regulator | |
parent | 0c2fe82a9b106f1c03719783134360586d718a69 (diff) | |
parent | 4992fa1fd425f1934f503ffa96b68e235b89db9a (diff) |
Merge tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates for 3.4 from Mark Brown:
"This has been a fairly quiet release from a regulator point of view,
the only real framework features added were devm support and a
convenience helper for setting up fixed voltage regulators.
We also added a couple of drivers (but will drop the BQ240022 driver
via the arm-soc tree as it's been replaced by the more generic
gpio-regulator driver) and Axel Lin continued his relentless and
generally awesome stream of fixes and cleanups."
* tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (93 commits)
regulator: Fix up a confusing dev_warn when DT lookup fails
regulator: Convert tps6507x to set_voltage_sel
regulator: Refactor tps6507x to use one tps6507x_pmic_ops for all LDOs and DCDCs
regulator: Make s5m8767_get_voltage_register always return correct register
regulator: s5m8767: Check pdata->buck[2|3|4]_gpiodvs earlier
regulator: tps65910: Provide settling time for DCDC voltage change
regulator: Add Anatop regulator driver
regulator: Simplify implementation of tps65912_get_voltage_dcdc
regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx
regulator: tps65910: Provide settling time for enabling rails
regulator: max8925: Use DIV_ROUND_UP macro
regulator: tps65912: Use simple equations to get register address
regulator: Fix the logic of tps65910_get_mode
regulator: Merge tps65217_pmic_ldo234_ops and tps65217_pmic_dcdc_ops to tps65217_pmic_ops
regulator: Use DIV_ROUND_CLOSEST in wm8350_isink_get_current
regulator: Use array to store dcdc_range settings for tps65912
regulator: Rename s5m8767_convert_voltage to s5m8767_convert_voltage_to_sel
regulator: tps6524x: Remove unneeded comment for N_REGULATORS
regulator: Rename set_voltage_sel callback function name to *_sel
regulator: Fix s5m8767_set_voltage_time_sel calculation value
...
Diffstat (limited to 'drivers/regulator')
35 files changed, 3412 insertions, 1033 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 7a61b17ddd0..a229de98ae6 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -74,13 +74,72 @@ config REGULATOR_GPIO and the platform has to provide a mapping of GPIO-states to target volts/amps. -config REGULATOR_BQ24022 - tristate "TI bq24022 Dual Input 1-Cell Li-Ion Charger IC" +config REGULATOR_AD5398 + tristate "Analog Devices AD5398/AD5821 regulators" + depends on I2C help - This driver controls a TI bq24022 Charger attached via - GPIOs. The provided current regulator can enable/disable - charging select between 100 mA and 500 mA charging current - limit. + This driver supports AD5398 and AD5821 current regulator chips. + If building into module, its name is ad5398.ko. + +config REGULATOR_AAT2870 + tristate "AnalogicTech AAT2870 Regulators" + depends on MFD_AAT2870_CORE + help + If you have a AnalogicTech AAT2870 say Y to enable the + regulator driver. + +config REGULATOR_DA903X + tristate "Dialog Semiconductor DA9030/DA9034 regulators" + depends on PMIC_DA903X + help + Say y here to support the BUCKs and LDOs regulators found on + Dialog Semiconductor DA9030/DA9034 PMIC. + +config REGULATOR_DA9052 + tristate "Dialog Semiconductor DA9052/DA9053 regulators" + depends on PMIC_DA9052 + help + This driver supports the voltage regulators of DA9052-BC and + DA9053-AA/Bx PMIC. + +config REGULATOR_ANATOP + tristate "Freescale i.MX on-chip ANATOP LDO regulators" + depends on MFD_ANATOP + help + Say y here to support Freescale i.MX on-chip ANATOP LDOs + regulators. It is recommended that this option be + enabled on i.MX6 platform. + +config REGULATOR_MC13XXX_CORE + tristate + +config REGULATOR_MC13783 + tristate "Freescale MC13783 regulator driver" + depends on MFD_MC13783 + select REGULATOR_MC13XXX_CORE + help + Say y here to support the regulators found on the Freescale MC13783 + PMIC. + +config REGULATOR_MC13892 + tristate "Freescale MC13892 regulator driver" + depends on MFD_MC13XXX + select REGULATOR_MC13XXX_CORE + help + Say y here to support the regulators found on the Freescale MC13892 + PMIC. + +config REGULATOR_ISL6271A + tristate "Intersil ISL6271A Power regulator" + depends on I2C + help + This driver supports ISL6271A voltage regulator chip. + +config REGULATOR_88PM8607 + bool "Marvell 88PM8607 Power regulators" + depends on MFD_88PM860X=y + help + This driver supports 88PM8607 voltage regulator chips. config REGULATOR_MAX1586 tristate "Maxim 1586/1587 voltage regulator" @@ -136,61 +195,12 @@ config REGULATOR_MAX8998 via I2C bus. The provided regulator is suitable for S3C6410 and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. -config REGULATOR_TWL4030 - bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" - depends on TWL4030_CORE - help - This driver supports the voltage regulators provided by - this family of companion chips. - -config REGULATOR_WM831X - tristate "Wolfson Microelcronics WM831x PMIC regulators" - depends on MFD_WM831X - help - Support the voltage and current regulators of the WM831x series - of PMIC devices. - -config REGULATOR_WM8350 - tristate "Wolfson Microelectronics WM8350 AudioPlus PMIC" - depends on MFD_WM8350 - help - This driver provides support for the voltage and current regulators - of the WM8350 AudioPlus PMIC. - -config REGULATOR_WM8400 - tristate "Wolfson Microelectronics WM8400 AudioPlus PMIC" - depends on MFD_WM8400 - help - This driver provides support for the voltage regulators of the - WM8400 AudioPlus PMIC. - -config REGULATOR_WM8994 - tristate "Wolfson Microelectronics WM8994 CODEC" - depends on MFD_WM8994 - help - This driver provides support for the voltage regulators on the - WM8994 CODEC. - -config REGULATOR_DA903X - tristate "Support regulators on Dialog Semiconductor DA9030/DA9034 PMIC" - depends on PMIC_DA903X - help - Say y here to support the BUCKs and LDOs regulators found on - Dialog Semiconductor DA9030/DA9034 PMIC. - -config REGULATOR_DA9052 - tristate "Dialog DA9052/DA9053 regulators" - depends on PMIC_DA9052 - help - This driver supports the voltage regulators of DA9052-BC and - DA9053-AA/Bx PMIC. - -config REGULATOR_PCF50633 - tristate "PCF50633 regulator driver" - depends on MFD_PCF50633 +config REGULATOR_PCAP + tristate "Motorola PCAP2 regulator driver" + depends on EZX_PCAP help - Say Y here to support the voltage regulators and convertors - on PCF50633 + This driver provides support for the voltage regulators of the + PCAP2 PMIC. config REGULATOR_LP3971 tristate "National Semiconductors LP3971 PMIC regulator driver" @@ -206,31 +216,20 @@ config REGULATOR_LP3972 Say Y here to support the voltage regulators and convertors on National Semiconductors LP3972 PMIC -config REGULATOR_PCAP - tristate "PCAP2 regulator driver" - depends on EZX_PCAP - help - This driver provides support for the voltage regulators of the - PCAP2 PMIC. - -config REGULATOR_MC13XXX_CORE - tristate - -config REGULATOR_MC13783 - tristate "Support regulators on Freescale MC13783 PMIC" - depends on MFD_MC13783 - select REGULATOR_MC13XXX_CORE +config REGULATOR_PCF50633 + tristate "NXP PCF50633 regulator driver" + depends on MFD_PCF50633 help - Say y here to support the regulators found on the Freescale MC13783 - PMIC. + Say Y here to support the voltage regulators and convertors + on PCF50633 -config REGULATOR_MC13892 - tristate "Support regulators on Freescale MC13892 PMIC" - depends on MFD_MC13XXX - select REGULATOR_MC13XXX_CORE +config REGULATOR_S5M8767 + tristate "Samsung S5M8767A voltage regulator" + depends on MFD_S5M_CORE help - Say y here to support the regulators found on the Freescale MC13892 - PMIC. + This driver supports a Samsung S5M8767A voltage output regulator + via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and + supports DVS mode with 8bits of output voltage control. config REGULATOR_AB3100 tristate "ST-Ericsson AB3100 Regulator functions" @@ -241,6 +240,32 @@ config REGULATOR_AB3100 AB3100 analog baseband dealing with power regulators for the system. +config REGULATOR_AB8500 + bool "ST-Ericsson AB8500 Power Regulators" + depends on AB8500_CORE + help + This driver supports the regulators found on the ST-Ericsson mixed + signal AB8500 PMIC + +config REGULATOR_DBX500_PRCMU + bool + +config REGULATOR_DB8500_PRCMU + bool "ST-Ericsson DB8500 Voltage Domain Regulators" + depends on MFD_DB8500_PRCMU + select REGULATOR_DBX500_PRCMU + help + This driver supports the voltage domain regulators controlled by the + DB8500 PRCMU + +config REGULATOR_BQ24022 + tristate "TI bq24022 Dual Input 1-Cell Li-Ion Charger IC" + help + This driver controls a TI bq24022 Charger attached via + GPIOs. The provided current regulator can enable/disable + charging select between 100 mA and 500 mA charging current + limit. + config REGULATOR_TPS6105X tristate "TI TPS6105X Power regulators" depends on TPS6105X @@ -250,6 +275,16 @@ config REGULATOR_TPS6105X It is a single boost converter primarily for white LEDs and audio amplifiers. +config REGULATOR_TPS62360 + tristate "TI TPS62360 Power Regulator" + depends on I2C + select REGMAP_I2C + help + This driver supports TPS62360 voltage regulator chip. This + regulator is meant for processor core supply. This chip is + high-frequency synchronous step down dc-dc converter optimized + for battery-powered portable applications. + config REGULATOR_TPS65023 tristate "TI TPS65023 Power regulators" depends on I2C @@ -267,73 +302,77 @@ config REGULATOR_TPS6507X three step-down converters and two general-purpose LDO voltage regulators. It supports TI's software based Class-2 SmartReflex implementation. -config REGULATOR_TPS65912 - tristate "TI TPS65912 Power regulator" - depends on (MFD_TPS65912_I2C || MFD_TPS65912_SPI) +config REGULATOR_TPS65217 + tristate "TI TPS65217 Power regulators" + depends on MFD_TPS65217 help - This driver supports TPS65912 voltage regulator chip. + This driver supports TPS65217 voltage regulator chips. TPS65217 + provides three step-down converters and four general-purpose LDO + voltage regulators. It supports software based voltage control + for different voltage domains -config REGULATOR_88PM8607 - bool "Marvell 88PM8607 Power regulators" - depends on MFD_88PM860X=y +config REGULATOR_TPS6524X + tristate "TI TPS6524X Power regulators" + depends on SPI help - This driver supports 88PM8607 voltage regulator chips. + This driver supports TPS6524X voltage regulator chips. TPS6524X + provides three step-down converters and two general-purpose LDO + voltage regulators. This device is interfaced using a customized + serial interface currently supported on the sequencer serial + port controller. -config REGULATOR_ISL6271A - tristate "Intersil ISL6271A Power regulator" - depends on I2C +config REGULATOR_TPS6586X + tristate "TI TPS6586X Power regulators" + depends on MFD_TPS6586X help - This driver supports ISL6271A voltage regulator chip. + This driver supports TPS6586X voltage regulator chips. -config REGULATOR_AD5398 - tristate "Analog Devices AD5398/AD5821 regulators" - depends on I2C +config REGULATOR_TPS65910 + tristate "TI TPS65910/TPS65911 Power Regulators" + depends on MFD_TPS65910 help - This driver supports AD5398 and AD5821 current regulator chips. - If building into module, its name is ad5398.ko. + This driver supports TPS65910/TPS65911 voltage regulator chips. -config REGULATOR_AB8500 - bool "ST-Ericsson AB8500 Power Regulators" - depends on AB8500_CORE +config REGULATOR_TPS65912 + tristate "TI TPS65912 Power regulator" + depends on (MFD_TPS65912_I2C || MFD_TPS65912_SPI) help - This driver supports the regulators found on the ST-Ericsson mixed - signal AB8500 PMIC + This driver supports TPS65912 voltage regulator chip. -config REGULATOR_DB8500_PRCMU - bool "ST-Ericsson DB8500 Voltage Domain Regulators" - depends on MFD_DB8500_PRCMU +config REGULATOR_TWL4030 + bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" + depends on TWL4030_CORE help - This driver supports the voltage domain regulators controlled by the - DB8500 PRCMU + This driver supports the voltage regulators provided by + this family of companion chips. -config REGULATOR_TPS6586X - tristate "TI TPS6586X Power regulators" - depends on MFD_TPS6586X +config REGULATOR_WM831X + tristate "Wolfson Microelectronics WM831x PMIC regulators" + depends on MFD_WM831X help - This driver supports TPS6586X voltage regulator chips. + Support the voltage and current regulators of the WM831x series + of PMIC devices. -config REGULATOR_TPS6524X - tristate "TI TPS6524X Power regulators" - depends on SPI +config REGULATOR_WM8350 + tristate "Wolfson Microelectronics WM8350 AudioPlus PMIC" + depends on MFD_WM8350 help - This driver supports TPS6524X voltage regulator chips. TPS6524X - provides three step-down converters and two general-purpose LDO - voltage regulators. This device is interfaced using a customized - serial interface currently supported on the sequencer serial - port controller. + This driver provides support for the voltage and current regulators + of the WM8350 AudioPlus PMIC. -config REGULATOR_TPS65910 - tristate "TI TPS65910 Power Regulator" - depends on MFD_TPS65910 +config REGULATOR_WM8400 + tristate "Wolfson Microelectronics WM8400 AudioPlus PMIC" + depends on MFD_WM8400 help - This driver supports TPS65910 voltage regulator chips. + This driver provides support for the voltage regulators of the + WM8400 AudioPlus PMIC. -config REGULATOR_AAT2870 - tristate "AnalogicTech AAT2870 Regulators" - depends on MFD_AAT2870_CORE +config REGULATOR_WM8994 + tristate "Wolfson Microelectronics WM8994 CODEC" + depends on MFD_WM8994 help - If you have a AnalogicTech AAT2870 say Y to enable the - regulator driver. + This driver provides support for the voltage regulators on the + WM8994 CODEC. endif diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 503bac87715..b5042c885d8 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -3,50 +3,56 @@ # -obj-$(CONFIG_REGULATOR) += core.o dummy.o +obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o obj-$(CONFIG_OF) += of_regulator.o obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o +obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o +obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o +obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o +obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o +obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o +obj-$(CONFIG_REGULATOR_DA903X) += da903x.o +obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o +obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o +obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o +obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o -obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o -obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o -obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o -obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o -obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o -obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o -obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o -obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o -obj-$(CONFIG_REGULATOR_DA903X) += da903x.o -obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o -obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o -obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o -obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o +obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o +obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o +obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o +obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o +obj-$(CONFIG_REGULATOR_TPS65217) += tps65217-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o -obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o -obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o -obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o -obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o -obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o +obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o -obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o +obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o +obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o +obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o +obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o +obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o +obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o +obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o +obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o + ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 685ad43b074..9ed5c5d84e1 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c @@ -31,7 +31,7 @@ #include <linux/mfd/aat2870.h> struct aat2870_regulator { - struct platform_device *pdev; + struct aat2870_data *aat2870; struct regulator_desc desc; const int *voltages; /* uV */ @@ -60,7 +60,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) { struct aat2870_regulator *ri = rdev_get_drvdata(rdev); - struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); + struct aat2870_data *aat2870 = ri->aat2870; return aat2870->update(aat2870, ri->voltage_addr, ri->voltage_mask, selector << ri->voltage_shift); @@ -69,7 +69,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev, static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) { struct aat2870_regulator *ri = rdev_get_drvdata(rdev); - struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); + struct aat2870_data *aat2870 = ri->aat2870; u8 val; int ret; @@ -83,7 +83,7 @@ static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) static int aat2870_ldo_enable(struct regulator_dev *rdev) { struct aat2870_regulator *ri = rdev_get_drvdata(rdev); - struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); + struct aat2870_data *aat2870 = ri->aat2870; return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask, ri->enable_mask); @@ -92,7 +92,7 @@ static int aat2870_ldo_enable(struct regulator_dev *rdev) static int aat2870_ldo_disable(struct regulator_dev *rdev) { struct aat2870_regulator *ri = rdev_get_drvdata(rdev); - struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); + struct aat2870_data *aat2870 = ri->aat2870; return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask, 0); } @@ -100,7 +100,7 @@ static int aat2870_ldo_disable(struct regulator_dev *rdev) static int aat2870_ldo_is_enabled(struct regulator_dev *rdev) { struct aat2870_regulator *ri = rdev_get_drvdata(rdev); - struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); + struct aat2870_data *aat2870 = ri->aat2870; u8 val; int ret; @@ -185,7 +185,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Invalid device ID, %d\n", pdev->id); return -EINVAL; } - ri->pdev = pdev; + ri->aat2870 = dev_get_drvdata(pdev->dev.parent); rdev = regulator_register(&ri->desc, &pdev->dev, pdev->dev.platform_data, ri, NULL); diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index c9b92531ae6..c7ee4c15d6f 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -201,7 +201,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) return info->voltages[selector]; } -static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) +static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) { int ret, val; struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); @@ -229,11 +229,9 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) /* vintcore has a different layout */ val = regval & info->voltage_mask; if (info->desc.id == AB8500_LDO_INTCORE) - ret = info->voltages[val >> 0x3]; + return val >> 0x3; else - ret = info->voltages[val]; - - return ret; + return val; } static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, @@ -320,7 +318,7 @@ static struct regulator_ops ab8500_regulator_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable, .is_enabled = ab8500_regulator_is_enabled, - .get_voltage = ab8500_regulator_get_voltage, + .get_voltage_sel = ab8500_regulator_get_voltage_sel, .set_voltage = ab8500_regulator_set_voltage, .list_voltage = ab8500_list_voltage, .enable_time = ab8500_regulator_enable_time, diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index 483c8093085..26d23adfc66 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c @@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int if (max_uA > chip->max_uA || max_uA < chip->min_uA) return -EINVAL; - selector = ((min_uA - chip->min_uA) * chip->current_level + - range_uA - 1) / range_uA; + selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level, + range_uA); if (ad5398_calc_current(chip, selector) > max_uA) return -EINVAL; diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c new file mode 100644 index 00000000000..17499a55113 --- /dev/null +++ b/drivers/regulator/anatop-regulator.c @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + */ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <linux/slab.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/mfd/anatop.h> +#include <linux/regulator/driver.h> +#include <linux/regulator/of_regulator.h> + +struct anatop_regulator { + const char *name; + u32 control_reg; + struct anatop *mfd; + int vol_bit_shift; + int vol_bit_width; + int min_bit_val; + int min_voltage; + int max_voltage; + struct regulator_desc rdesc; + struct regulator_init_data *initdata; +}; + +static int anatop_set_voltage(struct regulator_dev *reg, int min_uV, + int max_uV, unsigned *selector) +{ + struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); + u32 val, sel; + int uv; + + uv = min_uV; + dev_dbg(®->dev, "%s: uv %d, min %d, max %d\n", __func__, + uv, anatop_reg->min_voltage, + anatop_reg->max_voltage); + + if (uv < anatop_reg->min_voltage) { + if (max_uV > anatop_reg->min_voltage) + uv = anatop_reg->min_voltage; + else + return -EINVAL; + } + + if (!anatop_reg->control_reg) + return -ENOTSUPP; + + sel = DIV_ROUND_UP(uv - anatop_reg->min_voltage, 25000); + if (sel * 25000 + anatop_reg->min_voltage > anatop_reg->max_voltage) + return -EINVAL; + val = anatop_reg->min_bit_val + sel; + *selector = sel; + dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); + anatop_set_bits(anatop_reg->mfd, + anatop_reg->control_reg, + anatop_reg->vol_bit_shift, + anatop_reg->vol_bit_width, + val); + + return 0; +} + +static int anatop_get_voltage_sel(struct regulator_dev *reg) +{ + struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); + u32 val; + + if (!anatop_reg->control_reg) + return -ENOTSUPP; + + val = anatop_get_bits(anatop_reg->mfd, + anatop_reg->control_reg, + anatop_reg->vol_bit_shift, + anatop_reg->vol_bit_width); + + return val - anatop_reg->min_bit_val; +} + +static int anatop_list_voltage(struct regulator_dev *reg, unsigned selector) +{ + struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); + int uv; + + uv = anatop_reg->min_voltage + selector * 25000; + dev_dbg(®->dev, "vddio = %d, selector = %u\n", uv, selector); + + return uv; +} + +static struct regulator_ops anatop_rops = { + .set_voltage = anatop_set_voltage, + .get_voltage_sel = anatop_get_voltage_sel, + .list_voltage = anatop_list_voltage, +}; + +static int __devinit anatop_regulator_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct regulator_desc *rdesc; + struct regulator_dev *rdev; + struct anatop_regulator *sreg; + struct regulator_init_data *initdata; + struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent); + int ret = 0; + + initdata = of_get_regulator_init_data(dev, np); + sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); + if (!sreg) + return -ENOMEM; + sreg->initdata = initdata; + sreg->name = kstrdup(of_get_property(np, "regulator-name", NULL), + GFP_KERNEL); + rdesc = &sreg->rdesc; + memset(rdesc, 0, sizeof(*rdesc)); + rdesc->name = sreg->name; + rdesc->ops = &anatop_rops; + rdesc->type = REGULATOR_VOLTAGE; + rdesc->owner = THIS_MODULE; + sreg->mfd = anatopm |