* [PATCH] Fix incomplete initialization of ADC[3:6]
@ 2015-07-16 22:20 Adam YH Lee
0 siblings, 0 replies; 5+ messages in thread
From: Adam YH Lee @ 2015-07-16 22:20 UTC (permalink / raw)
To: linux-arm-kernel
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(+)
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Fix incomplete initialization of ADC[3:6]$
@ 2015-07-20 18:14 Adam YH Lee
2015-07-20 18:14 ` [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings Adam YH Lee
0 siblings, 1 reply; 5+ messages in thread
From: Adam YH Lee @ 2015-07-20 18:14 UTC (permalink / raw)
To: linux-arm-kernel
Additionally the original discussion for this patch can be found here [5].
$
[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$
[4] http://www.droid-developers.org/images/2/21/Tps65950_TRM.pdf$
[5] http://www.spinics.net/lists/linux-omap/msg120300.html
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(+)
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings
2015-07-20 18:14 [PATCH] Fix incomplete initialization of ADC[3:6]$ Adam YH Lee
@ 2015-07-20 18:14 ` Adam YH Lee
2015-07-20 18:54 ` Peter Meerwald
0 siblings, 1 reply; 5+ messages in thread
From: Adam YH Lee @ 2015-07-20 18:14 UTC (permalink / raw)
To: linux-arm-kernel
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
Signed-off-by: Adam YH Lee <adam.yh.lee@gmail.com>
---
drivers/iio/adc/twl4030-madc.c | 14 ++++++++++++++
drivers/phy/phy-twl4030-usb.c | 7 +++++++
2 files changed, 21 insertions(+)
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index 94c5f05..b5020ab 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -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;
}
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 7b04bef..88fc7d7 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -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;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings
2015-07-20 18:14 ` [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings Adam YH Lee
@ 2015-07-20 18:54 ` Peter Meerwald
2015-07-20 19:19 ` Adam Lee
0 siblings, 1 reply; 5+ messages in thread
From: Peter Meerwald @ 2015-07-20 18:54 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 20 Jul 2015, Adam YH Lee wrote:
> 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
comments below
> Signed-off-by: Adam YH Lee <adam.yh.lee@gmail.com>
> ---
> drivers/iio/adc/twl4030-madc.c | 14 ++++++++++++++
> drivers/phy/phy-twl4030-usb.c | 7 +++++++
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 94c5f05..b5020ab 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -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");
please fix wording, "could not enable usb 3v1 bias regulator" probably
> +
> 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;
> }
>
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> index 7b04bef..88fc7d7 100644
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -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);
> +
shouldn't this be done is the adc driver?
> return 0;
> }
>
>
--
Peter Meerwald
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings
2015-07-20 18:54 ` Peter Meerwald
@ 2015-07-20 19:19 ` Adam Lee
0 siblings, 0 replies; 5+ messages in thread
From: Adam Lee @ 2015-07-20 19:19 UTC (permalink / raw)
To: linux-arm-kernel
Hi Peter, I sent a V2 with corrected wording. My bad!
And yes I agree that register setting should be done in the ADC driver.
Let me see what I can do, and will report back.
Thanks,
Adam
On Mon, Jul 20, 2015 at 11:54 AM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
> On Mon, 20 Jul 2015, Adam YH Lee wrote:
>
>> 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
>
> comments below
>
>> Signed-off-by: Adam YH Lee <adam.yh.lee@gmail.com>
>> ---
>> drivers/iio/adc/twl4030-madc.c | 14 ++++++++++++++
>> drivers/phy/phy-twl4030-usb.c | 7 +++++++
>> 2 files changed, 21 insertions(+)
>>
>> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
>> index 94c5f05..b5020ab 100644
>> --- a/drivers/iio/adc/twl4030-madc.c
>> +++ b/drivers/iio/adc/twl4030-madc.c
>> @@ -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");
>
> please fix wording, "could not enable usb 3v1 bias regulator" probably
>
>> +
>> 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;
>> }
>>
>> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
>> index 7b04bef..88fc7d7 100644
>> --- a/drivers/phy/phy-twl4030-usb.c
>> +++ b/drivers/phy/phy-twl4030-usb.c
>> @@ -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);
>> +
>
> shouldn't this be done is the adc driver?
>
>> return 0;
>> }
>>
>>
>
> --
>
> Peter Meerwald
> +43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-20 19:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-20 18:14 [PATCH] Fix incomplete initialization of ADC[3:6]$ Adam YH Lee
2015-07-20 18:14 ` [PATCH] [TWL4030 MADC] Fix ADC[3:6] readings Adam YH Lee
2015-07-20 18:54 ` Peter Meerwald
2015-07-20 19:19 ` Adam Lee
-- strict thread matches above, loose matches on Subject: below --
2015-07-16 22:20 [PATCH] Fix incomplete initialization of ADC[3:6] Adam YH Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).