Skip to content

Commit b7ef0c5

Browse files
kylemannagregkh
authored andcommitted
mfd: Turn on the twl4030-madc MADC clock
commit 3d6271f upstream. 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> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent d5700ae commit b7ef0c5

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎drivers/mfd/twl4030-madc.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,28 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev)
740740
TWL4030_BCI_BCICTL1);
741741
goto err_i2c;
742742
}
743+
744+
/* Check that MADC clock is on */
745+
ret = twl_i2c_read_u8(TWL4030_MODULE_INTBR, &regval, TWL4030_REG_GPBR1);
746+
if (ret) {
747+
dev_err(&pdev->dev, "unable to read reg GPBR1 0x%X\n",
748+
TWL4030_REG_GPBR1);
749+
goto err_i2c;
750+
}
751+
752+
/* If MADC clk is not on, turn it on */
753+
if (!(regval & TWL4030_GPBR1_MADC_HFCLK_EN)) {
754+
dev_info(&pdev->dev, "clk disabled, enabling\n");
755+
regval |= TWL4030_GPBR1_MADC_HFCLK_EN;
756+
ret = twl_i2c_write_u8(TWL4030_MODULE_INTBR, regval,
757+
TWL4030_REG_GPBR1);
758+
if (ret) {
759+
dev_err(&pdev->dev, "unable to write reg GPBR1 0x%X\n",
760+
TWL4030_REG_GPBR1);
761+
goto err_i2c;
762+
}
763+
}
764+
743765
platform_set_drvdata(pdev, madc);
744766
mutex_init(&madc->lock);
745767
ret = request_threaded_irq(platform_get_irq(pdev, 0), NULL,

‎include/linux/i2c/twl4030-madc.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ enum sample_type {
129129
#define REG_BCICTL2 0x024
130130
#define TWL4030_BCI_ITHSENS 0x007
131131

132+
/* Register and bits for GPBR1 register */
133+
#define TWL4030_REG_GPBR1 0x0c
134+
#define TWL4030_GPBR1_MADC_HFCLK_EN (1 << 7)
135+
132136
struct twl4030_madc_user_parms {
133137
int channel;
134138
int average;

0 commit comments

Comments
 (0)