Skip to content

Commit ab4d11e

Browse files
committed
regulator: wm8994: Fix shared GPIOs
This reverts commit 3c6b38d "regulator: wm8994: Pass descriptor instead of GPIO number" as it has problems with shared GPIOs similar to that on s2mps11. Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d1dae72 commit ab4d11e

4 files changed

Lines changed: 22 additions & 26 deletions

File tree

‎arch/arm/mach-s3c64xx/mach-crag6410-module.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,15 @@ static struct wm8994_pdata wm8994_pdata = {
194194
0x3, /* IRQ out, active high, CMOS */
195195
},
196196
.ldo = {
197-
{ .init_data = &wm8994_ldo1, },
198-
{ .init_data = &wm8994_ldo2, },
197+
{ .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, },
198+
{ .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, },
199199
},
200200
};
201201

202202
static const struct i2c_board_info wm1277_devs[] = {
203203
{ I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */
204204
.platform_data = &wm8994_pdata,
205205
.irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
206-
.dev_name = "wm8958",
207-
},
208-
};
209-
210-
static struct gpiod_lookup_table wm8994_gpiod_table = {
211-
.dev_id = "i2c-wm8958", /* I2C device name */
212-
.table = {
213-
GPIO_LOOKUP("GPION", 6,
214-
"wlf,ldo1ena", GPIO_ACTIVE_HIGH),
215-
GPIO_LOOKUP("GPION", 4,
216-
"wlf,ldo2ena", GPIO_ACTIVE_HIGH),
217-
{ },
218206
},
219207
};
220208

@@ -393,7 +381,6 @@ static int wlf_gf_module_probe(struct i2c_client *i2c,
393381

394382
gpiod_add_lookup_table(&wm5102_reva_gpiod_table);
395383
gpiod_add_lookup_table(&wm5102_gpiod_table);
396-
gpiod_add_lookup_table(&wm8994_gpiod_table);
397384

398385
if (i < ARRAY_SIZE(gf_mods)) {
399386
dev_info(&i2c->dev, "%s revision %d\n",

‎drivers/mfd/wm8994-core.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/mfd/core.h>
2222
#include <linux/of.h>
2323
#include <linux/of_device.h>
24+
#include <linux/of_gpio.h>
2425
#include <linux/pm_runtime.h>
2526
#include <linux/regmap.h>
2627
#include <linux/regulator/consumer.h>
@@ -301,6 +302,14 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
301302
if (of_find_property(np, "wlf,ldoena-always-driven", NULL))
302303
pdata->lineout2fb = true;
303304

305+
pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0);
306+
if (pdata->ldo[0].enable < 0)
307+
pdata->ldo[0].enable = 0;
308+
309+
pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0);
310+
if (pdata->ldo[1].enable < 0)
311+
pdata->ldo[1].enable = 0;
312+
304313
return 0;
305314
}
306315
#else

‎drivers/regulator/wm8994-regulator.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/platform_device.h>
2020
#include <linux/regulator/driver.h>
2121
#include <linux/regulator/machine.h>
22-
#include <linux/gpio/consumer.h>
22+
#include <linux/gpio.h>
2323
#include <linux/slab.h>
2424

2525
#include <linux/mfd/wm8994/core.h>
@@ -129,7 +129,6 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
129129
int id = pdev->id % ARRAY_SIZE(pdata->ldo);
130130
struct regulator_config config = { };
131131
struct wm8994_ldo *ldo;
132-
struct gpio_desc *gpiod;
133132
int ret;
134133

135134
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
@@ -146,14 +145,12 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
146145
config.driver_data = ldo;
147146
config.regmap = wm8994->regmap;
148147
config.init_data = &ldo->init_data;
149-
150-
/* Look up LDO enable GPIO from the parent device node */
151-
gpiod = devm_gpiod_get_optional(pdev->dev.parent,
152-
id ? "wlf,ldo2ena" : "wlf,ldo1ena",
153-
GPIOD_OUT_LOW);
154-
if (IS_ERR(gpiod))
155-
return PTR_ERR(gpiod);
156-
config.ena_gpiod = gpiod;
148+
if (pdata) {
149+
config.ena_gpio = pdata->ldo[id].enable;
150+
} else if (wm8994->dev->of_node) {
151+
config.ena_gpio = wm8994->pdata.ldo[id].enable;
152+
config.ena_gpio_initialized = true;
153+
}
157154

158155
/* Use default constraints if none set up */
159156
if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) {
@@ -162,7 +159,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
162159

163160
ldo->init_data = wm8994_ldo_default[id];
164161
ldo->init_data.consumer_supplies = &ldo->supply;
165-
if (!gpiod)
162+
if (!config.ena_gpio)
166163
ldo->init_data.constraints.valid_ops_mask = 0;
167164
} else {
168165
ldo->init_data = *pdata->ldo[id].init_data;

‎include/linux/mfd/wm8994/pdata.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#define WM8994_NUM_AIF 3
2121

2222
struct wm8994_ldo_pdata {
23+
/** GPIOs to enable regulator, 0 or less if not available */
24+
int enable;
25+
2326
const struct regulator_init_data *init_data;
2427
};
2528

0 commit comments

Comments
 (0)