public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support
       [not found] <CANOLnOPB=wFMPwqGbu9ufh__iM7TquUx3-o95R=gyJcae+gENg@mail.gmail.com>
@ 2011-08-12  3:33 ` Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 1/4] mfd: twl4030-madc: copy the device pointer Kyle Manna
                     ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Kyle Manna @ 2011-08-12  3:33 UTC (permalink / raw)
  To: Tony Lindgren, Russell King, Samuel Ortiz
  Cc: Keerthy, linux-omap, linux-arm-kernel, linux-kernel, Kyle Manna

These patches add basic functionality to the twl4030-madc driver to make
it work on the BeagleBoard xM.

Version 2 adds fixes per Grazvydas Ignotas and the check for NULL pointer patch.

Kyle Manna (4):
  mfd: twl4030-madc: copy the device pointer
  mfd: twl4030-madc: turn on the MADC clock
  mfd: twl4030-madc: check for NULL pointer
  arm: BeagleBoard: add support for the twl4030-madc

 arch/arm/mach-omap2/board-omap3beagle.c |    9 ++++++++-
 drivers/mfd/twl4030-madc.c              |   27 ++++++++++++++++++++++++++-
 include/linux/i2c/twl4030-madc.h        |    4 ++++
 3 files changed, 38 insertions(+), 2 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] mfd: twl4030-madc: copy the device pointer
  2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
@ 2011-08-12  3:33   ` Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock Kyle Manna
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Kyle Manna @ 2011-08-12  3:33 UTC (permalink / raw)
  To: Tony Lindgren, Russell King, Samuel Ortiz
  Cc: Keerthy, linux-omap, linux-arm-kernel, linux-kernel, Kyle Manna

Worst case this fixes the following error:
[   72.086212] (NULL device *): conversion timeout!

Best case it prevents a crash

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
---
 drivers/mfd/twl4030-madc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index b5d598c..cb44b53 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -706,6 +706,8 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev)
 	if (!madc)
 		return -ENOMEM;
 
