linux-stable/drivers
Axel Lin 022dcdf083 regulator: pcf50633: Don't write to reserved bits of AUTO output voltage select register
The datasheet says 00000000 to 00101110 are reserved, and the min value of the
voltage setting is 1.8 V.
Thus don't write 0 to AUTO output voltage select register (address 1Ah).

Table 50. AUTOOUT - AUTO output voltage select register (address 1Ah) bit description[1]
Bit Symbol Access Description
7:0 auto_out R/W VO(prog) = 0.625 + auto_out × 0.025 V
eg. 00000000 to 00101110: reserved
00101111: 1.8 V (min)
01010011: 2.7 V
01101010: 3.275 V
01101011: 3.300 V
01101100: 3.325 V
01111111 : 3.800 V (max)
..... .....
11111110 : 3.800 V
11111111 : 3.800 V

This patch also fixes a bug in pcf50633_regulator_list_voltage:
In regulator core _regulator_do_set_voltage function:

        if (rdev->desc->ops->set_voltage) {
                ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
                                                   &selector);

                if (rdev->desc->ops->list_voltage)
                        selector = rdev->desc->ops->list_voltage(rdev,
                                                                 selector);
                else
                        selector = -1;

The list_voltage call here takes the selector got from set_voltage callback.
Thus adding 0x2f to the index in pcf50633_regulator_list_voltage looks wrong to me.

e.g.
If min_uV < 1.8V, pcf50633_regulator_set_voltage sets 0 to selector.
For this case, adding 0x2f to the index in pcf50633_regulator_list_voltage is correct.
However, if min_uV == 1.8V, pcf50633_regulator_set_voltage sets 0x2f to selector.
Adding 0x2f to the index in pcf50633_regulator_list_voltage in this case is wrong.

What this patch does is:
The minimal voltage setting for AUTOOUT is 0x2f.
Thus for the case min_uV < 1.8, set the voltage setting to 1.8V by writting
0x2f to AUTOOUT register and set selector = 0x2f.
So we don't write the rserved range to AUTOOUT register.
Which means the possible range of AUTOOUT register value is 0x2f ~ 0xff.

We have no problem in regulator_get_voltage.
Since we won't write 0~0x2e to AUTOOUT register, we have no problem converting
the bits we read to voltage. The equation in auto_voltage_value works fine.

For list_voltage, we need to take into account the case selector is 0 ~ 0x2e
because the regulator core assumes the selector is starting from 0.
This patch returns 0 for the cases selector is 0 ~ 0x2e, which means
"this selector code can't be used on this system".

The regulator core iterates from 0 to n_voltages to find the small voltage
in the specific range. The n_voltages settings for AUTOOUT should be 128 now,
including the reserved range of AUTOOUT.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-01 11:59:22 +01:00
..
accessibility
acpi Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-03-30 16:45:39 -07:00
amba
ata 1) AHCI regression fix. A recent "make driver conform to spec" change 2012-03-22 20:22:30 -07:00
atm Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
auxdisplay
base Merge branch 'for-linus-3.4' of git://git.linaro.org/people/sumitsemwal/linux-dma-buf 2012-03-28 15:02:41 -07:00
bcma
block Merge branch 'akpm' (Andrew's patch-bomb) 2012-03-28 17:19:28 -07:00
bluetooth Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
cdrom
char Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
clk clk: make CONFIG_COMMON_CLK invisible 2012-03-19 09:37:11 +00:00
clocksource Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm 2012-03-29 16:53:48 -07:00
connector
cpufreq Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
cpuidle Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-03-30 16:45:39 -07:00
crypto Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2012-03-22 18:15:32 -07:00
dca
devfreq ARM: global cleanups 2012-03-27 16:03:32 -07:00
dio
dma MTD merge for 3.4 2012-03-30 17:31:56 -07:00
edac Merge branch 'linux_next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-edac 2012-03-28 14:24:40 -07:00
eisa
firewire Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
firmware
gpio Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm 2012-03-29 16:53:48 -07:00
gpu drm/i915: suspend fbdev device around suspend/hibernate 2012-03-29 07:44:27 +01:00
hid Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-03-23 14:39:09 -07:00
hv
hwmon MFD changes for 3.4 2012-03-28 13:56:35 -07:00
hwspinlock
i2c Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
ide Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
idle drivers/idle/intel_idle.c: fix confusing code identation 2012-03-21 17:54:54 -07:00
ieee802154
infiniband Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2012-03-29 23:17:44 -07:00
iommu The IOMMU updates for this round are not very large patch-wise. But 2012-03-23 14:15:07 -07:00
isdn Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
leds MFD changes for 3.4 2012-03-28 13:56:35 -07:00
lguest
macintosh Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
mca
md dm: add verity target 2012-03-28 18:43:38 +01:00
media ARM: cleanups of io includes 2012-03-29 18:02:10 -07:00
memstick memstick: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:19 +08:00
message Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
mfd Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
misc Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
mmc MTD merge for 3.4 2012-03-30 17:31:56 -07:00
mtd Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-31 13:42:57 -07:00
net MTD merge for 3.4 2012-03-30 17:31:56 -07:00
nfc
nubus Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
of GPIO changes for v3.4 2012-03-28 14:08:46 -07:00
oprofile tidy up after d_make_root() conversion 2012-03-20 21:29:37 -04:00
parisc Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
parport
pci ASPM: Fix pcie devices with non-pcie children 2012-03-31 12:49:56 -07:00
pcmcia Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia 2012-03-29 16:00:48 -07:00
pinctrl
platform Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-03-30 16:45:39 -07:00
pnp Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-03-30 16:45:39 -07:00
power Various small bugfixes and enhancements, plus two new drivers: 2012-03-30 16:09:02 -07:00
pps
ps3
ptp
rapidio
regulator regulator: pcf50633: Don't write to reserved bits of AUTO output voltage select register 2012-04-01 11:59:22 +01:00
remoteproc
rpmsg
rtc ARM: cleanups of io includes 2012-03-29 18:02:10 -07:00
s390 Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
sbus Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
scsi SCSI updates on 20120331 2012-03-31 13:31:23 -07:00
sfi
sh SuperH updates for 3.4 merge window 2012-03-30 00:09:17 -07:00
sn
spi Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma 2012-03-29 15:34:57 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2012-03-20 21:04:47 -07:00
staging Documentation: remove references to /etc/modprobe.conf 2012-03-30 16:03:15 -07:00
target Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2012-03-22 12:38:04 -07:00
tc
thermal thermal: Fix for setting the thermal zone mode to enable/disable 2012-03-22 01:10:18 -04:00
tty Documentation: remove references to /etc/modprobe.conf 2012-03-30 16:03:15 -07:00
uio
usb Documentation: remove references to /etc/modprobe.conf 2012-03-30 16:03:15 -07:00
uwb uwb: use for_each_clear_bit() 2012-03-23 16:58:34 -07:00
vhost Merge branch 'vhost-net' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost 2012-03-23 14:46:48 -04:00
video ARM: cleanups of io includes 2012-03-29 18:02:10 -07:00
virt
virtio virtio-pci: switch to PM ops macro to initialise PM functions 2012-03-31 08:09:51 +05:30
vlynq
w1
watchdog ARM: cleanups of io includes 2012-03-29 18:02:10 -07:00
xen One tiny feature that accidentally got lost in the initial git pull: 2012-03-24 12:20:25 -07:00
zorro
Kconfig remoteproc/rpmsg: new subsystem 2012-03-27 16:30:09 -07:00
Makefile remoteproc/rpmsg: new subsystem 2012-03-27 16:30:09 -07:00