Fixes to twl4030-madc and add BeagleBoard support
cover Fixes to twl4030-madc and add BeagleBoard support
These patches add basic functionality to the twl4030-madc driver to make it work on the BeagleBoard xM. These patches were also tested on a OMAP3EVM.
Kyle Manna (3):
twl4030-madc: copy the device pointer
twl4030-madc: turn on the MADC clock
BeagleBoard: add support for the twl4030-madc
arch/arm/mach-omap2/board-omap3beagle.c | 11 +++++++++++ drivers/mfd/twl4030-madc.c | 27 ++++++++++++++++++++++++++- include/linux/i2c/twl4030-madc.h | 4 ++++ 3 files changed, 41 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/3 twl4030-madc: copy the device pointer
Worst case this fixes the following error:
[ 72.086212] (NULL device *): conversion timeout!
Best case it prevents a crash
--- drivers/mfd/twl4030-madc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/mfd/twl4030-madc.c +4 -1
@@ -706,6 +706,9 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev)if (!madc)return -ENOMEM ; +/* Copy the pointer to device struct */ + 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
@@ -733,7 +736,7 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev) ret =twl_i2c_write_u8 (TWL4030_MODULE_MAIN_CHARGE , regval,TWL4030_BCI_BCICTL1 );if (ret) { -dev_err (&pdev->dev,"unable to write reg BCI Ctl1 0x%X\n" , +dev_err (&pdev->dev,"unable to write reg BCI CTL1 0x%X\n" ,TWL4030_BCI_BCICTL1 ); goto err_i2c; }
Signature · 1 line
1.7.4.1
PATCH 2/3 twl4030-madc: turn on the MADC clock
In reply to Kyle MannaWithout 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
--- drivers/mfd/twl4030-madc.c | 22 ++++++++++++++++++++++ include/linux/i2c/twl4030-madc.h | 4 ++++ 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-madc.c +22 -0
@@ -740,6 +740,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 , ®val,TWL4030_REG_GPBR1 ); +if (ret) { +dev_err (&pdev->dev,"unable to read reg GPBR1 0x%X\n" , +TWL4030_REG_GPBR1 ); + } + +/* 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,
include/linux/i2c/twl4030-madc.h +4 -0
@@ -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;
Signature · 1 line
1.7.4.1
PATCH 3/3 BeagleBoard: add support for the twl4030-madc
In reply to Kyle Manna--- arch/arm/mach-omap2/board-omap3beagle.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +11 -0
@@ -362,11 +362,16 @@ static struct regulator_init_data beagle_vsim = { .consumer_supplies = beagle_vsim_supply, }; +static struct twl4030_madc_platform_data beagle_madc = { + .irq_line =1 , +}; +static struct twl4030_platform_data beagle_twldata = {/* platform_data for children goes here */ .gpio = &beagle_gpio_data, .vmmc1 = &beagle_vmmc1, .vsim = &beagle_vsim, + .madc = &beagle_madc, };static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
@@ -456,9 +461,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 = {
Signature · 1 line
1.7.4.1
Re: [PATCH 3/3] BeagleBoard: add support for the twl4030-madc
You need to CC linux-arm-kernel too.
Quoted 14 lines · Kyle Manna
Signed-off-by Kyle Manna <[email protected]>---
arch/arm/mach-omap2/board-omap3beagle.c | 11 +++++++++++1 files changed, 11 insertions(+), 0 deletions(-)arch/arm/mach-omap2/board-omap3beagle.c +1
-0@@ -362,11 +362,16 @@ static struct regulator_init_data beagle_vsim = { .consumer_supplies = beagle_vsim_supply, }; +static struct twl4030_madc_platform_data beagle_madc = {
arch/arm/mach-omap2/board-omap3beagle.c static struct regulator_init_data beagle_vsim = { · line 375
Quoted 10 lines
arch/arm/mach-omap2/board-omap3beagle.c +4
-0+ .irq_line = 1, +}; + static struct twl4030_platform_data beagle_twldata = { /* platform_data for children goes here */ .gpio = &beagle_gpio_data, .vmmc1 = &beagle_vmmc1, .vsim = &beagle_vsim, + .madc = &beagle_madc, };
Basically all boards with twl4030 might want to have this, maybe add this to twl-common.c instead to avoid code duplication?
Signature · 5 lines
Gražvydas -- 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
Re: [PATCH 1/3] twl4030-madc: copy the device pointer
In reply to Kyle MannaYou need to send this one to mfd maintainer, separate from this series perhaps (see MAINTAINERS or just use ./scripts/get_maintainer.pl).
Quoted 15 lines · 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 <[email protected]>---
drivers/mfd/twl4030-madc.c | 5 ++++-1 files changed, 4 insertions(+), 1 deletions(-)drivers/mfd/twl4030-madc.c +0
-0
drivers/mfd/twl4030-madc.c static int __devinit twl4030_madc_probe(struct platform_device *pdev) · line 711
Quoted 6 lines
drivers/mfd/twl4030-madc.c +3
-0@@ -706,6 +706,9 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev) if (!madc) return -ENOMEM; + /* Copy the pointer to device struct */ + madc->dev = &pdev->dev; +
This comment is not useful, it's already clear you are copying a pointer.
drivers/mfd/twl4030-madc.c static int __devinit twl4030_madc_probe(struct platform_device *pdev) · line 740
Quoted 10 lines
drivers/mfd/twl4030-madc.c +1
-1/** Phoenix provides 2 interrupt lines. The first one is connected to * the OMAP. The other one can be connected to the other processor such @@ -733,7 +736,7 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev) ret = twl_i2c_write_u8(TWL4030_MODULE_MAIN_CHARGE, regval, TWL4030_BCI_BCICTL1); if (ret) { - dev_err(&pdev->dev, "unable to write reg BCI Ctl1 0x%X\n", + dev_err(&pdev->dev, "unable to write reg BCI CTL1 0x%X\n", TWL4030_BCI_BCICTL1);
Stray change (no mention in commit message), should not be part of this patch.
Quoted 10 lines
drivers/mfd/twl4030-madc.c +0
-1goto err_i2c; } --1.7.4.1
--
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
Signature · 5 lines
Gražvydas -- 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
Re: [PATCH 2/3] twl4030-madc: turn on the MADC clock
In reply to Kyle MannaThis one needs to go to mfd maintainer too.
Quoted 20 lines · 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 unavailableSigned-off-by Kyle Manna <[email protected]>---
drivers/mfd/twl4030-madc.c | 22 ++++++++++++++++++++++include/linux/i2c/twl4030-madc.h| 4 ++++2 files changed, 26 insertions(+), 0 deletions(-)drivers/mfd/twl4030-madc.c +0
-0@@ -740,6 +740,28 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev) TWL4030_BCI_BCICTL1); goto err_i2c; }
drivers/mfd/twl4030-madc.c static int __devinit twl4030_madc_probe(struct platform_device *pdev) · line 752
Quoted 10 lines
drivers/mfd/twl4030-madc.c +10
-0+ + /* Check that MADC clock is on */ + ret = twl_i2c_read_u8(TWL4030_MODULE_INTBR, ®val, TWL4030_REG_GPBR1); + if (ret) { + dev_err(&pdev->dev, "unable to read reg GPBR1 0x%X\n", + TWL4030_REG_GPBR1); + } + + /* If MADC clk is not on, turn it on */ + if (!(regval & TWL4030_GPBR1_MADC_HFCLK_EN)) {
You should check if above read failed before using regval - you might end up writing trash to GPBR1..
drivers/mfd/twl4030-madc.c static int __devinit twl4030_madc_probe(struct platform_device *pdev) · line 764
Quoted 12 lines
drivers/mfd/twl4030-madc.c +12
-0+ 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; + } + } + +
Single newline is enough.
--
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
v2 cover Fixes to twl4030-madc and add BeagleBoard support
In reply to Grazvydas IgnotasThese 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(-)
Signature · 1 line
1.7.4.1
PATCH v2 1/4 mfd: twl4030-madc: copy the device pointer
Worst case this fixes the following error:
[ 72.086212] (NULL device *): conversion timeout!
Best case it prevents a crash
--- drivers/mfd/twl4030-madc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-madc.c +2 -0
@@ -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
Signature · 1 line
1.7.4.1
PATCH v2 2/4 mfd: twl4030-madc: turn on the MADC clock
In reply to Kyle MannaWithout 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
--- drivers/mfd/twl4030-madc.c | 22 ++++++++++++++++++++++ include/linux/i2c/twl4030-madc.h | 4 ++++ 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-madc.c +22 -0
@@ -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 , ®val,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,
include/linux/i2c/twl4030-madc.h +4 -0
@@ -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;
Signature · 1 line
1.7.4.1
PATCH v2 3/4 mfd: twl4030-madc: check for NULL pointer
In reply to Kyle MannaIf the twl4030-madc device wasn't registered, and another device, such as twl4030-madc-hwmon, calls twl4030_madc_conversion() a NULL pointer is dereferenced.
--- drivers/mfd/twl4030-madc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mfd/twl4030-madc.c +2 -1
@@ -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 ;
Signature · 1 line
1.7.4.1
PATCH v2 4/4 arm: BeagleBoard: add support for the twl4030-madc
In reply to Kyle Manna--- arch/arm/mach-omap2/board-omap3beagle.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +8 -1
@@ -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 = {
Signature · 1 line
1.7.4.1
Hi Kyle,
Quoted 10 lines · 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
Tony, are you ok with the BeagleBoard changes ? The MFD ones look fine to me, I'd like to apply them.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Re: [PATCH v2 4/4] arm: BeagleBoard: add support for the twl4030-madc
In reply to Kyle MannaQuoted 1 line · Kyle Manna
Signed-off-by Kyle Manna <[email protected]>
Missing description, but with that corrected:
Quoted 37 lines
--- arch/arm/mach-omap2/board-omap3beagle.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)arch/arm/mach-omap2/board-omap3beagle.c +8
-1@@ -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 = {Signature · 1 line
1.7.4.1
Tony Lindgren
maintainerQuoted 8 lines · Samuel Ortiz
Hi Kyle,
Quoted 5 lines · 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.
Quoted 7 lines
Quoted 5 lines
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-madcTony, 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
Hi Tony,
Quoted 14 lines · Tony Lindgren
Quoted 13 lines · Samuel Ortiz
Hi Kyle,
Quoted 10 lines · 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
Quoted 6 lines
Quoted 2 lines
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.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/