Merge remote-tracking branches 'regulator/topic/bcm590xx', 'regulator/topic/da9052...
authorMark Brown <broonie@linaro.org>
Wed, 26 Mar 2014 16:57:51 +0000 (16:57 +0000)
committerMark Brown <broonie@linaro.org>
Wed, 26 Mar 2014 16:57:51 +0000 (16:57 +0000)
1  2  3  4  5  6  7  8 
drivers/regulator/da9055-regulator.c
drivers/regulator/da9063-regulator.c

        #include <linux/platform_device.h>
        #include <linux/regulator/driver.h>
        #include <linux/regulator/machine.h>
+++ ++++#include <linux/of.h>
+++ ++++#include <linux/regulator/of_regulator.h>
        
        #include <linux/mfd/da9055/core.h>
        #include <linux/mfd/da9055/reg.h>
@@@@@@@@@ -446,6 -446,6 -446,6 -448,9 -446,6 -446,6 -446,6 -446,6 +448,9 @@@@@@@@@ static int da9055_gpio_init(struct da90
                struct da9055_regulator_info *info = regulator->info;
                int ret = 0;
        
+++ ++++        if (!pdata)
+++ ++++                return 0;
+++ ++++
                if (pdata->gpio_ren && pdata->gpio_ren[id]) {
                        char name[18];
                        int gpio_mux = pdata->gpio_ren[id];
@@@@@@@@@ -530,6 -530,6 -530,6 -535,59 -530,6 -530,6 -530,6 -530,6 +535,59 @@@@@@@@@ static inline struct da9055_regulator_i
                return NULL;
        }
        
+++ ++++#ifdef CONFIG_OF
+++ ++++static struct of_regulator_match da9055_reg_matches[] = {
+++ ++++        { .name = "BUCK1", },
+++ ++++        { .name = "BUCK2", },
+++ ++++        { .name = "LDO1", },
+++ ++++        { .name = "LDO2", },
+++ ++++        { .name = "LDO3", },
+++ ++++        { .name = "LDO4", },
+++ ++++        { .name = "LDO5", },
+++ ++++        { .name = "LDO6", },
+++ ++++};
+++ ++++
+++ ++++static int da9055_regulator_dt_init(struct platform_device *pdev,
+++ ++++                                    struct da9055_regulator *regulator,
+++ ++++                                    struct regulator_config *config,
+++ ++++                                    int regid)
+++ ++++{
+++ ++++        struct device_node *nproot, *np;
+++ ++++        int ret;
+++ ++++
+++ ++++        nproot = of_node_get(pdev->dev.parent->of_node);
+++ ++++        if (!nproot)
+++ ++++                return -ENODEV;
+++ ++++
+++ ++++        np = of_get_child_by_name(nproot, "regulators");
+++ ++++        if (!np)
+++ ++++                return -ENODEV;
+++ ++++
+++ ++++        ret = of_regulator_match(&pdev->dev, np, &da9055_reg_matches[regid], 1);
+++ ++++        of_node_put(nproot);
+++ ++++        if (ret < 0) {
+++ ++++                dev_err(&pdev->dev, "Error matching regulator: %d\n", ret);
+++ ++++                return ret;
+++ ++++        }
+++ ++++
+++ ++++        config->init_data = da9055_reg_matches[regid].init_data;
+++ ++++        config->of_node = da9055_reg_matches[regid].of_node;
+++ ++++
+++ ++++        if (!config->of_node)
+++ ++++                return -ENODEV;
+++ ++++
+++ ++++        return 0;
+++ ++++}
+++ ++++#else
+++ ++++static inline int da9055_regulator_dt_init(struct platform_device *pdev,
+++ ++++                                       struct da9055_regulator *regulator,
+++ ++++                                       struct regulator_config *config,
+++ ++++                                       int regid)
+++ ++++{
+++ ++++        return -ENODEV;
+++ ++++}
+++ ++++#endif /* CONFIG_OF */
+++ ++++
        static int da9055_regulator_probe(struct platform_device *pdev)
        {
                struct regulator_config config = { };
                struct da9055_pdata *pdata = dev_get_platdata(da9055->dev);
                int ret, irq;
        
--- ----        if (pdata == NULL || pdata->regulators[pdev->id] == NULL)
--- ----                return -ENODEV;
--- ----
                regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9055_regulator),
                                         GFP_KERNEL);
                if (!regulator)
                config.driver_data = regulator;
                config.regmap = da9055->regmap;
        
