From patchwork Fri Apr 23 13:48:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 94674 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3NDmZa5020330 for ; Fri, 23 Apr 2010 13:48:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757440Ab0DWNs2 (ORCPT ); Fri, 23 Apr 2010 09:48:28 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:60774 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757423Ab0DWNs1 (ORCPT ); Fri, 23 Apr 2010 09:48:27 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o3NDmEiN032104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Apr 2010 08:48:16 -0500 Received: from linfarm488.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o3NDm8WN012353; Fri, 23 Apr 2010 19:18:09 +0530 (IST) Received: from linfarm488.india.ti.com (localhost [127.0.0.1]) by linfarm488.india.ti.com (8.12.11/8.12.11) with ESMTP id o3NDm80b031383; Fri, 23 Apr 2010 19:18:08 +0530 Received: (from a0393109@localhost) by linfarm488.india.ti.com (8.12.11/8.12.11/Submit) id o3NDm7Hp031381; Fri, 23 Apr 2010 19:18:07 +0530 From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: khilman@deeprootsystems.com, paul@pwsan.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PM-WIP-SR][PATCH] OMAP3: PM: Separating PMIC specific part out of smartreflex driver Date: Fri, 23 Apr 2010 19:18:07 +0530 Message-Id: <1272030487-31118-1-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.5.5 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.3 (demeter.kernel.org [140.211.167.41]); Fri, 23 Apr 2010 13:48:36 +0000 (UTC) diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index a6a29d1..7134529 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +58,7 @@ struct omap_sr { /* sr_list contains all the instances of smartreflex module */ static LIST_HEAD(sr_list); static struct omap_smartreflex_class_data *sr_class; +static struct omap_smartreflex_pmic_data *sr_pmic_data; static inline void sr_write_reg(struct omap_sr *sr, unsigned offset, u32 value) { @@ -670,6 +670,24 @@ void omap_sr_register_class(struct omap_smartreflex_class_data *class_data) sr_late_init(sr_info); } +/** + * omap_sr_register_pmic : API to register pmic specific info. + * @pmic_data - The structure containing pmic specific data. + * + * This API is to be called from the PMIC specific code to register with + * smartreflex driver pmic specific info. Currently the only info required + * is the smartreflex init on the PMIC side. + */ +void omap_sr_register_pmic(struct omap_smartreflex_pmic_data *pmic_data) +{ + if (!pmic_data) { + pr_warning("Trying to register NULL PMIC data structure with \ + smartreflex\n"); + return; + } + sr_pmic_data = pmic_data; +} + /* PM Debug Fs enteries to enable disable smartreflex.*/ static int omap_sr_autocomp_show(void *data, u64 *val) @@ -770,16 +788,10 @@ static struct platform_driver smartreflex_driver = { static int __init sr_init(void) { - int ret = 0; - u8 RdReg; - - /* TODO: Find an appropriate place for this */ - /* Enable SR on T2 */ - ret = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &RdReg, - R_DCDC_GLOBAL_CFG); - RdReg |= DCDC_GLOBAL_CFG_ENABLE_SRFLX; - ret |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, RdReg, - R_DCDC_GLOBAL_CFG); + int ret; + + if (sr_pmic_data && sr_pmic_data->sr_pmic_init) + sr_pmic_data->sr_pmic_init(); ret = platform_driver_probe(&smartreflex_driver, omap_smartreflex_probe); diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h index d12c093..46bc1f1 100644 --- a/arch/arm/mach-omap2/smartreflex.h +++ b/arch/arm/mach-omap2/smartreflex.h @@ -138,12 +138,6 @@ extern struct dentry *pm_dbg_main_dir; /* TODO:3630/OMAP4 values if it has to come from this file */ -/* Info for enabling SR in T2/gaia. ToDo: Move it to twl4030_power.c */ -#define PHY_TO_OFF_PM_RECIEVER(p) (p - 0x5b) -#define R_DCDC_GLOBAL_CFG PHY_TO_OFF_PM_RECIEVER(0x61) -/* R_DCDC_GLOBAL_CFG register, SMARTREFLEX_ENABLE values */ -#define DCDC_GLOBAL_CFG_ENABLE_SRFLX 0x08 - #ifdef CONFIG_OMAP_SMARTREFLEX_TESTING #define SR_TESTING_NVALUES 1 #else @@ -196,6 +190,16 @@ struct omap_smartreflex_dev_data { #define SR_CLASS3 0x3 /** + * omap_smartreflex_pmic_data : Strucutre to be populated by pmic code to pass + * pmic specific info to smartreflex driver + * + * @sr_pmic_init - API to initialize smartreflex on the PMIC side. + */ +struct omap_smartreflex_pmic_data { + void (*sr_pmic_init) (void); +}; + +/** * omap_smartreflex_class_data : Structure to be populated by * Smartreflex class driver with corresponding class enable disable API's * @@ -260,9 +264,15 @@ void sr_configure_minmax(int srid); * API to register the smartreflex class driver with the smartreflex driver */ void omap_sr_register_class(struct omap_smartreflex_class_data *class_data); + + +/* API to register the pmic specific data with the smartreflex driver */ +void omap_sr_register_pmic(struct omap_smartreflex_pmic_data *pmic_data); #else static inline void omap_smartreflex_enable(int srid) {} static inline void omap_smartreflex_disable(int srid) {} +static inline void omap_sr_register_pmic + (struct omap_smartreflex_pmic_data *pmic_data) {} #endif #endif diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c index 6647156..360e4ba 100644 --- a/arch/arm/mach-omap2/twl4030.c +++ b/arch/arm/mach-omap2/twl4030.c @@ -9,7 +9,10 @@ #ifdef CONFIG_TWL4030_POWER +#include + #include "twl4030.h" +#include "smartreflex.h" static struct prm_setup_vc twl4030_voltsetup_time = { /* VOLT SETUPTIME for RET */ @@ -151,4 +154,27 @@ void twl4030_get_vc_timings(struct prm_setup_vc *setup_vc) setup_vc->off.voltsetup2 = twl4030_voltsetup_time.off.voltsetup2; setup_vc->off.voltoffset = twl4030_voltsetup_time.off.voltoffset; } + +static void twl4030_smartreflex_init(void) +{ + int ret = 0; + u8 read_val; + + ret = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &read_val, + R_DCDC_GLOBAL_CFG); + read_val |= DCDC_GLOBAL_CFG_ENABLE_SRFLX; + ret |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, read_val, + R_DCDC_GLOBAL_CFG); +} + +struct omap_smartreflex_pmic_data twl4030_sr_data = { + .sr_pmic_init = twl4030_smartreflex_init, +}; + +static int __init twl4030_init(void) +{ + omap_sr_register_pmic(&twl4030_sr_data); + return 0; +} +arch_initcall(twl4030_init); #endif diff --git a/arch/arm/mach-omap2/twl4030.h b/arch/arm/mach-omap2/twl4030.h index 3a7da2d..52218b2 100644 --- a/arch/arm/mach-omap2/twl4030.h +++ b/arch/arm/mach-omap2/twl4030.h @@ -5,6 +5,12 @@ #include "voltage.h" #ifdef CONFIG_TWL4030_POWER +/* Info for enabling SR in T2/gaia. */ +#define PHY_TO_OFF_PM_RECIEVER(p) (p - 0x5b) +#define R_DCDC_GLOBAL_CFG PHY_TO_OFF_PM_RECIEVER(0x61) +/* R_DCDC_GLOBAL_CFG register, SMARTREFLEX_ENABLE values */ +#define DCDC_GLOBAL_CFG_ENABLE_SRFLX 0x08 + extern void twl4030_get_scripts(struct twl4030_power_data *t2scripts_data); extern void twl4030_get_vc_timings(struct prm_setup_vc *setup_vc); #else