From patchwork Mon May 14 08:06:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135670 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439130lji; Mon, 14 May 2018 01:07:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqIie9jylzahiy7m5aU25s5XwsLXf3onxcRkFvRBpHpLhYTJiq3ro3AuabB0poT+1GnYGJ4 X-Received: by 2002:a62:4a50:: with SMTP id x77-v6mr9466097pfa.142.1526285225517; Mon, 14 May 2018 01:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285225; cv=none; d=google.com; s=arc-20160816; b=X5pbsIaRW8dPTip24/dajQ9IVG4XuciWF37hF9NmcS0mZHZnXprNcSaJs51KjLGTrn rER3EAUALDEPVRX0OBimG8/okUaHmFhwg2YdlmMuvh50DS28jNkg6LY3xUMTqMB2Y3HN SPRSAl09+M0VZ0y9qAMUo6RvYpwcdZh3ASn17uh7Qi6x0VEoyNdx0uKmmaKf/ToWpIbr 1xggdafGaabdZ3u//sYYutlud+xLhFyptPORnXqJLQSkJ3BS1MfwAADbQseBj5wkC3Gr XAZNbDPd9octWvRp2wmZAyX+3ESErE8dlawG4R5beh+WFSk9sk60ewgbRZM2d8NuGEYl lcPA== 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=IFQWRX6+SOSfSUvpG035OnD4GcF2vsDiivNeDUABgS0=; b=R9qFGGaCtjIgsH4zizxcSwTcMGnAlxPFaIt93lCg1LqWxqq2QKGZRXvLYhl9px5E+8 ZUXYgTX9uWO3gLIwbX2zQzxxXbVqgXqijuAk6NecnvKSCqfUHPqno9Zs8YKjDb1hz87G ev1gEQD6ENH+uLqNB3740wgmGMN/SqssmIBlgC5x95GgfW46KcYKYjuZHMpAz+2CzwEU mq197+cpdFA6uToFr36ux2ryzxljjW9LjxKP9GEvTxORUTHYefwup1Uj07+MC7paDpLZ jMee3BhbFFBMqe+wJYKkj9Vy/KRTpctpx3GqsjBR8lArB/8yIvssRDphCBiAVTZrySgO Q1VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BkMGja8U; 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 75-v6si7154566pgf.653.2018.05.14.01.07.05; Mon, 14 May 2018 01:07: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=BkMGja8U; 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 S1752188AbeENIHC (ORCPT + 29 others); Mon, 14 May 2018 04:07:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39623 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751982AbeENIGt (ORCPT ); Mon, 14 May 2018 04:06:49 -0400 Received: by mail-lf0-f66.google.com with SMTP id j193-v6so16553801lfg.6 for ; Mon, 14 May 2018 01:06:48 -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=IFQWRX6+SOSfSUvpG035OnD4GcF2vsDiivNeDUABgS0=; b=BkMGja8Urse//lOriTr7NRbQrohs65eEky/aoxDSju6GbRhoZQxv94UmSP9sRt4s/e lrJrJe1fW/FbzYLJaDlLjDLHyS2Yu8n4yz9iIp6hsnfw2HAOr0cG9VT174jrm+fLatNi y1fHpHsQibhy3jRZH1K6ub4nkvaMSVBSEs5Nw= 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=IFQWRX6+SOSfSUvpG035OnD4GcF2vsDiivNeDUABgS0=; b=a2wP7lIzztmODAwrEOdDXkz1Ckj4A7Va9+AkAm5NTHOmMyytXI0wgJwBFktHraZhx7 StQwniND41dEm5wiNUBs9fPaJSd7p06eHaHtOLfjYNwtVUWlgC1bQDdFgdpqGcRVz5ZG 5UdOM+RCMbJj3wEvC+dTV3e965Fcw0zfHf3n/ReVhPHalCky583N0gpuw/6EckQeoRLN SBQk57W/nXlU6UFR2fqGI3zGPKRIq7V7gKZSk9ebiEsazvkvlOlJRo6fkOtpC/y39c5B AsYs0aDw0SjeeXbgyCWgF5a2xNwz/ApfXfagivs8IUhnOKMJ7vC2eSjP/yWg5WcRxxxE 8+WQ== X-Gm-Message-State: ALKqPwehhCm9TqszXCpNxraPDqLRe1ZMqQgF07C6fqzy+puP7bNSqDBB OQd9mlm7wM971cny5+3xA+7ARw== X-Received: by 2002:a19:f00f:: with SMTP id p15-v6mr8141000lfc.77.1526285207990; Mon, 14 May 2018 01:06:47 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:46 -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/19 v3] regulator: fixed: Convert to use GPIO descriptor only Date: Mon, 14 May 2018 10:06:22 +0200 Message-Id: <20180514080640.12515-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. 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.17.0 Acked-by: Andy Shevchenko Acked-by: Tony Lindgren Tested-by: Andy Shevchenko 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 Mon May 14 08:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135669 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439098lji; Mon, 14 May 2018 01:07:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRGpRcxa6NfjM4zhrS8h9uj/0/c/YLpqDN2YEAY63FIx33/3YDmgq8edeKbr1DU7S66jFH X-Received: by 2002:a17:902:585e:: with SMTP id f30-v6mr8747765plj.50.1526285223595; Mon, 14 May 2018 01:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285223; cv=none; d=google.com; s=arc-20160816; b=Wo6gv5rsx+qEUpjDhNsTn+czltgOXUW9r7SbWjZxFgkj7wgu1/hEyT0FebzMbyQ3hz bfAYXEEEhrsp/R1PNLjAa6NM2f3ZQ3xYeC46Yvty1hwF3Q5R15i/y55T4bNC3Y2Ya13G GRJF5bJFk3ac8upcXrApPz9KnjrdxHVQ07pI1/2XodOUiaZ+T6Qoed2NZdVYKyGW0xTu Yrn88LJuyU1tjoMFjtje/2syeZFVCd8/ZaX6gBuHD/K+nP1tIKaMlyD4UuywHSXzBNn7 eG/iKIhilWOd7N/OnFP8PQFKePDdjVP94Vvs/a5PQ4ikPzmBnae6SiWsClcK3ABaZVbb lj2g== 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=HqLIC+WFm2iVOJGu9EtARwz57472VcP26ZroaLfea/8=; b=tgJfU8yl/r54xtTkbmCMcsV1OfeIWinsWJUUQrTvUERW0Yh4CRM0D6MnkLv995FmxN mkVu2l121MF/S1Js8SpWKKRgLg/UK3dQIWxprm8L4v/e1r0/3BH2jvTxzPu8KJh//5/P 3ZL6HBp0JJiB1TxJ0mY6nVxE3ScjwLJBIykEdHlHhs3UIgFX2rW2shYzEvflmEErmSDp r0atqttnXULBXqO3GYu4dYk12aDpSiflEzpmBVPiPy/JhqTEJIp9B5EfotkzSG3pMviX XjByRxQP8bHuJo2ExGZMnFZjRbGNWv6JOLyb26NzIpCkV1lccWWmAvVRi725r12fFiKk NcHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N7dNssyG; 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 75-v6si7154566pgf.653.2018.05.14.01.07.03; Mon, 14 May 2018 01:07:03 -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=N7dNssyG; 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 S1752168AbeENIHA (ORCPT + 29 others); Mon, 14 May 2018 04:07:00 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41445 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbeENIGv (ORCPT ); Mon, 14 May 2018 04:06:51 -0400 Received: by mail-lf0-f65.google.com with SMTP id m17-v6so11386975lfj.8 for ; Mon, 14 May 2018 01:06:51 -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=HqLIC+WFm2iVOJGu9EtARwz57472VcP26ZroaLfea/8=; b=N7dNssyGBr0BhVrGEW/CuiiqqlzKNtE83k5E3Gjj8wIPIDswKtfYwkX+koVocZugZ5 A3liwRAPNRHZHViF33CS/+zbYhwtR8vPzc6lMjtTBIREKPC4AcvGd82fCfKMhgpv9Mri 5/CvCuKKemFw8w/yL9wq548SNeHhlUcOJZ0OA= 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=HqLIC+WFm2iVOJGu9EtARwz57472VcP26ZroaLfea/8=; b=ekJefdKiTOv9NHOpd0O2hDYRndx8CWb3fpf2PiZ4HM/fif2rzqqW+H4yMcXF9FDpdE HXWRKQTvg9YNr4TQOU+sV0EvcVGOMp8QPNMV2lP5U6t0L+BW/OWODgpuSWqG5WujlNlR Xx3+bvbzPOb9MoSv6bm5+sUxOqwvw91Lt780k2C9Hpr0g4eSQtGG1NI9CEiQpZVVPFQy AxiknLLt777poojUaXVpwcM6Ip5dtU621nlVdTpdoO2EYfz2d3l51hbJXtxeWCDpwBl/ yL0iMt+qsSYNlhsf9xW+OlAMKMU7Tl32itnAQQMGSW0CUfzWIOy9hMjcT18u2cutfcfs 8sjg== X-Gm-Message-State: ALKqPwcl6j3619GAzKeiv4rW/MKlQvb4ldr533pAw64iSsTx+2pGBlnQ aiy576dNaDZZtpD5MdodtenNn5Bc4uc= X-Received: by 2002:a2e:89d7:: with SMTP id c23-v6mr3887480ljk.22.1526285210129; Mon, 14 May 2018 01:06:50 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:48 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Philipp Zabel Subject: [PATCH 02/19 v3] regulator: gpio: Get enable GPIO using GPIO descriptor Date: Mon, 14 May 2018 10:06:23 +0200 Message-Id: <20180514080640.12515-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135671 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439200lji; Mon, 14 May 2018 01:07:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqn8pU6R/4SMCxagQA5Um0QqQ2zupinb2Eke6S0Wflk9kXVqf4wqi7v2esJed3bNI0t3Srm X-Received: by 2002:a65:4a46:: with SMTP id a6-v6mr7703908pgu.227.1526285229883; Mon, 14 May 2018 01:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285229; cv=none; d=google.com; s=arc-20160816; b=gE0zuPoxA4k8scrSjG2qiry/II9h3xv07mg/rX/iuWOYH1lhdq2Ux+uVcEUiDYlsGB jEGMFp0XJsLnsH1OBtUNys4+A1RXtq3dB/cGSYXrvcyDmaPhBCRgVfpd8IJJVvXr1C2f t01fSZfZGbsWExbM2+xx1O91TtMk7ZwNM/6Yo0BezGeIawW56p+4z/dw7wd+1MRrXU4y 0StMDY3CeBZyveAjV6m+vSgZYhNIrJYw/uws5xxfh6cIY0tY7Y4f4xvLKXIDMuU1qt9X gA4uhXSG2xtsY9HKFV8TCPwhqtKVOKaRKPUeOgdnR0xHIyrJWqP3KtGPeXz6qy88IZsW K9OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=Kg2/eaZcXHo4OoEcFFeEdpXufnFj5u9UD/0YICX6eRnpfJb7VOOFn1QlLStVTShz96 Wek8zT/4s0wrcbqSkGIk5U7gstv1Mxk0tCy3wZ98DlF7x5YtAdm3OfxyDvSvqtfYBYA0 Gdr3ZToTxUwjTTclA4kiheA2gA3wJdQz1c4xomyiPyjea9ohyhfMijtgFKInhM2WAGZx ldvhJ0s6rbT6u1efY08uOcUkVWhp/GYG8D/zNuraIRI3mQYtwv7j7T/GlFhK+XP9JTD3 sx1rsbGVOCLif67OxUfbv+r5ag3nGOJgFMIVIN2gCTqWsefzonEOv20fiJkjLbymTb0i rRUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H4j8Fo3I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6-v6si8978027pfk.194.2018.05.14.01.07.09; Mon, 14 May 2018 01:07:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H4j8Fo3I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbeENIHF (ORCPT + 29 others); Mon, 14 May 2018 04:07:05 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40000 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbeENIGy (ORCPT ); Mon, 14 May 2018 04:06:54 -0400 Received: by mail-lf0-f68.google.com with SMTP id p85-v6so16542777lfg.7 for ; Mon, 14 May 2018 01:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=H4j8Fo3IIjqtRDghOGcePcfmmp1qbyLE+WPsZ3HxhuJxu9qNB93RWlk6XM4FRCC3mC X6+iciCK4ZyUXqpz1JyHmk8vxz4UsYoDRraBM/bZMwktk0YZwrSDc04cC/d+zb0dirig sUB4QeeVcJgMzytdDcd5BEaVdWCFy9Zj/K+Ds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g+TzSfzqHwJrkY9mmTB5VzMJBl2DAFQ5DbZxTirdVQk=; b=pRK+IW+NBWue43NWfqQx3fQ1UlGINCowJjkSOX2cIt6WoSTQbDwyOOt3h61W6ltEyS UEcaZPBgK07HqYmoWEsk2fVSaod87gkQkEq/rTQRCIDSMI+Vp77FGkR8yAomdH3IfoUD ykhxI1bFHFRV4YwN4gFRuBhiLFv1R+WfP9FStWHei6saep6TO55rS8gfcOtS+p9VYkri twTIuaKW9ZunJl3mR7m0P86xVjprENZdS5skEcxptpWNpVFz3E80Y9XoCz80aOpHeoYu HQ2kCHrfQ8HA0PvtEL5PKQB6UFy7ie3mB90pW9ZOBH0Ur/bRO5Spp9QMXFgFAHl+NlZ4 B6BA== X-Gm-Message-State: ALKqPwcyjlGwiaogqzMihVL7n52W42pBT0O8k3fAPi2NhVs7/s2+bIym WxzfM73dyRcW1S7gQOqhzWPT98DTNA4= X-Received: by 2002:a2e:8693:: with SMTP id l19-v6mr3813357lji.91.1526285213059; Mon, 14 May 2018 01:06:53 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:51 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com, Richard Fitzgerald , Charles Keepax Subject: [PATCH 03/19 v3] regulator: arizona-ldo1: Look up a descriptor and pass to the core Date: Mon, 14 May 2018 10:06:24 +0200 Message-Id: <20180514080640.12515-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. We have augmented the GPIO core to look up the regulator special GPIO "wlf,ldoena" in commit 6a537d48461d "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Cc: Richard Fitzgerald Cc: Charles Keepax Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Fix "wlf,ldo1ena" to "wlf,ldoena" on WM5102 non-reva ChangeLog v1->v2: - Rebase the patch on the other changes. - Make sure to update some s3c64xx platform data properly. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 28 +++++++++++++++----- drivers/regulator/arizona-ldo1.c | 19 +++++-------- include/linux/regulator/arizona-ldo1.h | 3 --- 3 files changed, 28 insertions(+), 22 deletions(-) -- 2.17.0 Acked-by: Charles Keepax diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index f00988705408..5aa472892465 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -206,9 +207,6 @@ static const struct i2c_board_info wm1277_devs[] = { }; static struct arizona_pdata wm5102_reva_pdata = { - .ldo1 = { - .ldoena = S3C64XX_GPN(7), - }, .gpio_base = CODEC_GPIO_BASE, .irq_flags = IRQF_TRIGGER_HIGH, .micd_pol_gpio = CODEC_GPIO_BASE + 4, @@ -237,10 +235,16 @@ static struct spi_board_info wm5102_reva_spi_devs[] = { }, }; -static struct arizona_pdata wm5102_pdata = { - .ldo1 = { - .ldoena = S3C64XX_GPN(7), +static struct gpiod_lookup_table wm5102_reva_gpiod_table = { + .dev_id = "spi0.1", /* SPI device name */ + .table = { + GPIO_LOOKUP("GPION", 7, + "wlf,ldoena", GPIO_ACTIVE_HIGH), + { }, }, +}; + +static struct arizona_pdata wm5102_pdata = { .gpio_base = CODEC_GPIO_BASE, .irq_flags = IRQF_TRIGGER_HIGH, .micd_pol_gpio = CODEC_GPIO_BASE + 2, @@ -264,6 +268,15 @@ static struct spi_board_info wm5102_spi_devs[] = { }, }; +static struct gpiod_lookup_table wm5102_gpiod_table = { + .dev_id = "spi0.1", /* SPI device name */ + .table = { + GPIO_LOOKUP("GPION", 7, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct spi_board_info wm5110_spi_devs[] = { [0] = { .modalias = "wm5110", @@ -366,6 +379,9 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, rev == gf_mods[i].rev)) break; + gpiod_add_lookup_table(&wm5102_reva_gpiod_table); + gpiod_add_lookup_table(&wm5102_gpiod_table); + if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", gf_mods[i].name, rev + 1); diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 96fddfff5dc4..f6d6a4ad9e8a 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -17,12 +17,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include @@ -198,16 +197,6 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata, struct device_node *init_node, *dcvdd_node; struct regulator_init_data *init_data; - pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0); - if (pdata->ldoena < 0) { - dev_warn(config->dev, - "LDOENA GPIO property missing/malformed: %d\n", - pdata->ldoena); - pdata->ldoena = 0; - } else { - config->ena_gpio_initialized = true; - } - init_node = of_get_child_by_name(np, "ldo1"); dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0); @@ -264,7 +253,11 @@ static int arizona_ldo1_common_init(struct platform_device *pdev, } } - config.ena_gpio = pdata->ldoena; + /* We assume that high output = regulator off */ + config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena", + GPIOD_OUT_HIGH); + if (IS_ERR(config.ena_gpiod)) + return PTR_ERR(config.ena_gpiod); if (pdata->init_data) config.init_data = pdata->init_data; diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h index c685f1277c63..fe74ab9990e6 100644 --- a/include/linux/regulator/arizona-ldo1.h +++ b/include/linux/regulator/arizona-ldo1.h @@ -14,9 +14,6 @@ struct regulator_init_data; struct arizona_ldo1_pdata { - /** GPIO controlling LDOENA, if any */ - int ldoena; - /** Regulator configuration for LDO1 */ const struct regulator_init_data *init_data; }; From patchwork Mon May 14 08:06: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: 135687 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1450988lji; Mon, 14 May 2018 01:19:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZownPDGq59P9+j+pCS41sIZ59dJ9d67KFw3GlxFkk1IgrJto2fGWlDzkR+COCsgLBn4rxr7 X-Received: by 2002:a62:c81d:: with SMTP id z29-v6mr9421101pff.81.1526285946343; Mon, 14 May 2018 01:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285946; cv=none; d=google.com; s=arc-20160816; b=F0T5EJdEL4b6ZMXQLbDC2ch4W2XNQioFhL61HPqnFvhZ8aTZ/fT0apI+4OL+WHJ9qL gUqBBuG4v6muUTEVOr2BJvJq4dYqwnk5Dxi+J7hPbaZZJ8LD3CS2y1yaD49opU+fwUx0 0Rceffad8DYog6vISZJyoNc/2UEjSPCx3dEx/NvOYH8kEIKv0hSKedNxpC0I42JAoDXF 4DQ0CLpPecj+x9yhdpooOILr61pDJDCrdM4ELJKsHKAsLpDaf1wIRNQuQ6Zr6Z+yXgIj /sS2CEvOJQxdy5ZJmhkSoll2XfKy9uIKrjmrZSd0FEh+lcY5jhfNRXNch+Pa9G0szeA6 ngLA== 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=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=zBBJkeYZDAGGf5bMhQkT1DpU43bOujySqGB8CpuxV6mNq5U1hMJXDa0NMf55P5JA9B UmqL4XKM8ko7gGQ3EydkCqCBtmaeVMLF0DaSVRIoOe9HpMH0Kx8CjDjNBRknMEZLVI1Q RgysqSrcjCTsjRsKHVgaAWDEBZg03bp1nwrzhA09asHajAumel5/GYV6RL8J/TAxynlF BX+zaVQmjIy7GF7eTTuGgk+kdZzJjs83Eup/T9mzZ6L9iN/kf999Au5GMf6joXnvcEue KmmSAlG3wUbm1WB+6QL1GTYPBsZx1G/C3y5dQaJF1DU+Q1XwLnUterFpXR981RP7FiBN auNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pe25SOxO; 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 t24-v6si9001757pfj.231.2018.05.14.01.19.06; Mon, 14 May 2018 01:19:06 -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=Pe25SOxO; 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 S1752610AbeENITC (ORCPT + 29 others); Mon, 14 May 2018 04:19:02 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38112 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbeENIG5 (ORCPT ); Mon, 14 May 2018 04:06:57 -0400 Received: by mail-lf0-f65.google.com with SMTP id z142-v6so16529066lff.5 for ; Mon, 14 May 2018 01:06:56 -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=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=Pe25SOxOx1cBlUSNfdEvKW+weXI7dOWUl43WSbQq7GBkI/QBAgcB5xWYdkn+3OEjp5 uzPUEyhF/3mbYvU7tjoP0cknXZTRaIjwPdmLFlLMwbZo5RE3iMSZMT1avskm7YQtAyeb UQqQ34UleKFrB17s8Z7gBm2t1+B/ItH6SGvOg= 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=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=ZwSxP9/t+jPWtAfe+wI8bekEF06vOp+ZLAB1TRHusx4RiE/uUmwya6artr7y1Lx/W8 dai85mNmm1YDcfz0JoH87ouop3ziYLxlS1ARoPeG2+vhS4tVlXZrSZ58fZeFlhPw0zIW egIrTosXe1tvqoNxwNh/btqXQ6+y5eexAya5ZVHrTgpdR1RymLi8OOBvrajiikss7Smc Cp22VUtAEvJ9DABQe5uN/YUNAD/Crlw4wRYgm01ve5D2UiKRlvmAKRoBPOwKRNZSQfUu 1+zGtZsmKbqJphdq/4Nx942RHp9y+Kobr+o+lNJwtLajJxFBUM/3LsaGj5dTo4xsa65V 1UBw== X-Gm-Message-State: ALKqPwd/vzeE8+oUx1OJJalUXBWOFGgMK9ds2svQIrZ5bKQq6R4urBu6 dQZ2JeLpk3UgBJd1uUg+bKxscT/JpXM= X-Received: by 2002:a19:5512:: with SMTP id n18-v6mr5494282lfe.24.1526285215419; Mon, 14 May 2018 01:06:55 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:54 -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/19 v3] regulator: max8973: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:25 +0200 Message-Id: <20180514080640.12515-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. Cc: Mikko Perttunen Cc: Laxman Dewangan Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max8973-regulator.c | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) -- 2.17.0 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 Mon May 14 08:06: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: 135686 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1450546lji; Mon, 14 May 2018 01:18:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZomW9+szWEESYNFKMTMIJ+dwaGj8irlnk6W4TwmkeCNMCP/3sAUOhWaVV8fb1FMMhKsDAr4 X-Received: by 2002:a62:62c2:: with SMTP id w185-v6mr9453541pfb.78.1526285918313; Mon, 14 May 2018 01:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285918; cv=none; d=google.com; s=arc-20160816; b=J6QlT1/Bxll4mcP0PsyucxETsM0e/HY79SV/rVTUqj6u4oaDbHw+CgqXBI7EgJfIt2 u5OYAjXLuyr2GQXQSdVZgc37yFxjhXzTX7e+Qud+ntVgp2FVmQzEYcl3jj+zAZ8cxXJr eXH4Mjr1AT69bMCZr98i2H1P/pJdUoH8ELsbNpIqGmvzNc8pF3zei9yZqjuDnaHWkS8x yE/+PIXrSeV4jUqjxAtWooIZRJfyzYzhzrdJE4CQBIxtvfGDrOddhtDR42E7VTw0+h15 pek526hmnDMUmZC4PKMGtPw3Ed2ysrz8n/HuDxIEAzssigENuZVod/pkICN5Kziez9wK vbBQ== 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=RdP7YtCvCRm+SKxjNunfqP/kd9Y28Uyre/s4qOHu8jw=; b=mcOnrI8UYMCRaKm2vQpA1T2fCaUjqq8BHP42Zjle6NONBQMPl2iJ3bZMdQ8SC0ZUJJ EZUCiAOsfrz0bLEHL/aECQkYgWk2AgIpBViH+4ewMPHk5f5mlgiJvkVpeIwY0Tne60/s Gm+vJW9bgul0x4yb0nudwCyujsLHIIyb8PVkCi9nMoecorTdw/RrNHvJUDRUmY8zsgxC ZPUth9rN2hUOCvLUhWVWYJFhg5Gkp8gSlkSQQOECdDK3clAbW5LcEVRsRjEFOdtRMsPS HGkyFXJ6UzD+uk9Y/or/nrdz+8VJJR/mOKR1tqxtdtgFlfKLpBeSMzhTAe2o5i3Ed6pu S/CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kZW+bUFl; 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 t24-v6si9001757pfj.231.2018.05.14.01.18.38; Mon, 14 May 2018 01:18:38 -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=kZW+bUFl; 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 S1752590AbeENISe (ORCPT + 29 others); Mon, 14 May 2018 04:18:34 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40007 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752137AbeENIG7 (ORCPT ); Mon, 14 May 2018 04:06:59 -0400 Received: by mail-lf0-f68.google.com with SMTP id p85-v6so16543103lfg.7 for ; Mon, 14 May 2018 01:06:58 -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=RdP7YtCvCRm+SKxjNunfqP/kd9Y28Uyre/s4qOHu8jw=; b=kZW+bUFlOba/g5mRpBVl2vTb2ecr8jpKs3ZQbglsQVGOYYHoHUiHj3m+CueJ/qRsCi 6VexccaOAb7ACoHM9Zbg2O/UEIjDQEsstwXu/66Zzy2Y912kKQLNDFA+0RZRyNvbDuAl T+/mAQN403ZDkr2PygmqqMD55zjODotfeffXA= 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=RdP7YtCvCRm+SKxjNunfqP/kd9Y28Uyre/s4qOHu8jw=; b=RCCwK2b6LoCRpbV5sNtENyc81Wx0xUH+JUafRsXj9Irj8kJiWg9VEDpwT8nPdlpkJl xhZ/ybt8TC5R9ey1eRWXVYkV3D1KH3x/feretjwPLl+i4MXKInR4h2ZPmnhNvcTxeRQS +n9mhEaOuEPo+AnrLqlSKNQSbV+P0RUPMM+/FDtDbJl6npRvXbZ7alVDDnzh6Zp3rMdI lWX0EF2/QeyHn4zXBg5Q/I61CWWduQSCRSkMAha/EYV+9M2m3itHnYU5lip4kmughvDg +yWyold/F5GRdD9CS+pGgoeLJZ7DQl5Yw2t30LCKGjMGecD/eXp9U8TOMB/GlCOoWUzX bNIg== X-Gm-Message-State: ALKqPwcWrNtgQjYc78VkfHJbSYpk8OFTmO01clQ2jhAVkiVxpJh2Y3Kw x5yF64apjGbXwQJrN1iI/ufmZA== X-Received: by 2002:a19:ca5b:: with SMTP id h27-v6mr7593130lfj.69.1526285217923; Mon, 14 May 2018 01:06:57 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:56 -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/19 v3] regulator: max77686: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:26 +0200 Message-Id: <20180514080640.12515-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up from the device tree configuration node. Cc: Chanwoo Choi Cc: Krzysztof Kozlowski Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Name the regulator "max77686-regulator" - Set the regulator to NULL on erroneous lookup, restoring the old init data lookup behaviour. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max77686-regulator.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.17.0 Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index c301f3733475..37f98a8350f0 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-regulator"); + if (IS_ERR(config->ena_gpiod)) + config->ena_gpiod = NULL; 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 Mon May 14 08:06: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: 135685 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1449958lji; Mon, 14 May 2018 01:18:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoor2kc5515WB4EwZ6JiyKb3O2mwVVvkYgy9vQMPh7JG8kt+VoQa1tnDXLdsXNEiMQLQTXc X-Received: by 2002:a17:902:6903:: with SMTP id j3-v6mr8855870plk.313.1526285884473; Mon, 14 May 2018 01:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285884; cv=none; d=google.com; s=arc-20160816; b=dNbt7HJvVu65c7bcf+dHRw4M1FnQYJjTSH92GSspoEGeabGhv674K5YKDVOxVFL4CI rllttni991+MP5ijL15p0OSXpcdXLlO2mPW8FiWBRoWPBXnVMO7NhOvkZSkzZCJCNCu+ 7FyPxOU7kF+Em4WX2mf/ceU4TOKtMAtvgBpGGzFn2Cx7DBbp7xfdZCK0NnyRPTJUqiIp EEfxRYd9MMpXRh6Dlw1eORgregzo75nbcxEHDpmZQYRSSrxXhEUkmi/je40oOuutTfbx J5EruqWlj1uESX7AjpfLANm2nIQ5Q5QPZP1vMYYRzRmGv6SHO/QoVg2dnu7HHGR3m3SZ S6og== 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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=gRW6+GiEJD7uthpKkvugPSe7gAI2Z6VEisUavrv/3Evxm+GLxE0xBinlhQ4E4H6udG fWIQh3HQiZsAU3Pf063n+IoGKg0gS2Ojzqb1ykxN0FwBK9KtNoKfbhl+guQU4thsFF+A W3jj3j7zrgWlsinfOyBZoJPyLQhgm/3WzmuK3Euz8JMHnung7ql5gIA33X+LkbFLXgOW DInWjrhD+buEoTMRv1UYBkLulvNXKovzBWSVx2am8uf4utc9dGmMVZ6ZIOPY7FY4kiXd C4jX1p3peIhJzmQf7W46oYOQKW7GWbZXwcihUGcUJEaDqsMiuYTJFeubB/lZ7DcnLWQt 27sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsydSttD; 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 j7-v6si9788422plk.506.2018.05.14.01.18.04; Mon, 14 May 2018 01:18:04 -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=CsydSttD; 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 S1752659AbeENISA (ORCPT + 29 others); Mon, 14 May 2018 04:18:00 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36035 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbeENIHB (ORCPT ); Mon, 14 May 2018 04:07:01 -0400 Received: by mail-lf0-f66.google.com with SMTP id t129-v6so16536245lff.3 for ; Mon, 14 May 2018 01:07:00 -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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=CsydSttD6Mq5qne6u5hZ3PiW1t4vhQzufJp6+kJMjpQYvRKG4jUv+yo6Jnhw6nzZDu 9l0HJR6D9d5IvMqjVSPqL9fs1LhqAsvHddU4Dxs4mk71MNZJK08f6g3MCsSEXLh4sX0W xfm7IB3LS/HTJpinP6c6M8yPrshxaBfB51X/4= 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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=K6JkbJ3B6h0V5toje1RuNXkcQOM6z8mN8a3mdFk0c0DoH2uJVsQRZMNpeBDMXWF3nt K82zIim0wS4ciRwl7b0mqJ67IP+A3JbkpK+uTavDE9lo7Ua7jCB4WBYwqXAGl82wELoa B8R0j2QLeaYIR+AwwGW5JE0aPUs6H0WRaMxZ9hdBfQylpyHe2IgbXtwul0mVeIUVODOt 7VY+e3FAWs2/Yr+NzObIzYWWg1ssDFkHLiZXLDZt3or+sgUeMSrPySVz326PidJkaGbw RxjlNorTEkEL1LqVaq9He966jqBWxIBoB4/YPhdA9ycQ99H64vZSmsvjoXXMe5hGt7LW aBZQ== X-Gm-Message-State: ALKqPwdV8X8ObwgkdbdwC/sAx1ESNw9vQeAGWUBJ7qCUTwJ46e7odAOo Jsl/xS4rt7aten9RhXhWEn7+Aw== X-Received: by 2002:a19:1186:: with SMTP id 6-v6mr8206963lfr.134.1526285220180; Mon, 14 May 2018 01:07:00 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:59 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 06/19 v3] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:27 +0200 Message-Id: <20180514080640.12515-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_index_optional() call. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.17.0 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 Mon May 14 08:06: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: 135684 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1444160lji; Mon, 14 May 2018 01:12:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrtHotfpNqIJZbI7Wgn1hNlMdA/wAb6ULFpL5K4wWYhFj1Kgm42y6RVtRbFPAPH380/Y3Kc X-Received: by 2002:a17:902:704c:: with SMTP id h12-v6mr8799690plt.269.1526285534210; Mon, 14 May 2018 01:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285534; cv=none; d=google.com; s=arc-20160816; b=B/cY0G4PPqXsqkHEcExivDVZKkuw0B9Igfue3cGE0JCERr9IPQkwfmf51ilxjaWdcL YncBQpIMHsK/OIGo6DXB7KfzBrzH9Rx2S9GwfGbd/KhSvL/CEYyhnIr5j+McD/zHOYKO EHCvSF++IyBxuKXwF1HETfWrDCtoxLyJzg8a/wmcFaE2SUZxKQ/NyQghrlu0R4A3DT7D SHfJ3X1AGy6EyCHbJWTqBDrQKd4hhmUQMwD+cP3oXoBgpwXvtntGZFOFvPMIOIkbRVwU F32I3iaq+Ok1pITjPKNf/NG+7RbhRsPQ/mCj6ciNE0EJmxvF6Zsp2ZpHfyjYTTNN3+Ti Zo4w== 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=H3W8X/oQAyR92nkO70yecClyKJhVPUQDgCQhu9u9v3A=; b=s7irjdmn30nP0Sq7O0IWfFknMlACyW6bkIhrft/bmjUe7Ps6S2KPu1hdHMIMEdAHez TtlfLgCb//aa0qiUPqDqU5YFgIGT1YWosZTZcUy6l1I9p36gxd3adkUXJKLkTCkFNB0E N15RRczrCT2KxcBzZVBoGW//uYOkuRbUXw8/XptZcvhKfRmzTKySBf4KUIIABSpy5AUX QLe5J0+7qcPFRUynfR8eNvDa9+RLWjxgpQhRrb/4hYABLriOOY4SKJ2K5k6dWdi5FEjr a3xoxhyN2zXnr1HDK3zR9g6uG6GUu4kpviUleFTjonqbRO2zK5+052cVMB6srURMvL4L 4zaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WiS/gsFz; 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 n9-v6si7106669pgq.470.2018.05.14.01.12.13; Mon, 14 May 2018 01:12: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=WiS/gsFz; 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 S1752441AbeENIMK (ORCPT + 29 others); Mon, 14 May 2018 04:12:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:37494 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751982AbeENIHE (ORCPT ); Mon, 14 May 2018 04:07:04 -0400 Received: by mail-lf0-f68.google.com with SMTP id r2-v6so16556942lff.4 for ; Mon, 14 May 2018 01:07:03 -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=H3W8X/oQAyR92nkO70yecClyKJhVPUQDgCQhu9u9v3A=; b=WiS/gsFzmncmt1M+InsIqF044DoJdCTnofHmwjmptgf1ntglznGcHPwk22/qoRAZXg IELJwURHoc7smmKknAVQYSX5oHLQMuwPM6t8Ajmc7cNI982VX1wQ6AWgsAvhR5fMorDD /R2e3GSpiKT3/KULNCTYbMmiW/mrh0y+FoAXo= 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=H3W8X/oQAyR92nkO70yecClyKJhVPUQDgCQhu9u9v3A=; b=hoiPg3uXsC9Q/P7vjZCjvLhVJA9GycmKT/cZfqKj7yydNORnROtThCGBLWhugaDw9m qIe+15s+mNusAuzom5i9ehrGj1H1zblZLxMGfJ7wCt5A1/G7aWvsykN+pQtAPGsvmXSl DoJqRpm7j6rIfaWCIP40oy7R0IDvQ8x8oMY8r9jUQxSXp/doj1n4PmsbOLn67sLby38k AyI0iKVhem9xlG7i0OoBE1M4aHxNmZWV/7WwpflW6nlKHFJQq+oCVVztyHGSBqj5HS2W I5aXOhFFlHhAQ38Vx+h3+Ilni0OBjHc+CNbjaBDts9btmZwHKSzChGA0/x7/PMQmW35D HAjQ== X-Gm-Message-State: ALKqPwd5xUXY10SparDsK6qbkZW7iijMGbRVwBwPHVWH0XvPDK5wxEW9 awn2QViZgjFmOnpUPaR8JdszzQ== X-Received: by 2002:a19:c749:: with SMTP id x70-v6mr8253232lff.32.1526285222548; Mon, 14 May 2018 01:07:02 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:01 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Milo Kim Subject: [PATCH 07/19 v3] regulator: lp8788-ldo: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:28 +0200 Message-Id: <20180514080640.12515-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135673 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439528lji; Mon, 14 May 2018 01:07:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLYwzVy5bcPbruTbS1wVbCwAaT6NKoAtXwqJltaQsFHa89GO03F0/cMITlEoNE2qXZb9xA X-Received: by 2002:a62:5841:: with SMTP id m62-v6mr9310475pfb.116.1526285248469; Mon, 14 May 2018 01:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285248; cv=none; d=google.com; s=arc-20160816; b=N6wXEtEitlJi+OluWonYM9nSzeQAT6IinYn+/3k4GafMi2gbaPdr3kfcOsrtijKpYY 2ovZMK5dT2clqQrHuammH2c+LzKxFSrCKgn7zys7ifP4iBDIlhcu6hC4k7vGkkkVOJx8 FPJLvvtIjplCOss5Cq3YMqfRJ3rJin9KxjtNTTB9+mLxhsr6YzcSxRnsDff1jvB+Dg0M DzbrFO1wXvCZC7iY5jhZaN46aGXctz9V5GkHRxCnm5tqMEw6suG0zs98Zi78juKjweBW F528dvZ0ThOajvsx7XpfLsIa4r9RJ71qH3Thl0EiwS8jpiS570w4jSLB2PzyOdixkoSl 3TuQ== 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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=YMXV0SKGDXMC/9mKSJuB2rZJ2Qo73KkrEfP7oytSwrmrMmLf+m+SjU1LVJSwqLivl3 zDEQk7uLZUbYL8iH7nSrEmgLG0SElxWCvoZi1SO2E/YsBhqtvYwY4/R9vX9JvBcndOjW eulUaJchVEO37wg0fY1PojsOLbp2cNKuykUIBPZYolRCMD5pgZ0+BtOopkWRhDAH7GPA zeWu9hJrmyWJScquQ9ckAgBGRbxMoLl55FcCCGplr6ipVuNJRl/dHy2yGEpmZ/A+9fH3 kay16Z6suhZnrAF8JAeQJC0iZq9iUjWIPcv8p5zD9paoCJQ3RINRcFxl5dsi9h+IW3K0 fQYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HUVBOIL4; 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 m198-v6si6785758pga.107.2018.05.14.01.07.28; Mon, 14 May 2018 01:07:28 -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=HUVBOIL4; 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 S1752336AbeENIHY (ORCPT + 29 others); Mon, 14 May 2018 04:07:24 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36047 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752208AbeENIHG (ORCPT ); Mon, 14 May 2018 04:07:06 -0400 Received: by mail-lf0-f66.google.com with SMTP id t129-v6so16536578lff.3 for ; Mon, 14 May 2018 01:07:05 -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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=HUVBOIL4wdGdQ2+mgbtzFQydlg26rnI+PJog3jnRxe11cHeIK5nj2nuAQtZiGbnKQy xq8Wngs0x68mpmzOYFSzWV3+z0q2o92YNjy2ZcVybiQJEsmbH585nPzOAg27x+3PSf6S ChhB1/SKoFyLdBgXKTmNMbhKh9KrBkSAJKowE= 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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=tjJdJ4Q9GPayegTswVSTDMQtzkA2dI7IJVFpPpNYLt2ugqm0jwZ9OdKpaleQ1JMc8n FIiLkvI/PEj68GQbY0SyrDiyJmRn0O7hZcSfQ1pXyQ8tdzpScZQznxEx6UF2co62suP/ nMGvCbLFHxzJlHwugY2Wtdi1sI4L0FgOYYh8MwlJ7KJQ6MAVtrn2eTxYc4qyc4lpAhTs r9vDqOZYvJM3X7Ta73BGSQLvG9FgqAa56xq3+YZWjrW6znEEAEXaHjSepbjNWNcFiUAZ +4HOppBGrs1ZkZSnq/4eS62GSKdo2eC2IGYwxqm1efbb/5vYqIfat0NwmJ65K6jvxX6n /5LQ== X-Gm-Message-State: ALKqPweZBr3kX3X5bxuAcFuCACaQoshfjDd+Zg7pmSA8CkCk6o++k2ca uCrUIRVJkcPjaTo/ng0w+Z39Zw== X-Received: by 2002:a19:1142:: with SMTP id g63-v6mr6432969lfi.6.1526285224766; Mon, 14 May 2018 01:07:04 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:03 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 08/19 v3] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:29 +0200 Message-Id: <20180514080640.12515-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135678 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1441268lji; Mon, 14 May 2018 01:09:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq9Zt1Ll2RylHkdaZBuQtjSRiaQjDDqDBLiD8c/4cPkkZ3f/BR3s4vhIEBe2B7sW0m3ldjD X-Received: by 2002:a62:7002:: with SMTP id l2-v6mr9475154pfc.40.1526285353980; Mon, 14 May 2018 01:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285353; cv=none; d=google.com; s=arc-20160816; b=ruX/d0JpoB85/syXM4ytoAPuXEyRFNjGyqAg3SqK9nl54aOwOZBK17IWNsKUrYYj5u 00FbCSrNS3J0LawIOJeI7Oyw/wmGQCOuYhYuuVlcubmrzl8IBFTmG6ZBvgkO42sq3i+h I5fwqtGxI/3IoPj6Ds4p2QnyxK2npW7UAs7b1vNRHWJSdGBviKdObNNtlfzNCEgEZF49 clkLxNQbnAF4QadttVDITefG/rS/wf9RHwWwlVxkjaCW/vH/Zj5LOxS0fD3lJoDpG3HZ gH7O3BM5DrxCBLriuAZH/t+rVtV+bExiTxRYxOAuNLbTbe2q7S2PtZhhctfNHGayznMx 7wBA== 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=n+mwPjgvTiqsvab6ujwt53MLo9UqrXzOtUygt62N/1E=; b=Gpy1Hbv6LjU8qA8I2xcYKAmxaywbvVKEiDTL3UYomI/3yoQLMBNrLhf3QgnC5ZQs6c M2Y1mzwybEXQybTGz8UUJPl6amZwdYe+w1bDEDhtj1T2uHRyVKRaksoVy5mAt83dvF30 DKNhGuKuP16qvlKAoj7Kf4+X518/1MvBlNjL60CISbOZ6t4jJnrU2dk0treEhCZ1Iodq LX3410J2iHvXy8EFVLw6eU0atpxmJu58zxArChS6BzNi0T6RRfH9Hiz92RKwAAWIceiu wNVOKG1VEd0SqryfnY2jji9J7PpOkjrKceJBOYFcqfHVPMT3Mxa6AB3xpVi/rhqzx/9L Tpfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dLQ1MTbB; 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 p67-v6si8815667pfp.72.2018.05.14.01.09.13; Mon, 14 May 2018 01:09: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=dLQ1MTbB; 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 S1752318AbeENIHX (ORCPT + 29 others); Mon, 14 May 2018 04:07:23 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36052 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752212AbeENIHH (ORCPT ); Mon, 14 May 2018 04:07:07 -0400 Received: by mail-lf0-f68.google.com with SMTP id t129-v6so16536719lff.3 for ; Mon, 14 May 2018 01:07:07 -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=n+mwPjgvTiqsvab6ujwt53MLo9UqrXzOtUygt62N/1E=; b=dLQ1MTbB2aFiv/xRDF/L3VWSR2uLF0ecuEcj39Bf2/Nc9jkzVQ+nud5a6AytDxPVCe nxHWrFzIxPz1Gcn0AWykc3y6YxiiBhr/EXvENUY9ACCGiJp9NeuDmsQGw4L+koHgRp8f 9yUgjN/UJycktwhpQ/nqzJfXkso17wSG89W5g= 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=n+mwPjgvTiqsvab6ujwt53MLo9UqrXzOtUygt62N/1E=; b=pcxmhFa0E1Tr3HgRaHFEhuag2NdEbg8mooA5xK2im6PO/9QgjquVeMV2MnK6BY7GwG R3dS8FNjNxVfJs1k/iHPjCWpbgU3G3AYaYU1jMl4P8GY7lTF7grCG4BA3kHjABxIjbXc XfQlSiGTNSOzs0O+Rk+iLsAQ07JSTWuW6LGyuOFTjjsGjiB4PXniAPZI3JY+HlXKTGjE cpYRgh4Jtqlgp/QEmzGH7yWYa8yui0JZ8BDNCEAYoUjWeFfF4XekCi82bDaFC00NXb2V df5W4/0ejWafxkikmQYUHoSNtLMMLuX/dMOzQ3VCmO92rz+N/0lsva6CVFi+qwJsKhAB Zzdg== X-Gm-Message-State: ALKqPweAMEzO2IyF+bj7v0P+O6bQ2CeNPAYG3DPqC9lE4RSJuNWDj+uj B842/o6MmGN+9ldFz60osk+iYA== X-Received: by 2002:a19:4310:: with SMTP id q16-v6mr7665589lfa.74.1526285226578; Mon, 14 May 2018 01:07:06 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:05 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 09/19 v3] regulator: pfuze100: Delete reference to ena_gpio Date: Mon, 14 May 2018 10:06:30 +0200 Message-Id: <20180514080640.12515-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/pfuze100-regulator.c | 1 - 1 file changed, 1 deletion(-) -- 2.17.0 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 Mon May 14 08:06: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: 135680 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1442041lji; Mon, 14 May 2018 01:10:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmqbUoygcg+H92YKEXdhjBzchcwVuilxP2wWyB94vPCaA98LQXQADDVHF2MZGZ+Lz2xVQy X-Received: by 2002:a65:5787:: with SMTP id b7-v6mr7724577pgr.130.1526285406363; Mon, 14 May 2018 01:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285406; cv=none; d=google.com; s=arc-20160816; b=yDNOY7KJB9GgNFjn70pd87lMzcfW4VNNXrqebE3wZoKibory1NkxsjBjIqPCpYj94r ESPgjAgc9x0PAjVwRfp6Rf8+mYBJBp6A8S2VS71/juu6EPRNnzn+YpqS+pHPOvCeseS7 uLkwiGP2Tfv5F1CgaSIf82r1MNJj3hlup8ZWHuB4vf3tZEPx+rhojaUNnHewiZbAMwzp mlZBAaLnCPGD7WnR4OOsUmoso5sbEPVxBgGiyffsKkDvGm8DcgdQFItwm9RqEUW0Gvn3 Q68kC9mVX2QaqwrY1phB8gUYbbSaI8u2HgcrwpObVziv/mActqEc6F3PLe/Cr7dfa0wm TuXg== 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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=WKet7c0z4eoSQTguDhyLR0QBP5rUCaDDBa/POfw3LE538OkA2DGBnhdFaiQGD8ChyG CqkYrH1YHEmFYHDcIWmsBV5VMctuQPgSjqMu0JxDKe0OGKJfQUwzbVLsG6thQEHX+mMc GN7Igq8DNh033Eb4yt07rTB2Dwy/TwnoXF9yGzhA+/MGiL1zd0Sb/WG8SB6YD0uXAdy7 gIGXRvVKp5o4LEEAXE/7VwpQCq/DnXU9Nces6o72dZpUdlZN6F64ARpo1CUOk8NdziUa eXaqtORcuFwBeCbPEiYUEBX8z8SXeyq9rxtai6zT4tYfRHpLWjWFGj0oy95irY1NhasD UJVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BrG13Vrx; 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 h65-v6si7376872pgc.357.2018.05.14.01.10.06; Mon, 14 May 2018 01:10:06 -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=BrG13Vrx; 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 S1752282AbeENIHU (ORCPT + 29 others); Mon, 14 May 2018 04:07:20 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:42388 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbeENIHK (ORCPT ); Mon, 14 May 2018 04:07:10 -0400 Received: by mail-lf0-f67.google.com with SMTP id b18-v6so15832780lfa.9 for ; Mon, 14 May 2018 01:07:10 -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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=BrG13Vrx4Wz3wE5+e+KRZ8CnaKc5M1AcN0PbeOh3tFHjbYrj2IdVjfS0u7GV6TJZvT YjKNokJTJ90s9IEBHUMmX2LL0QpGc5M+bzk1I74rE+uZ+tjG52miQOwY2eCgYMjASHZH YEtsX2pZpNp5PKJQoFb/DQN6oJuqTAJ/XYM/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=WYtGLxDWQ+JTsqLaXlUGBoVvAY9Ow6y7jbg6Rw93dlk=; b=THEpMMdTNkFQAQkhG0ORX6CaqsKGGEZXCeOghTGYsV3vxkEi6DKx0PqhujXwmBx2Ch rABihWMxwCq5esJQsuhamJEapTqxK0TZ+SonaQ9400DY61lK/Uf6x0N2f4G1IX/BqEBR jOL3Gj7KhdzcyhSk6RXmrX2OYtdn2RdNUMgaE0SaTAy5+APF/mnqX7Und8MeUVY3mWuV +Y8b+Lyybir+0yTdzYWhYNzuZvvA8ey9z6/MtrXvoE2DB90/HxE9Py5KffqVjmuDsT3N 0UEbQW3yBHV+mSRo5++amkAJa54wRwEE8G/+cJHMbTWr/s6KmOchki3yKouqxG6ynu5T 5clw== X-Gm-Message-State: ALKqPwcZji/70Wc0NAdJ+TDeNgin9lR1rj+mOzEbzpu4jJTFMkYOHFwG B0Hiz+WOqC/9XzxnGGWOaVqpCA== X-Received: by 2002:a19:b55a:: with SMTP id e87-v6mr7722734lff.54.1526285229274; Mon, 14 May 2018 01:07:09 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:07 -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/19 v3] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:31 +0200 Message-Id: <20180514080640.12515-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up 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 v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.17.0 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 Mon May 14 08:06: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: 135672 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439374lji; Mon, 14 May 2018 01:07:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoHRTNd09usmzNPy6p8uOLXEbMI/Igq+P/qfD9Fmby2K0HCNLpnMyQs4UvyzIRTUwqvvnaY X-Received: by 2002:a63:3147:: with SMTP id x68-v6mr7649746pgx.108.1526285239418; Mon, 14 May 2018 01:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285239; cv=none; d=google.com; s=arc-20160816; b=w36BvmE3wg9qY2wbgngkrW9bk73QVNokW0UhEVhYzL+6ybQQtDBI+vSTvlcsFZf4+1 PZP0rUHb0GVnRX3UCPa9Wt0cL3rXKQYhLxR4MTueFpN4G9sOZ4J6LtPNDTEwy0kpNsh4 ekBmmPfDN0lGV1N+gSRnkBzNxBf6mRWReni/c+DnGkH/K0xv+FeWvGFeyjN9NRJDCFxS yzGgOkOKlqsP5u3WzryrlqPajF2Jbzos4ht6XLWmaYmZhXTYGF/N8a35myRYYqb7spC9 ShIpIJnOaigUu5P4A8SVrIe4//atqMGBiHPXwW/nsl7DAssXr4X3BTQzvCejDXa1Rxuc D0gQ== 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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=GhOa3sFPfc7wqSvQL2lWz0m1Pr+F2IgEk/pXY1ussC/xiVna08iGdZI3a3PMllXgx+ Hj08UgcY4AJfhpQWuKG9oz4puMzXZsZxJoURi5fEwzCuyedZPwwPNIQgTPC+dQHf47yB yos3OGAxWQRYfcVD99h5Vcd3UAEDRRYZMgoDtiTk265/2qqgW/pl2mt+qs0796qg52eS SPk4bXH/qvojEMAJo9WaDYz8nGHMIFp/NZxOEH6Ik4e2nayCTt5jmrjB19ODvlTVh/YV oYCMwURD+kbfK8fFnHZ/sAaGqteFuVsFkG45OaH2UBr8sbqoBm+tNcW2QZMf+pcC8bG+ y+qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MnAmo37h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6-v6si8978027pfk.194.2018.05.14.01.07.19; Mon, 14 May 2018 01:07:19 -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=MnAmo37h; 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 S1752250AbeENIHQ (ORCPT + 29 others); Mon, 14 May 2018 04:07:16 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41495 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbeENIHN (ORCPT ); Mon, 14 May 2018 04:07:13 -0400 Received: by mail-lf0-f67.google.com with SMTP id m17-v6so11388444lfj.8 for ; Mon, 14 May 2018 01:07: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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=MnAmo37hC/kkWYOfvZ3NvEpcLCsgZZcwToTCB1CmmRUOHbhHDNy2nWkxZUpeaW04ls ilU1Oz7VPbAfjdRmwlvyWsiwUNyeaJxwitRD30LekiH60ONzlXk/tVUKEUgIZWRtHn+x OKdC4kjDH0GRfQITiOLTQwACHOndeKPY8DVNk= 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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=MmfEhY3vatGU+JrCVZ1Z59/w0+nEz9baw8tr/VTnDo83UpfxLBlBIH6gcs6k6iwBmg GRrj8VvUuepn9x1Bc4S1TsaEFsBm7jOpaaN5YYl6vIsxY52YhDv9KNLXsZV0wxXBO5Bs TFlbyWlC8/9Syp6HuNR9P52uhJHGZv1rcPYat2JBR65qwpvE7D89tCITKtLS3+ncdPPH U5cP+v3XTU9/Vu5embspv/mtwoA4TSJlHAiZB8/q1XJZ4d2qJoFEExLZ6oLN5lrMEUik daveXyOswEzA/bwnRAgwSPhro+yX01MMI/r370xAkI2udEdTLlOxbiwftgAKx2wRjVSb xrvw== X-Gm-Message-State: ALKqPweNFjkHBsmHouTqXz94xn6erIhyLNth6Rc+Kmaj4S+L+Gng6yO9 U3FQEwlk5uMNtrw2eYWpveyfzw== X-Received: by 2002:a19:63d7:: with SMTP id v84-v6mr8149767lfi.57.1526285231708; Mon, 14 May 2018 01:07:11 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:10 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 11/19 v3] regulator: s5m8767: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:32 +0200 Message-Id: <20180514080640.12515-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135682 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1443074lji; Mon, 14 May 2018 01:11:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZovbITxCJJAMPXvmr1vjs9oAtX6hpLR5hJFuqKlq0pun3KKb0vaxLAp4E7lV9e4yN42t9+z X-Received: by 2002:a65:5b8e:: with SMTP id i14-v6mr7740378pgr.352.1526285469380; Mon, 14 May 2018 01:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285469; cv=none; d=google.com; s=arc-20160816; b=A/Fmk8OxG43VIQii+Ipta/bJ2U7OTYawpFa6eQFGbwN8QVyLwFw/JvL6Jqy8/998fL nz4NLEQ/w1/14vzykn2IwHjpyXVlZOtRTHQfAlU8l0dm2rECSa7nl5aDS311ua5CnPUs KcbKXxtlTL3Xda9bVe5D/RF4xc71hv/96kSSllcWkOGO0uesAJ5SyWuWA9zSE+v/j5aA R/SxdGTq9P9Lo2gtydfCD4wiqSwA/+TABvG9ow4yYXQUQkCKdSp8ZcCznlMEpknQioaf ZfGSe4oyBUJkJ9cqstrKv67oOcQD3ffw/nOtFJOiLAR9kjzIAEQ7WE9aySSxamvG6I2T HJzw== 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=ttlgodo/0t7qIpnc2skubxKgJENhJJNr4mwPZICnA50=; b=p082DonbHdjF0uJHWUFOwOAxMSu4n16MA5EK2BWbzvBFSoR3jao1ouUSh1yjFThMET c/Ia+xlV2N09vDcHHg20p59GoKviH0/elzTWs/kZdqdCndMYQOIEPvOdF0CSlHk+NDkJ dprzbdYNyBRwd+RVx0fFtQMXE7KczkRwozz/QGhNg6vSLP6syFzSLo1hdayatmP/kjbx mf8+k4GAT/l4dOfFNXGBLdcnPZY9OJ0b1Mcxo+PGVk29iR4tnhWaJ3m1dWPAqH8D+Mu3 IFf6ATnhvXj88Uo9LZ7C9Tk+y30+YBGEeOfMWb7gFNoRsbqjlGP7sNmY4gxWVwhFWRcE SVDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jz3Lpcg2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y25-v6si8784004pfn.248.2018.05.14.01.11.09; Mon, 14 May 2018 01:11:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jz3Lpcg2; 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 S1752572AbeENILE (ORCPT + 29 others); Mon, 14 May 2018 04:11:04 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:32818 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbeENIHP (ORCPT ); Mon, 14 May 2018 04:07:15 -0400 Received: by mail-lf0-f68.google.com with SMTP id h9-v6so15560264lfi.0 for ; Mon, 14 May 2018 01:07: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=ttlgodo/0t7qIpnc2skubxKgJENhJJNr4mwPZICnA50=; b=jz3Lpcg2bSZP58fMauzhhFHmNDbaDmiL6ceBZM+7Coa83hmnzKcLxYYUSvb8sMGCFp n1cEzGHEGgtQZ5tnOUIiZp33IJCqlHjj+/ynO6H9lV6/XiM6xzbcoALLJd6hWagler6I F3iywUfoTTnzi589F/InUA142QR0Q3dOzPfjQ= 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=ttlgodo/0t7qIpnc2skubxKgJENhJJNr4mwPZICnA50=; b=H6srX1sBtwrdCvY8oincrAotb3RgS7xCO+qhWyTbP58nscmWgkN/nbzeJloR649xTg FThie7cIH6c8seKDsMnYmUMue5emdYtJfENP3Xd+VaJYgYq4Ud/X3ss+AfJakZyBTIe7 QtDR8hT3/ncurqQaenwTE5VNrBLNMOcznw2+rSsSWdaR2q4Idd/tdmclb7FKNAHVVX4r sjsWnK6IM3dpHAe6kjy56Mo34q79TghU7XG2LCQ4fLWJfafbhL0h+ZoT/JZMM21TxaMW gX4U0MbgQ6SG7zmJ1MZqfHGzM6Vha09CXXclyYBPwOpYFC9H11L/xeMH9qEZoxZCi0mC EmGg== X-Gm-Message-State: ALKqPwd5NkoCC4GeNIFtDjQ3dcFkVrOGepPFNXwjlNgOUmsaoaC8O5q2 rbkcBq+DK8KFS3BY3ZfAt2/uwj1CSgg= X-Received: by 2002:a19:4ed1:: with SMTP id u78-v6mr7650333lfk.40.1526285234125; Mon, 14 May 2018 01:07:14 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:12 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 12/19 v3] regulator: tps65090: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:33 +0200 Message-Id: <20180514080640.12515-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135683 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1443332lji; Mon, 14 May 2018 01:11:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqn8Xcx47w3jMqV33VAv0NRbF1CmzjE1RQvVTHJlL8QHjaABof98tctXWHPjBAcbrHCIrrP X-Received: by 2002:a62:404f:: with SMTP id n76-v6mr9413704pfa.185.1526285484248; Mon, 14 May 2018 01:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285484; cv=none; d=google.com; s=arc-20160816; b=vzOhdAUoZmtMdXlRrD8ind5OJfXl11GyhfYKs4i/QNJV5IIs/ttZCJWHD0xQu8fTue /EzCmliTP00nOAPHNfLKd5qzPY3EX6aw+BUJuvGCtJ/DRx6ftUQ9rosjE98Eo9R9pAXp qF5DmIbq005JYLM1Rt3l6yJ7k3mnce2+1PugjGOIdLJ0PpmneTxKw15/KS80dxVIOcPw 0JEjaR8Cr1T1YEXVBBSMwr4i0Vo6/3yOIYo8rqBitCyD7x3EjXQmm6GtAN49jDTJSO1M bV5qjwbjMIY9JVTuGd1a8J0NDXXv1nHz/DFtSC7LTMPKhHat2AYOtgdOnO5xpPDb+wXR Pk5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=pezU7BEkNno0IzV+rKX+6wWo3O0ubp9Dmo6NhTUNL5Fqy/RF5azze4q0UIJMIotDmy i9uqSJct5tw9U/03OJtkHHfapI8jOn5CxkA1HPrQOtEle2KNgBTK/CX1Te9mxdGmFcOA 24ZdzwAHYFVcCJvtHmszxmMY9NLTrtZCQaM+vetY2ks/BHHvOzHvoR/Jpq6ZaIp0wccO +3lrARsXxqGQYhkEkAtmQvA8xalKVQHLdlKOyBNMsF9mXLcPvOv2rjv4LxmDAKpC1GQB STiYc5Tr/3Vr38KcXjIGafe+EFMt1NpB9BEVxSF8yHqTEMldZaUgoAWLYQlc4bm6Bq9X aWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kh1lpMc6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y25-v6si8784004pfn.248.2018.05.14.01.11.23; Mon, 14 May 2018 01:11:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kh1lpMc6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbeENILC (ORCPT + 29 others); Mon, 14 May 2018 04:11:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:41504 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752251AbeENIHS (ORCPT ); Mon, 14 May 2018 04:07:18 -0400 Received: by mail-lf0-f66.google.com with SMTP id m17-v6so11388783lfj.8 for ; Mon, 14 May 2018 01:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=kh1lpMc6UwxKJdX8omRFQqGkoaop9lMNQFohe1AVvbPT51aWgtB5mfQNo80tuPbeCe gBl6NXSlqMQKM2ZhhGVtIDRjlRqvsB2ss+OSOcp44KvbnOqZnYbMTtIJp1oa1P1EV6bK geX/zLRKBltQ0LpdgJKiUVaKn2TNdODQY4H+Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0jMIdzcK8DJht+7X6feguInt7MovcAl/qLhDSVoNlGI=; b=s09mHKpHxI33MuNkG+Lgz4PrhFEfqBcSMCdxnlRVxmmpF61zc2pdSw7Xv+tyXl/kb1 fwpn82C0EoXpYTfdOoEUzRDMXQpzPUPHgswg+eDPzaH2yIMil4UHpbxx/675uRz1GMG5 erq/B9AWvXVodtQ/jU8otK+tfldsbRt1DTsMs/HNzAq5mQwPID5dPMYrZRXMs2dP9Z9G e96Z9VZRQXMW9bmD1Vgc2s6zJlU9IH4IUHI6sF0UOxenvD5iCcTyiujGK66Z0pz0FPlm op6lzS2o81J06vQAGyQcwIM83xAbl4KFxOyKCHEGGLYo2+HCMHJMEFJLxOSklCQ96S8z srzg== X-Gm-Message-State: ALKqPwf6ljiEi2pH+1R7Q/DccJla/yqD9RxV9LsuRg48XpDvdw4dq7fS CH2Q7x7++Y+oislFr28ISVXvWg== X-Received: by 2002:a19:6d02:: with SMTP id i2-v6mr8195999lfc.81.1526285236391; Mon, 14 May 2018 01:07:16 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:15 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , patches@opensource.cirrus.com Subject: [PATCH 13/19 v3] regulator: wm8994: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:34 +0200 Message-Id: <20180514080640.12515-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up from the device tree node or the board file decriptor table for the regulator. There is a single board file passing the GPIOs for LDO1 and LDO2 through platform data, so augment this to pass descriptors associated with the i2c device as well. The special GPIO enable DT property for the enable GPIO is nonstandard but this was accomodated in commit 6a537d48461deacc57c07ed86d9915e5aa4b3539 "gpio: of: Support regulator nonstandard GPIO properties". Cc: patches@opensource.cirrus.com Acked-by: Charles Keepax Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Collect Charles' ACK. ChangeLog v1->v2: - Rebase the patch on the other changes. - Collect Lee's ACK. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 17 +++++++++++++++-- drivers/mfd/wm8994-core.c | 9 --------- drivers/regulator/wm8994-regulator.c | 19 +++++++++++-------- include/linux/mfd/wm8994/pdata.h | 3 --- 4 files changed, 26 insertions(+), 22 deletions(-) -- 2.17.0 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 5aa472892465..76c4855a03bc 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -194,8 +194,8 @@ static struct wm8994_pdata wm8994_pdata = { 0x3, /* IRQ out, active high, CMOS */ }, .ldo = { - { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, - { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, + { .init_data = &wm8994_ldo1, }, + { .init_data = &wm8994_ldo2, }, }, }; @@ -203,6 +203,18 @@ static const struct i2c_board_info wm1277_devs[] = { { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ .platform_data = &wm8994_pdata, .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, + .dev_name = "wm8958", + }, +}; + +static struct gpiod_lookup_table wm8994_gpiod_table = { + .dev_id = "i2c-wm8958", /* I2C device name */ + .table = { + GPIO_LOOKUP("GPION", 6, + "wlf,ldo1ena", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("GPION", 4, + "wlf,ldo2ena", GPIO_ACTIVE_HIGH), + { }, }, }; @@ -381,6 +393,7 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, gpiod_add_lookup_table(&wm5102_reva_gpiod_table); gpiod_add_lookup_table(&wm5102_gpiod_table); + gpiod_add_lookup_table(&wm8994_gpiod_table); if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 953d0790ffd5..c409464231f6 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -302,14 +301,6 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) if (of_find_property(np, "wlf,ldoena-always-driven", NULL)) pdata->lineout2fb = true; - pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0); - if (pdata->ldo[0].enable < 0) - pdata->ldo[0].enable = 0; - - pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0); - if (pdata->ldo[1].enable < 0) - pdata->ldo[1].enable = 0; - return 0; } #else diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 7a4ce6df4f22..d3a5f48119c2 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -129,6 +129,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) int id = pdev->id % ARRAY_SIZE(pdata->ldo); struct regulator_config config = { }; struct wm8994_ldo *ldo; + struct gpio_desc *gpiod; int ret; dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); @@ -145,12 +146,14 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - if (pdata) { - config.ena_gpio = pdata->ldo[id].enable; - } else if (wm8994->dev->of_node) { - config.ena_gpio = wm8994->pdata.ldo[id].enable; - config.ena_gpio_initialized = true; - } + + /* Look up LDO enable GPIO from the parent device node */ + gpiod = devm_gpiod_get_optional(pdev->dev.parent, + id ? "wlf,ldo2ena" : "wlf,ldo1ena", + GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + config.ena_gpiod = gpiod; /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { @@ -159,7 +162,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev) ldo->init_data = wm8994_ldo_default[id]; ldo->init_data.consumer_supplies = &ldo->supply; - if (!config.ena_gpio) + if (!gpiod) ldo->init_data.constraints.valid_ops_mask = 0; } else { ldo->init_data = *pdata->ldo[id].init_data; diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index 90c60524a496..fca67bd194e2 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -20,9 +20,6 @@ #define WM8994_NUM_AIF 3 struct wm8994_ldo_pdata { - /** GPIOs to enable regulator, 0 or less if not available */ - int enable; - const struct regulator_init_data *init_data; }; From patchwork Mon May 14 08:06: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: 135681 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1442107lji; Mon, 14 May 2018 01:10:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrKCndS1YhEJLW9gDyt3HYoDjwUaxvApXgqPt/v5jrvW9q7T3m4LAM08mO2RPO7RUDUE/A2 X-Received: by 2002:a17:902:bb83:: with SMTP id m3-v6mr8833303pls.236.1526285409291; Mon, 14 May 2018 01:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285409; cv=none; d=google.com; s=arc-20160816; b=gcpoUqXUKjhb/pm58l9i8thuFrkYNdr1TmJ3xCNII1EeqXlt16vimdR/JejVnVqWdi ir2WsRM4C8la12vQIwg3lR/tCC67E72YoS4RvoRVe8NNO8mXc/ngvb/wsyfcrWnk4crI IgRMOMIUTpaR5Y4vx6/lTgCaau3P6L7hZzL1M63uW8BCJNqFZJJyp4GvgMP5PzegY68n cMdXGykQ8Wko/g7oG8mIAszaEpCnrLQbYbmnO9vBxSXizq0UdYiYlTTRDOReYAF7tLD/ aIyHoyD+dCu5SrEKrlSpdlBiJi+MXUms2lil75/GH9l0adeFHbuc/gH1QR9JhU6Vv1+Z ai0A== 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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=u6JhT39IUl5pb545yzSC2Y8k5j0KDSoprPwiBEPFiItwkIsmkhMruJ3a1Wkcue8ip0 C6qO5+hFvUq5Z+tRhbDBpnnldjVxjmbKyllYKFttFoVV0tAH6w/y9K9vNUj0jRZVj4kH eZEfL3mYZr5Yo55+LTQArbmyqCkH9YCqEf+kafEqPlZ6IbybnF3lnetg0GlX4YaHPYVB ZJm+tRI7v+5KMkZapbrAeQzhqh/5x2ANsNLr783XtOmsSd3vD7JVHDUnoLZms8M7yiGn BxlwgkGsvUKg8mDJsduw4Olk0H7Ni3Smh9K1lI4u/SK50VnoPzpU4GX05bawMv/Zxjwa G1Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MxjuDmZp; 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 h65-v6si7376872pgc.357.2018.05.14.01.10.09; Mon, 14 May 2018 01:10:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MxjuDmZp; 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 S1752537AbeENIKE (ORCPT + 29 others); Mon, 14 May 2018 04:10:04 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:32830 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbeENIHU (ORCPT ); Mon, 14 May 2018 04:07:20 -0400 Received: by mail-lf0-f66.google.com with SMTP id h9-v6so15560619lfi.0 for ; Mon, 14 May 2018 01:07:19 -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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=MxjuDmZpP9P8q21gM8efyaMazHNNTq+Zqqo355Gop0PDr6DezVPc7n/qPNaKLCJFTf b507kWBVYTe3OYCLq7dSzpsT47kIh27WEVO+lEbS3/5iPQRZkip9+Vqa9FN/9iAuH5A5 Upsz7AxtJA9u6j44t/xgGZIomU1/uOHO+sn3w= 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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=WgKUIOn3bVu9bxd3ixHe+teFe0nEvk47uN5TjJKpX3tw4M5+myyRLyxT04jVL3VJNc +LAG52O5BKWzwAjVKaeeAdC6ml+iXSrrDnwT+1ygOiCJiqYWs2Pp8CXRFTVP24fH9cVD gbLLbuj0fC5ng7gHxZJFSCgzsnotSia/5SNCj92DGcCrVGjYbo+sWfaSMw0vUAFLnSGY HMKNkXyQBgwcJ3LbB49ksLcgRMQgSA8dXIaWzwVjImlV9Stto6rlzz2HRaKspYlH9WBX X0ZETQyClCBSfhugaoVcM3Lt1l+ifOVtfQhPyOhncG7+OuF05hN7JU2x+k5/iUIAn1ga vVsA== X-Gm-Message-State: ALKqPwcu4WI+k8kd2KEDKWCibJ2ehXhJ2/I1P7TYGIJCOXOTatIzDaSO HfcgbxdzuHo9+BsLSR4RePzA/g== X-Received: by 2002:a19:ea48:: with SMTP id i69-v6mr3961766lfh.118.1526285238891; Mon, 14 May 2018 01:07:18 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:17 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 14/19 v3] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 14 May 2018 10:06:35 +0200 Message-Id: <20180514080640.12515-15-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135679 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1441292lji; Mon, 14 May 2018 01:09:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrjO2seiWgABCDLAqfd6KF+pudeNBl2J+AEBiqVVYwquQh0Cs6MMKitV+gElDpApWr37JQb X-Received: by 2002:a65:4acc:: with SMTP id c12-v6mr7557464pgu.329.1526285356340; Mon, 14 May 2018 01:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285356; cv=none; d=google.com; s=arc-20160816; b=uhpx5gbfTP9P/HjQBCYMi9jZK63koaGNZx6OjDIxnfr5X+616MIJfLXq9F+LA/+8NT e3T6bDaxsHHcJoahQ7EWd0SoA+HvNEfWYaG2S1WBSCja2YqOy4WWXQhb1FB4znbG/qmb VNSQTPLRbtCrnp19mzBUrMfGxl9appjofMIjFfayuO0Ry8dvlSTWZMO8LnEGTd80s5nu LESTYumgZY4mOMpFEMQh+VZUZ5aA3cKS9D9gSQhG2LP0ej1zWhpr0MuaCyU3NNzQxHZb aA52ACroH78+jIzSXOKnQrZ9BdwaUZSAehdj9NZltgkchLSvP+tk0Y4+x1Merr0vEeHg TX+Q== 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=1tvHfvIdnYFLAvXii2FXiAxDv9QUCjGhkP6gJ4UmFSU=; b=ax6v1YgWa0Gu0YS/qD81xDqQ+YJt5KXYXs+JyRHEjwJPeTgMngkduTQke0uepHXd+Y RnA+MP1pueVo8k5tgJ7CXBm2WxNjx4cLv4nM9lvRUFZfeKYNk4VEFAKGTDZI5JTI9QBt CsxR0zaPjVB18O2pBo8dQo/Y5ZZPvGFcb6g2Kk6Hl3ClhUj/Ut/XViDw6913tT3GjoUR Mdfox7c0WIa0dOTtYWvC5dOcW6HWiHL0XLGM7OZ28mEL7nElP/C+WMuge2Anrazj7QVm 4k+NjCWGeRz+q2G0L5cpdFq4NgNZyLSmF5k1Kvhy8agNDOIMoqqPlMJZ9Gwn+9Q5BQuX d83Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jxez6M+J; 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 a64-v6si9136181pla.530.2018.05.14.01.09.16; Mon, 14 May 2018 01:09:16 -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=jxez6M+J; 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 S1752510AbeENIJM (ORCPT + 29 others); Mon, 14 May 2018 04:09:12 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35254 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbeENIHX (ORCPT ); Mon, 14 May 2018 04:07:23 -0400 Received: by mail-lf0-f67.google.com with SMTP id y72-v6so16532835lfd.2 for ; Mon, 14 May 2018 01:07: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=1tvHfvIdnYFLAvXii2FXiAxDv9QUCjGhkP6gJ4UmFSU=; b=jxez6M+JTGDRVihAxFc18/U1cbaXYogvm03qmXf/AGZieoU3CKdCoK7w1/htdpFrib GWZeohEkogjH1eFz566HQIQUOj4MxSAj2UI8wHRbbWnfxj4BGxa7/autoQtlPkaeWMGL iS8YOD5wbknQYEbU0Fv/ADUEfo/bztP7e2fOA= 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=1tvHfvIdnYFLAvXii2FXiAxDv9QUCjGhkP6gJ4UmFSU=; b=WoFVnhTVLttIdN4KzYLUbZRhjrg1CFhkXJI5dWZyRzqmVf1hh8zlhDrVJUIpYIMTCS yU5iyAjaaA96M6ogF57+3LFdjDk/L3VUqrk27XV23+v6N8lRI4sR3DmC7rDAg1ZbxCSf CrX+4coODWY8cfNjpR5UKxRXd5Fxzfd+nlVeE04SpxDaSaFdNKrIXY2j/bqZGZRfB/mT gxORNtoCXO/pYCvjxscHQwZ3iwfEWoi6y1jAiZxcscS7UhD/c7g4vjxnwzbI9iUzpVlv ag77uI8yDGKXnFtauYXnrqssezyT8eHiCjrRaXSPLyp7Dq5GL4mQeFJplThJGQxiHKqM YZVw== X-Gm-Message-State: ALKqPwdTNR5PsWPLNjDdK2wWFuAey4C7ZgncP61QyBK6jbsZz3FyBKQh I6Aq41vrA5aqqljIbsiQ5/oconSIbd8= X-Received: by 2002:a19:1186:: with SMTP id 6-v6mr8207870lfr.134.1526285241471; Mon, 14 May 2018 01:07:21 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:20 -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/19 v3] regulator: fixed/gpio: Pull inversion/OD into gpiolib Date: Mon, 14 May 2018 10:06:36 +0200 Message-Id: <20180514080640.12515-16-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135674 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439624lji; Mon, 14 May 2018 01:07:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZog4TYb9y2MimfCyBUQsQ3ogIlpLXcR3Dj25mUmpz3e2rdd81S7kp53YNHQ+d3Zix1s+WqZ X-Received: by 2002:a17:902:bc4a:: with SMTP id t10-v6mr8791313plz.343.1526285254137; Mon, 14 May 2018 01:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285254; cv=none; d=google.com; s=arc-20160816; b=vlIq5gqOjXk/03rObDX9LraLzTcwjgnkda9nTOxJgtTQuE3HUsXq1qU+2m3YaIb6WE M4akr+I2Cj4Hmmst31oFwRsgTlloKoWeHhQkb8yYpFh9/oyEBQakTxEP7fdq+0mQ2qSq idKkLMUzhJm8Xzq57gvP1w8m/KMXTOB1cFKIdSeGLMecQN6CHCjYnk2eF2vBPUw/ypRC hPzSMsxBOyA2w0sdHyPkWVlnsYugPAcGF9nYBzRnX3ZmCv+P7jftdSdd2Jhm2Wh/2zb7 dBoS3C4hBZc8x0HyhiIpcLhB4v+6/6ylb+wtH/fu4pLFEbYVJWnmcmWBE3GMNweW3pIr 074g== 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=NW0KBA/srjrUv7rN/huGBF7G0waKkWJrGeIm8NKkJ2s=; b=pPwDPujblWHIBEeXBbYkVShe2ODBmOkmq/Tr/v2dy+222OotiM3U279sL+AbbS0wQz 99oI+S3jAPTczij63rgBXWI+taTatN31AOiXKDzWQIxohJF7WEwburqN3U0W7jWAn1QC EgWKW4O+RNX5o2yORAIlqwvTBCPSDcAQte5Y0wXwle9ebpY6E+rO6lxaHisiYNAoVx12 l2mctqZ1oiq50sF05hqxOx2Sw7XEF4IApIWHHxV9MrJ/3ohPqYFuh5Nep1uPChlwS39G P5ab/jnXpOn4Oi6Ggwe1qmYT5tbDC1tbzQwx4IiC3RDTwXAbIZxwpwuyRNQObBCLwsdk /2GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OWLOfwQ3; 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 m198-v6si6785758pga.107.2018.05.14.01.07.33; Mon, 14 May 2018 01:07:34 -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=OWLOfwQ3; 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 S1752368AbeENIHa (ORCPT + 29 others); Mon, 14 May 2018 04:07:30 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:37540 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752328AbeENIHZ (ORCPT ); Mon, 14 May 2018 04:07:25 -0400 Received: by mail-lf0-f66.google.com with SMTP id r2-v6so16558316lff.4 for ; Mon, 14 May 2018 01:07:24 -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=NW0KBA/srjrUv7rN/huGBF7G0waKkWJrGeIm8NKkJ2s=; b=OWLOfwQ3i3o64DziXYnewYOy3VeJSyFOWtEypLg9pkajut3T5i3uXomkqTZMUOvL3r WLUYwJrWLcDjqGcK6Fw4VztRdgaURaGmUdFsoEnqUaNdtgNAQvRi/Tr0PbQn7zkvBrzl y7ZPJ7cCDkG/Hv5A4+9bU2x9xrSIrAliwkthk= 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=NW0KBA/srjrUv7rN/huGBF7G0waKkWJrGeIm8NKkJ2s=; b=uGD6GmblAnvf6O0laYHBMRrUgZn7YVIo+esYFU2NSHpldXnn6l1wisEL0l31L5qmLL OKamrO3fKRqihr4AbuAedFNP47fQ6DDcFnq5YSGMQXad8PH80hGh7J146Vq36kL/Vdyh NAA+lmjWkTch+Ym4KFW4tdxytjB+x0x7dm5RBO87k4D6yNCib7cIualMXwnlGK08lLUg ZRmcD+a26CQRVUmGDYL5803IjqF5KMkgap+cCRfUFG1gT6aPsflsydlX2EA6zaOaermr TkuTVJDyVodjvpim27PVmY1mdi/I+zxeudHnHXULpF96iGCrWF7NM1vtSN0WNvyZXMdO sxnA== X-Gm-Message-State: ALKqPwckqURmAoHQPpwucm7Zz4OrgNloR94r2x5wLqi4aV+jQrUKorF6 eSwJ2cvEOmEf2u65mHUtbjTV3vfrB40= X-Received: by 2002:a19:4d04:: with SMTP id a4-v6mr7056662lfb.99.1526285243731; Mon, 14 May 2018 01:07:23 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:22 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 16/19 v3] regulator: fixed/gpio: Update device tree bindings Date: Mon, 14 May 2018 10:06:37 +0200 Message-Id: <20180514080640.12515-17-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Deprecate the open drain binding for fixed regulator and indicate that we prefer this to be passed in the GPIO phandle flags. Clarify that the line inversion semantics for fixed and GPIO regulators completely overrides the active low flags in the phandle flags. Unfortunately this can not be changed to prefer that we pass the flags in the phandle: the bindings have been specified and deployed such that the presence/absence of this flag and only that controls the line inversion semantics. The crucial semantic is that the absence of the flag means the core will assume the line is active low, which in GPIO terms is an exception, as GPIO lines are normally assumed to be active high. This special device tree semantic cannot be changed without introducing a whole new compatible string for the fixed and GPIO regulators, so we just contain the situation. Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Collect Rob's ACK. --- .../bindings/regulator/fixed-regulator.txt | 13 +++++++++++-- .../bindings/regulator/gpio-regulator.txt | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) -- 2.17.0 diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt index 0c2a6c8a1536..a7a1cd0dfa6e 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt @@ -8,10 +8,19 @@ Optional properties: - gpio: gpio to use for enable control - startup-delay-us: startup time in microseconds - enable-active-high: Polarity of GPIO is Active high -If this property is missing, the default assumed is Active low. + If this property is missing, the default assumed is Active low. + If the phandle flags to the GPIO handle also flag the line as active + low or high, that will be ignored for fixed regulators and the + presence or absence of this flag solely controls the inversion + semantics. +-vin-supply: Input supply name. + +Deprecated properties: - gpio-open-drain: GPIO is open drain type. If this property is missing then default assumption is false. --vin-supply: Input supply name. + Do not use this property in new device trees: instead use the + phandle flag to indicate to the GPIO provider that the line + should be handled as open drain. Any property defined as part of the core regulator binding, defined in regulator.txt, can also be used. diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt index 1f496159e2bb..8fef3e5358a2 100644 --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt @@ -14,6 +14,10 @@ Optional properties: defualt is LOW if nothing is specified. - startup-delay-us : Startup time in microseconds. - enable-active-high : Polarity of GPIO is active high (default is low). + If the phandle flags to the GPIO handle also flag the line as + active low or high, that will be ignored for fixed regulators + and the presence or absence of this flag solely controls the + inversion semantics. - regulator-type : Specifies what is being regulated, must be either "voltage" or "current", defaults to voltage. From patchwork Mon May 14 08:06: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: 135677 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1440816lji; Mon, 14 May 2018 01:08:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbL2xHSQLsp86GQ0SbQfV6ggT96CSS5T/4P3qxZ5uQThqF8byrPAEWKk3y9F69aHmgH2r6 X-Received: by 2002:a65:65c4:: with SMTP id y4-v6mr7529207pgv.369.1526285326475; Mon, 14 May 2018 01:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285326; cv=none; d=google.com; s=arc-20160816; b=hYDsI7e4g+5oxSt9CW5eMI5CW5URJfWm+Rx51YuGw8d53DbZ3TMgaQ8QVgVnaI1qbB eO1btsMnAwVGCd2DkngVyiAnOKX+gy/zG+I81xqTGCAAXQ9e6K9d7ogn3HmPqtdyXDJg mFUqCW2CpcbNMKt4ucBRK1dFJIJPzuEO4moFPye9Xu1rDA7qe0es9bnFgLfJoNxU3Gtr 5QBNXVXYIZYlSQ2GelxhyAlT8J+Dm8dyE7c109I3m1cekFru/TvYwNAt90cjiwCjoKLX 2fsKGYndjm++ubttPCs5zwHKGYktDX/KwC8F/xS5w5dDzqJvREEoemIrKi6DAvp2a6l1 MjIA== 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=svKS+Kx+Us5i/bqzg98uEZKUETJVQyP3Zo+k1ETmEVQ=; b=ktfK2zraDisdYj31daYSXFTSHbFGjXorWS34HSzHoMROr+myp+wuXU54+cdwv9NfSv WPWWbZN5nI8bbefZpWXdbBiSqW9kTrMyZ781m7zXQi1+I139fmKw6dNK8tinVJV4vbfa V3u/i8e9WRZtibrb27woxUjSR0IOldvvMDSpUK/DCAjk0zwMV+KuBBB1tnKz07dxP5tX NVf8eRYbZorXYyVLCuWnrEC4eYO/HVVEl1MswJ7Ijs8CpyHs40L/kMTD8Y9NeYl40GCU zAo53a+Aapo08zwmDsvkDDI4qWGBsQqXLlMOeX0BzwNZXq6oqWsZ0oUPjBIm33SuXjFt PguA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ICGtcQQU; 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 p67-v6si8815667pfp.72.2018.05.14.01.08.46; Mon, 14 May 2018 01:08:46 -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=ICGtcQQU; 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 S1752479AbeENIIm (ORCPT + 29 others); Mon, 14 May 2018 04:08:42 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:42435 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752346AbeENIH2 (ORCPT ); Mon, 14 May 2018 04:07:28 -0400 Received: by mail-lf0-f66.google.com with SMTP id b18-v6so15833986lfa.9 for ; Mon, 14 May 2018 01:07:27 -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=svKS+Kx+Us5i/bqzg98uEZKUETJVQyP3Zo+k1ETmEVQ=; b=ICGtcQQUnN6pfYiMti/A4qZI6Ip1fOYU+Db3yLB07+S26sulMeEEP4vaThBoYco1RH VXkq/FNQ+gEwKZChP5rp3Lkc4dHXTRd7V2McwHcGWcRhR8rLm+HzF8cMHB8W72h7L9Yo tqwILkDvrldNftQEXjeb1MmdeH6o5xSg9yCd0= 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=svKS+Kx+Us5i/bqzg98uEZKUETJVQyP3Zo+k1ETmEVQ=; b=sxqP61+QKzLgT/rwNjRpKHKvG0XJ5CVwKhFZ2WdemXuJ8/jqD7jecUdG/X76lhTGRT rGQtPimr5AnZxVqD0jNXLkSGIg31yxfLypYJx/5XuTNA/3CtfHOQ+FVtTN3iMunchimK PCkA6r0MbWyRwRHMr/UhO4wvQKftG62wK0Zks2F4vJmiveNJcmS24SZr4hchOEUJtjj4 r1/w00jhSoHPDZu4QykEkTXD+DjHR5DDxpUZs0yUSAqIr5CjTiK0ggN7ViFqqmjEE9Kq wG9Lta08kPtqKZ+oT9Hw581aN0Cf9VDzNKTuKvEhJlcm5OsbzL1dU5wOPGTr9K+mFb2z 3AMQ== X-Gm-Message-State: ALKqPwekUCM0wW6OQE7eh5OcI0WPyiO6CAAZzNowY/18cooellORkebg nHEx4bSxGFjla/UTNW5RlC4u/w== X-Received: by 2002:a2e:87d8:: with SMTP id v24-v6mr3811853ljj.69.1526285246844; Mon, 14 May 2018 01:07:26 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:25 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 17/19 v3] regulator: gpio: Convert to fully use descriptors Date: Mon, 14 May 2018 10:06:38 +0200 Message-Id: <20180514080640.12515-18-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. 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.17.0 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 Mon May 14 08:06: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: 135675 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439734lji; Mon, 14 May 2018 01:07:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr48oeNStVK8KUI5caT94W+Is8KGCP5qa6RSEr4Qi6i0iu6yyME+77UYdhMwfmuGSLNARGA X-Received: by 2002:a62:18d6:: with SMTP id 205-v6mr9396141pfy.242.1526285262158; Mon, 14 May 2018 01:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285262; cv=none; d=google.com; s=arc-20160816; b=vMd7fPU4eLZu7g9S77lZbqdwt5LVGW/vjxMQquv2FBdhsu+lkmSXksBdqN8wfa58ad 4+ZWeTwhUWgoQb5J2xxpSe4d5y6kS/Gr4tY6/RIAkFCXGPm6xehrOZ4kGDe/lqze1eVF ium16AHXxwuGDMOW1Pv5OJb9gIKNR5B5XLdlZ3yIllYB1H13ADpnpsm7a98MvHnd4Mj8 qfAi2CsfhXKkOXgFzpqNtUS5iwa+8oLgUzRLLFPggg/ULMgBWVR8+1UYr3FhzJUHb2uv 6Ms+y1T/B5csntrCB39/0xnxHf9f36bMtlN8D6x1x5Td468BbzDKrcYtXS/eAJocvIlH uhrA== 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=w5DFBrZwEmLY1hlKVjmpTyntGWY4PBnErlDD98AIvv8=; b=fUPWlD2tKRflZUjf+eDeIYD9inPQUboxl16ScGaSGYiYUAcclVLpdZMCyWV7Rwt3Ba +rIqw0+xq5y41lYpipF89aRcmo/EiVNHb6CZ4HFaQJZWAIvXyYYh70jL2l+Ll8L2CT9S xCSjzJWzxRUbjKxmr8PfHcTN0Cmkdn7n2FAT7AeT2sF4ZCfjpo8vtboDZbHNf39OicH/ vMPjItJ2v5sQfksoowTekhD7ASD89dZ40YBds5iYgsrQHTp+gVuPvurTRx4d0YrVRoRP YqrPJX1qXNB/S8JHoGpfoOlexKYaqXs0V7y3slpUTSDHszD0T4X/RC9jnjPGB5ADGeGJ rbVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IrjPIKxn; 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 b8-v6si2014958ple.469.2018.05.14.01.07.41; Mon, 14 May 2018 01:07:42 -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=IrjPIKxn; 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 S1752096AbeENIHh (ORCPT + 29 others); Mon, 14 May 2018 04:07:37 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:42441 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369AbeENIHb (ORCPT ); Mon, 14 May 2018 04:07:31 -0400 Received: by mail-lf0-f67.google.com with SMTP id b18-v6so15834156lfa.9 for ; Mon, 14 May 2018 01:07: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=w5DFBrZwEmLY1hlKVjmpTyntGWY4PBnErlDD98AIvv8=; b=IrjPIKxno1C4V9s/FbMoWG+ngHSpjYnrhuLOAZtXo7EBejZey1ioqtyuvLCD0pMnlM a3Qg5gFbqaG0kCVRo83bCjeu+Bo797x6XgzjxiGPma6PB+CdRCQOVq5oITGgtvfdXgc0 4r5oepTgnHw5/KJxTSTCtZE2N/PHvNjeoEFUw= 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=w5DFBrZwEmLY1hlKVjmpTyntGWY4PBnErlDD98AIvv8=; b=tCDQvD0AFCOui+nN08JcN6ZpUDbcvHTct0/hf7UQoOs75uWZS7TT0s8w99gEiopGQ6 KCXdfehUooTbKRYPY9wfsS6NEAAHyBtQe8oGHhpbvss8n7YGTmpEiFkpCgDJpplLtkk5 FW2ufhV/aAVnj3EwRMj6RzCx5SzHX+pWcQVJbK61N7Sp6o7nflboaOAI0AFPmZrxfjI3 AePuUv0/Rp+gdN1H7f3mnpATqodS6J2m72QtX53A6llBM/i+MuY3xyJAkd/JDmQqp3Z8 gvJ2FlAUUgXZckwFvCtHRb89vQFEOwv6NYHvaKtKgBDwNR9XCGZWSTjum3AvacPjIr0U iC7A== X-Gm-Message-State: ALKqPwdfCNG8DJrIDcaDuU/eH8MJw7xlFmmEWXC3ZdtQ4TN1SoxXUR2/ AamV6ZIbXt4qfijCo6sUNpIGrA== X-Received: by 2002:a2e:9f56:: with SMTP id v22-v6mr3829735ljk.42.1526285249889; Mon, 14 May 2018 01:07:29 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:28 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 18/19 v3] regulator: gpio: Simplify probe path Date: Mon, 14 May 2018 10:06:39 +0200 Message-Id: <20180514080640.12515-19-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/gpio-regulator.c | 56 ++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-) -- 2.17.0 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; } From patchwork Mon May 14 08:06:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135676 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1440310lji; Mon, 14 May 2018 01:08:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrbFLIix9rDjNxlgoEsPrSsd8eWvWVoyykb9zV2ugT8xsdjzkeHfUz1C4Ufgk7Nr52Ut0Yv X-Received: by 2002:a63:4004:: with SMTP id n4-v6mr4302614pga.248.1526285296663; Mon, 14 May 2018 01:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285296; cv=none; d=google.com; s=arc-20160816; b=cPAFsMhVEPqlSOs+D40xqciLFKHzWDX0NdeXCimvou97zINc80r7Hroacuw7fOe21O 0nblZbhyI+0dwIDauFn5erzrOmtv1dNlMrVE6qiw0S0V1kIJGZKJrM43hzG7R265I2hf iTx4M+bKI6QwqWQhFFtCGLHg46WO8gUzDqwe05Ns5TAGKe/QBU0RJrW9fnkr5KLc/JY1 /d4QUbNLPfKducPymtvY5abUd4Az+84qzZ/j0tXYRE9ZMiKL9k7Ad0Tu4UCNIezTx7r2 f2q3Ysdbrv9TPpxozPCHEqwbqw8ScAv9+WNCiVY+LdRziSzkfuuoyRujGn7UXr5vcroS 1fTg== 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=PBEaF+OG1gZgFtTHMsGljuBEAx17IQCDRITqW+e1xh8=; b=vEPoxZTXC/NWVTONwPdPCWubbadiFgO/KKO0pAdLjasrhH13eCKOLidicKWWPB9fZ1 FMZIGYueAaKm3T79+oH8QA714NfgYojJI7Yf8QvH+2PLGtyzDv8LJYTXWIkgWnLcms3f m1k0uzV4qjpyNv6hMwYNMCryxVC11auE4/jC6np1qsWaMPCrvmQWre+p0Dqg+d9y4UdK KNDSWKwy2OLAMWa6W1JtQPe7MRYOMvPltzOJG+Hcar43Tz4aJkAz9+lsAWNPOfkwjnDS wyVoIH2LlAfUTKwTVMxe/1tK/kmwv2vN0EG4SDnyYMwtShs4x4bKzbQ1Id1b/gcTcn5b ydLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xr6frUf5; 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 q2-v6si8785681pfb.1.2018.05.14.01.08.16; Mon, 14 May 2018 01:08:16 -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=Xr6frUf5; 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 S1752454AbeENIIN (ORCPT + 29 others); Mon, 14 May 2018 04:08:13 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36108 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbeENIHd (ORCPT ); Mon, 14 May 2018 04:07:33 -0400 Received: by mail-lf0-f66.google.com with SMTP id t129-v6so16538463lff.3 for ; Mon, 14 May 2018 01:07:32 -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=PBEaF+OG1gZgFtTHMsGljuBEAx17IQCDRITqW+e1xh8=; b=Xr6frUf5cnEDYqTxmLA7Dezz5Vw/B5qWmkKxwzNAMeQ7M+XMKaruGi/v75cV1B+uLU UdbZVPNNdoG9TyUNdo77cLyYvF3CLI/D1xQTemDTqaImYPLiVly24xCfUNo9UgHdAVpy FxDp2wemKrH+BLtBh5NqQuKKFb2Y2fgHHcYAQ= 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=PBEaF+OG1gZgFtTHMsGljuBEAx17IQCDRITqW+e1xh8=; b=AwJConGxWznk99MUMi/07nKp4HIZ+V8yU6jIYNjKCKrWWX2WoeSa9Vg5o5ynsio7aG aLMBgvvbtvCe3+C23BbY8N1N/uSaJYNSXpyg2doUTZIi2rIvb9gDt5T68TYmO0CIVSk6 1V5dPesx6F4Bz5dbGQv5fw6h7UJwSJjv4moDdq1EpAdqzyDGFP3cLEQVyPndW209+PQc vSNBR+DF2BMieeZG2vm8M8gJffV0JngL8gsj03X2j1f7vBbIxuHg69thjaMaEDvv84t5 a9O1CgMhtp0+heGOmq5uUD/CLkc6CCJBS0qF7WVC2DimTcf47rrMiK7rhdIO4C0psJp/ HNWA== X-Gm-Message-State: ALKqPwe/1YBmByV09ghUR2bWAJEea0giZgERWJNqxRZWk8NNh/QW2Rr2 PHZGjkQO/NAcRBqZAMSoatBtmw== X-Received: by 2002:a19:b55a:: with SMTP id e87-v6mr7723655lff.54.1526285252019; Mon, 14 May 2018 01:07:32 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:30 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Linus Walleij Subject: [PATCH 19/19 v3] ARM: s3c64xx: Tidy up handling of regulator GPIO lookups Date: Mon, 14 May 2018 10:06:40 +0200 Message-Id: <20180514080640.12515-20-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Charles Keepax Rather than unconditionally registering the GPIO lookup table only do so for devices that require it. Signed-off-by: Charles Keepax [Fixed up to also handle wm5102 and wm5102 reva] Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Including this in my patch series. --- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) -- 2.17.0 diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 76c4855a03bc..56ec212442ad 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c @@ -328,6 +328,8 @@ static const struct { int num_i2c_devs; const struct spi_board_info *spi_devs; int num_spi_devs; + + struct gpiod_lookup_table *gpiod_table; } gf_mods[] = { { .id = 0x01, .rev = 0xff, .name = "1250-EV1 Springbank" }, { .id = 0x02, .rev = 0xff, .name = "1251-EV1 Jura" }, @@ -362,13 +364,16 @@ static const struct { .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) }, { .id = 0x3c, .rev = 0xff, .name = "1273-EV1 Longmorn" }, { .id = 0x3d, .rev = 0xff, .name = "1277-EV1 Littlemill", - .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) }, + .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs), + .gpiod_table = &wm8994_gpiod_table }, { .id = 0x3e, .rev = 0, .name = "WM5102-6271-EV1-CS127 Amrut", .spi_devs = wm5102_reva_spi_devs, - .num_spi_devs = ARRAY_SIZE(wm5102_reva_spi_devs) }, + .num_spi_devs = ARRAY_SIZE(wm5102_reva_spi_devs), + .gpiod_table = &wm5102_reva_gpiod_table }, { .id = 0x3e, .rev = -1, .name = "WM5102-6271-EV1-CS127 Amrut", .spi_devs = wm5102_spi_devs, - .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) }, + .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs), + .gpiod_table = &wm5102_gpiod_table }, { .id = 0x3f, .rev = -1, .name = "WM2200-6271-CS90-M-REV1", .i2c_devs = wm2200_i2c, .num_i2c_devs = ARRAY_SIZE(wm2200_i2c) }, }; @@ -391,10 +396,6 @@ 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); - gpiod_add_lookup_table(&wm8994_gpiod_table); - if (i < ARRAY_SIZE(gf_mods)) { dev_info(&i2c->dev, "%s revision %d\n", gf_mods[i].name, rev + 1); @@ -408,6 +409,9 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, spi_register_board_info(gf_mods[i].spi_devs, gf_mods[i].num_spi_devs); + + if (gf_mods[i].gpiod_table) + gpiod_add_lookup_table(gf_mods[i].gpiod_table); } else { dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n", id, rev + 1);