Commit bbad8220 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regulator-fix-v4.3-rc2' of...

Merge tag 'regulator-fix-v4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
 "A collection of fixes that came in since I tagged the merge window
  pull request for v4.3:

   - Error handling fixes in the core

   - Fixes to a couple of TI drivers for device specific issues

   - Several fixes for module autoloading"

* tag 'regulator-fix-v4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: vexpress: Fix module autoload for OF platform driver
  regulator: gpio: Fix module autoload for OF platform driver
  regulator: anatop: Fix module autoload for OF platform driver
  regulator: core: Correct return value check in regulator_resolve_supply
  regulator: tps65218: Fix missing zero typo
  regulator: pbias: program pbias register offset in pbias driver
  regulator: core: fix possible NULL dereference
parents 5146c8e4 16651fc2
......@@ -2,7 +2,12 @@ PBIAS internal regulator for SD card dual voltage i/o pads on OMAP SoCs.
Required properties:
- compatible:
- "ti,pbias-omap" for OMAP2, OMAP3, OMAP4, OMAP5, DRA7.
- should be "ti,pbias-dra7" for DRA7
- should be "ti,pbias-omap2" for OMAP2
- should be "ti,pbias-omap3" for OMAP3
- should be "ti,pbias-omap4" for OMAP4
- should be "ti,pbias-omap5" for OMAP5
- "ti,pbias-omap" is deprecated
- reg: pbias register offset from syscon base and size of pbias register.
- syscon : phandle of the system control module
- regulator-name : should be
......
......@@ -318,6 +318,7 @@ static const struct of_device_id of_anatop_regulator_match_tbl[] = {
{ .compatible = "fsl,anatop-regulator", },
{ /* end */ }
};
MODULE_DEVICE_TABLE(of, of_anatop_regulator_match_tbl);
static struct platform_driver anatop_regulator_driver = {
.driver = {
......
......@@ -1394,6 +1394,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
return 0;
r = regulator_dev_lookup(dev, rdev->supply_name, &ret);
if (!r) {
if (ret == -ENODEV) {
/*
* No supply was specified for this regulator and
......@@ -1402,7 +1403,6 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
return 0;
}
if (!r) {
if (have_full_constraints()) {
r = dummy_regulator_rdev;
} else {
......@@ -1422,10 +1422,9 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
return ret;
/* Cascade always-on state to supply */
if (_regulator_is_enabled(rdev)) {
if (_regulator_is_enabled(rdev) && rdev->supply) {
ret = regulator_enable(rdev->supply);
if (ret < 0) {
if (rdev->supply)
_regulator_put(rdev->supply);
return ret;
}
......
......@@ -394,6 +394,7 @@ static const struct of_device_id regulator_gpio_of_match[] = {
{ .compatible = "regulator-gpio", },
{},
};
MODULE_DEVICE_TABLE(of, regulator_gpio_of_match);
#endif
static struct platform_driver gpio_regulator_driver = {
......
......@@ -45,6 +45,10 @@ struct pbias_regulator_data {
int voltage;
};
struct pbias_of_data {
unsigned int offset;
};
static const unsigned int pbias_volt_table[] = {
1800000,
3000000
......@@ -102,8 +106,35 @@ static struct of_regulator_match pbias_matches[] = {
};
#define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches)
/* Offset from SCM general area (and syscon) base */
static const struct pbias_of_data pbias_of_data_omap2 = {
.offset = 0x230,
};
static const struct pbias_of_data pbias_of_data_omap3 = {
.offset = 0x2b0,
};
static const struct pbias_of_data pbias_of_data_omap4 = {
.offset = 0x60,
};
static const struct pbias_of_data pbias_of_data_omap5 = {
.offset = 0x60,
};
static const struct pbias_of_data pbias_of_data_dra7 = {
.offset = 0xe00,
};
static const struct of_device_id pbias_of_match[] = {
{ .compatible = "ti,pbias-omap", },
{ .compatible = "ti,pbias-omap2", .data = &pbias_of_data_omap2, },
{ .compatible = "ti,pbias-omap3", .data = &pbias_of_data_omap3, },
{ .compatible = "ti,pbias-omap4", .data = &pbias_of_data_omap4, },
{ .compatible = "ti,pbias-omap5", .data = &pbias_of_data_omap5, },
{ .compatible = "ti,pbias-dra7", .data = &pbias_of_data_dra7, },
{},
};
MODULE_DEVICE_TABLE(of, pbias_of_match);
......@@ -118,6 +149,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
const struct pbias_reg_info *info;
int ret = 0;
int count, idx, data_idx = 0;
const struct of_device_id *match;
const struct pbias_of_data *data;
unsigned int offset;
count = of_regulator_match(&pdev->dev, np, pbias_matches,
PBIAS_NUM_REGS);
......@@ -133,6 +167,20 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (IS_ERR(syscon))
return PTR_ERR(syscon);
match = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
if (match && match->data) {
data = match->data;
offset = data->offset;
} else {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -EINVAL;
offset = res->start;
dev_WARN(&pdev->dev,
"using legacy dt data for pbias offset\n");
}
cfg.regmap = syscon;
cfg.dev = &pdev->dev;
......@@ -145,10 +193,6 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (!info)
return -ENODEV;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -EINVAL;
drvdata[data_idx].syscon = syscon;
drvdata[data_idx].info = info;
drvdata[data_idx].desc.name = info->name;
......@@ -158,9 +202,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
drvdata[data_idx].desc.volt_table = pbias_volt_table;
drvdata[data_idx].desc.n_voltages = 2;
drvdata[data_idx].desc.enable_time = info->enable_time;
drvdata[data_idx].desc.vsel_reg = res->start;
drvdata[data_idx].desc.vsel_reg = offset;
drvdata[data_idx].desc.vsel_mask = info->vmode;
drvdata[data_idx].desc.enable_reg = res->start;
drvdata[data_idx].desc.enable_reg = offset;
drvdata[data_idx].desc.enable_mask = info->enable_mask;
drvdata[data_idx].desc.enable_val = info->enable;
drvdata[data_idx].desc.disable_val = info->disable_val;
......
......@@ -73,7 +73,7 @@ static const struct regulator_linear_range dcdc4_ranges[] = {
};
static struct tps_info tps65218_pmic_regs[] = {
TPS65218_INFO(DCDC1, "DCDC1", 850000, 167500),
TPS65218_INFO(DCDC1, "DCDC1", 850000, 1675000),
TPS65218_INFO(DCDC2, "DCDC2", 850000, 1675000),
TPS65218_INFO(DCDC3, "DCDC3", 900000, 3400000),
TPS65218_INFO(DCDC4, "DCDC4", 1175000, 3400000),
......
......@@ -103,6 +103,7 @@ static const struct of_device_id vexpress_regulator_of_match[] = {
{ .compatible = "arm,vexpress-volt", },
{ }
};
MODULE_DEVICE_TABLE(of, vexpress_regulator_of_match);
static struct platform_driver vexpress_regulator_driver = {
.probe = vexpress_regulator_probe,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment