From patchwork Mon Sep 10 10:46:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1431541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 1A8B74025E for ; Mon, 10 Sep 2012 10:50:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TB1WK-0003wY-0G; Mon, 10 Sep 2012 10:47:12 +0000 Received: from na3sys009aog118.obsmtp.com ([74.125.149.244]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1TB1VX-0003kR-KF for linux-arm-kernel@lists.infradead.org; Mon, 10 Sep 2012 10:46:24 +0000 Received: from mail-ob0-f177.google.com ([209.85.214.177]) (using TLSv1) by na3sys009aob118.postini.com ([74.125.148.12]) with SMTP ID DSNKUE3E/e5XlnX1UTGQ9NhVYMVzGOXgWkfJ@postini.com; Mon, 10 Sep 2012 03:46:23 PDT Received: by obbta17 with SMTP id ta17so2845741obb.36 for ; Mon, 10 Sep 2012 03:46:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=XKW7Hls+SOCNGTOKd3jwySTj4GgGUj678H5clMBsDKs=; b=D3N2x+m/KGbRoZEke+b/7QDHaXGCOTDVKQ/CNLMuVJL7sQXgss3rbG4u+08WtBXD9P XH3VFTg4YoVWD7C/XLnEjWDmCmeE6XIthamW8NhHs4ebcieqLId4bvnVzDNb8/9+5wLM qa0hkpiEJTBIkJKs0ViesZ0TkLbEaUXawu1xP6+9foNktdiasoMeU9Dz9MLbUNRra5ix qRkefaCnlR8SA6US72+20Ko0PIVwUApOufAbE6N4ik881/BggzQ/zLECv/jm3USPcJ3v KfML9NhskbtGbLhGmUGfsVj60uLHEI9UuoiE/nW5a05Vjc7yyND/6/detpZ6VhdNYswa sjnw== Received: by 10.60.3.194 with SMTP id e2mr13360478oee.1.1347273981413; Mon, 10 Sep 2012 03:46:21 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id 5sm8888098oeq.4.2012.09.10.03.46.17 (version=SSLv3 cipher=OTHER); Mon, 10 Sep 2012 03:46:20 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Samuel Ortiz , Dmitry Torokhov , Grant Likely , Rob Herring Subject: [PATCH v4 04/14] MFD: twl-core: Add API to query the HFCLK rate Date: Mon, 10 Sep 2012 13:46:22 +0300 Message-Id: <1347273992-9107-5-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347273992-9107-1-git-send-email-peter.ujfalusi@ti.com> References: <1347273992-9107-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQlO9PWYXjzOTA1IEbvFPVxSqzTAbfrN3ufcF4gK7sKp93cPJdReKV/AGD1P7ARXdRkwdcq5 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.244 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: alsa-devel@alsa-project.org, Benoit Cousson , devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Tero Kristo , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org CFG_BOOT register's HFCLK_FREQ field hold information about the used HFCLK frequency. Add possibility for users to get the configured rate based on this register. This register was configured during boot, without it the chip would not operate correctly, so we can trust on this information. Signed-off-by: Peter Ujfalusi --- drivers/mfd/twl-core.c | 32 ++++++++++++++++++++++++++++++++ include/linux/i2c/twl.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 1c32afe..f162b68 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -552,6 +552,38 @@ int twl_get_version(void) } EXPORT_SYMBOL_GPL(twl_get_version); +/** + * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate. + * + * Api to get the TWL HFCLK rate based on BOOT_CFG register. + */ +int twl_get_hfclk_rate(void) +{ + u8 ctrl; + int rate; + + twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &ctrl, R_CFG_BOOT); + + switch (ctrl & 0x3) { + case HFCLK_FREQ_19p2_MHZ: + rate = 19200000; + break; + case HFCLK_FREQ_26_MHZ: + rate = 26000000; + break; + case HFCLK_FREQ_38p4_MHZ: + rate = 38400000; + break; + default: + pr_err("TWL4030: HFCLK is not configured\n"); + rate = -EINVAL; + break; + } + + return rate; +} +EXPORT_SYMBOL_GPL(twl_get_hfclk_rate); + static struct device * add_numbered_child(unsigned chip, const char *name, int num, void *pdata, unsigned pdata_len, diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index 7ea898c..ac6488c 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h @@ -188,6 +188,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); int twl_get_type(void); int twl_get_version(void); +int twl_get_hfclk_rate(void); int twl6030_interrupt_unmask(u8 bit_mask, u8 offset); int twl6030_interrupt_mask(u8 bit_mask, u8 offset);