PCAP regulator driver (for 2.6.32)
PATCH v2 2/2 PCAP regulator driver (for 2.6.32)
Changed: Removed workaround for regulator use_count issues.
=== CUT HERE ===
Add (partial) support for the voltage regulators on the PCAP2 PMIC.
--- drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/pcap-regulator.c | 329 ++++++++++++++++++++++++++++++++++++ 3 files changed, 337 insertions(+), 0 deletions(-)
drivers/regulator/Kconfig +7 -0
@@ -117,4 +117,11 @@ config REGULATOR_LP3971 Say Y here to support the voltage regulators and convertors on National Semiconductors LP3971 PMIC +config REGULATOR_PCAP + tristate "PCAP2 regulator driver" + depends on EZX_PCAP + help + This driver provides support for the voltage regulators of the + PCAP2 PMIC. + endif
drivers/regulator/Makefile +1 -0
@@ -16,5 +16,6 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o +obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
drivers/regulator/pcap-regulator.c new file +329 -0
329 lines not on this page · raw message
Signature · 4 lines
tg: (69e76aa..) ezx/pcap_regulator (depends on: ezx/local/pcap) -- Daniel Ribeiro
Quoted 1 line · Daniel Ribeiro
Changed: Removed workaround for regulator
use_countissues.
The usual place for these comments is after the --- with the diffstat (the tools can then deal automatically with them). Incidentally, the code you had would only help pxamci with this particular regulator driver.
Quoted 3 lines
Add (partial) support for the voltage regulators on the PCAP2 PMIC.
Signed-off-by Daniel Ribeiro <[email protected]>
Sorry, I've noticed a race condition below that I didn't spot first time round below:
drivers/regulator/pcap-regulator.c line 163
Quoted 11 lines
drivers/regulator/pcap-regulator.c new file +11
-0+static int pcap_regulator_set_voltage (struct regulator_dev *rdev, +int min_uV,int max_uV) +{ +struct pcap_regulator *vreg = &vreg_table[rdev_get_id (rdev)]; +void *pcap =rdev_get_drvdata (rdev); +int uV; +u32 tmp; +u8 i; + +if (vreg->n_voltages ==1 ) +return -EINVAL ;
It'd be a little more friendly to check if the supported voltage is in the requested range. However, that'd only be an issue if constraints allowed voltage changes which is obviously broken so a comment to that effect would be enough. I wouldn't have mentioned it but...
drivers/regulator/pcap-regulator.c line 215
Quoted 11 lines
drivers/regulator/pcap-regulator.c new file +11
-0+{ +struct pcap_regulator *vreg = &vreg_table[rdev_get_id (rdev)]; +void *pcap =rdev_get_drvdata (rdev); +u32 tmp; + +if (vreg->en ==NA ) +return -EINVAL ; + +ezx_pcap_read (pcap, vreg->reg, &tmp); + tmp |= (1 << vreg->en); +ezx_pcap_write (pcap, vreg->reg, tmp);
This read/modify/write cycle is racy; the individual regulator is locked by the core but this register is shared between all regulators on the chip so if two are being updated at once things will go wrong. Most of the MFDs have a set_bits() function that does an atomic read/modify/write cycle for cases like this.
Em Sáb, 2009-06-27 às 02:04 +0100, Mark Brown escreveu:
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (vreg->n_voltages == 1) + return -EINVAL;It'd be a little more friendly to check if the supported voltage is in the requested range. However, that'd only be an issue if constraints allowed voltage changes which is obviously broken so a comment to that effect would be enough. I wouldn't have mentioned it but...
Ok, I will add a comment.
Quoted 9 lines
drivers/regulator/pcap-regulator.c line 215
Quoted 3 lines
drivers/regulator/pcap-regulator.c new file +3
-0+ezx_pcap_read (pcap, vreg->reg, &tmp); + tmp |= (1 << vreg->en); +ezx_pcap_write (pcap, vreg->reg, tmp);This read/modify/write cycle is racy; the individual regulator is locked by the core but this register is shared between all regulators on the chip so if two are being updated at once things will go wrong. Most of the MFDs have a
set_bits()function that does an atomic read/modify/write cycle for cases like this.
Good point, thanks! :)
Signature · 1 line
Daniel Ribeiro