Commit Graph

40 Commits

Author SHA1 Message Date
Mark Brown e2a23affe6
Merge branch 'regulator-5.2' into regulator-next 2019-05-06 22:52:14 +09:00
Axel Lin 0b5e200cc7
regulator: tps65217: Fix off-by-one for latest seletor of tps65217_uv1_ranges
According to the datasheet the latest seletor 11 1111b = 3.3 V.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-26 13:57:32 +00:00
Axel Lin 2c33b50e62
regulator: tps65217: Constify regulator_ops
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-25 12:21:29 +00:00
Axel Lin 689b9e025f
regulator: tps65217: Simplify linear range for selector 25-52
The original code separates the selector 25-52 into 2 ranges on purpose
because DCDC1/DCDC3 only support up to 1.8V/1.5V in the old code.
Both DCDC1 and DCDC3 support up to 3.3V since commit b4c2e158a1
("regulator: tps65217: Allow DCDC1 and DCDC3 up to 3.3V"), so merge
25-30 and 31-52 ranges to one range.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-21 14:59:24 +00:00
Anton Vasilyev 4f919ca2bf
regulator: tps65217: Fix NULL pointer dereference on probe
There is no check that tps->strobes is allocated successfully in
tps65217_regulator_probe().
The patch adds corresponding check.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-30 09:41:04 +01:00
Kees Cook a86854d0c5 treewide: devm_kzalloc() -> devm_kcalloc()
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

        devm_kzalloc(handle, a * b, gfp)

with:
        devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

        devm_kzalloc(handle, a * b * c, gfp)

