Received: by 10.223.185.116 with SMTP id b49csp2233852wrg; Mon, 12 Feb 2018 06:35:50 -0800 (PST) X-Google-Smtp-Source: AH8x2275t2WMNgaRGPKIVpnsPvxA3maGbAT3ZqCpCFQPu1LqUCmohQf5SFq2WhFUHCuN+c3m6cPw X-Received: by 10.98.12.144 with SMTP id 16mr11899632pfm.147.1518446150754; Mon, 12 Feb 2018 06:35:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518446150; cv=none; d=google.com; s=arc-20160816; b=T5jGScqoLPD3TZG/D1/mmApqi7sDbhY0QW236CW4QgVMVB83Eyqu1cJIc8yCXOpKxq USfym1A9cB5hQhs81ggyQHAVp5pjTK2aY8eNXXCilTSuvZU549bRzu0MI8kAInwMoHNR 7mpmsspPuy/jUta/bE9ZPkY0vzdRlEsouuj2OWCZDF6Pgq7eBxgu0e4+xcKYfb4E51os NjFcKp22qlQDhQDk0lrQPjLIyUSBUl0WPE8psRPASlJhisPkkzZlvDLV9afa7anwXzwM yLbHdnsPJy/QbLHtlEjYuyN/X+B0MzJoELfkUrWkzQcOcnCY28qgydb1N+dFja2K1IMw fs1Q== 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=jX4buJqmwi3v7ZY16HuFYDWultv1gGtOOAL/qiwPrzY=; b=eh3nPOVeXfqfA16SLGn/Vhe3M0m5C9LyfgL27ozN+hsi11x2uvNjj0i7a3t2kAED5U iKC0CIJf3L8KoMsNppGPbMswyEEn/ZeyQ5CL7yFU0dWscZPGNCcoAaDTu8doVDQRINyn mdqpPXmkdsf52bLeVwB/arrkb0sCQv5HalduqlLu+DrYBdl26l82Mx0qCLtp17F/P23f Se23ajSyDH0nLL9fGzIdB5gD2znEWYnar6+TZrI0WlxOrWu9Gwc+qLlHCfnjoegc6/Cb v6uDGP664BL9/w33htZJ3nWP0EJjbTZwfdbiRj4Lb3oJ8kIkUvVdnhfKYkETllLP6uyW q29w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TeKnt0HV; 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 u64si6360861pfk.340.2018.02.12.06.35.32; Mon, 12 Feb 2018 06:35:50 -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=TeKnt0HV; 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 S935401AbeBLNTa (ORCPT + 99 others); Mon, 12 Feb 2018 08:19:30 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41039 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935307AbeBLNSF (ORCPT ); Mon, 12 Feb 2018 08:18:05 -0500 Received: by mail-lf0-f68.google.com with SMTP id f136so20376723lff.8 for ; Mon, 12 Feb 2018 05:18:04 -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=jX4buJqmwi3v7ZY16HuFYDWultv1gGtOOAL/qiwPrzY=; b=TeKnt0HVENE+Wx4ldMDpqNcmrtiiyn/QsMgeUuXzWKKSqYU/b4Vxa1MEyzzQS29OE+ q55PrXYds1Yk9GTl0f4Bpcgo4D9kQkx3ecPcJOTsP0ByT0cBiVyLz5CsWp+vzQtlWgqt sBZdpy2eG/OX0PbwRr7Trqbfl34vrnNB8ZE5Q= 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=jX4buJqmwi3v7ZY16HuFYDWultv1gGtOOAL/qiwPrzY=; b=HbvWsYKtlonymeLAeJ+lrZV2+4VYsENpRVX69kv9tAHHclRnLBuWFEt198GRZhycLz YcBgKRaLKEO5anc6eJYaoDbbPzCbrUNvzn5jcj7zY20ZDYdwj3BwSp2XmgT2rphE05Rx WsAVVEuVKH8xjxoYzeqxi1xm795K6ZBcgKMl4Q/0hfEmifT0PM/0qFy65z5Jo52axjOo VEroE8OEEQIF7i6G986K97hxuwrXur0LTmlIIXLkaoEmVXsJkh4lay8mdU+u+DbWWylV qPm0IaSn8ioOldCoBgF2Rh4gqYnD5pcRGxH7BIodUz2QN6R0VzIcWQqGZH7SCVHvUeex ln3g== X-Gm-Message-State: APf1xPBQSsKConW3f1ymsRn4grMkXQrtp+Wb4gACLRizHEBMKVB7K/Qm 7FJ//zM5BfzwZuCjvtfxGAW89UpiO4Y= X-Received: by 10.46.68.131 with SMTP id b3mr3373604ljf.13.1518441484003; Mon, 12 Feb 2018 05:18:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:03 -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, Charles Keepax , Lee Jones Subject: [PATCH 16/21] regulator: wm8994: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:12 +0100 Message-Id: <20180212131717.27193-17-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 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. Cc: patches@opensource.cirrus.com Cc: Charles Keepax Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: this patch is touching the MFD core driver for WM8994, but as with all other patches we just change the regulator parts. Would be nice if you could ACK it. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 18 ++++++++++++++++-- drivers/mfd/wm8994-core.c | 9 --------- drivers/regulator/wm8994-regulator.c | 19 +++++++++++-------- include/linux/mfd/wm8994/pdata.h | 3 --- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index f00988705408..a4db97f156d7 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -193,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, }, }, }; @@ -202,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), + { }, }, }; @@ -366,6 +379,7 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, rev == gf_mods[i].rev)) break; + gpiod_add_lookup_table(&wm8994_gpiod_table); if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", gf_mods[i].name, rev + 1); 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; }; -- 2.14.3