aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-05-17 09:45:16 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-18 03:37:25 -0400
commit3a8334b94850b08728237235df94a69c6ea9f6e7 (patch)
tree61a1262e1617d344ca3b1e7614f9abffde242916 /drivers/regulator/ab8500.c
parenta7ac1d9e4eac7e4ca5f7c76ea98421a0f6af671b (diff)
regulator: Enable the ab8500 for Device Tree
Here we setup the ab8500 regulator driver for DT. We first do this in the normal way, by providing a match structure during initialisation, but then we provide information so that whilst probing we can use existing data structures to do DT look-ups. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r--drivers/regulator/ab8500.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 3571b5425b3..e1b8c54ace5 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -18,9 +18,12 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/mfd/abx500.h> 19#include <linux/mfd/abx500.h>
20#include <linux/mfd/abx500/ab8500.h> 20#include <linux/mfd/abx500/ab8500.h>
21#include <linux/of.h>
22#include <linux/regulator/of_regulator.h>
21#include <linux/regulator/driver.h> 23#include <linux/regulator/driver.h>
22#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
23#include <linux/regulator/ab8500.h> 25#include <linux/regulator/ab8500.h>
26#include <linux/slab.h>
24 27
25/** 28/**
26 * struct ab8500_regulator_info - ab8500 regulator information 29 * struct ab8500_regulator_info - ab8500 regulator information
@@ -790,12 +793,57 @@ static __devinit int ab8500_regulator_register(struct platform_device *pdev,
790 return 0; 793 return 0;
791} 794}
792 795
796static struct of_regulator_match ab8500_regulator_matches[] = {
797 { .name = "LDO-AUX1", .driver_data = (void *) AB8500_LDO_AUX1, },
798 { .name = "LDO-AUX2", .driver_data = (void *) AB8500_LDO_AUX2, },
799 { .name = "LDO-AUX3", .driver_data = (void *) AB8500_LDO_AUX3, },
800 { .name = "LDO-INTCORE", .driver_data = (void *) AB8500_LDO_INTCORE, },
801 { .name = "LDO-TVOUT", .driver_data = (void *) AB8500_LDO_TVOUT, },
802 { .name = "LDO-USB", .driver_data = (void *) AB8500_LDO_USB, },
803 { .name = "LDO-AUDIO", .driver_data = (void *) AB8500_LDO_AUDIO, },
804 { .name = "LDO-ANAMIC1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
805 { .name = "LDO-ANAMIC2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
806 { .name = "LDO-DMIC", .driver_data = (void *) AB8500_LDO_DMIC, },
807 { .name = "LDO-ANA", .driver_data = (void *) AB8500_LDO_ANA, },
808};
809
810static __devinit int
811ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
812{
813 int err, i;
814
815 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) {
816 err = ab8500_regulator_register(
817 pdev, ab8500_regulator_matches[i].init_data,
818 i, ab8500_regulator_matches[i].of_node);
819 if (err)
820 return err;
821 }
822
823 return 0;
824}
825
793static __devinit int ab8500_regulator_probe(struct platform_device *pdev) 826static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
794{ 827{
795 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 828 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
796 struct ab8500_platform_data *pdata; 829 struct ab8500_platform_data *pdata;
830 struct device_node *np = pdev->dev.of_node;
797 int i, err; 831 int i, err;
798 832
833 if (np) {
834 err = of_regulator_match(&pdev->dev, np,
835 ab8500_regulator_matches,
836 ARRAY_SIZE(ab8500_regulator_matches));
837 if (err < 0) {
838 dev_err(&pdev->dev,
839 "Error parsing regulator init data: %d\n", err);
840 return err;
841 }
842
843 err = ab8500_regulator_of_probe(pdev, np);
844 return err;
845 }
846
799 if (!ab8500) { 847 if (!ab8500) {
800 dev_err(&pdev->dev, "null mfd parent\n"); 848 dev_err(&pdev->dev, "null mfd parent\n");
801 return -EINVAL; 849 return -EINVAL;
@@ -858,12 +906,18 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev)
858 return 0; 906 return 0;
859} 907}
860 908
909static const struct of_device_id ab8500_regulator_match[] = {
910 { .compatible = "stericsson,ab8500-regulator", },
911 {}
912};
913
861static struct platform_driver ab8500_regulator_driver = { 914static struct platform_driver ab8500_regulator_driver = {
862 .probe = ab8500_regulator_probe, 915 .probe = ab8500_regulator_probe,
863 .remove = __devexit_p(ab8500_regulator_remove), 916 .remove = __devexit_p(ab8500_regulator_remove),
864 .driver = { 917 .driver = {
865 .name = "ab8500-regulator", 918 .name = "ab8500-regulator",
866 .owner = THIS_MODULE, 919 .owner = THIS_MODULE,
920 .of_match_table = ab8500_regulator_match,
867 }, 921 },
868}; 922};
869 923