regulator: add support for Dallas DS1803 dual digital potentiometer
PATCH 4/19 regulator: add support for Dallas DS1803 dual digital potentiometer
--- drivers/regulator/Kconfig | 7 ++ drivers/regulator/Makefile | 1 + drivers/regulator/ds1803.c | 201 ++++++++++++++++++++++++++++++++++++++ include/linux/regulator/ds1803.h | 41 ++++++++ 4 files changed, 250 insertions(+), 0 deletions(-) create mode 100644 drivers/regulator/ds1803.c create mode 100644 include/linux/regulator/ds1803.h
drivers/regulator/Kconfig +7 -0
@@ -201,5 +201,12 @@ config REGULATOR_88PM8607 help This driver supports 88PM8607 voltage regulator chips. +config REGULATOR_DS1803 + tristate "Dallas Maxim DS1803 addressable dual digital potentiometer" + depends on I2C + help + Say Y here to support the dual digital potentiometer on + Dallas Maxim DS1803 + endif
drivers/regulator/Makefile +1 -0
@@ -31,5 +31,6 @@ obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o +obj-$(CONFIG_REGULATOR_DS1803) += ds1803.o ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
drivers/regulator/ds1803.c new file +201 -0
201 lines not on this page · raw message
include/linux/regulator/ds1803.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.6.3.3
On Thu, Apr 01, 2010 at 01:23:32PM +0200, Rodolfo Giometti wrote:
This looks good, a few nitpicky things below.
drivers/regulator/Kconfig config REGULATOR_88PM8607 · line 210
Quoted 7 lines
drivers/regulator/Kconfig +7
-0+config REGULATOR_DS1803 + tristate "Dallas Maxim DS1803 addressable dual digital potentiometer" + depends on I2C + help + Say Y here to support the dual digital potentiometer on + Dallas Maxim DS1803 +
Oh, wow. A pot as a voltage regulator... :)
drivers/regulator/ds1803.c line 35
Quoted 7 lines
drivers/regulator/ds1803.c new file +7
-0+struct ds1803_data { +struct i2c_client *client; +struct regulator_dev *rdev; + +unsigned int min_uV;/* voltage for selector value 0 */ +unsigned int max_uV;/* voltage for selector value 255 */ +unsigned int init_uV;/* initial voltage */
Given that you don't support get_voltage() or otherwise reference init_uV it seems as well to just drop that for now.
Quoted 1 line
+static u8 ds1803_write_pot_lut[] = {
0xa9,0xaa, /* both not supported */ };
Both what? Since you don't seem to reference this I guess it could just be dropped...
drivers/regulator/ds1803.c line 78
Quoted 7 lines
drivers/regulator/ds1803.c new file +7
-0+static int ds1803_list_voltage (struct regulator_dev *rdev,unsigned index) +{ +struct ds1803_data *ds1803 =rdev_get_drvdata (rdev); + +return (ds1803->max_uV - ds1803->min_uV) * index /255 + + ds1803->min_uV; +}
I think I'd like more brackets in this calculation for clarity that the operator precedence is OK.
drivers/regulator/ds1803.c line 131
Quoted 2 lines
drivers/regulator/ds1803.c new file +2
-0+/* Set chip's name according to user supplied type */ + ds1803_reg[i].name = ds1803_names[pdata->type];
Perhaps just let the user write in something they feel like, or use a constant string for the chip? The type doesn't seem to be used otherwise so I can see the data ending up wrong and misleading folks.
include/linux/regulator/ds1803.h line 30
Quoted 5 lines
include/linux/regulator/ds1803.h new file +5
-0+enum ds1803_type { +DS1803_100K , +DS1803_50K , +DS1803_10K , +};
If you are going to keep these assign a value to the first item so you don't end up with 0 as a valid type, or make the 0 type be "unspecified" or something. That way platform data that's left initialised to zero can be distinguished from something that someone deliberately set.