Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3483678imm; Tue, 29 May 2018 08:02:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrV6rKXGWFLwiN7VJsQMrOm+SnXmFODbVbuDjhWZAdlriHzAWPnjq2dWiCcASQIB4zy5pMR X-Received: by 2002:a17:902:b205:: with SMTP id t5-v6mr17979403plr.343.1527606132555; Tue, 29 May 2018 08:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527606132; cv=none; d=google.com; s=arc-20160816; b=AvTKevRluxsJAtFppaA5a+aykyR2tVBaCkGuqNZ2EwPCi42emim/PwkjKcwoFp9wE4 +LHKq5c210mIrtQlXD13T1my9/sfLgBS0kXLdlV6A25n5xgSQSp9TFOBS2nxxEdC5Whw XyvEM3OYlMxkBquIkhtzi3oREOfynuSOfp3xYBFO2uPEBNDcoroBKJXMybSg7dlGmE42 NAwzpmfYiV84eXvcrHYjZIlnliNP4ssQQR04I1iemZQudXZrYxLJ0XbLl/rpuhzh3Ocm JY4IQ5/h43ABcVqVvibJtYrvApp8y556K85OrMjZS+CzZ84iCwhmizlBrOa+w4fYEQ5h mIGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=4ZzCI2/KGThBJ/96RzLwNUZD42e8u2kxvVllgu2gykE=; b=kl/Prcfd3ucNRUVW83yiAHS5TUwyjVjrj6o7JHmL5bFN9+RBodo71IHcB1biaC5LbY l7iC/Y/3eh6aF0MqtsXh7UjEYpajXuHMZ+X4zfT5EoBIbjddakW+G56B43Gbm4VOYZ2L r4x0Hccs4xY3F/v7Lxd2bsNTtxe4c4MLwhABRJluN1f3g2FMEi2/tw/S+bq0TpZRnx8E nQsDr3WG8mFW6AS+pV1zNFCx00MMjfiPZvzOGv83DGIjhWIpS3CNojwlmjn9UFX+vQdr NRl+/lNxcgUtCw484HnWJuI5CHusScLEHyARHK/seowiYUl1VvRXLnKovmqcQ7dsi0Y1 6nfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=AdwjB7eP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si26500676pgr.72.2018.05.29.08.01.57; Tue, 29 May 2018 08:02:12 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=AdwjB7eP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965117AbeE2PAD (ORCPT + 99 others); Tue, 29 May 2018 11:00:03 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:42136 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935773AbeE2O76 (ORCPT ); Tue, 29 May 2018 10:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=4ZzCI2/KGThBJ/96RzLwNUZD42e8u2kxvVllgu2gykE=; b=AdwjB7ePxIcV raOxwkaBknY4cVxN63GF/8/tQcepsTnqgjBBzhDDxwEIjmG/zWV2J2K0YUNoV3zWy1zJx0ixf/9om Btk2FlCC1ZT2Qt+vqpWNOzprjbnUe6JbVRo/rWolCaPKMSsnn4gVgwqa+L92kf/VScdxKJSaOm1T8 q/+Fw=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNg6O-0005cK-0c; Tue, 29 May 2018 14:59:56 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fNg6N-0006Cf-J8; Tue, 29 May 2018 15:59:55 +0100 From: Mark Brown To: Linus Walleij Cc: Philipp Zabel , Mark Brown , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Philipp Zabel , linux-kernel@vger.kernel.org Subject: Applied "regulator: gpio: Get enable GPIO using GPIO descriptor" to the regulator tree In-Reply-To: <20180212131717.27193-4-linus.walleij@linaro.org> Message-Id: Date: Tue, 29 May 2018 15:59:55 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: gpio: Get enable GPIO using GPIO descriptor has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 37bed97f00734ce329495823d9682181028b51e4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 May 2018 10:06:23 +0200 Subject: [PATCH] regulator: gpio: Get enable GPIO using GPIO descriptor 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 Signed-off-by: Mark Brown --- 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(-) 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 a86b8997bb54..9d6094c4d71c 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)) @@ -255,6 +252,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; -- 2.17.0