From patchwork Thu Aug 11 03:27:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Manna X-Patchwork-Id: 1055682 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 p7B3S63u014113 for ; Thu, 11 Aug 2011 03:28:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754088Ab1HKD2D (ORCPT ); Wed, 10 Aug 2011 23:28:03 -0400 Received: from hapkido.dreamhost.com ([66.33.216.122]:52336 "EHLO hapkido.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423Ab1HKD17 (ORCPT ); Wed, 10 Aug 2011 23:27:59 -0400 Received: from homiemail-a24.g.dreamhost.com (caiajhbdcaib.dreamhost.com [208.97.132.81]) by hapkido.dreamhost.com (Postfix) with ESMTP id 626B117E55B for ; Wed, 10 Aug 2011 20:27:59 -0700 (PDT) Received: from homiemail-a24.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a24.g.dreamhost.com (Postfix) with ESMTP id 767B32C806B; Wed, 10 Aug 2011 20:27:57 -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=YBQFxIQH/lzHHQh3DifVO75ckUvr356aMwEHDl4Nh8P/eVd mySUIIKeitBJAPZM+qjaAyouzMhGZXByHBWcfBgwIKAdvDTa0GQbHartBMtDWBm5 4/j5DjZC2Hmncey0oamS1pL6KLJDbWs7BvOqfvjjOl+HNR3dJWWWhQpjq0Ec= 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=QX3hTVgqTEbdzZ596MBI77hFNxI=; b=DwjTg6pTzQuubP 9hij2JP5MLdhQ0HvM8jO9C6UUM2NQj5AKzF9Yu0I79JQ20bqfrqsRuXkmi/yhQA+ IEaOrRcigBcsG090QpgPVAVSWTU2ZOqde3j8hkrnipmmDxjPNAOD9jROhlp0EToO Mmmppo6LyQ+ZdLWsT74jzWYmFy9Pw= 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-a24.g.dreamhost.com (Postfix) with ESMTPSA id 5D5262C8057; Wed, 10 Aug 2011 20:27:57 -0700 (PDT) Received: by core (Postfix, from userid 1000) id 795F8680A9F; Wed, 10 Aug 2011 22:27:56 -0500 (CDT) From: Kyle Manna To: linux-omap@vger.kernel.org Cc: Kyle Manna Subject: [PATCH 2/3] twl4030-madc: turn on the MADC clock Date: Wed, 10 Aug 2011 22:27:51 -0500 Message-Id: <1313033272-16774-3-git-send-email-kyle@kylemanna.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1313033272-16774-1-git-send-email-kyle@kylemanna.com> References: <1313033272-16774-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]); Thu, 11 Aug 2011 03:28:38 +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 8ef7801..75040b4 100644 --- a/drivers/mfd/twl4030-madc.c +++ b/drivers/mfd/twl4030-madc.c @@ -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, 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;