From patchwork Mon May 14 08:06:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135683 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1443332lji; Mon, 14 May 2018 01:11:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqn8Xcx47w3jMqV33VAv0NRbF1CmzjE1RQvVTHJlL8QHjaABof98tctXWHPjBAcbrHCIrrP X-Received: by 2002:a62:404f:: with SMTP id n76-v6mr9413704pfa.185.1526285484248; Mon, 14 May 2018 01:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285484; cv=none; d=google.com; s=arc-20160816; b=vzOhdAUoZmtMdXlRrD8ind5OJfXl11GyhfYKs4i/QNJV5IIs/ttZCJWHD0xQu8fTue /EzCmliTP00nOAPHNfLKd5qzPY3EX6aw+BUJuvGCtJ/DRx6ftUQ9rosjE98Eo9R9pAXp qF5DmIbq005JYLM1Rt3l6yJ7k3mnce2+1PugjGOIdLJ0PpmneTxKw15/KS80dxVIOcPw 0JEjaR8Cr1T1YEXVBBSMwr4i0Vo6/3yOIYo8rqBitCyD7x3EjXQmm6GtAN49jDTJSO1M bV5qjwbjMIY9JVTuGd1a8J0NDXXv1nHz/DFtSC7LTMPKhHat2AYOtgdOnO5xpPDb+wXR Pk5Q== 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=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=pezU7BEkNno0IzV+rKX+6wWo3O0ubp9Dmo6NhTUNL5Fqy/RF5azze4q0UIJMIotDmy i9uqSJct5tw9U/03OJtkHHfapI8jOn5CxkA1HPrQOtEle2KNgBTK/CX1Te9mxdGmFcOA 24ZdzwAHYFVcCJvtHmszxmMY9NLTrtZCQaM+vetY2ks/BHHvOzHvoR/Jpq6ZaIp0wccO +3lrARsXxqGQYhkEkAtmQvA8xalKVQHLdlKOyBNMsF9mXLcPvOv2rjv4LxmDAKpC1GQB STiYc5Tr/3Vr38KcXjIGafe+EFMt1NpB9BEVxSF8yHqTEMldZaUgoAWLYQlc4bm6Bq9X aWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kh1lpMc6; 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 y25-v6si8784004pfn.248.2018.05.14.01.11.23; Mon, 14 May 2018 01:11:24 -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=kh1lpMc6; 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 S1752555AbeENILC (ORCPT + 29 others); Mon, 14 May 2018 04:11:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:41504 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752251AbeENIHS (ORCPT ); Mon, 14 May 2018 04:07:18 -0400 Received: by mail-lf0-f66.google.com with SMTP id m17-v6so11388783lfj.8 for ; Mon, 14 May 2018 01:07:17 -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=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=kh1lpMc6UwxKJdX8omRFQqGkoaop9lMNQFohe1AVvbPT51aWgtB5mfQNo80tuPbeCe gBl6NXSlqMQKM2ZhhGVtIDRjlRqvsB2ss+OSOcp44KvbnOqZnYbMTtIJp1oa1P1EV6bK geX/zLRKBltQ0LpdgJKiUVaKn2TNdODQY4H+Y= 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=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=s09mHKpHxI33MuNkG+Lgz4PrhFEfqBcSMCdxnlRVxmmpF61zc2pdSw7Xv+tyXl/kb1 fwpn82C0EoXpYTfdOoEUzRDMXQpzPUPHgswg+eDPzaH2yIMil4UHpbxx/675uRz1GMG5 erq/B9AWvXVodtQ/jU8otK+tfldsbRt1DTsMs/HNzAq5mQwPID5dPMYrZRXMs2dP9Z9G e96Z9VZRQXMW9bmD1Vgc2s6zJlU9IH4IUHI6sF0UOxenvD5iCcTyiujGK66Z0pz0FPlm op6lzS2o81J06vQAGyQcwIM83xAbl4KFxOyKCHEGGLYo2+HCMHJMEFJLxOSklCQ96S8z srzg== X-Gm-Message-State: ALKqPwf6ljiEi2pH+1R7Q/DccJla/yqD9RxV9LsuRg48XpDvdw4dq7fS CH2Q7x7++Y+oislFr28ISVXvWg== X-Received: by 2002:a19:6d02:: with SMTP id i2-v6mr8195999lfc.81.1526285236391; Mon, 14 May 2018 01:07:16 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:15 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com Subject: [PATCH 13/19 v3] regulator: wm8994: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:34 +0200 Message-Id: <20180514080640.12515-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node or the board file decriptor table for the regulator. There is a single board file passing the GPIOs for LDO1 and LDO2 through platform data, so augment this to pass descriptors associated with the i2c device as well. The special GPIO enable DT property for the enable GPIO is nonstandard but this was accomodated in commit 6a537d48461deacc57c07ed86d9915e5aa4b3539 "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Acked-by: Charles Keepax Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Collect Charles' ACK. ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 17 +++++++++++++++-- drivers/mfd/wm8994-core.c | 9 --------- drivers/regulator/wm8994-regulator.c | 19 +++++++++++-------- include/linux/mfd/wm8994/pdata.h | 3 --- 4 files changed, 26 insertions(+), 22 deletions(-) -- 2.17.0 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 5aa472892465..76c4855a03bc 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -194,8 +194,8 @@ static struct wm8994_pdata wm8994_pdata = { 0x3, /* IRQ out, active high, CMOS */ }, .ldo = { - { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, - { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, + { .init_data = &wm8994_ldo1, }, + { .init_data = &wm8994_ldo2, }, }, }; @@ -203,6 +203,18 @@ static const struct i2c_board_info wm1277_devs[] = { { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ .platform_data = &wm8994_pdata, .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, + .dev_name = "wm8958", + }, +}; + +static struct gpiod_lookup_table wm8994_gpiod_table = { + .dev_id = "i2c-wm8958", /* I2C device name */ + .table = { + GPIO_LOOKUP("GPION", 6, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("GPION", 4, + "wlf,ldo2ena", GPIO_ACTIVE_HIGH), + { }, }, }; @@ -381,6 +393,7 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, gpiod_add_lookup_table(&wm5102_reva_gpiod_table); gpiod_add_lookup_table(&wm5102_gpiod_table); + gpiod_add_lookup_table(&wm8994_gpiod_table); if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 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; };