summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/twl-regulator.c
AgeCommit message (Collapse)AuthorFilesLines
2012-04-13regulator: twl-regulator: Implement enable_time callbackAxel Lin1-4/+19
Let regulator core do the necessary delay for us. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-10regulator: twl-regulator: Fix off-by-one vsel setting in twl6030smps_set_voltageAxel Lin1-4/+10
commit 268a1 "regulator: twl-regulator: Use DIV_ROUND_UP at appropriate places" introduced an off-by-one bug for setting vsel. The linear calculation code in twl6030smps_list_voltage() does subtract index by 1 so we need the vsel++ after DIV_ROUND_UP. The original code use this trick to differentiate if we are going to set the voltage to 0 or the voltage falls within the linear calculation range. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-10regulator: twl-regulator: Use DIV_ROUND_UP at appropriate placesAxel Lin1-24/+6
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-10regulator: twl-regulator: Simplify the code matching regulator idAxel Lin1-3/+5
This patch makes the code easier to read. Also add checking the case when no desc id is matched. This is required because if no desc id is matched, the poiner info is pointed to twl_of_match[i].data which may be not NULL. Checking info is NULL or not latter does not catch the error. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-09regulator: core: Use a struct to pass in regulator runtime configurationMark Brown1-2/+7
Rather than adding new arguments to regulator_register() every time we want to add a new bit of dynamic information at runtime change the function to take these via a struct. By doing this we avoid needing to do further changes like the recent addition of device tree support which required each regulator driver to be updated to take an additional parameter. The regulator_desc which should (mostly) be static data is still passed separately as most drivers are able to configure this statically at build time. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-06regulator: Convert twl4030ldo_set_voltage to set_voltage_selAxel Lin1-23/+4
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11regulator: twl-regulator: Add fixed LDO for V1V8, V2V1 supplyPeter Ujfalusi1-0/+4
V1V8 supply most common use is to provide VIO for the system. V2V1 supply is used on SDP4430/PandaBoards to provide 2.1V to twl6040, and also as an input to VCXIO_IN, VDAC_IN of twl6030. Also update the bindings documentation with the new compatible property for these additional LDOs. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11regulator: twl: adapt twl-regulator driver to dtRajendra Nayak1-87/+172
Modify the twl regulator driver to extract the regulator_init_data from device tree when passed, instead of getting it through platform_data structures (on non-DT builds) Also add documentation for TWL regulator specific bindings. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11regulator: twl6030: add support for vdd1, vdd2 and vdd3 regulatorsTero Kristo1-0/+39
vdd1 and vdd2 are now common regulators for twl4030 and twl6030. Also added vdd3 as a new regulator for twl6030. twl6030 vdd1...vdd3 smps regulator voltages can only be controlled through the smartreflex voltage channel, thus the support for the voltage_get and set is minimal and requires external controller. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Rajendra Nayak <rnayak@ti.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11regulator: twl4030: add support for external voltage get/setTero Kristo1-5/+34
This is needed for SMPS regulators, which use the OMAP voltage processor for voltage get/set functions instead of the normal I2C channel. For this purpose, regulator_init_data->driver_data contents are expanded, it is now a struct which contains function pointers for the set/get voltage operations, a data pointer for these, and the previously used features bitmask. Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com> [for the MFD part] Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11regulator: twl6030: Fix voltage selection logicLaxman Dewangan1-3/+11
The voltage selection logic for the twl6030 smps fails if min:max is such that min < 1300mV and max > 1300mV although this is in valid range for a regulator e.g. [x, 1350] where x < 1300. Fixing the voltage selection logic such that first it will check for min_uV for a range and then calculated value will be checked against max_uV. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-11-28Merge remote-tracking branches 'regulator/topic/dt' and ↵Mark Brown1-2/+44
'regulator/for-linus' into regulator-next
2011-11-28regulator: twl: fix twl4030 support for smps regulatorsTero Kristo1-2/+44
SMPS regulator voltage control differs from the one of the LDO ones. Current TWL code was using LDO regulator ops for controlling the SMPS regulators, which fails. This was fixed fixed by adding separate regulator type which uses correct logic and calculations for the voltage levels. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@kernel.org
2011-11-23regulator: pass additional of_node to regulator_register()Rajendra Nayak1-1/+1
With device tree support for regulators, its needed that the regulator_dev->dev device has the right of_node attached. To be able to do this add an additional parameter to the regulator_register() api, wherein the dt-adapted driver can then pass this additional info onto the regulator core. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-07-22regulator: TWL: Remove entry of RES_ID for 6030 macrosAmbresh K1-34/+30
RES_ID is only used in 4030, to send PBM singular message to control the state of dedicated resources. In 6030, we don't have concept of PBM, hence removing the definition of RES_ID (num) from macros. Signed-off-by: Ambresh K <ambresh@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-05-30regulator: twl-regulator: fix n_voltages for twl6030 variable LDOsColin Cross1-1/+1
The n_voltages initializer for the TWL6030_ADJUSTABLE_LDO macro is off by one, causing the the highest supported voltage to be unreachable. Setting the machine constraints to only allow the highest voltage causes errors: machine_constraints_voltage: VAUX3_6030: unsupportable voltage constraints twl_reg twl_reg.39: can't register VAUX3_6030, -22 twl_reg: probe of twl_reg.39 failed with error -22 This patch fixes the off by one error. Tested by setting VAUX3_6030 to 3.3V. Signed-off-by: Colin Cross <ccross@android.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-05-27REGULATOR: TWL6025: add support to twl-regulatorGraeme Gregory1-8/+321
Adding support for the twl6025. Major difference in the twl6025 is the group functionality has been removed from the chip so this affects how regulators are enabled and disabled. The names of the regulators also changed. The DCDCs of the 6025 are software controllable as well. Since V1 Use the features variable passed via platform data instead of calling global function. Change the very switch like if statements to be a more readable switch statement. Since V2 twl6025 doesn't use remap so remove it from the macros. Since V3 enable/disable functions for 4030/6030 were seperated upstream so rebase on top of this. Change DCDC reference to SMPS as this is used in TRM. Change list_voltage slightly to have less code. Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-05-27regulator: twl6030: do not write to _GRP for regulator disableBalaji T K1-25/+22
TWL6030: regulator is disabled via VREG_STATE TWL4030: regulator is disabled via VREG_GRP Since there is nothing common, split twlreg_enable similar to other regulator_ops Signed-off-by: Balaji T K <balajitk@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-05-27regulator: twl6030: do not write to _GRP for regulator enableBalaji T K1-14/+25
TWL6030: regulator is enabled via VREG_STATE TWL4030: regulator is enabled via VREG_GRP Since there is nothing common, split twlreg_enable similar to other regulator_ops Signed-off-by: Balaji T K <balajitk@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-05-27regulator: twl: add twl6030 set_modeSaquib Herman1-8/+34
Current set_mode logic does not support 6030. The logic for 4030 is not reusable for 6030 as the mode setting for 6030 now uses the new CFG_STATE register. We hence rename the old get_status as being specific to 4030. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Saquib Herman <saquib@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
2011-05-27regulator: twl: add twl6030 get_statusSaquib Herman1-9/+35
Current get_status logic does not support 6030 get_status. The logic for 4030 is not reusable for 6030 as the status check for 6030 now depends on the new CFG_STATE register. We hence rename the old get_status as being specific to 4030 and remove the redundant check for the same. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Saquib Herman <saquib@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
2011-05-27regulator: twl: fix twl6030 regulator is_enabledSaquib Herman1-15/+46
With TWL6030, it is not enough to ensure that the regulator is the group of P1 group (CPU/Linux), but we need to check the state as far as APP is concerned as well. Split the current is_enabled to 6030 and 4030 specific ones. This split impacts few macros and variables as well, but sets up the stage for further fixes to set_mode and get_status in subsequent patches. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Saquib Herman <saquib@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
2011-05-27regulator: twl: remap has no meaning for 6030Saquib Herman1-20/+17
TWL6030 does not have remap register. The current implementation causes value of remap to be written to state register, accidentally causing the regulators which are probed to be switched on as well. This is wrong as regulators should be controllable based on calls to enable/disable for TWL regulator framework. Further, the values initialized make no sense as well. We hence remove this from the initalizers and also write to remap register only if the TWL is 4030. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Saquib Herman <saquib@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
2011-05-27regulator: twl: fix twl6030 enable/disableSaquib Herman1-1/+30
TWL6030 requires an additional register write to CFG_STATE register to explicitly state that the regulator is in a certain state. Merely associating the regulator with the group is not enough. Add the required register field definitions and fix the handling for TWL6030 enable/disable. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Saquib Herman <saquib@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
2011-03-23regulator: twl: add clk32kg to twl-regulatorBalaji T K1-1/+23
In OMAP4 Blaze and Panda, 32KHz clock to WLAN is supplied from Phoenix TWL6030. The 32KHz clock state (ON/OFF) is configured in CLK32KG_CFG_[GRP, TRANS, STATE] register. This follows the same register programming model as other regulators in TWL6030. So add CLK32KG as pseudo regulator. Signed-off-by: Balaji T K <balajitk@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2011-01-12regulator: Report actual configured voltage to set_voltage()Mark Brown1-3/+8
Change the interface used by set_voltage() to report the selected value to the regulator core in terms of a selector used by list_voltage(). This allows the regulator core to know the voltage that was chosen without having to do an explict get_voltage(), which would be much more expensive as it will generally access hardware. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-11-30regulator: twl-regulator - fix twlreg_set_modeAxel Lin1-3/+3
The Singular Message is 16 bits: DEV_GRP[15:13] MT[12] RES_ID[11:4] RES_STATE[3:0] Current implementation return immedially after sucessfuly write MSB part. To properly set mode, we need to write the complete message ( MSB and LSB ). In twl.h, now we have defines for PM Master module register offsets, use it instead of hard coded 0x15/0x16. Use "message & 0xff" to ensure we send correct value for LSB. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Tested-by: Lesly Arackal Manuel <leslyam@ti.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-05-25twl6030: regulator: Remove vsel tables and use formula for calculationRajendra Nayak1-47/+91
All twl6030 regulators can be programmed from 1.0v to 3.3v with 100mV steps. The below formula can be used to calculate the vsel values to be programmed in the VREG_VOLTAGE registers. Voltage(in mV) = 1000mv + 100mv * (vsel - 1) Ex: if vsel = 0x9, mV = 1000 + 100 * (9 -1) = 1800mV. This patch removes all existing VSEL tables for twl6030 adjustable regulators and just uses the formula directly for vsel calculations after verifing they fall in the allowed range. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Cc: Liam Girdwood <lrg@slimlogic.co.uk> Cc: Samuel Ortiz <sameo@linux.intel.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-03-03Regulators: twl-regulator - mark probe function as __devinitDmitry Torokhov1-1/+1
Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-03-03twl6030: regulator: Configure STATE register instead of REMAPRajendra Nayak1-10/+10
This is no REMAP register on twl6030, instead there is a STATE register to drive a resource to a given state. The state register can be used to specify what state the resource should enter when its associated with a GRP. Register Bit field description is as below. The patch programmes the corresponding STATE registers for all LDO's to turn ON when assocaited with GRP_P1. STATE REG: Bit7 |Bit6 |Bit5 |Bit4 |Bit3 |Bit2 |Bit1 |Bit0 P3_GRP |P2_GRP |P1_GRP |RES |RES |RES |State1 |State0 State can be specified as below 00: OFF 01: ON 10: OFF 11: SLEEP Signed-off-by: Rajendra Nayak <rnayak@ti.com> Cc: Liam Girdwood <lrg@slimlogic.co.uk> Cc: Samuel Ortiz <sameo@linux.intel.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Fix reg_disable functionality for 4030 and 6030Juha Keski-Saari1-2/+2
This change makes sure all regulator group assignments are cleared on disable call Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Add turnon delay to reg_enableJuha Keski-Saari1-1/+7
This change implements a basic turnon delay in the regulator enable function to make it less probable that reg_enable returns before the regulator output is at target level Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Restore REMAP configuration in regulator probeJuha Keski-Saari1-0/+3
This change ensures the regulator REMAP register configuration is in a known state so state transitions will function as intended regardless of possible bootloader effects on it Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Add turnon-delay and REMAP config to twlreg_info structJuha Keski-Saari1-41/+62
This change includes regulator turnon delay values and the REMAP reset configuration to the twlreg_info struct, since they are basic attributes of every TWL regulator Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Define critical regulators as always_onJuha Keski-Saari1-0/+13
Defines VIO, VDD1, VDD2, VPLL1 and VINT* regulators as always_on by default since they are critical to TWL and its master's functionality and should be on in all cases where RegFW is used Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-17twl-regulator: Add all twl4030 regulators to twlreg_infoJuha Keski-Saari1-9/+17
Define all twl4030 regulators in the twlreg_info table, along with appropriate VSEL tables for adjustable regulators Signed-off-by: Juha Keski-Saari <ext-juha.1.keski-saari@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-12-14regulator: Add support for twl6030 regulatorsRajendra Nayak1-21/+95
This patch updates the regulator driver to add support for TWL6030 PMIC specific LDO regulators. SMPS resources are not yet supported for TWL6030 and also .set_mode and .get_status for LDO's are yet to be implemented for TWL6030. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Balaji T K <balajitk@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2009-12-13mfd: Rename twl4030_ routines in twl-regulator.cRajendra Nayak1-92/+97
This patch renames all twl4030_ functions to twl so that regulator driver can be reused by Triton - TWL4030 and Phoenix - TWL6030. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2009-12-13mfd: Rename all twl4030_i2c*Balaji T K1-4/+4
This patch renames function names like twl4030_i2c_write_u8, twl4030_i2c_read_u8 to twl_i2c_write_u8, twl_i2c_read_u8 and also common variable in twl-core.c Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2009-12-13mfd: Rename twl4030* driver files to enable re-useSantosh Shilimkar1-0/+500
The upcoming TWL6030 is companion chip for OMAP4 like the current TWL4030 for OMAP3. The common modules like RTC, Regulator creates opportunity to re-use the most of the code from twl4030. This patch renames few common drivers twl4030* files to twl* to enable the code re-use. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>