From: Mark Brown Date: Wed, 30 May 2018 14:15:20 +0000 (+0100) Subject: regulator: wm8994: Fix shared GPIOs X-Git-Tag: v4.19~844^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab4d11e2c2329cf7cb7be31ff22489aae4dee5dc;p=platform%2Fkernel%2Flinux-rpi.git regulator: wm8994: Fix shared GPIOs This reverts commit 3c6b38d45fa51c7c51 "regulator: wm8994: Pass descriptor instead of GPIO number" as it has problems with shared GPIOs similar to that on s2mps11. Reported-by: Marek Szyprowski Signed-off-by: Mark Brown --- diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c index 76c4855..5aa4728 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 = { - { .init_data = &wm8994_ldo1, }, - { .init_data = &wm8994_ldo2, }, + { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, + { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, }, }; @@ -203,18 +203,6 @@ 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), - { }, }, }; @@ -393,7 +381,6 @@ 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 c409464..953d079 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -301,6 +302,14 @@ 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 d3a5f48..7a4ce6d 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,7 +129,6 @@ 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); @@ -146,14 +145,12 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - - /* 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; + 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; + } /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { @@ -162,7 +159,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 (!gpiod) + if (!config.ena_gpio) 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 fca67bd..90c6052 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -20,6 +20,9 @@ #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; };