From patchwork Mon Feb 12 13:16:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128055 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3200843ljc; Mon, 12 Feb 2018 05:17:41 -0800 (PST) X-Google-Smtp-Source: AH8x225eXqGlHZQcIcqzKe5dpHRNJvpeRAOrkPKoP8+KBFCdv84hHb27JVdDEL3QiTuhWWohdl/0 X-Received: by 10.101.74.134 with SMTP id b6mr9402281pgu.137.1518441461731; Mon, 12 Feb 2018 05:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441461; cv=none; d=google.com; s=arc-20160816; b=Jajq9SVlUMLibza2groEowKPB3Q5vuav6x43DipuLy6I3TZwR+MkTsu6FcbM3WoL9w 2/19o3J4dnZrnOSgyuD0mAsYittMK6Ba/u80Knbnmp0njI/ARuwzytKejY7WfkHK0wYt JJwf/dApX1HYZvETiGwpYf2Z4xrY3mBQVMxz6SNDpzPV5KutIWWLq/nHcPHM3bWYjsdL 8IpPxBeuQQjUol89AVyZoww6fkz48Eky4JrGNQQjZvy66+t+4duSRLmCpEKe+knCuC8n 7+8HgKjk97j2F0dVbIYYyIsu0PWGd16RBTBWcd7avVM/vA5p33K0US7VQvQUCL+1TgOn PrcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9+ety9xIr/oE/yu+3Y3X18lDgdk1zRmG+8hw4AppQPo=; b=q4DYVj5LDe1VTrQCpLUvUkN8403ft8OLXrg7/ocA3Ng6UC3GPFGV54h26Na+1Wuxkd zkEZ8rb10pLtBlEpgvV08MDWEjN1fHkB7Qyzcf5JafdeZywxYQZk3rxeeYUC7yN5czMW zCBy0fADO6b39vCu8oxTmlvfDWxZc1qd1BagUbFzXYuYGgseoRB00z5+Wu72PLgcP+mV EPi1d8a5FqwCY86jDfSewHE3AdG/UAJzTUASFaX6T4Kfl7gaFXXr2xoE0ux1gldYkL1V qT9VurZAEg8XP5fU1+FOggN3AX0dE6RWeVJpULKmK6pis3QR6krz90Kqvek3UF8BVRT1 Kp4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fF/19+LD; 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 a84si2768073pfk.123.2018.02.12.05.17.41; Mon, 12 Feb 2018 05:17: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=fF/19+LD; 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 S935229AbeBLNRi (ORCPT + 13 others); Mon, 12 Feb 2018 08:17:38 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42458 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935210AbeBLNRb (ORCPT ); Mon, 12 Feb 2018 08:17:31 -0500 Received: by mail-lf0-f65.google.com with SMTP id w10so7597912lfc.9 for ; Mon, 12 Feb 2018 05:17:30 -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=9+ety9xIr/oE/yu+3Y3X18lDgdk1zRmG+8hw4AppQPo=; b=fF/19+LD0LumffXyIUjTfoXlNVJWqHNzVPxoomQ3mRxc0Ul9IVNx1gsm/FREw6bHVk A5UIAPhP9o9SvA9BOjBJDw3cAZOlzH7nGAIfRKt2DSudpsXTN2MW8DR7cd3PEzNOtBL3 h9P+PLMKhjrGKFOI/SgU9WNAw1aIe5Bj4VusM= 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=9+ety9xIr/oE/yu+3Y3X18lDgdk1zRmG+8hw4AppQPo=; b=EWDiMRU1IkVLphls2Aue+6A22R94/W9zO8Z9AWoFu8wIty7PJ3lwgAT7scHr5ej48b Pnb3toPw47yEfw2tvq2LFPFVwOjkM1dH4TBdYxDbGeoybrxUL33ddjaO0zDqGthwy4/G 3OZCqdoX++tUPsN/B+bywpa9oca3+wnvAE3S9jWvW/YkAZTYVy0g0JkgJ0XjcZxJcB4Y bf+jIneX3RYV11fc6XPTiSU8to87hQMi2BtQUIPCd9yJRFn2zujoVX1/U00Ph4MaAuGi ReO982MbJAKnLN/VJ0b50PRerEJbcnVvqd+7UFysDHmMqHyv+GRQX47rTs61wq0rm8W+ XUSA== X-Gm-Message-State: APf1xPBcOrm3FvJX4H8LvvAotnyodrPWFRJ35UFp7eFWPgs3WDOXEORD VcprK3XBf3cA2viw0oPaeq1nUg== X-Received: by 10.25.15.170 with SMTP id 42mr1238220lfp.6.1518441449940; Mon, 12 Feb 2018 05:17:29 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:29 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 01/21] regulator: core: Support passing an initialized GPIO enable descriptor Date: Mon, 12 Feb 2018 14:16:57 +0100 Message-Id: <20180212131717.27193-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We are currently passing a GPIO number from the global GPIO numberspace into the regulator core for handling enable GPIOs. This is not good since it ties into the global GPIO numberspace and uses gpio_to_desc() to overcome this. Start supporting passing an already initialized GPIO descriptor to the core instead: leaf drivers pick their descriptors, associated directly with the device node (or from ACPI or from a board descriptor table) and use that directly without any roundtrip over the global GPIO numberspace. This looks messy since it adds a bunch of extra code in the core, but at the end of the patch series we will delete the handling of the GPIO number and only deal with descriptors so things end up neat. Signed-off-by: Linus Walleij --- drivers/regulator/core.c | 25 ++++++++++++++++--------- include/linux/regulator/driver.h | 3 +++ 2 files changed, 19 insertions(+), 9 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index dd4708c58480..4549b93b0ff9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1937,7 +1937,10 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, struct gpio_desc *gpiod; int ret; - gpiod = gpio_to_desc(config->ena_gpio); + if (config->ena_gpiod) + gpiod = config->ena_gpiod; + else + gpiod = gpio_to_desc(config->ena_gpio); list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { if (pin->gpiod == gpiod) { @@ -1947,15 +1950,18 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, } } - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); - if (ret) - return ret; + 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) { - gpio_free(config->ena_gpio); + if (!config->ena_gpiod) + gpio_free(config->ena_gpio); return -ENOMEM; } @@ -4154,8 +4160,9 @@ regulator_register(const struct regulator_desc *regulator_desc, goto clean; } - if ((config->ena_gpio || config->ena_gpio_initialized) && - gpio_is_valid(config->ena_gpio)) { + if (config->ena_gpiod || + ((config->ena_gpio || config->ena_gpio_initialized) && + gpio_is_valid(config->ena_gpio))) { mutex_lock(®ulator_list_mutex); ret = regulator_ena_gpio_request(rdev, config); mutex_unlock(®ulator_list_mutex); diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4c00486b7a78..4fc96cb8e5d7 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -19,6 +19,7 @@ #include #include +struct gpio_desc; struct regmap; struct regulator_dev; struct regulator_config; @@ -387,6 +388,7 @@ struct regulator_desc { * 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() */ @@ -399,6 +401,7 @@ struct regulator_config { bool ena_gpio_initialized; int ena_gpio; + struct gpio_desc *ena_gpiod; unsigned int ena_gpio_invert:1; unsigned int ena_gpio_flags; }; From patchwork Mon Feb 12 13:16:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128087 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3204943ljc; Mon, 12 Feb 2018 05:22:43 -0800 (PST) X-Google-Smtp-Source: AH8x225lUS9mE5uJo27QXGNpNMyaUIcc3QtyiNdfwdbSFhAlED5ifXoJygYD5kLLnllYuVePVs9v X-Received: by 10.98.137.6 with SMTP id v6mr11805017pfd.179.1518441763695; Mon, 12 Feb 2018 05:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441763; cv=none; d=google.com; s=arc-20160816; b=C57U8GcdvfVoMJbnvmGnUI5PRrmG02caN/qrV2wbdepzR0in2Q3DQWGKyVG7h/88rg 4rUF3y7/9wLiKzhRS6tjOLJr2Y7pjS5qmtJhGATAD9SX4842+GunpT9jmVVznHgwJOXK DkKNk7IiiBAjNj1imfprRussRUUnajPI9Jg9EmlM6oeuJgSMWs1A5GvXwYsG4CW9gmGe Kflqx+OzTBvmUntyBF6/xIFQ9IMVF+L25PiOAxJZfnXWUUtf/qlmvC0vwZVMpaAqPdkI husffp44+A/l+QRZbVQsetHCUp7xHF15pKCrNT4OaODK9oecNb1A+cmOziSglrL7MrHS 0VtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5wly3XivhYvhQplhIH/KIJfb5OD+jITv1HUO9l0l9rc=; b=DLpv5srmWni7sukaulG7UTXD/YCRB75nIHfB7I4BjUxEGrVQyZF3f/s9n2bbuJH40T pV4QX3Z2CXQnZ1Ojf3yIkAytdVr1A4PYQYjmuZw776pwTE9nx9n5eIlxCRWlwCBtkrNv FrPFM7tGCxlzWNv8UqNghxrRdBhB/BrHQWE2QPfG08yYxLp9JksgKLdF0ex8bGyxeelT uY8NVwNpIOoiF8vjRstO7DSomUtHbut5/w4Ubjg2MXFl8C86GgfM+LQrBznVoixOJTNd VcoJdgNdM7DkVgNUqYy5jBJTwwLRqiQaM/TPfxFZZWywCygGU+BLTfyG839fDRE3M00V /osw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dgUSqESA; 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 90-v6si1002676pld.541.2018.02.12.05.22.43; Mon, 12 Feb 2018 05:22:43 -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=dgUSqESA; 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 S935476AbeBLNWk (ORCPT + 13 others); Mon, 12 Feb 2018 08:22:40 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43056 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935212AbeBLNRg (ORCPT ); Mon, 12 Feb 2018 08:17:36 -0500 Received: by mail-lf0-f67.google.com with SMTP id q69so2533301lfi.10 for ; Mon, 12 Feb 2018 05:17: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=5wly3XivhYvhQplhIH/KIJfb5OD+jITv1HUO9l0l9rc=; b=dgUSqESAU/tug/zi1elVl807EY04gvfvqrFyLoTDfG9A4CEV2sr7rJQdL+vqTKf2p6 QRca2dVZAZOflOqlAAGSWZAaWXjg52UlRRDYagYSLLKvKvReRc9SZznA1FMc9RT2Qke/ ff9qSBjsRzRbp3xsYQlkgyjV6jLPp33j8KU1U= 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=5wly3XivhYvhQplhIH/KIJfb5OD+jITv1HUO9l0l9rc=; b=ZUqrdgX4+n8DXUBCUBhUYFYnVeKs1F/RtuMW2k3gbeDXNvmW1LXBCJx++R4BCN6tzC QtAXi2ExZD3EeblsJGFhpnwGPSVQoGTbmAnyNVULvMOSh0trFJeb7N59E4tRt67aeB8Z rwXaHcSCEF8P0u1epCZqCjTJr5stnhDUvt1sLjv5P3xEOk5TSolJ3mU5Ekr0mSvWUBVU RvtjgHW/uVJrY43gDcDQKC3LbN/HO8XQRbkbm7zYfTyNflUcS/r/Gp/GM/c0vpSPJs1T 5WFkoE9tWabXx/gnKpK3UflUIIVPbJ7q1kf8xNqhQhT9wanT60LBNJzqz1VFGrSmuYuL 4mlg== X-Gm-Message-State: APf1xPCMT2ntcsdU2ya0gaGrFwmWKxhZVIc9nAb/cUsmxzysys/wCsrw tLoVcXpPQk4pxSF6XngY6fqEoA== X-Received: by 10.46.68.131 with SMTP id b3mr3372616ljf.13.1518441454541; Mon, 12 Feb 2018 05:17:34 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:33 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Andy Shevchenko , Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Daniel Mack , Marc Zyngier , Geert Uytterhoeven Subject: [PATCH 02/21] regulator: fixed: Convert to use GPIO descriptor only Date: Mon, 12 Feb 2018 14:16:58 +0100 Message-Id: <20180212131717.27193-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we augmented the regulator core to accept a GPIO descriptor instead of a GPIO number, we can augment the fixed GPIO regulator to look up and pass that descriptor directly from device tree or board GPIO descriptor look up tables. Some boards just auto-enumerate their fixed regulator platform devices and I have assumed they get names like "fixed-regulator.0" but it's pretty hard to guess this. I need some testing from board maintainers to be sure. Other boards are straight forward, using just plain "fixed-regulator" (ID -1) or "fixed-regulator.1" hammering down the device ID. The OMAP didn't have proper label names on its GPIO chips so I have fixed this with a separate patch to the GPIO tree. It seems the da9055 and da9211 has never got around to actually passing any enable gpio into its platform data (not the in-tree code anyway) so we can just decide to simply pass a descriptor instead. The fixed GPIO-controlled regulator in mach-pxa/ezx.c was confusingly named "*_dummy_supply_device" while it is a very real device backed by a GPIO line. There is nothing dummy about it at all, so I renamed it with the infix *_regulator_* as part of this patch set. For the patch hunk hitting arch/blackfin I would say I do not expect testing, review or ACKs anymore so if it works, it works. The hunk hitting the x86 BCM43xx driver is especially tricky as the number comes out of SFI which is a mystery to me. I definately need someone to look at this. (Hi Andy.) Cc: Andy Shevchenko # Check the x86 BCM stuff 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: Daniel Mack # Raumfeld maintainer Cc: Marc Zyngier # Zeus maintainer Cc: Geert Uytterhoeven # SuperH pinctrl/GPIO maintainer Signed-off-by: Linus Walleij --- arch/arm/mach-imx/mach-mx21ads.c | 13 ++++++++- arch/arm/mach-imx/mach-mx27ads.c | 12 +++++++- arch/arm/mach-mmp/brownstone.c | 12 +++++++- arch/arm/mach-omap1/board-ams-delta.c | 14 ++++++++- arch/arm/mach-omap2/pdata-quirks.c | 16 ++++++++++- arch/arm/mach-pxa/em-x270.c | 1 - arch/arm/mach-pxa/ezx.c | 33 ++++++++++++++-------- arch/arm/mach-pxa/magician.c | 2 +- arch/arm/mach-pxa/raumfeld.c | 12 ++++++-- arch/arm/mach-pxa/zeus.c | 23 +++++++++++++-- arch/arm/mach-s3c64xx/mach-crag6410.c | 1 - arch/arm/mach-s3c64xx/mach-smdk6410.c | 1 - arch/blackfin/mach-bf537/boards/stamp.c | 14 ++++++++- arch/sh/boards/mach-ecovec24/setup.c | 27 ++++++++++++++++-- .../intel-mid/device_libs/platform_bcm43xx.c | 19 +++++++++++-- drivers/regulator/fixed-helper.c | 1 - drivers/regulator/fixed.c | 33 +++++++++++----------- include/linux/regulator/fixed.h | 3 -- 18 files changed, 186 insertions(+), 51 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 5e366824814f..5d3b6b4fe6db 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -175,6 +176,7 @@ static struct resource mx21ads_mmgpio_resource = DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); static struct bgpio_pdata mx21ads_mmgpio_pdata = { + .label = "mx21ads-mmgpio", .base = MX21ADS_MMGPIO_BASE, .ngpio = 16, }; @@ -203,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, - .gpio = MX21ADS_IO_LCDON, .enable_high = 1, .init_data = &mx21ads_lcd_regulator_init_data, }; @@ -216,6 +217,15 @@ static struct platform_device mx21ads_lcd_regulator = { }, }; +static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ + .table = { + GPIO_LOOKUP("mx21ads-mmgpio", 9, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * Connected is a portrait Sharp-QVGA display * of type: LQ035Q7DB02 @@ -311,6 +321,7 @@ static void __init mx21ads_late_init(void) { imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata); + gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table); platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); mx21ads_cs8900_resources[1].start = diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c index a04bb094ded1..0fdb88db0cbd 100644 --- a/arch/arm/mach-imx/mach-mx27ads.c +++ b/arch/arm/mach-imx/mach-mx27ads.c @@ -16,6 +16,7 @@ #include /* Needed for gpio_to_irq() */ #include +#include #include #include #include @@ -230,10 +231,17 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = { static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { .supply_name = "LCD", .microvolts = 3300000, - .gpio = MX27ADS_LCD_GPIO, .init_data = &mx27ads_lcd_regulator_init_data, }; +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, "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void __init mx27ads_regulator_init(void) { struct gpio_chip *vchip; @@ -247,6 +255,8 @@ static void __init mx27ads_regulator_init(void) vchip->set = vgpio_set; gpiochip_add_data(vchip, NULL); + gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table); + platform_device_register_data(NULL, "reg-fixed-voltage", PLATFORM_DEVID_AUTO, &mx27ads_lcd_regulator_pdata, diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index d1613b954926..563b5a278d65 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -148,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, - .gpio = GPIO_5V_ENABLE, .enable_high = 1, .enabled_at_boot = 1, .init_data = &brownstone_v_5vp_data, @@ -162,6 +162,15 @@ static struct platform_device brownstone_v_5vp_device = { }, }; +static struct gpiod_lookup_table brownstone_v_5vp_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", /* .id set to 1 above */ + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_5V_ENABLE, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct max8925_platform_data brownstone_max8925_info = { .irq_base = MMP_NR_IRQS, }; @@ -217,6 +226,7 @@ static void __init brownstone_init(void) mmp2_add_isram(&mmp2_isram_platdata); /* enable 5v regulator */ + gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table); platform_device_register(&brownstone_v_5vp_device); } diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 52e8e53ca154..759fa18f6ab4 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ #include +#include #include #include #include @@ -203,6 +204,7 @@ static struct resource latch2_resources[] = { }; static struct bgpio_pdata latch2_pdata = { + .label = "ams-delta-latch2", .base = AMS_DELTA_LATCH2_GPIO_BASE, .ngpio = AMS_DELTA_LATCH2_NGPIO, }; @@ -272,7 +274,6 @@ static struct regulator_init_data modem_nreset_data = { static struct fixed_voltage_config modem_nreset_config = { .supply_name = "modem_nreset", .microvolts = 3300000, - .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET, .startup_delay = 25000, .enable_high = 1, .enabled_at_boot = 1, @@ -287,6 +288,16 @@ static struct platform_device modem_nreset_device = { }, }; +static struct gpiod_lookup_table modem_nreset_gpiod_table = { + .dev_id = "reg-fixed-voltage", + .table = { + /* The AMS_DELTA_GPIO_PIN_MODEM_NRESET is at offset 12 */ + GPIO_LOOKUP("ams-delta-latch2", 12, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + struct modem_private_data { struct regulator *regulator; }; @@ -570,6 +581,7 @@ static int __init late_init(void) platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); + gpiod_add_lookup_table(&modem_nreset_gpiod_table); err = platform_device_register(&modem_nreset_device); if (err) { pr_err("Couldn't register the modem regulator device\n"); diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 6b433fce65a5..4ddde151809c 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -330,7 +331,6 @@ static struct regulator_init_data pandora_vmmc3 = { static struct fixed_voltage_config pandora_vwlan = { .supply_name = "vwlan", .microvolts = 1800000, /* 1.8V */ - .gpio = PANDORA_WIFI_NRESET_GPIO, .startup_delay = 50000, /* 50ms */ .enable_high = 1, .init_data = &pandora_vmmc3, @@ -344,6 +344,19 @@ static struct platform_device pandora_vwlan_device = { }, }; +static struct gpiod_lookup_table pandora_vwlan_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + /* + * As this is a low GPIO number it should be at the first + * GPIO bank. + */ + GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void pandora_wl1251_init_card(struct mmc_card *card) { /* @@ -405,6 +418,7 @@ static void __init pandora_wl1251_init(void) static void __init omap3_pandora_legacy_init(void) { platform_device_register(&pandora_backlight); + gpiod_add_lookup_table(&pandora_vwlan_gpiod_table); platform_device_register(&pandora_vwlan_device); omap_hsmmc_init(pandora_mmc3); omap_hsmmc_late_init(pandora_mmc3); diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 49022ad338e9..6d7d93981098 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -987,7 +987,6 @@ static struct fixed_voltage_config camera_dummy_config = { .supply_name = "camera_vdd", .input_supply = "vcc cam", .microvolts = 2800000, - .gpio = -1, .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 2c90b58f347d..2b4bd6d94855 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -698,31 +699,39 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = { #if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910) /* camera */ -static struct regulator_consumer_supply camera_dummy_supplies[] = { +static struct regulator_consumer_supply camera_regulator_supplies[] = { REGULATOR_SUPPLY("vdd", "0-005d"), }; -static struct regulator_init_data camera_dummy_initdata = { - .consumer_supplies = camera_dummy_supplies, - .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies), +static struct regulator_init_data camera_regulator_initdata = { + .consumer_supplies = camera_regulator_supplies, + .num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies), .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS, }, }; -static struct fixed_voltage_config camera_dummy_config = { +static struct fixed_voltage_config camera_regulator_config = { .supply_name = "camera_vdd", .microvolts = 2800000, - .gpio = GPIO50_nCAM_EN, .enable_high = 0, - .init_data = &camera_dummy_initdata, + .init_data = &camera_regulator_initdata, }; -static struct platform_device camera_supply_dummy_device = { +static struct platform_device camera_supply_regulator_device = { .name = "reg-fixed-voltage", .id = 1, .dev = { - .platform_data = &camera_dummy_config, + .platform_data = &camera_regulator_config, + }, +}; + +static struct gpiod_lookup_table camera_supply_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, + "enable", GPIO_ACTIVE_HIGH), + { }, }, }; #endif @@ -800,7 +809,7 @@ static struct i2c_board_info a780_i2c_board_info[] = { static struct platform_device *a780_devices[] __initdata = { &a780_gpio_keys, - &camera_supply_dummy_device, + &camera_supply_regulator_device, }; static void __init a780_init(void) @@ -823,6 +832,7 @@ static void __init a780_init(void) if (a780_camera_init() == 0) pxa_set_camera_info(&a780_pxacamera_platform_data); + gpiod_add_lookup_table(&camera_supply_gpiod_table); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(a780_devices)); @@ -892,6 +902,7 @@ static void __init e680_init(void) pxa_set_keypad_info(&e680_keypad_platform_data); + gpiod_add_lookup_table(&camera_supply_gpiod_table); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(e680_devices)); @@ -1098,7 +1109,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = { static struct platform_device *a910_devices[] __initdata = { &a910_gpio_keys, - &camera_supply_dummy_device, + &camera_supply_regulator_device, }; static void __init a910_init(void) diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index c5325d1ae77b..14c0f80bc9e7 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -696,7 +697,6 @@ static struct regulator_init_data vads7846_regulator = { static struct fixed_voltage_config vads7846 = { .supply_name = "vads7846", .microvolts = 3300000, /* probably */ - .gpio = -EINVAL, .startup_delay = 0, .init_data = &vads7846_regulator, }; diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 4d5d05cf87d6..58833dcd2293 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -875,7 +875,6 @@ static struct regulator_init_data audio_va_initdata = { static struct fixed_voltage_config audio_va_config = { .supply_name = "audio_va", .microvolts = 5000000, - .gpio = GPIO_AUDIO_VA_ENABLE, .enable_high = 1, .enabled_at_boot = 0, .init_data = &audio_va_initdata, @@ -889,6 +888,15 @@ static struct platform_device audio_va_device = { }, }; +static struct gpiod_lookup_table audio_va_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_AUDIO_VA_ENABLE, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* Dummy supplies for Codec's VD/VLC */ static struct regulator_consumer_supply audio_dummy_supplies[] = { @@ -907,7 +915,6 @@ static struct regulator_init_data audio_dummy_initdata = { static struct fixed_voltage_config audio_dummy_config = { .supply_name = "audio_vd", .microvolts = 3300000, - .gpio = -1, .init_data = &audio_dummy_initdata, }; @@ -1022,6 +1029,7 @@ static void __init raumfeld_audio_init(void) else gpio_direction_output(GPIO_MCLK_RESET, 1); + gpiod_add_lookup_table(&audio_va_gpiod_table); platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices)); } diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index e3851795d6d7..58e05afcece0 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -410,7 +411,6 @@ static struct regulator_init_data can_regulator_init_data = { static struct fixed_voltage_config can_regulator_pdata = { .supply_name = "CAN_SHDN", .microvolts = 3300000, - .gpio = ZEUS_CAN_SHDN_GPIO, .init_data = &can_regulator_init_data, }; @@ -422,6 +422,15 @@ static struct platform_device can_regulator_device = { }, }; +static struct gpiod_lookup_table can_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct mcp251x_platform_data zeus_mcp2515_pdata = { .oscillator_frequency = 16*1000*1000, }; @@ -538,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 */ - .gpio = ZEUS_USB2_PWREN_GPIO, .enable_high = 1, .startup_delay = 0, .init_data = &zeus_ohci_regulator_data, @@ -552,6 +560,15 @@ static struct platform_device zeus_ohci_regulator_device = { }, }; +static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct pxaohci_platform_data zeus_ohci_platform_data = { .port_mode = PMM_NPS_MODE, /* Clear Power Control Polarity Low and set Power Sense @@ -855,6 +872,8 @@ static void __init zeus_init(void) pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config)); + gpiod_add_lookup_table(&can_regulator_gpiod_table); + gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table); platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices)); zeus_register_ohci(); diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index f04650297487..379424d72ae7 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -352,7 +352,6 @@ static struct fixed_voltage_config wallvdd_pdata = { .supply_name = "WALLVDD", .microvolts = 5000000, .init_data = &wallvdd_data, - .gpio = -EINVAL, }; static struct platform_device wallvdd_device = { diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c index c46fa5dfd2e0..908e5aa831c8 100644 --- a/arch/arm/mach-s3c64xx/mach-smdk6410.c +++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c @@ -222,7 +222,6 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = { .supply_name = "B_PWR_5V", .microvolts = 5000000, .init_data = &smdk6410_b_pwr_5v_data, - .gpio = -EINVAL, }; static struct platform_device smdk6410_b_pwr_5v = { diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 400e6693643e..0adc34e8c975 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -39,6 +39,7 @@ #include #ifdef CONFIG_REGULATOR_FIXED_VOLTAGE #include +#include #endif #include #include @@ -2695,7 +2696,6 @@ static struct regulator_init_data adp_switch_regulator_data = { static struct fixed_voltage_config adp_switch_pdata = { .supply_name = REGULATOR_ADP122, .microvolts = REGULATOR_ADP122_UV, - .gpio = GPIO_PF2, .enable_high = 1, .enabled_at_boot = 0, .init_data = &adp_switch_regulator_data, @@ -2709,6 +2709,15 @@ static struct platform_device adp_switch_device = { }, }; +static struct gpiod_lookup_table adp_switch_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("BFIN-GPIO", GPIO_PF2, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + #if IS_ENABLED(CONFIG_REGULATOR_USERSPACE_CONSUMER) static struct regulator_bulk_data adp122_bulk_data = { .supply = REGULATOR_ADP122, @@ -2958,6 +2967,9 @@ static int __init stamp_init(void) printk(KERN_INFO "%s(): registering device resources\n", __func__); bfin_plat_nand_init(); adf702x_mac_init(); +#if IS_ENABLED(CONFIG_REGULATOR_FIXED_VOLTAGE) + gpiod_add_lookup_table(&adp_switch_gpiod_table); +#endif platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); i2c_register_board_info(0, bfin_i2c_board_info, ARRAY_SIZE(bfin_i2c_board_info)); diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 6f929abe0b50..2b8472431f02 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -554,7 +555,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, - .gpio = GPIO_PTB7, .enable_high = 1, .init_data = &cn12_power_init_data, }; @@ -567,6 +567,16 @@ static struct platform_device cn12_power = { }, }; +static struct gpiod_lookup_table cn12_power_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + /* Offset 7 on port B */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) /* SDHI0 */ static struct regulator_consumer_supply sdhi0_power_consumers[] = @@ -586,7 +596,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, - .gpio = GPIO_PTB6, .enable_high = 1, .init_data = &sdhi0_power_init_data, }; @@ -599,6 +608,16 @@ static struct platform_device sdhi0_power = { }, }; +static struct gpiod_lookup_table sdhi0_power_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + /* Offset 6 on port B */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct tmio_mmc_data sdhi0_info = { .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, @@ -1431,6 +1450,10 @@ static int __init arch_setup(void) gpio_set_value(GPIO_PTG4, 1); #endif + gpiod_add_lookup_table(&cn12_power_gpiod_table); +#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) + gpiod_add_lookup_table(&sdhi0_power_gpiod_table); +#endif return platform_add_devices(ecovec_devices, ARRAY_SIZE(ecovec_devices)); } 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 4392c15ed9e0..d185d3696fc5 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c @@ -10,7 +10,7 @@ * of the License. */ -#include +#include #include #include #include @@ -43,7 +43,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { * real voltage and signaling are still 1.8V. */ .microvolts = 2000000, /* 1.8V */ - .gpio = -EINVAL, .startup_delay = 250 * 1000, /* 250ms */ .enable_high = 1, /* active high */ .enabled_at_boot = 0, /* disabled at boot */ @@ -58,11 +57,25 @@ static struct platform_device bcm43xx_vmmc_regulator = { }, }; +static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + /* CHECKME: is this the correct PCI address for the GPIO controller? */ + GPIO_LOOKUP("0000:00:0c.0", -1, "enable", GPIO_ACTIVE_LOW), + { }, + }, +}; + static int __init bcm43xx_regulator_register(void) { + struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table; + struct gpiod_lookup *lookup = table->table; int ret; - bcm43xx_vmmc.gpio = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); + /* FIXME: convert SFI layer to use GPIO descriptors internally */ + lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); + gpiod_add_lookup_table(table); + ret = platform_device_register(&bcm43xx_vmmc_regulator); if (ret) { pr_err("%s: vmmc regulator register failed\n", __func__); diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c index 777fac6fb4cb..2c6098e6f4bc 100644 --- a/drivers/regulator/fixed-helper.c +++ b/drivers/regulator/fixed-helper.c @@ -43,7 +43,6 @@ struct platform_device *regulator_register_always_on(int id, const char *name, } data->cfg.microvolts = uv; - data->cfg.gpio = -EINVAL; data->cfg.enabled_at_boot = 1; data->cfg.init_data = &data->init_data; diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 988a7472c2ab..1142f195529b 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -24,10 +24,9 @@ #include #include #include -#include +#include #include #include -#include #include #include @@ -78,10 +77,6 @@ of_get_fixed_voltage_config(struct device *dev, if (init_data->constraints.boot_on) config->enabled_at_boot = true; - config->gpio = of_get_named_gpio(np, "gpio", 0); - if ((config->gpio < 0) && (config->gpio != -ENOENT)) - return ERR_PTR(config->gpio); - of_property_read_u32(np, "startup-delay-us", &config->startup_delay); config->enable_high = of_property_read_bool(np, "enable-active-high"); @@ -102,6 +97,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) struct fixed_voltage_config *config; struct fixed_voltage_data *drvdata; struct regulator_config cfg = { }; + enum gpiod_flags gflags; int ret; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), @@ -150,25 +146,28 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - if (gpio_is_valid(config->gpio)) { - cfg.ena_gpio = config->gpio; - if (pdev->dev.of_node) - 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; + gflags = GPIOD_OUT_HIGH; else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; + gflags = GPIOD_OUT_LOW; } else { if (config->enable_high) - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; + gflags = GPIOD_OUT_LOW; else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + gflags = GPIOD_OUT_HIGH; } - if (config->gpio_is_open_drain) - cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; + if (config->gpio_is_open_drain) { + if (gflags == GPIOD_OUT_HIGH) + gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; + else + gflags = GPIOD_OUT_LOW_OPEN_DRAIN; + } + + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); + if (IS_ERR(cfg.ena_gpiod)) + return PTR_ERR(cfg.ena_gpiod); cfg.dev = &pdev->dev; cfg.init_data = config->init_data; diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 48918be649d4..1a4340ed8e2b 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h @@ -24,8 +24,6 @@ struct regulator_init_data; * @supply_name: Name of the regulator supply * @input_supply: Name of the input regulator supply * @microvolts: Output voltage of regulator - * @gpio: GPIO to use for enable control - * set to -EINVAL if not used * @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 @@ -49,7 +47,6 @@ struct fixed_voltage_config { const char *supply_name; const char *input_supply; int microvolts; - int gpio; unsigned startup_delay; unsigned gpio_is_open_drain:1; unsigned enable_high:1; From patchwork Mon Feb 12 13:16:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128057 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3200945ljc; Mon, 12 Feb 2018 05:17:49 -0800 (PST) X-Google-Smtp-Source: AH8x224POMM18H1FeO5+h4qyCrJqFIvv4E05g7U2tUdQSHaDacScb6747j0jVdhvSq3THjMiipS2 X-Received: by 10.99.173.73 with SMTP id y9mr9176131pgo.432.1518441468966; Mon, 12 Feb 2018 05:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441468; cv=none; d=google.com; s=arc-20160816; b=KuE+YGfEFxHFWOwhOMVEc1GFLA8ZVJtM9339OuWj67Jo1Svt0PwgCyht71l9EWuwG7 VUvaBc1Hpf7YtdKdmgZ26NVmWuaQY57P4M6xKpps4enLKYX61r9UI84iG2bvEMrlb8uZ cmqn9v5zjH0EGkQJ6z9vwuUWhSxwkquWxb0delp1QBfWpIsrOA6WIZXBlV8wqZ8QnPq+ NcbrRUunQvhJXgpbB5DenEXs7nMSRkaQDrYACU/+v/TNVywheiFk8xEcrPHzq/yWOGcw fMcOIm0enDrO/1DmIsjGPF/1M8smPlpo/mXvGWzAfOHPpMNknCYfJXyYqe2sqQF23d37 lqXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=nl5wo3EimBMqlMLcbt7HRKNzdZzfcYRFhLCs9kDF8Ik=; b=Z7bNg5tpLVX42BYa2OJVirnkkpZlxVXMApkhCKBhgE2zziQ0cHqB9/jSDXmTXf1Qhk 268U9YNOkQ+neF1VYhq7R0ERt4ZN0hg7wcdTaDaQETF5uLepgjKXJ7Uc/S4OqFgduqXo kYWpvVS32RUUJPwjdmQHE+/I7nZ+R/kLCsZKLNNeZCPrg/Ea/olpu34r/EiaeJ7mgRFw M2/qtk0WTwwP+8p9nj+GrkaJh5pSx3fkQUpdnrUdjEeva0dqGzuWGOz/Un/X3Vj5/2ae mRL6w+AK3gOb9D67th8EaQf890i010BC/jLJKmy2wgAITi8PyQuWBxPzPokjKdRO/QBo J4xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SsYkjUtg; 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 a84si2768073pfk.123.2018.02.12.05.17.48; Mon, 12 Feb 2018 05:17:48 -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=SsYkjUtg; 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 S935247AbeBLNRo (ORCPT + 13 others); Mon, 12 Feb 2018 08:17:44 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34763 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935226AbeBLNRi (ORCPT ); Mon, 12 Feb 2018 08:17:38 -0500 Received: by mail-lf0-f66.google.com with SMTP id k19so20399572lfj.1 for ; Mon, 12 Feb 2018 05:17: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=nl5wo3EimBMqlMLcbt7HRKNzdZzfcYRFhLCs9kDF8Ik=; b=SsYkjUtg1MQJeiamlCbh0SMacCVh5tUdSIGR7F4XuNzgUUbTvvgYQqt6jiPEB3egvC lEwEX6fy7PC1YsZBcvr9AAXfb3I2xm2AEkkSXMq6sYyPSSRjiqa3FGwgENL/HLreUpNx 0H+VkVfydA4/VqqG2MeV+OAQc04JwmAWI+BNc= 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=nl5wo3EimBMqlMLcbt7HRKNzdZzfcYRFhLCs9kDF8Ik=; b=Pv/VzGSnIJai8B9PDFG4x5ON9XC8RqUmll0nlNNHqLEk0oudb+SJQ90PEMo5LxKrfR /xJL5q2oMCiMYdA63G3fmH+wGkPjhxOSwbn3RKmdGt4psFQDfpHUkI9i8pEwIkj986Ix ckX6ukGwEinCbk6RjMUCKO96tn9/JFjjLYJi7Nv0xllL0IbF/mEnvk3+CxmTJqrUWbUh kzxaSMPabdwAabubkIh9xtdxJKFZU06ajLqFXDld79ttW0s9f4qeptTU9KqiWM3ty8Z1 Jdjcdo58h8U97FwMrm5HH6nFyKNJhzEVwDN89B7bUZdeCRzjkBSwdbVwowGWfL70z5Ua CxtQ== X-Gm-Message-State: APf1xPBgEYquypaGuNEMHJ6b/55h6RdMDndWeZvS8iuFwMCD//JiTjNB yeVZs5eQfVnOmyugrsGzlyI2+hJnc4s= X-Received: by 10.46.84.76 with SMTP id y12mr7701936ljd.36.1518441457030; Mon, 12 Feb 2018 05:17:37 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:36 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Philipp Zabel Subject: [PATCH 03/21] regulator: gpio: Get enable GPIO using GPIO descriptor Date: Mon, 12 Feb 2018 14:16:59 +0100 Message-Id: <20180212131717.27193-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We augment the GPIO regulator to get the *enable* regulator GPIO line (not the other lines) using a descriptor rather than a global number. We then pass this into the regulator core which has been prepared to hande enable descriptors in a separate patch. Switch over the two boardfiles using this facility and clean up so we only pass descriptors around. Cc: Philipp Zabel # HX4700/Magician maintainer Signed-off-by: Linus Walleij --- arch/arm/mach-pxa/hx4700.c | 12 +++++++++++- arch/arm/mach-pxa/magician.c | 11 ++++++++++- drivers/regulator/gpio-regulator.c | 23 +++++++++++------------ include/linux/regulator/gpio-regulator.h | 3 --- 4 files changed, 32 insertions(+), 17 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index e2e7f247a645..6717a10180eb 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -711,7 +712,6 @@ 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, @@ -733,6 +733,15 @@ static struct platform_device bq24022 = { }, }; +static struct gpiod_lookup_table bq24022_gpiod_table = { + .dev_id = "gpio-regulator", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * StrataFlash */ @@ -875,6 +884,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..9a5bda3ea194 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -657,7 +657,6 @@ 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, @@ -679,6 +678,15 @@ static struct platform_device bq24022 = { }, }; +static struct gpiod_lookup_table bq24022_gpiod_table = { + .dev_id = "gpio-regulator", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * 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 0fce06acfaec..172ca4c578b2 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -161,10 +162,6 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, 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)) @@ -254,6 +251,7 @@ 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 = { }; + enum gpiod_flags gflags; int ptr, ret, state; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), @@ -340,21 +338,22 @@ 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; + gflags = GPIOD_OUT_HIGH; else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; + gflags = GPIOD_OUT_LOW; } else { if (config->enable_high) - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; + gflags = GPIOD_OUT_LOW; else - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + gflags = GPIOD_OUT_HIGH; + } + 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_stategpio; } drvdata->dev = regulator_register(&drvdata->desc, &cfg); diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h index 19fbd267406d..536cab86f2d5 100644 --- a/include/linux/regulator/gpio-regulator.h +++ b/include/linux/regulator/gpio-regulator.h @@ -44,8 +44,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 @@ -69,7 +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 Mon Feb 12 13:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128083 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3204391ljc; Mon, 12 Feb 2018 05:21:56 -0800 (PST) X-Google-Smtp-Source: AH8x2269vN7obj2b3yK3AP90psgyT1Vq95yxOhyEOFSwgp2/hvU3l5PpPwRzcLf2YRwQIQxJGImc X-Received: by 2002:a17:902:4601:: with SMTP id o1-v6mr438539pld.210.1518441716761; Mon, 12 Feb 2018 05:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441716; cv=none; d=google.com; s=arc-20160816; b=vJUmIup4p6nvRhPZIpyCwaddowTGLMnTMPG+tnh3Az/p7yexFRo8mhnTmub79w+EIw RhFp8wiVeJR7y1uBKqp1xrZ+9jDnAD7aCCHrPF5Wi27Gm2oCdp0a8ycWp9+Tn971TciX LjLjJ80Kw2MrcAx6DPm4lxapSFjEGldJbo1N5eTiVx9DSQt+nQTMZkkB6OAd1O/yaYvv XlFI/SOJjyqRXkCq1xM04/BpSiRnx+BHY5M9KIizvpKGyson45aHvBr+QyP4vn0ZyzSR fkjCJUKHjIvSxxUU4UphBebzWom+j94elKrho/RC/6q6RVi51dbTSu+zOrfao86OeVSa SxZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yqdPznfAAMYDe469YxnJeMdLfr4FVNjY0fMYez2bl2E=; b=Aja5y3sRLqmElEV81OSHUEjCMnQ2JzV9oZByKEmmFrXcZ/gSP0hsYwpEBTZakEHAjx ZbOEJ5VS8cCyHpJYag3ylyQACjOmP8CXzLpQOVrotwMBVT1xDEoFPCaxiSjB+repVXqs CqXcNkL/5jEc9ediCwMbSJNo3Y95z2mU+V/g287CPDMime8MPIK1HCmqYGlpLjLqhDD+ FtCq2WyGo8g3ARGqSADO+pk9ULZV4HmvhPR/WXOI8yMbbgHAroWhTUcCsmq3Qb/CxVVk F6dX1OZzMEXfOHYMZQnI8BCZMvSFjftnYkkdTrx5x30OVai4mXIF5KJvoQeFlEzrmr4d sPBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GfDgZ/EX; 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 l9si2769133pff.155.2018.02.12.05.21.56; Mon, 12 Feb 2018 05:21: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=GfDgZ/EX; 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 S935461AbeBLNVx (ORCPT + 13 others); Mon, 12 Feb 2018 08:21:53 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34769 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935210AbeBLNRk (ORCPT ); Mon, 12 Feb 2018 08:17:40 -0500 Received: by mail-lf0-f67.google.com with SMTP id k19so20399701lfj.1 for ; Mon, 12 Feb 2018 05:17: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=yqdPznfAAMYDe469YxnJeMdLfr4FVNjY0fMYez2bl2E=; b=GfDgZ/EXSjUWqAu0zeba8e8kJllXImgdPxKnOGHsuB4bEqZp9VAmbKE7kxQYy493V4 xvgppT9h3nYkRUpXEIOZYaUrr9as0hjYmiQsMvnWeB5gxhxJxM897+bvLzxXmTk+xlVD fZNB5m7Bhh+Isx6RF8DlvNTqhJWChsHgmQL8E= 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=yqdPznfAAMYDe469YxnJeMdLfr4FVNjY0fMYez2bl2E=; b=oa3RixmTRYH0dEyXnsgeprcTQKUcnVQk4BFgZNbSEwUpx9lWzfAcheNPfJY1QyYRdH 2qdB8VzucS9xkDA1VkmyId7u0h+oUEsx945fIAwm9YF7wB23wczTTSaZ/LGpZNivOLgV BSDg1KHhSpLSJql0U8VSts9cytth+iFYbMtWNI5RZRKvyHLt1qtd3/HdvAEc1W8Lo658 p7p8T097mMo+hiPCksi8bjNje+kBBdTPRIjMR1hF/9A/P7BsS6SMN/uM1A4qNKyM8wYY mrS+9+MUjTFCCRFcxKtDttrz11K0MFF8dZuhzfLYMl931kUS/7RezbaYrRIkL6JVz6GL xZHA== X-Gm-Message-State: APf1xPAOlVTZOu9CH7qlpNgeEmizKG8pmmjWqu5tcctUUCTOxglNbUU7 7il7DzGFhcxhZOov2Emt/L5sXw== X-Received: by 10.46.9.22 with SMTP id 22mr7582525ljj.124.1518441459178; Mon, 12 Feb 2018 05:17:39 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:38 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Lee Jones Subject: [PATCH 04/21] regulator: da9055: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:00 +0100 Message-Id: <20180212131717.27193-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When setting up a fixed regulator on the DA9055, pass a descriptor instead of a global GPIO number. This facility is not used in the kernel so we can easily just say that this should be a descriptor if/when put to use. Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: would be nice if you could ACK this smallish patch to the MFD header. --- drivers/regulator/da9055-regulator.c | 4 ++-- include/linux/mfd/da9055/pdata.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.14.3 Acked-by: Lee Jones diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index d029c941a1e1..f40c3b8644ae 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -455,8 +456,7 @@ static int da9055_gpio_init(struct da9055_regulator *regulator, char name[18]; int gpio_mux = pdata->gpio_ren[id]; - config->ena_gpio = pdata->ena_gpio[id]; - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config->ena_gpiod = pdata->ena_gpiods[id]; config->ena_gpio_invert = 1; /* diff --git a/include/linux/mfd/da9055/pdata.h b/include/linux/mfd/da9055/pdata.h index 04e092be4b07..1a94fa2ac309 100644 --- a/include/linux/mfd/da9055/pdata.h +++ b/include/linux/mfd/da9055/pdata.h @@ -12,6 +12,7 @@ #define DA9055_MAX_REGULATORS 8 struct da9055; +struct gpio_desc; enum gpio_select { NO_GPIO = 0, @@ -47,7 +48,7 @@ struct da9055_pdata { * controls the regulator set A/B, 0 if not available. */ enum gpio_select *reg_rsel; - /* GPIOs to enable regulator, 0 if not available */ - int *ena_gpio; + /* GPIO descriptors to enable regulator, NULL if not available */ + struct gpio_desc **ena_gpiods; }; #endif /* __DA9055_PDATA_H */ From patchwork Mon Feb 12 13:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128085 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3204710ljc; Mon, 12 Feb 2018 05:22:24 -0800 (PST) X-Google-Smtp-Source: AH8x225SqFuNJE4S3rSTJpNUMfZpto+SbiyZbwtU6Iv/yKtBPeygGbXC8yYXQuytJbapTutyFAMY X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr10901548pld.17.1518441744193; Mon, 12 Feb 2018 05:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441744; cv=none; d=google.com; s=arc-20160816; b=MUZn3HBWapWBJ4+BulihyjtSGwrqaqNxg5s0coIhsPqmUbpW+ZSNVVgpux/iiOvGz/ //JMBUjjTlvFJ2oNOMUIerN0+FMuhyLZfeXhk5PekdWHVOuqDFKsu8T1LlMzicyPj/Ag BKggMp/9YRuylYTq/T/edoliMvKDCGfdJ5nzaMnIZhRKL4j4/7Y2PqD1ZYY+jbLP/Ybr yXqh+PrmRtY0CsNVf434c6Lj+wDgZgCT7rSi665wuGrBKpYpwDxMYSyoiDNmOMgZmqGy yxsznT6eidXRUD89dNo/H1G0Fb1yyCZUlxT9ZKO8eoJRRYVuNm2F73nBVDrQ40eWKlZU 6L6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9BM6OVRpMQt1hkiTw+Zip0PFrliiPSsPjoDwFDm2Jn0=; b=HLNhxnj6knWutkkTb5QzsjJI4Ao+RAm0vrIQHdD3T7pNf41PsaGgbZvbz52pZ5O0G6 9JRudCgJs2Pev9koCJmg4jEtcWrdL1sQbKEmtrjyDJ/d96XioSIHnCeWni72jE227IL4 uXakOJTEyeiYAMrdP//qEeHD4h5esW0OwsXuWDdwNyPCXjYg5PD5jO7F6D5Eqjvi2s6k E5ZYGNbm4GiV0eN+lQaxPpwzcrHGkihOdISWgMNnESbV2rJVq0ympbJvq3/eKW6TsFcq U8QuWMm/S4OKosZQArAodQNfIZN54pXo5dHsRhuxtTlCa2GSRQu6LS0/6nkW/vnTmsMw Ywow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SmKemPEg; 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 k5si6333058pfj.272.2018.02.12.05.22.23; Mon, 12 Feb 2018 05:22:24 -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=SmKemPEg; 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 S935414AbeBLNVw (ORCPT + 13 others); Mon, 12 Feb 2018 08:21:52 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42486 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935232AbeBLNRm (ORCPT ); Mon, 12 Feb 2018 08:17:42 -0500 Received: by mail-lf0-f65.google.com with SMTP id w10so7598646lfc.9 for ; Mon, 12 Feb 2018 05:17:42 -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=9BM6OVRpMQt1hkiTw+Zip0PFrliiPSsPjoDwFDm2Jn0=; b=SmKemPEgmxyEtfJXtrsyKcGUL/uxw60wyRGrBj3CxHVGexHit+xqGdjoKMolKr5gaB CaOy42ZXG4Qt5a/L7VwwJq6MCz/2IppxplGNgN6bsd8ABwLpjoYryG7Vr/9xmX2TKJMO ghPGpwg8YLGsq7m/bt4ooOMdXU4YXZEJmiIF8= 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=9BM6OVRpMQt1hkiTw+Zip0PFrliiPSsPjoDwFDm2Jn0=; b=Kf+D1og6xMBD+7Jraqt9A6GOOL/8bUKi33fLlxc7+q72vfDyEQFwIXP0djv9EJGPFf FtkaT6XJO/JglpPGbufXnOi4X3hFoZcw1a2lAtkxsrMHfuEjWT3G7n9ijfQFQXnW1bjS SxodpKOUgVWuSXtKBVNOvePKh1K2zUVlDxTCetTcv+hUr5YY6AytyM4r9EjwD8CcYjEc J/HeEwLU+vsK4F5e+RcZ7Bl7ujRP3fCTS/vx5S8OYs8GLLNj/LNUj0srYxis7FdOcWcj 1Fw9k8/6ZInbURaWCk91tPoS7oIh2r3r95qqs7uItbOBisUtgtYgj8S57xkh7tA6te0V jH1Q== X-Gm-Message-State: APf1xPALqFvaXwjsQS0uS/Npy6Cwotea3gbz8+rEo1wM/k0eSvm8/dv3 hU5enhoUHUzDK6p9QVQRCf6hGA== X-Received: by 10.46.85.17 with SMTP id j17mr8374085ljb.55.1518441461201; Mon, 12 Feb 2018 05:17:41 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:40 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com, Richard Fitzgerald Subject: [PATCH 05/21] regulator: arizona-ldo1: Look up a descriptor and pass to the core Date: Mon, 12 Feb 2018 14:17:01 +0100 Message-Id: <20180212131717.27193-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 with the standard devm_gpiod_get_optional() call. We have augmented the GPIO core to look up the regulator special GPIO "wlf,ldoena" in a separate patch. Cc: patches@opensource.cirrus.com Cc: Richard Fitzgerald Signed-off-by: Linus Walleij --- drivers/regulator/arizona-ldo1.c | 19 ++++++------------- include/linux/regulator/arizona-ldo1.h | 3 --- 2 files changed, 6 insertions(+), 16 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 96fddfff5dc4..f6d6a4ad9e8a 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -17,12 +17,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include @@ -198,16 +197,6 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata, struct device_node *init_node, *dcvdd_node; struct regulator_init_data *init_data; - pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0); - if (pdata->ldoena < 0) { - dev_warn(config->dev, - "LDOENA GPIO property missing/malformed: %d\n", - pdata->ldoena); - pdata->ldoena = 0; - } else { - config->ena_gpio_initialized = true; - } - init_node = of_get_child_by_name(np, "ldo1"); dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0); @@ -264,7 +253,11 @@ static int arizona_ldo1_common_init(struct platform_device *pdev, } } - config.ena_gpio = pdata->ldoena; + /* We assume that high output = regulator off */ + config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena", + GPIOD_OUT_HIGH); + if (IS_ERR(config.ena_gpiod)) + return PTR_ERR(config.ena_gpiod); if (pdata->init_data) config.init_data = pdata->init_data; diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h index c685f1277c63..fe74ab9990e6 100644 --- a/include/linux/regulator/arizona-ldo1.h +++ b/include/linux/regulator/arizona-ldo1.h @@ -14,9 +14,6 @@ struct regulator_init_data; struct arizona_ldo1_pdata { - /** GPIO controlling LDOENA, if any */ - int ldoena; - /** Regulator configuration for LDO1 */ const struct regulator_init_data *init_data; }; From patchwork Mon Feb 12 13:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128058 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201026ljc; Mon, 12 Feb 2018 05:17:56 -0800 (PST) X-Google-Smtp-Source: AH8x225fvxmbFPNwGCjR4ULQDYgvTQYC5VfmL5KYVDS1seKV4n9SMTWbUMOJG8ibO04lVuGtmAVm X-Received: by 10.101.97.81 with SMTP id o17mr9131337pgv.31.1518441476268; Mon, 12 Feb 2018 05:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441476; cv=none; d=google.com; s=arc-20160816; b=h924vaNALhpbWFjVqKn8zWTHzxunQtKCsmd7+mEma5mYdMVHzzcQN3clCLMLRC33nO kpcVT30oVTA9+0Yrqu+FHUH/u6AgGiejLso9RkzzjqUvt4w0TJBAlc4lKwcBLhtVyJp0 CkvSXU3hZvzWtZZ7+L/BSU9xgxk5LpzhvODrdP5PlRoU8pziBb8WaxmHBkDdRnzOQsAU RE4XZDCQwyCd128IqgJZHHMIRXipDxto2+QDH3JpweE4dJYfcCy8Tlojxa3/3kWO0HBv gJqACnDW4Vmcjhxfi3ZYNzfD1gZVqxpwGI7u8Lns9ZfuCv/KQw7Sxh0K5Syyt45ZJh4l 2RAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=beQT3Ujk0PPk3AACQnOPTy5VNJM0vX7jfM296fHM4Ufb/KA9qM2we/s0+32o2bnaoa q8HWdsTaMDpNbefYApNTnR2YxzFEQPuZpbdaLLMQex8VPKFeodxd7U/YcIMd9z2ASD6v UWlbB4KRyfmP66R+Z/LFeKc+NWX2LQDMXccEmOJjJPUmjgaYQKeMs2HZ9sW2/un2A0gS v8LlU/zdWjlqnO4S7n9kojvImqKT1/Rwe1wLQ4Zqot/aJ8lbRh5Xss6Ptf/SoCM4NZmi nBt8DRQK/au/bJ9MmrdFCPnV9qG9FgjEGN9IItucLt5uFhR3gy/venkn6ofHnH6OPVZ1 CXbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e4d+SiCL; 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 a84si2768073pfk.123.2018.02.12.05.17.55; Mon, 12 Feb 2018 05:17: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=e4d+SiCL; 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 S935265AbeBLNRt (ORCPT + 13 others); Mon, 12 Feb 2018 08:17:49 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:40992 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935244AbeBLNRo (ORCPT ); Mon, 12 Feb 2018 08:17:44 -0500 Received: by mail-lf0-f67.google.com with SMTP id f136so20375354lff.8 for ; Mon, 12 Feb 2018 05:17:43 -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=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=e4d+SiCL6f2fuxG7TkAUd5qnqGwY0RNSCU7ausWcDU4aemEVtmhGzLo4K0syYQmXe3 6FwVmkFmWBKwtwTxppZbcplY8ZTrUa9W4AmwruIh9goLR/afJrCyVBFGICodWQhQhohR O0DNE+1euvyyXaB8v88+HNLIknuUY7Hit/+yQ= 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=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=IQ1vDZIcp68ZEB+DVU0j5ker1YSAceOyMhdlak8MiCZA0xymPagFXiC+O3hi0xOz0S 8RDtoXYwtUAfvgUvzFmQ+dVBVFaLZZDHoURBd6a6kGTz0vC3dUZ6Pyl+tDoGIM9oziud rgSpLwRemY8Yc2Gvy3syQRwvR4a8sgmATBzHGbiL5poyTRjZvXpEbqZWOPefhAPMBtGh 0b0kGOmC7PAJ+x29pQPB7fAM5gFQxNdHrcliLHkq9dYcbr0gifHe8q8t3N/JQj59KaIA fwF5ZAUk5oBCXdblYJxI0+IF682lc7MvOWKYxsa4J7Ud4wEAxipEL7KGSzMBzeZc8a/q swxw== X-Gm-Message-State: APf1xPCDOTIfb4x5tWHHVwe8rJsJSFY4vyZgpeLLNHZ3ObZgZnP79MaV fj2YrJUtw2kSSzbd2ywfI9JSdg== X-Received: by 10.46.18.148 with SMTP id 20mr1908421ljs.2.1518441463125; Mon, 12 Feb 2018 05:17:43 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:42 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 06/21] regulator: da9211: Pass descriptors instead of GPIO numbers Date: Mon, 12 Feb 2018 14:17:02 +0100 Message-Id: <20180212131717.27193-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 augments the DA9211 regulator driver to fetch its GPIO descriptors directly from the device tree using the newly exported devm_get_gpiod_from_child(). Signed-off-by: Linus Walleij --- drivers/regulator/da9211-regulator.c | 23 +++++++++++------------ include/linux/regulator/da9211.h | 4 +++- 2 files changed, 14 insertions(+), 13 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index 9b8f47617724..6c122b3df5d0 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -25,7 +24,7 @@ #include #include #include -#include +#include #include #include #include "da9211-regulator.h" @@ -294,9 +293,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt( pdata->init_data[n] = da9211_matches[i].init_data; pdata->reg_node[n] = da9211_matches[i].of_node; - pdata->gpio_ren[n] = - of_get_named_gpio(da9211_matches[i].of_node, - "enable-gpios", 0); + pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev, + da9211_matches[i].of_node, + "enable", + 0, + GPIOD_OUT_HIGH, + "da9211-enable"); n++; } @@ -382,13 +384,10 @@ static int da9211_regulator_init(struct da9211 *chip) config.regmap = chip->regmap; config.of_node = chip->pdata->reg_node[i]; - if (gpio_is_valid(chip->pdata->gpio_ren[i])) { - config.ena_gpio = chip->pdata->gpio_ren[i]; - config.ena_gpio_initialized = true; - } else { - config.ena_gpio = -EINVAL; - config.ena_gpio_initialized = false; - } + if (chip->pdata->gpiod_ren[i]) + config.ena_gpiod = chip->pdata->gpiod_ren[i]; + else + config.ena_gpiod = NULL; chip->rdev[i] = devm_regulator_register(chip->dev, &da9211_regulators[i], &config); diff --git a/include/linux/regulator/da9211.h b/include/linux/regulator/da9211.h index f2fd2d3bf58f..d1f2073e4d5f 100644 --- a/include/linux/regulator/da9211.h +++ b/include/linux/regulator/da9211.h @@ -21,6 +21,8 @@ #define DA9211_MAX_REGULATORS 2 +struct gpio_desc; + enum da9211_chip_id { DA9211, DA9212, @@ -39,7 +41,7 @@ struct da9211_pdata { * 2 : 2 phase 2 buck */ int num_buck; - int gpio_ren[DA9211_MAX_REGULATORS]; + struct gpio_desc *gpiod_ren[DA9211_MAX_REGULATORS]; struct device_node *reg_node[DA9211_MAX_REGULATORS]; struct regulator_init_data *init_data[DA9211_MAX_REGULATORS]; }; From patchwork Mon Feb 12 13:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128080 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3204052ljc; Mon, 12 Feb 2018 05:21:31 -0800 (PST) X-Google-Smtp-Source: AH8x227JubqsyHg/SPaHIEipKJHB9HIfRwrGmprLqHyi/2RePNH68vnOpaabujReXd86YwCslqxG X-Received: by 2002:a17:902:bd4b:: with SMTP id b11-v6mr10896153plx.313.1518441691424; Mon, 12 Feb 2018 05:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441691; cv=none; d=google.com; s=arc-20160816; b=o1iKfikPV3rIDyLyxDPo7r4+hufS+X+0ZANCl2rb1Wwd+nS4rpYuOsYyvuWL6s6Swi eLBNStS0WxgR3r0SHG8sveHfvvICUmtyiC5fLHTLxsIbCxJsyaUYyJE3FzNe3euM+dNv AUrece9XbYpgS90qCtD/y19W3A94HskHPRf5YQWvY3Ro9VXS0Anp7zJ0zWk11BMJUZRS O/qW+840l8HqEVwujqxKu/wstlLGoNVsRRcYYykLcZrzcfIx3pbVUVyC2u+UW1ynOeGT mKm4K7gdWOewPbrqs8BEo0R522igtGPySpIctunzegLB38q2+NOhZ7LzD+stOQ0zq7I1 bPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=kHXgkV4BTEknlhb6tEvbjpHvX7LFECftej/WZktKnw7ApLM0p0kvC8UPV4fqS5WFjk BN006+nOahyoIzLgJSq3axFmTpyzHcj0QCphafQve/BnkPIYZndWMKtm13AMM1arAWgA HS+ICdRRK7HJ5F16zKQQlW2yHS7yMys/FSm0WLxm+RNgVSTv9b2sZDPatirrSM/67Aif axwN0iANxGXqsU1z+E6zMm37tkJMd1buysS15Irx+Nzfw7uWKEjjqgAEHe4IShOmWdAG UpqSYA4pX2QEa6jScCm0GxDglAJllUg8dbIBXow0dlrBRITQ8BP+nAbqhQYMm0iWDT45 Q2Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3+jJO9J; 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 l9si2769133pff.155.2018.02.12.05.21.30; Mon, 12 Feb 2018 05:21:31 -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=T3+jJO9J; 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 S935256AbeBLNV3 (ORCPT + 13 others); Mon, 12 Feb 2018 08:21:29 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44084 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935226AbeBLNRq (ORCPT ); Mon, 12 Feb 2018 08:17:46 -0500 Received: by mail-lf0-f67.google.com with SMTP id c188so4485991lfc.11 for ; Mon, 12 Feb 2018 05:17:45 -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=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=T3+jJO9JvHYH96HyIVxJXifibGHk+nROuSgDk2doLY0xK7l3TFW89R9xHHDu44QNHn TPpX/d5y0Tnc07/uj/wmm+FFFXtj8YbeF9X5B2mLUkbf+pPs9cNTanmC0hUpitDLO3ET P1RG4lZWdUnUaf5qiw0+YUvVOREa2uRWQO1tI= 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=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=QRSgnU+WI5JjgzRpRVrBEmcps2+zHLXL/4JkDFptwKEtDrXAtWn2fJPd10m33gJZpX a6XHfFnnZZMhjfDtBN1nMi1mRImIVKxUKsQxt/1iUnT8aZvc6Pi06L+6kDI+hUCey5/9 A9FU2wviXxqQ9JYcal+fsJPbYrb3/aJM3NebtSe6gPJU+yZ9f2xU4sLYlH6A5WYLTh3i xFnBV0aOCuyeF83rpNopDQqUQa6CpuAOb9JKSC4ckx/+mUmLCILPlo/RZIR+j3HgDZ0o cIbanudUPRkiPN/tS6i/lgiN4YcxWpNjurr8NgSfFnX8zag2LcwbC3WKPHk/9JTR4eVt 1mrg== X-Gm-Message-State: APf1xPA+4ck8PZz5AA/IpFr5aSVBJuvxICYKP+WcWE/oSBStVZGzDXBt YneRCZwq9Bm7+BtBPRNChPgl4g== X-Received: by 10.46.48.1 with SMTP id w1mr7321305ljw.69.1518441465090; Mon, 12 Feb 2018 05:17:45 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:44 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Mikko Perttunen , Laxman Dewangan Subject: [PATCH 07/21] regulator: max8973: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:03 +0100 Message-Id: <20180212131717.27193-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 with the standard devm_gpiod_get_optional() call. Cc: Mikko Perttunen Cc: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/regulator/max8973-regulator.c | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e0c747aa9f85..7cd493ec6315 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,6 @@ struct max8973_chip { struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; - int enable_gpio; int dvs_gpio; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; @@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( pdata->enable_ext_control = of_property_read_bool(np, "maxim,externally-enable"); - pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); @@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret; pdata = dev_get_platdata(&client->dev); @@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, return -EIO; } - if ((pdata->dvs_gpio == -EPROBE_DEFER) || - (pdata->enable_gpio == -EPROBE_DEFER)) + if (pdata->dvs_gpio == -EPROBE_DEFER) return -EPROBE_DEFER; max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); @@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; - max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->junction_temp_warning = pdata->junction_temp_warning; - if (gpio_is_valid(max->enable_gpio)) - max->enable_external_control = true; - max->lru_index[0] = max->curr_vout_reg; if (gpio_is_valid(max->dvs_gpio)) { @@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, break; } - if (gpio_is_valid(max->enable_gpio)) { - config.ena_gpio_flags = GPIOF_OUT_INIT_LOW; - if (ridata && (ridata->constraints.always_on || - ridata->constraints.boot_on)) - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio = max->enable_gpio; + if (ridata && (ridata->constraints.always_on || + ridata->constraints.boot_on)) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) { + config.ena_gpiod = gpiod; + max->enable_external_control = true; } + break; case MAX77621: - if (gpio_is_valid(max->enable_gpio)) { - ret = devm_gpio_request_one(&client->dev, - max->enable_gpio, GPIOF_OUT_INIT_HIGH, - "max8973-en-gpio"); - if (ret) { - dev_err(&client->dev, - "gpio_request for gpio %d failed: %d\n", - max->enable_gpio, ret); - return ret; - } - } + /* + * We do not let the core switch this regulator on/off, + * we just leave it on. + */ + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + max->enable_external_control = true; max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_mask = MAX8973_VOUT_ENABLE; From patchwork Mon Feb 12 13:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128077 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3203583ljc; Mon, 12 Feb 2018 05:20:59 -0800 (PST) X-Google-Smtp-Source: AH8x226e9hg2jTWs8fm0EC0v+GSd8xdzDy739y/Ofexd9gx/UOSlCHZssFT632agUysyR142YIR/ X-Received: by 10.98.223.80 with SMTP id u77mr11810984pfg.186.1518441659691; Mon, 12 Feb 2018 05:20:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441659; cv=none; d=google.com; s=arc-20160816; b=o4tNiXxNXsFX8QXaKZWqNxZdpqNG4jsVobsVMdusPtsJ35luXhnC+snJ3bVWyDcaMZ cVRwmJHQEai7sCVSq1QpndPeDzcZuG63P4CApGxdUuE4YbM9A+s/AkhArg8hrb/j0/8s /V+Aoov2Ek7j+2GOyU4zcFP2+97CK2uC9gCm6escjsIibjEI9HJSLm6LIBrmecAdjw/W PfVF/7rsL0XdLsMxiZSOM8794l40jJVVmBZmd/W5ph1lpFjJjxfJqQ86Pve4jZbyn6po /R6ex05ArWEQ1kQDNzbvNgNZ1HtCKGhna+elTM+iWvDrkI4gSBLfgY13oYmqaVSJjtDG kOmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=m85RyQv8NKO+UsZ9nVriTvZRsERzHYgC3rhiaoQ10vk=; b=BJj77UX0ZYcIF9tl/rZzxc2PxCYOsvaFRfY0QT5BgYCEs2vGJpXOFeT0HQ4W9dLltt 03fYsEoveEMZsfOftfEJB/SlSor4YJ7Q5U9u50I0fWEZROgm3R9CKZH0bJ+m3cYN681a MUSeaSGbJq26OruiqslyJYakBEWw+LLouAV/gm+HKs5lCbEbcRwAi5i/7FljaOqdxMjU djwQcFtxfTbLitYrvefVAqye+xi1VVzDEw8KAMmpy9hALWONS58az6pIgsE0APxBkiQl Iz7mUm0ILJY8Dv7RV+tlaoIe7Soin/o4rTUw605GW8ruoFakvS+AZi99BNAoexoIFOQa aodw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGCazp4/; 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 l9si2769133pff.155.2018.02.12.05.20.59; Mon, 12 Feb 2018 05:20:59 -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=KGCazp4/; 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 S964774AbeBLNUy (ORCPT + 13 others); Mon, 12 Feb 2018 08:20:54 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:44090 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935256AbeBLNRs (ORCPT ); Mon, 12 Feb 2018 08:17:48 -0500 Received: by mail-lf0-f65.google.com with SMTP id c188so4486137lfc.11 for ; Mon, 12 Feb 2018 05:17:48 -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=m85RyQv8NKO+UsZ9nVriTvZRsERzHYgC3rhiaoQ10vk=; b=KGCazp4/Tur4NxBEjFfFrEWwZcMQwlKL6Z8ZRt8AhiCZPm3sA4IVXXXFtTdwhAKIJQ sbmS1zFgb7mvj2zTAR8gOI0Kf/XlLv0+rIHSQ7XIfmhNL0IkqYGox51IqB2xuFIDt0dG lbf2IeMiWeiGK4pUc66YQR022Nu+TumEFALng= 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=m85RyQv8NKO+UsZ9nVriTvZRsERzHYgC3rhiaoQ10vk=; b=GyojDwz21GikN9YL4RvtwkE5mgygJUTTwr1jhARJJAetLJW8aVpspgQXGJS8dEcUk0 yWbk4nAu4+FansSR/ddPQtkWAxJucEb6DMgR5067ZGXT4SxWkU+AQKBWmFZmZnt4bTPm BCiNF94mHcAJgVDF7pODAejkIWK4LSvVN+kxXZJOrfUh7JXMPr/uIDJr3r6leomBHNQe fvvhO/V+x3YWW2dwv/RHBruUZhMqov5jXFZcCwowWQ4pin97ira8TvkIk9N39rvw9Wo8 grGrB/mJWMQ/0rihwp/5PpQzCzuetWjq8ew3gfOIz+NoIcyOOZO5DYIseAJWzLJIVu/M 2v/g== X-Gm-Message-State: APf1xPDDZEyfsqDLyQASeaG+NpTuzhGeZL4Ovvf3CvGBcLrB3EsnKwit jkCarOfy+Z/qWo+xgDaQ0aBJJA== X-Received: by 10.25.40.205 with SMTP id o196mr7399440lfo.89.1518441467306; Mon, 12 Feb 2018 05:17:47 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:46 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 08/21] regulator: max77686: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:04 +0100 Message-Id: <20180212131717.27193-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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. Cc: Chanwoo Choi Cc: Krzysztof Kozlowski Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Linus Walleij --- drivers/regulator/max77686-regulator.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index c301f3733475..5ebd06f47e6a 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -90,6 +89,7 @@ enum max77686_ramp_rate { }; struct max77686_data { + struct device *dev; DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); /* Array indexed by regulator id */ @@ -269,16 +269,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, + "max77686-LDO"); + if (IS_ERR(config->ena_gpiod)) + return PTR_ERR(config->ena_gpiod); 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, @@ -521,6 +525,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 Mon Feb 12 13:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128059 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201104ljc; Mon, 12 Feb 2018 05:18:02 -0800 (PST) X-Google-Smtp-Source: AH8x226Qe4+gxnE3UCaHghNB4XFwNnl3c3U8jdxn20NcJtuSPozicdV0qCOqNPKPOkvVuggiaKkt X-Received: by 10.98.171.12 with SMTP id p12mr11578757pff.71.1518441482523; Mon, 12 Feb 2018 05:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441482; cv=none; d=google.com; s=arc-20160816; b=CehVHM2oq27YWtRGzQI/P7pz1E3Q8Ynlpz3xVs4FqgyHh0D7Gq1S2B3no0Mj19SVdw gFQYalHe/sybJYUT/y4cKkW3vzW0Rf45hJ8KqvX3b5zrDceyhfhuoyyYQJjYPRbzAWO4 478w3Q8Yt+DAa9uDVaJjiZKdjbQyQWSO5hJccOWaXLv4POUQwQLC4HaZVcNHXF7WJNo8 d4Moier94MoWH9vsNobFQLbeWlQv1uYD4H8sMfmUP52gbpQNVxmXuO+t9uXV+7f3A1UT LJ527m/p8YuS6VwQrVQ03+Rx8InR+4bCvZkC/BAdfml8uw8r+IxKiylKaXNMx4cgIO2e KlEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tqXpUwKG6hUpLmNnwuDZ8Xb8+RGj4kJMQ0JC7BLEzCw=; b=JaDTWL84yr96cZ7x9vwGfS/4A9/ONreJPHYL4GQt8fB7KWuI6DIF8/ls4VlnJ9dIdu sGChHIMmthPcR6GtlE/zMsTdsM9VEDEpzsmUN42JGlqUNw5o/Lqi5b3KfPDZO3rVr4hi R0VJD1BiPi93xcizHIS2Pc/+KGY/Vf5LSrbb9rtCbnOqvwJ+yOAi/yvQP/SX+UvYWpoA wEaLArOzFsJZFEq1zTsIL53M2jl6rH0XPinj0r0OuVuD9L5powPykvEE0NDnCFgbLjT2 dswI8l3C048VYT808YUE7b70PfA+lMSS52fgOlcvDibYE3sMeRqn1dpx02W2pB5oWtE5 p8Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYDZuGHD; 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 j15si3605235pgt.173.2018.02.12.05.18.02; Mon, 12 Feb 2018 05:18:02 -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=LYDZuGHD; 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 S935285AbeBLNR4 (ORCPT + 13 others); Mon, 12 Feb 2018 08:17:56 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:37354 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935244AbeBLNRv (ORCPT ); Mon, 12 Feb 2018 08:17:51 -0500 Received: by mail-lf0-f66.google.com with SMTP id f137so20387209lfe.4 for ; Mon, 12 Feb 2018 05:17:50 -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=tqXpUwKG6hUpLmNnwuDZ8Xb8+RGj4kJMQ0JC7BLEzCw=; b=LYDZuGHDpqpwvqZZpV2OaM+7xSu5HBjTglqbgpoxcVRe70ctxh4PzInrE2eOp7nSmz Oc5OOZQofniAT3HMP8ZcEgx0t7P35DBsdSvZUXNs9/8d7YvoEg0FZIrP8CAg2QQfhSlT RV4BPhbuxDTMkGe1clxyNPYcDwvYrgXWjWgUg= 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=tqXpUwKG6hUpLmNnwuDZ8Xb8+RGj4kJMQ0JC7BLEzCw=; b=W+vvlZn3RC7gTKv7sAlQS+8dg5AkffkOp3/4xyIVysPc9hT39Nd8Pv0SdZofm2iBON gVEnn6kIsE1UHLv2hQYHnOeuObryZGXB2hDkRWccZj8dXpbcMdDEGSrwamYLWDdDQ0rE ZnegM6nUbBoLuJYiOV/z+T+VzU/HNCScFe6Kmi8kRWqFLQGy/P0VPct1r7H7J40ByKTg mq5kalAXI4KpyPkoPjp0b8e2ZF1+tBrnbtHKHR97ZzMfyhme+ANA3PhgIBOSWxI/RK9S 0gG2KdJTzqEkQFcWq2fcCy/vLORwC/6ZKyr50ppRB27DgS6wNoYOZONbeqDwQ+ki2qzH EMAA== X-Gm-Message-State: APf1xPA5aWYRcrXX2WgxjHTpw15ERwpIPBMZHmMbCQdaeEiEJ3ro+Hdn ZamwksB/GhzM34/sP4BzrhBFig== X-Received: by 10.25.196.9 with SMTP id u9mr2925309lff.108.1518441469836; Mon, 12 Feb 2018 05:17:49 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:49 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Milo Kim Subject: [PATCH 09/21] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:05 +0100 Message-Id: <20180212131717.27193-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 with the standard devm_gpiod_get_index_optional() call. Cc: Milo Kim Signed-off-by: Linus Walleij --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index ce5f7d9ad475..b615a413ca9f 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = { }, }; -static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) +static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id) { /* * Check LCM_EN1/2_GPIO is configured. @@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) */ switch (id) { case LM3632_LDO_POS: - return of_get_named_gpio(np, "enable-gpios", 0); + return devm_gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW); case LM3632_LDO_NEG: - return of_get_named_gpio(np, "enable-gpios", 1); + return devm_gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW); default: - return -EINVAL; + return NULL; } } @@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) struct regulator_dev *rdev; struct device *dev = &pdev->dev; int id = pdev->id; - int ret, ena_gpio; + struct gpio_desc *gpiod; + int ret; cfg.dev = dev; cfg.regmap = regmap; @@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev) * LM3632 LDOs can be controlled by external pin. * Register update is required if the pin is used. */ - ena_gpio = lm363x_regulator_of_get_enable_gpio(dev->of_node, id); - if (gpio_is_valid(ena_gpio)) { - cfg.ena_gpio = ena_gpio; - cfg.ena_gpio_flags = GPIOF_OUT_INIT_LOW; + gpiod = lm363x_regulator_of_get_enable_gpio(dev, id); + if (gpiod) { + cfg.ena_gpiod = gpiod; ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, LM3632_EXT_EN_MASK, From patchwork Mon Feb 12 13:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128079 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3203769ljc; Mon, 12 Feb 2018 05:21:12 -0800 (PST) X-Google-Smtp-Source: AH8x226dtTEWucSb0dXyzICpsp7zmpOhxx88aW2dW8uWIu6OqOfJECdvyL3e7M0mp6ZAyohoRks7 X-Received: by 2002:a17:902:bd4b:: with SMTP id b11-v6mr10895366plx.313.1518441671899; Mon, 12 Feb 2018 05:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441671; cv=none; d=google.com; s=arc-20160816; b=UXwAVfQsE11ygLMzUY0b09KWewGrQLBfQxnF3DW60lJR9H68+aa55iRxQMfeqf0Rp+ ms8Wy7jtzSTLhKQ1n5uZ49QYKnx8UXoZl4Rc1sWTcUyZ19ozpLYRa1xiiFSby13AUS+k soc9Nm0r5u/9QtgUA4qL9p4IX61zMr+XYMMVumuCcSArfFZ0Sgu8sFQxbaFqh7B/D2p3 o7LnrAIKgjh8M5pGvFLUjLVbTF6u4046Hp/3kOdaX3hO003Q6eXsvVzjMlmtoXIU+38B 4UbLFoNL6vPy03AlBxUYHyeDLwwEUu7zDMo7UDwUg0gVk9dwkGa71kEOyItJ+tFNy/uK NLwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=YiZdEOCFlF79yfcnzgpzX9bHqa8whfm3Uxmhu0W1E5E=; b=nVzZUGQfbHkVFjUhuP18LgqZTcaSzuFbnZA7ZRUQgjHDQsIc17PqvgB1TIC7DisRb9 Xk9yqKvOX42BCR5AheEmZfLEY4gFsZzSedH9D+Oyd01OuPfNzHxHLnDdZHlzjEBGLian vnU0rgG3827WwKIl4MSrXcG1GSquIaG8tAoe3WBAe96MsydCaMB7Rm14Na3nhI9P6M7g aKSnL8icXklWJWnU8RT6Jh6vdXGglYGdmBbUzGUHQEBtCDUeR8SRRSU4/J1XbDzr2FD8 PwYJ26Y5WAqWAlcIAU+1V4m1OFqbPF96T0nVL6QJn9zoTUpH9tWXu0ExtibbHPE2Lzmy QYgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFu1Zoe4; 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 l9si2769133pff.155.2018.02.12.05.21.11; Mon, 12 Feb 2018 05:21:11 -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=QFu1Zoe4; 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 S935442AbeBLNUx (ORCPT + 13 others); Mon, 12 Feb 2018 08:20:53 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:32951 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935269AbeBLNRx (ORCPT ); Mon, 12 Feb 2018 08:17:53 -0500 Received: by mail-lf0-f68.google.com with SMTP id j193so4413422lfe.0 for ; Mon, 12 Feb 2018 05:17:52 -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=YiZdEOCFlF79yfcnzgpzX9bHqa8whfm3Uxmhu0W1E5E=; b=QFu1Zoe4QNU0q1LGAT0eao6EgwRFFXQRAuBFchQLH/EjHIOAmMUGCZ1Jqj6Tgxay64 3su84k8lJeFcGlxoL8Lspd+cp4KXcYN5WU7Z3opu+jOVqhCuPt+0Axw2ElQU3IXB1qc0 33J1U1GIVhkoyHdJbsuOMIiWCRAbX1cG923M8= 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=YiZdEOCFlF79yfcnzgpzX9bHqa8whfm3Uxmhu0W1E5E=; b=dRQwh21/RaI+NGZRYTqvC0Rc6lrBoiHMeoZgN7QMYvM+wItq/S7PdMyVlx0Uagh585 9Vr/7e87KUkqr1l13lQH2YhFM0+i38t7h9zO4WrdXeRWG8KzI3q081BDi+/7yc8H2L2a UhNZohaLuC1w7ohorh/X5sSfKO1HIN6OTvhEgyBS5ID8Jp/Dj0OCQrQhbJDEp6wemnb0 TSKbFIsw5ym5uRojhv/Uo238hJ0piyeIj14VoKxZ3W6aLZA4Ch/aLU7YTOwUUBhUiBBL NGyKCCKy3CucoU5fUL3w4YhIITkpyA5CRvYZuh0gx4KHNwuew2RRVjgmk7tHty+iGbtM Tl/Q== X-Gm-Message-State: APf1xPAFWUKM2ukzvFWiKOFMgg4FfOmCcygtG8S47tiBGhvcwQpJFYdj SigEqozuw6n7MXrpxHJCXN7q4Q== X-Received: by 10.25.24.203 with SMTP id 72mr4951407lfy.132.1518441471731; Mon, 12 Feb 2018 05:17:51 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:51 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Milo Kim , Lee Jones Subject: [PATCH 10/21] regulator: lp8788-ldo: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:06 +0100 Message-Id: <20180212131717.27193-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 with the standard devm_gpiod_get_index_optional() call. This driver has supported passing a LDO enable GPIO for years, yet this facility has never been put to use in the upstream kernel. If someone desires to put in place GPIO control for the LDOs, this can be done by adding a GPIO descriptor table in the MFD nexus in drivers/mfd/lp8788.c for the LDO device when spawning the MFD children, or using a board file. Cc: Milo Kim Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: would be nice if you could ACK this smallish patch to the MFD header. --- drivers/regulator/lp8788-ldo.c | 32 ++++++++++++++++---------------- include/linux/mfd/lp8788.h | 16 ---------------- 2 files changed, 16 insertions(+), 32 deletions(-) -- 2.14.3 Acked-by: Lee Jones diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index cbfd35873575..f2347474a106 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include /* register address */ @@ -85,8 +85,6 @@ #define LP8788_STARTUP_TIME_S 3 #define ENABLE_TIME_USEC 32 -#define ENABLE GPIOF_OUT_INIT_HIGH -#define DISABLE GPIOF_OUT_INIT_LOW enum lp8788_ldo_id { DLDO1, @@ -117,7 +115,7 @@ struct lp8788_ldo { struct lp8788 *lp; struct regulator_desc *desc; struct regulator_dev *regulator; - struct lp8788_ldo_enable_pin *en_pin; + struct gpio_desc *ena_gpiod; }; /* DLDO 1, 2, 3, 9 voltage table */ @@ -469,7 +467,6 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, enum lp8788_ldo_id id) { struct lp8788 *lp = ldo->lp; - struct lp8788_platform_data *pdata = lp->pdata; enum lp8788_ext_ldo_en_id enable_id; u8 en_mask[] = { [EN_ALDO1] = LP8788_EN_SEL_ALDO1_M, @@ -504,11 +501,18 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, return 0; } - /* if no platform data for ldo pin, then set default enable mode */ - if (!pdata || !pdata->ldo_pin || !pdata->ldo_pin[enable_id]) + /* FIXME: check default mode for GPIO here: high or low? */ + ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev, + "enable", + enable_id, + GPIOD_OUT_HIGH); + if (IS_ERR(ldo->ena_gpiod)) + return PTR_ERR(ldo->ena_gpiod); + + /* if no GPIO for ldo pin, then set default enable mode */ + if (!ldo->ena_gpiod) goto set_default_ldo_enable_mode; - ldo->en_pin = pdata->ldo_pin[enable_id]; return 0; set_default_ldo_enable_mode: @@ -533,10 +537,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL; @@ -582,10 +584,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL; diff --git a/include/linux/mfd/lp8788.h b/include/linux/mfd/lp8788.h index 786bf6679a28..2010e0de3e34 100644 --- a/include/linux/mfd/lp8788.h +++ b/include/linux/mfd/lp8788.h @@ -181,20 +181,6 @@ struct lp8788_buck2_dvs { enum lp8788_dvs_sel vsel; }; -/* - * struct lp8788_ldo_enable_pin - * - * Basically, all LDOs are enabled through the I2C commands. - * But ALDO 1 ~ 5, 7, DLDO 7, 9, 11 can be enabled by external gpio pins. - * - * @gpio : gpio number which is used for enabling ldos - * @init_state : initial gpio state (ex. GPIOF_OUT_INIT_LOW) - */ -struct lp8788_ldo_enable_pin { - int gpio; - int init_state; -}; - /* * struct lp8788_chg_param * @addr : charging control register address (range : 0x11 ~ 0x1C) @@ -288,7 +274,6 @@ struct lp8788_vib_platform_data { * @aldo_data : regulator initial data for analog ldo * @buck1_dvs : gpio configurations for buck1 dvs * @buck2_dvs : gpio configurations for buck2 dvs - * @ldo_pin : gpio configurations for enabling LDOs * @chg_pdata : platform data for charger driver * @alarm_sel : rtc alarm selection (1 or 2) * @bl_pdata : configurable data for backlight driver @@ -306,7 +291,6 @@ struct lp8788_platform_data { struct regulator_init_data *aldo_data[LP8788_NUM_ALDOS]; struct lp8788_buck1_dvs *buck1_dvs; struct lp8788_buck2_dvs *buck2_dvs; - struct lp8788_ldo_enable_pin *ldo_pin[EN_LDOS_MAX]; /* charger */ struct lp8788_charger_platform_data *chg_pdata; From patchwork Mon Feb 12 13:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128074 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3203251ljc; Mon, 12 Feb 2018 05:20:35 -0800 (PST) X-Google-Smtp-Source: AH8x226DKQYwp0sPnkZhDffUGcVz1EzwxwQuVR+aSP3FoBBzkvkoveh54uTDaLiDHDkOcetNU/As X-Received: by 10.99.4.197 with SMTP id 188mr2781886pge.359.1518441634909; Mon, 12 Feb 2018 05:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441634; cv=none; d=google.com; s=arc-20160816; b=03NOV5w82pK+aKJbLtBlL3Bbpvx9PtMIv9W6eb1IlPTU/iAhhquw2i1WC8gXwsYeIp 3SISk/gXN7mRQRgLhI/ivfPF2fSVnGvUqZ/eWr8FCxPjRGdpk4qPwdS8PmxGPoBF5gex fEJNJX4G5Z5c6Kq1qjK+lf7koMsHF1+iZJ4KY+uuBmC6l0zFStf0d4YMR76gNj0kohW1 7w0noZGzIzzGq009C6vX/Aofompd0v1+JnDSLHo5TzSLcRrVMJxgDey1/rlrSzIItxks ysGe90dup7EN3yEkxj1jqSlDEhVcGDL5ef03N3JLCoUTwT6P0kYxHC7B4+7HXTNDPPiY a+bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=WwBBHQUec/k3CgLtl6EfrwV0FAw2LepISR9R0lfccat0TF5ElDhD7X6Xq9QAWuY0d/ Y8BVRZeZckLQ0fzLVFQ0pN10sBfzwAbIiEJGZNLlWylILCWmBjfhplXDQVM5EPuT6Rps 8QkXsaFV+/GT/oFjtamZ3WBHKp5sFezmGGRhZ6TUiF+y8P248Oga2Pdk0I3yEn6P0EVy JCISf/ywctLmLiIe/eLqJ5Irnbln+Q7XdiF4RQ/umNOVlmFVx6OPZCBwPMkEG/xwSZbl yAESXTIp47vrhHTc3zwK2zwRPDdJcbWHR06nWfLdFryFqxtdWyk9AUaBXhOgLMAgPAcr TC0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNSFvyCu; 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 l9si2769133pff.155.2018.02.12.05.20.34; Mon, 12 Feb 2018 05:20:34 -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=XNSFvyCu; 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 S935439AbeBLNUb (ORCPT + 13 others); Mon, 12 Feb 2018 08:20:31 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43100 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935272AbeBLNRz (ORCPT ); Mon, 12 Feb 2018 08:17:55 -0500 Received: by mail-lf0-f67.google.com with SMTP id q69so2534503lfi.10 for ; Mon, 12 Feb 2018 05:17:54 -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=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=XNSFvyCumBL1geRxiMszE5wBuUdY1phHLrv7VIhO3YhFe5uxXUHlcsqQSy1mn3sYkt aVzL9QRpSijypAKsQyrwTv7vVAZLJQ/1F1hsrG2hJTyBJTjbv6VzV+Jlj0uvdopXJaKe brVBwCSXhS9FAL3/i8IlDDM/Ft0Ya6psZJ3S4= 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=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=APYqYJVNxD1RHpjP3NSc4SKEcSfmf9bXXE0q/fChjJzT/1oe71ppUE/nth+SvkD6aS 7Wu+TAvH589T3WFZ+kZ1gf90HD2pkDfuwxwJcE7CrQkslP2gST3Hz4BbExX4KnSpRXXm VOQmxsuKjzbnMpczTTtlV+IfDCbuGy0RN7D1tY88XTa438S3wKRWgFFgR9zHTlkLrXFk H5eiS40remELgQXWWscWJZCjyPVo7fwSIsKyySMa7lytmkf+gYAo1DUr8e0Sy4raOLRS YGva7DhXYYENQTaWZzaMrgrB9bnoM3NV12JxmZoeybWk82WHFFufiSU50wsS+GRb/OFy +nsQ== X-Gm-Message-State: APf1xPBA4SjTMOXYXnoAS1N9WPWGm6flHdXX4syPXmbzbw7qi9X2GxhA R6k0eQMkxKW41yp05Ip0p9lcPA== X-Received: by 10.25.205.148 with SMTP id d142mr7098931lfg.9.1518441473957; Mon, 12 Feb 2018 05:17:53 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:53 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 11/21] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:07 +0100 Message-Id: <20180212131717.27193-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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. All users of this regulator use device tree so the transition is pretty smooth. Cc: MyungJoo Ham Signed-off-by: Linus Walleij --- drivers/regulator/max8952.c | 18 +++++++++++++----- include/linux/regulator/max8952.h | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 1096546c05e9..f1e77ed5dfec 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0); pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1); - pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0); if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode)) dev_warn(dev, "Default mode not specified, assuming 0\n"); @@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client, struct regulator_config config = { }; struct max8952_data *max8952; struct regulator_dev *rdev; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret = 0, err = 0; @@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client, config.driver_data = max8952; config.of_node = client->dev.of_node; - config.ena_gpio = pdata->gpio_en; - if (client->dev.of_node) - config.ena_gpio_initialized = true; if (pdata->reg_data->constraints.boot_on) - config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "max8952,en", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + config.ena_gpiod = gpiod; rdev = devm_regulator_register(&client->dev, ®ulator, &config); if (IS_ERR(rdev)) { diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h index 4dbb63a1d4ab..686c42c041b5 100644 --- a/include/linux/regulator/max8952.h +++ b/include/linux/regulator/max8952.h @@ -120,7 +120,6 @@ enum { struct max8952_platform_data { int gpio_vid0; int gpio_vid1; - int gpio_en; u32 default_mode; u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ From patchwork Mon Feb 12 13:17:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128060 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201125ljc; Mon, 12 Feb 2018 05:18:04 -0800 (PST) X-Google-Smtp-Source: AH8x224dZs+geNbm+X0wum3V3EwguyazXVMzSjVwQnlyyvrBaGqRhTJdjutRmCrmLto7QaKqGM9n X-Received: by 2002:a17:902:20c8:: with SMTP id v8-v6mr10687791plg.226.1518441484402; Mon, 12 Feb 2018 05:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441484; cv=none; d=google.com; s=arc-20160816; b=Qy/goP651+lOw0dabKJ1LCvShBmP3Gik9JekZdI4mNlhRicqVDlUh40vnt7OXCRaOz Aofxg/+nh6Qan/8pZdwXTt7yTQynQZVDHHwEdNnp5CRYW8KuPHuP2Ui+QtsCupMWRa1f WcHrTluj0ynzfq6DCpcbCA8vv+I5PuFbqJcJKKjYi7R24mR9Nbz5I5P4RDl528xJP+Bf dx1C87pEIqeJdju9Ptpyywx5JQRtWcUWSof5h6Lsl0SEwO18ocAYPlFoUZFfBXkRdaRd 9S7dFraSyKnSLMvzMH+1CwLPRSB6uyaszniHdRlAOTTy1OamrlLeNDRC3VzKzbYSPvBP tNTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ipSnndn20BOACJnA4S/SdJNa8vcelDcG8Kbw1rrM55A=; b=Jb4FCJUdybd7MC9vd6kMGr9Px55m3i4f+lZ6y1i7ICRmA9WuKaSBf+5GSCvtOezKuT bjlO1ncHNQ6DwSTszcyhl2Gtvn+SRBShgfhqFYIlOhTRO64FlFcFSH42YqAVVOeRJWcV D6sq4y2mnnlvFCum2daIb6r93O8EZANm8WB9p5nfE/WAFk2XHFYhIkUc8HeT4dK4MI3f UwUt5g2GmDWKfKsQwrkFW5A+bYToZ6HV81JTqJ/gffgxbUwrzDuwvh/OMYaSIbl/6zZV SiMkX3qqkVxOKx++39zwMc59iPCVX//tjJU0lre/oKR8xdhBsHxrQjNx+YwrE5h1qvYl c3fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LtYIJlnL; 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 j15si3605235pgt.173.2018.02.12.05.18.04; Mon, 12 Feb 2018 05:18:04 -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=LtYIJlnL; 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 S932847AbeBLNSB (ORCPT + 13 others); Mon, 12 Feb 2018 08:18:01 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37370 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935287AbeBLNR5 (ORCPT ); Mon, 12 Feb 2018 08:17:57 -0500 Received: by mail-lf0-f67.google.com with SMTP id f137so20387604lfe.4 for ; Mon, 12 Feb 2018 05:17:56 -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=ipSnndn20BOACJnA4S/SdJNa8vcelDcG8Kbw1rrM55A=; b=LtYIJlnL6Kt29iOKo7GS6I30Af8Tj6qyUx8biOEyYxH3VbT+k16ztkZMt7OZ/novNE 4V5Hf2jmIzIl5USNV5fcqJ4z+aT67nKOhRVbFmZCrSBXk7XxkjkVH+atQGsnHeSmbLaV rtcWQTSRyNGZ1G7bEGRxg3l5/sl3t+RAxAOoE= 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=ipSnndn20BOACJnA4S/SdJNa8vcelDcG8Kbw1rrM55A=; b=JKBQZBT0fxolnfGEjddzUxAPKJqwkAmAn+tpfd6zQFyBFdBs33hqY698YT0jIu9JM6 PSGKcNyf1YRHmRgujFfnzeldT34F5hJopOMwBovt5ShC7vkh96euL66RRr0Rc7ix9PUz TXrbizgjTrZjPHJN6gXxKXRNw07Jkfnf0fBXGyR3oP/9y7JirAt0xgPpUA6+uKd2n5ys l1mITFxUi18PTBt/4NwVgbr1yDhbCaP5fVvHEgwmtbrOC4uV71sqTzjJn5VhPbNUKd/p VgRP8Fbi4rm2JYBYvMLyf+nn/rQtyKqdxBGT6MSf2H0qyW+9qq9227MeaxG9xOIuDu5N 9kbQ== X-Gm-Message-State: APf1xPDvQp1T9RYqyYYQzFXoMmQyIa1N9sm0NygJnTmZY/WFN31TD7I9 +0UsY9T2t0ezbdndqu51v7sciNrXIfc= X-Received: by 10.46.92.135 with SMTP id q129mr3168825ljb.94.1518441476091; Mon, 12 Feb 2018 05:17:56 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:55 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 12/21] regulator: pfuze100: Delete reference to ena_gpio Date: Mon, 12 Feb 2018 14:17:08 +0100 Message-Id: <20180212131717.27193-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We now pass a GPIO descriptor to the core instead of a global GPIO number, if this descriptor is NULL the GPIO line is not used. Just delete the assignment of an invalid GPIO line. Signed-off-by: Linus Walleij --- drivers/regulator/pfuze100-regulator.c | 1 - 1 file changed, 1 deletion(-) -- 2.14.3 diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index 63922a2167e5..f341d9614a77 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -648,7 +648,6 @@ static int pfuze100_regulator_probe(struct i2c_client *client, config.init_data = init_data; config.driver_data = pfuze_chip; config.of_node = match_of_node(i); - config.ena_gpio = -EINVAL; pfuze_chip->regulators[i] = devm_regulator_register(&client->dev, desc, &config); From patchwork Mon Feb 12 13:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128073 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3202965ljc; Mon, 12 Feb 2018 05:20:14 -0800 (PST) X-Google-Smtp-Source: AH8x2272HwpHe+XLRVbqZJBQmTu7VniwVPZtzTykMPN+TyGipuPXGl3uiZyHLSf2szyjA4gEYAwI X-Received: by 10.98.102.88 with SMTP id a85mr11725775pfc.235.1518441614679; Mon, 12 Feb 2018 05:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441614; cv=none; d=google.com; s=arc-20160816; b=k9BVcAImDm1Cf3feB2QIY5W1Ywdc3VXUnURMbvkbwsV3douhzx9Gn/SOGfqJnI76gZ ks8MKUh/NoJwKv7ZTiL9+Ox4T+R6zry5yyjYrKQd8U+a2ZVJtzxSMS9mG/2kSKLu3MMd wBvnAjpONXJyTl0t/1ZLFq7v+sPrOJ+Ycs8v03UMSsyzwI/rfyFLIqdCa3N1W8cra26x SEqRfQM7L7n+fMkJ3o6DTKy74JrXw/zdk5FIdn9BVMV3xWYOLddK8DATHtslfzS9iqcS QPEWtaQdHwvdqNWkJ8FTmgIJrze6NV+7rVHdZAyk3aGa6W5cQaizorKGzHgOh6CdtiEu ozVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=F54DiT9gXZzo+s533cZuvanNMmyq0eC/i79jnYN5MzDWVf878CAiQgHyA21k5M6nF4 6AxEU9bblIEcpEtR41oiFXKoEAXPlvxa9APUYYki0dWvM5W9pdRP/MQRQVEfft3mt7Ux asK5giCLC4vE2WDynaTXLiXg6C+bgunl/sXHg4k6V7UG1QhdnwdobEKSdKmOAGqrCPcS rMkJWIR1nklJRvclrsei+Z7TqzckgRjkLaKyF0l7tx5pHPwqMAWmuUtyMGOdzbKBbsXY XA+YIiNCV3Vb6HHWXeFCrgaciBGRUB+zOV8080ywqdqQTvHcEfwJYHr2VKd7SujuHZNu u8gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWgkQYgL; 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 l9si2769133pff.155.2018.02.12.05.20.14; Mon, 12 Feb 2018 05:20:14 -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=UWgkQYgL; 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 S935431AbeBLNUL (ORCPT + 13 others); Mon, 12 Feb 2018 08:20:11 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45213 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935289AbeBLNR7 (ORCPT ); Mon, 12 Feb 2018 08:17:59 -0500 Received: by mail-lf0-f66.google.com with SMTP id x196so20328777lfd.12 for ; Mon, 12 Feb 2018 05:17:58 -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=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=UWgkQYgLLFK+1rZXuTxtTDSg+efu6MTVjmPgZ3MJv0xjeQbscv7E8HcNZR5H2KgoPC qhuwPA7bpXTY5MxdGVzHNSRGpgXIDsJDSwBA3Va/9x3p2A0Om/kwAxVsuJCiKNekfln0 R/NXk383c0sq4389Rpi/22FTe6+laPKZ9RCrE= 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=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=TAIokbG/bkmcDXSaBQIZuwDKNtRX0xHqdOtZWIuaC1vES3DzYiNVsBeRbHWzOb4+5I bK80FY+fJpPDayRbX7KriMTHoIOVScPL9jL6ewYdk2P2mOCZLwkMcjbRtkSoaE1lY0Nz bEgbmCovtQ1Df46vPcYIHKdZYxUonFXxbiWLgS5ArdANmMoldTh0t5C6AggHzSLNpR8E 81jCWvgAXtNmsXsHN5aun7A41Ti41mq/OUTJpg2X2jdxRlQlVfk/+81WydmrV96mUOnM 1cON8x9hFztc2AJuhY1FETZKyYif+gAfcfBHA/w0K5cnxYk3g1PeeaJimIOghM2NvjIg ma1w== X-Gm-Message-State: APf1xPD51uBY7CRou5z7DsYuBv+6+DQ9gsZSgAAY/4YYnGDzY5+wVidQ GiIXp9zaYTB4J5DZFFNxsHRneg== X-Received: by 10.46.32.66 with SMTP id g63mr7461777ljg.75.1518441478120; Mon, 12 Feb 2018 05:17:58 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:57 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Krzysztof Kozlowski , Sangbeom Kim , Chanwoo Choi Subject: [PATCH 13/21] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:09 +0100 Message-Id: <20180212131717.27193-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Chanwoo Choi Signed-off-by: Linus Walleij --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..9a1dca26362e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ struct s2mps11_info { * Array (size: number of regulators) with GPIO-s for external * sleep control. */ - int *ext_control_gpio; + struct gpio_desc **ext_control_gpiod; }; static int get_ramp_delay(int ramp_delay) @@ -524,7 +523,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) case S2MPS14X: if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) val = S2MPS14_ENABLE_SUSPEND; - else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) + else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -818,7 +817,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) { - int *gpio = s2mps11->ext_control_gpio; + struct gpio_desc **gpio = s2mps11->ext_control_gpiod; unsigned int i; unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, S2MPS14_LDO12 }; @@ -829,11 +828,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = of_get_named_gpio(rdata[reg].of_node, - "samsung,ext-control-gpios", 0); - if (gpio_is_valid(gpio[reg])) - dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", - gpio[reg], reg, rdata[reg].name); + gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, + rdata[reg].of_node, + "samsung,ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s2mps11-LDO"); + if (IS_ERR(gpio[reg])) { + dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n", + reg, rdata[reg].name); + continue; + } + if (gpio[reg]) + dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n", + reg, rdata[reg].name); } } @@ -1139,17 +1147,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, - sizeof(*s2mps11->ext_control_gpio) * rdev_num, + s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpiod) * rdev_num, GFP_KERNEL); - if (!s2mps11->ext_control_gpio) + if (!s2mps11->ext_control_gpiod) return -ENOMEM; - /* - * 0 is a valid GPIO so initialize all GPIO-s to negative value - * to indicate that external control won't be used for this regulator. - */ - for (i = 0; i < rdev_num; i++) - s2mps11->ext_control_gpio[i] = -EINVAL; if (!iodev->dev->of_node) { if (iodev->pdata) { @@ -1179,8 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio_initialized = true; for (i = 0; i < rdev_num; i++) { struct regulator_dev *regulator; @@ -1191,7 +1191,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].init_data; config.of_node = rdata[i].of_node; } - config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpiod = s2mps11->ext_control_gpiod[i]; regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); @@ -1202,7 +1202,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) goto out; } - if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { + if (s2mps11->ext_control_gpiod[i]) { ret = s2mps14_pmic_enable_ext_control(s2mps11, regulator); if (ret < 0) { From patchwork Mon Feb 12 13:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128061 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201219ljc; Mon, 12 Feb 2018 05:18:10 -0800 (PST) X-Google-Smtp-Source: AH8x226fov6Clxx8xAFyOlyrIgNoYssIJIFGoCif8X7RIA2rMK0cs6rl0zlnl9wsURkOzXClkiJg X-Received: by 2002:a17:902:7008:: with SMTP id y8-v6mr10783229plk.358.1518441490134; Mon, 12 Feb 2018 05:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441490; cv=none; d=google.com; s=arc-20160816; b=StHrprGmOtNvdoAJtzyBS2/JnAM2vgCq0dzvrvMFMqD8Aspugu2Q+ZRhLxxjutf1tn h8ESIdJ+PzL3Xc4QB5ZqbsY7Stb/Ydhc+hm/g+JbAJfeM6MZCaVD5k8e6hTYxFxzWLIi boG2TyQ/yyKhuiAnbrqoe18dDpPd8tacUTeE0y78Wxkw9qlKvaabmYSErWqjG8MWs1PH 5QXw+Sk+GvUpovUQbagE2SliSbuQAsFh+YBvnSjaaErBppWKOtnOytxUJ9bOpkMVD75K YvZ84FdG0r/tlFhNEDYCy7JSAPDntvmgthwzHFeyjwWndXuLKK9l+zt8QYd2oYDEod2Y 8JYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5qmUC/1eGwV+uOvff6xJWgLGLq07yd1DLO8dgHO0TXw=; b=hm2o+vJYvUO21LCdpPxcWpp73CBFRUCCTZbDK0PU+WvTOxoQl9yVlAPyscSFlotiOK NoJb+VcPF6ZSR56iPZvgnmuIJV2gAd/zXvJPD3oNSBXfZNmAprLgolmCP8+aNEzPWcnt zGLNbmbXCjvYiH1JZhQ6EoVmaO1dBJ70cifaC43Xjr9eujUXbQBh5IikamlJskXed+e4 GqaJMHJJA+A/JUeDNVgBWo35hPO5MUNxbi/YLAk2VRRd+MzhqMzwGq7qY1FWwD4pV1m9 Ah3ghiFtnS7PYMV8/YOH91S+PoXXUbhPewQKEzSsSD7VFJvPjXTru6LurV6WSfyVrmCM 4ynw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iEvkvdGK; 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 j15si3605235pgt.173.2018.02.12.05.18.09; Mon, 12 Feb 2018 05:18:10 -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=iEvkvdGK; 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 S935322AbeBLNSH (ORCPT + 13 others); Mon, 12 Feb 2018 08:18:07 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38477 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935300AbeBLNSB (ORCPT ); Mon, 12 Feb 2018 08:18:01 -0500 Received: by mail-lf0-f66.google.com with SMTP id g72so20371782lfg.5 for ; Mon, 12 Feb 2018 05:18:00 -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=5qmUC/1eGwV+uOvff6xJWgLGLq07yd1DLO8dgHO0TXw=; b=iEvkvdGK2lGbgx0IbXyut1dl6imeI5yv1RUygTliPHEnrNQgomW8n2yW16PAIRq8/Z Y0e0BGuNSK4KFI9R3jdhQawzLGeKtBS2rwvd6sMfRzOfyJYgzjKfMyGAIagCFG5S0TrU wD7ecW6zhsntMEvPGKKKn+cTsSn7aWIC8e/vQ= 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=5qmUC/1eGwV+uOvff6xJWgLGLq07yd1DLO8dgHO0TXw=; b=ZAyN2ZQEMH3XNUPhp+0rqVwWE4cfFwVOV8q8oqyY1U9K3rS8AaddjdWTodcnovTyH0 wUJFeWlSW2XxqFKViGv29VwQpiuO59edF1wdQnoBZsJCimCoQgYHyHPAX6QkkXiImbQe w009bv8aTn+HD+SVrRnaUZ3kde4EKI+aoC1U86f1bCy+06aQfsK4SBc52tkKGiIjgWP4 EFwKnhUw1MH055q6V34iqFGXYF2OpRi1w0Kee8UQKgxLNBtZG3WLq4C9lv6VNmBjOAao yMp+8AxbOqkGYWblKjejQiXQ0/bgfSb2lRD+TPmD4rYjnMpJDetnfvKhALelLbfoYxZ3 lvYQ== X-Gm-Message-State: APf1xPD8pc1xR6v4U17x1h4js1S/ffVLyjB7nK2jwmjdOOd9OHMHZi59 zwVRtNNOuTqSPw85cUUMpDLcv8SDA9E= X-Received: by 10.46.74.17 with SMTP id x17mr7629225lja.84.1518441480063; Mon, 12 Feb 2018 05:18:00 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:59 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Lee Jones Subject: [PATCH 14/21] regulator: s5m8767: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:10 +0100 Message-Id: <20180212131717.27193-15-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: would be nice if you could ACK this smallish patch to the MFD header. --- drivers/regulator/s5m8767.c | 26 +++++++++++++++----------- include/linux/mfd/samsung/core.h | 4 +++- 2 files changed, 18 insertions(+), 12 deletions(-) -- 2.14.3 Acked-by: Lee Jones diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 4836947e1521..b8443a360646 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, return; } - if (!gpio_is_valid(rdata->ext_control_gpio)) { + if (!rdata->ext_control_gpiod) { dev_warn(s5m8767->dev, "ext-control for %s: GPIO not valid, ignoring\n", - rdata->reg_node->name); + rdata->reg_node->name); return; } - config->ena_gpio = rdata->ext_control_gpio; - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config->ena_gpiod = rdata->ext_control_gpiod; } /* @@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, continue; } - rdata->ext_control_gpio = of_get_named_gpio(reg_np, - "s5m8767,pmic-ext-control-gpios", 0); + rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + reg_np, + "s5m8767,pmic-ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s5m8767"); + if (IS_ERR(rdata->ext_control_gpiod)) + return PTR_ERR(rdata->ext_control_gpiod); rdata->id = i; rdata->initdata = of_get_regulator_init_data( @@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.driver_data = s5m8767; config.regmap = iodev->regmap_pmic; config.of_node = pdata->regulators[i].reg_node; - config.ena_gpio = -EINVAL; - config.ena_gpio_flags = 0; - config.ena_gpio_initialized = true; - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) + config.ena_gpiod = NULL; + if (pdata->regulators[i].ext_control_gpiod) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); @@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return ret; } - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { + if (pdata->regulators[i].ext_control_gpiod) { ret = s5m8767_enable_ext_control(s5m8767, rdev); if (ret < 0) { dev_err(s5m8767->dev, diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 5a23dd4df432..28f4ae76271d 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -39,6 +39,8 @@ #define STEP_12_5_MV 12500 #define STEP_6_25_MV 6250 +struct gpio_desc; + enum sec_device_type { S5M8751X, S5M8763X, @@ -151,7 +153,7 @@ struct sec_regulator_data { int id; struct regulator_init_data *initdata; struct device_node *reg_node; - int ext_control_gpio; + struct gpio_desc *ext_control_gpiod; }; /* From patchwork Mon Feb 12 13:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128072 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3202667ljc; Mon, 12 Feb 2018 05:19:51 -0800 (PST) X-Google-Smtp-Source: AH8x224e2Q6d7g4pjaOyimtFJoc125dqZFKHxvivj3fwWKW+pp8xkVPkGlFDb+I0LKvX+4ZtJ5NC X-Received: by 10.101.93.142 with SMTP id f14mr9150433pgt.82.1518441591524; Mon, 12 Feb 2018 05:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441591; cv=none; d=google.com; s=arc-20160816; b=t91xp4vhYhMd19TirABdNkxIQ4OO3y5ToziAw2S5S015EcLizqrD6Qrmx5xS+5oGAp 5mJnYo5t/gp3NnbvccAgZoxzXYTxMn9iXHiuQj4lPsYlx0//L6GlIys8OFFh3obGs3vu l4A892rFLeZVA6VCMJoyJFf/Jc9g8bqQ2b6EPx21ueB5XIPR/7TnDLmYYu50EsFTjUnN 9phbjM8/l94DQeW/KopT+jJdz4lGUG5cwO7/7lXJgbEGtZjuivQoBweR6KwEKWU5AXFN Sqa3ea5TAm2lw/jg0n7RU8U4lbdqhL8EZ3rffMr4dBMYewMKhojaZA2x9UbOAFrpC7iG c68Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iS7YMbMa3i6KrieAXv7AYFWFkYDgLO+yTHSLHkI0Vbg=; b=p1WLLzgwLfcYTr6ufZl8UPOJUJrH5RxNuOWPqwdYtAfXnqiQG/hwIYnGIUO0QIfzqq 9Ns3hYh7/BoGb6Kz1WR+FVMHM9Tv8e0X7r+J1vzu4Uwg/q0j9LOoApLkDjL6gn5eA4jQ THqpNowAVVsGhP4qMXG3Tz9PaTnCBrKTtirewVizoar1/11Rbt2Cx2yYlfErin51ZU9s 7cMRbnceolAx5YNtcytcCjkes1s3BzIgGABkuIQvcpG1gsZsojcrWa4N8Ep7DPYVYejO 8yyOBJDuppEuudNYMktn01xxlHsJ0DRXW32jLln3DemMd1/mhfMitWHPGxQE0FIKUJL4 4ofQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZS3nBVb; 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 j11-v6si3781695pll.485.2018.02.12.05.19.51; Mon, 12 Feb 2018 05:19: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=QZS3nBVb; 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 S935419AbeBLNTr (ORCPT + 13 others); Mon, 12 Feb 2018 08:19:47 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36312 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935287AbeBLNSD (ORCPT ); Mon, 12 Feb 2018 08:18:03 -0500 Received: by mail-lf0-f68.google.com with SMTP id t79so20401612lfe.3 for ; Mon, 12 Feb 2018 05:18:02 -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=iS7YMbMa3i6KrieAXv7AYFWFkYDgLO+yTHSLHkI0Vbg=; b=QZS3nBVblcC1MMyk+ENU6hPVc71rsqLMp49EkzpFmjgm60c3PZinFmXgHrjQptPecL WmVuqE4Nf0hN2cvfdmypG9i/3roe0XqMufQ7OXhlC/0cF4eoTeNxKLOGXFzpd9zDbuEl dKiUqH2qcxAXWGFSTWzIRMOE6gIRSoF6H6KrU= 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=iS7YMbMa3i6KrieAXv7AYFWFkYDgLO+yTHSLHkI0Vbg=; b=Rb07AF2v5KITI/7YTKXcFEWZjMXwv2wAtgP7D2/ELR0czJXOAMSXdrIjoXf6bbw4B6 Cf4GRm6ze7rSFhcgmXumqWHS/k7i0pOZgPvbXJVn2w51R7VVGtTObqrks+A91vXlXCEk zciyeb6aWtiRsQAicYpUodz/UhtEmdT7FxMh62mjHM4siwHeE2ICbO7uIzXJrPNjBifv PrEOIVyaTcWc68D29JOkCMPlu35dX6cu9oEg0vA7d3FZ8pdpJ//KR7JtRBh92amEKl7Z uPYm3UBJjtriX19nUqJErJMuH5WlPqYyRi7I4YNanhId2ey9JSIlJlmJ2//JPs3pzUJJ OoLQ== X-Gm-Message-State: APf1xPD6GjLPbIF1HHiApf2VuWQ9zY/n+SPzsS59oRIBtQKp9gz2hLR1 bsHGnfBJ3fQtDRl3/WDOoa+7pg== X-Received: by 10.46.65.152 with SMTP id d24mr7384703ljf.109.1518441481868; Mon, 12 Feb 2018 05:18:01 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:01 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Lee Jones Subject: [PATCH 15/21] regulator: tps65090: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:11 +0100 Message-Id: <20180212131717.27193-16-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: it would be nice if you could ACK this smallish patch to the MFD header. --- drivers/regulator/tps65090-regulator.c | 50 ++++++++++++++++------------------ include/linux/mfd/tps65090.h | 8 ++++-- 2 files changed, 28 insertions(+), 30 deletions(-) -- 2.14.3 Acked-by: Lee Jones diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 395f35dc8cdb..2d398fa3b720 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -300,26 +300,6 @@ static int tps65090_regulator_disable_ext_control( return tps65090_config_ext_control(ri, false); } -static void tps65090_configure_regulator_config( - struct tps65090_regulator_plat_data *tps_pdata, - struct regulator_config *config) -{ - if (gpio_is_valid(tps_pdata->gpio)) { - int gpio_flag = GPIOF_OUT_INIT_LOW; - - if (tps_pdata->reg_init_data->constraints.always_on || - tps_pdata->reg_init_data->constraints.boot_on) - gpio_flag = GPIOF_OUT_INIT_HIGH; - - config->ena_gpio = tps_pdata->gpio; - config->ena_gpio_initialized = true; - config->ena_gpio_flags = gpio_flag; - } else { - config->ena_gpio = -EINVAL; - config->ena_gpio_initialized = false; - } -} - #ifdef CONFIG_OF static struct of_regulator_match tps65090_matches[] = { { .name = "dcdc1", }, @@ -385,9 +365,26 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( rpdata->enable_ext_control = of_property_read_bool( tps65090_matches[idx].of_node, "ti,enable-ext-control"); - if (rpdata->enable_ext_control) - rpdata->gpio = of_get_named_gpio(np, - "dcdc-ext-control-gpios", 0); + if (rpdata->enable_ext_control) { + enum gpiod_flags gflags; + + if (ri_data->constraints.always_on || + ri_data->constraints.boot_on) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + + rpdata->gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + tps65090_matches[idx].of_node, + "dcdc-ext-control-gpios", 0, + gflags, + "tps65090"); + if (IS_ERR(rpdata->gpiod)) + return ERR_CAST(rpdata->gpiod); + if (!rpdata->gpiod) + dev_err(&pdev->dev, + "could not find DCDC external control GPIO\n"); + } if (of_property_read_u32(tps65090_matches[idx].of_node, "ti,overcurrent-wait", @@ -455,8 +452,7 @@ static int tps65090_regulator_probe(struct platform_device *pdev) */ if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data) { if (tps_pdata->enable_ext_control) { - tps65090_configure_regulator_config( - tps_pdata, &config); + config.ena_gpiod = tps_pdata->gpiod; ri->desc->ops = &tps65090_ext_control_ops; } else { ret = tps65090_regulator_disable_ext_control( diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h index 67d144b3b8f9..f05bf4a146e2 100644 --- a/include/linux/mfd/tps65090.h +++ b/include/linux/mfd/tps65090.h @@ -83,6 +83,8 @@ enum { #define TPS65090_MAX_REG TPS65090_REG_AD_OUT2 #define TPS65090_NUM_REGS (TPS65090_MAX_REG + 1) +struct gpio_desc; + struct tps65090 { struct device *dev; struct regmap *rmap; @@ -95,8 +97,8 @@ struct tps65090 { * @reg_init_data: The regulator init data. * @enable_ext_control: Enable extrenal control or not. Only available for * DCDC1, DCDC2 and DCDC3. - * @gpio: Gpio number if external control is enabled and controlled through - * gpio. + * @gpiod: Gpio descriptor if external control is enabled and controlled through + * gpio * @overcurrent_wait_valid: True if the overcurrent_wait should be applied. * @overcurrent_wait: Value to set as the overcurrent wait time. This is the * actual bitfield value, not a time in ms (valid value are 0 - 3). @@ -104,7 +106,7 @@ struct tps65090 { struct tps65090_regulator_plat_data { struct regulator_init_data *reg_init_data; bool enable_ext_control; - int gpio; + struct gpio_desc *gpiod; bool overcurrent_wait_valid; int overcurrent_wait; }; From patchwork Mon Feb 12 13:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128063 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201307ljc; Mon, 12 Feb 2018 05:18:16 -0800 (PST) X-Google-Smtp-Source: AH8x225KNHpJkSRyxWtpS1M0dXuoibNKS1vl5FVsvIySU194E1fpfydZSeqT6Ikw9GaA1YczMk1x X-Received: by 10.101.70.203 with SMTP id n11mr3977614pgr.377.1518441496383; Mon, 12 Feb 2018 05:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441496; cv=none; d=google.com; s=arc-20160816; b=Oeg02eAn2+jyuptep9s4/gucoRsA7fG6tTEzaPQX8NnR1CJH8meSV1JccVs9/cLE2i dNd/eINfIRqWGVMtNMxqCt/S8AeTRRKFWwFCI5azXVVeKdbf9UFF9kgG9J7LoC5LwXbQ rUxJd4BdFelM1tYrYqPjfCehISLmMiJCOhYh3F6HEBTbuzqyusYX5ykqu8SUGncA6+XX E7rvWB4ooXRo5IkMRof64jmKWzZF7p6ngYnAn7UrlzAuhbqFDAOcvjJcGoDHPu5yTVVw Mo3EoKEjekMnNQVfr7F247cIhGb5N7lHSnUF/xgsz58WOyUUUhXoQHd/UgM9bPHeAfD7 A7Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=dmh8Q1tT8OADMjLXc9YXw7QdtHsaGwTaVW7YJggjxQoDyywkrx7k6c+n5RTiR/qCkv PFBmSYjBmusDGKdP9kh2ookn8EP6qIzIF+mLgmWgy1iZOX9W0E8MRCvTs+ij9oq0Bkka eexNfITLCTrcd+PEW3KUyKSn+CmS5yrpFBqLhHaC079kaWUE64wS8ufDYWePE6hKL6ZY PaVw45s9FZCfI5Cw9kokoXUNOFktNdXqFln5XYMzqbV72BAJwzaH+B053yrDh7rmcT+A OoJXe991XN4J4x1R1sex/pgkFxwJwxoXzS4p9m8ZJK4m4KY/TkVJoNLWAEULNeHVMvz9 TIBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AftjiduH; 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 j15si3605235pgt.173.2018.02.12.05.18.16; Mon, 12 Feb 2018 05:18:16 -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=AftjiduH; 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 S935337AbeBLNSK (ORCPT + 13 others); Mon, 12 Feb 2018 08:18:10 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41044 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935318AbeBLNSH (ORCPT ); Mon, 12 Feb 2018 08:18:07 -0500 Received: by mail-lf0-f67.google.com with SMTP id f136so20376831lff.8 for ; Mon, 12 Feb 2018 05:18:06 -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=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=AftjiduHnAhm6zevj4LgiC37g0L5xzoRBSWHSdztFCH9d6rN9yH4WkDDYs48xc/ZQF 6gdrpSB+t5+FeTMcHUvpWNPVg8XOoNP78DkTHUBL5QMAw+RRaZGhFqhvJ52N2qKHhDtL fgMfia2jpQLpY+y5LH/lhwKbgbAQc5/DR/zKE= 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=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=JNKLCANdVYF9l8AQNJqz42nCpyzp5Y5RSpEh4n1hKHgCAFuKhm8fXsMBpn6BI9jZ+L 8ipC7FBI4ERs8JjJOMxFyqRO765uEhJboG66msFGi8DapgJpHlZI3H93pZXQ7tzX1M+b h9GT0pOWYeNvGrhtnLVfMqJLN7n2EOnzoIYuBodFDjwT1PwVyGQrT9sWapGkeSZ0QJ36 TLKwiMkhqGcRRVT/coRHJWqfy1cW4+GJ7B0k5FVbqOaoSLPKM+2KdRHhT+iZjamLbSVz n5Bw5fEcvH8CpWerOTFHSdxIxBfZIKAqNZVTHmcmfbr/6LEmzfDUxROO50C9VSUHrDyF 4lLQ== X-Gm-Message-State: APf1xPDg3fGJLNJlquOEgZ46jXmmtlajMgRr3jxx8PwXCu3hj0vJE7Bl k20ZEMSTlT9/8bw9YQ76Iy7ZNw== X-Received: by 10.46.85.157 with SMTP id g29mr1352170lje.118.1518441485826; Mon, 12 Feb 2018 05:18:05 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:05 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 17/21] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 12 Feb 2018 14:17:13 +0100 Message-Id: <20180212131717.27193-18-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 10 +--------- 2 files changed, 7 insertions(+), 35 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4549b93b0ff9..fc5346d23fd7 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -1935,35 +1934,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; pin->ena_gpio_invert = config->ena_gpio_invert; @@ -1987,7 +1970,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; @@ -4160,15 +4142,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 4fc96cb8e5d7..8900c230c899 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -384,13 +384,8 @@ 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_gpiod: GPIO controlling regulator enable. * @ena_gpio_invert: Sense for GPIO enable control. - * @ena_gpio_flags: Flags to use when calling gpio_request_one() */ struct regulator_config { struct device *dev; @@ -399,11 +394,8 @@ 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; }; /* From patchwork Mon Feb 12 13:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128068 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3202034ljc; Mon, 12 Feb 2018 05:19:09 -0800 (PST) X-Google-Smtp-Source: AH8x227uJlIPFFDD4SkliL/gRIVGA1M9cmz0etQ+mpYBGxSvxPVbJQ9uzoh1RaLehTVW8YUQIbzc X-Received: by 10.99.185.84 with SMTP id v20mr1365804pgo.112.1518441549247; Mon, 12 Feb 2018 05:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441549; cv=none; d=google.com; s=arc-20160816; b=asn6yXbBS2ZGfoWwsptnTpMheqF3ynjfq2ir+Zff/6YXu/+blN6BDBKoW7vwslalMa KgSRjXu1RmZjGOyvnCA08oFlEbJY6ntFvFtCTRiHsJxAqnVqDFPT6bgIR8Wj8hOBjiBS LqBP+63/vhSBV0EbVMbrAMjTFjn+DKs/+AB/SqT/E8C5CJvnuzGV1bDetvyhqi9MIcy+ T2V3WfuBZf7rHIJH0g2TBhp1F55DSwAB+4XBXdAsPz4Jhl7eec/57LYJu7yp2N2MgeG1 Or3fiMbm/at1U+f0JgGBjAsV9z1l50bjgWBYGc2kRZdyjVI0dF4apbLC0axooTqQzYGp opNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mEFjzoCeU6JbO7JxP0s6C0zOSyn999lvV0Jjjun03YI=; b=HMSlrdbQedvcig+UiTfZVaw076xHoIPJAiGg8RZ+Vbh+6iPUrZeKhYwYS8bGadGeNV id7rurqIrjbDAGkJ5YRvS3emNKzth9SdtCybTmMKht3eIr258RLc8wjyUPAhNun8M9vn GbC/gbwFQ8Gm6enxDKSYnMtw4OUwg79ZrdAMgL7Cd/SIBCM4APIcpDDnA6ghM/vdAVcB vz1Hiw90nBlwzZIedttmdL1W7sp+TZ0reWvfe29/W7mLJTSnF9nq+Eu/fIIgsFq++v+m CS0ZzOF0RR59mniwnyuHOxxlwnpWsJptturyfaGKxDvNzKaj9ATXWpXIF31f4xtbnBUp awng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dGLI3mmT; 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 n6-v6si1217488pla.619.2018.02.12.05.19.09; Mon, 12 Feb 2018 05:19:09 -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=dGLI3mmT; 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 S935392AbeBLNTE (ORCPT + 13 others); Mon, 12 Feb 2018 08:19:04 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:44139 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935300AbeBLNSJ (ORCPT ); Mon, 12 Feb 2018 08:18:09 -0500 Received: by mail-lf0-f66.google.com with SMTP id c188so4487396lfc.11 for ; Mon, 12 Feb 2018 05:18:09 -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=mEFjzoCeU6JbO7JxP0s6C0zOSyn999lvV0Jjjun03YI=; b=dGLI3mmTH7sml3EFCNueA5a/FFrPFL+hH7erSEIPQnbrRedaU20qzZ4cgwVEB714FN eK0kv1Tz+gFdzhxqs/fFXHb6k5O/wxdekkpzoJyqdpuv9+3NciCEdtLuPUbvZZssbsO0 A9CF6jj6mQqyxwhQ/0oXlA6kAp7E2XQt6ofQo= 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=mEFjzoCeU6JbO7JxP0s6C0zOSyn999lvV0Jjjun03YI=; b=E3ibPfflsADUNpGOkZd7moaMrTx/JxYn6lTfRx+o9QIXkmN37hsmpiqkBu6TyQT7yf GtxgFwEWpJS5NyaA5bRDHysTMSWIlCNDGggpOnZYR7oA7Oe/TJPYhCQoK4fvNhnFRB1/ JvXoHClpPr3FThJ1TVV6L1IfRS3kvLtEM4TBHjZ6k6jPPc6ga7Vw95Jr3HsnEegv1l7w Eba7/ADs8ggzvgoJZaqtnQjyUd1Tdqrdjbjwt6oRK8oT/GyeVp1YflrutpmAr9ISvJ7P WSgtONiV7qBGPkpH1Q/omxyw+627htU0Gzu8YTAq+8IIiALpGEtFO90IZwGAv0moedRH rUcg== X-Gm-Message-State: APf1xPC0uGtv9yxGtbE9xIUBjhvDM404j65UUoJWHmNkkhhwyltgBAHl e4QwP501ZRRBEtgYJm6IZa8u/w== X-Received: by 10.46.9.22 with SMTP id 22mr7583501ljj.124.1518441488180; Mon, 12 Feb 2018 05:18:08 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:07 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , arm@kernel.orh, Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Daniel Mack , Marc Zyngier , Geert Uytterhoeven Subject: [PATCH 18/21] regulator: fixed/gpio: Pull inversion/OD into gpiolib Date: Mon, 12 Feb 2018 14:17:14 +0100 Message-Id: <20180212131717.27193-19-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 especiallt 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: arm@kernel.orh # ARM systems 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: Daniel Mack # Raumfeld maintainer Cc: Marc Zyngier # Zeus maintainer Cc: Geert Uytterhoeven # SuperH pinctrl/GPIO maintainer Signed-off-by: Linus Walleij --- Maintainers: I would like to see ACKs or Tested-by's if possible, see patch 0/21 for information on the series. --- 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/hx4700.c | 3 +-- arch/arm/mach-pxa/magician.c | 3 +-- arch/arm/mach-pxa/raumfeld.c | 1 - arch/arm/mach-pxa/zeus.c | 3 +-- arch/blackfin/mach-bf537/boards/stamp.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 | 30 ++++++---------------- drivers/regulator/gpio-regulator.c | 24 +++++++---------- include/linux/regulator/fixed.h | 10 -------- include/linux/regulator/gpio-regulator.h | 3 --- 20 files changed, 24 insertions(+), 76 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 5d3b6b4fe6db..8c4a4920468a 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 0fdb88db0cbd..08a7e217b9e6 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, "enable", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index 563b5a278d65..502343b32c7f 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 759fa18f6ab4..22e94da4af85 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -275,7 +275,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 4ddde151809c..2ff620b01367 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -332,7 +332,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 6d7d93981098..8d9ec158f118 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -987,7 +987,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 2b4bd6d94855..13ebdfd697cc 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, - "enable", GPIO_ACTIVE_HIGH), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 6717a10180eb..05148016c620 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -712,7 +712,6 @@ static struct gpio_regulator_state bq24022_states[] = { static struct gpio_regulator_config bq24022_info = { .supply_name = "bq24022", - .enable_high = 0, .enabled_at_boot = 0, .gpios = bq24022_gpios, @@ -737,7 +736,7 @@ static struct gpiod_lookup_table bq24022_gpiod_table = { .dev_id = "gpio-regulator", .table = { GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN, - "enable", GPIO_ACTIVE_HIGH), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 9a5bda3ea194..fab63c52d50e 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -657,7 +657,6 @@ static struct gpio_regulator_state bq24022_states[] = { static struct gpio_regulator_config bq24022_info = { .supply_name = "bq24022", - .enable_high = 0, .enabled_at_boot = 1, .gpios = bq24022_gpios, @@ -682,7 +681,7 @@ static struct gpiod_lookup_table bq24022_gpiod_table = { .dev_id = "gpio-regulator", .table = { GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, - "enable", GPIO_ACTIVE_HIGH), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 58833dcd2293..67e6e0759c78 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -875,7 +875,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 58e05afcece0..428c2db6818a 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, - "enable", GPIO_ACTIVE_HIGH), + "enable", 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/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 0adc34e8c975..648df18c4ccd 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -2696,7 +2696,6 @@ static struct regulator_init_data adp_switch_regulator_data = { static struct fixed_voltage_config adp_switch_pdata = { .supply_name = REGULATOR_ADP122, .microvolts = REGULATOR_ADP122_UV, - .enable_high = 1, .enabled_at_boot = 0, .init_data = &adp_switch_regulator_data, }; diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 2b8472431f02..934482f8bce8 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -555,7 +555,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, }; @@ -596,7 +595,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 d185d3696fc5..1ec518472344 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 fc5346d23fd7..4554f52818f9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -79,7 +79,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; }; /* @@ -1949,7 +1948,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, return -ENOMEM; pin->gpiod = gpiod; - pin->ena_gpio_invert = config->ena_gpio_invert; list_add(&pin->list, ®ulator_ena_gpio_list); update_ena_gpio_to_rdev: @@ -1999,8 +1997,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 { @@ -2011,8 +2008,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 f40c3b8644ae..1a384258d0e5 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 1142f195529b..8c479cdb69a9 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -79,10 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - config->enable_high = of_property_read_bool(np, "enable-active-high"); - config->gpio_is_open_drain = of_property_read_bool(np, - "gpio-open-drain"); - if (of_find_property(np, "vin-supply", NULL)) config->input_supply = "vin"; @@ -146,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; cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); if (IS_ERR(cfg.ena_gpiod)) diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 172ca4c578b2..fb9563de59fc 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -154,9 +154,6 @@ 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; @@ -338,18 +335,15 @@ static int gpio_regulator_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = np; - 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; - } + /* + * 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; + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags); if (IS_ERR(cfg.ena_gpiod)) { ret = PTR_ERR(cfg.ena_gpiod); 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 536cab86f2d5..4f3cc1a73ade 100644 --- a/include/linux/regulator/gpio-regulator.h +++ b/include/linux/regulator/gpio-regulator.h @@ -44,8 +44,6 @@ struct gpio_regulator_state { /** * struct gpio_regulator_config - config structure * @supply_name: Name of the regulator supply - * @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 @@ -67,7 +65,6 @@ struct gpio_regulator_state { struct gpio_regulator_config { const char *supply_name; - unsigned enable_high:1; unsigned enabled_at_boot:1; unsigned startup_delay; From patchwork Mon Feb 12 13:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128065 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201378ljc; Mon, 12 Feb 2018 05:18:22 -0800 (PST) X-Google-Smtp-Source: AH8x226RqQcwnjjvY/fdes5qYYSE3tvdiraZO8hS8Z5Up6gk6TESo+ZU4IHZUTxvPUP+etXQo4bC X-Received: by 2002:a17:902:e83:: with SMTP id 3-v6mr3352179plx.158.1518441502188; Mon, 12 Feb 2018 05:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441502; cv=none; d=google.com; s=arc-20160816; b=LBPVGHxIy5qbZNAyXOso3gUekfe0Fep1o2IY835H1k6iHp1AE634lworPpFIRdi5hI nXBA9IR0t5oRdG2B4lw4FOTG2cYeb0w4o2DoCQJfibq7VW7qF2Btig7iKhWrUJ+704i2 qAxdPyu0bHg3NjDqOGsor1mLnBCR+Y1q2Z/NcnULzdyNABcnR1mIb9VwGb9NCiUNw0O2 jo0SXjlNyUjB++X9pfAos39Jg+WQQhzKuIT6vqjpcQ58iOmMpRDDuTPcA/IMlMwgGJPZ ljyxI1v4r0Cmxbv4BA6h6JI3YHOXodsFcj84U2snCgeOpBA+Ge3RQbPxRr3tlAe5WrQ7 k7ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pcxLStTOo4dkY8HyqYC7WSpSk5+4mQd1pWhYFYCMwjo=; b=B8Jiwm0XXk0Sk7oxkeWMzIMFgN2g8dEMnGxyyQsOVVp/nlM2ZLob2OdM9jn8rpvrnX xcceC+2dfOdEWBbkAt3qPYI8v1tDsNBpUBtAN/oTrxtfo0lSx2qGdOeAGuHWhsFrUCqX +ffgOthsemBivASxz+GmQlf6S+MpwUjbMES8qfnQSRuxoB7RVC/LjTsd1nLp5oO9ecRX LbmIfkVDAZV9C05Zu2DlbFFQwn13fuseDfRTAJdMNUNtv5Nr6kShqPtYf+9LVskqDPKX MkN9LM/jPlP1MGeYMHaUE6VvTsRqOee1Q73YfaI3orgr2j8gjIeCCKlmIrbvtpE/6CXs TWAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kOK2PO/m; 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 n6-v6si1217488pla.619.2018.02.12.05.18.21; Mon, 12 Feb 2018 05:18:22 -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=kOK2PO/m; 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 S935368AbeBLNSS (ORCPT + 13 others); Mon, 12 Feb 2018 08:18:18 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:40869 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933761AbeBLNSN (ORCPT ); Mon, 12 Feb 2018 08:18:13 -0500 Received: by mail-lf0-f66.google.com with SMTP id 37so1518291lfs.7 for ; Mon, 12 Feb 2018 05:18:12 -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=pcxLStTOo4dkY8HyqYC7WSpSk5+4mQd1pWhYFYCMwjo=; b=kOK2PO/mC1i0QMixbKiYYdBiJwHlvevWsYx3umNZrpXAyGkh1kFkZ4L2LyLJJWDPFH y/Lo8kMDzgzTvn2Zid8GZnWVWQPCQktpAuGSS0FhN86d47/rfGQvs1q8wkMQhqrMivSF wFPBESui7LmkvnF8Bppvk+sBELvBCw3E7LzQE= 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=pcxLStTOo4dkY8HyqYC7WSpSk5+4mQd1pWhYFYCMwjo=; b=syxIFyYnjCvw7AW9bzXcuq466F15Jk1T1XBf2svqQncU2DDF2fc4FTxSUH86yAlro8 gWGtAZqOMUfKO6FtwluA0+W/1HHkhJsctVEqkAzrVQzd/gL/HSg+Y54v3SwAHoq075Ju s9hrfHE3ZvI0+M9ZiY/kj8BjDV4AGP28jiuzYw8vKWnJOxWcL+83aFJKlKCS89u1uIDb wYu7vT/HmtGBtWCrzz6EhwBUTX11md4Jh/XU2bP5ZEuA1TLW1I6EX56eGN0D+2J1a9+2 RmXgDjiXmE5SEgvESXoEV/JPfDfJMWJYrgYYE+aufkk8RvIYVFSI9qznm2NMAqigmj1q TdCA== X-Gm-Message-State: APf1xPAJq2rHgi461qElD+yx1vaAC1gMrzwEALxwkBWg5/ioh3IpqhVC +SGIYe5KCne+jUoNPR4wsz1eBw== X-Received: by 10.46.46.14 with SMTP id u14mr7054490lju.81.1518441491903; Mon, 12 Feb 2018 05:18:11 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:11 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 20/21] regulator: gpio: Convert to fully use descriptors Date: Mon, 12 Feb 2018 14:17:16 +0100 Message-Id: <20180212131717.27193-21-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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. Signed-off-by: Linus Walleij --- arch/arm/mach-pxa/hx4700.c | 10 +-- arch/arm/mach-pxa/magician.c | 11 +-- drivers/regulator/gpio-regulator.c | 116 +++++++++++-------------------- include/linux/regulator/gpio-regulator.h | 12 ++-- 4 files changed, 58 insertions(+), 91 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 05148016c620..24ba230340d8 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -700,9 +700,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,8 +712,8 @@ static struct gpio_regulator_config bq24022_info = { .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), @@ -735,6 +733,8 @@ 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), { }, diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index fab63c52d50e..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) }, @@ -659,8 +658,8 @@ static struct gpio_regulator_config bq24022_info = { .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), @@ -680,6 +679,8 @@ 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), { }, diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index fb9563de59fc..aecdd3f211ba 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -30,17 +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; @@ -83,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; @@ -120,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; @@ -139,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, @@ -159,46 +158,31 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - /* 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_kzalloc(dev, - sizeof(struct gpio) * config->nr_gpios, - 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; - 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"); @@ -249,7 +233,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) struct gpio_regulator_data *drvdata; struct regulator_config cfg = { }; enum gpiod_flags gflags; - int ptr, ret, state; + int ptr, ret, state, i; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); @@ -263,6 +247,16 @@ static int gpio_regulator_probe(struct platform_device *pdev) return PTR_ERR(config); } + 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]); + } + drvdata->nr_gpios = config->ngpios; + drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); if (drvdata->desc.name == NULL) { dev_err(&pdev->dev, "Failed to allocate supply name\n"); @@ -270,27 +264,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) goto err; } - 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_memstate; - } - } - drvdata->states = kmemdup(config->states, config->nr_states * sizeof(struct gpio_regulator_state), @@ -298,7 +271,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_memgpio; + goto err_name; } drvdata->nr_states = config->nr_states; @@ -319,13 +292,13 @@ static int gpio_regulator_probe(struct platform_device *pdev) default: dev_err(&pdev->dev, "No regulator type set\n"); ret = -EINVAL; - goto err_memgpio; + goto err_memstate; } /* 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; @@ -347,26 +320,22 @@ static int gpio_regulator_probe(struct platform_device *pdev) 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_stategpio; + goto err_memstate; } 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_stategpio; + goto err_memstate; } platform_set_drvdata(pdev, drvdata); return 0; -err_stategpio: - gpio_free_array(drvdata->gpios, drvdata->nr_gpios); err_memstate: kfree(drvdata->states); -err_memgpio: - kfree(drvdata->gpios); err_name: kfree(drvdata->desc.name); err: @@ -378,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 4f3cc1a73ade..11cd6375215d 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; @@ -49,9 +51,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 @@ -68,8 +70,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 Mon Feb 12 13:17: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: 128066 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201604ljc; Mon, 12 Feb 2018 05:18:36 -0800 (PST) X-Google-Smtp-Source: AH8x225//em035tUTEURgqffVdZpssbImR+Hu7Ew4MADa6S9TWAI9bpDOGFhVvh/lBkLaDms4DrE X-Received: by 2002:a17:902:34e:: with SMTP id 72-v6mr1416972pld.277.1518441516271; Mon, 12 Feb 2018 05:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441516; cv=none; d=google.com; s=arc-20160816; b=ZiIYu862CoFeUOTQ4eS7gbjGykyueEFJznyMArJSnnRgtBMfJ4r7vbYeH1mwLVqXOn jNjckj//cce63PcUQ0+EEGp9H9zH/T3RU8aTTidRuDaOefNdEyZA0XfPpG96Dls/q1TC feoFxMojtt5okuUhxEEbU5kgO9XOaj5veKCL3wnY11G+7ZhpgHIPDBsyDCEaM1hTfWQe 1H0KCQ+1EuTAbF1CLXcs1ZfS9OF25VInX7lKuFAIEPbQAMJiVP04KVY1Suz+jlbzlgac I9YMaaGKGvhOdeZIF2yByb/KUrduzt0LmAMNeWYTAaI2wCgvw48Xr+74A0CO5jGxOga4 DvZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=12wbP2PkUK9SWwXUn7ItipXduToiJIVpyn+lgGw7hjg=; b=SPKp7NshwSBgDayNEHE19UVir2bd35Flbqblz6DXsH2njoQ5cC8FtfhHtGjpxddSfx C3Syx4xPOQpShEo52xfUAVnMKi1ayg+14mKxhEGuWCoO+bVSwpNUuCGNSsHNLgmGTGpF 00s/4NwI24Ae2gW8HO8N9ionjBjwdYah8DIj14QBQg+P95zLJUEjftU0xEc0X2zVJkbz 5mo5mdiFamrSposROJQtq9/XQzDIDAu1tJOjow0SWIJtOcnuehDkODNHPQqiPil07fs+ U/32hKFS7cOdYdBvPr4erIsHtTFbcB+C0rnudhwqf/jt/o6a+QVFBZM56PDUxWSeqCZU 8OFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VAWn1/vE; 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 n6-v6si1217488pla.619.2018.02.12.05.18.36; Mon, 12 Feb 2018 05:18: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=VAWn1/vE; 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 S935379AbeBLNSc (ORCPT + 13 others); Mon, 12 Feb 2018 08:18:32 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43145 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935350AbeBLNSP (ORCPT ); Mon, 12 Feb 2018 08:18:15 -0500 Received: by mail-lf0-f66.google.com with SMTP id q69so2535771lfi.10 for ; Mon, 12 Feb 2018 05:18:14 -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=12wbP2PkUK9SWwXUn7ItipXduToiJIVpyn+lgGw7hjg=; b=VAWn1/vEusqwPWnTbQBmjcBqkEqqP3GOz5dgGqLx57v4JvJkVOLFeYZDf81Zf11K/L AOLJ0Huf+iSbmZayBQD32ZMRVgbxPfQRVTLWw6qJIbhAnt54bnMG4P3UFdFE0vfS9WkB qc0ANznd1Rvq3EoaX5IsQRp6pndqFNB/PFQh8= 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=12wbP2PkUK9SWwXUn7ItipXduToiJIVpyn+lgGw7hjg=; b=Bkpj6fSglydBmYVgQdwvxECvT09aPuL0VNTwuYa+ANvtk2BPfYT9bffyKwWTqaUJkx 3lBk3vl58g6mom0+dgrS4lHvMmeIhzbiMQhtWkeq/QF1CWlmHRKgFW3bokoGmRkr4Fhs 2Oo0zKZ1TZTVAsyCc3k4tt3yPIEnv63fDHctmY6vOZ2FDO9EaDECvLpFglC8IFisn9H7 cemSteNTozF8u1p4lNFTVpyLIxx6dqUUEPfreHsS5ZnpKPxlJMr/IXqrUj8s8IPpmUz0 U4wBPA8cMqIu8mUusYK77za9khGSDU+K7unkAz5CvyorS8hHfvJ4yHlLnAxdspGjO2pJ Jl1w== X-Gm-Message-State: APf1xPBDEHAQcMFmU0u6J4glqERZ8qESrUJuyZj/QyGlnxzlYqpPcugv YMrOA0Nmc+aFISFcP9imxK/Uag== X-Received: by 10.46.17.208 with SMTP id 77mr5253371ljr.87.1518441493852; Mon, 12 Feb 2018 05:18:13 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:13 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 21/21] regulator: gpio: Simplify probe path Date: Mon, 12 Feb 2018 14:17:17 +0100 Message-Id: <20180212131717.27193-22-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-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 --- drivers/regulator/gpio-regulator.c | 60 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 36 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index aecdd3f211ba..38a283252aaf 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -228,27 +228,28 @@ 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); } for (i = 0; i < config->ngpios; i++) { - drvdata->gpiods[i] = devm_gpiod_get_index(&pdev->dev, + drvdata->gpiods[i] = devm_gpiod_get_index(dev, NULL, i, config->gflags[i]); @@ -257,21 +258,20 @@ static int gpio_regulator_probe(struct platform_device *pdev) } drvdata->nr_gpios = config->ngpios; - 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"); - ret = -ENOMEM; - goto err; + dev_err(dev, "Failed to allocate supply name\n"); + return -ENOMEM; } - 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; @@ -290,9 +290,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. */ @@ -303,7 +302,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; @@ -317,29 +316,20 @@ static int gpio_regulator_probe(struct platform_device *pdev) else gflags = GPIOD_OUT_LOW; - 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); -err: - return ret; } static int gpio_regulator_remove(struct platform_device *pdev) @@ -347,8 +337,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; }