with:

        devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
  devm_kzalloc(HANDLE,
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  devm_kzalloc(HANDLE,
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
  devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * E2
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00
Keerthy 511cb17448 mfd: tps65217: Introduce dependency on CONFIG_OF
Currently the driver boots only via device tree hence add a
dependency on CONFIG_OF. This leaves with a bunch of unused code
so clean that up. This patch also makes use of probe_new function
in place of the probe function so as to avoid passing i2c_device_id.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-10-13 10:42:58 +01:00
Måns Andersson b4c2e158a1 regulator: tps65217: Allow DCDC1 and DCDC3 up to 3.3V
The data sheet statement that DCDC1 and DCDC3 only can be set in the range
0.9V - 1.5V refers to storage on its internal EEPROM and therefore cold boot
configuration. After power-on the device can be reconfigured over i2c and
DCDC1/3 set up to 3.3V.

Signed-off-by: Måns Andersson <mans.andersson@nibe.se>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-23 17:48:55 +00:00
Russ Dill 3de5609959 regulator: tps65217: Enable suspend configuration
The TPS65217 has a pre-defined power-up / power-down sequence which in
a typical application does not need to be changed. However, it is possible
to define custom sequences under I2C control. The power-up sequence is
defined by strobes and delay times. Each output rail is assigned to a
strobe to determine the order in which the rails are enabled.

Every regulator of tps65217 PMIC has sequence registers and every
regulator has a default strobe value and gets disabled when a particular
power down sequence occurs.

To keep a regulator on during suspend we write value 0 to strobe so
that the regulator is out of all sequencers and is not impacted by any
power down sequence. Hence saving the default strobe value during probe
so that when we want to regulator to be enabled during suspend we write 0
to strobe and when we want it to get disabled during suspend we write
the default saved strobe value.

This allows platform data to specify which power rails should be on or off
during RTC only suspend. This is necessary to keep DDR state while in RTC
only suspend.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
[Enhanced commit log and added dynamic allocation for strobes]
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-06-27 17:56:43 +01:00
Mark Brown 7d42a7f293 regulator: tps65217: Use simplified DT parsing
Remove a bunch of code in favour of data.

Signed-off-by: Mark Brown <broonie@linaro.org>
2014-09-10 12:02:48 +01:00
Mark Brown c2542d2a86 regulator: tps65217: Remove unused driver_data from of_match table
We don't ever reference the driver_data we supply so remove it.

Signed-off-by: Mark Brown <broonie@linaro.org>
2014-09-09 23:22:19 +01:00
Mark Brown 81baf9fe02 regulator: tps65217: Remove spurious platform data check
We should always be able to probe a regulator with no platform data. This
will enable readback of current state, though no changes can be made to
the device configuration.

Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-06 12:43:40 +01:00
Sachin Kamat 6bdaaf0e5d regulator: tps65217: Fix build warnings
rdev_get_id() returns an int. Convert rid to type int to avoid the
following warnings:

drivers/regulator/tps65217-regulator.c:73:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
drivers/regulator/tps65217-regulator.c:87:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-24 16:23:00 +01:00
Axel Lin 5957ae1fdc regulator: tps65217: Use regulator_map_voltage_ascend for LDO1
The voltages in LDO1_VSEL_table are in ascendant order, so use
regulator_map_voltage_ascend.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-18 17:21:00 +01:00
Axel Lin 073a77d03e regulator: tps65217: Remove *rdev[] from struct tps65217
Now this driver uses devm_regulator_register() so we don't need to save rdev
pointer to tps->rdev[i] for cleanup.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-18 15:47:39 +01:00
Axel Lin 94ee607c96 regulator: tps65217: Allow missing init_data for diagnostics
The regulator core supports this to allow the configuration to be inspected
at runtime even if no software management is enabled.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-03 12:00:39 +08:00
Sachin Kamat 93195c33eb regulator: tps65217: Use of_get_child_by_name
of_find_node_by_name walks the allnodes list, and can thus walk
outside of the parent node. Use of_get_child_by_name instead.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-14 21:21:54 +00:00
Mark Brown 4c35c8676f Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
Axel Lin 8828bae464 regulator: Add REGULATOR_LINEAR_RANGE macro
Add REGULATOR_LINEAR_RANGE macro and convert regulator drivers to use it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-11 12:49:16 +01:00
Axel Lin e277e65680 regulator: Remove max_uV from struct regulator_linear_range
linear ranges means each range has linear voltage settings.
So we can calculate max_uV for each linear range in regulator core rather than
set the max_uV field in drivers.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-11 12:49:12 +01:00
Sachin Kamat 4aac198ddc regulator: tps65217: Use devm_regulator_register
devm_* simplifies the code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:28:43 +01:00
Axel Lin 6290d60656 regulator: tps65217: Convert to use linear ranges
Below is the equation in original code:

tps65217_uv1_ranges:
        0  ... 24: uV = vsel * 25000 + 900000;
        25 ... 52: uV = (vsel - 24) * 50000 + 1500000;
                      = (vsel - 25) * 50000 + 1550000;
        53 ... 55: uV = (vsel - 52) * 100000 + 2900000;
                      = (vsel - 53) * 100000 + 3000000;
        56 ... 62: uV = 3300000;

tps65217_uv2_ranges:
        0  ...  8: uV = vsel * 50000 + 1500000;
        9  ... 13: uV = (vsel - 8) * 100000 + 1900000;
                      = (vsel - 9) * 100000 + 2000000;
        14 ... 31: uV = (vsel - 13) * 50000 + 2400000;
                      = (vsel - 14) * 50000 + 2450000;

The voltage tables are composed of linear ranges.
This patch converts this driver to use multiple linear ranges APIs.

In original code, voltage range for DCDC1 is 900000 ~ 1800000 and voltage range
for DCDC3 is 900000 ~ 1500000.  This patch separates the range 25~52 in
tps65217_uv1_ranges table to two linear ranges: 25~30 and 31~52.
This change makes it possible to reuse the same linear_ranges table for DCDCx.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-30 15:26:03 +01:00
Axel Lin 405c54009c regulator: Remove all platform_set_drvdata(pdev, NULL) in drivers
Since 0998d06310 "device-core: Ensure drvdata = NULL when no driver is bound",
this is done by driver core after device_release or on probe failure.
Thus we can remove all platform_set_drvdata(pdev, NULL) in drivers.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-12 18:34:12 +04:00
Axel Lin 5bce833c44 regulator: tps65217: Fix using wrong dev argument for calling of_regulator_match
The dev parameter is the device requestiong the data.
In this case it should be &pdev->dev rather than pdev->dev.parent.

The dev parameter is used to call devm_kzalloc in of_get_regulator_init_data(),
which means this fixes a memory leak because the memory is allocated every time
probe() is called, thus it should be freed when this driver is unloaded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-24 18:58:33 +08:00
Bill Pemberton 8dc995f56e regulator: remove use of __devexit
CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-11-20 10:53:38 +09:00
Bill Pemberton a5023574d1 regulator: remove use of __devinit
CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-11-20 10:31:26 +09:00
Bill Pemberton 5eb9f2b963 regulator: remove use of __devexit_p
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-11-20 10:31:19 +09:00
AnilKumar Ch 1922b0f275 mfd: Move tps65217 regulator plat data handling to regulator
Regulator platform data handling was mistakenly added to MFD
driver. So we will see build errors if we compile MFD drivers
without CONFIG_REGULATOR. This patch moves regulator platform
data handling from TPS65217 MFD driver to regulator driver.

This makes MFD driver independent of REGULATOR framework so
build error is fixed if CONFIG_REGULATOR is not set.

drivers/built-in.o: In function `tps65217_probe':
tps65217.c:(.devinit.text+0x13e37): undefined reference
to `of_regulator_match'

This patch also fix allocation size of tps65217 platform data.
Current implementation allocates a struct tps65217_board for each
regulator specified in the device tree. But the structure itself
provides array of regulators so one instance of it is sufficient.

Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
2012-08-22 10:55:25 +02:00
AnilKumar Ch a7f1b63eb8 regulator: tps65217: Add device tree support
This commit adds device tree support for tps65217 pmic. And usage
details are added to device tree documentation. Driver is tested
by using kernel module with regulator set and get APIs.

Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-07-12 18:27:36 +01:00
Axel Lin 844e6901df regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage
It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
max_uV > tps->info[rid]->max_uV.

The equation we used in uv_to_vsel() does not allow
min_uV < tps->info[rid]->min_uV, otherwise it returns negative selector.
So we need to set min_uV = tps->info[rid]->min_uV if
min_uV < tps->info[rid]->min_uV.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-07-03 20:18:34 +01:00
Alan Cox 1a5d39d064 regulator: tps65217: invalid if check
This permits the setting of bogus values because the invalidity check is
itself invalid.

Reported-by: dcb314@hotmail.com
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-07-02 18:26:04 +01:00
Axel Lin d172f319c1 regulator: tps65217: Convert LDO1 to use regulator_list_voltage_table
Convert tps65217_pmic_ldo1_ops to use regulator_list_voltage_table.

We have n_voltages and volt_table settings in regulator_desc,
so we don't need the table and table_len fields in struct tps_info.
Thus remove them from struct tps_info.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-07-01 19:12:58 +01:00
Axel Lin b4bc9ef625 regulator: tps65217: Convert to regulator_[is_enabled|get_voltage_sel]_regmap
This patch converts .is_enabled and .get_voltage_sel to
regulator_is_enabled_regmap and regulator_get_voltage_sel_regmap.

For .enable, .disable, and .set_voltage_sel, the write protect level is either
1 or 2. So we cannot use regulator_[enable|disable|set_voltage_sel]_regmap.

Now we store the enable reg/mask and vsel reg/mask in regulator_desc,
so we can remove enable_mask, set_vout_reg, and set_vout_mask from
struct tps_info.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-06-13 18:57:56 +01:00
Axel Lin 8b22285fd7 regulator: tps65217: Convert to set_voltage_sel and map_voltage
Convert tps65217_pmic_ops to use set_voltage_sel and map_voltage.
After this convertion, we can also use tps65217_pmic_set_voltage_sel()
for set_voltage_sel callback of tps65217_pmic_ldo1_ops.
Thus this patch also removes tps65217_pmic_ldo1_set_voltage_sel() function.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-05-18 08:38:32 +01:00
Mark Brown c172708d38 regulator: core: Use a struct to pass in regulator runtime configuration
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-09 12:37:09 +01:00
Axel Lin 78637a3d8c regulator: tps65217: Constify regulator_desc
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-06 10:07:03 +01:00
Axel Lin fc56911bc6 regulator: Merge tps65217_pmic_ldo234_ops and tps65217_pmic_dcdc_ops to tps65217_pmic_ops
Most callback functions implementation for tps65217_pmic_ldo234_ops and
tps65217_pmic_dcdc_ops are the same except the rid range checking.

This patch uses tps65217_pmic_ops for all DCDCx, LDO2, LDO3, and LDO4.
And rework tps65217_pmic_set_voltage to make it can be called for
DCDCx, LDO2, LDO3, and LDO4.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-12 10:50:46 +00:00
Axel Lin 2fe4e0259d regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector
Use DIV_ROUND_UP macro for better readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-11 20:48:52 +00:00
Axel Lin b683d980d8 regulator: Update tps65217-regulator for DT changes
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-01-20 12:01:33 +00:00
AnilKumar Ch a493077f18 regulator: tps65217: Add tps65217 regulator driver
This patch adds tps65217 PMIC as a regulator

The regulator module consists of 3 DCDCs and 4 LDOs. The output
voltages are configurable and are meant to supply power to the
main processor and other components

Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-01-20 12:01:31 +00:00