Skip to contentSkip to conversation

twl4030-madc driver

PATCH In review Keerthy 3 participants 7 messages Mar 1, 2011 – May 4, 2011

Subsystems (4)
lore
Share & tools
lore

Keerthy

author
#0 lore raw

v5 cover twl4030-madc driver

MADC(Monitoring ADC) driver enables monitoring analog signals using analog-to-digital conversion (ADC) on the input source.
The previous discussion concluded in keeping the generic ADC functionality and the hwmon separate. The discussion can be found here:

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

Keerthy (2):
mfd: twl4030: Driver for twl4030 madc module
hwmon: twl4030: Hwmon Driver for TWL4030 MADC

 Documentation/hwmon/twl4030-madc-hwmon |   45 ++
 drivers/hwmon/Kconfig                  |   10 +
 drivers/hwmon/Makefile                 |    1 +
 drivers/hwmon/twl4030-madc-hwmon.c     |  157 +++++++
 drivers/mfd/Kconfig                    |   10 +
 drivers/mfd/Makefile                   |    1 +
 drivers/mfd/twl4030-madc.c             |  802 ++++++++++++++++++++++++++++++++
 include/linux/i2c/twl4030-madc.h       |  141 ++++++
 8 files changed, 1167 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/twl4030-madc-hwmon
 create mode 100644 drivers/hwmon/twl4030-madc-hwmon.c
 create mode 100644 drivers/mfd/twl4030-madc.c
 create mode 100644 include/linux/i2c/twl4030-madc.h
#1 lore raw

Hi Keerthy,

Quoted 6 lines · Keerthy

MADC(Monitoring ADC) driver enables monitoring analog signals using analog-to-digital conversion (ADC) on the input source.
The previous discussion concluded in keeping the generic ADC functionality and the hwmon separate. The discussion can be found here:

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

Thanks a lot, I applied those 2 patches.

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
#2 lore raw
Quoted 10 lines · Samuel Ortiz

Hi Keerthy,

Quoted 6 lines · Keerthy

MADC(Monitoring ADC) driver enables monitoring analog signals using analog-to-digital conversion (ADC) on the input source.
The previous discussion concluded in keeping the generic ADC functionality and the hwmon separate. The discussion can be found here:

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

Thanks a lot, I applied those 2 patches.

I'm attempting to use this drive on the Overo platform with 2.6.39-rc5.

Other than enabling the module with CONFIG_SENSORS_TWL4030_MADC=m are there any board file modifications required other than the below?

I have setup the platform data for the twl4030 madc driver:

(quoted diff) +0 -0

b/arch/arm/mach-omap2/board-overo.c
index 112dfc9..05dd3eb 100644

arch/arm/mach-omap2/board-overo.c +5 -0
@@ -637,10 +637,15 @@ static struct twl4030_codec_data overo_codec_data = {
 	.audio = &overo_audio_data,
 };
 
