linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kyle Manna <kyle@kylemanna.com>
To: Tony Lindgren <tony@atomide.com>,
	Russell King <linux@arm.linux.org.uk>,
	Samuel Ortiz <sameo@linux.intel.com>
Cc: Keerthy <j-keerthy@ti.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Kyle Manna <kyle@kylemanna.com>
Subject: [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock
Date: Thu, 11 Aug 2011 22:33:13 -0500	[thread overview]
Message-ID: <1313119995-15382-3-git-send-email-kyle@kylemanna.com> (raw)
In-Reply-To: <1313119995-15382-1-git-send-email-kyle@kylemanna.com>

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


  parent reply	other threads:[~2011-08-12  3:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11  3:27 [PATCH 0/3] Fixes to twl4030-madc and add BeagleBoard support Kyle Manna
2011-08-11  3:27 ` [PATCH 1/3] twl4030-madc: copy the device pointer Kyle Manna
2011-08-11  9:50   ` Grazvydas Ignotas
2011-08-11  3:27 ` [PATCH 2/3] twl4030-madc: turn on the MADC clock Kyle Manna
2011-08-11  9:55   ` Grazvydas Ignotas
2011-08-11  3:27 ` [PATCH 3/3] BeagleBoard: add support for the twl4030-madc Kyle Manna
2011-08-11  9:44   ` Grazvydas Ignotas
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313119995-15382-3-git-send-email-kyle@kylemanna.com \
    --to=kyle@kylemanna.com \
    --cc=j-keerthy@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=sameo@linux.intel.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).