From patchwork Sun Apr 22 23:07:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133946 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp370750lji; Sun, 22 Apr 2018 16:13:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx48hCXR+2uezgvbKEeQXaLA7jWZ2wvxl6wGSPbkcXc9dyr2RvqQKRxoN2rM3GGq54jtr5Yb0 X-Received: by 2002:a17:902:b595:: with SMTP id a21-v6mr18789037pls.68.1524438827127; Sun, 22 Apr 2018 16:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438827; cv=none; d=google.com; s=arc-20160816; b=ea9ew55vgx04gHSS49BeMyMcxRvI1UxniuFlbc5Q0JJJQw9zMa2NXVTc79QxcjAflM fPDCkbfW8wzA7icHnd5nTJFGlaa5ayp9UJlZU01PcjYeF+9fa+KLeJVMaT7s59YqDdTN r8G56EgtEMDhaLlzMbxTZKQC44gtrscUPrA0K0Ga7saERB8Q/IsNHu6NIIqmYEB7UI6f fCzqJUbG2C2zSGRBqs6gvh4L0bonB5nGI7QpriPmKqBrB3y2LdJEJkBeFpZx6sp6fkOK jCUE0cGjjImbVyFILu2ywmTedDBmrO+IsWya1LRVJzX5iWt08b2oZjsK0Z/PUC6ngADr Tezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/8EkvG80rU8vrDoLXOWUDZme3kP46u/4/Y5iSgrgxos=; b=So4GNScNSiMsbzIrpblU68ihTSTulAddJSEgxOy4u05oHdcOXF7ygNeHeDTyzYMVoP CzTAjKtDVph/6qcjdRCu1O5jp2Qp8dKEiU/K6ppIzT4dMGoFZWT7UmhT75vtxN1BHNlg Adaw/2GoxIbYUrRL6smsECJCm8F0d7gqIWwTp9GG/GYsKOk4e/vhceWhFbmS9ymxe/E1 32u7fCBraclTgPNx1COrHG3lZug8xk8eJ5VfOqBSM9Si0Y4/PvpW1cycMQLi+NgMf1CY eQ7zvhdEmzdkPLlFsz6zH0XqbeRywlk111fTMcH4jBWBwqItgOyn161DwmFpl6CUyrh4 NrIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QYJdlTDg; 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 90-v6si4474610plc.205.2018.04.22.16.13.46; Sun, 22 Apr 2018 16:13:47 -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=QYJdlTDg; 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 S1753982AbeDVXNm (ORCPT + 29 others); Sun, 22 Apr 2018 19:13:42 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:37602 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753495AbeDVXJx (ORCPT ); Sun, 22 Apr 2018 19:09:53 -0400 Received: by mail-lf0-f68.google.com with SMTP id b23-v6so12251485lfg.4 for ; Sun, 22 Apr 2018 16:09:52 -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; bh=/8EkvG80rU8vrDoLXOWUDZme3kP46u/4/Y5iSgrgxos=; b=QYJdlTDgSaZuYSHeeq6diTBYKXsvPAePYL25WMqaIGU6oM1OX+8m3csPhLKO76WYNs vcU2dkX/J2CQUFc+iYSjFMLFnv1J5nJfC15N7/H9e9UzgQlTFQCF7r5DG0Igmr7WDIun 0meLW1GgXY85BmpRAHq5xGUiwN13/GghMrkAM= 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; bh=/8EkvG80rU8vrDoLXOWUDZme3kP46u/4/Y5iSgrgxos=; b=HnVWpizlorkDD1vvthOKYNGdHjDpc7l5QRoBpc057EWQJ66VVDWUs5Ci2GGTnn+xwC ohposR9pPA5TiNWyhdALNyjTQ/IpYAGV/zGsXN43xSzWY6qk5WH5FZbzDtas31vZP4nB kbthiKAAW+QjjsqyWSQ8svIjBjysL1ga34egI2kgHDn5z8RyCLvH5iK9Fw9q03TVewQl 6qHCV+gi0tENWzIRZWPl4d36ghX/aQc2g0mi5iAeCwKyCWX1RzqBUq5kLpuaW6JJCGvR YFH74FxAkcugP7QqviIQJ0ci8wef637RS+iCkC0Gb+5QnS7zaW6JZ/j+L2TNWmS2li2y 9LZg== X-Gm-Message-State: ALQs6tBP9CaJ/R9qIUnxayFOKnbJ3fkgOQkhlEXGHINItn907Pz3Nzz8 2F+HmSlg6Q2N2dgI4axb8lULgg== X-Received: by 2002:a19:10c1:: with SMTP id 62-v6mr7716194lfq.76.1524438591947; Sun, 22 Apr 2018 16:09:51 -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.09.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:09:50 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Andy Shevchenko , Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Daniel Mack , Marc Zyngier , Geert Uytterhoeven , Russell King Subject: [PATCH 01/18 v2] regulator: fixed: Convert to use GPIO descriptor only Date: Mon, 23 Apr 2018 01:07:25 +0200 Message-Id: <20180422230742.3729-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we augmented the regulator core to accept a GPIO descriptor instead of a GPIO number, we can augment the fixed GPIO regulator to look up and pass that descriptor directly from device tree or board GPIO descriptor look up tables. Some boards just auto-enumerate their fixed regulator platform devices and I have assumed they get names like "fixed-regulator.0" but it's pretty hard to guess this. I need some testing from board maintainers to be sure. Other boards are straight forward, using just plain "fixed-regulator" (ID -1) or "fixed-regulator.1" hammering down the device ID. The OMAP didn't have proper label names on its GPIO chips so I have fixed this with a separate patch to the GPIO tree, see commit 088413bc0bd5f5fb66ca22a19d66a49d7154ba4c "gpio: omap: Give unique labels to each GPIO bank/chip" It seems the da9055 and da9211 has never got around to actually passing any enable gpio into its platform data (not the in-tree code anyway) so we can just decide to simply pass a descriptor instead. The fixed GPIO-controlled regulator in mach-pxa/ezx.c was confusingly named "*_dummy_supply_device" while it is a very real device backed by a GPIO line. There is nothing dummy about it at all, so I renamed it with the infix *_regulator_* as part of this patch set. For the patch hunk hitting arch/blackfin I would say I do not expect testing, review or ACKs anymore so if it works, it works. The hunk hitting the x86 BCM43xx driver is especially tricky as the number comes out of SFI which is a mystery to me. I definately need someone to look at this. (Hi Andy.) Cc: Andy Shevchenko # Check the x86 BCM stuff Cc: Alexander Shiyan # i.MX boards user Cc: Haojian Zhuang # MMP2 maintainer Cc: Aaro Koskinen # OMAP1 maintainer Cc: Tony Lindgren # OMAP1,2,3 maintainer Cc: Mike Rapoport # EM-X270 maintainer Cc: Robert Jarzmik # EZX maintainer Cc: Philipp Zabel # Magician maintainer Cc: Daniel Mack # Raumfeld maintainer Cc: Marc Zyngier # Zeus maintainer Cc: Geert Uytterhoeven # SuperH pinctrl/GPIO maintainer Cc: Russell King # SA1100 Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on mainline with Blackfin gone and other changes. - Fix up the new users that appeared in sa1100 - Drop some suplus comments in x86. --- arch/arm/mach-imx/mach-mx21ads.c | 13 ++++++++- arch/arm/mach-imx/mach-mx27ads.c | 12 +++++++- arch/arm/mach-mmp/brownstone.c | 12 +++++++- arch/arm/mach-omap1/board-ams-delta.c | 14 ++++++++- arch/arm/mach-omap2/pdata-quirks.c | 16 ++++++++++- arch/arm/mach-pxa/em-x270.c | 1 - arch/arm/mach-pxa/ezx.c | 33 ++++++++++++++-------- arch/arm/mach-pxa/magician.c | 2 +- arch/arm/mach-pxa/raumfeld.c | 12 ++++++-- arch/arm/mach-pxa/zeus.c | 23 +++++++++++++-- arch/arm/mach-s3c64xx/mach-crag6410.c | 1 - arch/arm/mach-s3c64xx/mach-smdk6410.c | 1 - arch/arm/mach-sa1100/assabet.c | 21 +++++++++----- arch/arm/mach-sa1100/generic.c | 5 ++-- arch/arm/mach-sa1100/generic.h | 3 +- arch/arm/mach-sa1100/shannon.c | 4 +-- arch/sh/boards/mach-ecovec24/setup.c | 22 +++++++++++++-- .../intel-mid/device_libs/platform_bcm43xx.c | 17 +++++++++-- drivers/regulator/fixed-helper.c | 1 - drivers/regulator/fixed.c | 33 +++++++++++----------- include/linux/regulator/fixed.h | 3 -- 21 files changed, 187 insertions(+), 62 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 5e366824814f..5d3b6b4fe6db 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -175,6 +176,7 @@ static struct resource mx21ads_mmgpio_resource = DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); static struct bgpio_pdata mx21ads_mmgpio_pdata = { + .label = "mx21ads-mmgpio", .base = MX21ADS_MMGPIO_BASE, .ngpio = 16, }; @@ -203,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { .supply_name = "LCD", .microvolts = 3300000, - .gpio = MX21ADS_IO_LCDON, .enable_high = 1, .init_data = &mx21ads_lcd_regulator_init_data, }; @@ -216,6 +217,15 @@ static struct platform_device mx21ads_lcd_regulator = { }, }; +static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ + .table = { + GPIO_LOOKUP("mx21ads-mmgpio", 9, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * Connected is a portrait Sharp-QVGA display * of type: LQ035Q7DB02 @@ -311,6 +321,7 @@ static void __init mx21ads_late_init(void) { imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata); + gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table); platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); mx21ads_cs8900_resources[1].start = diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c index a04bb094ded1..0fdb88db0cbd 100644 --- a/arch/arm/mach-imx/mach-mx27ads.c +++ b/arch/arm/mach-imx/mach-mx27ads.c @@ -16,6 +16,7 @@ #include /* Needed for gpio_to_irq() */ #include +#include #include #include #include @@ -230,10 +231,17 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = { static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { .supply_name = "LCD", .microvolts = 3300000, - .gpio = MX27ADS_LCD_GPIO, .init_data = &mx27ads_lcd_regulator_init_data, }; +static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ + .table = { + GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void __init mx27ads_regulator_init(void) { struct gpio_chip *vchip; @@ -247,6 +255,8 @@ static void __init mx27ads_regulator_init(void) vchip->set = vgpio_set; gpiochip_add_data(vchip, NULL); + gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table); + platform_device_register_data(NULL, "reg-fixed-voltage", PLATFORM_DEVID_AUTO, &mx27ads_lcd_regulator_pdata, diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index d1613b954926..563b5a278d65 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = { static struct fixed_voltage_config brownstone_v_5vp = { .supply_name = "v_5vp", .microvolts = 5000000, - .gpio = GPIO_5V_ENABLE, .enable_high = 1, .enabled_at_boot = 1, .init_data = &brownstone_v_5vp_data, @@ -162,6 +162,15 @@ static struct platform_device brownstone_v_5vp_device = { }, }; +static struct gpiod_lookup_table brownstone_v_5vp_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", /* .id set to 1 above */ + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_5V_ENABLE, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct max8925_platform_data brownstone_max8925_info = { .irq_base = MMP_NR_IRQS, }; @@ -217,6 +226,7 @@ static void __init brownstone_init(void) mmp2_add_isram(&mmp2_isram_platdata); /* enable 5v regulator */ + gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table); platform_device_register(&brownstone_v_5vp_device); } diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 52e8e53ca154..759fa18f6ab4 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ #include +#include #include #include #include @@ -203,6 +204,7 @@ static struct resource latch2_resources[] = { }; static struct bgpio_pdata latch2_pdata = { + .label = "ams-delta-latch2", .base = AMS_DELTA_LATCH2_GPIO_BASE, .ngpio = AMS_DELTA_LATCH2_NGPIO, }; @@ -272,7 +274,6 @@ static struct regulator_init_data modem_nreset_data = { static struct fixed_voltage_config modem_nreset_config = { .supply_name = "modem_nreset", .microvolts = 3300000, - .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET, .startup_delay = 25000, .enable_high = 1, .enabled_at_boot = 1, @@ -287,6 +288,16 @@ static struct platform_device modem_nreset_device = { }, }; +static struct gpiod_lookup_table modem_nreset_gpiod_table = { + .dev_id = "reg-fixed-voltage", + .table = { + /* The AMS_DELTA_GPIO_PIN_MODEM_NRESET is at offset 12 */ + GPIO_LOOKUP("ams-delta-latch2", 12, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + struct modem_private_data { struct regulator *regulator; }; @@ -570,6 +581,7 @@ static int __init late_init(void) platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); + gpiod_add_lookup_table(&modem_nreset_gpiod_table); err = platform_device_register(&modem_nreset_device); if (err) { pr_err("Couldn't register the modem regulator device\n"); diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 6459816c2879..7d1447204fb8 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -330,7 +331,6 @@ static struct regulator_init_data pandora_vmmc3 = { static struct fixed_voltage_config pandora_vwlan = { .supply_name = "vwlan", .microvolts = 1800000, /* 1.8V */ - .gpio = PANDORA_WIFI_NRESET_GPIO, .startup_delay = 50000, /* 50ms */ .enable_high = 1, .init_data = &pandora_vmmc3, @@ -344,6 +344,19 @@ static struct platform_device pandora_vwlan_device = { }, }; +static struct gpiod_lookup_table pandora_vwlan_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + /* + * As this is a low GPIO number it should be at the first + * GPIO bank. + */ + GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void pandora_wl1251_init_card(struct mmc_card *card) { /* @@ -405,6 +418,7 @@ static void __init pandora_wl1251_init(void) static void __init omap3_pandora_legacy_init(void) { platform_device_register(&pandora_backlight); + gpiod_add_lookup_table(&pandora_vwlan_gpiod_table); platform_device_register(&pandora_vwlan_device); omap_hsmmc_init(pandora_mmc3); omap_hsmmc_late_init(pandora_mmc3); diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 49022ad338e9..6d7d93981098 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -987,7 +987,6 @@ static struct fixed_voltage_config camera_dummy_config = { .supply_name = "camera_vdd", .input_supply = "vcc cam", .microvolts = 2800000, - .gpio = -1, .enable_high = 0, .init_data = &camera_dummy_initdata, }; diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c index 2c90b58f347d..2b4bd6d94855 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -698,31 +699,39 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = { #if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910) /* camera */ -static struct regulator_consumer_supply camera_dummy_supplies[] = { +static struct regulator_consumer_supply camera_regulator_supplies[] = { REGULATOR_SUPPLY("vdd", "0-005d"), }; -static struct regulator_init_data camera_dummy_initdata = { - .consumer_supplies = camera_dummy_supplies, - .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies), +static struct regulator_init_data camera_regulator_initdata = { + .consumer_supplies = camera_regulator_supplies, + .num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies), .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS, }, }; -static struct fixed_voltage_config camera_dummy_config = { +static struct fixed_voltage_config camera_regulator_config = { .supply_name = "camera_vdd", .microvolts = 2800000, - .gpio = GPIO50_nCAM_EN, .enable_high = 0, - .init_data = &camera_dummy_initdata, + .init_data = &camera_regulator_initdata, }; -static struct platform_device camera_supply_dummy_device = { +static struct platform_device camera_supply_regulator_device = { .name = "reg-fixed-voltage", .id = 1, .dev = { - .platform_data = &camera_dummy_config, + .platform_data = &camera_regulator_config, + }, +}; + +static struct gpiod_lookup_table camera_supply_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, + "enable", GPIO_ACTIVE_HIGH), + { }, }, }; #endif @@ -800,7 +809,7 @@ static struct i2c_board_info a780_i2c_board_info[] = { static struct platform_device *a780_devices[] __initdata = { &a780_gpio_keys, - &camera_supply_dummy_device, + &camera_supply_regulator_device, }; static void __init a780_init(void) @@ -823,6 +832,7 @@ static void __init a780_init(void) if (a780_camera_init() == 0) pxa_set_camera_info(&a780_pxacamera_platform_data); + gpiod_add_lookup_table(&camera_supply_gpiod_table); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(a780_devices)); @@ -892,6 +902,7 @@ static void __init e680_init(void) pxa_set_keypad_info(&e680_keypad_platform_data); + gpiod_add_lookup_table(&camera_supply_gpiod_table); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(e680_devices)); @@ -1098,7 +1109,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = { static struct platform_device *a910_devices[] __initdata = { &a910_gpio_keys, - &camera_supply_dummy_device, + &camera_supply_regulator_device, }; static void __init a910_init(void) diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index c5325d1ae77b..14c0f80bc9e7 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -696,7 +697,6 @@ static struct regulator_init_data vads7846_regulator = { static struct fixed_voltage_config vads7846 = { .supply_name = "vads7846", .microvolts = 3300000, /* probably */ - .gpio = -EINVAL, .startup_delay = 0, .init_data = &vads7846_regulator, }; diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 034345546f84..ee766e4ebddc 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -886,7 +886,6 @@ static struct regulator_init_data audio_va_initdata = { static struct fixed_voltage_config audio_va_config = { .supply_name = "audio_va", .microvolts = 5000000, - .gpio = GPIO_AUDIO_VA_ENABLE, .enable_high = 1, .enabled_at_boot = 0, .init_data = &audio_va_initdata, @@ -900,6 +899,15 @@ static struct platform_device audio_va_device = { }, }; +static struct gpiod_lookup_table audio_va_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_AUDIO_VA_ENABLE, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* Dummy supplies for Codec's VD/VLC */ static struct regulator_consumer_supply audio_dummy_supplies[] = { @@ -918,7 +926,6 @@ static struct regulator_init_data audio_dummy_initdata = { static struct fixed_voltage_config audio_dummy_config = { .supply_name = "audio_vd", .microvolts = 3300000, - .gpio = -1, .init_data = &audio_dummy_initdata, }; @@ -1033,6 +1040,7 @@ static void __init raumfeld_audio_init(void) else gpio_direction_output(GPIO_MCLK_RESET, 1); + gpiod_add_lookup_table(&audio_va_gpiod_table); platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices)); } diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index e3851795d6d7..58e05afcece0 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -410,7 +411,6 @@ static struct regulator_init_data can_regulator_init_data = { static struct fixed_voltage_config can_regulator_pdata = { .supply_name = "CAN_SHDN", .microvolts = 3300000, - .gpio = ZEUS_CAN_SHDN_GPIO, .init_data = &can_regulator_init_data, }; @@ -422,6 +422,15 @@ static struct platform_device can_regulator_device = { }, }; +static struct gpiod_lookup_table can_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct mcp251x_platform_data zeus_mcp2515_pdata = { .oscillator_frequency = 16*1000*1000, }; @@ -538,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = { static struct fixed_voltage_config zeus_ohci_regulator_config = { .supply_name = "vbus2", .microvolts = 5000000, /* 5.0V */ - .gpio = ZEUS_USB2_PWREN_GPIO, .enable_high = 1, .startup_delay = 0, .init_data = &zeus_ohci_regulator_data, @@ -552,6 +560,15 @@ static struct platform_device zeus_ohci_regulator_device = { }, }; +static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct pxaohci_platform_data zeus_ohci_platform_data = { .port_mode = PMM_NPS_MODE, /* Clear Power Control Polarity Low and set Power Sense @@ -855,6 +872,8 @@ static void __init zeus_init(void) pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config)); + gpiod_add_lookup_table(&can_regulator_gpiod_table); + gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table); platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices)); zeus_register_ohci(); diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index f04650297487..379424d72ae7 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -352,7 +352,6 @@ static struct fixed_voltage_config wallvdd_pdata = { .supply_name = "WALLVDD", .microvolts = 5000000, .init_data = &wallvdd_data, - .gpio = -EINVAL, }; static struct platform_device wallvdd_device = { diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c index c46fa5dfd2e0..908e5aa831c8 100644 --- a/arch/arm/mach-s3c64xx/mach-smdk6410.c +++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c @@ -222,7 +222,6 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = { .supply_name = "B_PWR_5V", .microvolts = 5000000, .init_data = &smdk6410_b_pwr_5v_data, - .gpio = -EINVAL, }; static struct platform_device smdk6410_b_pwr_5v = { diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 575ec085cffa..dbb53c520165 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -101,7 +101,7 @@ static int __init assabet_init_gpio(void __iomem *reg, u32 def_val) assabet_bcr_gc = gc; - return gc->base; + return 0; } /* @@ -471,6 +471,14 @@ static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { .enable_high = 1, }; +static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("assabet", 0, "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void __init assabet_init(void) { /* @@ -517,9 +525,11 @@ static void __init assabet_init(void) neponset_resources, ARRAY_SIZE(neponset_resources)); #endif } else { + gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table); sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, - assabet_cf_vcc_consumers, - ARRAY_SIZE(assabet_cf_vcc_consumers)); + assabet_cf_vcc_consumers, + ARRAY_SIZE(assabet_cf_vcc_consumers), + true); } @@ -802,7 +812,6 @@ fs_initcall(assabet_leds_init); void __init assabet_init_irq(void) { - unsigned int assabet_gpio_base; u32 def_val; sa1100_init_irq(); @@ -817,9 +826,7 @@ void __init assabet_init_irq(void) * * This must precede any driver calls to BCR_set() or BCR_clear(). */ - assabet_gpio_base = assabet_init_gpio((void *)&ASSABET_BCR, def_val); - - assabet_cf_vcc_pdata.gpio = assabet_gpio_base + 0; + assabet_init_gpio((void *)&ASSABET_BCR, def_val); } MACHINE_START(ASSABET, "Intel-Assabet") diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 7167ddf84a0e..800321c6cbd8 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -348,7 +348,8 @@ void __init sa11x0_init_late(void) int __init sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, - struct regulator_consumer_supply *supplies, unsigned num_supplies) + struct regulator_consumer_supply *supplies, unsigned num_supplies, + bool uses_gpio) { struct regulator_init_data *id; @@ -356,7 +357,7 @@ int __init sa11x0_register_fixed_regulator(int n, if (!cfg->init_data) return -ENOMEM; - if (cfg->gpio < 0) + if (!uses_gpio) id->constraints.always_on = 1; id->constraints.name = cfg->supply_name; id->constraints.min_uV = cfg->microvolts; diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index 5f3cb52fa6ab..158a4fd5ca24 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h @@ -54,4 +54,5 @@ void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *); struct fixed_voltage_config; struct regulator_consumer_supply; int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, - struct regulator_consumer_supply *supplies, unsigned num_supplies); + struct regulator_consumer_supply *supplies, unsigned num_supplies, + bool uses_gpio); diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c index 22f7fe0b809f..5bc82e2671c6 100644 --- a/arch/arm/mach-sa1100/shannon.c +++ b/arch/arm/mach-sa1100/shannon.c @@ -102,14 +102,14 @@ static struct fixed_voltage_config shannon_cf_vcc_pdata __initdata = { .supply_name = "cf-power", .microvolts = 3300000, .enabled_at_boot = 1, - .gpio = -EINVAL, }; static void __init shannon_init(void) { sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata, shannon_cf_vcc_consumers, - ARRAY_SIZE(shannon_cf_vcc_consumers)); + ARRAY_SIZE(shannon_cf_vcc_consumers), + false); sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table); sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table); sa11x0_ppc_configure_mcp(); diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index adc61d14172c..c296b5c399b7 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -633,7 +633,6 @@ static struct regulator_init_data cn12_power_init_data = { static struct fixed_voltage_config cn12_power_info = { .supply_name = "CN12 SD/MMC Vdd", .microvolts = 3300000, - .gpio = GPIO_PTB7, .enable_high = 1, .init_data = &cn12_power_init_data, }; @@ -646,6 +645,16 @@ static struct platform_device cn12_power = { }, }; +static struct gpiod_lookup_table cn12_power_gpiod_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + /* Offset 7 on port B */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) /* SDHI0 */ static struct regulator_consumer_supply sdhi0_power_consumers[] = @@ -665,7 +674,6 @@ static struct regulator_init_data sdhi0_power_init_data = { static struct fixed_voltage_config sdhi0_power_info = { .supply_name = "CN11 SD/MMC Vdd", .microvolts = 3300000, - .gpio = GPIO_PTB6, .enable_high = 1, .init_data = &sdhi0_power_init_data, }; @@ -678,6 +686,16 @@ static struct platform_device sdhi0_power = { }, }; +static struct gpiod_lookup_table sdhi0_power_gpiod_table = { + .dev_id = "reg-fixed-voltage.1", + .table = { + /* Offset 6 on port B */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6, + "enable", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct tmio_mmc_data sdhi0_info = { .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c index 4392c15ed9e0..fc77d69e51d7 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c @@ -10,7 +10,7 @@ * of the License. */ -#include +#include #include #include #include @@ -43,7 +43,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { * real voltage and signaling are still 1.8V. */ .microvolts = 2000000, /* 1.8V */ - .gpio = -EINVAL, .startup_delay = 250 * 1000, /* 250ms */ .enable_high = 1, /* active high */ .enabled_at_boot = 0, /* disabled at boot */ @@ -58,11 +57,23 @@ static struct platform_device bcm43xx_vmmc_regulator = { }, }; +static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = { + .dev_id = "reg-fixed-voltage.0", + .table = { + GPIO_LOOKUP("0000:00:0c.0", -1, "enable", GPIO_ACTIVE_LOW), + {} + }, +}; + static int __init bcm43xx_regulator_register(void) { + struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table; + struct gpiod_lookup *lookup = table->table; int ret; - bcm43xx_vmmc.gpio = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); + lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); + gpiod_add_lookup_table(table); + ret = platform_device_register(&bcm43xx_vmmc_regulator); if (ret) { pr_err("%s: vmmc regulator register failed\n", __func__); diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c index 777fac6fb4cb..2c6098e6f4bc 100644 --- a/drivers/regulator/fixed-helper.c +++ b/drivers/regulator/fixed-helper.c @@ -43,7 +43,6 @@ struct platform_device *regulator_register_always_on(int id, const char *name, } data->cfg.microvolts = uv; - data->cfg.gpio = -EINVAL; data->cfg.enabled_at_boot = 1; data->cfg.init_data = &data->init_data; diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 988a7472c2ab..1142f195529b 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -24,10 +24,9 @@ #include #include #include -#include +#include #include #include -#include #include #include @@ -78,10 +77,6 @@ of_get_fixed_voltage_config(struct device *dev, if (init_data->constraints.boot_on) config->enabled_at_boot = true; - config->gpio = of_get_named_gpio(np, "gpio", 0); - if ((config->gpio < 0) && (config->gpio != -ENOENT)) - return ERR_PTR(config->gpio); - of_property_read_u32(np, "startup-delay-us", &config->startup_delay); config->enable_high = of_property_read_bool(np, "enable-active-high"); @@ -102,6 +97,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) struct fixed_voltage_config *config; struct fixed_voltage_data *drvdata; struct regulator_config cfg = { }; + enum gpiod_flags gflags; int ret; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), @@ -150,25 +146,28 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - if (gpio_is_valid(config->gpio)) { - cfg.ena_gpio = config->gpio; - if (pdev->dev.of_node) - 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; } - if (config->gpio_is_open_drain) - cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; + if (config->gpio_is_open_drain) { + if (gflags == GPIOD_OUT_HIGH) + gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; + else + gflags = GPIOD_OUT_LOW_OPEN_DRAIN; + } + + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); + if (IS_ERR(cfg.ena_gpiod)) + return PTR_ERR(cfg.ena_gpiod); cfg.dev = &pdev->dev; cfg.init_data = config->init_data; diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 48918be649d4..1a4340ed8e2b 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h @@ -24,8 +24,6 @@ struct regulator_init_data; * @supply_name: Name of the regulator supply * @input_supply: Name of the input regulator supply * @microvolts: Output voltage of regulator - * @gpio: GPIO to use for enable control - * set to -EINVAL if not used * @startup_delay: Start-up time in microseconds * @gpio_is_open_drain: Gpio pin is open drain or normal type. * If it is open drain type then HIGH will be set @@ -49,7 +47,6 @@ struct fixed_voltage_config { const char *supply_name; const char *input_supply; int microvolts; - int gpio; unsigned startup_delay; unsigned gpio_is_open_drain:1; unsigned enable_high:1; From patchwork Sun Apr 22 23:07:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133929 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368204lji; Sun, 22 Apr 2018 16:10:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx481G6B8+TrCl/Z6Zvknuamq3T++x5ZTbYN/x7+FGapP66eRukJ6iu9wU292vIb7IWX2Cyul X-Received: by 10.98.37.197 with SMTP id l188mr17709255pfl.17.1524438613547; Sun, 22 Apr 2018 16:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438613; cv=none; d=google.com; s=arc-20160816; b=Vwh4IDT4Kex74iW4MACdAN63hn7FGjfa1aeFhL01uibJxTh0D+Pj3GDQ0foNBUuW0M q4gpn2evRFA8PuX0eheosDQu4DWZpMNh1T5v4ta3Ce/LMEw8p3CiPBU0eVjlAEU236oO /KJF22SgXulm3NR1y4KehkrfaU4qW4eqftHmtZMnde+Cm00pYMTc1rbv8QxwQAvACEpJ nRZEcOh6hicKuwDY21M0Hk1KmcH3m2JO6aqAkWjL46PAJfPpnwch/Uf+jSOVyuwwzudt UpYm/gGd64pl2uJ6hxRc+lVaSq77VHvsy0FAmcs6c2YZ0eppAiQ/tNrhXhzdsC7gNkVS 1lUQ== 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=1ayiMYopnzJbCAZbC1rEU8BWk/oZGPxqhuOFp1zmtXo=; b=FTXRQ9r2FYBNBa+iiL255gHlIs2/HAbYKgBjdi4iKzSzVh2Mov4RwqpUfGf4HT3INI nG0dw3Oh4Ec2oyfbwIEZJUTSbGpJb/kVj7BDTSoMF/4UejAh6Wt61rncfy3h1GhWkeGL SVXpyWsQ3TiWoYw4EwJAPunJ01xA2GGhceePVqpNqFISG0T/6YMWWrsoFbH09l6WNNOF ZL2CeKT8Gc6n/e6EbpShEbdeAnYKPIDKZAARYuV8qAJBdV9/Jxg+4EYomb0pU5srPt8f JFq9sYWFAxlqqFhZaVBZwKEt4EfWFZkfsKcIOG1cDxCuGncdqS1ON2LRr3uYM1OD86p9 FKDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxCqafgX; 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 k10si7616465pgs.304.2018.04.22.16.10.13; Sun, 22 Apr 2018 16:10:13 -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=RxCqafgX; 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 S1753830AbeDVXKC (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43723 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753670AbeDVXJ4 (ORCPT ); Sun, 22 Apr 2018 19:09:56 -0400 Received: by mail-lf0-f66.google.com with SMTP id v207-v6so12174318lfa.10 for ; Sun, 22 Apr 2018 16:09:55 -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=1ayiMYopnzJbCAZbC1rEU8BWk/oZGPxqhuOFp1zmtXo=; b=RxCqafgXTOCQdpM5qqB1V1U4kqJtHi6aEXZYLAh8uxDG8Hw9eRLQqG2yL6dcz7fRSK lAouW11LlID89af/2t+UqkQLPWXTU2UgvoNmJuno2ApywixrxcRCA4FzVbm/zZ7XtH6r GpEN9nbqs9JOUlRXwEUcERjkMrEZTZdzB/jxE= 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=1ayiMYopnzJbCAZbC1rEU8BWk/oZGPxqhuOFp1zmtXo=; b=CRBSi0Ngmuw5WmKqALmj4ITtWocJ+ktO3wv5vnybdqiFvIJjMGXDptJQhCngDhjCQ1 88tqhkZHg67To5jsVgWb8Ds47LaIOcFrqx26KtkEJByONSMGsVmpr4/V3Rt4Dkntestz RDYo2v/SDX4dWn1+G1kiLw/OphOYfiNhRR1uFd2ioUgKlNiq2aZkTdgtWFaBhuH7KYUV 7/5CztrrC6cfezGTc7aRUByhJiYim7zZLWs2So5ZXqMJW3kbW9nDVrOGfctJDPKHDP39 FRjWeMoVUyhpUzOZF05w7CLV47Lo5uVdcphWRhVyLdQ0FLQdtDsfSzqD58ZuyvjOyAwZ tMkA== X-Gm-Message-State: ALQs6tDkbem2wTsT7NnEHsaia8CVgh5KxXvVXV43GZgznBpsIRn++iRK e2zzOmcgyMG1ii2WzlgcEo0Tuw== X-Received: by 2002:a19:2a88:: with SMTP id q8-v6mr7226681lfq.79.1524438594612; Sun, 22 Apr 2018 16:09:54 -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.09.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:09:53 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Philipp Zabel Subject: [PATCH 02/18 v2] regulator: gpio: Get enable GPIO using GPIO descriptor Date: Mon, 23 Apr 2018 01:07:26 +0200 Message-Id: <20180422230742.3729-2-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 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 --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- 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(-) -- 2.14.3 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; From patchwork Sun Apr 22 23:07:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133930 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368209lji; Sun, 22 Apr 2018 16:10:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49/wE+IM+1Np8YLtPVgHjwT6KW9xuumg8/mINXNTmqhpjp1nNeDs65DAUEIv7k2reaZ+gdz X-Received: by 2002:a17:902:7c0e:: with SMTP id x14-v6mr19081886pll.392.1524438613955; Sun, 22 Apr 2018 16:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438613; cv=none; d=google.com; s=arc-20160816; b=Z3X/pH56Rd1u+KKoODqL74QdRYgPuuB3bVJCWTiWbSShizRNmjvBAwWi52dlX34S6r ZxdL2WBIQvbj+S+SL0DaR27O/V5BpRBO9x93L9ry7D7RaKRkjL9w1BcblbqPR22xSnQs LK2suJHdPVywZsRYCedhP3s/s21Ow1JnY+EoiTozmrS+LHAZwcDGsDDSXJ5SUIl6yPJq TBNpQTMOQNzE01EPAYwrXjNUoMposNUSqfXCnCc54WBvdbeWUHOtzJH7XSwvEo+/U4uT vLk8/Ze1xEeJY6YieYlTS3bKe+cRZC4Tmk/1SgmlJfehmoRWCLDOAmqnQzcSkAEm85dg QSMg== 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=t7UGbbBFvbxu1BIVCL8+ik8ewwJkUge6BHhtP3paDlE=; b=i7GVWwn+MhBXXiZ3uhJT8I4578TaKkhVgHV4KGp8+4BZQ+R/xJwev3PMbOa+dSmPaa RJMK8rwhEBRE+ZGmkOcef9ka/XmYQvLrXVQo8Z364wNJoKfHZ+jSusVu6g07tLsV5TUF h9m08i+u3u7ASg9R5zd1jKgHlrSLALYKUM86SDPcWy+9E0+6Xo1bhbQXVUmYBxXV2RUu sEkYTy6KCzu82MfryTjRvFZT/fFvwOTZ7rafLcGTidN1uxm1iYL8QOAUeqmj5rzDShGu 7FAIZ26GwiJUOpE2hliT+wa5qHEHdRMr3kSR38XnGQp6nGx302RCBxD+s1hKnPoQk9Xc VOiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e09xkB4m; 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 k10si7616465pgs.304.2018.04.22.16.10.13; Sun, 22 Apr 2018 16:10:13 -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=e09xkB4m; 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 S1753860AbeDVXKE (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:04 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40592 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753707AbeDVXJ6 (ORCPT ); Sun, 22 Apr 2018 19:09:58 -0400 Received: by mail-lf0-f68.google.com with SMTP id i18-v6so12224879lfc.7 for ; Sun, 22 Apr 2018 16:09:57 -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=t7UGbbBFvbxu1BIVCL8+ik8ewwJkUge6BHhtP3paDlE=; b=e09xkB4mR6p3RhnilzsQ9zD4J5pREi5zXBkH6ZgbwVZm8pUwWXMioSTantIVClphdk y+khvzx4PKH+RLC2y4CdG0/80Ikn+XI+ouVgDpCheWvDKoo/mBCdbnXRgoEvEYmBYnhS aEXbR0DRq4c9P9SqmUJjNPRVgkGsQ1lUZb6Tg= 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=t7UGbbBFvbxu1BIVCL8+ik8ewwJkUge6BHhtP3paDlE=; b=Ja7s62sjWF2R4osT5PBd9KOqJnXDzy1f9lQvXGM1U71GkTjb5eBHbcdY4/U7pTQIbi lA3NbhNEDb8yET8u6Y+i3cplMMP+kSlpOPnSNJtJjmJEtUz2Nyyck5vx/2zSp/DwfHmc DhnabrNqtTdcrzmtn/5yT8w+ZAEIEDcA89SBikY4KYMjchb/6FGg6ifjj1NiW/vjwo2N +5bYnZjVdh6SuHZHVYNdI78IP0heA/JXUm0yhkLwXZL0cCw3LCKsNocSam0guBY7HxO0 Y1B9VChc7Mwqe5r7tMIZH5CBXuAgvH1kqU2NiOCL0xZS4PdUd+M+KzqWb3gvw51Ryyd1 6bFQ== X-Gm-Message-State: ALQs6tClAdN/lTm8TSaoG4ihHgHbwsqDLoX/czyzAHF8fpRJ03RBOjqw 6d2nqfu0qX9Whsp6vVrEFza8jA== X-Received: by 2002:a19:e444:: with SMTP id b65-v6mr7152530lfh.61.1524438596876; Sun, 22 Apr 2018 16:09:56 -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.09.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:09:56 -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/18 v2] regulator: arizona-ldo1: Look up a descriptor and pass to the core Date: Mon, 23 Apr 2018 01:07:27 +0200 Message-Id: <20180422230742.3729-3-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, 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 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.14.3 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index f00988705408..5da041edd3b4 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,ldo1ena", 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; }; From patchwork Sun Apr 22 23:07:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133945 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp370467lji; Sun, 22 Apr 2018 16:13:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/fw8F9+06w+17zz4RwfUTjMvGQBlVUyzRqo9zdcZ8qXoUEGgrZBi9cztNSztjifJlVytgt X-Received: by 10.101.101.136 with SMTP id u8mr15638752pgv.333.1524438804020; Sun, 22 Apr 2018 16:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438804; cv=none; d=google.com; s=arc-20160816; b=U3/KQOlfA5+SLWIwztT5S1KGILfsJBBo2f77TSOsfS3Ud4COcKKys5f7CsrY1qyRpE N4shh4IA++FexgH9xzk3YI3lWnpjzXz826KYsEYYkVycrBd4MEMRmBfKJelye5lIFr5V yqb5FreSbc7kIA/1fYEFW+b/T5VhuFJLbjx7qRzT7lgcwZXsNvgS0UEX/GdR7wC4hBX4 szhlMmpcJS9n1BPE0OdrNjkboeS9txHMu7kZx2fesNpPuK3ThArSCISxDnCfoB+KOa2Q O2N8TKkwkUkjeQVa4pgbXf1o+1dxu0JFTm+MURdWqqK5x8jwLn/vq/Q7kAufMMSVfo2h T4bg== 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=KNPDKQdHQ4VwCTuf88fkbPqvezjOX6gJ4Bh0LZDUsh8=; b=WC1rgwf6GPpWrS0JMOf7EsWbeJWYe22pevwWCBatRKUx3V76NVu/VLFgfZLUA7sdw5 eXS0mV/Y12UDuzPwOPIPsyL96+wUcvD5EqDOd9bFcR3X8JvvZkjiIwXJtZoTtxqBVGMF xbfu8pddzSvL9up0PjycyELJe8dGj5iAxU9ekHhlOyQM4Ndro5+LGpPB70NsICMxmzOF vhQOg4qQpaBpkGtvuptV1naZvPPnY++1XLEkIXbSfZIKUAtMpvxKWS+Vh9Tz2AwAAtpa AGsLjAZ1FNhsMsvaTR0Ll9LqLFpTN6FMpSt+7xDpTn3zpEuIlC5Kh7Xg2vGeSLRwMY9h er0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K78qv2j5; 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 90-v6si4474610plc.205.2018.04.22.16.13.23; Sun, 22 Apr 2018 16:13: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=K78qv2j5; 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 S1753946AbeDVXNU (ORCPT + 29 others); Sun, 22 Apr 2018 19:13:20 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36801 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753728AbeDVXKA (ORCPT ); Sun, 22 Apr 2018 19:10:00 -0400 Received: by mail-lf0-f68.google.com with SMTP id d20-v6so12234706lfe.3 for ; Sun, 22 Apr 2018 16:09:59 -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=KNPDKQdHQ4VwCTuf88fkbPqvezjOX6gJ4Bh0LZDUsh8=; b=K78qv2j5zYuh4Itr7Uaa+YW7U+bLS3EuFzbQldOe1EZ1gAx/jfl0LhKxNYWEuYFsO0 f2VYO/1psO5ritQVc6+0GBGR/jGJ4w8OZbj3wZa99Vms/oe7pms94xRHtggTdlON84wq YruwMB59hUTlCtAuyv5VWhilCLe8X5LFy+2/c= 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=KNPDKQdHQ4VwCTuf88fkbPqvezjOX6gJ4Bh0LZDUsh8=; b=eruoUp1Iu/enYwDYDO54Gdj0lphrQiUNE3qaw5ZvgfusWjlC/SyX2cLv8Hy7/9GOX3 60QAmNsmQmtIbDY6l71JJK22ipj7hDWRW0xRqjq+9eqsMTSQolfMACuLO7vWJeOJYR1X kRTBkRmHuumUGch51FxnHt+OiFJ/t7Tj73C/EbJ/8a1KxcIlgws/HYwggcCbPDhkbeHM OmFQiz6nvIllQWic9Zoo2VVFgWNbyDz0kZ84lz70XzD2/H4GgcvSUOUaR4jn3GSAh6ln vJt/EfCZMe6pYdGuCiH50DEUH8cww8QMQEA+5Fr+1KyWVVEma6iVtp5NDb4ApppjCZft BgsA== X-Gm-Message-State: ALQs6tDif7qf4Aodn+W34iSYGNC8+pLXYGD00RlnvuyKpVOu+ndCo0zw Vtmwi7vEmaQZUyDZ9SnOuwTZkA== X-Received: by 2002:a19:8e0c:: with SMTP id q12-v6mr7797255lfd.95.1524438598846; Sun, 22 Apr 2018 16:09:58 -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.09.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:09:58 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Mikko Perttunen , Laxman Dewangan Subject: [PATCH 04/18 v2] regulator: max8973: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:28 +0200 Message-Id: <20180422230742.3729-4-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, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. Cc: Mikko Perttunen Cc: Laxman Dewangan Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max8973-regulator.c | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e0c747aa9f85..7cd493ec6315 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,6 @@ struct max8973_chip { struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; - int enable_gpio; int dvs_gpio; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; @@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( pdata->enable_ext_control = of_property_read_bool(np, "maxim,externally-enable"); - pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); @@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret; pdata = dev_get_platdata(&client->dev); @@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, return -EIO; } - if ((pdata->dvs_gpio == -EPROBE_DEFER) || - (pdata->enable_gpio == -EPROBE_DEFER)) + if (pdata->dvs_gpio == -EPROBE_DEFER) return -EPROBE_DEFER; max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); @@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; - max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->junction_temp_warning = pdata->junction_temp_warning; - if (gpio_is_valid(max->enable_gpio)) - max->enable_external_control = true; - max->lru_index[0] = max->curr_vout_reg; if (gpio_is_valid(max->dvs_gpio)) { @@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, break; } - if (gpio_is_valid(max->enable_gpio)) { - config.ena_gpio_flags = GPIOF_OUT_INIT_LOW; - if (ridata && (ridata->constraints.always_on || - ridata->constraints.boot_on)) - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio = max->enable_gpio; + if (ridata && (ridata->constraints.always_on || + ridata->constraints.boot_on)) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) { + config.ena_gpiod = gpiod; + max->enable_external_control = true; } + break; case MAX77621: - if (gpio_is_valid(max->enable_gpio)) { - ret = devm_gpio_request_one(&client->dev, - max->enable_gpio, GPIOF_OUT_INIT_HIGH, - "max8973-en-gpio"); - if (ret) { - dev_err(&client->dev, - "gpio_request for gpio %d failed: %d\n", - max->enable_gpio, ret); - return ret; - } - } + /* + * We do not let the core switch this regulator on/off, + * we just leave it on. + */ + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + max->enable_external_control = true; max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_mask = MAX8973_VOUT_ENABLE; From patchwork Sun Apr 22 23:07:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133944 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp370242lji; Sun, 22 Apr 2018 16:13:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5BbKKc7cNIG5CIduAW++ojuozC2mB6zSAw/vrHYlH98jZWDWA7ZYa48FmCMRVoYH4szJZ X-Received: by 10.99.99.133 with SMTP id x127mr15062167pgb.50.1524438785260; Sun, 22 Apr 2018 16:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438785; cv=none; d=google.com; s=arc-20160816; b=zlwcIqPy+wUtfXIftdDHqCfzRmQQQgpIgHmJ9xDZCfpCesg86LaeBxwXXdPNgGet5+ jlgLGz8jwhvlDa+gV7ej1exXfVYxHMki/mDLMlHjJGNEzzWt+3CBZ/5/ZaWftcDgwMWy uk4aZosTKP95vlhABSQ5rKrJK1MfWwFJ5vBUU204+p1Kt65DYlcNTvN45eVJDEZNsu5y Vfy+KYvoh5ILnNzrjLgtTuFg6LeKrXqYdull/AABaNkyC9X9IFL43oBHTzpvGSn33LoP 3Es3FarUiskvC6TmNhmuwaqbGzd9mbnP1ZYDS22KbX8J6oZm3bcwFm/LvOKQA/Gv1WXu WZ2A== 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=dn2F8aZQOmoMM3GMvlYfhA/F0xsoRmM3i8KywfDXWEM=; b=wOMGip9zUiz/FLaP+yj1t1Dcju9ur+EPOdui25YpSV0LPc3CTUlsFD45eisz2lMZYr UyB4rAIDvmwBqo2SsPvqKCFI56e9D+0oW6XBsaX3WkwPhYCfSLPaVMax0z58vKh9vbL6 neHe930SZfT4jLuMj7uGHe5m+TNiXM28q+KReq1VEF8GL2ypHxqD30e46OMYDgkWwNAW AHiJSE+HcElz84S7HCAifFUPKnWdjjOsJgmeSQ8C2ItTNk6GoX+2pXeRVQYQuAod4pFK t6tUpk29TTwV7zLjWkRHdlvTBJSkAlkzjGfRbNkhr/g+I+ib5QDfKxSNaPIJx9qfT9b6 efTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ioIesM28; 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 h14-v6si11488160plk.535.2018.04.22.16.13.05; Sun, 22 Apr 2018 16:13:05 -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=ioIesM28; 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 S1753934AbeDVXNC (ORCPT + 29 others); Sun, 22 Apr 2018 19:13:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:37609 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753829AbeDVXKC (ORCPT ); Sun, 22 Apr 2018 19:10:02 -0400 Received: by mail-lf0-f66.google.com with SMTP id b23-v6so12251700lfg.4 for ; Sun, 22 Apr 2018 16:10:01 -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=dn2F8aZQOmoMM3GMvlYfhA/F0xsoRmM3i8KywfDXWEM=; b=ioIesM28G6uNuTELgYqQtHRmcZUt1FnGfa5vqw/OB8YJvhtA/3it0B3+LAsW4tlj6Q aPcTX6NxL15jme1B3D+RdAvyoS+AcElVPBVHAKa9M7kd1/OyVWUm1UE7d5KWa7HVfh7J rMQKhlXhYHtb5KmB8g/6j+tlWTCUTLMgHqjJI= 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=dn2F8aZQOmoMM3GMvlYfhA/F0xsoRmM3i8KywfDXWEM=; b=NxAORGvkp/fGN78llE76KK9SQPbFpudrfxH33a276dvhLF8UnipAZHWVAWjCUs444q 2GSzsf4vHbyFU0g0Y/6nYsYAVuk7DY71mGoUjCVtbmwK6rpOLd03tyqUK67itnVX+eHQ hq1syri6suT+6XEPpAIPj9+cTi4Fhd+XAtWoUm7IjZ/nW2wkzgRGqFD94VEKF6r61Gk9 Pscc8XsevtXZeRpi7KOrjOZWsZ2DRpAcsPNmtOuT2FyGAd7jt+titsws1SvjnXS2Ttex dFHcIqQvh2CKGtpcoqvvXunTsA1tkuq7fKPI89nK0fxpIhzhfxIIqXWi+vCc1M48LKRO f+BQ== X-Gm-Message-State: ALQs6tCpDKyzXQ1dO5/AB2tIRWXrD9el3bvBSWATE3OLRWV3dvxbJNu/ 0jX6MFA35wESzIgvhbfNMEDhOw== X-Received: by 2002:a19:740a:: with SMTP id v10-v6mr7177076lfe.59.1524438600923; Sun, 22 Apr 2018 16:10:00 -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.09.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:00 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 05/18 v2] regulator: max77686: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:29 +0200 Message-Id: <20180422230742.3729-5-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, pass a descriptor looked up from the device tree configuration node. Cc: Chanwoo Choi Cc: Krzysztof Kozlowski Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max77686-regulator.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index c301f3733475..5ebd06f47e6a 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -90,6 +89,7 @@ enum max77686_ramp_rate { }; struct max77686_data { + struct device *dev; DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); /* Array indexed by regulator id */ @@ -269,16 +269,20 @@ static int max77686_of_parse_cb(struct device_node *np, case MAX77686_BUCK8: case MAX77686_BUCK9: case MAX77686_LDO20 ... MAX77686_LDO22: - config->ena_gpio = of_get_named_gpio(np, - "maxim,ena-gpios", 0); - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config->ena_gpio_initialized = true; + config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, + np, + "maxim,ena", + 0, + GPIOD_OUT_HIGH, + "max77686-LDO"); + if (IS_ERR(config->ena_gpiod)) + return PTR_ERR(config->ena_gpiod); break; default: return 0; } - if (gpio_is_valid(config->ena_gpio)) { + if (config->ena_gpiod) { set_bit(desc->id, max77686->gpio_enabled); return regmap_update_bits(config->regmap, desc->enable_reg, @@ -521,6 +525,7 @@ static int max77686_pmic_probe(struct platform_device *pdev) if (!max77686) return -ENOMEM; + max77686->dev = &pdev->dev; config.dev = iodev->dev; config.regmap = iodev->regmap; config.driver_data = max77686; From patchwork Sun Apr 22 23:07:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133931 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368216lji; Sun, 22 Apr 2018 16:10:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ZwV81A+6rTEAFfKJJV7w7uHiJJ2XLqW7Y8A677LT+zxjFsohc/drIrsaUFSeGfe1PL6gj X-Received: by 2002:a17:902:1a6:: with SMTP id b35-v6mr16240587plb.80.1524438614307; Sun, 22 Apr 2018 16:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438614; cv=none; d=google.com; s=arc-20160816; b=XfQMCxYNzVeJn5Sk6MFIjAWdPNkoXqFxgP93DaejXmSmm+DAeB+YZuyxCsIi2+p75X TwG4l3UKTy1+yaJad+Qwp5dbyRgx6mk0WA3Ue0Vontlky1avDAH2/nuCtQh561oE/XQI F+uq2VFkvJCtATe8r/7QZjEIRwPc9Tk88ShPWm1y2flUkKNeMYBMLj+yUZUTuyis+hl1 41yYUc8/a34DUKO2uJ8SXSg//Uh0zuJwJFIqqIqg8Ywli1p6HwqgiE3tW0NxQJKKneJb ymG5gPAU6ygYndNzu8tzRTn5o6reROjY8ePX5H1jzhlKu70Ma0gTE4yWb48bLszDB5JA o5Xw== 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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=Rl+xMwXiPr/HhO42XCQwoYjJXGCKgC0bQPctSgOm8VZ9wa0uyx/LNjCe/MGmj4BcAS EHbJCB9eyZ5VYNXeLSK2+vbS7yLKkWEfwpyc74xKdEfS23P5zpzxywkWJWZ9DqU1cBTg JqXVVw95fbNrxQ6B8TYXGfuG/AnbGTV8mwm0SonbnNtTeqMP/VgjfaeK5ZvOBkGHvmxe 53QMGjHWNNIv/x0we+ht2EC/EchvvUigjRfqXSPOcWr4oxVJfT5qfNCw2+JSIfeW3Mny baAG2/rc9kDl/X+YYdj+olY4vP9CUaeJmEgJzi10KtynOKZtpzd/aPKFpXiibPItIBSx gAJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FyIauxjI; 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 k10si7616465pgs.304.2018.04.22.16.10.14; Sun, 22 Apr 2018 16:10:14 -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=FyIauxjI; 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 S1753878AbeDVXKI (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:08 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38328 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753847AbeDVXKE (ORCPT ); Sun, 22 Apr 2018 19:10:04 -0400 Received: by mail-lf0-f67.google.com with SMTP id z130-v6so12234109lff.5 for ; Sun, 22 Apr 2018 16:10:04 -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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=FyIauxjIHR7t8oHB9HT5OBY2uUw6Seap1Sp3SkK7fUEqO4k9sHtJgQTpnF35SXYhyg 17cyMfC/vcnPvsYrMmB2LbM/3Nh3OMHHN9CuoURiTsD5hXmTmhMarp9jASoE/7gtI9WG wR2iftiMCOuuVlo8fOYvxf1lBd22rG3fBPVGw= 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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=Ja71ZMCxxLopHIdtij17UWPFh4DVGv9N3kSwYvUERNRb6OAJ3wAEARo6LHMgBPTkbS LbaqcBXuHbUGa8ulbBiil6CS6Tpz86zcllS3G+yBmEU5ByNShfKVDpRYgI6TKYCDn6d5 jqls1TyDGKZRjojzF3lYOP++PaNU0BR2g2GcttnxDP2CEA82drGMOuQf/QWzhc2H0yC7 x5DZjOsp2O+pLRPFfpWEMN+UG/PdS2c5XNMrr/lF4WHtD9jANV1RLHP4tJF/o5cYuqTE 1UyMLiQkbNM1zypDSHqsGF+slXW9IZNPYw24uFkSFfK18ssfRIdKUlPcuYAEpdtjGpWk Nn6w== X-Gm-Message-State: ALQs6tDYGCz0F6ZWuNyAxiIjEfaSP59eJiqcSb/TOolAfdjg5oEpZvvn +u7M6wgcen7elXzREVNgks2Udg== X-Received: by 2002:a19:4318:: with SMTP id q24-v6mr7217228lfa.22.1524438603121; Sun, 22 Apr 2018 16:10:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:02 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 06/18 v2] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:30 +0200 Message-Id: <20180422230742.3729-6-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, pass a descriptor looked up with the standard devm_gpiod_get_index_optional() call. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index ce5f7d9ad475..b615a413ca9f 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = { }, }; -static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) +static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id) { /* * Check LCM_EN1/2_GPIO is configured. @@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) */ switch (id) { case LM3632_LDO_POS: - return of_get_named_gpio(np, "enable-gpios", 0); + return devm_gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW); case LM3632_LDO_NEG: - return of_get_named_gpio(np, "enable-gpios", 1); + return devm_gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW); default: - return -EINVAL; + return NULL; } } @@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) struct regulator_dev *rdev; struct device *dev = &pdev->dev; int id = pdev->id; - int ret, ena_gpio; + struct gpio_desc *gpiod; + int ret; cfg.dev = dev; cfg.regmap = regmap; @@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev) * LM3632 LDOs can be controlled by external pin. * Register update is required if the pin is used. */ - ena_gpio = lm363x_regulator_of_get_enable_gpio(dev->of_node, id); - if (gpio_is_valid(ena_gpio)) { - cfg.ena_gpio = ena_gpio; - cfg.ena_gpio_flags = GPIOF_OUT_INIT_LOW; + gpiod = lm363x_regulator_of_get_enable_gpio(dev, id); + if (gpiod) { + cfg.ena_gpiod = gpiod; ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, LM3632_EXT_EN_MASK, From patchwork Sun Apr 22 23:07:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133943 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369790lji; Sun, 22 Apr 2018 16:12:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4844DtCUR8ZHaZ/kjUDkrSlQV6ppk1sxYUnHP12oHyaUGn/2Xhj+onER2lzR5ySYr3nfDvI X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr18222618plp.136.1524438750707; Sun, 22 Apr 2018 16:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438750; cv=none; d=google.com; s=arc-20160816; b=Tv/sYtcuhzFiwczOoqQeDP0rQ2sjWzT4TWhN5lJOqrp2+EQTQBCwCB/7EUXfMrl6aA 4G85ZfAyQy4ZZ7nGnbMxiHlrwEdxCgFP16IAVhwECRHmxecR3tE2sUgfleYQ/VysBa3y ZhMKYY0a8CPtmSp0MqE7O2p8kvzW281bfIez3rme+F0n593N1RVph4BC387HazVm2tuK t6B1Vx3HXDpnUuOHcQ/PVbNsXCOAFjJrlZ5OISBmQpxxQr0EvxwiGWg+35oGUJaAL/yt zMlDxjkT26KMiDhas+Z1bRbpyTtwW/SjAaAVUeOwMkZpTdE8TxCtDVYKV/wMxNwo4zPW BT8w== 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=0dkYm0FyKOuoGNcZrW878Dd5CgLT6V0eE7UMIOGpD9U=; b=aFWbhzraKEtsKG5auSkESP8aZBBEygsug+mdd5G0YO23fZ2xbkKIoWWX75jGIo8v2s X7KsFevV2IuRqxfn2W3Zr0ZosLCJqpF+oPwnfNfMqfdcf17W44ZfpY9mVwk1EEyCw0a2 lB4e5DmYeGpPQKU4JPHHPk7JkNViQdobFdL67gl6o5kaAMhVNAE7XVQ1DXM7MuUs2+Q3 Ou1L2piNGsr1YK615OJpq+RVtMT5Q1z0mGSBJuF0XoaEIY0haEg01NGS9VsQbD5Zhh4n ZDp7Xe58gcNwAhgb7RfvfZ/PMy1MWxUTacpo4T5KU2QS03cOTdMavGP/KBiGys3iIgDB MvrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fvaaiu+T; 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 h14-v6si11488160plk.535.2018.04.22.16.12.30; Sun, 22 Apr 2018 16:12:30 -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=Fvaaiu+T; 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 S1754099AbeDVXMZ (ORCPT + 29 others); Sun, 22 Apr 2018 19:12:25 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45818 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753707AbeDVXKH (ORCPT ); Sun, 22 Apr 2018 19:10:07 -0400 Received: by mail-lf0-f66.google.com with SMTP id q5-v6so12197933lff.12 for ; Sun, 22 Apr 2018 16:10:06 -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=0dkYm0FyKOuoGNcZrW878Dd5CgLT6V0eE7UMIOGpD9U=; b=Fvaaiu+Tn7dH/8N4VbTsiH/vABjT2DzCyL09Kc7pBuEbgmP9pyP/hkNmOlKiX2HYuh 0Zlgf4dyKScB6vaOi0/U7RmDtyLXVWfHm+7MbEpWKeMURMaBZKX5TFQFJmGT0owPDN2Q It3AT0CXp10fyoOF6dSCPPhiRQLEZGDilyzfg= 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=0dkYm0FyKOuoGNcZrW878Dd5CgLT6V0eE7UMIOGpD9U=; b=UBxWZiUhDvF/U7pISLjVObduWkvbJyUOuJJNKa7eYEjZivpx5LCRTpkjWDy/qXvLnI rD2mXeD3ZcdeXQNnc4EvBV9Wz2HNOVGfnF7LzSun1XK6jyk/eqs1wa0hGPdR+DY39BZ1 Xro2xv5eGT2CT5WGH/sL+b6VI5dkyoF1JoT642OHXuVGkIA/6Nr4ShcHh5EV4W7HrFNs vowO4QMIPvWwBKD5befcY4ENBnahgopuhkdTOwQDjNU4bGCYjNerkt/uVKuwVsRxIZQc ykU7XMG5UxKI8n3OSTjia6rdqEg+aqCRi/GmoAsvon+ji5I/RlpBQascvYZjRuOQimcT hSgw== X-Gm-Message-State: ALQs6tCSkryI1zFcjl6TeMTpe8SovXdwnuzzHnT+MR9WfOdnnEpWzmOL V5P91lfViTCbNWtQDJAiwnHrlg== X-Received: by 2002:a19:1d84:: with SMTP id d126-v6mr7744956lfd.100.1524438605446; Sun, 22 Apr 2018 16:10:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:04 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Milo Kim Subject: [PATCH 07/18 v2] regulator: lp8788-ldo: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:31 +0200 Message-Id: <20180422230742.3729-7-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, pass a descriptor looked up with the standard devm_gpiod_get_index_optional() call. This driver has supported passing a LDO enable GPIO for years, yet this facility has never been put to use in the upstream kernel. If someone desires to put in place GPIO control for the LDOs, this can be done by adding a GPIO descriptor table in the MFD nexus in drivers/mfd/lp8788.c for the LDO device when spawning the MFD children, or using a board file. Cc: Milo Kim Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- drivers/regulator/lp8788-ldo.c | 32 ++++++++++++++++---------------- include/linux/mfd/lp8788.h | 16 ---------------- 2 files changed, 16 insertions(+), 32 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index cbfd35873575..f2347474a106 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include /* register address */ @@ -85,8 +85,6 @@ #define LP8788_STARTUP_TIME_S 3 #define ENABLE_TIME_USEC 32 -#define ENABLE GPIOF_OUT_INIT_HIGH -#define DISABLE GPIOF_OUT_INIT_LOW enum lp8788_ldo_id { DLDO1, @@ -117,7 +115,7 @@ struct lp8788_ldo { struct lp8788 *lp; struct regulator_desc *desc; struct regulator_dev *regulator; - struct lp8788_ldo_enable_pin *en_pin; + struct gpio_desc *ena_gpiod; }; /* DLDO 1, 2, 3, 9 voltage table */ @@ -469,7 +467,6 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, enum lp8788_ldo_id id) { struct lp8788 *lp = ldo->lp; - struct lp8788_platform_data *pdata = lp->pdata; enum lp8788_ext_ldo_en_id enable_id; u8 en_mask[] = { [EN_ALDO1] = LP8788_EN_SEL_ALDO1_M, @@ -504,11 +501,18 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, return 0; } - /* if no platform data for ldo pin, then set default enable mode */ - if (!pdata || !pdata->ldo_pin || !pdata->ldo_pin[enable_id]) + /* FIXME: check default mode for GPIO here: high or low? */ + ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev, + "enable", + enable_id, + GPIOD_OUT_HIGH); + if (IS_ERR(ldo->ena_gpiod)) + return PTR_ERR(ldo->ena_gpiod); + + /* if no GPIO for ldo pin, then set default enable mode */ + if (!ldo->ena_gpiod) goto set_default_ldo_enable_mode; - ldo->en_pin = pdata->ldo_pin[enable_id]; return 0; set_default_ldo_enable_mode: @@ -533,10 +537,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL; @@ -582,10 +584,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL; diff --git a/include/linux/mfd/lp8788.h b/include/linux/mfd/lp8788.h index 786bf6679a28..2010e0de3e34 100644 --- a/include/linux/mfd/lp8788.h +++ b/include/linux/mfd/lp8788.h @@ -181,20 +181,6 @@ struct lp8788_buck2_dvs { enum lp8788_dvs_sel vsel; }; -/* - * struct lp8788_ldo_enable_pin - * - * Basically, all LDOs are enabled through the I2C commands. - * But ALDO 1 ~ 5, 7, DLDO 7, 9, 11 can be enabled by external gpio pins. - * - * @gpio : gpio number which is used for enabling ldos - * @init_state : initial gpio state (ex. GPIOF_OUT_INIT_LOW) - */ -struct lp8788_ldo_enable_pin { - int gpio; - int init_state; -}; - /* * struct lp8788_chg_param * @addr : charging control register address (range : 0x11 ~ 0x1C) @@ -288,7 +274,6 @@ struct lp8788_vib_platform_data { * @aldo_data : regulator initial data for analog ldo * @buck1_dvs : gpio configurations for buck1 dvs * @buck2_dvs : gpio configurations for buck2 dvs - * @ldo_pin : gpio configurations for enabling LDOs * @chg_pdata : platform data for charger driver * @alarm_sel : rtc alarm selection (1 or 2) * @bl_pdata : configurable data for backlight driver @@ -306,7 +291,6 @@ struct lp8788_platform_data { struct regulator_init_data *aldo_data[LP8788_NUM_ALDOS]; struct lp8788_buck1_dvs *buck1_dvs; struct lp8788_buck2_dvs *buck2_dvs; - struct lp8788_ldo_enable_pin *ldo_pin[EN_LDOS_MAX]; /* charger */ struct lp8788_charger_platform_data *chg_pdata; From patchwork Sun Apr 22 23:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133933 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368361lji; Sun, 22 Apr 2018 16:10:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49CtxXZKFpBxYtTXfcEK0Er2cPFCnPc+uww9MO34GOKRNd3ymBmOe8NVublgHDGJJrHYuUA X-Received: by 10.101.92.199 with SMTP id b7mr15085547pgt.138.1524438626391; Sun, 22 Apr 2018 16:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438626; cv=none; d=google.com; s=arc-20160816; b=Ai4SrLAaej1pn2d/peTmn6Xp1ZQYl03OOYMpQQji6N+GZUfWY6Got1oPrthedTmjl8 7TapDdwtBxEj+bPQjgyc6G8dVbM0Uvgp9nJae3nCvCOSw1PWT1YzvGTkApX92mhHIH9S +uX7K2Lzy7HOCdqk5MJPq97O8Kw8t6v93j7ndZvTTzIOko3vB4lB+r21jPJhqgfKe4tG FptL5US1W7smeKNi3OU+5w8jHxmHnlLbmneZmtUPtsskic+qKfbtOEaW8KGe5R6St0VT mmgRdAyntewubcUV4ivoQsfgDJJIoAtlHoSWExnL2tAREcwQhBSXLefilp4+fILdCFuY itXw== 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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=TeUO8RHuQmq1qqzcBqnz7Z5mC0RiywPEwyrNjXEGHLjhfVuaoEXEhr0arcnD9PC3ND XjVMkxbCvBTpt0FZ8oIgCbf7uvTLP7tCQ0RFc/4pMdV7l6ppwAK2E3OJ+LgmqJClyE/E wew1CXHecS8gNRXDySIw66zAf5XDw15R8dbJW8P9dqFvmLY9yU40IfJyPXZFyJzZU5lo Hi5k1gbkbWMPh0akMZm/ryMVC+a5/OXK7rF8WziR7HXpVLsn0mCy1xoYpA8P6No2YZKu 5tHnYsHrcM/is19o7S/ntEgnvxnvcSxm5Z46sOhsW3OjAn1j7xuFAP8swNwFePpnOz+d wq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zu+i3/LD; 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.26; Sun, 22 Apr 2018 16:10:26 -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=Zu+i3/LD; 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 S1753918AbeDVXKU (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:20 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45823 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753814AbeDVXKL (ORCPT ); Sun, 22 Apr 2018 19:10:11 -0400 Received: by mail-lf0-f65.google.com with SMTP id q5-v6so12198049lff.12 for ; Sun, 22 Apr 2018 16:10:11 -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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=Zu+i3/LDWJuYIvzki8dCWMUKjrHRSLcB5iZg8+s8ByghsrnB7PUk0QuVtgCk78lC4z xqfhwwfnz/VKU0HCkVZssu1B07oCrXr5RYdoDigB7YxkN99YRcdU+FjbXxW6D13drYYD lc1182x+heAV1EVhzS9DAY5BDmFI3QGV5Qlzw= 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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=MLd2Z7HrYa1k7GoXUW1lxzUOVWeDtW1YQmRFNHcxVsQd9iKkubd7U9yeNDpHLRJ9vc FHS3ul/mAK22PisbR8my8GO+nUgViT6xTF4MzK9fnckgqy5wlxFP7vcr2ewFlCBPorzP sCtbK5Q87XrKVcQzdBWyFJXC+3O3wVKOGG6UIyQjE6xFPohoD3PGSm1T3NP9K/+e5whK mb4MwLrlp6cmO4y8QwKOmfssudeEhvUNp3AAEEtbWGm5kxqxG9C4zB6pj6yUMa/0eOuc jJ71WfSBlkIC20lW1fUuCjwb1l52kOr2NlZNFl8F6JRA4jKB7ReLQFHic3LCdmiZ+can BhoQ== X-Gm-Message-State: ALQs6tA8wWjR0h/EzcIWBzgnJ2omFiuV1AjrBnVb84+0/tRYlXbj3IWA WOR2mzsv8WUyRuVqlBhlRGOssQ== X-Received: by 2002:a19:e583:: with SMTP id i3-v6mr6500123lfk.135.1524438607711; Sun, 22 Apr 2018 16:10:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:06 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 08/18 v2] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:32 +0200 Message-Id: <20180422230742.3729-8-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 with the standard devm_gpiod_get_optional() call. All users of this regulator use device tree so the transition is pretty smooth. Cc: MyungJoo Ham Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max8952.c | 18 +++++++++++++----- include/linux/regulator/max8952.h | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 1096546c05e9..f1e77ed5dfec 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0); pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1); - pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0); if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode)) dev_warn(dev, "Default mode not specified, assuming 0\n"); @@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client, struct regulator_config config = { }; struct max8952_data *max8952; struct regulator_dev *rdev; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret = 0, err = 0; @@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client, config.driver_data = max8952; config.of_node = client->dev.of_node; - config.ena_gpio = pdata->gpio_en; - if (client->dev.of_node) - config.ena_gpio_initialized = true; if (pdata->reg_data->constraints.boot_on) - config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "max8952,en", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + config.ena_gpiod = gpiod; rdev = devm_regulator_register(&client->dev, ®ulator, &config); if (IS_ERR(rdev)) { diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h index 4dbb63a1d4ab..686c42c041b5 100644 --- a/include/linux/regulator/max8952.h +++ b/include/linux/regulator/max8952.h @@ -120,7 +120,6 @@ enum { struct max8952_platform_data { int gpio_vid0; int gpio_vid1; - int gpio_en; u32 default_mode; u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ From patchwork Sun Apr 22 23:07:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133932 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368301lji; Sun, 22 Apr 2018 16:10:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+UqFQEK4XQKbeKV2ne+IBHcx5e2r7opBaSN0K7odGj5AYt6YJBz8NMv0dCDAe72+Qki0EV X-Received: by 10.98.11.144 with SMTP id 16mr17827575pfl.228.1524438621726; Sun, 22 Apr 2018 16:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438621; cv=none; d=google.com; s=arc-20160816; b=dgKR5UP+SFUnp3PDcysPJAdbBW0G1UYeeAdQsL9Zov+ybDTUOc5wB49jp7871gV8GA uOYasIQBLVTHWTWAVLBWxadZywU+k22GX9fqQtj/t7zC8/KdY6YUi7J/JRxH9cf6ESj9 mEqmfVojryCppwb6+UHKwnMudselOEV4FGIAGLx578JWOdz3io/6+R0V6f7jfgVC0eOa s98Nd8CLWjdW01JEYKQQynONpff5TT/Cl2nfVkc9fKTfBocB4bPgWmt3yv0tkeXztffh fark7YCvWnkNqf3ijVgfvKdWEf0oUqAd5OnneDfJP13c1wE9TdA1JFGhSoiyxnZwYIiC JAWA== 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=nqpo6sX0t8t7ihlPS/9UTfM9SxmT7RqdKY9o7uxx9gE=; b=SYAKXt0ozoaf8XBEFw0JyFBaKX9iiC5tBsSdiHmbn9qIETWNH1MiJSbt4oEhMbzuqY 8QWHPy4L354I6atVFeTaseg5g5erCA3qXxM2t4p293BZQL81F0hBBuxJuq65dOuTud23 4VEDOU1oho7zR1joBdtLxTtKs1CxHqZk2ENkFCfUwY3mxyyyHwp6eASezCH7FGkAXgYa p9yRlMVpAV9ZhLGSA4dKoGnB++zKiBIT2VbADFLQTpG93TCnY/ytUY3PutZ2X1iXh3PV eztlD0NDW/QffSKTdc0E4dDgVLuM9EMBPXefbWXdKQPoXeu8Y5xm/YJRUVfXYxOYo9SA Wl5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rk3y/rOj; 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 o11si8856604pgc.274.2018.04.22.16.10.21; Sun, 22 Apr 2018 16:10:21 -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=Rk3y/rOj; 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 S1753895AbeDVXKS (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:18 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36814 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753847AbeDVXKM (ORCPT ); Sun, 22 Apr 2018 19:10:12 -0400 Received: by mail-lf0-f65.google.com with SMTP id d20-v6so12235058lfe.3 for ; Sun, 22 Apr 2018 16:10:12 -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=nqpo6sX0t8t7ihlPS/9UTfM9SxmT7RqdKY9o7uxx9gE=; b=Rk3y/rOjwur19w7Rd757YdKsfFBRqnksKUwhZ5jv9RvtV7m+pdfFejbdqZ2iTAwFlx ryRTFZhCI+lKyw6/FwjxjmybQoA0y20qUs08J5A4w9YTAIu7N+PWrGh44KQZePlfusip 0lnGQks7ALoaCUWKl9iERnlgPqTCFQ8UOmpfg= 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=nqpo6sX0t8t7ihlPS/9UTfM9SxmT7RqdKY9o7uxx9gE=; b=eU1ryAQaLt4LGDHXpqm52bx/cH18rXvhcsu4HkjwPU63Yl5ezMdSHO+S2LoN8/us2/ 7zq3TaMxDIqlXyoEARmf62oXf/Ia45VF0Jz264+cCNDsTBBNG4QdIlGHZfUu2wTAlhlk QrtKZvquOqUWWJTGXtGDY+Z3muTv8jlF0WEcKcD3kXG8HKDGj6+Tom7dBsenoSujuTE4 WK/6YyxpJb9UuO4UicWYaicM6KkLsKQ+SY9pwotPUIj01C6OIyJZUJ8JxylSD29yEHEP qX9iMFnsb3meR0YpVvA9JBVPZ2MjUj+J+I+ieSdjkCUEcjEK/AMZHPBflmmb7TvR2uzp QtYA== X-Gm-Message-State: ALQs6tDrRtUjFyYrHQySTnG4V8ZyQXMSgbWIwNddNE3mdinJyxMBsBw8 dMCJdxbMLG3kYhrCSxkoWCl5SQ== X-Received: by 10.46.144.3 with SMTP id h3mr11576568ljg.37.1524438611435; Sun, 22 Apr 2018 16:10:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:10 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 09/18 v2] regulator: pfuze100: Delete reference to ena_gpio Date: Mon, 23 Apr 2018 01:07:33 +0200 Message-Id: <20180422230742.3729-9-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 We now pass a GPIO descriptor to the core instead of a global GPIO number, if this descriptor is NULL the GPIO line is not used. Just delete the assignment of an invalid GPIO line. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/pfuze100-regulator.c | 1 - 1 file changed, 1 deletion(-) -- 2.14.3 diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index 63922a2167e5..f341d9614a77 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -648,7 +648,6 @@ static int pfuze100_regulator_probe(struct i2c_client *client, config.init_data = init_data; config.driver_data = pfuze_chip; config.of_node = match_of_node(i); - config.ena_gpio = -EINVAL; pfuze_chip->regulators[i] = devm_regulator_register(&client->dev, desc, &config); From patchwork Sun Apr 22 23:07: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: 133942 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369731lji; Sun, 22 Apr 2018 16:12:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx48u1TyhQrMapIndF83HXCwhO2PAk/nAi3ymoPR39ATruOJsJtZPOp3xds7wPgMnDdH5ZmSU X-Received: by 2002:a17:902:6949:: with SMTP id k9-v6mr18720877plt.185.1524438745916; Sun, 22 Apr 2018 16:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438745; cv=none; d=google.com; s=arc-20160816; b=SzlUELrCmCPAfG4xj+Nix5Znpco9sVJOcOfq/V+Udq9XZHT908ue/WOkYLXjlwmHmG duxXWGAEC3H+sm4UDUTk4cJ9ZNe1DC/cGuh5tE/TnImTBWb6pAyj1lBLGrFIWXK16v5/ 85a0AVRg4R+wOHAqTb7X3j3smWhx49zCu/F+GOX3jIYb03UcmF+g30Yx8VwCtxB0fBIM rn+FsYZAQEMant1kWsn56wxsb7s59nY2NGb9DyTSjDgVAIpjwZxKFCYTKh8BbAilve0O nydxSIwuo5853TAOMI+QnWyX4mXRrRtpzqonwKvTy2bY3/OBOMsShu53/MFfAFAU6hRD kJAg== 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=tN46b+PIlX6JV9YDrsfa5XYiO1hDgRnlEjZQQ5YAsoU=; b=EFXt5pdDunC714cBSL/XUrM0vGBgwMj9XUNegze+k1dcSaaPzKhovTb48FSmaLIMxg cvixMY78y3kg40xDKtUEsBnOdvESUSxbn5uel+iQYvs5DdsP1V423yIFFjBwaFHqioGi CySIkDDgW8hFdLMtYX6Bo3ur4vMbBbw3vYB6WcJp7d872idTzWc7QLM57/CSclDlqeyl 3zSwLnqoMF1qWMvgH5WqXpfGNFCzBhUr7AFyI3xqZ7IRCjOdXsHFy790l+teVcNgXH85 4OJVo+rDc1guNHj1Hh2GU3Hg/h9I9lNQtuEs9DhRSWdcZ53N86RhE4CMYkTcH8sqKZzS iaSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aQ8t60ey; 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 f85si648938pfj.125.2018.04.22.16.12.25; Sun, 22 Apr 2018 16:12:25 -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=aQ8t60ey; 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 S1754080AbeDVXMX (ORCPT + 29 others); Sun, 22 Apr 2018 19:12:23 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43747 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655AbeDVXKP (ORCPT ); Sun, 22 Apr 2018 19:10:15 -0400 Received: by mail-lf0-f66.google.com with SMTP id v207-v6so12174857lfa.10 for ; Sun, 22 Apr 2018 16:10:14 -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=tN46b+PIlX6JV9YDrsfa5XYiO1hDgRnlEjZQQ5YAsoU=; b=aQ8t60eyZ6/5ellA+sP8J6h0Qb/eEP1UUfw6+297lf/qM40TbUMnj6elHaA+uLDYrl OHHxZt75bTMGrcsHZVWYGc6ISZ4+u9CB8OmaBgaiQE13ZW/O04iG6Wfys9m0ONe3IUlh juh/TS1XO62mWOhPX8KM58IHIFb+wZxHqJDos= 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=tN46b+PIlX6JV9YDrsfa5XYiO1hDgRnlEjZQQ5YAsoU=; b=MuLQ2OXRzqvBbHa7XUwXDJZY4vlEKhdUGpJTvdN9EbwpZeQybxRAWGriyHmD+NG/+M PYFn8r7m+GfKQ6/HIke8mA0qauIK16VotLcGwdWZUA44qYDH4c6bfH7s6IPtt82ujZKH 9KXoKrELgofrIK5YFo5SE2JhE48K3AOY6dStnKM13A2SYS8o2y8l/Bz1V764NV0gqrmM 1828OoFFpiwuym9AIjr7mIcr3Rb/81TDdrVSdP6RFGCD+MouxWoZakzq+SbXedytTnaf ADdrnjqttlsIS0nN+Cwxo8x4NOeHsgSR3sXA9dRX2dfjgy/SSYoo9X90fczaPM/em5qz 8gig== X-Gm-Message-State: ALQs6tAFwsIQOHCNphwKhzqa48y+s+z2SrqTQSwaf94/qIte38Ho+ohC bhRG8VpAw1VQ+abVCV82PX7+Qg== X-Received: by 10.46.136.139 with SMTP id k11mr3459602lji.54.1524438613853; Sun, 22 Apr 2018 16:10:13 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:13 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Krzysztof Kozlowski , Sangbeom Kim , Chanwoo Choi Subject: [PATCH 10/18 v2] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:34 +0200 Message-Id: <20180422230742.3729-10-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 with the standard devm_gpiod_get_optional() call. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Chanwoo Choi Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.14.3 Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..9a1dca26362e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ struct s2mps11_info { * Array (size: number of regulators) with GPIO-s for external * sleep control. */ - int *ext_control_gpio; + struct gpio_desc **ext_control_gpiod; }; static int get_ramp_delay(int ramp_delay) @@ -524,7 +523,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) case S2MPS14X: if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) val = S2MPS14_ENABLE_SUSPEND; - else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) + else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -818,7 +817,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) { - int *gpio = s2mps11->ext_control_gpio; + struct gpio_desc **gpio = s2mps11->ext_control_gpiod; unsigned int i; unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, S2MPS14_LDO12 }; @@ -829,11 +828,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = of_get_named_gpio(rdata[reg].of_node, - "samsung,ext-control-gpios", 0); - if (gpio_is_valid(gpio[reg])) - dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", - gpio[reg], reg, rdata[reg].name); + gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, + rdata[reg].of_node, + "samsung,ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s2mps11-LDO"); + if (IS_ERR(gpio[reg])) { + dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n", + reg, rdata[reg].name); + continue; + } + if (gpio[reg]) + dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n", + reg, rdata[reg].name); } } @@ -1139,17 +1147,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, - sizeof(*s2mps11->ext_control_gpio) * rdev_num, + s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpiod) * rdev_num, GFP_KERNEL); - if (!s2mps11->ext_control_gpio) + if (!s2mps11->ext_control_gpiod) return -ENOMEM; - /* - * 0 is a valid GPIO so initialize all GPIO-s to negative value - * to indicate that external control won't be used for this regulator. - */ - for (i = 0; i < rdev_num; i++) - s2mps11->ext_control_gpio[i] = -EINVAL; if (!iodev->dev->of_node) { if (iodev->pdata) { @@ -1179,8 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio_initialized = true; for (i = 0; i < rdev_num; i++) { struct regulator_dev *regulator; @@ -1191,7 +1191,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].init_data; config.of_node = rdata[i].of_node; } - config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpiod = s2mps11->ext_control_gpiod[i]; regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); @@ -1202,7 +1202,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) goto out; } - if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { + if (s2mps11->ext_control_gpiod[i]) { ret = s2mps14_pmic_enable_ext_control(s2mps11, regulator); if (ret < 0) { From patchwork Sun Apr 22 23:07:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133941 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369558lji; Sun, 22 Apr 2018 16:12:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx483Vguu0fivGywbdaii6epOi6bNGKuyq50ykzDefjUDsjIlVXmkuJion/g6kcQq2WCJOqRi X-Received: by 10.101.96.150 with SMTP id t22mr15281782pgu.4.1524438727995; Sun, 22 Apr 2018 16:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438727; cv=none; d=google.com; s=arc-20160816; b=eJyMZpbD6dbiyNI+dzJU6Hgpfc8uh2F3upe5q/dBg7lCjqbZOY1MsZx4sku7PC1bGK KooKWmsUIwe63x9Ie8UcmmDcdqSX4FrCul6Qpj8vMpC0wJNNmjMeg45gUOo3ZNg9okCt GfZHkWapaBM8VKQFrMDUFmaxjX3qKZm+74wj9NvodmHrg/IPsN4FPz+WFjp4qdvVL/cj LAvWSKf9IFwGzs5qjO/NS1e0uRYtt1VSMKj0BUGBExi919B9SCtnWCcAFpcoQrXcICRl PldyFLn1V7jmeEuonSs/CCvpBtjYziNNNxWMJreuuoM3kP0OUC4Y/yx/bAs1vScFPOl0 GaSQ== 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=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=O2TxGWIn/i7Ne4ndcU6jwh9V95xsCPdH+K8JIiC2y/QdORRN1dHxx63xIU9zUwjBCu i4vNrT21Ku77Bwg/cEhsLHh/Fozwbq33Vfwb2MVN8wESseDkeZIQYfVYp1TkZlEpCWfA pn2wgHMbii+qW+PbE3cSAfhOfpla3h4KMeC85bhm/+o2dloJW2Vd5sp+sMu9JoonBuWL xvB0LmMQCGcgwSPV8SgD5M1lP+jei3q4RevssOb7evBIUgdE3wY+6UjNPuBAiE7sf8zr tO02VS/yBg8LpJa2La76REQc32LXhvRRodoFOrNOastbdkyZ+fEekMBGJ2duAxYYjd74 RB9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RBHgT7n8; 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 f85si648938pfj.125.2018.04.22.16.12.07; Sun, 22 Apr 2018 16:12:07 -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=RBHgT7n8; 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 S1754072AbeDVXMF (ORCPT + 29 others); Sun, 22 Apr 2018 19:12:05 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40614 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbeDVXKR (ORCPT ); Sun, 22 Apr 2018 19:10:17 -0400 Received: by mail-lf0-f68.google.com with SMTP id i18-v6so12225352lfc.7 for ; Sun, 22 Apr 2018 16:10:16 -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=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=RBHgT7n8QjKAwUXiG1HRZTZuSJm6+eCAWu7Qve8bvGpJ2XrmBumWjca0JGbpjZ6VZX eU47GGe3S+hbzC3mxbNV2jRBgRm+yaJ57cOBhwgCkN3onuY4xDHHHQctyTbE+2fFr9RI mtm/FjXUSjflsA/xrY9AKtxmF6q/yDM4eqtQI= 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=OElT/XvsVFQuIyM5xH7gxjLfxNrMI7NMY0aShcgBDD8=; b=WL3qfhw7XGLn6daKkvapra24H8B2VkEm8jd1/vMeVhoPupxaZys+AbV0M++EOZuDlH T1y9GWUHKZWXbt62lXxOTlgLBpy8YchbNCJC2bzbDZOKF+6h200zpPrWjiA5UjSi7qht +GMUQETrE/5fQe+vTNaSnWvWyPQ93DXE38NfuPnSzrqb1hBeUXdF8jW2vCsEEejxy7GW lCmlDEfTvZlUN4dQNtRGtRASS19cex3Ri8YakiXHdRuUh8uCsmfB1LqnfOgm0TMDCJUR Muw516ujSOhvvdb9P/GmFvOQCidBcsdOXUI0U59IAn5tE3wNmLFWOCJfgLmRAWIAuhI1 d8bA== X-Gm-Message-State: ALQs6tDGC4cGZb4xy9J/p4HJyvtt+haSn0RgVO8thwjJqR7uiwKaoE+7 pFyOd0g6I/ozEWpWInksiA4qaw== X-Received: by 10.46.154.205 with SMTP id p13mr5625333ljj.60.1524438615784; Sun, 22 Apr 2018 16:10:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:15 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 11/18 v2] regulator: s5m8767: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:35 +0200 Message-Id: <20180422230742.3729-11-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 for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes - Collect Lee's ACK. --- drivers/regulator/s5m8767.c | 26 +++++++++++++++----------- include/linux/mfd/samsung/core.h | 4 +++- 2 files changed, 18 insertions(+), 12 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 4836947e1521..b8443a360646 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, return; } - if (!gpio_is_valid(rdata->ext_control_gpio)) { + if (!rdata->ext_control_gpiod) { dev_warn(s5m8767->dev, "ext-control for %s: GPIO not valid, ignoring\n", - rdata->reg_node->name); + rdata->reg_node->name); return; } - config->ena_gpio = rdata->ext_control_gpio; - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config->ena_gpiod = rdata->ext_control_gpiod; } /* @@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, continue; } - rdata->ext_control_gpio = of_get_named_gpio(reg_np, - "s5m8767,pmic-ext-control-gpios", 0); + rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + reg_np, + "s5m8767,pmic-ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s5m8767"); + if (IS_ERR(rdata->ext_control_gpiod)) + return PTR_ERR(rdata->ext_control_gpiod); rdata->id = i; rdata->initdata = of_get_regulator_init_data( @@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.driver_data = s5m8767; config.regmap = iodev->regmap_pmic; config.of_node = pdata->regulators[i].reg_node; - config.ena_gpio = -EINVAL; - config.ena_gpio_flags = 0; - config.ena_gpio_initialized = true; - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) + config.ena_gpiod = NULL; + if (pdata->regulators[i].ext_control_gpiod) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); @@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return ret; } - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { + if (pdata->regulators[i].ext_control_gpiod) { ret = s5m8767_enable_ext_control(s5m8767, rdev); if (ret < 0) { dev_err(s5m8767->dev, diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 5a23dd4df432..28f4ae76271d 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -39,6 +39,8 @@ #define STEP_12_5_MV 12500 #define STEP_6_25_MV 6250 +struct gpio_desc; + enum sec_device_type { S5M8751X, S5M8763X, @@ -151,7 +153,7 @@ struct sec_regulator_data { int id; struct regulator_init_data *initdata; struct device_node *reg_node; - int ext_control_gpio; + struct gpio_desc *ext_control_gpiod; }; /* From patchwork Sun Apr 22 23:07:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133940 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369421lji; Sun, 22 Apr 2018 16:11:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Xp4Qoh3de6fxjY4wW1npTi6UcFUziKh6qC4d1yp1XpALtxqPi/gzFaylTL5cbKW/I8jKW X-Received: by 10.98.133.15 with SMTP id u15mr17728629pfd.160.1524438713734; Sun, 22 Apr 2018 16:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438713; cv=none; d=google.com; s=arc-20160816; b=JXeMrVwGXJPoNgL9ATz81qSwIYnOyJ1GnSgz/8rvnKKkWnd3faYR+vjbybb208UjEd ZcXCZxGK46k1ULVODJwLWIz4e0B6Xp93CRW5akbqaksCHp1C6Oh2MgiCuLM1gmxxDcBK +s8dKbDYksFGLzY/MTasOHCQcJr6sfh9Sakj8LshRENF9fQnU4cpJ6GkncG4uWymqV75 d8e2bXflLhcsRFssVCNTDaNUVJIXgABfFwdpqvzFMVTLpe7k5g6b3hSF4p3K0wrRNNVu b1JbkU5NXtKwbPa6djHKlBs7ayl1I1GfhIVNBrIvp1brWr2glq/7ZxKMABwSAsljkqSU 2e2Q== 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=4tsKjEB3Uq++ewbri23rjtwYKlpf+kEYJmA1qq2FZVk=; b=TBAk+8APh0uRUnoGXhkDnJJFztiCJO2CqPl5dlqWu67VnG//F7S656vEK+u5o9YnFg pF4l5HOZxE46aalia5+3g3qAphXyy4yPit+K6nGKBD8AITN6o2WcSZ/JisJboCpgmoH2 cL60H8jxALfInt1D/rpY8uyY2xodF4OCsYOHQogxAPyfsD112I4NtPDSDppCZhVjJ5X8 EN1M+i93NgHW/O2UJdC0rfcqr87NYwMqsX+bhcfR70LlZskRt8eFNE1zhxIn8R3NvVyb el785Jpq8Eu9PecVOQiAwa3/+3zWrHmqnVb2Ya+6LiHRk6dXkDX7VBUuQ6QyqJZRnYyO I2Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O3IqNGQD; 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 y7-v6si10569375plh.583.2018.04.22.16.11.53; Sun, 22 Apr 2018 16:11:53 -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=O3IqNGQD; 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 S1754046AbeDVXLv (ORCPT + 29 others); Sun, 22 Apr 2018 19:11:51 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39873 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753898AbeDVXKT (ORCPT ); Sun, 22 Apr 2018 19:10:19 -0400 Received: by mail-lf0-f66.google.com with SMTP id p142-v6so12222640lfd.6 for ; Sun, 22 Apr 2018 16:10:18 -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=4tsKjEB3Uq++ewbri23rjtwYKlpf+kEYJmA1qq2FZVk=; b=O3IqNGQDQzBzvh8lFl/YdkiM5dCbRXun01lfw/ujK2eUtATp+IsKJg8dntVmZZoYIk HklIdzVXmfEk6gVo8eIZmS+ESibQEnv06EmOKjE9NkQkOOG64LxQOitkYP4830DXfYoW QTvcPjIjvRm9m4Yz5E8to7z6HnT9s0g4H89EA= 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=4tsKjEB3Uq++ewbri23rjtwYKlpf+kEYJmA1qq2FZVk=; b=oDNDxjjiDMnU2R1P+dsxL7+56j6MA1tYynUtfRTcleutgXulg3TAq06qwgg2Ckz5yV bBHtH0t0GEt72B858m0kJTmQEz7z+zne3R1trmKe/esFrNUaCgAa2gD16sEwcfpUZ52q OQDVNFvYr7v1M/gRtoitJoR8qtezNc1TSeHJA0B5cGpM9f22MLK3f1TliVQEVNscgCi2 ztdGFr6K0kCMKB6fuA8cBVUcQbGcd/u0o8VkTovwKuJNobsB1kaf23N/80bQwLutcOaH Mhbi3fmqrS3+Fbh93gCp9RwfsDn6uXuQCKYDzxAU4TvBusXtRP5fkmydBQ7WZuewVFLm NHsA== X-Gm-Message-State: ALQs6tA3AfiIEYQ/synYwVCp1BiS9QTK6oJAjlyAwcnipMsCk/nMFii+ 72Ip9KpaqpPCDz6NQtxX4q/Ynw== X-Received: by 10.46.144.69 with SMTP id n5mr7776548ljg.109.1524438617829; Sun, 22 Apr 2018 16:10:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:17 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 12/18 v2] regulator: tps65090: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:36 +0200 Message-Id: <20180422230742.3729-12-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 for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- drivers/regulator/tps65090-regulator.c | 50 ++++++++++++++++------------------ include/linux/mfd/tps65090.h | 8 ++++-- 2 files changed, 28 insertions(+), 30 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 395f35dc8cdb..2d398fa3b720 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -300,26 +300,6 @@ static int tps65090_regulator_disable_ext_control( return tps65090_config_ext_control(ri, false); } -static void tps65090_configure_regulator_config( - struct tps65090_regulator_plat_data *tps_pdata, - struct regulator_config *config) -{ - if (gpio_is_valid(tps_pdata->gpio)) { - int gpio_flag = GPIOF_OUT_INIT_LOW; - - if (tps_pdata->reg_init_data->constraints.always_on || - tps_pdata->reg_init_data->constraints.boot_on) - gpio_flag = GPIOF_OUT_INIT_HIGH; - - config->ena_gpio = tps_pdata->gpio; - config->ena_gpio_initialized = true; - config->ena_gpio_flags = gpio_flag; - } else { - config->ena_gpio = -EINVAL; - config->ena_gpio_initialized = false; - } -} - #ifdef CONFIG_OF static struct of_regulator_match tps65090_matches[] = { { .name = "dcdc1", }, @@ -385,9 +365,26 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( rpdata->enable_ext_control = of_property_read_bool( tps65090_matches[idx].of_node, "ti,enable-ext-control"); - if (rpdata->enable_ext_control) - rpdata->gpio = of_get_named_gpio(np, - "dcdc-ext-control-gpios", 0); + if (rpdata->enable_ext_control) { + enum gpiod_flags gflags; + + if (ri_data->constraints.always_on || + ri_data->constraints.boot_on) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + + rpdata->gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + tps65090_matches[idx].of_node, + "dcdc-ext-control-gpios", 0, + gflags, + "tps65090"); + if (IS_ERR(rpdata->gpiod)) + return ERR_CAST(rpdata->gpiod); + if (!rpdata->gpiod) + dev_err(&pdev->dev, + "could not find DCDC external control GPIO\n"); + } if (of_property_read_u32(tps65090_matches[idx].of_node, "ti,overcurrent-wait", @@ -455,8 +452,7 @@ static int tps65090_regulator_probe(struct platform_device *pdev) */ if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data) { if (tps_pdata->enable_ext_control) { - tps65090_configure_regulator_config( - tps_pdata, &config); + config.ena_gpiod = tps_pdata->gpiod; ri->desc->ops = &tps65090_ext_control_ops; } else { ret = tps65090_regulator_disable_ext_control( diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h index 67d144b3b8f9..f05bf4a146e2 100644 --- a/include/linux/mfd/tps65090.h +++ b/include/linux/mfd/tps65090.h @@ -83,6 +83,8 @@ enum { #define TPS65090_MAX_REG TPS65090_REG_AD_OUT2 #define TPS65090_NUM_REGS (TPS65090_MAX_REG + 1) +struct gpio_desc; + struct tps65090 { struct device *dev; struct regmap *rmap; @@ -95,8 +97,8 @@ struct tps65090 { * @reg_init_data: The regulator init data. * @enable_ext_control: Enable extrenal control or not. Only available for * DCDC1, DCDC2 and DCDC3. - * @gpio: Gpio number if external control is enabled and controlled through - * gpio. + * @gpiod: Gpio descriptor if external control is enabled and controlled through + * gpio * @overcurrent_wait_valid: True if the overcurrent_wait should be applied. * @overcurrent_wait: Value to set as the overcurrent wait time. This is the * actual bitfield value, not a time in ms (valid value are 0 - 3). @@ -104,7 +106,7 @@ struct tps65090 { struct tps65090_regulator_plat_data { struct regulator_init_data *reg_init_data; bool enable_ext_control; - int gpio; + struct gpio_desc *gpiod; bool overcurrent_wait_valid; int overcurrent_wait; }; 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; }; From patchwork Sun Apr 22 23:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133939 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369185lji; Sun, 22 Apr 2018 16:11:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+X9hOpQ4Q6y9bVdIl+pLPJpYeI3+qyijE1Dh5SGuK+SCcTiJplC+JPUhU6T7+MUoPnF5HH X-Received: by 2002:a17:902:2468:: with SMTP id m37-v6mr19066759plg.388.1524438693767; Sun, 22 Apr 2018 16:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438693; cv=none; d=google.com; s=arc-20160816; b=d+0r/lbrV3SaBQnPgEvDSYWPP9SN2cEWjsWPrNTZyESVy+q61MxwpT6AzgvdqKO779 S9OVY5zvMK93o1urxfKE6IbKuCL/BLHVXv7bsbSlKYXJk+j+jRPG4Us6zz98VMTTg/yb 42XRhp++RhsPk9Jj+Gsc9xeduyN9q5Utf3b3E2yDnHaluetUcs2TjoojFB4rNRe4gpb7 LxrcF4+3xTy3Mwp67zPhpo9k0xHnyPOZHxr/sDlNP/QOHYZIwbFz6FIs6iPw179TOqYN OjpyLiBNhYdoMFWBhdL4UAGhciTK6MdeScSaNpwZCtFWP2eXkmkz2gRYxArVnyNUE8KU OdBg== 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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=M6YwfkEsZRjIXs4el/vSFHlSvvjhYWJ4STF97PwqRs6oF6SCjV2t5BY5BIqHu8LupA 3OknMsvHvEwUot20l9A8QqN/PFmDzLr6PPMlYkyz9cEMmzj3ex/v/pt71zclvQbKpbdP skxddsSiCrmtDk/ySGYYMEb9HjIkTGZz8h2bKtTWCpUwAG+T1VaLcF8utOK2oXeNG3Jn /fGn8jjQwJtEmlTLp57o8YeuYIFUqKukkdYjQTD2Woj2NPJFJgOUoAQKdustwW90MAla NLmBfor9oYvRxjxf9WifTBOJ3d6tAid4K8KkIWR3JewsSII/9lK14M8DO7E34sT9Iwyt 57YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8FAmtSN; 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 y7-v6si10569375plh.583.2018.04.22.16.11.33; Sun, 22 Apr 2018 16:11:33 -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=V8FAmtSN; 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 S1754037AbeDVXLb (ORCPT + 29 others); Sun, 22 Apr 2018 19:11:31 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35072 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753814AbeDVXKX (ORCPT ); Sun, 22 Apr 2018 19:10:23 -0400 Received: by mail-lf0-f68.google.com with SMTP id r125-v6so12231950lfe.2 for ; Sun, 22 Apr 2018 16:10:22 -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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=V8FAmtSNTg3dCo8ij24qzvaX2aqn1Sa4/06eHQ8VPx656KCDMgbfXzqo79o/NdVgCi rgxe1Tv1L7Q3NoQruaf2OKDn1qwupe8XFka3bXG+GyXOB2M31dCXHwEL0ypzwt0hy/nO UCULjnEckwdIwvRsQmOic1DDZ7R1hr3ikAn7g= 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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=E2s7cJSKwja9ULEj7IJOteI31nGRtB7uNKys8eGuZcXtz6JkGMGFQgrsIDSw89NSvu JGVSu+7NGvvU1juc/pHT1xruiNga5PDJBlk66QjGLoXAOZQdhcP3AoD1KmSl9BVdWiG+ 5PDxuRpqSt+YPSbcpz2NRrFsR+wOqfJpATXTS16/UhjC2oyG1/eMf0mjSfbPZd8Lvr3o kbZp01TiJWBj9jIc1jYlSCsnya3LpO7S6IsxdQRt1rR8sCLzNAVIPRcSXz9ommMAu2/A 4alRP4aqfAMZ8C+V2dMGj/FVBO/EuTjOXwM3Cr64WDSzSrHpKU6bCYpV+Kmn5hMLfK57 nrdQ== X-Gm-Message-State: ALQs6tDSIrAG2CNVAoGP9V07QuX82UnS+YHf6+cn08Camsqza3RtZeZ2 LYCGsxN0D97LifbtBU9nIWhULA== X-Received: by 2002:a19:4e4a:: with SMTP id c71-v6mr7816508lfb.42.1524438622054; Sun, 22 Apr 2018 16:10:22 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:21 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 14/18 v2] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 23 Apr 2018 01:07:38 +0200 Message-Id: <20180422230742.3729-14-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 Now that we changed all providers to pass descriptors into the core for enable GPIOs instead of a global GPIO number, delete the support for passing GPIO numbers in, and we get a cleanup and size reduction in the core, and from a GPIO point of view we use the modern, cleaner interface. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 10 +--------- 2 files changed, 7 insertions(+), 35 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d4803460a557..8d56f9b906b0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -1935,35 +1934,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, { struct regulator_enable_gpio *pin; struct gpio_desc *gpiod; - int ret; - if (config->ena_gpiod) - gpiod = config->ena_gpiod; - else - gpiod = gpio_to_desc(config->ena_gpio); + gpiod = config->ena_gpiod; list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { if (pin->gpiod == gpiod) { - rdev_dbg(rdev, "GPIO %d is already used\n", - config->ena_gpio); + rdev_dbg(rdev, "GPIO is already used\n"); goto update_ena_gpio_to_rdev; } } - if (!config->ena_gpiod) { - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); - if (ret) - return ret; - } - pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL); - if (pin == NULL) { - if (!config->ena_gpiod) - gpio_free(config->ena_gpio); + if (pin == NULL) return -ENOMEM; - } pin->gpiod = gpiod; pin->ena_gpio_invert = config->ena_gpio_invert; @@ -1987,7 +1970,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) if (pin->gpiod == rdev->ena_pin->gpiod) { if (pin->request_count <= 1) { pin->request_count = 0; - gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); rdev->ena_pin = NULL; @@ -4160,15 +4142,13 @@ regulator_register(const struct regulator_desc *regulator_desc, goto clean; } - if (config->ena_gpiod || - ((config->ena_gpio || config->ena_gpio_initialized) && - gpio_is_valid(config->ena_gpio))) { + if (config->ena_gpiod) { mutex_lock(®ulator_list_mutex); ret = regulator_ena_gpio_request(rdev, config); mutex_unlock(®ulator_list_mutex); if (ret != 0) { - rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", - config->ena_gpio, ret); + rdev_err(rdev, "Failed to request enable GPIO: %d\n", + ret); goto clean; } } diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4fc96cb8e5d7..8900c230c899 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -384,13 +384,8 @@ struct regulator_desc { * NULL). * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is * insufficient. - * @ena_gpio_initialized: GPIO controlling regulator enable was properly - * initialized, meaning that >= 0 is a valid gpio - * identifier and < 0 is a non existent gpio. - * @ena_gpio: GPIO controlling regulator enable. - * @ena_gpiod: GPIO descriptor controlling regulator enable. + * @ena_gpiod: GPIO controlling regulator enable. * @ena_gpio_invert: Sense for GPIO enable control. - * @ena_gpio_flags: Flags to use when calling gpio_request_one() */ struct regulator_config { struct device *dev; @@ -399,11 +394,8 @@ struct regulator_config { struct device_node *of_node; struct regmap *regmap; - bool ena_gpio_initialized; - int ena_gpio; struct gpio_desc *ena_gpiod; unsigned int ena_gpio_invert:1; - unsigned int ena_gpio_flags; }; /* From patchwork Sun Apr 22 23:07:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133936 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368502lji; Sun, 22 Apr 2018 16:10:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx48PGei1zYJAW1pE5ULRWrNu48QiKowLADRIc9/yXs3z50XUcMwLJX6WQuaCVmF0gqovYogX X-Received: by 10.101.92.77 with SMTP id v13mr4929231pgr.428.1524438636834; Sun, 22 Apr 2018 16:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438636; cv=none; d=google.com; s=arc-20160816; b=ZDFwMUmnQoB8QZIIpbMK4RPuSA8RwONZH+6f9NZulvPGJo00B08wDnnATmKBXFKrml pvgGjTcB3YsX+a6zhPzj3AVLw3A/370ysa+Y8j0SNaE6HImLOIgzaiKaRrsTh7JT+kK7 LCl0vUoiBiLqK6LzOGFJQ7gRvgGO9C+yb3wQRb90yMLievbq/K/wiDm1z6044xVotgm0 +FH1hSiXBeBvX/pGxZi/hCRaggEQiXeDiO3Ab2lkph99ksxh8Lwk/78sRhUVm4nn9UXt bQMWiKXRZYH3pqBudKk5fdgAH/GBSfalUFR0PKWrzYQ3yit4Cg3Vng3YumJLICIZY6H7 gbkQ== 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=7lu/rWwGQbKb7bVzPwXI5PyKD/rOyTNHgO3o59dLuQA=; b=PV4cOOOz2D4WrLskMiYZvLmTXUAufkVqRDhDk+cNSxsBAu+mXbfHct8YrA6pv4hI2n EiATlcyoC8gnohqG5urDd4ch6TyY3gD38Kg4NbEio6IzvrB8C+KTa8xpuAyCtdWOVq8P qhCcbsKoqv3Xf2JkeQ0iehv8tA8MqCq9MhT323+Rk0TqJTxF0fPoyQEHmZl38l6j21oG 2vMso1FAZt/13361In8n9uVggQhwZVAuxCTXNptm7QZ3xRL9t6lsBQqi2KPxffbzAwQr 1Y9cLHt6Z0afM1lWSuv3v7LPDVxzuhO9tZlSbOtDM5UX/ALriGOEEBMFt3y7hjWMfr6+ hB4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pv1nMVEx; 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 p15si9001536pgf.358.2018.04.22.16.10.36; Sun, 22 Apr 2018 16:10:36 -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=Pv1nMVEx; 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 S1753962AbeDVXKe (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:34 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37633 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbeDVXK0 (ORCPT ); Sun, 22 Apr 2018 19:10:26 -0400 Received: by mail-lf0-f67.google.com with SMTP id b23-v6so12252294lfg.4 for ; Sun, 22 Apr 2018 16:10:25 -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=7lu/rWwGQbKb7bVzPwXI5PyKD/rOyTNHgO3o59dLuQA=; b=Pv1nMVExba1jNsS4YM99uwsNZTLSet3wxYgo6/uDjn1fIY42BlXPgArZxc2UX5fTNs v+1AxnjxH3AZmSBHFjAhSH1USi74AnL7XP98vwoZxhhUNRu45SzH2exrx/zyR1MUaOGD Bu7JHCuvOQ3XfMBdN6MLgsnSvgYfjo4sfwxhA= 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=7lu/rWwGQbKb7bVzPwXI5PyKD/rOyTNHgO3o59dLuQA=; b=PKqnDn4wX/KLdb5X/aayQt7AEDc1PTYI+OmNGEPslW1401+4+x/g6yrcAw6tn4LPgU fJuieFWMf/V+nTQSywQCPTPuhq667x9JNRvOmji3eQvXkSaMeGX+8l3ipmSXvZaylplz xOYIZbwCFfxsxUJc+D4CcrnlKTGZkJQv3EchCnkCk+TNtUabOpmZM+7o3qXLhlxFjS2G l6TntbJS5I5z/IFx1OZrS6qKhWYESO6fBAUwdWavJ/iq2e826A5HdAP6+L8Y0Gz/NuD4 NcYMpVhdFCvkjiSRA4xhvZ2+Do2aIkPxDy9LilrfX4C6IB5GtR8Te5OPMbZKEns0ldf+ yTmQ== X-Gm-Message-State: ALQs6tALxC0CPorCKhZWbUz1rnDxURNr1ROuFSxO9cSWpNIRfve1XZam uzaUaj5gzuuEV11vjvgtDCSiQg== X-Received: by 2002:a19:59c5:: with SMTP id n188-v6mr7221616lfb.53.1524438624318; Sun, 22 Apr 2018 16:10:24 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:23 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Daniel Mack , Marc Zyngier , Geert Uytterhoeven , Russell King Subject: [PATCH 15/18 v2] regulator: fixed/gpio: Pull inversion/OD into gpiolib Date: Mon, 23 Apr 2018 01:07:39 +0200 Message-Id: <20180422230742.3729-15-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 This pushes the handling of inversion semantics and open drain settings to the GPIO descriptor and gpiolib. All affected board files are also augmented. This is especiallt nice since we don't have to have any confusing flags passed around to the left and right littering the fixed and GPIO regulator drivers and the regulator core. It is all just very straight-forward: the core asks the GPIO line to be asserted or deasserted and gpiolib deals with the rest depending on how the platform is configured: if the line is active low, it deals with that, if the line is open drain, it deals with that too. Cc: Alexander Shiyan # i.MX boards user Cc: Haojian Zhuang # MMP2 maintainer Cc: Aaro Koskinen # OMAP1 maintainer Cc: Tony Lindgren # OMAP1,2,3 maintainer Cc: Mike Rapoport # EM-X270 maintainer Cc: Robert Jarzmik # EZX maintainer Cc: Philipp Zabel # Magician maintainer Cc: Daniel Mack # Raumfeld maintainer Cc: Marc Zyngier # Zeus maintainer Cc: Geert Uytterhoeven # SuperH pinctrl/GPIO maintainer Cc: Russell King # SA1100 Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch series - Cover the new user added in sa1100 --- arch/arm/mach-imx/mach-mx21ads.c | 1 - arch/arm/mach-imx/mach-mx27ads.c | 2 +- arch/arm/mach-mmp/brownstone.c | 1 - arch/arm/mach-omap1/board-ams-delta.c | 1 - arch/arm/mach-omap2/pdata-quirks.c | 1 - arch/arm/mach-pxa/em-x270.c | 1 - arch/arm/mach-pxa/ezx.c | 3 +-- arch/arm/mach-pxa/hx4700.c | 3 +-- arch/arm/mach-pxa/magician.c | 3 +-- arch/arm/mach-pxa/raumfeld.c | 1 - arch/arm/mach-pxa/zeus.c | 3 +-- arch/arm/mach-sa1100/assabet.c | 1 - arch/sh/boards/mach-ecovec24/setup.c | 2 -- .../intel-mid/device_libs/platform_bcm43xx.c | 1 - drivers/regulator/core.c | 8 ++---- drivers/regulator/da9055-regulator.c | 1 - drivers/regulator/fixed.c | 30 ++++++---------------- drivers/regulator/gpio-regulator.c | 24 +++++++---------- include/linux/regulator/fixed.h | 10 -------- include/linux/regulator/gpio-regulator.h | 3 --- 20 files changed, 24 insertions(+), 76 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 5d3b6b4fe6db..8c4a4920468a 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -205,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { .supply_name = "LCD", .microvolts = 3300000, - .enable_high = 1, .init_data = &mx21ads_lcd_regulator_init_data, }; diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c index 0fdb88db0cbd..08a7e217b9e6 100644 --- a/arch/arm/mach-imx/mach-mx27ads.c +++ b/arch/arm/mach-imx/mach-mx27ads.c @@ -237,7 +237,7 @@ static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ .table = { - GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index 563b5a278d65..502343b32c7f 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -149,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = { static struct fixed_voltage_config brownstone_v_5vp = { .supply_name = "v_5vp", .microvolts = 5000000, - .enable_high = 1, .enabled_at_boot = 1, .init_data = &brownstone_v_5vp_data, }; diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 759fa18f6ab4..22e94da4af85 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -275,7 +275,6 @@ static struct fixed_voltage_config modem_nreset_config = { .supply_name = "modem_nreset", .microvolts = 3300000, .startup_delay = 25000, - .enable_high = 1, .enabled_at_boot = 1, .init_data = &modem_nreset_data, }; diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 7d1447204fb8..1c740c7e7c55 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -332,7 +332,6 @@ static struct fixed_voltage_config pandora_vwlan = { .supply_name = "vwlan", .microvolts = 1800000, /* 1.8V */ .startup_delay = 50000, /* 50ms */ - .enable_high = 1, .init_data = &pandora_vmmc3, }; diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 6d7d93981098..8d9ec158f118 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -987,7 +987,6 @@ static struct fixed_voltage_config camera_dummy_config = { .supply_name = "camera_vdd", .input_supply = "vcc cam", .microvolts = 2800000, - .enable_high = 0, .init_data = &camera_dummy_initdata, }; diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c index 2b4bd6d94855..13ebdfd697cc 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -714,7 +714,6 @@ static struct regulator_init_data camera_regulator_initdata = { static struct fixed_voltage_config camera_regulator_config = { .supply_name = "camera_vdd", .microvolts = 2800000, - .enable_high = 0, .init_data = &camera_regulator_initdata, }; @@ -730,7 +729,7 @@ static struct gpiod_lookup_table camera_supply_gpiod_table = { .dev_id = "reg-fixed-voltage.1", .table = { GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, - "enable", GPIO_ACTIVE_HIGH), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 6717a10180eb..05148016c620 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -712,7 +712,6 @@ static struct gpio_regulator_state bq24022_states[] = { static struct gpio_regulator_config bq24022_info = { .supply_name = "bq24022", - .enable_high = 0, .enabled_at_boot = 0, .gpios = bq24022_gpios, @@ -737,7 +736,7 @@ 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), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 9a5bda3ea194..fab63c52d50e 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_high = 0, .enabled_at_boot = 1, .gpios = bq24022_gpios, @@ -682,7 +681,7 @@ 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), + "enable", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index ee766e4ebddc..30ea27b85bb0 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -886,7 +886,6 @@ static struct regulator_init_data audio_va_initdata = { static struct fixed_voltage_config audio_va_config = { .supply_name = "audio_va", .microvolts = 5000000, - .enable_high = 1, .enabled_at_boot = 0, .init_data = &audio_va_initdata, }; diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index 58e05afcece0..428c2db6818a 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -426,7 +426,7 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = { .dev_id = "reg-fixed-voltage.0", .table = { GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, - "enable", GPIO_ACTIVE_HIGH), + "enable", GPIO_ACTIVE_LOW), { }, }, }; @@ -547,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = { static struct fixed_voltage_config zeus_ohci_regulator_config = { .supply_name = "vbus2", .microvolts = 5000000, /* 5.0V */ - .enable_high = 1, .startup_delay = 0, .init_data = &zeus_ohci_regulator_data, }; diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index dbb53c520165..705196a4b66f 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -468,7 +468,6 @@ static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = { static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { .supply_name = "cf-power", .microvolts = 3300000, - .enable_high = 1, }; static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index c296b5c399b7..6b9542616447 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -633,7 +633,6 @@ static struct regulator_init_data cn12_power_init_data = { static struct fixed_voltage_config cn12_power_info = { .supply_name = "CN12 SD/MMC Vdd", .microvolts = 3300000, - .enable_high = 1, .init_data = &cn12_power_init_data, }; @@ -674,7 +673,6 @@ static struct regulator_init_data sdhi0_power_init_data = { static struct fixed_voltage_config sdhi0_power_info = { .supply_name = "CN11 SD/MMC Vdd", .microvolts = 3300000, - .enable_high = 1, .init_data = &sdhi0_power_init_data, }; diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c index fc77d69e51d7..8a579aad0b27 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c @@ -44,7 +44,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { */ .microvolts = 2000000, /* 1.8V */ .startup_delay = 250 * 1000, /* 250ms */ - .enable_high = 1, /* active high */ .enabled_at_boot = 0, /* disabled at boot */ .init_data = &bcm43xx_vmmc_data, }; diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8d56f9b906b0..f3050eaa0a7e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -79,7 +79,6 @@ struct regulator_enable_gpio { struct gpio_desc *gpiod; u32 enable_count; /* a number of enabled shared GPIO */ u32 request_count; /* a number of requested shared GPIO */ - unsigned int ena_gpio_invert:1; }; /* @@ -1949,7 +1948,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, return -ENOMEM; pin->gpiod = gpiod; - pin->ena_gpio_invert = config->ena_gpio_invert; list_add(&pin->list, ®ulator_ena_gpio_list); update_ena_gpio_to_rdev: @@ -1999,8 +1997,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) if (enable) { /* Enable GPIO at initial use */ if (pin->enable_count == 0) - gpiod_set_value_cansleep(pin->gpiod, - !pin->ena_gpio_invert); + gpiod_set_value_cansleep(pin->gpiod, 1); pin->enable_count++; } else { @@ -2011,8 +2008,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) /* Disable GPIO if not used */ if (pin->enable_count <= 1) { - gpiod_set_value_cansleep(pin->gpiod, - pin->ena_gpio_invert); + gpiod_set_value_cansleep(pin->gpiod, 0); pin->enable_count = 0; } } diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index f40c3b8644ae..1a384258d0e5 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c @@ -457,7 +457,6 @@ static int da9055_gpio_init(struct da9055_regulator *regulator, int gpio_mux = pdata->gpio_ren[id]; config->ena_gpiod = pdata->ena_gpiods[id]; - config->ena_gpio_invert = 1; /* * GPI pin is muxed with regulator to control the diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 1142f195529b..8c479cdb69a9 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -79,10 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - config->enable_high = of_property_read_bool(np, "enable-active-high"); - config->gpio_is_open_drain = of_property_read_bool(np, - "gpio-open-drain"); - if (of_find_property(np, "vin-supply", NULL)) config->input_supply = "vin"; @@ -146,24 +142,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - cfg.ena_gpio_invert = !config->enable_high; - if (config->enabled_at_boot) { - if (config->enable_high) - gflags = GPIOD_OUT_HIGH; - else - gflags = GPIOD_OUT_LOW; - } else { - if (config->enable_high) - gflags = GPIOD_OUT_LOW; - else - gflags = GPIOD_OUT_HIGH; - } - if (config->gpio_is_open_drain) { - if (gflags == GPIOD_OUT_HIGH) - gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; - else - gflags = GPIOD_OUT_LOW_OPEN_DRAIN; - } + /* + * The signal will be inverted by the GPIO core if flagged so in the + * decriptor. + */ + if (config->enabled_at_boot) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); if (IS_ERR(cfg.ena_gpiod)) diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 9d6094c4d71c..16ef08406739 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -154,9 +154,6 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, config->supply_name = config->init_data->constraints.name; - if (of_property_read_bool(np, "enable-active-high")) - config->enable_high = true; - if (of_property_read_bool(np, "enable-at-boot")) config->enabled_at_boot = true; @@ -338,18 +335,15 @@ static int gpio_regulator_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = np; - cfg.ena_gpio_invert = !config->enable_high; - if (config->enabled_at_boot) { - if (config->enable_high) - gflags = GPIOD_OUT_HIGH; - else - gflags = GPIOD_OUT_LOW; - } else { - if (config->enable_high) - gflags = GPIOD_OUT_LOW; - else - gflags = GPIOD_OUT_HIGH; - } + /* + * The signal will be inverted by the GPIO core if flagged so in the + * decriptor. + */ + if (config->enabled_at_boot) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags); if (IS_ERR(cfg.ena_gpiod)) { ret = PTR_ERR(cfg.ena_gpiod); diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 1a4340ed8e2b..f10140da7145 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h @@ -25,14 +25,6 @@ struct regulator_init_data; * @input_supply: Name of the input regulator supply * @microvolts: Output voltage of regulator * @startup_delay: Start-up time in microseconds - * @gpio_is_open_drain: Gpio pin is open drain or normal type. - * If it is open drain type then HIGH will be set - * through PULL-UP with setting gpio as input - * and low will be set as gpio-output with driven - * to low. For non-open-drain case, the gpio will - * will be in output and drive to low/high accordingly. - * @enable_high: Polarity of enable GPIO - * 1 = Active high, 0 = Active low * @enabled_at_boot: Whether regulator has been enabled at * boot or not. 1 = Yes, 0 = No * This is used to keep the regulator at @@ -48,8 +40,6 @@ struct fixed_voltage_config { const char *input_supply; int microvolts; unsigned startup_delay; - unsigned gpio_is_open_drain:1; - unsigned enable_high:1; unsigned enabled_at_boot:1; struct regulator_init_data *init_data; }; diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h index 536cab86f2d5..4f3cc1a73ade 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_high: Polarity of enable GPIO - * 1 = Active high, 0 = Active low * @enabled_at_boot: Whether regulator has been enabled at * boot or not. 1 = Yes, 0 = No * This is used to keep the regulator at @@ -67,7 +65,6 @@ struct gpio_regulator_state { struct gpio_regulator_config { const char *supply_name; - unsigned enable_high:1; unsigned enabled_at_boot:1; unsigned startup_delay; From patchwork Sun Apr 22 23:07:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133937 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368715lji; Sun, 22 Apr 2018 16:10:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+8POw2XuGCpv2VDf6NVXKbL8tdxIAgvTHYyelcHVlL2MI/F8FOXUPSPhuu/R7IyCkUELtw X-Received: by 10.98.253.22 with SMTP id p22mr17925550pfh.217.1524438652238; Sun, 22 Apr 2018 16:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438652; cv=none; d=google.com; s=arc-20160816; b=Ua1sHtm/g5EGchkrnth/dbEuQevoQHCngI9G2fyLXEhDKNeAZV7YU4VrxM+7oQ4kOQ mZbs+7hcMewDA06tdy2Ta2wQOGJAMvG7+FTqGjB1oWznWyOpz+b9W9iN5dDcBPvri4is gM/i5D9/j4svtrlryRdDFNT+/4MfKkNR6XD0MIf/buagM53H0eJwzdgM/EvhZw9FF1Vv qDTI/Wh+6zCz9xZJI+FpgZgU82heW/HWAnjIxEKp4eeDCEf7XSkRkKIqO7gwvi61BteD Sz8Dc85OBNJgWXVMIAk16ueONCGlGGaIrbrL0SdPQEZaMN6TC0RDOxflkNM5Z7+14IT6 W76w== 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=9XYGdbr6clUbvOk2Xb7BzXhl9ru0Mz5q7iqnkwHudi0=; b=XlWk1nj+L2/P0EtltGOVJxWUDWLw4ZUx0piBkaKCIRg65tZv2J7MZym2gp63eZpZdS 1hBo8LUB5xhZ1S1eRb30dXDzpVPQqM9nTz+jZKb9A1nBUxoAW5hwdrLkpNz2KV+V6Sqa 2BsG1G2Gn1vH9D22P1svRKGHr8tFB5H2upuwSDrVA+qGSqZk3G/eNovaDL+rSQ0qctpe 9VAPtD6QYpvXR1VWLelNuTx6wHvWNIzVj7/5BRdVx+Juqt0PlI2UaNo3iCPkBrOPjHz1 gIuGHNUWOMT8NxJgdCWxBIGlrj4uTeqrLNhxHIQn/c4yZcaocZO8BdKK5ymGGkgnOQSl X5oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=II6Q5LN7; 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 r129si10270705pfc.202.2018.04.22.16.10.51; Sun, 22 Apr 2018 16:10:52 -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=II6Q5LN7; 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 S1753994AbeDVXKt (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:49 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45840 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753942AbeDVXKa (ORCPT ); Sun, 22 Apr 2018 19:10:30 -0400 Received: by mail-lf0-f67.google.com with SMTP id q5-v6so12198561lff.12 for ; Sun, 22 Apr 2018 16:10:29 -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=9XYGdbr6clUbvOk2Xb7BzXhl9ru0Mz5q7iqnkwHudi0=; b=II6Q5LN78bIbMuVLAw0soh/FWTCNabTtEq3HBGa8pK+c4FVZ1MzvlXYhJjtxtiinbY zNZDOSg63arjFbQyAn4N1i2mTbzoHWcsIdvYgO0I0JNsSRBXUufVkcbA7cdNYypM+a5B 7CNGfp8ROT4MqNOGwiGqVgDRF08jTly2q145M= 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=9XYGdbr6clUbvOk2Xb7BzXhl9ru0Mz5q7iqnkwHudi0=; b=BwouVYPDf/JEHOVAi4n5nZAHdB/+ZeZKOmpk5UnNC7WEhWZiviHnNtW7f+NHCIrx0h 9KaKrugLxTMAaTtTx429SpQiQCsMJahZrGBmMbhgoUuvDjnpq7zBq2+cSoU9/r6qV6fD eExHErOisTNxL/RYh6vbfTQBc0KteaCg0B7NmiCnOOojQFyXgWLkr8TkanQBpbHT5uii QsruGRIZRsaprVOqAN0GSx5Q2VnA+V2a2dQN9+H643Uf6RINAaHcIYm2qEF82NifSgVs cKOxCXSmViaPT3wykEcsiNyTvyz5+/IfAi+i/iHLs9mCUQmBSnt6CW4NPF4OMsbjfV3x 0tdg== X-Gm-Message-State: ALQs6tDYxuN00AY8bB4B0nIEGPoCPVjzET58HRE1SbedKHoXBylR9E4F pyuji/T/Bi69Bb6t8iU9TZ9FEQ== X-Received: by 2002:a19:2a08:: with SMTP id f8-v6mr7171376lfl.84.1524438628317; Sun, 22 Apr 2018 16:10:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:27 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 17/18 v2] regulator: gpio: Convert to fully use descriptors Date: Mon, 23 Apr 2018 01:07:41 +0200 Message-Id: <20180422230742.3729-17-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 This converts the GPIO regulator driver to use decriptors only. We have to let go of the array gpio handling: the fetched descriptors are handled individually anyway, and the array retrieveal function does not make it possible to retrieve each GPIO descriptor with unique flags. Instead get them one by one. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- arch/arm/mach-pxa/hx4700.c | 10 +-- arch/arm/mach-pxa/magician.c | 11 +-- drivers/regulator/gpio-regulator.c | 113 +++++++++++-------------------- include/linux/regulator/gpio-regulator.h | 12 ++-- 4 files changed, 56 insertions(+), 90 deletions(-) -- 2.14.3 diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 05148016c620..24ba230340d8 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -700,9 +700,7 @@ static struct regulator_init_data bq24022_init_data = { .consumer_supplies = bq24022_consumers, }; -static struct gpio bq24022_gpios[] = { - { GPIO96_HX4700_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, -}; +static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW }; static struct gpio_regulator_state bq24022_states[] = { { .value = 100000, .gpios = (0 << 0) }, @@ -714,8 +712,8 @@ static struct gpio_regulator_config bq24022_info = { .enabled_at_boot = 0, - .gpios = bq24022_gpios, - .nr_gpios = ARRAY_SIZE(bq24022_gpios), + .gflags = bq24022_gpiod_gflags, + .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags), .states = bq24022_states, .nr_states = ARRAY_SIZE(bq24022_states), @@ -735,6 +733,8 @@ static struct platform_device bq24022 = { static struct gpiod_lookup_table bq24022_gpiod_table = { .dev_id = "gpio-regulator", .table = { + GPIO_LOOKUP("gpio-pxa", GPIO96_HX4700_BQ24022_ISET2, + NULL, GPIO_ACTIVE_HIGH), GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN, "enable", GPIO_ACTIVE_LOW), { }, diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index fab63c52d50e..5d21de79135b 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -645,9 +645,8 @@ static struct regulator_init_data bq24022_init_data = { .consumer_supplies = bq24022_consumers, }; -static struct gpio bq24022_gpios[] = { - { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, -}; + +static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW }; static struct gpio_regulator_state bq24022_states[] = { { .value = 100000, .gpios = (0 << 0) }, @@ -659,8 +658,8 @@ static struct gpio_regulator_config bq24022_info = { .enabled_at_boot = 1, - .gpios = bq24022_gpios, - .nr_gpios = ARRAY_SIZE(bq24022_gpios), + .gflags = bq24022_gpiod_gflags, + .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags), .states = bq24022_states, .nr_states = ARRAY_SIZE(bq24022_states), @@ -680,6 +679,8 @@ static struct platform_device bq24022 = { static struct gpiod_lookup_table bq24022_gpiod_table = { .dev_id = "gpio-regulator", .table = { + GPIO_LOOKUP("gpio-pxa", EGPIO_MAGICIAN_BQ24022_ISET2, + NULL, GPIO_ACTIVE_HIGH), GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, "enable", GPIO_ACTIVE_LOW), { }, diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 16ef08406739..756b7b50ffba 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -30,17 +30,15 @@ #include #include #include -#include #include #include #include -#include struct gpio_regulator_data { struct regulator_desc desc; struct regulator_dev *dev; - struct gpio *gpios; + struct gpio_desc **gpiods; int nr_gpios; struct gpio_regulator_state *states; @@ -83,7 +81,7 @@ static int gpio_regulator_set_voltage(struct regulator_dev *dev, for (ptr = 0; ptr < data->nr_gpios; ptr++) { state = (target & (1 << ptr)) >> ptr; - gpio_set_value_cansleep(data->gpios[ptr].gpio, state); + gpiod_set_value_cansleep(data->gpiods[ptr], state); } data->state = target; @@ -120,7 +118,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev, for (ptr = 0; ptr < data->nr_gpios; ptr++) { state = (target & (1 << ptr)) >> ptr; - gpio_set_value_cansleep(data->gpios[ptr].gpio, state); + gpiod_set_value_cansleep(data->gpiods[ptr], state); } data->state = target; @@ -139,7 +137,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, { struct gpio_regulator_config *config; const char *regtype; - int proplen, gpio, i; + int proplen, i; + int ngpios; int ret; config = devm_kzalloc(dev, @@ -159,47 +158,31 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - /* Fetch GPIOs. - optional property*/ - ret = of_gpio_count(np); - if ((ret < 0) && (ret != -ENOENT)) - return ERR_PTR(ret); - - if (ret > 0) { - config->nr_gpios = ret; - config->gpios = devm_kzalloc(dev, - sizeof(struct gpio) * config->nr_gpios, - GFP_KERNEL); - if (!config->gpios) + /* Fetch GPIO init levels */ + ngpios = gpiod_count(dev, NULL); + if (ngpios > 0) { + config->gflags = devm_kzalloc(dev, + sizeof(enum gpiod_flags) + * ngpios, + GFP_KERNEL); + if (!config->gflags) return ERR_PTR(-ENOMEM); - proplen = of_property_count_u32_elems(np, "gpios-states"); - /* optional property */ - if (proplen < 0) - proplen = 0; + for (i = 0; i < ngpios; i++) { + u32 val; - if (proplen > 0 && proplen != config->nr_gpios) { - dev_warn(dev, "gpios <-> gpios-states mismatch\n"); - proplen = 0; - } + ret = of_property_read_u32_index(np, "gpios-states", i, + &val); - for (i = 0; i < config->nr_gpios; i++) { - gpio = of_get_named_gpio(np, "gpios", i); - if (gpio < 0) { - if (gpio != -ENOENT) - return ERR_PTR(gpio); - break; - } - config->gpios[i].gpio = gpio; - config->gpios[i].label = config->supply_name; - if (proplen > 0) { - of_property_read_u32_index(np, "gpios-states", - i, &ret); - if (ret) - config->gpios[i].flags = - GPIOF_OUT_INIT_HIGH; - } + /* Default to high per specification */ + if (ret) + config->gflags[i] = GPIOD_OUT_HIGH; + else + config->gflags[i] = + val ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; } } + config->ngpios = ngpios; /* Fetch states. */ proplen = of_property_count_u32_elems(np, "states"); @@ -250,7 +233,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) struct gpio_regulator_data *drvdata; struct regulator_config cfg = { }; enum gpiod_flags gflags; - int ptr, ret, state; + int ptr, ret, state, i; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); @@ -264,33 +247,22 @@ static int gpio_regulator_probe(struct platform_device *pdev) return PTR_ERR(config); } + for (i = 0; i < config->ngpios; i++) { + drvdata->gpiods[i] = devm_gpiod_get_index(&pdev->dev, + config->supply_name, + i, + config->gflags[i]); + if (IS_ERR(drvdata->gpiods[i])) + return PTR_ERR(drvdata->gpiods[i]); + } + drvdata->nr_gpios = config->ngpios; + drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); if (drvdata->desc.name == NULL) { dev_err(&pdev->dev, "Failed to allocate supply name\n"); return -ENOMEM; } - if (config->nr_gpios != 0) { - drvdata->gpios = kmemdup(config->gpios, - config->nr_gpios * sizeof(struct gpio), - GFP_KERNEL); - if (drvdata->gpios == NULL) { - dev_err(&pdev->dev, "Failed to allocate gpio data\n"); - ret = -ENOMEM; - goto err_name; - } - - drvdata->nr_gpios = config->nr_gpios; - ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, - "Could not obtain regulator setting GPIOs: %d\n", - ret); - goto err_memgpio; - } - } - drvdata->states = kmemdup(config->states, config->nr_states * sizeof(struct gpio_regulator_state), @@ -298,7 +270,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) if (drvdata->states == NULL) { dev_err(&pdev->dev, "Failed to allocate state data\n"); ret = -ENOMEM; - goto err_stategpio; + goto err_name; } drvdata->nr_states = config->nr_states; @@ -325,7 +297,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) /* build initial state from gpio init data. */ state = 0; for (ptr = 0; ptr < drvdata->nr_gpios; ptr++) { - if (config->gpios[ptr].flags & GPIOF_OUT_INIT_HIGH) + if (config->gflags[ptr] == GPIOD_OUT_HIGH) state |= (1 << ptr); } drvdata->state = state; @@ -347,7 +319,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) 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; + goto err_memstate; } drvdata->dev = regulator_register(&drvdata->desc, &cfg); @@ -363,10 +335,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) err_memstate: kfree(drvdata->states); -err_stategpio: - gpio_free_array(drvdata->gpios, drvdata->nr_gpios); -err_memgpio: - kfree(drvdata->gpios); err_name: kfree(drvdata->desc.name); return ret; @@ -377,12 +345,7 @@ static int gpio_regulator_remove(struct platform_device *pdev) struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); regulator_unregister(drvdata->dev); - - gpio_free_array(drvdata->gpios, drvdata->nr_gpios); - kfree(drvdata->states); - kfree(drvdata->gpios); - kfree(drvdata->desc.name); return 0; diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h index 4f3cc1a73ade..11cd6375215d 100644 --- a/include/linux/regulator/gpio-regulator.h +++ b/include/linux/regulator/gpio-regulator.h @@ -21,6 +21,8 @@ #ifndef __REGULATOR_GPIO_H #define __REGULATOR_GPIO_H +#include + struct regulator_init_data; enum regulator_type; @@ -49,9 +51,9 @@ struct gpio_regulator_state { * This is used to keep the regulator at * the default state * @startup_delay: Start-up time in microseconds - * @gpios: Array containing the gpios needed to control - * the setting of the regulator - * @nr_gpios: Number of gpios + * @gflags: Array of GPIO configuration flags for initial + * states + * @ngpios: Number of GPIOs and configurations available * @states: Array of gpio_regulator_state entries describing * the gpio state for specific voltages * @nr_states: Number of states available @@ -68,8 +70,8 @@ struct gpio_regulator_config { unsigned enabled_at_boot:1; unsigned startup_delay; - struct gpio *gpios; - int nr_gpios; + enum gpiod_flags *gflags; + int ngpios; struct gpio_regulator_state *states; int nr_states; From patchwork Sun Apr 22 23:07:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133938 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368999lji; Sun, 22 Apr 2018 16:11:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Vyyr5WrN+Bfj1Atei/1k0g3VLfaVM9B4Qv6QilXzyBIo7vWORhr2RUHRkAfdl7/u7kFIW X-Received: by 10.99.160.106 with SMTP id u42mr14736163pgn.389.1524438677952; Sun, 22 Apr 2018 16:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438677; cv=none; d=google.com; s=arc-20160816; b=xAuKvDN4itQt92vGqeLomXk6PvBZzF6UEKvk8/TvLJtUpaz0upxjCkHJAS1oqSGuC8 c6F/zQZ1S6fLXorLvYgqXGVfqfvPiJpIldymh2y4YYQDOvCiACxdyzVPl3goVtmDUhXu YxFa9qBdOlHfwzQjTJ0byz8y4YMy/gdPg3pd3RGcu+uJXAnNX3jq4iwlOoNmZqydBWcc vBsUBEToXtOSvYUFr/LdMYn2yBUcqTEUmlNIRBQzoP1uUvuaVOZSaaq2qLOK6uLPMl+X fcb0aUxarnt3vTSdfkNnRcO//PBdgVd8jvFPLtNuZXrLyD5VCL3cB2N8RIw6GdAHvWsO kFcw== 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=QEw14JMUgGrqO20JULTN0mCeOahs6b8QHm5uQv/Q7zU=; b=W7ipARgaIRTa6KfaYgdHfl1ystt3ldXfbP5NqIZsltZATd1tzddiNEG7ySx7mjQsql E0Do7zSn9nmsZWO4IXowIjwPdpVhQEbFzMsyhtryyYHUdCVdhcWYsflKCiPuR/nka+FK DlXfgbpZ/bRkNGjpscK4vtH08eo1UyHi8YCCPlbhiJ+YFurepPUh5rrrNp1ccbSHb1eX U6oJki+ZoY+iLMDEvZswwEvmltkbjYmG/gzer0AZ8CDhX3tRMi7TaE6HzzNV/9QahMgO UE2nzSXAE8U2PXDtRz0cu5T/4YhC1IoncMP6zT2btJRZrN35A5wfVPKmWHA1ZDTmFYvG amEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B77RDkm/; 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 r129si10270705pfc.202.2018.04.22.16.11.17; Sun, 22 Apr 2018 16:11:17 -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=B77RDkm/; 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 S1754015AbeDVXLO (ORCPT + 29 others); Sun, 22 Apr 2018 19:11:14 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33516 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753943AbeDVXKb (ORCPT ); Sun, 22 Apr 2018 19:10:31 -0400 Received: by mail-lf0-f66.google.com with SMTP id y15-v6so4103718lfj.0 for ; Sun, 22 Apr 2018 16:10:30 -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=QEw14JMUgGrqO20JULTN0mCeOahs6b8QHm5uQv/Q7zU=; b=B77RDkm/2ppEMx4GMMUKO0XwZYcvwYBdabbI1psS9z3nYoHgFMkzrkr0uqvYT5bLCm CtzXij9jpK2rYow0rDl5oelTwlWjXUoRyGQIQsXNtjRZ8ahPzxTBin9XxKNW2Vm3rGTA /5dEJG/2XmMj9esCCEtkLiZtB4eElqnDoTCwU= 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=QEw14JMUgGrqO20JULTN0mCeOahs6b8QHm5uQv/Q7zU=; b=K3EWwrnlpeihiQl7KiSXaDARpxxWCFq/B0bF/CSj6NYCJ3RmebSXnNHY2Xvnf+VDig ekD5NyqR7FluS+dkBE6opTHe9KH1weLVx5AltejqOt4U/5kqMg8e3J1c1fSENc6IjAbJ 3hlxP5mvGCyr2ZTBGxQ+l0+xq9EQNaqKJ7M1tpSd7FJRlKjhdxXHWNhYKLdtoAFn5mrk RHkkpYFVUbElmevYCm6Mz6PIY6iCpBnKL/pNzBeU5qt3mI1B8A4/+p2mrwZSIs7AA9It 8J14l/ZoV7NtW98/TOIB9np64cfVx3VUhCUwAdulGlKzNXlB0uWQ4NHilw5eQHxMEVfg 972Q== X-Gm-Message-State: ALQs6tAzxncFSBhWlcaxmLKjT7Ig5gmH94S4lDBQKKJN1Rx3+nndJwj/ e1jdceobpKcyX1lJ66Oz7HRIAg== X-Received: by 10.46.118.22 with SMTP id r22mr11841094ljc.144.1524438630235; Sun, 22 Apr 2018 16:10:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:29 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 18/18 v2] regulator: gpio: Simplify probe path Date: Mon, 23 Apr 2018 01:07:42 +0200 Message-Id: <20180422230742.3729-18-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 Use devm_* managed device resources and create a local struct device *dev variable to simplify the code inside probe(). Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/gpio-regulator.c | 56 ++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 33 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 756b7b50ffba..e4b573bf8b99 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -228,27 +228,28 @@ static struct regulator_ops gpio_regulator_current_ops = { static int gpio_regulator_probe(struct platform_device *pdev) { - struct gpio_regulator_config *config = dev_get_platdata(&pdev->dev); - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct gpio_regulator_config *config = dev_get_platdata(dev); + struct device_node *np = dev->of_node; struct gpio_regulator_data *drvdata; struct regulator_config cfg = { }; enum gpiod_flags gflags; int ptr, ret, state, i; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), + drvdata = devm_kzalloc(dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); if (drvdata == NULL) return -ENOMEM; if (np) { - config = of_get_gpio_regulator_config(&pdev->dev, np, + config = of_get_gpio_regulator_config(dev, np, &drvdata->desc); if (IS_ERR(config)) return PTR_ERR(config); } for (i = 0; i < config->ngpios; i++) { - drvdata->gpiods[i] = devm_gpiod_get_index(&pdev->dev, + drvdata->gpiods[i] = devm_gpiod_get_index(dev, config->supply_name, i, config->gflags[i]); @@ -257,20 +258,20 @@ static int gpio_regulator_probe(struct platform_device *pdev) } drvdata->nr_gpios = config->ngpios; - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); + drvdata->desc.name = devm_kstrdup(dev, config->supply_name, GFP_KERNEL); if (drvdata->desc.name == NULL) { - dev_err(&pdev->dev, "Failed to allocate supply name\n"); + dev_err(dev, "Failed to allocate supply name\n"); return -ENOMEM; } - drvdata->states = kmemdup(config->states, - config->nr_states * - sizeof(struct gpio_regulator_state), - GFP_KERNEL); + drvdata->states = devm_kmemdup(dev, + config->states, + config->nr_states * + sizeof(struct gpio_regulator_state), + GFP_KERNEL); if (drvdata->states == NULL) { - dev_err(&pdev->dev, "Failed to allocate state data\n"); - ret = -ENOMEM; - goto err_name; + dev_err(dev, "Failed to allocate state data\n"); + return -ENOMEM; } drvdata->nr_states = config->nr_states; @@ -289,9 +290,8 @@ static int gpio_regulator_probe(struct platform_device *pdev) drvdata->desc.ops = &gpio_regulator_current_ops; break; default: - dev_err(&pdev->dev, "No regulator type set\n"); - ret = -EINVAL; - goto err_memstate; + dev_err(dev, "No regulator type set\n"); + return -EINVAL; } /* build initial state from gpio init data. */ @@ -302,7 +302,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) } drvdata->state = state; - cfg.dev = &pdev->dev; + cfg.dev = dev; cfg.init_data = config->init_data; cfg.driver_data = drvdata; cfg.of_node = np; @@ -316,28 +316,20 @@ static int gpio_regulator_probe(struct platform_device *pdev) else gflags = GPIOD_OUT_LOW; - 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_memstate; - } + cfg.ena_gpiod = devm_gpiod_get_optional(dev, "enable", gflags); + if (IS_ERR(cfg.ena_gpiod)) + return PTR_ERR(cfg.ena_gpiod); drvdata->dev = regulator_register(&drvdata->desc, &cfg); if (IS_ERR(drvdata->dev)) { ret = PTR_ERR(drvdata->dev); - dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); - goto err_memstate; + dev_err(dev, "Failed to register regulator: %d\n", ret); + return ret; } platform_set_drvdata(pdev, drvdata); return 0; - -err_memstate: - kfree(drvdata->states); -err_name: - kfree(drvdata->desc.name); - return ret; } static int gpio_regulator_remove(struct platform_device *pdev) @@ -345,8 +337,6 @@ static int gpio_regulator_remove(struct platform_device *pdev) struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); regulator_unregister(drvdata->dev); - kfree(drvdata->states); - kfree(drvdata->desc.name); return 0; }