From patchwork Fri Oct 10 13:40:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 38585 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 11558205D8 for ; Fri, 10 Oct 2014 13:41:00 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf2124520wgg.2 for ; Fri, 10 Oct 2014 06:41:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=0VDwisycfSxGtw9UO+nhNAZSp8tVty+HFU/bfWX4JTo=; b=WiLEfg/DE4fkTolUC0EOLYd2xozl97lw+3QQq3hy1vWX0m+AftmWcKu15DH9mCLlyJ azopu576q9dKmDSysPC8BlZBByJs6jkqyCOA+HcnWeeHCzn/Jf/FB0fTKWbXFDdfxsRH zk/mlQjwoPNzbnboQRdRAoOSOT6ofLRq06U7PIi8F5fkdXRHT5ymxNVkYFWZAaRTzEVV 5wx6GctzL9CWQNHCAQ2Ux1WxnecT8NGK9tj1nHZ0AHZ2lxpCpLgZYOi0LGWXM0dms8Gr gQvdUPNWfgVtIJm/tyvDayoE/A/914XfEGnan7H30ijSG1e1IHev7WVCtKvMWciquOna LoDw== X-Gm-Message-State: ALoCoQnqqJPWpUQTpwspUauUNEX3Zj8OxmqInCm2aESbMf10LRPSe3jsgz3WPdW9NtSzS/zQrYeG X-Received: by 10.180.8.197 with SMTP id t5mr1071691wia.5.1412948460175; Fri, 10 Oct 2014 06:41:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.168 with SMTP id a8ls275144lab.55.gmail; Fri, 10 Oct 2014 06:41:00 -0700 (PDT) X-Received: by 10.112.149.36 with SMTP id tx4mr4715054lbb.79.1412948459982; Fri, 10 Oct 2014 06:40:59 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by mx.google.com with ESMTPS id ul7si9444215lbb.8.2014.10.10.06.40.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 06:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id hs14so3268359lab.3 for ; Fri, 10 Oct 2014 06:40:59 -0700 (PDT) X-Received: by 10.112.14.34 with SMTP id m2mr4773440lbc.74.1412948459751; Fri, 10 Oct 2014 06:40:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp430770lbz; Fri, 10 Oct 2014 06:40:58 -0700 (PDT) X-Received: by 10.66.250.227 with SMTP id zf3mr4227014pac.135.1412948457629; Fri, 10 Oct 2014 06:40:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si3800118pdf.63.2014.10.10.06.40.56 for ; Fri, 10 Oct 2014 06:40:57 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753937AbaJJNk4 (ORCPT + 5 others); Fri, 10 Oct 2014 09:40:56 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:44846 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbaJJNkz (ORCPT ); Fri, 10 Oct 2014 09:40:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9ADeVYH010863; Fri, 10 Oct 2014 08:40:31 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9ADeVeY009872; Fri, 10 Oct 2014 08:40:31 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 10 Oct 2014 08:40:30 -0500 Received: from sokoban.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9ADeR8q021407; Fri, 10 Oct 2014 08:40:29 -0500 From: Tero Kristo To: , , CC: Subject: [PATCH 1/2] ARM: OMAP3+: TWL: add support for mapping platform data via pdata-quirks Date: Fri, 10 Oct 2014 16:40:41 +0300 Message-ID: <1412948442-19896-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1412948442-19896-1-git-send-email-t-kristo@ti.com> References: <1412948442-19896-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: t-kristo@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Device tree based boot does not currently support DVFS voltage scaling, as the VC/VP mapping is broken. This patch adds support to provide platform data in the device tree boot case also, basically to pass the function pointers to the vc/vp core for voltage changes. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/pdata-quirks.c | 8 ++-- arch/arm/mach-omap2/twl-common.c | 88 ++++++++++++++++++++++++++++++++---- arch/arm/mach-omap2/twl-common.h | 2 + 3 files changed, 84 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 90c88d4..03e4a86 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -311,10 +311,10 @@ void omap_auxdata_legacy_init(struct device *dev) if (dev->platform_data) return; - if (strcmp("twl4030-gpio", dev_name(dev))) - return; - - dev->platform_data = &twl_gpio_auxdata; + if (!strcmp("twl4030-gpio", dev_name(dev))) + dev->platform_data = &twl_gpio_auxdata; + else + dev->platform_data = omap_twl_match_regulator(dev); } /* diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index b0d54da..50f6d33 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -210,17 +210,37 @@ static struct twl_regulator_driver_data omap3_vdd2_drvdata = { .set_voltage = twl_set_voltage, }; +struct pmic_drvdata_config { + const char *voltdm; + struct twl_regulator_driver_data *data; +}; + +static struct pmic_drvdata_config twl4030_vdd1 = { + .voltdm = "mpu_iva", + .data = &omap3_vdd1_drvdata, +}; + +static struct pmic_drvdata_config twl4030_vdd2 = { + .voltdm = "core", + .data = &omap3_vdd2_drvdata, +}; + +struct twl_regulator_driver_data +*omap_pmic_get_drvdata(struct pmic_drvdata_config *conf) +{ + conf->data->data = voltdm_lookup(conf->voltdm); + return conf->data; +} + void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, u32 pdata_flags, u32 regulators_flags) { if (!pmic_data->vdd1) { - omap3_vdd1.driver_data = &omap3_vdd1_drvdata; - omap3_vdd1_drvdata.data = voltdm_lookup("mpu_iva"); + omap3_vdd1.driver_data = omap_pmic_get_drvdata(&twl4030_vdd1); pmic_data->vdd1 = &omap3_vdd1; } if (!pmic_data->vdd2) { - omap3_vdd2.driver_data = &omap3_vdd2_drvdata; - omap3_vdd2_drvdata.data = voltdm_lookup("core"); + omap3_vdd2.driver_data = omap_pmic_get_drvdata(&twl4030_vdd2); pmic_data->vdd2 = &omap3_vdd2; } @@ -440,6 +460,21 @@ static struct twl_regulator_driver_data omap4_vdd3_drvdata = { .set_voltage = twl_set_voltage, }; +static struct pmic_drvdata_config twl6030_vdd1 = { + .voltdm = "mpu", + .data = &omap4_vdd1_drvdata, +}; + +static struct pmic_drvdata_config twl6030_vdd2 = { + .voltdm = "iva", + .data = &omap4_vdd2_drvdata, +}; + +static struct pmic_drvdata_config twl6030_vdd3 = { + .voltdm = "core", + .data = &omap4_vdd3_drvdata, +}; + static struct regulator_consumer_supply omap4_v1v8_supply[] = { REGULATOR_SUPPLY("vio", "1-004b"), }; @@ -475,24 +510,57 @@ static struct regulator_init_data omap4_v2v1_idata = { .consumer_supplies = omap4_v2v1_supply, }; +static struct of_device_id twl_regulator_ids[] = { + { .compatible = "ti,twl4030-vdd1", .data = &twl4030_vdd1, }, + { .compatible = "ti,twl4030-vdd2", .data = &twl4030_vdd2, }, + { .compatible = "ti,twl6030-vdd1", .data = &twl6030_vdd1, }, + { .compatible = "ti,twl6030-vdd2", .data = &twl6030_vdd2, }, + { .compatible = "ti,twl6030-vdd3", .data = &twl6030_vdd3, }, + {} +}; + +/** + * omap_twl_match_regulator - match regulator against a device + * @dev: device to check for regulator match + * + * Checks if the device provided is a supported regulator device. If yes, + * will initialize the corresponding platform data structure for it and + * return it for the caller to use. Returns NULL if not supported, + * a pointer to the regulator platform data struct otherwise. + */ +void *omap_twl_match_regulator(struct device *dev) +{ + const struct of_device_id *match; + struct pmic_drvdata_config *conf; + + if (!dev->of_node) + return NULL; + + match = of_match_node(twl_regulator_ids, dev->of_node); + + if (!match) + return NULL; + + conf = (struct pmic_drvdata_config *)match->data; + + return omap_pmic_get_drvdata(conf); +} + void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data, u32 pdata_flags, u32 regulators_flags) { if (!pmic_data->vdd1) { - omap4_vdd1.driver_data = &omap4_vdd1_drvdata; - omap4_vdd1_drvdata.data = voltdm_lookup("mpu"); + omap4_vdd1.driver_data = omap_pmic_get_drvdata(&twl6030_vdd1); pmic_data->vdd1 = &omap4_vdd1; } if (!pmic_data->vdd2) { - omap4_vdd2.driver_data = &omap4_vdd2_drvdata; - omap4_vdd2_drvdata.data = voltdm_lookup("iva"); + omap4_vdd2.driver_data = omap_pmic_get_drvdata(&twl6030_vdd2); pmic_data->vdd2 = &omap4_vdd2; } if (!pmic_data->vdd3) { - omap4_vdd3.driver_data = &omap4_vdd3_drvdata; - omap4_vdd3_drvdata.data = voltdm_lookup("core"); + omap4_vdd3.driver_data = omap_pmic_get_drvdata(&twl6030_vdd3); pmic_data->vdd3 = &omap4_vdd3; } diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h index 24b65d0..b392ade 100644 --- a/arch/arm/mach-omap2/twl-common.h +++ b/arch/arm/mach-omap2/twl-common.h @@ -55,6 +55,8 @@ void omap4_pmic_init(const char *pmic_type, struct twl4030_platform_data *pmic_data, struct i2c_board_info *devices, int nr_devices); +void *omap_twl_match_regulator(struct device *dev); + void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, u32 pdata_flags, u32 regulators_flags);