From patchwork Mon Jul 18 17:35:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 987332 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 p6IHaCbC013507 for ; Mon, 18 Jul 2011 17:36:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754540Ab1GRRgL (ORCPT ); Mon, 18 Jul 2011 13:36:11 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:34876 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754507Ab1GRRgI convert rfc822-to-8bit (ORCPT ); Mon, 18 Jul 2011 13:36:08 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p6IHa4xU019464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 Jul 2011 12:36:04 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep34.itg.ti.com (8.13.7/8.13.8) with ESMTP id p6IHa3LN022137; Mon, 18 Jul 2011 12:36:03 -0500 (CDT) Received: from dnce72.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6IHa3fk010610; Mon, 18 Jul 2011 12:36:03 -0500 (CDT) thread-index: AcxFcSpPYgAUuON0QLu61hDZA9YUTA== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4657 Received: from localhost.localdomain (172.24.88.4) by dnce72.ent.ti.com (137.167.131.87) with Microsoft SMTP Server (TLS) id 8.3.106.1; Mon, 18 Jul 2011 19:36:02 +0200 From: Tero Kristo To: CC: , , , , Subject: [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators Date: Mon, 18 Jul 2011 20:35:20 +0300 Message-ID: <1311010522-5868-5-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1311010522-5868-1-git-send-email-t-kristo@ti.com> References: <1311010522-5868-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 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]); Mon, 18 Jul 2011 17:36:13 +0000 (UTC) omap3_pmic_get_smps_config can now be used to get regulator configuration for MPU and CORE SMPS regulators. This should be expanded later to add IVA SMPS regulator for OMAP4. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/twl-common.c | 62 ++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/twl-common.h | 14 ++++++++ 2 files changed, 76 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index 2543342..dc36053 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -23,8 +23,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -302,3 +304,63 @@ void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2) pmic_data->vpll2 = &omap3_vpll2_idata; } + +static struct regulator_consumer_supply omap_smps_mpu_iva_supply[] = { + REGULATOR_SUPPLY("vcc", "mpu_iva"), +}; + +static struct regulator_consumer_supply omap_smps_core_supply[] = { + REGULATOR_SUPPLY("vcc", "core"), +}; + +static struct regulator_init_data omap_smps_mpu_iva = { + .constraints = { + .min_uV = 600000, + .max_uV = 1450000, + .valid_modes_mask = REGULATOR_MODE_NORMAL, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, + }, + .num_consumer_supplies = ARRAY_SIZE(omap_smps_mpu_iva_supply), + .consumer_supplies = omap_smps_mpu_iva_supply, +}; + +static struct regulator_init_data omap_smps_core = { + .constraints = { + .min_uV = 600000, + .max_uV = 1450000, + .valid_modes_mask = REGULATOR_MODE_NORMAL, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, + }, + .num_consumer_supplies = ARRAY_SIZE(omap_smps_core_supply), + .consumer_supplies = omap_smps_core_supply, +}; + +void omap_pmic_get_smps_config(struct platform_device *smps_dev, + u32 smps_flags) +{ + struct omap_smps_platform_data *info; + struct regulator_init_data **reg_list; + int num_reg = 0; + + reg_list = kmalloc(sizeof(void *) * hweight32(smps_flags), GFP_KERNEL); + info = kzalloc(sizeof(struct omap_smps_platform_data), GFP_KERNEL); + + if (!reg_list || !info) + return; + + if (smps_flags & SMPS_COMMON_REGULATOR_MPU_IVA) { + reg_list[num_reg] = &omap_smps_mpu_iva; + num_reg++; + } + if (smps_flags & SMPS_COMMON_REGULATOR_CORE) { + reg_list[num_reg] = &omap_smps_core; + num_reg++; + } + + info->regulators = reg_list; + info->num_regulators = num_reg; + + smps_dev->name = "omap-smps"; + smps_dev->id = -1; + smps_dev->dev.platform_data = info; +} diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h index 5e83a5b..fde8467 100644 --- a/arch/arm/mach-omap2/twl-common.h +++ b/arch/arm/mach-omap2/twl-common.h @@ -25,6 +25,11 @@ #define TWL_COMMON_REGULATOR_VPLL1 (1 << 4) #define TWL_COMMON_REGULATOR_VPLL2 (1 << 5) +/* TWLxxxx SMPS regulators */ +#define SMPS_COMMON_REGULATOR_MPU (1 << 0) +#define SMPS_COMMON_REGULATOR_CORE (1 << 1) +#define SMPS_COMMON_REGULATOR_IVA (1 << 2) +#define SMPS_COMMON_REGULATOR_MPU_IVA (1 << 3) struct twl4030_platform_data; @@ -56,4 +61,13 @@ void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, void omap4_pmic_get_config(struct twl4030_platform_data *pmic_data, u32 pdata_flags, u32 regulators_flags); +void omap_pmic_get_smps_config(struct platform_device *smps_dev, + u32 smps_flags); + +static inline void omap3_pmic_get_smps_config(struct platform_device *smps_dev) +{ + omap_pmic_get_smps_config(smps_dev, SMPS_COMMON_REGULATOR_MPU_IVA | + SMPS_COMMON_REGULATOR_CORE); +} + #endif /* __OMAP_PMIC_COMMON__ */