summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-05-26 11:03:17 +0100
committerMark Brown <broonie@kernel.org>2018-05-26 11:04:30 +0100
commit37fa23dbccbd97663acc085bd79246f427e603a1 (patch)
treee2f8580145eef761c64dd3e0159d39d8d65002be /drivers/regulator
parentf50e5ddae899d1599e4d6ccb46eadd78b7ed14bc (diff)
downloadlinux-37fa23dbccbd97663acc085bd79246f427e603a1.tar.gz
linux-37fa23dbccbd97663acc085bd79246f427e603a1.tar.bz2
linux-37fa23dbccbd97663acc085bd79246f427e603a1.zip
regulator: s2mps11: Fix boot on Odroid XU3
The change to descriptors in 0369e02b75 "regulator: s2mps11: Pass descriptor instead of GPIO number" has broken the boot on Odroid XU3 according to kernelci so let's revert that for now. We get a NULL pointer defererence in: [ 2.467929] [] (validate_desc) from [] (gpiod_set_value_cansleep+0x14/0x30) [ 2.476591] [] (gpiod_set_value_cansleep) from [] (_regulator_do_enable+0x2f8/0x370) [ 2.486032] [] (_regulator_do_enable) from [] (regulator_register+0xc54/0x1280) [ 2.495045] [] (regulator_register) from [] (devm_regulator_register+0x40/0x7c) [ 2.504057] [] (devm_regulator_register) from [] (s2mps11_pmic_probe+0x1c0/0x444) [ 2.513243] [] (s2mps11_pmic_probe) from [] (platform_drv_probe+0x6c/0xa4) Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/s2mps11.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 9a1dca26362e..7726b874e539 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -18,7 +18,7 @@
#include <linux/bug.h>
#include <linux/err.h>
-#include <linux/gpio/consumer.h>
+#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -27,6 +27,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
+#include <linux/of_gpio.h>
#include <linux/mfd/samsung/core.h>
#include <linux/mfd/samsung/s2mps11.h>
#include <linux/mfd/samsung/s2mps13.h>
@@ -56,7 +57,7 @@ struct s2mps11_info {
* Array (size: number of regulators) with GPIO-s for external
* sleep control.
*/
- struct gpio_desc **ext_control_gpiod;
+ int *ext_control_gpio;
};
static int get_ramp_delay(int ramp_delay)
@@ -523,7 +524,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 (s2mps11->ext_control_gpiod[rdev_get_id(rdev)])
+ else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
val = S2MPS14_ENABLE_EXT_CONTROL;
else
val = rdev->desc->enable_mask;
@@ -817,7 +818,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)
{
- struct gpio_desc **gpio = s2mps11->ext_control_gpiod;
+ int *gpio = s2mps11->ext_control_gpio;
unsigned int i;
unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11,
S2MPS14_LDO12 };
@@ -828,20 +829,11 @@ 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] = 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);
+ 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);
}
}
@@ -1147,11 +1139,17 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
return -EINVAL;
}
- s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev,
- sizeof(*s2mps11->ext_control_gpiod) * rdev_num,
+ s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
+ sizeof(*s2mps11->ext_control_gpio) * rdev_num,
GFP_KERNEL);
- if (!s2mps11->ext_control_gpiod)
+ if (!s2mps11->ext_control_gpio)
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) {
@@ -1181,6 +1179,8 @@ common_reg:
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 @@ common_reg:
config.init_data = rdata[i].init_data;
config.of_node = rdata[i].of_node;
}
- config.ena_gpiod = s2mps11->ext_control_gpiod[i];
+ config.ena_gpio = s2mps11->ext_control_gpio[i];
regulator = devm_regulator_register(&pdev->dev,
&regulators[i], &config);
@@ -1202,7 +1202,7 @@ common_reg:
goto out;
}
- if (s2mps11->ext_control_gpiod[i]) {
+ if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
ret = s2mps14_pmic_enable_ext_control(s2mps11,
regulator);
if (ret < 0) {