From patchwork Sun Apr 22 23:07:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133941 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369558lji; Sun, 22 Apr 2018 16:12:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx483Vguu0fivGywbdaii6epOi6bNGKuyq50ykzDefjUDsjIlVXmkuJion/g6kcQq2WCJOqRi X-Received: by 10.101.96.150 with SMTP id t22mr15281782pgu.4.1524438727995; Sun, 22 Apr 2018 16:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438727; cv=none; d=google.com; s=arc-20160816; b=eJyMZpbD6dbiyNI+dzJU6Hgpfc8uh2F3upe5q/dBg7lCjqbZOY1MsZx4sku7PC1bGK KooKWmsUIwe63x9Ie8UcmmDcdqSX4FrCul6Qpj8vMpC0wJNNmjMeg45gUOo3ZNg9okCt GfZHkWapaBM8VKQFrMDUFmaxjX3qKZm+74wj9NvodmHrg/IPsN4FPz+WFjp4qdvVL/cj LAvWSKf9IFwGzs5qjO/NS1e0uRYtt1VSMKj0BUGBExi919B9SCtnWCcAFpcoQrXcICRl PldyFLn1V7jmeEuonSs/CCvpBtjYziNNNxWMJreuuoM3kP0OUC4Y/yx/bAs1vScFPOl0 GaSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=O2TxGWIn/i7Ne4ndcU6jwh9V95xsCPdH+K8JIiC2y/QdORRN1dHxx63xIU9zUwjBCu i4vNrT21Ku77Bwg/cEhsLHh/Fozwbq33Vfwb2MVN8wESseDkeZIQYfVYp1TkZlEpCWfA pn2wgHMbii+qW+PbE3cSAfhOfpla3h4KMeC85bhm/+o2dloJW2Vd5sp+sMu9JoonBuWL xvB0LmMQCGcgwSPV8SgD5M1lP+jei3q4RevssOb7evBIUgdE3wY+6UjNPuBAiE7sf8zr tO02VS/yBg8LpJa2La76REQc32LXhvRRodoFOrNOastbdkyZ+fEekMBGJ2duAxYYjd74 RB9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RBHgT7n8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f85si648938pfj.125.2018.04.22.16.12.07; Sun, 22 Apr 2018 16:12:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RBHgT7n8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754072AbeDVXMF (ORCPT + 29 others); Sun, 22 Apr 2018 19:12:05 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40614 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbeDVXKR (ORCPT ); Sun, 22 Apr 2018 19:10:17 -0400 Received: by mail-lf0-f68.google.com with SMTP id i18-v6so12225352lfc.7 for ; Sun, 22 Apr 2018 16:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=RBHgT7n8QjKAwUXiG1HRZTZuSJm6+eCAWu7Qve8bvGpJ2XrmBumWjca0JGbpjZ6VZX eU47GGe3S+hbzC3mxbNV2jRBgRm+yaJ57cOBhwgCkN3onuY4xDHHHQctyTbE+2fFr9RI mtm/FjXUSjflsA/xrY9AKtxmF6q/yDM4eqtQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=WL3qfhw7XGLn6daKkvapra24H8B2VkEm8jd1/vMeVhoPupxaZys+AbV0M++EOZuDlH T1y9GWUHKZWXbt62lXxOTlgLBpy8YchbNCJC2bzbDZOKF+6h200zpPrWjiA5UjSi7qht +GMUQETrE/5fQe+vTNaSnWvWyPQ93DXE38NfuPnSzrqb1hBeUXdF8jW2vCsEEejxy7GW lCmlDEfTvZlUN4dQNtRGtRASS19cex3Ri8YakiXHdRuUh8uCsmfB1LqnfOgm0TMDCJUR Muw516ujSOhvvdb9P/GmFvOQCidBcsdOXUI0U59IAn5tE3wNmLFWOCJfgLmRAWIAuhI1 d8bA== X-Gm-Message-State: ALQs6tDGC4cGZb4xy9J/p4HJyvtt+haSn0RgVO8thwjJqR7uiwKaoE+7 pFyOd0g6I/ozEWpWInksiA4qaw== X-Received: by 10.46.154.205 with SMTP id p13mr5625333ljj.60.1524438615784; Sun, 22 Apr 2018 16:10:15 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r25sm2036291ljc.8.2018.04.22.16.10.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:15 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 11/18 v2] regulator: s5m8767: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:35 +0200 Message-Id: <20180422230742.3729-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180422230742.3729-1-linus.walleij@linaro.org> References: <20180422230742.3729-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes - Collect Lee's ACK. --- drivers/regulator/s5m8767.c | 26 +++++++++++++++----------- include/linux/mfd/samsung/core.h | 4 +++- 2 files changed, 18 insertions(+), 12 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 4836947e1521..b8443a360646 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, return; } - if (!gpio_is_valid(rdata->ext_control_gpio)) { + if (!rdata->ext_control_gpiod) { dev_warn(s5m8767->dev, "ext-control for %s: GPIO not valid, ignoring\n", - rdata->reg_node->name); + rdata->reg_node->name); return; } - config->ena_gpio = rdata->ext_control_gpio; - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config->ena_gpiod = rdata->ext_control_gpiod; } /* @@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, continue; } - rdata->ext_control_gpio = of_get_named_gpio(reg_np, - "s5m8767,pmic-ext-control-gpios", 0); + rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + reg_np, + "s5m8767,pmic-ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s5m8767"); + if (IS_ERR(rdata->ext_control_gpiod)) + return PTR_ERR(rdata->ext_control_gpiod); rdata->id = i; rdata->initdata = of_get_regulator_init_data( @@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.driver_data = s5m8767; config.regmap = iodev->regmap_pmic; config.of_node = pdata->regulators[i].reg_node; - config.ena_gpio = -EINVAL; - config.ena_gpio_flags = 0; - config.ena_gpio_initialized = true; - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) + config.ena_gpiod = NULL; + if (pdata->regulators[i].ext_control_gpiod) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); @@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return ret; } - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { + if (pdata->regulators[i].ext_control_gpiod) { ret = s5m8767_enable_ext_control(s5m8767, rdev); if (ret < 0) { dev_err(s5m8767->dev, diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 5a23dd4df432..28f4ae76271d 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -39,6 +39,8 @@ #define STEP_12_5_MV 12500 #define STEP_6_25_MV 6250 +struct gpio_desc; + enum sec_device_type { S5M8751X, S5M8763X, @@ -151,7 +153,7 @@ struct sec_regulator_data { int id; struct regulator_init_data *initdata; struct device_node *reg_node; - int ext_control_gpio; + struct gpio_desc *ext_control_gpiod; }; /*