regulator: mc13892-regulator: correct/refine handling of the SWxHI bit
MC13892 PMIC supports a "HI" bit for 3 of it's 4 buck switcher outputs,
which enables a higher set of voltage ranges.
Despite a comment in the code ('sw regulators need special care due to the
"hi" bit'), it actually does not take special care since it does not modify
it's use of the selector table index when this bit is set, giving us very
odd behavior when setting a high voltage on supported switchers or listing
current voltages. Net effect is in best case the kernel and sysfs report
lower voltages than are actually set in hardware (1300mV instead of 1800mV
for example) and in the worst case setting a voltage (e.g. 1800mV) will cause
an undervoltage condition (e.g. 1300mV).
Correct the behavior, taking into account SW1 doesn't support the HI bit,
and as such we need to ignore it.
While we are modifying these functions, fix and optimize the following;
* set_voltage_sel callback was using .reg instead of .vsel_reg - since
they were set to the same value it actually didn't break anything but
it would be semantically incorrect to use .reg in this case. We now use
.vsel_reg and be consistent.
* vsel_shift is always 0 for every SWx regulator, and constantly shifting
and masking off the bottom few bits is time consuming and makes the
code very hard to read - optimize this out.
* get_voltage_sel uses the variable "val" and set_voltage_sel uses the
variable "selector" (and reg_value). Introduce the variable "selector"
to get_voltage_sel such that it makes more sense and allow some leaner
code in light of the modifications in this patch. Add better exposure
to the debug print so the register value AND the selector are printed as
this will adequately show the HI bit in the register.
* correct a comment in probe which is doing a version check. Magic
values are awful but for once instance, a comment does just as
good a job as something symbolic.
Signed-off-by: Matt Sealey <matt@genesi-usa.com>
Tested-by: Steev Klimaszewski <steev@genesi-usa.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>