+static struct twl4030_madc_platform_data overo_madc_data = {
+	.irq_line	= 1,
+};
+
 static struct twl4030_platform_data overo_twldata = {
 	.irq_base	= TWL4030_IRQ_BASE,
 	.irq_end	= TWL4030_IRQ_END,
 	.gpio		= &overo_gpio_data,
+	.madc		= &overo_madc_data,
 	.usb		= &overo_usb_data,
 	.codec		= &overo_codec_data,
 	.vmmc1		= &overo_vmmc1,

However, I am not seeing the sysfs entry created:

# modprobe twl4030-madc-hwmon
twl4030_madc_hwmon_init entry
# lsmod
Module                  Size  Used by
twl4030_madc_hwmon      2594  0
ipv6                  224256  16
libertas_sdio          14867  0
libertas               92429  1 libertas_sdio
cfg80211              144256  1 libertas
lib80211                5027  1 libertas
firmware_class          5859  2 libertas_sdio,libertas
# ls /sys/class/hwmon/
#

I added a couple of printk's to the driver at the entry points of init and probe, and as you can see above the init message is printed, but not the probe.

Am I missing something really obvious here?

Steve

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#3 lore raw

Hello Steve,

Can you try adding this patch?

Regards,
Keerthy

Quoted 59 lines · Steve Sakoman
Quoted 10 lines · Samuel Ortiz

Hi Keerthy,

Quoted 6 lines · Keerthy

MADC(Monitoring ADC) driver enables monitoring analog signals using analog-to-digital conversion (ADC) on the input source.
The previous discussion concluded in keeping the generic ADC functionality and the hwmon separate. The discussion can be found here:

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

Thanks a lot, I applied those 2 patches.

I'm attempting to use this drive on the Overo platform with 2.6.39-rc5.

Other than enabling the module with CONFIG_SENSORS_TWL4030_MADC=m are there any board file modifications required other than the below?

I have setup the platform data for the twl4030 madc driver:

arch/arm/mach-omap2/board-overo.c +5 -0
index 112dfc9..05dd3eb 100644
@@ -637,10 +637,15 @@ static struct twl4030_codec_data overo_codec_data = {
        .audio = &overo_audio_data,
  };
 
+static struct twl4030_madc_platform_data overo_madc_data = {
+       .irq_line       = 1,
+};
+
  static struct twl4030_platform_data overo_twldata = {
        .irq_base       = TWL4030_IRQ_BASE,
        .irq_end        = TWL4030_IRQ_END,
        .gpio           = &overo_gpio_data,
+       .madc           = &overo_madc_data,
        .usb            = &overo_usb_data,
        .codec          = &overo_codec_data,
        .vmmc1          = &overo_vmmc1,

However, I am not seeing the sysfs entry created:

# modprobe twl4030-madc-hwmon
twl4030_madc_hwmon_init entry
# lsmod
Module                  Size  Used by
twl4030_madc_hwmon      2594  0
ipv6                  224256  16
libertas_sdio          14867  0
libertas               92429  1 libertas_sdio
cfg80211              144256  1 libertas
lib80211                5027  1 libertas
firmware_class          5859  2 libertas_sdio,libertas
# ls /sys/class/hwmon/
#
Quoted 8 lines

I added a couple of printk's to the driver at the entry points of init and probe, and as you can see above the init message is printed, but not the probe.

Am I missing something really obvious here?

Steve

From a05c6cbb4494173e03ea5957666216caedb22d84 Mon Sep 17 00:00:00 2001
From: Keerthy <[email protected]>
Date: Wed, 4 May 2011 01:14:50 +0530
Subject: [PATCH] Enabling Hwmon driver for twl4030-madc

---
 drivers/mfd/twl-core.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/mfd/twl-core.c +15 -0
index 960b5be..e6e99db 100644
@@ -83,6 +83,13 @@
 #define twl_has_madc()	false
 #endif
 
+#if defined(CONFIG_SENSORS_TWL4030_MADC) ||\
+	 defined(CONFIG_SENSORS_TWL4030_MADC_MODULE)
+#define twl_has_madc_hwmon()  true
+#else
+#define twl_has_madc_hwmon()  false
+#endif
+
 #ifdef CONFIG_TWL4030_POWER
 #define twl_has_power()        true
 #else
@@ -609,6 +616,14 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 			return PTR_ERR(child);
 	}
 
+if (twl_has_madc_hwmon()) {
+		child = add_child(2, "twl4030_madc_hwmon",
+				NULL, 0,
+				true, pdata->irq_base + MADC_INTR_OFFSET, 0);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+	}
+
 	if (twl_has_rtc()) {
 		/*
 		 * REVISIT platform_data here currently might expose the
Signature · 1 line
1.7.0.4
author
#5 lore raw
Quoted 10 lines · Steve Sakoman
Quoted 3 lines · KEERTHY

Hello Steve,

Can you try adding this patch?

Thanks!

I tried the patch and it did indeed fix the issue.  We should try to get this in mainline since the hwmon driver won't work without it.

Yes Steve. I am posting a patch today.

Quoted 2 lines

Steve

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
#6 lore raw
Quoted 6 lines · KEERTHY
Quoted 5 lines · Steve Sakoman
Quoted 3 lines · KEERTHY

Hello Steve,

Can you try adding this patch?

Quoted 7 lines
Quoted 5 lines

Thanks!

I tried the patch and it did indeed fix the issue.  We should try to get this in mainline since the hwmon driver won't work without it.

Yes Steve. I am posting a patch today.

I've also found that the madc clock needs to be enabled:

From: Steve Sakoman <[email protected]>
Date: Sat, 23 Jan 2010 14:26:54 +0000 (-0800)
Subject: mfd: twl-core: enable madc clock
X-Git-Url: http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=commitdiff_plain;h¡f1a1a6420f15e8351a0c5d63a81aa2444874f4

mfd: twl-core: enable madc clock

Now that the madc driver has been merged it is also necessary to enable the clock to the madc block

---

drivers/mfd/twl-core.c +8 -0
index d9435e4..9096d7d 100644
@@ -222,6 +222,11 @@
 
 /* Few power values */
 #define R_CFG_BOOT			0x05
+#define R_GPBR1				0x0C
+
+/* MADC clock values for R_GPBR1 */
+#define MADC_HFCLK_EN			0x80
+#define DEFAULT_MADC_CLK_EN		0x10
 
 /* some fields in R_CFG_BOOT */
 #define HFCLK_FREQ_19p2_MHZ		(1 << 0)
@@ -992,6 +997,9 @@ static void clocks_init(struct device *dev,
 
 	e |= unprotect_pm_master();
 	/* effect->MADC+USB ck en */
+	if (twl_has_madc())
+		e |= twl_i2c_write_u8(TWL_MODULE_INTBR,
+				MADC_HFCLK_EN | DEFAULT_MADC_CLK_EN, R_GPBR1);
 	e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
 	e |= protect_pm_master();
 
include/linux/i2c/twl.h +1 -0
index 0c0d1ae..cbbf3b3 100644
@@ -74,6 +74,7 @@
 
 #define TWL_MODULE_USB		TWL4030_MODULE_USB
 #define TWL_MODULE_AUDIO_VOICE	TWL4030_MODULE_AUDIO_VOICE
+#define TWL_MODULE_INTBR	TWL4030_MODULE_INTBR
 #define TWL_MODULE_PIH		TWL4030_MODULE_PIH
 #define TWL_MODULE_MADC		TWL4030_MODULE_MADC
 #define TWL_MODULE_MAIN_CHARGE	TWL4030_MODULE_MAIN_CHARGE

I'll submit this patch separately.

Steve

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors