Commit d90acbc4 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

regulator: lochnagar: Move driver to binding from DT

Based on review comments on the MFD driver, move the child drivers for
the Lochnagar MFD over to binding through device tree.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent d7c7fc44
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
...@@ -214,28 +215,52 @@ static const struct regulator_desc lochnagar_regulators[] = { ...@@ -214,28 +215,52 @@ static const struct regulator_desc lochnagar_regulators[] = {
}, },
}; };
static const struct of_device_id lochnagar_of_match[] = {
{
.compatible = "cirrus,lochnagar2-micvdd",
.data = &lochnagar_regulators[LOCHNAGAR_MICVDD],
},
{
.compatible = "cirrus,lochnagar2-mic1vdd",
.data = &lochnagar_regulators[LOCHNAGAR_MIC1VDD],
},
{
.compatible = "cirrus,lochnagar2-mic2vdd",
.data = &lochnagar_regulators[LOCHNAGAR_MIC1VDD],
},
{
.compatible = "cirrus,lochnagar2-vddcore",
.data = &lochnagar_regulators[LOCHNAGAR_VDDCORE],
},
{},
};
static int lochnagar_regulator_probe(struct platform_device *pdev) static int lochnagar_regulator_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct lochnagar *lochnagar = dev_get_drvdata(dev->parent); struct lochnagar *lochnagar = dev_get_drvdata(dev->parent);
struct regulator_config config = { }; struct regulator_config config = { };
const struct of_device_id *of_id;
const struct regulator_desc *desc;
struct regulator_dev *rdev; struct regulator_dev *rdev;
int ret, i; int ret;
config.dev = lochnagar->dev; config.dev = dev;
config.regmap = lochnagar->regmap; config.regmap = lochnagar->regmap;
config.driver_data = lochnagar; config.driver_data = lochnagar;
for (i = 0; i < ARRAY_SIZE(lochnagar_regulators); i++) { of_id = of_match_device(lochnagar_of_match, dev);
const struct regulator_desc *desc = &lochnagar_regulators[i]; if (!of_id)
return -EINVAL;
rdev = devm_regulator_register(dev, desc, &config); desc = of_id->data;
if (IS_ERR(rdev)) {
ret = PTR_ERR(rdev); rdev = devm_regulator_register(dev, desc, &config);
dev_err(dev, "Failed to register %s regulator: %d\n", if (IS_ERR(rdev)) {
desc->name, ret); ret = PTR_ERR(rdev);
return ret; dev_err(dev, "Failed to register %s regulator: %d\n",
} desc->name, ret);
return ret;
} }
return 0; return 0;
...@@ -244,6 +269,7 @@ static int lochnagar_regulator_probe(struct platform_device *pdev) ...@@ -244,6 +269,7 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
static struct platform_driver lochnagar_regulator_driver = { static struct platform_driver lochnagar_regulator_driver = {
.driver = { .driver = {
.name = "lochnagar-regulator", .name = "lochnagar-regulator",
.of_match_table = of_match_ptr(lochnagar_of_match),
}, },
.probe = lochnagar_regulator_probe, .probe = lochnagar_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