From patchwork Mon May 14 08:06:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135671 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439200lji; Mon, 14 May 2018 01:07:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqn8pU6R/4SMCxagQA5Um0QqQ2zupinb2Eke6S0Wflk9kXVqf4wqi7v2esJed3bNI0t3Srm X-Received: by 2002:a65:4a46:: with SMTP id a6-v6mr7703908pgu.227.1526285229883; Mon, 14 May 2018 01:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285229; cv=none; d=google.com; s=arc-20160816; b=gE0zuPoxA4k8scrSjG2qiry/II9h3xv07mg/rX/iuWOYH1lhdq2Ux+uVcEUiDYlsGB jEGMFp0XJsLnsH1OBtUNys4+A1RXtq3dB/cGSYXrvcyDmaPhBCRgVfpd8IJJVvXr1C2f t01fSZfZGbsWExbM2+xx1O91TtMk7ZwNM/6Yo0BezGeIawW56p+4z/dw7wd+1MRrXU4y 0StMDY3CeBZyveAjV6m+vSgZYhNIrJYw/uws5xxfh6cIY0tY7Y4f4xvLKXIDMuU1qt9X gA4uhXSG2xtsY9HKFV8TCPwhqtKVOKaRKPUeOgdnR0xHIyrJWqP3KtGPeXz6qy88IZsW K9OA== 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=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=Kg2/eaZcXHo4OoEcFFeEdpXufnFj5u9UD/0YICX6eRnpfJb7VOOFn1QlLStVTShz96 Wek8zT/4s0wrcbqSkGIk5U7gstv1Mxk0tCy3wZ98DlF7x5YtAdm3OfxyDvSvqtfYBYA0 Gdr3ZToTxUwjTTclA4kiheA2gA3wJdQz1c4xomyiPyjea9ohyhfMijtgFKInhM2WAGZx ldvhJ0s6rbT6u1efY08uOcUkVWhp/GYG8D/zNuraIRI3mQYtwv7j7T/GlFhK+XP9JTD3 sx1rsbGVOCLif67OxUfbv+r5ag3nGOJgFMIVIN2gCTqWsefzonEOv20fiJkjLbymTb0i rRUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H4j8Fo3I; 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 z6-v6si8978027pfk.194.2018.05.14.01.07.09; Mon, 14 May 2018 01:07:09 -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=H4j8Fo3I; 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 S1752211AbeENIHF (ORCPT + 29 others); Mon, 14 May 2018 04:07:05 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40000 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbeENIGy (ORCPT ); Mon, 14 May 2018 04:06:54 -0400 Received: by mail-lf0-f68.google.com with SMTP id p85-v6so16542777lfg.7 for ; Mon, 14 May 2018 01:06:53 -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=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=H4j8Fo3IIjqtRDghOGcePcfmmp1qbyLE+WPsZ3HxhuJxu9qNB93RWlk6XM4FRCC3mC X6+iciCK4ZyUXqpz1JyHmk8vxz4UsYoDRraBM/bZMwktk0YZwrSDc04cC/d+zb0dirig sUB4QeeVcJgMzytdDcd5BEaVdWCFy9Zj/K+Ds= 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=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=pRK+IW+NBWue43NWfqQx3fQ1UlGINCowJjkSOX2cIt6WoSTQbDwyOOt3h61W6ltEyS UEcaZPBgK07HqYmoWEsk2fVSaod87gkQkEq/rTQRCIDSMI+Vp77FGkR8yAomdH3IfoUD ykhxI1bFHFRV4YwN4gFRuBhiLFv1R+WfP9FStWHei6saep6TO55rS8gfcOtS+p9VYkri twTIuaKW9ZunJl3mR7m0P86xVjprENZdS5skEcxptpWNpVFz3E80Y9XoCz80aOpHeoYu HQ2kCHrfQ8HA0PvtEL5PKQB6UFy7ie3mB90pW9ZOBH0Ur/bRO5Spp9QMXFgFAHl+NlZ4 B6BA== X-Gm-Message-State: ALKqPwcyjlGwiaogqzMihVL7n52W42pBT0O8k3fAPi2NhVs7/s2+bIym WxzfM73dyRcW1S7gQOqhzWPT98DTNA4= X-Received: by 2002:a2e:8693:: with SMTP id l19-v6mr3813357lji.91.1526285213059; Mon, 14 May 2018 01:06:53 -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.06.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:51 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com, Richard Fitzgerald , Charles Keepax Subject: [PATCH 03/19 v3] regulator: arizona-ldo1: Look up a descriptor and pass to the core Date: Mon, 14 May 2018 10:06:24 +0200 Message-Id: <20180514080640.12515-4-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, 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 commit 6a537d48461d "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Cc: Richard Fitzgerald Cc: Charles Keepax Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Fix "wlf,ldo1ena" to "wlf,ldoena" on WM5102 non-reva ChangeLog v1->v2: - Rebase the patch on the other changes. - Make sure to update some s3c64xx platform data properly. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 28 +++++++++++++++----- drivers/regulator/arizona-ldo1.c | 19 +++++-------- include/linux/regulator/arizona-ldo1.h | 3 --- 3 files changed, 28 insertions(+), 22 deletions(-) -- 2.17.0 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 f00988705408..5aa472892465 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 @@ -206,9 +207,6 @@ static const struct i2c_board_info wm1277_devs[] = { }; static struct arizona_pdata wm5102_reva_pdata = { - .ldo1 = { - .ldoena = S3C64XX_GPN(7), - }, .gpio_base = CODEC_GPIO_BASE, .irq_flags = IRQF_TRIGGER_HIGH, .micd_pol_gpio = CODEC_GPIO_BASE + 4, @@ -237,10 +235,16 @@ static struct spi_board_info wm5102_reva_spi_devs[] = { }, }; -static struct arizona_pdata wm5102_pdata = { - .ldo1 = { - .ldoena = S3C64XX_GPN(7), +static struct gpiod_lookup_table wm5102_reva_gpiod_table = { + .dev_id = "spi0.1", /* SPI device name */ + .table = { + GPIO_LOOKUP("GPION", 7, + "wlf,ldoena", GPIO_ACTIVE_HIGH), + { }, }, +}; + +static struct arizona_pdata wm5102_pdata = { .gpio_base = CODEC_GPIO_BASE, .irq_flags = IRQF_TRIGGER_HIGH, .micd_pol_gpio = CODEC_GPIO_BASE + 2, @@ -264,6 +268,15 @@ static struct spi_board_info wm5102_spi_devs[] = { }, }; +static struct gpiod_lookup_table wm5102_gpiod_table = { + .dev_id = "spi0.1", /* SPI device name */ + .table = { + GPIO_LOOKUP("GPION", 7, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct spi_board_info wm5110_spi_devs[] = { [0] = { .modalias = "wm5110", @@ -366,6 +379,9 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, rev == gf_mods[i].rev)) break; + gpiod_add_lookup_table(&wm5102_reva_gpiod_table); + gpiod_add_lookup_table(&wm5102_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/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; };