--- ----        if (pdata && pdata->regulators)
+++ ++++        if (pdata && pdata->regulators) {
                        config.init_data = pdata->regulators[pdev->id];
+++ ++++        } else {
+++ ++++                ret = da9055_regulator_dt_init(pdev, regulator, &config,
+++ ++++                                               pdev->id);
+++ ++++                if (ret < 0)
+++ ++++                        return ret;
+++ ++++        }
        
                ret = da9055_gpio_init(regulator, &config, pdata, pdev->id);
                if (ret < 0)
                /* Only LDO 5 and 6 has got the over current interrupt */
                if (pdev->id == DA9055_ID_LDO5 || pdev->id ==  DA9055_ID_LDO6) {
                        irq = platform_get_irq_byname(pdev, "REGULATOR");
 -------                irq = regmap_irq_get_virq(da9055->irq_data, irq);
 +++++++                if (irq < 0)
 +++++++                        return irq;
 +++++++
                        ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
                                                        da9055_ldo5_6_oc_irq,
                                                        IRQF_TRIGGER_HIGH |
@@@@@@@@@ -1,4 -1,3 -1,3 -1,3 -1,3 -1,3 -1,3 -1,3 +1,4 @@@@@@@@@
 +++++++
        /*
         * Regulator driver for DA9063 PMIC series
         *
@@@@@@@@@ -61,8 -60,7 -60,7 -60,7 -60,7 -60,7 -60,7 -60,7 +61,8 @@@@@@@@@ struct da9063_regulator_info 
                .desc.ops = &da9063_ldo_ops, \
                .desc.min_uV = (min_mV) * 1000, \
                .desc.uV_step = (step_mV) * 1000, \
 -------        .desc.n_voltages = (((max_mV) - (min_mV))/(step_mV) + 1), \
 +++++++        .desc.n_voltages = (((max_mV) - (min_mV))/(step_mV) + 1 \
 +++++++                + (DA9063_V##regl_name##_BIAS)), \
                .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \
                .desc.enable_mask = DA9063_LDO_EN, \
                .desc.vsel_reg = DA9063_REG_V##regl_name##_A, \
@@@@@@@@@ -365,7 -363,7 -363,7 -363,7 -363,7 -363,7 -363,7 -363,7 +365,7 @@@@@@@@@ static int da9063_set_suspend_voltage(s
        
                sel = regulator_map_voltage_linear(rdev, uV, uV);
                if (sel < 0)
---- ---                return -EINVAL;
++++ +++                return sel;
        
                sel <<= ffs(rdev->desc->vsel_mask) - 1;
        
@@@@@@@@@ -666,7 -664,7 -664,7 -664,7 -664,7 -664,7 -664,7 -664,7 +666,7 @@@@@@@@@ static struct da9063_regulators_pdata *
                struct device_node *node;
                int i, n, num;
        
---- ---        node = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
++++ +++        node = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
                if (!node) {
                        dev_err(&pdev->dev, "Regulators device node not found\n");
                        return ERR_PTR(-ENODEV);
        
                num = of_regulator_match(&pdev->dev, node, da9063_matches,
                                         ARRAY_SIZE(da9063_matches));
++++ +++        of_node_put(node);
                if (num < 0) {
                        dev_err(&pdev->dev, "Failed to match regulators\n");
                        return ERR_PTR(-EINVAL);
@@@@@@@@@ -710,7 -708,7 -708,7 -708,7 -709,7 -708,7 -708,7 -708,7 +711,7 @@@@@@@@@ static struct da9063_regulators_pdata *
                        struct platform_device *pdev,
                        struct of_regulator_match **da9063_reg_matches)
        {
---- ---        da9063_reg_matches = NULL;
++++ +++        *da9063_reg_matches = NULL;
                return ERR_PTR(-ENODEV);
        }
        #endif
@@@@@@@@@ -756,7 -754,7 -754,7 -754,7 -755,7 -754,7 -754,7 -754,7 +757,7 @@@@@@@@@ static int da9063_regulator_probe(struc
                if (ret < 0) {
                        dev_err(&pdev->dev,
                                "Error while reading BUCKs configuration\n");
---- ---                return -EIO;
++++ +++                return ret;
                }
                bcores_merged = val & DA9063_BCORE_MERGE;
                bmem_bio_merged = val & DA9063_BUCK_MERGE;
                size = sizeof(struct da9063_regulators) +
                        n_regulators * sizeof(struct da9063_regulator);
                regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
---- ---        if (!regulators) {
---- ---                dev_err(&pdev->dev, "No memory for regulators\n");
++++ +++        if (!regulators)
                        return -ENOMEM;
---- ---        }
        
                regulators->n_regulators = n_regulators;
                platform_set_drvdata(pdev, regulators);