This driver does not really need struct as3711_regulator_info and
struct as3711_regulator, remove them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Declare regulator_ops structure as const as it is only stored in the ops
field of a regulator_desc structure. This field is of type const, so
regulator_ops structures having this property can be made const too.
File size before: drivers/regulator/as3711-regulator.o
text data bss dec hex filename
1517 4144 0 5661 161d regulator/as3711-regulator.o
File size after: drivers/regulator/as3711-regulator.o
text data bss dec hex filename
2301 3376 0 5677 162d regulator/as3711-regulator.o
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
The max_uV is not used, so remove it from struct as3711_regulator_info.
Current code is using devm_regulator_register(), so we don't need to store *rdev
in struct as3711_regulator for clean up.
Also clean up AS3711_REG macro to remove _vshift, _min_uV and _max_uV arguments.
_vshift is always 0, so remove it.
_min_uV and _max_uV are not required, all required settings are set in
REGULATOR_LINEAR_RANGE macro.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
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>
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>
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>
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>
The SD, ALDO, and DLDO vlotage tables are composed of linear ranges.
This patch converts as3711 to use newly introduced helpers for multiple
linear ranges.
Below is the voltage table on datasheet:
SD:
00h: DC/DC powered down
01h-40h: Volt = 0.6V + sdx_vsel * 12.5mV
41h-70h: Volt = 1.4V + (sdx_vsel - 40h) * 25mV
71h-7Fh: Volt = 2.6V + (sdx_vsel - 70h) * 50mV
ALDO:
0h-0Fh: 1.2V + ldox_vsel * 50mV
10h-1Fh: 1.8V + (ldox_vsel - 10h) * 100mV
DLDO:
00h-10h: Volt = 0.9V + ldox_vsel * 50mV
11h-1fh: Do not use
20h-3fh: Volt = 1.75V + (ldox_vsel - 20h) * 50mV
Note, when convert to use linear ranges APIs, the equation for SD needs below
adjustment because the linear ranges APIs wiil substract range->min_sel when
apply the equation.
SD ( the equation to be used with linear ranges APIs )
01h-40h: Volt = 0.6125V + (sdx_vsel - 1h) * 12.5mV
41h-70h: Volt = 1.425V + (sdx_vsel - 41h) * 25mV
71h-7Fh: Volt = 2.650V + (sdx_vsel - 71h) * 50mV
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
The same table can be used for multiple instance of pdev, so we don't need to
allocate memory for of_regulator_match table per pdev.
match->driver_data points to the corresponding entry of as3711_reg_info,
however it is not used in current code, thus this patch does not set
driver_data in the of_regulator_match table.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
AS3711 regulator OF support only evaluates standard regulator DT
properties.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
To skip registering regulator if no platform initialization data,
we should check reg_data rather than ri->desc.name.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Below equation means the "voltage" is the "smallest" voltage within specific
range.
ret = DIV_ROUND_UP(min - bottom) / step;
voltage = ret * step + bottom;
If we do try 1 down when (voltage > max), new voltage is then less than min
voltage. Which means the new voltage is not in the requested voltage range.
This patch also includes below cleanups:
- Use DIV_ROUND_UP
- rename variable 'ret' to 'sel' for better readability because as3711_sel_check
returns the selector.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Below cases are supposed to be valid:
min_uV == max_uV == info->max_uV
min_uV == max_uV == rdev->desc->min_uV
Don't return -EINVAL for above cases.
This patch also includes below cleanups:
- Use rdev_get_drvdata(rdev) instead of rdev->reg_data.
- Remove unnecessary WARN_ON, it looks pointless.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This driver supports the 4 DCDC and 8 LDO regulators on the AS3711 PMIC.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>