From patchwork Mon May 14 08:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135680 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1442041lji; Mon, 14 May 2018 01:10:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmqbUoygcg+H92YKEXdhjBzchcwVuilxP2wWyB94vPCaA98LQXQADDVHF2MZGZ+Lz2xVQy X-Received: by 2002:a65:5787:: with SMTP id b7-v6mr7724577pgr.130.1526285406363; Mon, 14 May 2018 01:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285406; cv=none; d=google.com; s=arc-20160816; b=yDNOY7KJB9GgNFjn70pd87lMzcfW4VNNXrqebE3wZoKibory1NkxsjBjIqPCpYj94r ESPgjAgc9x0PAjVwRfp6Rf8+mYBJBp6A8S2VS71/juu6EPRNnzn+YpqS+pHPOvCeseS7 uLkwiGP2Tfv5F1CgaSIf82r1MNJj3hlup8ZWHuB4vf3tZEPx+rhojaUNnHewiZbAMwzp mlZBAaLnCPGD7WnR4OOsUmoso5sbEPVxBgGiyffsKkDvGm8DcgdQFItwm9RqEUW0Gvn3 Q68kC9mVX2QaqwrY1phB8gUYbbSaI8u2HgcrwpObVziv/mActqEc6F3PLe/Cr7dfa0wm TuXg== 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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=WKet7c0z4eoSQTguDhyLR0QBP5rUCaDDBa/POfw3LE538OkA2DGBnhdFaiQGD8ChyG CqkYrH1YHEmFYHDcIWmsBV5VMctuQPgSjqMu0JxDKe0OGKJfQUwzbVLsG6thQEHX+mMc GN7Igq8DNh033Eb4yt07rTB2Dwy/TwnoXF9yGzhA+/MGiL1zd0Sb/WG8SB6YD0uXAdy7 gIGXRvVKp5o4LEEAXE/7VwpQCq/DnXU9Nces6o72dZpUdlZN6F64ARpo1CUOk8NdziUa eXaqtORcuFwBeCbPEiYUEBX8z8SXeyq9rxtai6zT4tYfRHpLWjWFGj0oy95irY1NhasD UJVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BrG13Vrx; 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 h65-v6si7376872pgc.357.2018.05.14.01.10.06; Mon, 14 May 2018 01:10:06 -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=BrG13Vrx; 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 S1752282AbeENIHU (ORCPT + 29 others); Mon, 14 May 2018 04:07:20 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:42388 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbeENIHK (ORCPT ); Mon, 14 May 2018 04:07:10 -0400 Received: by mail-lf0-f67.google.com with SMTP id b18-v6so15832780lfa.9 for ; Mon, 14 May 2018 01:07:10 -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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=BrG13Vrx4Wz3wE5+e+KRZ8CnaKc5M1AcN0PbeOh3tFHjbYrj2IdVjfS0u7GV6TJZvT YjKNokJTJ90s9IEBHUMmX2LL0QpGc5M+bzk1I74rE+uZ+tjG52miQOwY2eCgYMjASHZH YEtsX2pZpNp5PKJQoFb/DQN6oJuqTAJ/XYM/c= 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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=THEpMMdTNkFQAQkhG0ORX6CaqsKGGEZXCeOghTGYsV3vxkEi6DKx0PqhujXwmBx2Ch rABihWMxwCq5esJQsuhamJEapTqxK0TZ+SonaQ9400DY61lK/Uf6x0N2f4G1IX/BqEBR jOL3Gj7KhdzcyhSk6RXmrX2OYtdn2RdNUMgaE0SaTAy5+APF/mnqX7Und8MeUVY3mWuV +Y8b+Lyybir+0yTdzYWhYNzuZvvA8ey9z6/MtrXvoE2DB90/HxE9Py5KffqVjmuDsT3N 0UEbQW3yBHV+mSRo5++amkAJa54wRwEE8G/+cJHMbTWr/s6KmOchki3yKouqxG6ynu5T 5clw== X-Gm-Message-State: ALKqPwcZji/70Wc0NAdJ+TDeNgin9lR1rj+mOzEbzpu4jJTFMkYOHFwG B0Hiz+WOqC/9XzxnGGWOaVqpCA== X-Received: by 2002:a19:b55a:: with SMTP id e87-v6mr7722734lff.54.1526285229274; Mon, 14 May 2018 01:07:09 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:07 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Krzysztof Kozlowski , Sangbeom Kim , Chanwoo Choi Subject: [PATCH 10/19 v3] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:31 +0200 Message-Id: <20180514080640.12515-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-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 with the standard devm_gpiod_get_optional() call. 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. Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Chanwoo Choi Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.17.0 Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..9a1dca26362e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ struct s2mps11_info { * Array (size: number of regulators) with GPIO-s for external * sleep control. */ - int *ext_control_gpio; + struct gpio_desc **ext_control_gpiod; }; static int get_ramp_delay(int ramp_delay) @@ -524,7 +523,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) case S2MPS14X: if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) val = S2MPS14_ENABLE_SUSPEND; - else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) + else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -818,7 +817,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) { - int *gpio = s2mps11->ext_control_gpio; + struct gpio_desc **gpio = s2mps11->ext_control_gpiod; unsigned int i; unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, S2MPS14_LDO12 }; @@ -829,11 +828,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = of_get_named_gpio(rdata[reg].of_node, - "samsung,ext-control-gpios", 0); - if (gpio_is_valid(gpio[reg])) - dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", - gpio[reg], reg, rdata[reg].name); + gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, + rdata[reg].of_node, + "samsung,ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s2mps11-LDO"); + if (IS_ERR(gpio[reg])) { + dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n", + reg, rdata[reg].name); + continue; + } + if (gpio[reg]) + dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n", + reg, rdata[reg].name); } } @@ -1139,17 +1147,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, - sizeof(*s2mps11->ext_control_gpio) * rdev_num, + s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpiod) * rdev_num, GFP_KERNEL); - if (!s2mps11->ext_control_gpio) + if (!s2mps11->ext_control_gpiod) return -ENOMEM; - /* - * 0 is a valid GPIO so initialize all GPIO-s to negative value - * to indicate that external control won't be used for this regulator. - */ - for (i = 0; i < rdev_num; i++) - s2mps11->ext_control_gpio[i] = -EINVAL; if (!iodev->dev->of_node) { if (iodev->pdata) { @@ -1179,8 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio_initialized = true; for (i = 0; i < rdev_num; i++) { struct regulator_dev *regulator; @@ -1191,7 +1191,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].init_data; config.of_node = rdata[i].of_node; } - config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpiod = s2mps11->ext_control_gpiod[i]; regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); @@ -1202,7 +1202,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) goto out; } - if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { + if (s2mps11->ext_control_gpiod[i]) { ret = s2mps14_pmic_enable_ext_control(s2mps11, regulator); if (ret < 0) {