From patchwork Thu Nov 15 08:01:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151194 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691314ljp; Thu, 15 Nov 2018 00:01:36 -0800 (PST) X-Google-Smtp-Source: AJdET5dSlxd7laFndPprSQqZfGo2jKL28ZurMWSWWJrQl9fjLj/jGWHJmyQWHAjpzdcBQR1+uslr X-Received: by 2002:a63:6c4a:: with SMTP id h71-v6mr4872057pgc.326.1542268896200; Thu, 15 Nov 2018 00:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268896; cv=none; d=google.com; s=arc-20160816; b=LR7R6P8oWDIoobt9iFKILK7pWCdah4hS2LkQA6gFozX1tQv3Adff8bShV4+v6VvtxE GWCqPi79sVxWrPC95bRspDzOFtPzwi0OWCiAVZ9x3/76wD9Zl4MqoMESe5XSslyI0JSR 2oIJ3PVw2Br87DzeDpt6i7qetFNrL6C62Z63HWGwgg04WwJ0aH2eoCnxq6OUOx5RBiui Qrr86wQMAcfR8rMqoc9jg2r1NoVFzwXnpSe0eoIrLFSNPboXJCmHZkSuhch1twOa4ful Xx0Oy9HOIBxzv4goL0TvzFOenxCBAWjz7Be632hgBYuAD463aw3ApkbBo4ahAeLGr/5W UKHA== 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; bh=izSJwDOoJ3L6HTUkifpUePhxXhaoXbjxzOD3sLoJ6W0=; b=fqgngqnT0UWW1aKU3pIVAbty8RCeKCFfG76kUkEywyxK1SmKNXjqvAbngqqBw4N5cL Xshc3oe9YqDWsk45xgMHe6QvqXaAXvc5Go5+wGVwRLRhlYzFYis4hA9m7LF0C/VwcNcy DUkhZ79c0HbaV8mCnumq4XCS/da0quWtMurWch2u2rxoGMaI5eCJ8b9+OztyblXwHRuv 8mcakl5m8rFPkTgqNX/jCHMo7Xctx0WKKghBJ/k3NxhARMuftG7PwSP0feaYt0cZWIYc 2dyl4zOKJFvDCoaOvjviWwczMh2M1YPIzLSmCijGKNgKjX20YCp+Sfb2U0o6NwFOf2SG lWgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ErkZv0Ei; 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 q10-v6si25431393pls.344.2018.11.15.00.01.35; Thu, 15 Nov 2018 00:01:36 -0800 (PST) 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=ErkZv0Ei; 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 S1728949AbeKOSIT (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:19 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:42617 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbeKOSIT (ORCPT ); Thu, 15 Nov 2018 13:08:19 -0500 Received: by mail-lf1-f66.google.com with SMTP id l10so9856957lfh.9 for ; Thu, 15 Nov 2018 00:01:32 -0800 (PST) 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=izSJwDOoJ3L6HTUkifpUePhxXhaoXbjxzOD3sLoJ6W0=; b=ErkZv0EijwJK///fVYaUxEP9AoVIgf3fcwZqKCa41oSNU8hLv5qa/7wfYjdHv6kFpd Uvf2VrRobeVts/pueE3SCz3VyxOmKlrds2T56FQf2gI8ymQY/CwrPV/NbKpwS659cv/c Hptxir2aw76r7t9H6UT1I2bPdwxCfIqGM5euk= 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=izSJwDOoJ3L6HTUkifpUePhxXhaoXbjxzOD3sLoJ6W0=; b=Kon3P7NsoyPngHQjuSmCVRTYfbgEs21cCevimWrmCwuqjA7PMuFAzB2O/B7SrEZTZB RN0+46bJ9zkKtOQlwTD4K1Cv5DqmKPRFDxpAB//IexHJmWZu3Sp3LEJ3ycw6IqMCmwHH uz1O++ZwvhspdQVDU+qArkjQIbVMFMBdHNufl7MSDtVM79YdlRuZUTJyLmalGvFJ+BbW IYCftloDb7fi1aYiLJhBzO+eXTZxnnGLAEEyVvflRvdHqdZh0dqWS0Hg3MaZxKqc6Mun kGS4PY97+ML0go9kXojymh9gHxk744rawm7a2wGGNAH+/RwT5a27U/QTcA5/vRT3XEPk pwtQ== X-Gm-Message-State: AGRZ1gIKevNf3NP9XqFuEtwM3YJkFDRDPR07BZrL+ny1rbA5S5SZP49w E454H4fKnv38n7En00+AcgHFsw== X-Received: by 2002:a19:a7c1:: with SMTP id q184mr2725954lfe.4.1542268891912; Thu, 15 Nov 2018 00:01:31 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:30 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Sangbeom Kim , Chanwoo Choi , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [PATCH 1/8 v6] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Thu, 15 Nov 2018 09:01:17 +0100 Message-Id: <20181115080124.7789-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-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. Tested on Odroid XU3 (with s2mps11 although not using any GPIOs for regulators, so at least default paths are not broken). Cc: Sangbeom Kim Cc: Chanwoo Choi Cc: Bartlomiej Zolnierkiewicz Cc: Krzysztof Kozlowski Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski Signed-off-by: Linus Walleij --- ChangeLog v5->v6: - Tag on the nonexclusive bit as regulators can share a GPIO line. ChangeLog v4->v5: - Fold in a kzalloc() fix from Bartlomiej Zolnierkiewicz ChangeLog v3->v4: - Changed regulator name to "s2mps11-regulator" - Collected Krzysztof's review and test tags. 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.2 diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 5bb6f4ca48db..6fec45897194 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,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) @@ -511,7 +510,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; @@ -805,7 +804,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 }; @@ -816,11 +815,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 | GPIOD_FLAGS_BIT_NONEXCLUSIVE, + "s2mps11-regulator"); + 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); } } @@ -1126,17 +1134,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc_array(&pdev->dev, - rdev_num, sizeof(*s2mps11->ext_control_gpio), + s2mps11->ext_control_gpiod = devm_kmalloc_array(&pdev->dev, + rdev_num, sizeof(*s2mps11->ext_control_gpiod), 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) { @@ -1166,8 +1168,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; @@ -1178,7 +1178,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); @@ -1189,7 +1189,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) { From patchwork Thu Nov 15 08:01:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151195 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691404ljp; Thu, 15 Nov 2018 00:01:39 -0800 (PST) X-Google-Smtp-Source: AJdET5dsLN8CcdSgqP4KmAxgbCr+pbws1mQsGHILpHo6iB++1SBhP41zALHfL3cSzFu1/1jKnZqJ X-Received: by 2002:a63:e4d:: with SMTP id 13mr4513986pgo.369.1542268899781; Thu, 15 Nov 2018 00:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268899; cv=none; d=google.com; s=arc-20160816; b=OOCduQX2Kw3MJ+xi8s1YrXinrHJF0fG+LtYZdFwNm81uNu6GHhn56qH0tgrnHkcJo6 fwpFZs0pQCuck/UwVpZGDdqbBRWFvN7yXMEGaztAFpao7nIeOZdImfj0H3BLpbYMYbDt JUhCOBNfFPraTb1bEmRt/umadA2wOcUC9OVQtXQF11VDDEAvUqDK1l/mLA8Sjmc0yUCD 8SwR8fKvn9fsFpI0XYB16dbK/Xi83MpdgQP6gVLuw6+FGtU+LfU3hio/QXzEQo6kPI2k lMJlAOeaRSQJrG7wNDnyLDXYJ/Tuyrr+ezjJELdl4kzDcqgAqEL6iev0mqMbKn0vounp v6Vw== 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; bh=e409FRfNNxbNIv4WwP9QrFJYpyLvnrAbpReEHge2WlU=; b=r9NYNBcicVXKtum+5SYPVhhyOx7jukNV3LlUVyExovfI26IvgGtO/dCpHcvhCT/1Fd EnN+z3qwicwOR3/lcrOm4+SLTaNkGLorgqxEmBmAjwH4sJ2rbODbSphkjqZVXdwIR09w k2s4hfZsEfDCp+o/v8QbiGfbfgxdpBtOpTu6ACwv8xvFQGy0mVF1L2Tm/rW8ae02MxZW OVxV6SraWtRzAQ9mHd9wBuuHzC8t+bMb+2Sjh4oil/T5udHNc3Y/Mgag1lgZAqBij/EY gDjtjjS/2qgFV3kRdA5rVAaPr5Ack436Zbtskk2BXYm8FL9wA2OvKa8d5EMxzgj1cVX6 zHeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NG7aLZgZ; 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 e33-v6si27741031pld.314.2018.11.15.00.01.39; Thu, 15 Nov 2018 00:01:39 -0800 (PST) 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=NG7aLZgZ; 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 S1728986AbeKOSIX (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:23 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37594 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbeKOSIW (ORCPT ); Thu, 15 Nov 2018 13:08:22 -0500 Received: by mail-lj1-f193.google.com with SMTP id e5-v6so16486913lja.4 for ; Thu, 15 Nov 2018 00:01:35 -0800 (PST) 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=e409FRfNNxbNIv4WwP9QrFJYpyLvnrAbpReEHge2WlU=; b=NG7aLZgZQ3w5PKicl3pDJQq/avxWcBa5X6pf8oBGH0iMHdb9hstNtioFlZMnilZMz1 kYVUZ60fp/FoAMv9e6Es4ubk0dJcE8L/yLNTupFR2hLDIQ/Skq7Tm+N8TpPyRGToWV7P 4sqCPADj/OYpvjFIaWGAjDpW5rcKBtUFpTXoI= 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=e409FRfNNxbNIv4WwP9QrFJYpyLvnrAbpReEHge2WlU=; b=knmF9bvsZCnzjTDtO9LIjKEYrvOwgUonvXfHUQelqXCRi2n3xLcxH7D14jTkd64M7H svJqV8KPN9g5p7H1sdm2jeI5OheqKQP5mNIKxtOqGldvipvZgxtl2BmQC15KlyojSzGd C2oS06MHslpoCnm4SgiE6MNN6DoCYhoy9QD8ts8STIW4GB3QY071dTu+3N+hlAKfYVOv IRLPgR4j+V07338ReUiFew/VVR8JfAgELHhs/G7SkwsoU3hmFVkcrKxr73e3vzsg6Bw1 1OVoz/UcDWHFhRsAFjNiptD8oDdRTvlQQ9LS9ct9E47agpg7WVBcjOPZpLCCY84EPSoV OArw== X-Gm-Message-State: AGRZ1gJdk8eVfmJOKyFNl16YVMBJ18NyJh37J9X5cGp9V+ewfAn4ijCJ OpN2h3WT7gYp3pGGucC6Y4GaNQ== X-Received: by 2002:a2e:9b84:: with SMTP id z4-v6mr2937312lji.93.1542268894152; Thu, 15 Nov 2018 00:01:34 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:33 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , patches@opensource.cirrus.com Subject: [PATCH 2/8 v6] regulator: wm8994: Pass descriptor instead of GPIO number Date: Thu, 15 Nov 2018 09:01:18 +0100 Message-Id: <20181115080124.7789-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-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 or the board file decriptor table for the regulator. There is a single board file passing the GPIOs for LDO1 and LDO2 through platform data, so augment this to pass descriptors associated with the i2c device as well. The special GPIO enable DT property for the enable GPIO is nonstandard but this was accomodated in commit 6a537d48461deacc57c07ed86d9915e5aa4b3539 "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Acked-by: Charles Keepax Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v3->v6: - Request the GPIO line as shared as with other regulators. - Renumber to fit the rest of the patch series. ChangeLog v2->v3: - Collect Charles' ACK. ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 17 +++++++++++++++-- drivers/mfd/wm8994-core.c | 9 --------- drivers/regulator/wm8994-regulator.c | 20 ++++++++++++-------- include/linux/mfd/wm8994/pdata.h | 3 --- 4 files changed, 27 insertions(+), 22 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 5aa472892465..76c4855a03bc 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -194,8 +194,8 @@ static struct wm8994_pdata wm8994_pdata = { 0x3, /* IRQ out, active high, CMOS */ }, .ldo = { - { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, - { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, + { .init_data = &wm8994_ldo1, }, + { .init_data = &wm8994_ldo2, }, }, }; @@ -203,6 +203,18 @@ static const struct i2c_board_info wm1277_devs[] = { { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ .platform_data = &wm8994_pdata, .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, + .dev_name = "wm8958", + }, +}; + +static struct gpiod_lookup_table wm8994_gpiod_table = { + .dev_id = "i2c-wm8958", /* I2C device name */ + .table = { + GPIO_LOOKUP("GPION", 6, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("GPION", 4, + "wlf,ldo2ena", GPIO_ACTIVE_HIGH), + { }, }, }; @@ -381,6 +393,7 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, gpiod_add_lookup_table(&wm5102_reva_gpiod_table); gpiod_add_lookup_table(&wm5102_gpiod_table); + gpiod_add_lookup_table(&wm8994_gpiod_table); if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 22bd6525e09c..04a177efd245 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -306,14 +305,6 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) pdata->csnaddr_pd = of_property_read_bool(np, "wlf,csnaddr-pd"); - pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0); - if (pdata->ldo[0].enable < 0) - pdata->ldo[0].enable = 0; - - pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0); - if (pdata->ldo[1].enable < 0) - pdata->ldo[1].enable = 0; - return 0; } #else diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 7a4ce6df4f22..d7fec533c403 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -129,6 +129,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) int id = pdev->id % ARRAY_SIZE(pdata->ldo); struct regulator_config config = { }; struct wm8994_ldo *ldo; + struct gpio_desc *gpiod; int ret; dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); @@ -145,12 +146,15 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - if (pdata) { - config.ena_gpio = pdata->ldo[id].enable; - } else if (wm8994->dev->of_node) { - config.ena_gpio = wm8994->pdata.ldo[id].enable; - config.ena_gpio_initialized = true; - } + + /* Look up LDO enable GPIO from the parent device node */ + gpiod = devm_gpiod_get_optional(pdev->dev.parent, + id ? "wlf,ldo2ena" : "wlf,ldo1ena", + GPIOD_OUT_LOW | + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + config.ena_gpiod = gpiod; /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { @@ -159,7 +163,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) ldo->init_data = wm8994_ldo_default[id]; ldo->init_data.consumer_supplies = &ldo->supply; - if (!config.ena_gpio) + if (!gpiod) ldo->init_data.constraints.valid_ops_mask = 0; } else { ldo->init_data = *pdata->ldo[id].init_data; diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index b19c370fe81a..f346167c0e00 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -20,9 +20,6 @@ #define WM8994_NUM_AIF 3 struct wm8994_ldo_pdata { - /** GPIOs to enable regulator, 0 or less if not available */ - int enable; - const struct regulator_init_data *init_data; }; From patchwork Thu Nov 15 08:01:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151196 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691434ljp; Thu, 15 Nov 2018 00:01:41 -0800 (PST) X-Google-Smtp-Source: AJdET5cKaBMC/tuRD+WDXM1lWhjxoj8LMqYQ7Adsc2i8XqwQKfkFdlUGU1OkLf9rEE63gtUtOU03 X-Received: by 2002:a62:6bc8:: with SMTP id g191-v6mr5638024pfc.134.1542268901306; Thu, 15 Nov 2018 00:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268901; cv=none; d=google.com; s=arc-20160816; b=GSADjsxYNRtoYHUZQ9F2JoEIaTkYugAY46sWZMwl4PRjC+P5ExpiqxN5VLsh2FFyNi LAPMJUHKAnQwq5TrzSYJhV1wpAK4lKWpzbZFBzyCT6Y2B+qc9nuqVkl2sGAjn0CJJI/P XNcyLF49z/al4HctXn04dHpeSL4OURl8fnMQvSopp9u7Rpw/shOOXhQjqa+YOB1jjQBC h8UPztTlCUugxtfHtDdaPSzPTNM1Q9/GT5qK2bfctWBldpnU/6NHBb9r0NfVUrhF4Wku UrWZSxNtHlYWCUGsiWzTh1OfFyEoctLLMM8LgZ1aJQLF+zY+NBLvNE4yxxpDMr8h80CA z43A== 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; bh=Rq0isa9+uSFoYNz3NVzNiJqxPB2qDMbMU7T3rW8B1rk=; b=zKJn7qiU7mVZli4zBP5gj3itoXKdNAoQcXiRL5c2+uEtL3uPYqs6Low2BBC9XIcFD2 DyLQsZXN+zptRP9G3UpHqkX+dpIAC1T3/aMlXwD2tgF0i5wj2SYtXyeE9J7dnk8SYAgo dHz6z1wmyopFDn2jZMfgKbbdTO8CvzIWeVjzBjqSny/nKOmOX3lL3oOadEbwJvxbv0CA iXYXcItsZPnSv1zdY60wvInynRai3f6W5RdNyibzCmbsLswdQl5rB6CdxR2qu3D+pLUQ 0QNKapoifc+pWPhcourmlcifS7dY2TByiHFRgutE/m/hLBlmoMh28ZFDuOLkn4csXRb9 9JZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OrTDnXkA; 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 k134si26393755pga.401.2018.11.15.00.01.40; Thu, 15 Nov 2018 00:01:41 -0800 (PST) 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=OrTDnXkA; 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 S1729018AbeKOSIX (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:23 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33751 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728800AbeKOSIX (ORCPT ); Thu, 15 Nov 2018 13:08:23 -0500 Received: by mail-lj1-f196.google.com with SMTP id v1-v6so16481827ljd.0 for ; Thu, 15 Nov 2018 00:01:37 -0800 (PST) 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=Rq0isa9+uSFoYNz3NVzNiJqxPB2qDMbMU7T3rW8B1rk=; b=OrTDnXkAu6QGSbuDE3qVQIWSTXmbDS0mBFHBnk27vANuDuPV+yYun06I8r4ZUGj639 yMi4BAycWNEZiFzEqbewAOktiTZxLfmyjCowPqnoUHqwb/Ref90xNaWsjVAOYzHHQbFA oCsWeuLr9KjppjPK+hEtskmA0dkepiUF3c/Bs= 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=Rq0isa9+uSFoYNz3NVzNiJqxPB2qDMbMU7T3rW8B1rk=; b=SMBKayUOoT3Xq0BSS6tngdvxJNffnJDlh1vk7IvEd/Y3ECLTCUXzxN16BZOoFaMZfa SsIMaXUxO4Ol62+y+GHV1xvOW0ST+3gUSy7GdlDjxRYs2N8nrj/xPOEGSG3/hHtXevK9 xZdCp1HWbLPFg9AidBoKm3qHKliOwfJR5f6FoWlHKsK+9kPmDZJgFShdhXZI2kwYnfIk 6SpyOqqf8tErlwboLhYmyjrQ8PSiLQztDDrYy2v8HZdfi9ueYbvpRYSxxaDQCQoMmulz LDDiP1Yj/2kZQ8yEGp7JRN8F9Rz2Lmlu/DjcazErLQVT2Y60pBIDwrBLt5gd9MWjTR4A 8bBQ== X-Gm-Message-State: AGRZ1gIMKrzIDsh6aQ3x8OMg1vMT4t/wRS0uBPdq3ed+tcGMCrJwK1hk e9umCi/vX21aNSSp8ddkZ57WjA== X-Received: by 2002:a2e:8347:: with SMTP id l7-v6mr2130928ljh.152.1542268896584; Thu, 15 Nov 2018 00:01:36 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:35 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 3/8 v6] regulator: max77686: Pass descriptor instead of GPIO number Date: Thu, 15 Nov 2018 09:01:19 +0100 Message-Id: <20181115080124.7789-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-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, pass a descriptor looked up from the device tree configuration node. Tested on Odroid U3 (with max77686 although not using any GPIOs for regulators, so at least default paths are not broken). Cc: Chanwoo Choi Cc: Krzysztof Kozlowski Cc: Bartlomiej Zolnierkiewicz Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski Signed-off-by: Linus Walleij --- ChangeLog v4->v6: - Request regulator nonexclusive as expected by the regulator core. - Adjust numbering to fit the rest of the series. ChangeLog v3->v4: - Collected Krzysztof's test tags. ChangeLog v2->v3: - Name the regulator "max77686-regulator" - Set the regulator to NULL on erroneous lookup, restoring the old init data lookup behaviour. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max77686-regulator.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.17.2 diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index bee060937f56..f5cee1775905 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -76,6 +75,7 @@ enum max77686_ramp_rate { }; struct max77686_data { + struct device *dev; DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); /* Array indexed by regulator id */ @@ -255,16 +255,20 @@ static int max77686_of_parse_cb(struct device_node *np, case MAX77686_BUCK8: case MAX77686_BUCK9: case MAX77686_LDO20 ... MAX77686_LDO22: - config->ena_gpio = of_get_named_gpio(np, - "maxim,ena-gpios", 0); - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config->ena_gpio_initialized = true; + config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, + np, + "maxim,ena", + 0, + GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, + "max77686-regulator"); + if (IS_ERR(config->ena_gpiod)) + config->ena_gpiod = NULL; break; default: return 0; } - if (gpio_is_valid(config->ena_gpio)) { + if (config->ena_gpiod) { set_bit(desc->id, max77686->gpio_enabled); return regmap_update_bits(config->regmap, desc->enable_reg, @@ -507,6 +511,7 @@ static int max77686_pmic_probe(struct platform_device *pdev) if (!max77686) return -ENOMEM; + max77686->dev = &pdev->dev; config.dev = iodev->dev; config.regmap = iodev->regmap; config.driver_data = max77686; From patchwork Thu Nov 15 08:01:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151197 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691507ljp; Thu, 15 Nov 2018 00:01:44 -0800 (PST) X-Google-Smtp-Source: AJdET5fJZME9nzZ/AAUyklA1n4DxmX9VuxMTKppNAROjJ62U/0vyTNBNqFiyCMeyeSoBLZ81a7jp X-Received: by 2002:a63:d513:: with SMTP id c19mr4853652pgg.287.1542268904108; Thu, 15 Nov 2018 00:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268904; cv=none; d=google.com; s=arc-20160816; b=pwOOS29eFpHo5ADsa0o+Bpg0lc7qPPJOMADxfLlSepiSQlcBTNft/ncergcpZGhZkH jLVAJTJOtJ5frz33xu6l9txPwWZ3CEB5TEj8HHagmuW+Kc5xL/uLDqrNh1dWJvzM2wrI 6J62YFntTRu4RVMMtQv5ZPRQR4p2+Wl52a93S0RjHxkXseMyf1gOvIg1SWqn8KTyNAKd apSBpMfci88ODkAUednSJ5cALFMxSynyINGJ2GJbtt9xmzbHZX7g3Ran5ASsUGLDs+aX 6oQ1FIuXapcG9n1MocT/UmkTGlV26tHtkx53jG+36y7DZnQo9dAZ/kxh0gLYi1W5a42o seaQ== 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; bh=thTrAf6DNl+AdTfHofcmgWNbN2epGPDXGIY7Q7pHxno=; b=x/u73gS2X+/BxIR8IEDPBINCiPNZQBJZ4nHAN4J4So/5C1jVkzUPIsVcb1IppdSiUG 2nS3Zl0lCkocavnX/0Oowi96HY+vREjIlTEZItUo1k1rwPLJtnfDQKaiGdP8aJICPzaB tJQfLEoyp/B9DFvb/JthNGmhkVA2ORkWn25gP/tOw1Nr4gydB5QFZhWGAAUpXnSfxTWP o11N2qPoAt8i17Qa4LIyG7mA0t9TxBtWXGiZDKJSQodXCdQBSyCgbihKe/4krMmDjoQo PmZDvyhe98e48lXgOyEhUrq4SidygkcsiDT2dk4iwI8y9lbtf2MX/wGKkt0JJZu66rGe Li7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B9Q7vafl; 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 i12-v6si26096580plt.9.2018.11.15.00.01.43; Thu, 15 Nov 2018 00:01:44 -0800 (PST) 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=B9Q7vafl; 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 S1729053AbeKOSI1 (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:27 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:41679 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbeKOSI0 (ORCPT ); Thu, 15 Nov 2018 13:08:26 -0500 Received: by mail-lf1-f68.google.com with SMTP id c16so13474860lfj.8 for ; Thu, 15 Nov 2018 00:01:39 -0800 (PST) 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=thTrAf6DNl+AdTfHofcmgWNbN2epGPDXGIY7Q7pHxno=; b=B9Q7vaflS425klUJHcJlEMm4CwHBOebOfgJnrPYwsuoMJdlsvhI3Cb0FmC48RNbAek wSd9ELpLf+VVAQC+79guaMm5Yv00EV8NBP9VOQLxC+1kSqdQIzOtwiTbEOS0KSRbZMni TY4eBuCaWDOIgi87fFwCQir/UD1uulsb6uSYw= 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=thTrAf6DNl+AdTfHofcmgWNbN2epGPDXGIY7Q7pHxno=; b=S/PbGc5e5WapyjIrA+lSf3HoX1rF3x3pS2ZKXFBm+3yRZL2zXb7OMi/DGFxXYUg3TL jnDWmAoXDzmLdcvh3D93MuC7Lc+ESFzDWSEIw2f4LTrnBdL821l8cd3AJgpeyx5QWUVg Ista8uUGy2pnKd4J5Tp8F6zxiAzFHzRoIRxiBuwyI4SEpo4bCv9XXefXxLh0+q+DKOWE xRlimEPiI3lKRXJpMTXTqFBAUgr/ZKOx9Uqqx+OqjINw/fUg/5otG5RizAbcC0nek+lb Zf8IAI35EFJULeU+9rqAVgKzwcWxnQVfU9i4blzaYoXkwVx4c2FNNnYz6/uES5c5tox0 2kkQ== X-Gm-Message-State: AGRZ1gLyKhsXvBoQcKelI34H332yp7fAFUOy8qx4i2SwgoL9e6KmGRmg r+yNL3K6OsCKc0yupMezhxiXpQ== X-Received: by 2002:a19:9a8c:: with SMTP id c134mr2677532lfe.152.1542268898996; Thu, 15 Nov 2018 00:01:38 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:37 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Philipp Zabel , Petr Cvek , Robert Jarzmik , Paul Parsons Subject: [PATCH 4/8 v6] regulator: gpio: Convert to use descriptors Date: Thu, 15 Nov 2018 09:01:20 +0100 Message-Id: <20181115080124.7789-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This converts the GPIO regulator driver to use decriptors only. We have to let go of the array gpio handling: the fetched descriptors are handled individually anyway, and the array retrieveal function does not make it possible to retrieve each GPIO descriptor with unique flags. Instead get them one by one. We request the "enable" GPIO separately as before, and make sure that this line is requested as nonexclusive since enable lines can be shared and the regulator core expects this. Most users of the GPIO regulator are using device tree. There are two boards in the kernel using the gpio regulator from a non-devicetree path: PXA hx4700 and magician. Make sure to switch these over to use descriptors as well. Cc: Philipp Zabel # Magician Cc: Petr Cvek # Magician Cc: Robert Jarzmik # PXA Cc: Paul Parsons # hx4700 Signed-off-by: Linus Walleij --- ChangeLog v3->v6: - Make sure to request the GPIO line nonexclusive as with other regulator GPIOs. - Request the voltage controlling GPIOs from the name NULL as only "enable-gpio" is explicitly named. - Make sure to delete all unused struct members and assignments in board files. - Change numbering to fit the rest of the patches. ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- arch/arm/mach-pxa/hx4700.c | 23 ++-- arch/arm/mach-pxa/magician.c | 23 ++-- drivers/regulator/gpio-regulator.c | 146 ++++++++--------------- include/linux/regulator/gpio-regulator.h | 12 +- 4 files changed, 91 insertions(+), 113 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index b79b757fdd41..51d38d5e776a 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -702,9 +703,7 @@ static struct regulator_init_data bq24022_init_data = { .consumer_supplies = bq24022_consumers, }; -static struct gpio bq24022_gpios[] = { - { GPIO96_HX4700_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, -}; +static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW }; static struct gpio_regulator_state bq24022_states[] = { { .value = 100000, .gpios = (0 << 0) }, @@ -714,12 +713,10 @@ static struct gpio_regulator_state bq24022_states[] = { static struct gpio_regulator_config bq24022_info = { .supply_name = "bq24022", - .enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN, - .enable_high = 0, .enabled_at_boot = 0, - .gpios = bq24022_gpios, - .nr_gpios = ARRAY_SIZE(bq24022_gpios), + .gflags = bq24022_gpiod_gflags, + .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags), .states = bq24022_states, .nr_states = ARRAY_SIZE(bq24022_states), @@ -736,6 +733,17 @@ static struct platform_device bq24022 = { }, }; +static struct gpiod_lookup_table bq24022_gpiod_table = { + .dev_id = "gpio-regulator", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO96_HX4700_BQ24022_ISET2, + NULL, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN, + "enable", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* * StrataFlash */ @@ -878,6 +886,7 @@ static void __init hx4700_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); + gpiod_add_lookup_table(&bq24022_gpiod_table); platform_add_devices(devices, ARRAY_SIZE(devices)); pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup)); diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 14c0f80bc9e7..5d21de79135b 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -645,9 +645,8 @@ static struct regulator_init_data bq24022_init_data = { .consumer_supplies = bq24022_consumers, }; -static struct gpio bq24022_gpios[] = { - { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, -}; + +static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW }; static struct gpio_regulator_state bq24022_states[] = { { .value = 100000, .gpios = (0 << 0) }, @@ -657,12 +656,10 @@ static struct gpio_regulator_state bq24022_states[] = { static struct gpio_regulator_config bq24022_info = { .supply_name = "bq24022", - .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, - .enable_high = 0, .enabled_at_boot = 1, - .gpios = bq24022_gpios, - .nr_gpios = ARRAY_SIZE(bq24022_gpios), + .gflags = bq24022_gpiod_gflags, + .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags), .states = bq24022_states, .nr_states = ARRAY_SIZE(bq24022_states), @@ -679,6 +676,17 @@ static struct platform_device bq24022 = { }, }; +static struct gpiod_lookup_table bq24022_gpiod_table = { + .dev_id = "gpio-regulator", + .table = { + GPIO_LOOKUP("gpio-pxa", EGPIO_MAGICIAN_BQ24022_ISET2, + NULL, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, + "enable", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* * fixed regulator for ads7846 */ @@ -1007,6 +1015,7 @@ static void __init magician_init(void) regulator_register_always_on(0, "power", pwm_backlight_supply, ARRAY_SIZE(pwm_backlight_supply), 5000000); + gpiod_add_lookup_table(&bq24022_gpiod_table); platform_add_devices(ARRAY_AND_SIZE(devices)); } diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index b2f5ec4f658a..68a6c861bcad 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -30,16 +30,15 @@ #include #include #include -#include +#include #include #include -#include struct gpio_regulator_data { struct regulator_desc desc; struct regulator_dev *dev; - struct gpio *gpios; + struct gpio_desc **gpiods; int nr_gpios; struct gpio_regulator_state *states; @@ -82,7 +81,7 @@ static int gpio_regulator_set_voltage(struct regulator_dev *dev, for (ptr = 0; ptr < data->nr_gpios; ptr++) { state = (target & (1 << ptr)) >> ptr; - gpio_set_value_cansleep(data->gpios[ptr].gpio, state); + gpiod_set_value_cansleep(data->gpiods[ptr], state); } data->state = target; @@ -119,7 +118,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev, for (ptr = 0; ptr < data->nr_gpios; ptr++) { state = (target & (1 << ptr)) >> ptr; - gpio_set_value_cansleep(data->gpios[ptr].gpio, state); + gpiod_set_value_cansleep(data->gpiods[ptr], state); } data->state = target; @@ -138,7 +137,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, { struct gpio_regulator_config *config; const char *regtype; - int proplen, gpio, i; + int proplen, i; + int ngpios; int ret; config = devm_kzalloc(dev, @@ -153,59 +153,36 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, config->supply_name = config->init_data->constraints.name; - if (of_property_read_bool(np, "enable-active-high")) - config->enable_high = true; - if (of_property_read_bool(np, "enable-at-boot")) config->enabled_at_boot = true; of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); - if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT) - return ERR_PTR(config->enable_gpio); - - /* Fetch GPIOs. - optional property*/ - ret = of_gpio_count(np); - if ((ret < 0) && (ret != -ENOENT)) - return ERR_PTR(ret); - - if (ret > 0) { - config->nr_gpios = ret; - config->gpios = devm_kcalloc(dev, - config->nr_gpios, sizeof(struct gpio), - GFP_KERNEL); - if (!config->gpios) + /* Fetch GPIO init levels */ + ngpios = gpiod_count(dev, NULL); + if (ngpios > 0) { + config->gflags = devm_kzalloc(dev, + sizeof(enum gpiod_flags) + * ngpios, + GFP_KERNEL); + if (!config->gflags) return ERR_PTR(-ENOMEM); - proplen = of_property_count_u32_elems(np, "gpios-states"); - /* optional property */ - if (proplen < 0) - proplen = 0; + for (i = 0; i < ngpios; i++) { + u32 val; - if (proplen > 0 && proplen != config->nr_gpios) { - dev_warn(dev, "gpios <-> gpios-states mismatch\n"); - proplen = 0; - } + ret = of_property_read_u32_index(np, "gpios-states", i, + &val); - for (i = 0; i < config->nr_gpios; i++) { - gpio = of_get_named_gpio(np, "gpios", i); - if (gpio < 0) { - if (gpio != -ENOENT) - return ERR_PTR(gpio); - break; - } - config->gpios[i].gpio = gpio; - config->gpios[i].label = config->supply_name; - if (proplen > 0) { - of_property_read_u32_index(np, "gpios-states", - i, &ret); - if (ret) - config->gpios[i].flags = - GPIOF_OUT_INIT_HIGH; - } + /* Default to high per specification */ + if (ret) + config->gflags[i] = GPIOD_OUT_HIGH; + else + config->gflags[i] = + val ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; } } + config->ngpios = ngpios; /* Fetch states. */ proplen = of_property_count_u32_elems(np, "states"); @@ -255,7 +232,8 @@ static int gpio_regulator_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct gpio_regulator_data *drvdata; struct regulator_config cfg = { }; - int ptr, ret, state; + enum gpiod_flags gflags; + int ptr, ret, state, i; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); @@ -275,26 +253,17 @@ static int gpio_regulator_probe(struct platform_device *pdev) return -ENOMEM; } - if (config->nr_gpios != 0) { - drvdata->gpios = kmemdup(config->gpios, - config->nr_gpios * sizeof(struct gpio), - GFP_KERNEL); - if (drvdata->gpios == NULL) { - dev_err(&pdev->dev, "Failed to allocate gpio data\n"); - ret = -ENOMEM; - goto err_name; - } - - drvdata->nr_gpios = config->nr_gpios; - ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, - "Could not obtain regulator setting GPIOs: %d\n", - ret); - goto err_memgpio; - } + for (i = 0; i < config->ngpios; i++) { + drvdata->gpiods[i] = devm_gpiod_get_index(&pdev->dev, + NULL, + i, + config->gflags[i]); + if (IS_ERR(drvdata->gpiods[i])) + return PTR_ERR(drvdata->gpiods[i]); + /* This is good to know */ + gpiod_set_consumer_name(drvdata->gpiods[i], drvdata->desc.name); } + drvdata->nr_gpios = config->ngpios; drvdata->states = kmemdup(config->states, config->nr_states * @@ -303,7 +272,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) if (drvdata->states == NULL) { dev_err(&pdev->dev, "Failed to allocate state data\n"); ret = -ENOMEM; - goto err_stategpio; + goto err_name; } drvdata->nr_states = config->nr_states; @@ -330,7 +299,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) /* build initial state from gpio init data. */ state = 0; for (ptr = 0; ptr < drvdata->nr_gpios; ptr++) { - if (config->gpios[ptr].flags & GPIOF_OUT_INIT_HIGH) + if (config->gflags[ptr] == GPIOD_OUT_HIGH) state |= (1 << ptr); } drvdata->state = state; @@ -340,21 +309,19 @@ static int gpio_regulator_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = np; - if (gpio_is_valid(config->enable_gpio)) { - cfg.ena_gpio = config->enable_gpio; - cfg.ena_gpio_initialized = true; - } - cfg.ena_gpio_invert = !config->enable_high; - if (config->enabled_at_boot) { - if (config->enable_high) - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; - else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; - } else { - if (config->enable_high) - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; - else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + /* + * The signal will be inverted by the GPIO core if flagged so in the + * decriptor. + */ + if (config->enabled_at_boot) + gflags = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE; + else + gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE; + + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags); + if (IS_ERR(cfg.ena_gpiod)) { + ret = PTR_ERR(cfg.ena_gpiod); + goto err_memstate; } drvdata->dev = regulator_register(&drvdata->desc, &cfg); @@ -370,10 +337,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) err_memstate: kfree(drvdata->states); -err_stategpio: - gpio_free_array(drvdata->gpios, drvdata->nr_gpios); -err_memgpio: - kfree(drvdata->gpios); err_name: kfree(drvdata->desc.name); return ret; @@ -384,12 +347,7 @@ static int gpio_regulator_remove(struct platform_device *pdev) struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); regulator_unregister(drvdata->dev); - - gpio_free_array(drvdata->gpios, drvdata->nr_gpios); - kfree(drvdata->states); - kfree(drvdata->gpios); - kfree(drvdata->desc.name); return 0; diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h index 19fbd267406d..49c407afb944 100644 --- a/include/linux/regulator/gpio-regulator.h +++ b/include/linux/regulator/gpio-regulator.h @@ -21,6 +21,8 @@ #ifndef __REGULATOR_GPIO_H #define __REGULATOR_GPIO_H +#include + struct regulator_init_data; enum regulator_type; @@ -53,9 +55,9 @@ struct gpio_regulator_state { * This is used to keep the regulator at * the default state * @startup_delay: Start-up time in microseconds - * @gpios: Array containing the gpios needed to control - * the setting of the regulator - * @nr_gpios: Number of gpios + * @gflags: Array of GPIO configuration flags for initial + * states + * @ngpios: Number of GPIOs and configurations available * @states: Array of gpio_regulator_state entries describing * the gpio state for specific voltages * @nr_states: Number of states available @@ -74,8 +76,8 @@ struct gpio_regulator_config { unsigned enabled_at_boot:1; unsigned startup_delay; - struct gpio *gpios; - int nr_gpios; + enum gpiod_flags *gflags; + int ngpios; struct gpio_regulator_state *states; int nr_states; From patchwork Thu Nov 15 08:01:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151198 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691591ljp; Thu, 15 Nov 2018 00:01:49 -0800 (PST) X-Google-Smtp-Source: AJdET5ekjAfkvCVUzdX3z/DoUQSuqMl1FewUwEnt9LLjIEgdPov3s4rkbRlk345Do7ecK09lYx3v X-Received: by 2002:a17:902:32a4:: with SMTP id z33-v6mr5099286plb.168.1542268909517; Thu, 15 Nov 2018 00:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268909; cv=none; d=google.com; s=arc-20160816; b=rdFbeuh2YNRsyN6LofOBZ1y8W0zZKIw4XpCgTPz8IE8oUWZ/8ECPZnJNfoc4YYhl7s AczQo4aYGmlzww/+pWFimOZdRwO8titPiRSVlXojW7FbbVLOZZu3jLaxF6C1hzMzqGkO xXGaLliZs10lQZlddXN44qNalUtMrrxWoh7TMTLbllqb/BZhdeSuwlJxcUJktX8sa8cn eRsV6NCK2QwSW3WwMYNkiGyDpNqh6eQTgpLlKUf4HnwjRKTCnh4XnTOPI9jOm4hJBw6O eE2PRAdtk2HaSf4S90Tbb8SDcsX8UoxMAck58V7er5Tzlh6Wazc0vnej2ENzal+zD0f2 5iaw== 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; bh=pq8ovjkg8rpLP7yvaXN9qifs5X3fz7ynrjGWgp8fiIg=; b=UwudCObnnEoMRUKlw6TNkPUNp4wqYVuauH/VHAjDrbp+tGQQmV7e8EUL5aEv5rUXJE t0UDy5OS6jJJK6PEXJmHNjFmCux0DU1l0axUE58qVJ3awsleAnEI+ho+ZGo16ih3hAYO OHOS1dMprCl+3zfTxo/C+kEseWvusxLZRXtBub1ELrirwWUX4bWut1XYHHJvCE0xZcBb aqf8Pr3lYD7rQlgxn2epF3lMA9fvufdN83l6/hJ1PxtcWoe9FsDdhDsJTj7fNvu5b5qg xscM+X1c/AHE3ugpgkjhoNElM2YXQ6/Sfmk4znqWqM/ffwBYF9ueTlQuENFJ7jibqJkF mmQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JSHdRB7r; 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 i12-v6si26096580plt.9.2018.11.15.00.01.49; Thu, 15 Nov 2018 00:01:49 -0800 (PST) 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=JSHdRB7r; 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 S1729099AbeKOSIc (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:32 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36706 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbeKOSIc (ORCPT ); Thu, 15 Nov 2018 13:08:32 -0500 Received: by mail-lf1-f67.google.com with SMTP id h192so13483092lfg.3 for ; Thu, 15 Nov 2018 00:01:44 -0800 (PST) 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=pq8ovjkg8rpLP7yvaXN9qifs5X3fz7ynrjGWgp8fiIg=; b=JSHdRB7rnOE8bgOKzp2M08wHFmKjyjx3Ne+nSejJniJjzvXkDlg1al9yhUW4D7XU3k zi+Qv5RKQMKM2KtxC/nzWCWprh/Wg8SjnoV4quOVNMZXfKm8J4n+kbrUl4ooQqihQyZ0 NwaC4+0IcvTUgRm0kepxh+VzSK3TdARcvRkFU= 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=pq8ovjkg8rpLP7yvaXN9qifs5X3fz7ynrjGWgp8fiIg=; b=X6/x9O7tGqjs61oGuSYVHKDH9PZzKK0GsnpNYHpaVi8RKe/QP+oB2w00GAacbsaZBc mURZFf96QxEDHhOVc28JoMT+yOcdCuYYsnGXuv53WR8XdjFw5rZ1E1nhzQuD8vZnDvd6 EU+9jwnI39H1umB4hZJ3YKekrCibVkNEG0PDcfToG6SNTOKRegeD3ySY3TSDsQpd3GCv bxKXt1qqJigMdEkcDJOORH3RiPNxTVGdrNYSVfS3vZBBG2tKC2cbVFqymS4OVz7Hhps2 TGNGEZSQonlU2qPaqYvcu3kJcubeAs+x574Xxsen+AcDtNXFyglPbZFzbFIRPdGWL1My suCw== X-Gm-Message-State: AGRZ1gLJBmXgpE+MyAI5NHVTFBDi99ycB9yF7bM8jusw9NwK89iplJny DPlDBtM/9UA+4pyixMUXwDGrkA== X-Received: by 2002:a19:2d16:: with SMTP id k22mr2751687lfj.12.1542268903014; Thu, 15 Nov 2018 00:01:43 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:41 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Janusz Krzysztofik , Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Petr Cvek , Paul Parsons , Daniel Mack , Marc Zyngier , Geert Uytterhoeven , Russell King Subject: [PATCH 5/8 v6] regulator: fixed/gpio: Pull inversion/OD into gpiolib Date: Thu, 15 Nov 2018 09:01:21 +0100 Message-Id: <20181115080124.7789-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This pushes the handling of inversion semantics and open drain settings to the GPIO descriptor and gpiolib. All affected board files are also augmented. This is especially nice since we don't have to have any confusing flags passed around to the left and right littering the fixed and GPIO regulator drivers and the regulator core. It is all just very straight-forward: the core asks the GPIO line to be asserted or deasserted and gpiolib deals with the rest depending on how the platform is configured: if the line is active low, it deals with that, if the line is open drain, it deals with that too. Cc: Janusz Krzysztofik # OMAP1 Cc: Alexander Shiyan # i.MX boards user Cc: Haojian Zhuang # MMP2 maintainer Cc: Aaro Koskinen # OMAP1 maintainer Cc: Tony Lindgren # OMAP1,2,3 maintainer Cc: Mike Rapoport # EM-X270 maintainer Cc: Robert Jarzmik # EZX maintainer Cc: Philipp Zabel # Magician maintainer Cc: Petr Cvek # Magician Cc: Robert Jarzmik # PXA Cc: Paul Parsons # hx4700 Cc: Daniel Mack # Raumfeld maintainer Cc: Marc Zyngier # Zeus maintainer Cc: Geert Uytterhoeven # SuperH pinctrl/GPIO maintainer Cc: Russell King # SA1100 Signed-off-by: Linus Walleij --- ChangeLog v4->v6: - Split out parts relation to GPIO regulator descriptor conversion to the right patch. - Renumber to fit the rest of the series. - Daniel Mack says he will probably delete the Raumfeld board file and replace it with a device tree, I suggest we just deal with that conflict upstream. ChangeLog v3->v4: - Rebase on fixed regulator changes. ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch series - Cover the new user added in sa1100 --- arch/arm/mach-imx/mach-mx21ads.c | 1 - arch/arm/mach-imx/mach-mx27ads.c | 2 +- arch/arm/mach-mmp/brownstone.c | 1 - arch/arm/mach-omap1/board-ams-delta.c | 1 - arch/arm/mach-omap2/pdata-quirks.c | 1 - arch/arm/mach-pxa/em-x270.c | 1 - arch/arm/mach-pxa/ezx.c | 3 +- arch/arm/mach-pxa/raumfeld.c | 1 - arch/arm/mach-pxa/zeus.c | 3 +- arch/arm/mach-sa1100/assabet.c | 1 - arch/sh/boards/mach-ecovec24/setup.c | 2 -- .../intel-mid/device_libs/platform_bcm43xx.c | 1 - drivers/regulator/core.c | 8 ++--- drivers/regulator/da9055-regulator.c | 1 - drivers/regulator/fixed.c | 35 +++++-------------- include/linux/regulator/fixed.h | 10 ------ include/linux/regulator/gpio-regulator.h | 6 ---- 17 files changed, 13 insertions(+), 65 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 2e1e540f2e5a..d278fb672d40 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -205,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { .supply_name = "LCD", .microvolts = 3300000, - .enable_high = 1, .init_data = &mx21ads_lcd_regulator_init_data, }; diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c index f5e04047ed13..6dd7f57c332f 100644 --- a/arch/arm/mach-imx/mach-mx27ads.c +++ b/arch/arm/mach-imx/mach-mx27ads.c @@ -237,7 +237,7 @@ static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ .table = { - GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index a04e249c654b..d2560fb1e835 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -149,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = { static struct fixed_voltage_config brownstone_v_5vp = { .supply_name = "v_5vp", .microvolts = 5000000, - .enable_high = 1, .enabled_at_boot = 1, .init_data = &brownstone_v_5vp_data, }; diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 3d191fd52910..5a0c599ab516 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -268,7 +268,6 @@ static struct fixed_voltage_config modem_nreset_config = { .supply_name = "modem_nreset", .microvolts = 3300000, .startup_delay = 25000, - .enable_high = 1, .enabled_at_boot = 1, .init_data = &modem_nreset_data, }; diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 9fec5f84bf77..69a9182a9aff 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -330,7 +330,6 @@ static struct fixed_voltage_config pandora_vwlan = { .supply_name = "vwlan", .microvolts = 1800000, /* 1.8V */ .startup_delay = 50000, /* 50ms */ - .enable_high = 1, .init_data = &pandora_vmmc3, }; diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 67e37df637f5..97f428e3b77a 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -984,7 +984,6 @@ static struct fixed_voltage_config camera_dummy_config = { .supply_name = "camera_vdd", .input_supply = "vcc cam", .microvolts = 2800000, - .enable_high = 0, .init_data = &camera_dummy_initdata, }; diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c index 565965e9acc7..5e110e70ce5a 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -714,7 +714,6 @@ static struct regulator_init_data camera_regulator_initdata = { static struct fixed_voltage_config camera_regulator_config = { .supply_name = "camera_vdd", .microvolts = 2800000, - .enable_high = 0, .init_data = &camera_regulator_initdata, }; @@ -730,7 +729,7 @@ static struct gpiod_lookup_table camera_supply_gpiod_table = { .dev_id = "reg-fixed-voltage.1", .table = { GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, - NULL, GPIO_ACTIVE_HIGH), + NULL, GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index bd3c23ad6ce6..cffa182167a9 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -886,7 +886,6 @@ static struct regulator_init_data audio_va_initdata = { static struct fixed_voltage_config audio_va_config = { .supply_name = "audio_va", .microvolts = 5000000, - .enable_high = 1, .enabled_at_boot = 0, .init_data = &audio_va_initdata, }; diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index d53ea12fc766..9b8c2cf23111 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -426,7 +426,7 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = { .dev_id = "reg-fixed-voltage.0", .table = { GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, - NULL, GPIO_ACTIVE_HIGH), + NULL, GPIO_ACTIVE_LOW), { }, }, }; @@ -547,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = { static struct fixed_voltage_config zeus_ohci_regulator_config = { .supply_name = "vbus2", .microvolts = 5000000, /* 5.0V */ - .enable_high = 1, .startup_delay = 0, .init_data = &zeus_ohci_regulator_data, }; diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 3e8c0948abcc..3723d70af471 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -468,7 +468,6 @@ static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = { static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { .supply_name = "cf-power", .microvolts = 3300000, - .enable_high = 1, }; static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 06a894526a0b..ffddec161292 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -633,7 +633,6 @@ static struct regulator_init_data cn12_power_init_data = { static struct fixed_voltage_config cn12_power_info = { .supply_name = "CN12 SD/MMC Vdd", .microvolts = 3300000, - .enable_high = 1, .init_data = &cn12_power_init_data, }; @@ -674,7 +673,6 @@ static struct regulator_init_data sdhi0_power_init_data = { static struct fixed_voltage_config sdhi0_power_info = { .supply_name = "CN11 SD/MMC Vdd", .microvolts = 3300000, - .enable_high = 1, .init_data = &sdhi0_power_init_data, }; diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c index dbfc5cf2aa93..e3b57c346f3b 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c @@ -44,7 +44,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { */ .microvolts = 2000000, /* 1.8V */ .startup_delay = 250 * 1000, /* 250ms */ - .enable_high = 1, /* active high */ .enabled_at_boot = 0, /* disabled at boot */ .init_data = &bcm43xx_vmmc_data, }; diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2c66b528aede..109bd2bee868 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -80,7 +80,6 @@ struct regulator_enable_gpio { struct gpio_desc *gpiod; u32 enable_count; /* a number of enabled shared GPIO */ u32 request_count; /* a number of requested shared GPIO */ - unsigned int ena_gpio_invert:1; }; /* @@ -2047,7 +2046,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, } pin->gpiod = gpiod; - pin->ena_gpio_invert = config->ena_gpio_invert; list_add(&pin->list, ®ulator_ena_gpio_list); update_ena_gpio_to_rdev: @@ -2098,8 +2096,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) if (enable) { /* Enable GPIO at initial use */ if (pin->enable_count == 0) - gpiod_set_value_cansleep(pin->gpiod, - !pin->ena_gpio_invert); + gpiod_set_value_cansleep(pin->gpiod, 1); pin->enable_count++; } else { @@ -2110,8 +2107,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) /* Disable GPIO if not used */ if (pin->enable_count <= 1) { - gpiod_set_value_cansleep(pin->gpiod, - pin->ena_gpio_invert); + gpiod_set_value_cansleep(pin->gpiod, 0); pin->enable_count = 0; } } diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index 588c3d2445cf..417cafe2aba0 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c @@ -457,7 +457,6 @@ static int da9055_gpio_init(struct da9055_regulator *regulator, int gpio_mux = pdata->gpio_ren[id]; config->ena_gpiod = pdata->ena_gpiods[id]; - config->ena_gpio_invert = 1; /* * GPI pin is muxed with regulator to control the diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index ccc29038f19a..adaac8f5ddca 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -79,15 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - /* - * FIXME: we pulled active low/high and open drain handling into - * gpiolib so it will be handled there. Delete this in the second - * step when we also remove the custom inversion handling for all - * legacy boardfiles. - */ - config->enable_high = 1; - config->gpio_is_open_drain = 0; - if (of_find_property(np, "vin-supply", NULL)) config->input_supply = "vin"; @@ -151,24 +142,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - cfg.ena_gpio_invert = !config->enable_high; - if (config->enabled_at_boot) { - if (config->enable_high) - gflags = GPIOD_OUT_HIGH; - else - gflags = GPIOD_OUT_LOW; - } else { - if (config->enable_high) - gflags = GPIOD_OUT_LOW; - else - gflags = GPIOD_OUT_HIGH; - } - if (config->gpio_is_open_drain) { - if (gflags == GPIOD_OUT_HIGH) - gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; - else - gflags = GPIOD_OUT_LOW_OPEN_DRAIN; - } + /* + * The signal will be inverted by the GPIO core if flagged so in the + * decriptor. + */ + if (config->enabled_at_boot) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; /* * Some fixed regulators share the enable line between two diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 1a4340ed8e2b..f10140da7145 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h @@ -25,14 +25,6 @@ struct regulator_init_data; * @input_supply: Name of the input regulator supply * @microvolts: Output voltage of regulator * @startup_delay: Start-up time in microseconds - * @gpio_is_open_drain: Gpio pin is open drain or normal type. - * If it is open drain type then HIGH will be set - * through PULL-UP with setting gpio as input - * and low will be set as gpio-output with driven - * to low. For non-open-drain case, the gpio will - * will be in output and drive to low/high accordingly. - * @enable_high: Polarity of enable GPIO - * 1 = Active high, 0 = Active low * @enabled_at_boot: Whether regulator has been enabled at * boot or not. 1 = Yes, 0 = No * This is used to keep the regulator at @@ -48,8 +40,6 @@ struct fixed_voltage_config { const char *input_supply; int microvolts; unsigned startup_delay; - unsigned gpio_is_open_drain:1; - unsigned enable_high:1; unsigned enabled_at_boot:1; struct regulator_init_data *init_data; }; diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h index 49c407afb944..11cd6375215d 100644 --- a/include/linux/regulator/gpio-regulator.h +++ b/include/linux/regulator/gpio-regulator.h @@ -46,10 +46,6 @@ struct gpio_regulator_state { /** * struct gpio_regulator_config - config structure * @supply_name: Name of the regulator supply - * @enable_gpio: GPIO to use for enable control - * set to -EINVAL if not used - * @enable_high: Polarity of enable GPIO - * 1 = Active high, 0 = Active low * @enabled_at_boot: Whether regulator has been enabled at * boot or not. 1 = Yes, 0 = No * This is used to keep the regulator at @@ -71,8 +67,6 @@ struct gpio_regulator_state { struct gpio_regulator_config { const char *supply_name; - int enable_gpio; - unsigned enable_high:1; unsigned enabled_at_boot:1; unsigned startup_delay; From patchwork Thu Nov 15 08:01:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151199 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691631ljp; Thu, 15 Nov 2018 00:01:51 -0800 (PST) X-Google-Smtp-Source: AJdET5fPGzH7tttckvuzKkObMi9ONtC2ipUDj4GoXYs0Y/fb9pCatxJBsCIbQx4jJByuJu7CGKOg X-Received: by 2002:a62:5fc5:: with SMTP id t188-v6mr5426201pfb.84.1542268911198; Thu, 15 Nov 2018 00:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268911; cv=none; d=google.com; s=arc-20160816; b=zPirPHuiXAoxFWRpdRueDTIg9o9n7nmZlWXjtFTsC2XmGWxkdYeiKRdTfp64BMq2pL aNHSEPkiO6ld8dxm6azGoeBBwu3LZoQC6nDefG2wG8QoGMaBhe+MaIed58V/FSQ/dNqT DbUeS5E7zGaVfWKL7RCgZ/dK8/CzQW+a6QcFAkG+lZObg29ljeGFM/lNlUZMKORyxkGB PhGnY9D/N8/wJi5andfnahWd+XpaiiY1Yc6FcEarazWwqsUuU2bQD0fxxZuBLg630z6C CSp4MhiImlPBCOMRemoBSdSuoknPu48bXXBofGwiG7PNJi5DT4OAndvcgVdvMqV+Yqd1 dz0g== 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; bh=cAwx3JluMiA0iJvkhQszcUv3GhWr9rTeqVCy2GiE8hw=; b=PkUt+L9HenoujjbPFQXUfHa3h9wUyCKhR/1RefbN+O80RTurQjvwp9pRvc67HE1udi Fe4rDkVfgOn7/lqlqW9I0Fc+cn7HouJj10R+z3R7KQDCUM7m9ZaJnVhck40OT6MAIBN+ fhZMCGcNrB4+JrcO6FnZt85W7OBjgGKAO8+/Y7dtoLmuqRH7Imn45tRkQX3kzwm63snU VDx8hXXn6OUb2aTx9puOVsH+BhjDpm8z+RUEji2jJXi6PgSPQ5pFDDsIHJj8UjD4/7W1 wJU4dZOcit+g3onsclWqUMPdjuBSuxmQTk41Yw8Bh3bVSbWL+9M9Fbd7J+mh6O7Aev29 wzSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="TvlvOjJ/"; 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 n5si24165244pgl.485.2018.11.15.00.01.50; Thu, 15 Nov 2018 00:01:51 -0800 (PST) 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="TvlvOjJ/"; 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 S1729122AbeKOSId (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:33 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35757 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbeKOSIc (ORCPT ); Thu, 15 Nov 2018 13:08:32 -0500 Received: by mail-lj1-f194.google.com with SMTP id x85-v6so16495219ljb.2 for ; Thu, 15 Nov 2018 00:01:46 -0800 (PST) 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=cAwx3JluMiA0iJvkhQszcUv3GhWr9rTeqVCy2GiE8hw=; b=TvlvOjJ/Zgo0LdmbtYzcDsIdUYyzEf0hNaJ2NmWBqWexv46nSLtHA7R0ZN7gmTZM9k PzuxIxMHn43xPFXHW4AUwpJov7jzxrhkMkEmquxscq1fpoYFV/x6avSikxWqAaPQWkza w6y9lEnrQnWC1hIbZi/Br05i4iIgo5h/lLnU8= 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=cAwx3JluMiA0iJvkhQszcUv3GhWr9rTeqVCy2GiE8hw=; b=F/A0DzSelti9EGg4WdVuKgLG6KsFa/+Rnt9+0BYbGPQnaPNy5mP7/GPeSUiIeAu9hb 04u1umQGwQoO95dRqyZyHv+XYW8HsPewFIlg47i8ttf2vsQ3WwfuYu2fFzLzeqyzGCkY 4f4JQ4Ag1zGAz00nijmZ4GAsrXbaP2WhQrOcirNXfvMW6Yyxu0N/ZMbqmplltiOtFQ8v mON+fmhLubtRAszPCtFLaWtkR+uklnhbOFwDCYK0caFIsSVksrQ8hTKQOU56NfnCBFu0 P284u8FVpq+FnqMO45jMfXN4v4PHXRFUc/UgkE313sH0PaYzgxxCwa7tp/xgVFTTTVVE fqoA== X-Gm-Message-State: AA+aEWZILsqopyrcPgHXOPp8gzdBcRgHbFMJGJNx/6eJjNkRkmeq9SYq c0ss1UBiYFxFTzUmXzviM6V/2A== X-Received: by 2002:a2e:82d7:: with SMTP id n23-v6mr1273959ljh.143.1542268905506; Thu, 15 Nov 2018 00:01:45 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:44 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 6/8 v6] regulator: fixed/gpio: Update device tree bindings Date: Thu, 15 Nov 2018 09:01:22 +0100 Message-Id: <20181115080124.7789-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Deprecate the open drain binding for fixed regulator and indicate that we prefer this to be passed in the GPIO phandle flags. Clarify that the line inversion semantics for fixed and GPIO regulators completely overrides the active low flags in the phandle flags. Unfortunately this can not be changed to prefer that we pass the flags in the phandle: the bindings have been specified and deployed such that the presence/absence of this flag and only that controls the line inversion semantics. The crucial semantic is that the absence of the flag means the core will assume the line is active low, which in GPIO terms is an exception, as GPIO lines are normally assumed to be active high. This special device tree semantic cannot be changed without introducing a whole new compatible string for the fixed and GPIO regulators, so we just contain the situation. Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: Linus Walleij --- ChangeLog v3->v6: - Resending. ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Collect Rob's ACK. --- .../bindings/regulator/fixed-regulator.txt | 13 +++++++++++-- .../bindings/regulator/gpio-regulator.txt | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) -- 2.17.2 diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt index 0c2a6c8a1536..a7a1cd0dfa6e 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt @@ -8,10 +8,19 @@ Optional properties: - gpio: gpio to use for enable control - startup-delay-us: startup time in microseconds - enable-active-high: Polarity of GPIO is Active high -If this property is missing, the default assumed is Active low. + If this property is missing, the default assumed is Active low. + If the phandle flags to the GPIO handle also flag the line as active + low or high, that will be ignored for fixed regulators and the + presence or absence of this flag solely controls the inversion + semantics. +-vin-supply: Input supply name. + +Deprecated properties: - gpio-open-drain: GPIO is open drain type. If this property is missing then default assumption is false. --vin-supply: Input supply name. + Do not use this property in new device trees: instead use the + phandle flag to indicate to the GPIO provider that the line + should be handled as open drain. Any property defined as part of the core regulator binding, defined in regulator.txt, can also be used. diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt index 1f496159e2bb..8fef3e5358a2 100644 --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt @@ -14,6 +14,10 @@ Optional properties: defualt is LOW if nothing is specified. - startup-delay-us : Startup time in microseconds. - enable-active-high : Polarity of GPIO is active high (default is low). + If the phandle flags to the GPIO handle also flag the line as + active low or high, that will be ignored for fixed regulators + and the presence or absence of this flag solely controls the + inversion semantics. - regulator-type : Specifies what is being regulated, must be either "voltage" or "current", defaults to voltage. From patchwork Thu Nov 15 08:01:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151200 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691668ljp; Thu, 15 Nov 2018 00:01:53 -0800 (PST) X-Google-Smtp-Source: AJdET5fGthDuT0f4E6lmU3FGr6QCcMnb0Dni3bKiWMljym34+FW8DlE5nZJ8nUZT6ysXOaq3mX45 X-Received: by 2002:a63:9845:: with SMTP id l5mr4898617pgo.142.1542268913146; Thu, 15 Nov 2018 00:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268913; cv=none; d=google.com; s=arc-20160816; b=holLcPEjrWd9HE6UZZMZaB/EUS1OtGqWNRPQhD2RWBhOLjJR9sGdwQmQSV4JFUlD6d 1xjDmHWfwc874vIwLNbssTvzfbatqcxQU8H00QJdND+/v5d7Kz8LKeU+Xr+MJzIgQJN8 kdi5Qxle/DHFpUKrifZ+3pNyMcQgPKPF0OigKvdmUHVlJybkaCEuBah6pqz8Arzv4Wzj TGzBPPDYBQMqpA9M2Xl52UfQ9JJjO9httRxqxEEjoOcUlIQoloXPqw00GbrG0wLEV4bT gsXO9Gh/i8wxlCZvZ2VU7YbkcAKEzWGqEZzDMTzOZkev5pNCBGmqDkvVPS64lmaL5gOA KLcg== 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; bh=+gfqSmwj4PCQXaQnUcD+g6vIf/BCYMIzR0MwhukoLZU=; b=IsWKbAO1jU4MNPGXMTImbNVEGE8tB23MX5PIVggDL0Rn2qddnPOPMf6J5auZ2RIKcR 4jfYt3akDi2pt48hTibgwimk5JgbKTVAVlcACfr6WfzcB127OJLi3tG9gZlYHnCFzRv1 ZHLkB4+j+6be2hvPvbF+YrH1WF7aC2/XAxr0rqeqAPYwKUmC+2U7WWyVCzVr5Wu+SNv3 cvOzUYlOvXsGiQkyla0FAT3D096zQFy9O8+z8SBwdrdYb7SiHPoJcftWfnkIBbY5jagB MHYw7otvLik2ev71UIGpZi7nQiTtzhBJDn6Q+YKjh77AYp4vVoPzhByYTqQKF1qKb0Aq o06w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2u0Ex48; 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 n5si24165244pgl.485.2018.11.15.00.01.52; Thu, 15 Nov 2018 00:01:53 -0800 (PST) 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=Z2u0Ex48; 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 S1732294AbeKOSIg (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:36 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34122 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbeKOSIf (ORCPT ); Thu, 15 Nov 2018 13:08:35 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so13472559lfc.1 for ; Thu, 15 Nov 2018 00:01:49 -0800 (PST) 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=+gfqSmwj4PCQXaQnUcD+g6vIf/BCYMIzR0MwhukoLZU=; b=Z2u0Ex48BNpN+B9S+U4qmZd8niEav3tLTMNk12JHSX8sNB5tJWBexO51bFqiBtwWlc yly7B9tf8PuHmxIFsMOT/JaaIwP6fkP6njBKqzGkT8iynE56SSnM5QwTyG4gXBbVkLN9 ZC5ZR/Ie2rWsPPVXSU2lTCalRYiMt/s4SwqBA= 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=+gfqSmwj4PCQXaQnUcD+g6vIf/BCYMIzR0MwhukoLZU=; b=l6PnZODu9zdxfjS04fN8CQrKyByN5T8Aq1hzEL7Gbqv4Ve5Un7F1HyLH+y1qnIqOMw Iu61eXL0Ru0tm63eGQpar0/0rilsQ2aIDpc+yK5opeI1D87xtkTDg3ok4wcRDsfHTuR0 lztHncWFJRquqYGT+Q7guqdLlNIYKNZC1gxDCts/YEmdcipI0CVJONltkIO7o9f3FsB4 /LVVN3NsXhey2RG+SqN+R1VcpDErhLYmgo9OIbfe+CsPHkmIT5SVM4CAtxbZxPk0cci8 BxcmEmMaZfdduZYJ4ChyrhW/UiLV3kM/Ph/dhvISOxDJB7Kjub1Ck+Q55AeAr8RYnSsR J5eg== X-Gm-Message-State: AGRZ1gKYKJ6KYYI05GbVVKZ/0s5e4RCVxLCStTUu5NSAfnzyScCTrrfm CYZzTCl7ZTg7rl3+BdBwNfsv9w== X-Received: by 2002:a19:ec16:: with SMTP id b22mr3023486lfa.65.1542268908112; Thu, 15 Nov 2018 00:01:48 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:47 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij Subject: [PATCH 7/8 v6] regulator: gpio: Simplify probe path Date: Thu, 15 Nov 2018 09:01:23 +0100 Message-Id: <20181115080124.7789-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_* managed device resources and create a local struct device *dev variable to simplify the code inside probe(). Signed-off-by: Linus Walleij --- ChangeLog v3->v6: - Rebase on top of the other changes. - Change numbering to fit the rest of the series. ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/gpio-regulator.c | 55 +++++++++++++----------------- 1 file changed, 23 insertions(+), 32 deletions(-) -- 2.17.2 diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 68a6c861bcad..62ddea4a5255 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -228,31 +228,33 @@ static struct regulator_ops gpio_regulator_current_ops = { static int gpio_regulator_probe(struct platform_device *pdev) { - struct gpio_regulator_config *config = dev_get_platdata(&pdev->dev); - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct gpio_regulator_config *config = dev_get_platdata(dev); + struct device_node *np = dev->of_node; struct gpio_regulator_data *drvdata; struct regulator_config cfg = { }; enum gpiod_flags gflags; int ptr, ret, state, i; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), + drvdata = devm_kzalloc(dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); if (drvdata == NULL) return -ENOMEM; if (np) { - config = of_get_gpio_regulator_config(&pdev->dev, np, + config = of_get_gpio_regulator_config(dev, np, &drvdata->desc); if (IS_ERR(config)) return PTR_ERR(config); } - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); + drvdata->desc.name = devm_kstrdup(dev, config->supply_name, GFP_KERNEL); if (drvdata->desc.name == NULL) { - dev_err(&pdev->dev, "Failed to allocate supply name\n"); + dev_err(dev, "Failed to allocate supply name\n"); return -ENOMEM; } + for (i = 0; i < config->ngpios; i++) { drvdata->gpiods[i] = devm_gpiod_get_index(&pdev->dev, NULL, @@ -265,14 +267,14 @@ static int gpio_regulator_probe(struct platform_device *pdev) } drvdata->nr_gpios = config->ngpios; - drvdata->states = kmemdup(config->states, - config->nr_states * - sizeof(struct gpio_regulator_state), - GFP_KERNEL); + drvdata->states = devm_kmemdup(dev, + config->states, + config->nr_states * + sizeof(struct gpio_regulator_state), + GFP_KERNEL); if (drvdata->states == NULL) { - dev_err(&pdev->dev, "Failed to allocate state data\n"); - ret = -ENOMEM; - goto err_name; + dev_err(dev, "Failed to allocate state data\n"); + return -ENOMEM; } drvdata->nr_states = config->nr_states; @@ -291,9 +293,8 @@ static int gpio_regulator_probe(struct platform_device *pdev) drvdata->desc.ops = &gpio_regulator_current_ops; break; default: - dev_err(&pdev->dev, "No regulator type set\n"); - ret = -EINVAL; - goto err_memstate; + dev_err(dev, "No regulator type set\n"); + return -EINVAL; } /* build initial state from gpio init data. */ @@ -304,7 +305,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) } drvdata->state = state; - cfg.dev = &pdev->dev; + cfg.dev = dev; cfg.init_data = config->init_data; cfg.driver_data = drvdata; cfg.of_node = np; @@ -318,28 +319,20 @@ static int gpio_regulator_probe(struct platform_device *pdev) else gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE; - cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags); - if (IS_ERR(cfg.ena_gpiod)) { - ret = PTR_ERR(cfg.ena_gpiod); - goto err_memstate; - } + cfg.ena_gpiod = devm_gpiod_get_optional(dev, "enable", gflags); + if (IS_ERR(cfg.ena_gpiod)) + return PTR_ERR(cfg.ena_gpiod); drvdata->dev = regulator_register(&drvdata->desc, &cfg); if (IS_ERR(drvdata->dev)) { ret = PTR_ERR(drvdata->dev); - dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); - goto err_memstate; + dev_err(dev, "Failed to register regulator: %d\n", ret); + return ret; } platform_set_drvdata(pdev, drvdata); return 0; - -err_memstate: - kfree(drvdata->states); -err_name: - kfree(drvdata->desc.name); - return ret; } static int gpio_regulator_remove(struct platform_device *pdev) @@ -347,8 +340,6 @@ static int gpio_regulator_remove(struct platform_device *pdev) struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); regulator_unregister(drvdata->dev); - kfree(drvdata->states); - kfree(drvdata->desc.name); return 0; } From patchwork Thu Nov 15 08:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151201 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691721ljp; Thu, 15 Nov 2018 00:01:56 -0800 (PST) X-Google-Smtp-Source: AJdET5ew38Uc0ufMO0yX0MgkBdmHicgtdF6p6gim2Pzsy1erbs9NpwQpffoaS4W18qhbh0gaq217 X-Received: by 2002:a63:4c04:: with SMTP id z4mr4887550pga.312.1542268916421; Thu, 15 Nov 2018 00:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268916; cv=none; d=google.com; s=arc-20160816; b=dGnJFKgIPKspPwLEIvGBzzzZuWy5bwbFBaDNaoRc7EbnwNzEGIgUuOdoVbbUs92b/H YpsGDmbo+0svh+IRHbAXaYgqWQk+a8DZ6yN6CzaC0QkQmNimCBqr0OQ7wHKT7vPOaCQl H8A+HLyuIAZvAl5zQaWPccn1CA27X4e+qoV+d8RnrIgB0Hv5pbnzVernA+XtP/FY/xLy j/asqVusMJFGxTAB7r0cygthTgYceaQ6xQRiopwoyuU772uo1aUaB9M22ERiqiUEta6W vw7PDAczqQvr+yDIJAQXt2SXzVg8PT6fr3bUfoQRHcvEn1SFErxW0tUVNqbgTJHFwmDY /LAQ== 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; bh=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=GUMwxlnZK/gHNYgog436BKKucUEGqsOjGuEyyQ1WPdKGVKEGxj7koZNQfGiFf9CoQ1 Uc06Ng1xYliOOEMiOBENr6HtWje2QLz3smUDhw14k2vpWO6NBLPf858KqhA3RU21Si53 Dgtcdzh4An70ricB0dO1+9XkT8rGLCZA1j+2VtCca8NN5err9t6ac3ExzHc4du6duXD6 9Weusr7F7K+BB+A75pxMbfxGhbwnXzDgpuD8oOGwuhaNJ9TJk1WLvekPaKW1dNWZAo23 Y/AMHAtmXvUSt9HwaeWGVykCGXadyO0+hZ2+7FCyNrsEd97lur2NCPw530vv3ICp2gzr qbAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFbx1fFr; 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 z61-v6si27451129plb.46.2018.11.15.00.01.56; Thu, 15 Nov 2018 00:01:56 -0800 (PST) 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=QFbx1fFr; 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 S1732959AbeKOSIj (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:39 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44278 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbeKOSIi (ORCPT ); Thu, 15 Nov 2018 13:08:38 -0500 Received: by mail-lf1-f65.google.com with SMTP id z13so13455390lfe.11 for ; Thu, 15 Nov 2018 00:01:51 -0800 (PST) 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=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=QFbx1fFrDVQD4GDjnwzedh3woRcaXSa2om3SYgR/cbAfH69r6LuYSIqK1HGSaXoBgP tIyLfSAyc5i4oKExwD4+Kz4GmLcYDlgNsY69yStM6C77SX7/X9EdPxleqYsuQnM/SZNC bUlUQEgVfQSww1+6PTz64J75tM6KzljRR3xUM= 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=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=QnciiBB8BCDVSxkeuuX6AJrDpOGCs7KJtMkOpgV2Ye7eZeA7AWxDbu3/6zrTS/oom+ 46YXOBwAJKACDZeKYbrlG9LVWAiDnWIRvc9Qh9r/pQz72l3bsY9MxKYqj7E7C0+iW/8P 57ey47Xtm4KzTM8HaaQjJWyTb05TAmWJOSu8AfT7TPH5pRLuB2MjuPDJNedPQr5IZBjj RgwKzpgH4Zd63iG0PfTu2KSTCkpSpZ8irHSlHW3GwGsgTaw9UibgVjidolNqYSLBfdc3 wmq/ilOqb456qyfV/XAdcFyVG/Y98kSgWPWLOLsKh13wDFV5smOOQf2B7k4JxIfKM8Ne 5m7A== X-Gm-Message-State: AGRZ1gJOJe1dDs+PnLYSj0CHLII9EQaYI0gBNj/PVAXzUDFfTGhYiVsL FyY19QpI/ZL+SKcPZTn2/bSsCQ== X-Received: by 2002:a19:d381:: with SMTP id k123mr2968044lfg.101.1542268910984; Thu, 15 Nov 2018 00:01:50 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:49 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij Subject: [PATCH 8/8 v6] regulator: core: Only support passing enable GPIO descriptors Date: Thu, 15 Nov 2018 09:01:24 +0100 Message-Id: <20181115080124.7789-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we changed all providers to pass descriptors into the core for enable GPIOs instead of a global GPIO number, delete the support for passing GPIO numbers in, and we get a cleanup and size reduction in the core, and from a GPIO point of view we use the modern, cleaner interface. Signed-off-by: Linus Walleij --- ChangeLog v4->v6: - Rebase on top of the other changes. - Renumber to fit the rest of the series. ChangeLog v3->v4: - Also drop ena_gpio_invert from driver data ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 12 +----------- 2 files changed, 7 insertions(+), 37 deletions(-) -- 2.17.2 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 109bd2bee868..0eb5c48f1162 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -2015,35 +2014,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, { struct regulator_enable_gpio *pin; struct gpio_desc *gpiod; - int ret; - if (config->ena_gpiod) - gpiod = config->ena_gpiod; - else - gpiod = gpio_to_desc(config->ena_gpio); + gpiod = config->ena_gpiod; list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { if (pin->gpiod == gpiod) { - rdev_dbg(rdev, "GPIO %d is already used\n", - config->ena_gpio); + rdev_dbg(rdev, "GPIO is already used\n"); goto update_ena_gpio_to_rdev; } } - if (!config->ena_gpiod) { - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); - if (ret) - return ret; - } - pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL); - if (pin == NULL) { - if (!config->ena_gpiod) - gpio_free(config->ena_gpio); + if (pin == NULL) return -ENOMEM; - } pin->gpiod = gpiod; list_add(&pin->list, ®ulator_ena_gpio_list); @@ -2066,7 +2049,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) if (pin->gpiod == rdev->ena_pin->gpiod) { if (pin->request_count <= 1) { pin->request_count = 0; - gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); rdev->ena_pin = NULL; @@ -4336,15 +4318,13 @@ regulator_register(const struct regulator_desc *regulator_desc, goto clean; } - if (config->ena_gpiod || - ((config->ena_gpio || config->ena_gpio_initialized) && - gpio_is_valid(config->ena_gpio))) { + if (config->ena_gpiod) { mutex_lock(®ulator_list_mutex); ret = regulator_ena_gpio_request(rdev, config); mutex_unlock(®ulator_list_mutex); if (ret != 0) { - rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", - config->ena_gpio, ret); + rdev_err(rdev, "Failed to request enable GPIO: %d\n", + ret); goto clean; } } diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index a9c030192147..10ee158eac00 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -400,13 +400,7 @@ struct regulator_desc { * NULL). * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is * insufficient. - * @ena_gpio_initialized: GPIO controlling regulator enable was properly - * initialized, meaning that >= 0 is a valid gpio - * identifier and < 0 is a non existent gpio. - * @ena_gpio: GPIO controlling regulator enable. - * @ena_gpiod: GPIO descriptor controlling regulator enable. - * @ena_gpio_invert: Sense for GPIO enable control. - * @ena_gpio_flags: Flags to use when calling gpio_request_one() + * @ena_gpiod: GPIO controlling regulator enable. */ struct regulator_config { struct device *dev; @@ -415,11 +409,7 @@ struct regulator_config { struct device_node *of_node; struct regmap *regmap; - bool ena_gpio_initialized; - int ena_gpio; struct gpio_desc *ena_gpiod; - unsigned int ena_gpio_invert:1; - unsigned int ena_gpio_flags; }; /*