From patchwork Fri Jul 4 20:24:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 4483801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13A89BEEAA for ; Fri, 4 Jul 2014 20:30:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4709820381 for ; Fri, 4 Jul 2014 20:30:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64BF120265 for ; Fri, 4 Jul 2014 20:30:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X3A5r-0001HV-Bj; Fri, 04 Jul 2014 20:28:27 +0000 Received: from bhuna.collabora.co.uk ([93.93.135.160]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X3A3i-0005xg-PO for linux-arm-kernel@lists.infradead.org; Fri, 04 Jul 2014 20:26:15 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id E424660276E From: Javier Martinez Canillas To: Lee Jones Subject: [PATCH v7 16/24] regulator: max77686: Setup DVS-related GPIOs on probe Date: Fri, 4 Jul 2014 22:24:19 +0200 Message-Id: <1404505467-26526-17-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <1404505467-26526-1-git-send-email-javier.martinez@collabora.co.uk> References: <1404505467-26526-1-git-send-email-javier.martinez@collabora.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140704_132615_050618_A9D64F71 X-CRM114-Status: GOOD ( 13.11 ) X-Spam-Score: -0.0 (/) Cc: Alessandro Zummo , Krzysztof Kozlowski , Kukjin Kim , Mike Turquette , Tomeu Vizoso , devicetree@vger.kernel.org, Yadwinder Singh Brar , linux-kernel@vger.kernel.org, Liam Girdwood , Javier Martinez Canillas , Doug Anderson , Tushar Behera , Mark Brown , linux-samsung-soc@vger.kernel.org, Olof Johansson , Andreas Farber , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MAX77686 PMIC support Dyamic Voltage Scaling (DVS) on a set of Buck regulators. A number of GPIO are connected to these lines and are requested by the mfd driver. Setup the GPIO pins from the regulator driver. Signed-off-by: Javier Martinez Canillas --- drivers/regulator/max77686.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index ef1af2d..ecce77a 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -435,6 +435,12 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, } #endif /* CONFIG_OF */ +static inline bool max77686_is_dvs_buck(int id) +{ + /* BUCK 2,3 and 4 support DVS */ + return (id >= MAX77686_BUCK2 && id <= MAX77686_BUCK4); +} + static int max77686_pmic_probe(struct platform_device *pdev) { struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); @@ -442,6 +448,9 @@ static int max77686_pmic_probe(struct platform_device *pdev) struct max77686_data *max77686; int i, ret = 0; struct regulator_config config = { }; + unsigned int reg; + int buck_default_idx; + int buck_old_idx; dev_dbg(&pdev->dev, "%s\n", __func__); @@ -472,13 +481,34 @@ static int max77686_pmic_probe(struct platform_device *pdev) config.driver_data = max77686; platform_set_drvdata(pdev, max77686); + buck_default_idx = pdata->buck_default_idx; + buck_old_idx = max77686_read_gpios(pdata); + for (i = 0; i < MAX77686_REGULATORS; i++) { struct regulator_dev *rdev; + int id = pdata->regulators[i].id; config.init_data = pdata->regulators[i].initdata; config.of_node = pdata->regulators[i].of_node; max77686->opmode[i] = regulators[i].enable_mask; + + if (max77686_is_dvs_buck(id)) { + /* Try to copy over data so we keep firmware settings */ + reg = regulators[i].vsel_reg; + + ret = regmap_reg_copy(iodev->regmap, + reg + buck_default_idx, + reg + buck_old_idx); + + if (ret) + dev_warn(&pdev->dev, "Copy err %d => %d (%d)\n", + reg + buck_old_idx, + reg + buck_default_idx, ret); + + regulators[i].vsel_reg += buck_default_idx; + } + rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { @@ -488,6 +518,10 @@ static int max77686_pmic_probe(struct platform_device *pdev) } } + ret = max77686_setup_gpios(iodev->dev); + if (ret) + return ret; + return 0; }