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: 1431451 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AE611DF28C for ; Mon, 10 Sep 2012 10:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757224Ab2IJKq0 (ORCPT ); Mon, 10 Sep 2012 06:46:26 -0400 Received: from na3sys009aog129.obsmtp.com ([74.125.149.142]:34574 "EHLO na3sys009aog129.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757139Ab2IJKqW (ORCPT ); Mon, 10 Sep 2012 06:46:22 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob129.postini.com ([74.125.148.12]) with SMTP ID DSNKUE3E/e5XlnX1UTGQ9NhVYMVzGOXgWkfJ@postini.com; Mon, 10 Sep 2012 03:46:22 PDT Received: by obbuo13 with SMTP id uo13so2658590obb.19 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=n2H5X1AYdK1HRaJSNmOhYCHNzP5Q5+fNI6fKwaJmlRi+Hf4ThGGXZrFJEGUlduNYoo RvIyj6hiXIimRMu2T0uZ5Z2v3ks7nMLZBvUbHMVmSYUnZ3FRToPHshos5ovKEzQ6oJrk lztZrarcwcfUGCsiRn3BFvCXUKIIQqkJt7gabU/75JEfpTAoh5Iw0O2z4rcbknxcomrR RJFBrepglmOG4GQMb7d5zmx7u6hj/u4WGrvk69kTFRKPY/u2LcjkuIzOeKjAUBrLFlIh 2DDwx9V0vvb8JUB9CfIJVQ6gGaTMYKJRzP4trhPF+XrcT5S4nyNDZBIfGHQ7eDSywvND u48Q== 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 Cc: Tero Kristo , alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org, Benoit Cousson , linux-kernel@vger.kernel.org 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: ALoCoQm7T0JYtqhFZ5nkU2SAwZ8HpZgY8YaoIZH/5jmcsld5KaVzBZj6py1agNYESTWT/mXaAFNZ Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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);