From patchwork Sun Apr 22 23:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133934 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368390lji; Sun, 22 Apr 2018 16:10:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Q3ugjk5r9l4iYEe2DhidiibAttJ7NB+9dkdfUQaxo0Y3RmhlpP9OFLFWO8AbCxChkCTQF X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr19018685plm.266.1524438629340; Sun, 22 Apr 2018 16:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438629; cv=none; d=google.com; s=arc-20160816; b=JPq0Y+/s82qG/ZZlGHBJzqUzAbPiBDmhqZMHRCJVNi5eJn3b8fTWBcWtFRiNEp8OEg YlcSAungzQLWxz+DOVwxWhxpHi2ITVlfgxDH4CkCLuCIXNbXQ8Bm9rgIOVgDbHx2WNaN ACSggnYFEA0OpIrugoANzi3i7jc2YGCk42+ovLljmd5qlzf8VPFFJIlIaZKwY5BQE3Qa ysCzV6BRkUP66UJ1xS7kSCsiqiwLyVS7+pQ8BHCOrKPVppniuvMxOGh+wXHzGduMT3aV vO5sD7ypjskuqIGAl7D1S36zh9sGIP/h/vd5dRi9JrbIQOy+eR5pTloKAl5TO6gxjdkW SAMw== 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=zasxcs60DQx/CuijakeFlAHkLjnx+weYwmF44wl0feI=; b=DueBr0F7ULe+WDxeKBQgzIcbLh1Z+FsFb+uGlU8pWXkbqXjce9s7HvJ5E53t+zNzb3 RI6K+44kdHsffYHN2n46t9TGdrnIq8miMoGD7btEFGjNEN9l1jp1Z5RwbkdO5V+JWDwB T9xssJYLoadxzVGRL/v+2m7gsZjgmO/2bz55RFkUhr9HFYlZQgT3+UqdvqrMvcZUaAfR 11WBUV0Uo+HWLiMU9KLq4dKlftdPi/AOqjmfqALkbyiVyh2ItDq2+UpG/vv5NS6dSsX3 cGmKUym20anUYX5s8wt8NDqolS693pd4orL329e65/FR/lx01AZ2wjHb/rJiSgcjao2O /jqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=akXCsB4/; 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 l85si10041497pfb.231.2018.04.22.16.10.29; Sun, 22 Apr 2018 16:10:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=akXCsB4/; 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 S1753938AbeDVXK0 (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:26 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35070 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753915AbeDVXKV (ORCPT ); Sun, 22 Apr 2018 19:10:21 -0400 Received: by mail-lf0-f67.google.com with SMTP id r125-v6so12231910lfe.2 for ; Sun, 22 Apr 2018 16:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zasxcs60DQx/CuijakeFlAHkLjnx+weYwmF44wl0feI=; b=akXCsB4/mn+1Gqmojo5fkU7pXLf3s13NV/8KNo/xX32GIVgwzbti2LyUkoJ8aML58v Gkc3SnSSX0qwBVbiTZTPWg4Mz8BFriYmqToxaCgxsBhUoktapYsE4v6y1xolkf3DMlr5 dKcW90I89IbrVbOXBUaV/C50S5H/iR7peIE3o= 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=zasxcs60DQx/CuijakeFlAHkLjnx+weYwmF44wl0feI=; b=N/B86Hp+hJ2e+KkXgKKARPLN9hUYfR2GJA/2kXeUw/7Kaox1bvPBGNgBOjhZRQfwCS OuPnhvZkEKQ8A70Yd/oxi3pfwflCaVux7ehSF9R4diKXZXk58oBiaBe3AVsfEuJjWLUR ZxX/xjE6pkRNEA1H8jHPyFk+kcpamX8Hg3CbbIVGyRAwFyfSaOwf92YKSFl+87qngeC1 9NaZNbfBsqQ3R9rLFPWx0F1hbd9SZH0cUVX3kNU8s4VKrs5NVvPNLIfrfUdc1cl8D3h/ MkVgSQr8CN4d+8J2kqx8zy/mMKa80i3W6x/PbLniVzJvq9oOcMKDr2jykR7aWEICkJ8b X+/A== X-Gm-Message-State: ALQs6tDj5zDYK80NNzYtwcLIwHQ0GidE++hcalyI8X8ubrvWFI3xaWgC EJwB5oQf09VZeoQiBqfxYq8u4s6OWxs= X-Received: by 10.46.89.78 with SMTP id n75mr11753542ljb.139.1524438620013; Sun, 22 Apr 2018 16:10:20 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r25sm2036291ljc.8.2018.04.22.16.10.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:19 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com, Charles Keepax Subject: [PATCH 13/18 v2] regulator: wm8994: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:37 +0200 Message-Id: <20180422230742.3729-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180422230742.3729-1-linus.walleij@linaro.org> References: <20180422230742.3729-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node or the board file decriptor table for the regulator. There is a single board file passing the GPIOs for LDO1 and LDO2 through platform data, so augment this to pass descriptors associated with the i2c device as well. The special GPIO enable DT property for the enable GPIO is nonstandard but this was accomodated in commit 6a537d48461deacc57c07ed86d9915e5aa4b3539 "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Cc: Charles Keepax Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 17 +++++++++++++++-- drivers/mfd/wm8994-core.c | 9 --------- drivers/regulator/wm8994-regulator.c | 19 +++++++++++-------- include/linux/mfd/wm8994/pdata.h | 3 --- 4 files changed, 26 insertions(+), 22 deletions(-) -- 2.14.3 Acked-by: Charles Keepax diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 5da041edd3b4..efdb2fcb1c3c 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -194,8 +194,8 @@ static struct wm8994_pdata wm8994_pdata = { 0x3, /* IRQ out, active high, CMOS */ }, .ldo = { - { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, - { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, + { .init_data = &wm8994_ldo1, }, + { .init_data = &wm8994_ldo2, }, }, }; @@ -203,6 +203,18 @@ static const struct i2c_board_info wm1277_devs[] = { { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ .platform_data = &wm8994_pdata, .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, + .dev_name = "wm8958", + }, +}; + +static struct gpiod_lookup_table wm8994_gpiod_table = { + .dev_id = "i2c-wm8958", /* I2C device name */ + .table = { + GPIO_LOOKUP("GPION", 6, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("GPION", 4, + "wlf,ldo2ena", GPIO_ACTIVE_HIGH), + { }, }, }; @@ -381,6 +393,7 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, gpiod_add_lookup_table(&wm5102_reva_gpiod_table); gpiod_add_lookup_table(&wm5102_gpiod_table); + gpiod_add_lookup_table(&wm8994_gpiod_table); if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 953d0790ffd5..c409464231f6 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -302,14 +301,6 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) if (of_find_property(np, "wlf,ldoena-always-driven", NULL)) pdata->lineout2fb = true; - pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0); - if (pdata->ldo[0].enable < 0) - pdata->ldo[0].enable = 0; - - pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0); - if (pdata->ldo[1].enable < 0) - pdata->ldo[1].enable = 0; - return 0; } #else diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 7a4ce6df4f22..d3a5f48119c2 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -129,6 +129,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) int id = pdev->id % ARRAY_SIZE(pdata->ldo); struct regulator_config config = { }; struct wm8994_ldo *ldo; + struct gpio_desc *gpiod; int ret; dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); @@ -145,12 +146,14 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - if (pdata) { - config.ena_gpio = pdata->ldo[id].enable; - } else if (wm8994->dev->of_node) { - config.ena_gpio = wm8994->pdata.ldo[id].enable; - config.ena_gpio_initialized = true; - } + + /* Look up LDO enable GPIO from the parent device node */ + gpiod = devm_gpiod_get_optional(pdev->dev.parent, + id ? "wlf,ldo2ena" : "wlf,ldo1ena", + GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + config.ena_gpiod = gpiod; /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { @@ -159,7 +162,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) ldo->init_data = wm8994_ldo_default[id]; ldo->init_data.consumer_supplies = &ldo->supply; - if (!config.ena_gpio) + if (!gpiod) ldo->init_data.constraints.valid_ops_mask = 0; } else { ldo->init_data = *pdata->ldo[id].init_data; diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index 90c60524a496..fca67bd194e2 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -20,9 +20,6 @@ #define WM8994_NUM_AIF 3 struct wm8994_ldo_pdata { - /** GPIOs to enable regulator, 0 or less if not available */ - int enable; - const struct regulator_init_data *init_data; };