Fix incomplete initialization of ADC[3:6]
Subsystems (2)
PATCH 1/1 Fix incomplete initialization of ADC[3:6]
TPS65950(TWL4030) paired with OMAP3 is used in devices such as Beagleboard and Gumstix Overo COMs. Its ADCs from 3 to 6 seem to be broken [1][2][3].
The ADC readings for these pins are stuck at near 0v for these two reasons:
- 3v1 bias regulator (vusb3v1) is off unless USB-otg is being used
- pins are not configured to attach as ADC
This patch attempts to fix these issues by making sure 3v1 regulator is enabled and pins are correctly configured as ADC inputs.
[1] http://comments.gmane.org/gmane.linux.ports.arm.omap/83698
[2] http://gumstix.8.x6.nabble.com/twl4030-madc-low-read-value-td4967139.html#none
[3] https://e2e.ti.com/support/power_management/pmu/f/43/t/732
Adam YH Lee (1):
[TWL4030 MADC] Fix ADC[3:6] readings
drivers/iio/adc/twl4030-madc.c | 14 ++++++++++++++ drivers/phy/phy-twl4030-usb.c | 7 +++++++ 2 files changed, 21 insertions(+)
Signature · 1 line
2.1.4
PATCH 1/1 Fix ADC[3:6] readings
MADC[3:6] reads incorrect values without these two following changes:
- enable the 3v1 bias regulator for ADC[3:6]
- configure ADC[3:6] lines as input, not as USB
--- drivers/iio/adc/twl4030-madc.c | 14 ++++++++++++++ drivers/phy/phy-twl4030-usb.c | 7 +++++++ 2 files changed, 21 insertions(+)
drivers/iio/adc/twl4030-madc.c +14 -0
@@ -45,6 +45,7 @@#include <linux/types.h> #include <linux/gfp.h> #include <linux/err.h> +#include <linux/regulator/consumer.h> #include <linux/iio/iio.h>
@@ -52,6 +53,7 @@* struct twl4030_madc_data - a container for madc info * @dev: Pointer to device structure for madc * @lock: Mutex protecting this data structure +* @regulator: Pointer to bias regulator for madc * @requests: Array of request struct corresponding to SW1, SW2 and RT * @use_second_irq: IRQ selection (main or co-processor) * @imr: Interrupt mask register of MADC
@@ -60,6 +62,7 @@struct twl4030_madc_data {struct device *dev;struct mutex lock;/* mutex protecting this data structure */ +struct regulator *usb3v1;struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS ];bool use_second_irq;u8 imr;
@@ -848,6 +851,14 @@ static int twl4030_madc_probe(struct platform_device *pdev) goto err_i2c; } + madc->usb3v1 =devm_regulator_get (madc->dev,"vusb3v1" ); +if (IS_ERR (madc->usb3v1)) +return -ENODEV ; + + ret =regulator_enable (madc->usb3v1); +if (ret) +dev_err (madc->dev,"could not be enable 3v1 bias regulator\n" ); +return 0 ; err_i2c:
@@ -867,6 +878,9 @@ static int twl4030_madc_remove(struct platform_device *pdev)twl4030_madc_set_current_generator (madc,0 ,0 );twl4030_madc_set_power (madc,0 ); +regulator_disable (madc->usb3v1); +regulator_put (madc->usb3v1); +return 0 ; }
drivers/phy/phy-twl4030-usb.c +7 -0
@@ -144,6 +144,9 @@#define PMBR1 0x0D#define GPIO_USB_4PIN_ULPI_2430C (3 << 0) +#define TWL4030_USB_SEL_MADC_MCPC (1<<3) +#define TWL4030_USB_CARKIT_ANA_CTRL 0xBB +struct twl4030_usb {struct usb_phy phy;struct device *dev;
@@ -459,6 +462,10 @@ static int twl4030_phy_power_on(struct phy *phy)twl4030_i2c_access (twl,0 );schedule_delayed_work (&twl->id_workaround_work,0 ); +twl4030_usb_write (twl,TWL4030_USB_CARKIT_ANA_CTRL , +twl4030_usb_read (twl,TWL4030_USB_CARKIT_ANA_CTRL ) | +TWL4030_USB_SEL_MADC_MCPC ); +return 0 ; }
Signature · 1 line
2.1.4
PATCH 1/1 Fix ADC[3:6] readings
Hi,
To get a chance of this patch being considered for inclusion, you should send this to the maintainers of the phy and iio framework. There is a high chance, that none of them will see your mail.
Quoted 1 line · Adam YH Lee
MADC[3:6] reads incorrect values without these two following changes:
uhm MADC[3:6] are externally available analog inputs. Your change will result in them being tied to the USB module.
Quoted 1 line
- enable the 3v1 bias regulator for ADC[3:6]
The regulator is not required for correct MADC functionality, but for correct USB measureing. The regulator should not be requested by the madc module, but by the usb module, which is connected to the madc.
Quoted 1 line
- configure ADC[3:6] lines as input, not as USB
I don't think that should be done for all boards.
Quoted 1 line
[...]
-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150717/e0810b09/attachment.sig>
PATCH 1/1 Fix ADC[3:6] readings
Hello,
adding linux-iio...
Quoted 9 lines
To get a chance of this patch being considered for inclusion, you should send this to the maintainers of the phy and iio framework. There is a high chance, that none of them will see your mail.
Quoted 1 line · Adam YH Lee
MADC[3:6] reads incorrect values without these two following changes:
uhm MADC[3:6] are externally available analog inputs. Your change will result in them being tied to the USB module.
change regarding TWL4030_USB_SEL_MADC_MCPC is necessary at least for some hardware revisions to get proper ADC values
Quoted 6 lines
Quoted 1 line
- enable the 3v1 bias regulator for ADC[3:6]
The regulator is not required for correct MADC functionality, but for correct USB measureing. The regulator should not be requested by the madc module, but by the usb module, which is connected to the madc.
in my experience, the MADC exhibits several strange things, I wouldn't be surprised that this bias is somehow necessary for operation even if it is not what the spec says -- has this been tested?
Quoted 8 lines
Quoted 1 line
- configure ADC[3:6] lines as input, not as USB
I don't think that should be done for all boards.
Quoted 1 line
[...]
-- Sebastian
Signature · 2 lines
Peter Meerwald +43-664-2444418 (mobile)
PATCH 1/1 Fix ADC[3:6] readings
Hello, here is some more context from the TPS65950's TRM [1].
Quoting from section 15.3.1.2.1 VUSB3V1 section:
"VUSB3V1 is also used to bias analog multiplexers on the four MCPC
pins between the carkit and the MADC (supplied by VINTANA2)."
And from section 15.4.11. MADC Monitoring Using MCPC:
"Four MCPC pins can be selected as analog conversion input pins by
setting the CARKIT_ANA_CTRL[3] SEL_MADC_MCPC bit."
My patch addresses both (set the register, and enable 3v1). And yes it has been tested on Gumstix Overo COMs (OMAP3 + TPS65950).
Hope to hear from IIO maintainers!
[1] http://www.droid-developers.org/images/2/21/Tps65950_TRM.pdf
Quoted 41 lines · Peter Meerwald
Hello,
adding linux-iio...
Quoted 9 lines
To get a chance of this patch being considered for inclusion, you should send this to the maintainers of the phy and iio framework. There is a high chance, that none of them will see your mail.
Quoted 1 line · Adam YH Lee
MADC[3:6] reads incorrect values without these two following changes:
uhm MADC[3:6] are externally available analog inputs. Your change will result in them being tied to the USB module.
change regarding
TWL4030_USB_SEL_MADC_MCPCis necessary at least for some hardware revisions to get proper ADC valuesQuoted 6 lines
Quoted 1 line
- enable the 3v1 bias regulator for ADC[3:6]
The regulator is not required for correct MADC functionality, but for correct USB measureing. The regulator should not be requested by the madc module, but by the usb module, which is connected to the madc.
in my experience, the MADC exhibits several strange things, I wouldn't be surprised that this bias is somehow necessary for operation even if it is not what the spec says -- has this been tested?
Quoted 8 lines
Quoted 1 line
- configure ADC[3:6] lines as input, not as USB
I don't think that should be done for all boards.
Quoted 1 line
[...]
-- Sebastian
--
Peter Meerwald
+43-664-2444418 (mobile)
Jonathan Cameron
maintainerPATCH 1/1 Fix ADC[3:6] readings
Quoted 10 lines · Adam Lee
Hello, here is some more context from the TPS65950's TRM [1].
Quoting from section 15.3.1.2.1 VUSB3V1 section:
"VUSB3V1 is also used to bias analog multiplexers on the four MCPC
pins between the carkit and the MADC (supplied by VINTANA2)."And from section 15.4.11. MADC Monitoring Using MCPC:
Quoted 7 lines
"Four MCPC pins can be selected as analog conversion input pins by
setting the CARKIT_ANA_CTRL[3]SEL_MADC_MCPCbit."My patch addresses both (set the register, and enable 3v1). And yes it has been tested on Gumstix Overo COMs (OMAP3 + TPS65950).
Hope to hear from IIO maintainers!
I dug the patch out of the archives.
Looks clear enough to me. Could you resend the patch with linux-iio cc'd? I will want an Ack from Sebastian.
Thanks,
Jonathan
Quoted 50 lines
[1] http://www.droid-developers.org/images/2/21/Tps65950_TRM.pdf
Quoted 34 lines · Peter Meerwald
Hello,
adding linux-iio...
Quoted 9 lines
To get a chance of this patch being considered for inclusion, you should send this to the maintainers of the phy and iio framework. There is a high chance, that none of them will see your mail.
Quoted 1 line · Adam YH Lee
MADC[3:6] reads incorrect values without these two following changes:
uhm MADC[3:6] are externally available analog inputs. Your change will result in them being tied to the USB module.
change regarding
TWL4030_USB_SEL_MADC_MCPCis necessary at least for some hardware revisions to get proper ADC valuesQuoted 6 lines
Quoted 1 line
- enable the 3v1 bias regulator for ADC[3:6]
The regulator is not required for correct MADC functionality, but for correct USB measureing. The regulator should not be requested by the madc module, but by the usb module, which is connected to the madc.
in my experience, the MADC exhibits several strange things, I wouldn't be surprised that this bias is somehow necessary for operation even if it is not what the spec says -- has this been tested?
Quoted 6 lines
Quoted 1 line
- configure ADC[3:6] lines as input, not as USB
I don't think that should be done for all boards.
Quoted 1 line
[...]
Quoted 7 lines
Quoted 2 lines
-- Sebastian
--
Peter Meerwald
+43-664-2444418 (mobile)--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 Fix ADC[3:6] readings
Hello Jonathan, I sent the same patch with linux-iio cc'd. I expanded the cover letter with the quotes from TI's documents, but the text has been removed in the email somehow.
The discussion in this thread should be enough (I think) for linux-iio maintainers, so we will see!
Thanks,
Adam
Quoted 78 lines · Jonathan Cameron
Quoted 10 lines · Adam Lee
Hello, here is some more context from the TPS65950's TRM [1].
Quoting from section 15.3.1.2.1 VUSB3V1 section:
"VUSB3V1 is also used to bias analog multiplexers on the four MCPC
pins between the carkit and the MADC (supplied by VINTANA2)."And from section 15.4.11. MADC Monitoring Using MCPC:
Quoted 7 lines
"Four MCPC pins can be selected as analog conversion input pins by
setting the CARKIT_ANA_CTRL[3]SEL_MADC_MCPCbit."My patch addresses both (set the register, and enable 3v1). And yes it has been tested on Gumstix Overo COMs (OMAP3 + TPS65950).
Hope to hear from IIO maintainers!
I dug the patch out of the archives.
Looks clear enough to me. Could you resend the patch with linux-iio cc'd? I will want an Ack from Sebastian.
Thanks,
Jonathan
Quoted 50 lines
[1] http://www.droid-developers.org/images/2/21/Tps65950_TRM.pdf
Quoted 34 lines · Peter Meerwald
Hello,
adding linux-iio...
Quoted 9 lines
To get a chance of this patch being considered for inclusion, you should send this to the maintainers of the phy and iio framework. There is a high chance, that none of them will see your mail.
Quoted 1 line · Adam YH Lee
MADC[3:6] reads incorrect values without these two following changes:
uhm MADC[3:6] are externally available analog inputs. Your change will result in them being tied to the USB module.
change regarding
TWL4030_USB_SEL_MADC_MCPCis necessary at least for some hardware revisions to get proper ADC valuesQuoted 6 lines
Quoted 1 line
- enable the 3v1 bias regulator for ADC[3:6]
The regulator is not required for correct MADC functionality, but for correct USB measureing. The regulator should not be requested by the madc module, but by the usb module, which is connected to the madc.
in my experience, the MADC exhibits several strange things, I wouldn't be surprised that this bias is somehow necessary for operation even if it is not what the spec says -- has this been tested?
Quoted 6 lines
Quoted 1 line
- configure ADC[3:6] lines as input, not as USB
I don't think that should be done for all boards.
Quoted 1 line
[...]
Quoted 7 lines
Quoted 2 lines
-- Sebastian
--
Peter Meerwald
+43-664-2444418 (mobile)--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html