+	madc->dev = &pdev->dev;
+
 	/*
 	 * Phoenix provides 2 interrupt lines. The first one is connected to
 	 * the OMAP. The other one can be connected to the other processor such
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock
  2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 1/4] mfd: twl4030-madc: copy the device pointer Kyle Manna
@ 2011-08-12  3:33   ` Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 3/4] mfd: twl4030-madc: check for NULL pointer Kyle Manna
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Kyle Manna @ 2011-08-12  3:33 UTC (permalink / raw)
  To: Tony Lindgren, Russell King, Samuel Ortiz
  Cc: Keerthy, linux-omap, linux-arm-kernel, linux-kernel, Kyle Manna

Without turning the MADC clock on, no MADC conversions occur.

$ cat /sys/class/hwmon/hwmon0/device/in8_input
[   53.428436] twl4030_madc twl4030_madc: conversion timeout!
cat: read error: Resource temporarily unavailable

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
---
 drivers/mfd/twl4030-madc.c       |   22 ++++++++++++++++++++++
 include/linux/i2c/twl4030-madc.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index cb44b53..99dd611 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -739,6 +739,28 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev)
 			TWL4030_BCI_BCICTL1);
 		goto err_i2c;
 	}
+
+	/* Check that MADC clock is on */
+	ret = twl_i2c_read_u8(TWL4030_MODULE_INTBR, &regval, TWL4030_REG_GPBR1);
+	if (ret) {
+		dev_err(&pdev->dev, "unable to read reg GPBR1 0x%X\n",
+				TWL4030_REG_GPBR1);
+		goto err_i2c;
+	}
+
+	/* If MADC clk is not on, turn it on */
+	if (!(regval & TWL4030_GPBR1_MADC_HFCLK_EN)) {
+		dev_info(&pdev->dev, "clk disabled, enabling\n");
+		regval |= TWL4030_GPBR1_MADC_HFCLK_EN;
+		ret = twl_i2c_write_u8(TWL4030_MODULE_INTBR, regval,
+				       TWL4030_REG_GPBR1);
+		if (ret) {
+			dev_err(&pdev->dev, "unable to write reg GPBR1 0x%X\n",
+					TWL4030_REG_GPBR1);
+			goto err_i2c;
+		}
+	}
+
 	platform_set_drvdata(pdev, madc);
 	mutex_init(&madc->lock);
 	ret = request_threaded_irq(platform_get_irq(pdev, 0), NULL,
diff --git a/include/linux/i2c/twl4030-madc.h b/include/linux/i2c/twl4030-madc.h
index 6427d29..530e11b 100644
--- a/include/linux/i2c/twl4030-madc.h
+++ b/include/linux/i2c/twl4030-madc.h
@@ -129,6 +129,10 @@ enum sample_type {
 #define REG_BCICTL2             0x024
 #define TWL4030_BCI_ITHSENS	0x007
 
+/* Register and bits for GPBR1 register */
+#define TWL4030_REG_GPBR1		0x0c
+#define TWL4030_GPBR1_MADC_HFCLK_EN	(1 << 7)
+
 struct twl4030_madc_user_parms {
 	int channel;
 	int average;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] mfd: twl4030-madc: check for NULL pointer
  2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 1/4] mfd: twl4030-madc: copy the device pointer Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock Kyle Manna
@ 2011-08-12  3:33   ` Kyle Manna
  2011-08-12  3:33   ` [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc Kyle Manna
  2011-08-22 13:55   ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Samuel Ortiz
  4 siblings, 0 replies; 9+ messages in thread
From: Kyle Manna @ 2011-08-12  3:33 UTC (permalink / raw)
  To: Tony Lindgren, Russell King, Samuel Ortiz
  Cc: Keerthy, linux-omap, linux-arm-kernel, linux-kernel, Kyle Manna

If the twl4030-madc device wasn't registered, and another device, such
as twl4030-madc-hwmon, calls twl4030_madc_conversion() a NULL pointer is
dereferenced.

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
---
 drivers/mfd/twl4030-madc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index 99dd611..834f824 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -510,8 +510,9 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
 	u8 ch_msb, ch_lsb;
 	int ret;
 
-	if (!req)
+	if (!req || !twl4030_madc)
 		return -EINVAL;
+
 	mutex_lock(&twl4030_madc->lock);
 	if (req->method < TWL4030_MADC_RT || req->method > TWL4030_MADC_SW2) {
 		ret = -EINVAL;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc
  2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
                     ` (2 preceding siblings ...)
  2011-08-12  3:33   ` [PATCH v2 3/4] mfd: twl4030-madc: check for NULL pointer Kyle Manna
@ 2011-08-12  3:33   ` Kyle Manna
  2011-09-28 18:31     ` Tony Lindgren
  2011-08-22 13:55   ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Samuel Ortiz
  4 siblings, 1 reply; 9+ messages in thread
From: Kyle Manna @ 2011-08-12  3:33 UTC (permalink / raw)
  To: Tony Lindgren, Russell King, Samuel Ortiz
  Cc: Keerthy, linux-omap, linux-arm-kernel, linux-kernel, Kyle Manna

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 3ae16b4..9cc9fa9 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -378,7 +378,8 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
 static int __init omap3_beagle_i2c_init(void)
 {
 	omap3_pmic_get_config(&beagle_twldata,
-			TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
+			TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC |
+			TWL_COMMON_PDATA_AUDIO,
 			TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
 
 	beagle_twldata.vpll2->constraints.name = "VDVI";
@@ -456,9 +457,15 @@ static void __init omap3_beagle_init_irq(void)
 	omap3_init_irq();
 }
 
+static struct platform_device madc_hwmon = {
+	.name	= "twl4030_madc_hwmon",
+	.id	= -1,
+};
+
 static struct platform_device *omap3_beagle_devices[] __initdata = {
 	&leds_gpio,
 	&keys_gpio,
+	&madc_hwmon,
 };
 
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support
  2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
                     ` (3 preceding siblings ...)
  2011-08-12  3:33   ` [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc Kyle Manna
@ 2011-08-22 13:55   ` Samuel Ortiz
  2011-09-28 18:32     ` Tony Lindgren
  4 siblings, 1 reply; 9+ messages in thread
From: Samuel Ortiz @ 2011-08-22 13:55 UTC (permalink / raw)
  To: Kyle Manna
  Cc: Tony Lindgren, Russell King, Keerthy, linux-omap,
	linux-arm-kernel, linux-kernel

Hi Kyle,

On Thu, Aug 11, 2011 at 10:33:11PM -0500, Kyle Manna wrote:
> These patches add basic functionality to the twl4030-madc driver to make
> it work on the BeagleBoard xM.
> 
> Version 2 adds fixes per Grazvydas Ignotas and the check for NULL pointer patch.
> 
> Kyle Manna (4):
>   mfd: twl4030-madc: copy the device pointer
>   mfd: twl4030-madc: turn on the MADC clock
>   mfd: twl4030-madc: check for NULL pointer
>   arm: BeagleBoard: add support for the twl4030-madc
Tony, are you ok with the BeagleBoard changes ?
The MFD ones look fine to me, I'd like to apply them.

Cheers,
Samuel.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc
  2011-08-12  3:33   ` [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc Kyle Manna
@ 2011-09-28 18:31     ` Tony Lindgren
  0 siblings, 0 replies; 9+ messages in thread
From: Tony Lindgren @ 2011-09-28 18:31 UTC (permalink / raw)
  To: Kyle Manna
  Cc: Russell King, Samuel Ortiz, Keerthy, linux-omap, linux-arm-kernel,
	linux-kernel

* Kyle Manna <kyle@kylemanna.com> [110811 20:01]:
> Signed-off-by: Kyle Manna <kyle@kylemanna.com>

Missing description, but with that corrected:

Acked-by: Tony Lindgren <tony@atomide.com>

> ---
>  arch/arm/mach-omap2/board-omap3beagle.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index 3ae16b4..9cc9fa9 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -378,7 +378,8 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
>  static int __init omap3_beagle_i2c_init(void)
>  {
>  	omap3_pmic_get_config(&beagle_twldata,
> -			TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
> +			TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC |
> +			TWL_COMMON_PDATA_AUDIO,
>  			TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
>  
>  	beagle_twldata.vpll2->constraints.name = "VDVI";
> @@ -456,9 +457,15 @@ static void __init omap3_beagle_init_irq(void)
>  	omap3_init_irq();
>  }
>  
> +static struct platform_device madc_hwmon = {
> +	.name	= "twl4030_madc_hwmon",
> +	.id	= -1,
> +};
> +
>  static struct platform_device *omap3_beagle_devices[] __initdata = {
>  	&leds_gpio,
>  	&keys_gpio,
> +	&madc_hwmon,
>  };
>  
>  static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> -- 
> 1.7.4.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support
  2011-08-22 13:55   ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Samuel Ortiz
@ 2011-09-28 18:32     ` Tony Lindgren
  2011-10-04 10:28       ` Samuel Ortiz
  0 siblings, 1 reply; 9+ messages in thread
From: Tony Lindgren @ 2011-09-28 18:32 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Kyle Manna, Russell King, Keerthy, linux-omap, linux-arm-kernel,
	linux-kernel

* Samuel Ortiz <sameo@linux.intel.com> [110822 06:20]:
> Hi Kyle,
> 
> On Thu, Aug 11, 2011 at 10:33:11PM -0500, Kyle Manna wrote:
> > These patches add basic functionality to the twl4030-madc driver to make
> > it work on the BeagleBoard xM.
> > 
> > Version 2 adds fixes per Grazvydas Ignotas and the check for NULL pointer patch.
> > 
> > Kyle Manna (4):
> >   mfd: twl4030-madc: copy the device pointer
> >   mfd: twl4030-madc: turn on the MADC clock
> >   mfd: twl4030-madc: check for NULL pointer
> >   arm: BeagleBoard: add support for the twl4030-madc
> Tony, are you ok with the BeagleBoard changes ?
> The MFD ones look fine to me, I'd like to apply them.

Yes sorry for the delay in replying. I acked it, maybe
you can just copy the subject to have a proper description
for the patch.

Tony

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support
  2011-09-28 18:32     ` Tony Lindgren
@ 2011-10-04 10:28       ` Samuel Ortiz
  0 siblings, 0 replies; 9+ messages in thread
From: Samuel Ortiz @ 2011-10-04 10:28 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kyle Manna, Russell King, Keerthy, linux-omap, linux-arm-kernel,
	linux-kernel

Hi Tony,

On Wed, Sep 28, 2011 at 11:32:31AM -0700, Tony Lindgren wrote:
> * Samuel Ortiz <sameo@linux.intel.com> [110822 06:20]:
> > Hi Kyle,
> > 
> > On Thu, Aug 11, 2011 at 10:33:11PM -0500, Kyle Manna wrote:
> > > These patches add basic functionality to the twl4030-madc driver to make
> > > it work on the BeagleBoard xM.
> > > 
> > > Version 2 adds fixes per Grazvydas Ignotas and the check for NULL pointer patch.
> > > 
> > > Kyle Manna (4):
> > >   mfd: twl4030-madc: copy the device pointer
> > >   mfd: twl4030-madc: turn on the MADC clock
> > >   mfd: twl4030-madc: check for NULL pointer
> > >   arm: BeagleBoard: add support for the twl4030-madc
> > Tony, are you ok with the BeagleBoard changes ?
> > The MFD ones look fine to me, I'd like to apply them.
> 
> Yes sorry for the delay in replying. I acked it, maybe
> you can just copy the subject to have a proper description
> for the patch.
I actually pushed the 3 MFD patches already.
I think you can safely take the beagle one through your tree.

Cheers,
Samuel.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-10-04 10:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CANOLnOPB=wFMPwqGbu9ufh__iM7TquUx3-o95R=gyJcae+gENg@mail.gmail.com>
2011-08-12  3:33 ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
2011-08-12  3:33   ` [PATCH v2 1/4] mfd: twl4030-madc: copy the device pointer Kyle Manna
2011-08-12  3:33   ` [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock Kyle Manna
2011-08-12  3:33   ` [PATCH v2 3/4] mfd: twl4030-madc: check for NULL pointer Kyle Manna
2011-08-12  3:33   ` [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc Kyle Manna
2011-09-28 18:31     ` Tony Lindgren
2011-08-22 13:55   ` [PATCH v2 0/4] Fixes to twl4030-madc and add BeagleBoard support Samuel Ortiz
2011-09-28 18:32     ` Tony Lindgren
2011-10-04 10:28       ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox