From patchwork Thu Sep 6 12:12:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1413881 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 705723FC85 for ; Thu, 6 Sep 2012 12:16:42 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9awx-0001Dv-0e; Thu, 06 Sep 2012 12:12:47 +0000 Received: from na3sys009aog118.obsmtp.com ([74.125.149.244]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1T9awV-00017z-W2 for linux-arm-kernel@lists.infradead.org; Thu, 06 Sep 2012 12:12:21 +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 DSNKUEiTIWKR3R45PxiAUPo1FwySrqbfEP29@postini.com; Thu, 06 Sep 2012 05:12:19 PDT Received: by obbta17 with SMTP id ta17so2324837obb.36 for ; Thu, 06 Sep 2012 05:12:17 -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=cWHBnnDDgX3GBGJTuMSK6kG+b15mxOgxiqZdOiZ0bJGWjSPOkYtB0dvzkDBnieEGrB pCC76opgI/YwFyS5WbWBc3lKwrP5nHJYyEBrdBFm8Z4X9gN5cnO/biuUdKcNal8nAZkF epnLGUI7RvICJ+j9IHPJbqsDGPTQfmQUhugkXOkKYF5FlJvYc2C3MV9leEYa21LDRTIr Hp8jaiWnT+ZrnPVyIelDKhKrN1nkfKcom7pii0ppZZRHBrgCGtU5rG6tbIZ2T+gtiwoc EEo4b8z/8w8nNGrnaXKFdz1a5TNNyH2csqaxF0zWh0VE6N3k3bdXGEZhsHaNrVChAzNZ I/tg== Received: by 10.60.24.7 with SMTP id q7mr1651097oef.54.1346933537060; Thu, 06 Sep 2012 05:12:17 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id zn9sm1795856obb.23.2012.09.06.05.12.13 (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 05:12:16 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Samuel Ortiz , Dmitry Torokhov , Grant Likely , Rob Herring Subject: [PATCH v3 04/14] MFD: twl-core: Add API to query the HFCLK rate Date: Thu, 6 Sep 2012 15:12:11 +0300 Message-Id: <1346933541-21547-5-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1346933541-21547-1-git-send-email-peter.ujfalusi@ti.com> References: <1346933541-21547-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQke/OK4XbbjNedaDPh83qwfohKc1XKSL2XRLB+qxB2RP7qoagRCrPJurJGWthfW09PMlsfT 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);