Skip to contentSkip to conversation

mfd: twl4030: Driver for twl4030 madc module

PATCH Superseded Keerthy 2 participants 3 messages Feb 24, 2011 – Feb 28, 2011

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Keerthy

author
#0 lore raw

PATCH v2 1/2 mfd: twl4030: Driver for twl4030 madc module

Introducing a driver for MADC on TWL4030 powerIC. MADC stands for monitoring ADC. This driver monitors the real time conversion of analog signals like battery temperature, battery cuurent etc.

---
V2:
Added functions to convert raw voltages to current and temperature.

V1:
http://www.mail-archive.com/[email protected]/msg44543.html

 drivers/mfd/Kconfig              |   10 +
 drivers/mfd/Makefile             |    1 +
 drivers/mfd/twl4030-madc.c       |  815 ++++++++++++++++++++++++++++++++++++++
 include/linux/i2c/twl4030-madc.h |  142 +++++++
 4 files changed, 968 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/twl4030-madc.c
 create mode 100644 include/linux/i2c/twl4030-madc.h
drivers/mfd/Kconfig +10 -0
index fd01836..029e078 100644
@@ -167,6 +167,16 @@ config TWL4030_CORE
 	  high speed USB OTG transceiver, an audio codec (on most
 	  versions) and many other features.
 
+config TWL4030_MADC
+	tristate "Texas Instruments TWL4030 MADC"
+	depends on TWL4030_CORE
+	help
+	This driver provides support for triton TWL4030-MADC. The
+	driver supports both RT and SW conversion methods.
+
+	This driver can be built as a module. If so it will be
+	named twl4030-madc
+
 config TWL4030_POWER
 	bool "Support power resources on TWL4030 family chips"
 	depends on TWL4030_CORE && ARM
drivers/mfd/Makefile +1 -0
index a54e2c7..2922cc2 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_TPS6507X)		+= tps6507x.o
 obj-$(CONFIG_MENELAUS)		+= menelaus.o
 
 obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
+obj-$(CONFIG_TWL4030_MADC)      += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)    += twl4030-power.o
 obj-$(CONFIG_TWL4030_CODEC)	+= twl4030-codec.o
 obj-$(CONFIG_TWL6030_PWM)	+= twl6030-pwm.o
drivers/mfd/twl4030-madc.c new file +815 -0

815 lines not on this page · raw message

include/linux/i2c/twl4030-madc.h new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

Hi Keerthy,

Quoted 3 lines · Keerthy

Introducing a driver for MADC on TWL4030 powerIC. MADC stands for monitoring ADC. This driver monitors the real time conversion of analog signals like battery temperature, battery cuurent etc.

Looks mostly good to me, one minor comment though:

drivers/mfd/twl4030-madc.c line 222

Quoted 8 lines
drivers/mfd/twl4030-madc.c new file +8 -0
+static int twl4030_madc_read_channels(struct twl4030_madc_data *madc,
+				      u8 reg_base, u16 channels, int *buf)
+{
+	int count = 0, count_req = 0;
+	u8 reg, i;
+
+	for (i = 0; i < TWL4030_MADC_MAX_CHANNELS; i++) {
+		if (channels & (1 << i)) {

You may want to use for_each_set_bit() here.

drivers/mfd/twl4030-madc.c line 228

Quoted 6 lines
drivers/mfd/twl4030-madc.c new file +6 -0
+			reg = reg_base + 2 * i;
+			buf[i] = twl4030_madc_channel_raw_read(madc, reg);
+			if (buf[i] < 0) {
+				dev_err(madc->dev,
+				"Unable to read register 0x%X\n", reg);
+				count_req++;

For a clearer code, just call continue here, and the following blck will look nicer.

drivers/mfd/twl4030-madc.c line 349

Quoted 7 lines
drivers/mfd/twl4030-madc.c new file +7 -0
+static irqreturn_t twl4030_madc_threaded_irq_handler(int irq, void *_madc)
+{
+	struct twl4030_madc_data *madc = _madc;
+	const struct twl4030_madc_conversion_method *method;
+	u8 isr_val, imr_val;
+	int i, len, ret;
+	struct twl4030_madc_request *r;

Don't you want to take the madc lock around here ?

Cheers,
Samuel.

Signature · 7 lines
Intel Open Source Technology Centre
http://oss.intel.com/

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#2 lore raw
Quoted 8 lines · Samuel Ortiz

Hi Keerthy,

Quoted 3 lines · Keerthy

Introducing a driver for MADC on TWL4030 powerIC. MADC stands for monitoring ADC. This driver monitors the real time conversion of analog signals like battery temperature, battery cuurent etc.

Looks mostly good to me, one minor comment though:

Quoted 10 lines

drivers/mfd/twl4030-madc.c line 222

Quoted 8 lines
drivers/mfd/twl4030-madc.c new file +8 -0
+static int twl4030_madc_read_channels(struct twl4030_madc_data *madc,
+                                   u8 reg_base, u16 channels, int *buf)
+{
+     int count = 0, count_req = 0;
+     u8 reg, i;
+
+     for (i = 0; i < TWL4030_MADC_MAX_CHANNELS; i++) {
+             if (channels & (1 << i)) {

You may want to use for_each_set_bit() here.

Ok.

Quoted 10 lines
Quoted 7 lines

+                     reg = reg_base + 2 * i;
+                     buf[i] = twl4030_madc_channel_raw_read(madc, reg);
+                     if (buf[i] < 0) {
+                             dev_err(madc->dev,
+                             "Unable to read register 0x%X\n", reg);
+                             count_req++;

For a clearer code, just call continue here, and the following blck will look nicer.

I will call continue.

Quoted 9 lines

drivers/mfd/twl4030-madc.c line 349

Quoted 7 lines
drivers/mfd/twl4030-madc.c new file +7 -0
+static irqreturn_t twl4030_madc_threaded_irq_handler(int irq, void *_madc)
+{
+     struct twl4030_madc_data *madc = _madc;
+     const struct twl4030_madc_conversion_method *method;
+     u8 isr_val, imr_val;
+     int i, len, ret;
+     struct twl4030_madc_request *r;

Don't you want to take the madc lock around here ?

Ok.

Quoted 8 lines

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

Signature · 6 lines
Regards and Thanks,
Keerthy
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html