From patchwork Fri Aug 12 03:33:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Manna X-Patchwork-Id: 1059542 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7C3Y4i8018539 for ; Fri, 12 Aug 2011 03:34:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942Ab1HLDeD (ORCPT ); Thu, 11 Aug 2011 23:34:03 -0400 Received: from caiajhbdcagg.dreamhost.com ([208.97.132.66]:43748 "EHLO homiemail-a67.g.dreamhost.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752282Ab1HLDeB (ORCPT ); Thu, 11 Aug 2011 23:34:01 -0400 Received: from homiemail-a67.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a67.g.dreamhost.com (Postfix) with ESMTP id 242F388069; Thu, 11 Aug 2011 20:34:00 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=kylemanna.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; q=dns; s= kylemanna.com; b=JaXx34eGNAAXJFsbPY0sA+FOgki7hxD1g1hKssspDA5aXS/ pu3/nkwFXi57fRBRfV3DDqy5K6UJrWtognj956t+rvivJ/iqggmLE0bTdySJCwO7 NN2Ragn3GXWLX6uvo0qi5y7IggldayRr5+W8/U17b4SXGJaz7ghVHVKULRkU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=kylemanna.com; h=from:to :cc:subject:date:message-id:in-reply-to:references; s= kylemanna.com; bh=WwF3p1y4bcrUtRdstVvSUjm+0zA=; b=bgZVFMuWZetWwv WSi0xGfMdvgxrUJFZmcipyf2vLa4UKpCmfWOHttPFN1uCS/q5eCl7utSHUurAI4x oyCMhuKtwNRi2aKSIlJvTI05mksqfy3D+Pb2Q4jk39EhQQnTeuJbhE6jSg68PgUl b5wqz6/autd2O9wmq8GYa0tktpmkg= Received: from core (cpe-70-116-138-43.tx.res.rr.com [70.116.138.43]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: core@frozenliquid.net) by homiemail-a67.g.dreamhost.com (Postfix) with ESMTPSA id 09EEB88064; Thu, 11 Aug 2011 20:34:00 -0700 (PDT) Received: by core (Postfix, from userid 1000) id 1677A681FEA; Thu, 11 Aug 2011 22:33:59 -0500 (CDT) From: Kyle Manna To: Tony Lindgren , Russell King , Samuel Ortiz Cc: Keerthy , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kyle Manna Subject: [PATCH v2 2/4] mfd: twl4030-madc: turn on the MADC clock Date: Thu, 11 Aug 2011 22:33:13 -0500 Message-Id: <1313119995-15382-3-git-send-email-kyle@kylemanna.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1313119995-15382-1-git-send-email-kyle@kylemanna.com> References: <1313119995-15382-1-git-send-email-kyle@kylemanna.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Aug 2011 03:34:08 +0000 (UTC) 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 --- 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, ®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, 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;