Hi,
I have fixed my problem. The status register was showing 0xDD and the timeout of 5ms was always being reached. The BUSY bit was never set. Thanks to google, old.nabble.com and Steve Sakoman posting a patch for twl4030-core.c which enables the MADC clocks (via the GPBR1 register) - http://old.nabble.com/Re%3A-Help-with-Overo-ADC-tt24174607.html#a24174607. With version 2.6.32 kernel from gumdroid the patch is slightly different to the one posted. Which I will post below to help others in the future.
Here's what it looks like working (all floating voltages except channel 7):
# madc
madc[ 2] raw = 457 voltage = 1.12
madc[ 3] raw = 53 voltage = 0.13
madc[ 4] raw = 611 voltage = 1.49
madc[ 5] raw = 47 voltage = 0.11
madc[ 6] raw = 217 voltage = 0.53
madc[ 7] raw = 560 voltage = 1.37
and this is the kernel patch for 2.6.32 for gumdroid:
user@...$> svn diff twl-core.c
Index: twl-core.c
===================================================================
--- twl-core.c (revision 9262)
+++ twl-core.c (working copy)
@@ -208,6 +208,7 @@
/* Few power values */
#define R_CFG_BOOT 0x05
+#define R_GPBR1 0x0C
#define R_PROTECT_KEY 0x0E
/* access control values for R_PROTECT_KEY */
@@ -215,6 +216,10 @@
#define KEY_UNLOCK2 0xec
#define KEY_LOCK 0x00
+/* 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)
#define HFCLK_FREQ_26_MHZ (2 << 0)
@@ -932,6 +937,12 @@
e |= unprotect_pm_master();
/* effect->MADC+USB ck en */
+
+ if (twl_has_madc())
+ e |= twl_i2c_write_u8(TWL4030_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();
Maybe the clock initialisation should be moved into kernel/drivers/mfd/twl4030-madc.c in the twl4030_madc_probe() function - but I'm sure new kernels have completely changed everything and this works as it is.
Thanks (to Steve Sakoman for the kernel patch and Scott Ellis for the madc application),
Ben
________________________________
From: Keane, Ben (STRX) [mailto:ben.keane@...]
Sent: Friday, 25 November 2011 3:07 PM
To: General mailing list for gumstix users.
Subject: [Gumstix-users] ADC on the Overo's WaterStorm
Hi,
I am wondering if anyone has some experience with using the ADC's on the Overo Waterstorm Com's or other coms that are the same?
I am using Scott Ellis' example from http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=79&Itemid=91 and code from https://github.com/scottellis/madc on my Android system (from gumdroid - 2.6.32 kernel), but I am getting an error while trying to read ADC measurements:
# madc
madc[2]: status = -1
madc[3]: status = -1
madc[4]: status = -1
madc[5]: status = -1
madc[6]: status = -1
madc[7]: status = -1
Initially I thought it might have been because of the twl4030_pwrbutton misc input button driver causing a conflict because dmesg didn't show i2c-1 but that power button instead, so I have removed that from the kernel and can now see:
# dmesg | grep i2c
i2c_omap i2c_omap.1: bus 1 rev4.0 at 2600 kHz
i2c_omap i2c_omap.3: bus 3 rev4.0 at 400 kHz
i2c /dev entries driver
--whereas before bus 1 was not there and the pwrbutton input was.
>From looking at the twl4030-madc driver source (kernel/drivers/mfd/twl4030-madc.c) it looks like the timeout of 5ms is being reached... I am unsure why this is happening and how to correct this.
Any suggestions in fixing this or doing ADC another way is greatly appreciated.
Kind Regards,
Ben Keane
PROPRIETARY: This e-mail contains proprietary information some or all of which may be legally privileged. It is intended for the recipient only. If an addressing or transmission error has misdirected this e-mail, please notify the authority by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail.
|