mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
Merge remote-tracking branch 'regulator/topic/as3711' into v3.9-rc8
This commit is contained in:
commit
83b0dd9ea3
@ -13,9 +13,11 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/mfd/as3711.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/driver.h>
|
||||
#include <linux/regulator/of_regulator.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
struct as3711_regulator_info {
|
||||
@ -276,6 +278,53 @@ static struct as3711_regulator_info as3711_reg_info[] = {
|
||||
|
||||
#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
|
||||
|
||||
static struct of_regulator_match
|
||||
as3711_regulator_matches[AS3711_REGULATOR_NUM] = {
|
||||
[AS3711_REGULATOR_SD_1] = { .name = "sd1" },
|
||||
[AS3711_REGULATOR_SD_2] = { .name = "sd2" },
|
||||
[AS3711_REGULATOR_SD_3] = { .name = "sd3" },
|
||||
[AS3711_REGULATOR_SD_4] = { .name = "sd4" },
|
||||
[AS3711_REGULATOR_LDO_1] = { .name = "ldo1" },
|
||||
[AS3711_REGULATOR_LDO_2] = { .name = "ldo2" },
|
||||
[AS3711_REGULATOR_LDO_3] = { .name = "ldo3" },
|
||||
[AS3711_REGULATOR_LDO_4] = { .name = "ldo4" },
|
||||
[AS3711_REGULATOR_LDO_5] = { .name = "ldo5" },
|
||||
[AS3711_REGULATOR_LDO_6] = { .name = "ldo6" },
|
||||
[AS3711_REGULATOR_LDO_7] = { .name = "ldo7" },
|
||||
[AS3711_REGULATOR_LDO_8] = { .name = "ldo8" },
|
||||
};
|
||||
|
||||
static int as3711_regulator_parse_dt(struct device *dev,
|
||||
struct device_node **of_node, const int count)
|
||||
{
|
||||
struct as3711_regulator_pdata *pdata = dev_get_platdata(dev);
|
||||
struct device_node *regulators =
|
||||
of_find_node_by_name(dev->parent->of_node, "regulators");
|
||||
struct of_regulator_match *match;
|
||||
int ret, i;
|
||||
|
||||
if (!regulators) {
|
||||
dev_err(dev, "regulator node not found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = of_regulator_match(dev->parent, regulators,
|
||||
as3711_regulator_matches, count);
|
||||
of_node_put(regulators);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Error parsing regulator init data: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0, match = as3711_regulator_matches; i < count; i++, match++)
|
||||
if (match->of_node) {
|
||||
pdata->init_data[i] = match->init_data;
|
||||
of_node[i] = match->of_node;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as3711_regulator_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
|
||||
@ -284,13 +333,24 @@ static int as3711_regulator_probe(struct platform_device *pdev)
|
||||
struct regulator_config config = {.dev = &pdev->dev,};
|
||||
struct as3711_regulator *reg = NULL;
|
||||
struct as3711_regulator *regs;
|
||||
struct device_node *of_node[AS3711_REGULATOR_NUM] = {};
|
||||
struct regulator_dev *rdev;
|
||||
struct as3711_regulator_info *ri;
|
||||
int ret;
|
||||
int id;
|
||||
|
||||
if (!pdata)
|
||||
dev_dbg(&pdev->dev, "No platform data...\n");
|
||||
if (!pdata) {
|
||||
dev_err(&pdev->dev, "No platform data...\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (pdev->dev.parent->of_node) {
|
||||
ret = as3711_regulator_parse_dt(&pdev->dev, of_node, AS3711_REGULATOR_NUM);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "DT parsing failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
|
||||
sizeof(struct as3711_regulator), GFP_KERNEL);
|
||||
@ -300,7 +360,7 @@ static int as3711_regulator_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
|
||||
reg_data = pdata ? pdata->init_data[id] : NULL;
|
||||
reg_data = pdata->init_data[id];
|
||||
|
||||
/* No need to register if there is no regulator data */
|
||||
if (!reg_data)
|
||||
@ -312,6 +372,7 @@ static int as3711_regulator_probe(struct platform_device *pdev)
|
||||
config.init_data = reg_data;
|
||||
config.driver_data = reg;
|
||||
config.regmap = as3711->regmap;
|
||||
config.of_node = of_node[id];
|
||||
|
||||
rdev = regulator_register(&ri->desc, &config);
|
||||
if (IS_ERR(rdev)) {
|
||||
|
Loading…
Reference in New Issue
Block a user