diff options
| author | Tomasz Figa <t.figa@samsung.com> | 2013-06-25 10:08:10 -0400 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-30 17:30:04 -0400 |
| commit | ee999fb3f17faa3af6028bf7130707fe0d4157a4 (patch) | |
| tree | 9cbadb66c7a3f84c265fd2f7f10801385a7ea50b | |
| parent | 4280e0b42bd590316a048d66ea356e78c5d0464e (diff) | |
mfd: max8998: Add support for Device Tree
This patch adds Device Tree support to max8998 driver.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
| -rw-r--r-- | Documentation/devicetree/bindings/mfd/max8998.txt | 119 | ||||
| -rw-r--r-- | drivers/mfd/max8998.c | 67 | ||||
| -rw-r--r-- | drivers/regulator/max8998.c | 131 | ||||
| -rw-r--r-- | drivers/rtc/rtc-max8998.c | 2 | ||||
| -rw-r--r-- | include/linux/mfd/max8998-private.h | 2 | ||||
| -rw-r--r-- | include/linux/mfd/max8998.h | 2 |
6 files changed, 316 insertions, 7 deletions
diff --git a/Documentation/devicetree/bindings/mfd/max8998.txt b/Documentation/devicetree/bindings/mfd/max8998.txt new file mode 100644 index 000000000000..23a3650ff2a2 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/max8998.txt | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | * Maxim MAX8998, National/TI LP3974 multi-function device | ||
| 2 | |||
| 3 | The Maxim MAX8998 is a multi-function device which includes voltage/current | ||
| 4 | regulators, real time clock, battery charging controller and several | ||
| 5 | other sub-blocks. It is interfaced using an I2C interface. Each sub-block | ||
| 6 | is addressed by the host system using different i2c slave address. | ||
| 7 | |||
| 8 | PMIC sub-block | ||
| 9 | -------------- | ||
| 10 | |||
| 11 | The PMIC sub-block contains a number of voltage and current regulators, | ||
| 12 | with controllable parameters and dynamic voltage scaling capability. | ||
| 13 | In addition, it includes a real time clock and battery charging controller | ||
| 14 | as well. It is accessible at I2C address 0x66. | ||
| 15 | |||
| 16 | Required properties: | ||
| 17 | - compatible: Should be one of the following: | ||
| 18 | - "maxim,max8998" for Maxim MAX8998 | ||
| 19 | - "national,lp3974" or "ti,lp3974" for National/TI LP3974. | ||
| 20 | - reg: Specifies the i2c slave address of the pmic block. It should be 0x66. | ||
| 21 | |||
| 22 | Optional properties: | ||
| 23 | - interrupt-parent: Specifies the phandle of the interrupt controller to which | ||
| 24 | the interrupts from MAX8998 are routed to. | ||
| 25 | - interrupts: Interrupt specifiers for two interrupt sources. | ||
| 26 | - First interrupt specifier is for main interrupt. | ||
| 27 | - Second interrupt specifier is for power-on/-off interrupt. | ||
| 28 | - max8998,pmic-buck1-dvs-gpios: GPIO specifiers for two host gpios used | ||
| 29 | for buck 1 dvs. The format of the gpio specifier depends on the gpio | ||
| 30 | controller. | ||
| 31 | - max8998,pmic-buck2-dvs-gpio: GPIO specifier for host gpio used | ||
| 32 | for buck 2 dvs. The format of the gpio specifier depends on the gpio | ||
| 33 | controller. | ||
| 34 | - max8998,pmic-buck1-default-dvs-idx: Default voltage setting selected from | ||
| 35 | the possible 4 options selectable by the dvs gpios. The value of this | ||
| 36 | property should be 0, 1, 2 or 3. If not specified or out of range, | ||
| 37 | a default value of 0 is taken. | ||
| 38 | - max8998,pmic-buck2-default-dvs-idx: Default voltage setting selected from | ||
| 39 | the possible 2 options selectable by the dvs gpios. The value of this | ||
| 40 | property should be 0 or 1. If not specified or out of range, a default | ||
| 41 | value of 0 is taken. | ||
| 42 | - max8998,pmic-buck-voltage-lock: If present, disallows changing of | ||
| 43 | preprogrammed buck dvfs voltages. | ||
| 44 | |||
| 45 | Additional properties required if max8998,pmic-buck1-dvs-gpios is defined: | ||
| 46 | - max8998,pmic-buck1-dvs-voltage: An array of 4 voltage values in microvolts | ||
| 47 | for buck1 regulator that can be selected using dvs gpio. | ||
| 48 | |||
| 49 | Additional properties required if max8998,pmic-buck2-dvs-gpio is defined: | ||
| 50 | - max8998,pmic-buck2-dvs-voltage: An array of 2 voltage values in microvolts | ||
| 51 | for buck2 regulator that can be selected using dvs gpio. | ||
| 52 | |||
| 53 | Regulators: All the regulators of MAX8998 to be instantiated shall be | ||
| 54 | listed in a child node named 'regulators'. Each regulator is represented | ||
| 55 | by a child node of the 'regulators' node. | ||
| 56 | |||
| 57 | regulator-name { | ||
| 58 | /* standard regulator bindings here */ | ||
| 59 | }; | ||
| 60 | |||
| 61 | Following regulators of the MAX8998 PMIC block are supported. Note that | ||
| 62 | the 'n' in regulator name, as in LDOn or BUCKn, represents the LDO or BUCK | ||
| 63 | number as described in MAX8998 datasheet. | ||
| 64 | |||
| 65 | - LDOn | ||
| 66 | - valid values for n are 2 to 17 | ||
| 67 | - Example: LDO2, LDO10, LDO17 | ||
| 68 | - BUCKn | ||
| 69 | - valid values for n are 1 to 4. | ||
| 70 | - Example: BUCK1, BUCK2, BUCK3, BUCK4 | ||
| 71 | |||
| 72 | - ENVICHG: Battery Charging Current Monitor Output. This is a fixed | ||
| 73 | voltage type regulator | ||
| 74 | |||
| 75 | - ESAFEOUT1: (ldo19) | ||
| 76 | - ESAFEOUT2: (ld020) | ||
| 77 | |||
| 78 | Standard regulator bindings are used inside regulator subnodes. Check | ||
| 79 | Documentation/devicetree/bindings/regulator/regulator.txt | ||
| 80 | for more details. | ||
| 81 | |||
| 82 | Example: | ||
| 83 | |||
| 84 | pmic@66 { | ||
| 85 | compatible = "maxim,max8998-pmic"; | ||
| 86 | reg = <0x66>; | ||
| 87 | interrupt-parent = <&wakeup_eint>; | ||
| 88 | interrupts = <4 0>, <3 0>; | ||
| 89 | |||
| 90 | /* Buck 1 DVS settings */ | ||
| 91 | max8998,pmic-buck1-default-dvs-idx = <0>; | ||
| 92 | max8998,pmic-buck1-dvs-gpios = <&gpx0 0 1 0 0>, /* SET1 */ | ||
| 93 | <&gpx0 1 1 0 0>; /* SET2 */ | ||
| 94 | max8998,pmic-buck1-dvs-voltage = <1350000>, <1300000>, | ||
| 95 | <1000000>, <950000>; | ||
| 96 | |||
| 97 | /* Buck 2 DVS settings */ | ||
| 98 | max8998,pmic-buck2-default-dvs-idx = <0>; | ||
| 99 | max8998,pmic-buck2-dvs-gpio = <&gpx0 0 3 0 0>; /* SET3 */ | ||
| 100 | max8998,pmic-buck2-dvs-voltage = <1350000>, <1300000>; | ||
| 101 | |||
| 102 | /* Regulators to instantiate */ | ||
| 103 | regulators { | ||
| 104 | ldo2_reg: LDO2 { | ||
| 105 | regulator-name = "VDD_ALIVE_1.1V"; | ||
| 106 | regulator-min-microvolt = <1100000>; | ||
| 107 | regulator-max-microvolt = <1100000>; | ||
| 108 | regulator-always-on; | ||
| 109 | }; | ||
| 110 | |||
| 111 | buck1_reg: BUCK1 { | ||
| 112 | regulator-name = "VDD_ARM_1.2V"; | ||
| 113 | regulator-min-microvolt = <950000>; | ||
| 114 | regulator-max-microvolt = <1350000>; | ||
| 115 | regulator-always-on; | ||
| 116 | regulator-boot-on; | ||
| 117 | }; | ||
| 118 | }; | ||
| 119 | }; | ||
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index d7218cc90945..21af51a499f4 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c | |||
| @@ -20,12 +20,15 @@ | |||
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <linux/err.h> | ||
| 23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 24 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
| 25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 26 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 27 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
| 28 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/of.h> | ||
| 31 | #include <linux/of_irq.h> | ||
| 29 | #include <linux/pm_runtime.h> | 32 | #include <linux/pm_runtime.h> |
| 30 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
| 31 | #include <linux/mfd/core.h> | 34 | #include <linux/mfd/core.h> |
| @@ -128,6 +131,56 @@ int max8998_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask) | |||
| 128 | } | 131 | } |
| 129 | EXPORT_SYMBOL(max8998_update_reg); | 132 | EXPORT_SYMBOL(max8998_update_reg); |
| 130 | 133 | ||
| 134 | #ifdef CONFIG_OF | ||
| 135 | static struct of_device_id max8998_dt_match[] = { | ||
| 136 | { .compatible = "maxim,max8998", .data = (void *)TYPE_MAX8998 }, | ||
| 137 | { .compatible = "national,lp3974", .data = (void *)TYPE_LP3974 }, | ||
| 138 | { .compatible = "ti,lp3974", .data = (void *)TYPE_LP3974 }, | ||
| 139 | {}, | ||
| 140 | }; | ||
| 141 | MODULE_DEVICE_TABLE(of, max8998_dt_match); | ||
| 142 | #endif | ||
| 143 | |||
| 144 | /* | ||
| 145 | * Only the common platform data elements for max8998 are parsed here from the | ||
| 146 | * device tree. Other sub-modules of max8998 such as pmic, rtc and others have | ||
| 147 | * to parse their own platform data elements from device tree. | ||
| 148 | * | ||
| 149 | * The max8998 platform data structure is instantiated here and the drivers for | ||
| 150 | * the sub-modules need not instantiate another instance while parsing their | ||
| 151 | * platform data. | ||
| 152 | */ | ||
| 153 | static struct max8998_platform_data *max8998_i2c_parse_dt_pdata( | ||
| 154 | struct device *dev) | ||
| 155 | { | ||
| 156 | struct max8998_platform_data *pd; | ||
| 157 | |||
| 158 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); | ||
| 159 | if (!pd) | ||
| 160 | return ERR_PTR(-ENOMEM); | ||
| 161 | |||
| 162 | pd->ono = irq_of_parse_and_map(dev->of_node, 1); | ||
| 163 | |||
| 164 | /* | ||
| 165 | * ToDo: the 'wakeup' member in the platform data is more of a linux | ||
| 166 | * specfic information. Hence, there is no binding for that yet and | ||
| 167 | * not parsed here. | ||
| 168 | */ | ||
| 169 | return pd; | ||
| 170 | } | ||
| 171 | |||
| 172 | static inline int max8998_i2c_get_driver_data(struct i2c_client *i2c, | ||
| 173 | const struct i2c_device_id *id) | ||
| 174 | { | ||
| 175 | if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { | ||
| 176 | const struct of_device_id *match; | ||
| 177 | match = of_match_node(max8998_dt_match, i2c->dev.of_node); | ||
| 178 | return (int)match->data; | ||
| 179 | } | ||
| 180 | |||
| 181 | return (int)id->driver_data; | ||
| 182 | } | ||
| 183 | |||
| 131 | static int max8998_i2c_probe(struct i2c_client *i2c, | 184 | static int max8998_i2c_probe(struct i2c_client *i2c, |
| 132 | const struct i2c_device_id *id) | 185 | const struct i2c_device_id *id) |
| 133 | { | 186 | { |
| @@ -139,11 +192,20 @@ static int max8998_i2c_probe(struct i2c_client *i2c, | |||
| 139 | if (max8998 == NULL) | 192 | if (max8998 == NULL) |
| 140 | return -ENOMEM; | 193 | return -ENOMEM; |
| 141 | 194 | ||
| 195 | if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { | ||
| 196 | pdata = max8998_i2c_parse_dt_pdata(&i2c->dev); | ||
| 197 | if (IS_ERR(pdata)) { | ||
| 198 | ret = PTR_ERR(pdata); | ||
| 199 | goto err; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 142 | i2c_set_clientdata(i2c, max8998); | 203 | i2c_set_clientdata(i2c, max8998); |
| 143 | max8998->dev = &i2c->dev; | 204 | max8998->dev = &i2c->dev; |
| 144 | max8998->i2c = i2c; | 205 | max8998->i2c = i2c; |
| 145 | max8998->irq = i2c->irq; | 206 | max8998->irq = i2c->irq; |
| 146 | max8998->type = id->driver_data; | 207 | max8998->type = max8998_i2c_get_driver_data(i2c, id); |
| 208 | max8998->pdata = pdata; | ||
| 147 | if (pdata) { | 209 | if (pdata) { |
| 148 | max8998->ono = pdata->ono; | 210 | max8998->ono = pdata->ono; |
| 149 | max8998->irq_base = pdata->irq_base; | 211 | max8998->irq_base = pdata->irq_base; |
| @@ -158,7 +220,7 @@ static int max8998_i2c_probe(struct i2c_client *i2c, | |||
| 158 | 220 | ||
| 159 | pm_runtime_set_active(max8998->dev); | 221 | pm_runtime_set_active(max8998->dev); |
| 160 | 222 | ||
| 161 | switch (id->driver_data) { | 223 | switch (max8998->type) { |
| 162 | case TYPE_LP3974: | 224 | case TYPE_LP3974: |
| 163 | ret = mfd_add_devices(max8998->dev, -1, | 225 | ret = mfd_add_devices(max8998->dev, -1, |
| 164 | lp3974_devs, ARRAY_SIZE(lp3974_devs), | 226 | lp3974_devs, ARRAY_SIZE(lp3974_devs), |
| @@ -314,6 +376,7 @@ static struct i2c_driver max8998_i2c_driver = { | |||
| 314 | .name = "max8998", | 376 | .name = "max8998", |
| 315 | .owner = THIS_MODULE, | 377 | .owner = THIS_MODULE, |
| 316 | .pm = &max8998_pm, | 378 | .pm = &max8998_pm, |
| 379 | .of_match_table = of_match_ptr(max8998_dt_match), | ||
| 317 | }, | 380 | }, |
| 318 | .probe = max8998_i2c_probe, | 381 | .probe = max8998_i2c_probe, |
| 319 | .remove = max8998_i2c_remove, | 382 | .remove = max8998_i2c_remove, |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 8c45b93b7334..a4c53b2d1aaf 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
| @@ -28,8 +28,11 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
| 31 | #include <linux/of.h> | ||
| 32 | #include <linux/of_gpio.h> | ||
| 31 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
| 32 | #include <linux/regulator/driver.h> | 34 | #include <linux/regulator/driver.h> |
| 35 | #include <linux/regulator/of_regulator.h> | ||
| 33 | #include <linux/mfd/max8998.h> | 36 | #include <linux/mfd/max8998.h> |
| 34 | #include <linux/mfd/max8998-private.h> | 37 | #include <linux/mfd/max8998-private.h> |
| 35 | 38 | ||
| @@ -589,13 +592,13 @@ static struct regulator_desc regulators[] = { | |||
| 589 | .type = REGULATOR_VOLTAGE, | 592 | .type = REGULATOR_VOLTAGE, |
| 590 | .owner = THIS_MODULE, | 593 | .owner = THIS_MODULE, |
| 591 | }, { | 594 | }, { |
| 592 | .name = "EN32KHz AP", | 595 | .name = "EN32KHz-AP", |
| 593 | .id = MAX8998_EN32KHZ_AP, | 596 | .id = MAX8998_EN32KHZ_AP, |
| 594 | .ops = &max8998_others_ops, | 597 | .ops = &max8998_others_ops, |
| 595 | .type = REGULATOR_VOLTAGE, | 598 | .type = REGULATOR_VOLTAGE, |
| 596 | .owner = THIS_MODULE, | 599 | .owner = THIS_MODULE, |
| 597 | }, { | 600 | }, { |
| 598 | .name = "EN32KHz CP", | 601 | .name = "EN32KHz-CP", |
| 599 | .id = MAX8998_EN32KHZ_CP, | 602 | .id = MAX8998_EN32KHZ_CP, |
| 600 | .ops = &max8998_others_ops, | 603 | .ops = &max8998_others_ops, |
| 601 | .type = REGULATOR_VOLTAGE, | 604 | .type = REGULATOR_VOLTAGE, |
| @@ -621,10 +624,122 @@ static struct regulator_desc regulators[] = { | |||
| 621 | } | 624 | } |
| 622 | }; | 625 | }; |
| 623 | 626 | ||
| 627 | static int max8998_pmic_dt_parse_dvs_gpio(struct max8998_dev *iodev, | ||
| 628 | struct max8998_platform_data *pdata, | ||
| 629 | struct device_node *pmic_np) | ||
| 630 | { | ||
| 631 | int gpio; | ||
| 632 | |||
| 633 | gpio = of_get_named_gpio(pmic_np, "max8998,pmic-buck1-dvs-gpios", 0); | ||
| 634 | if (!gpio_is_valid(gpio)) { | ||
| 635 | dev_err(iodev->dev, "invalid buck1 gpio[0]: %d\n", gpio); | ||
| 636 | return -EINVAL; | ||
| 637 | } | ||
| 638 | pdata->buck1_set1 = gpio; | ||
| 639 | |||
| 640 | gpio = of_get_named_gpio(pmic_np, "max8998,pmic-buck1-dvs-gpios", 1); | ||
| 641 | if (!gpio_is_valid(gpio)) { | ||
| 642 | dev_err(iodev->dev, "invalid buck1 gpio[1]: %d\n", gpio); | ||
| 643 | return -EINVAL; | ||
| 644 | } | ||
| 645 | pdata->buck1_set2 = gpio; | ||
| 646 | |||
| 647 | gpio = of_get_named_gpio(pmic_np, "max8998,pmic-buck2-dvs-gpio", 0); | ||
| 648 | if (!gpio_is_valid(gpio)) { | ||
| 649 | dev_err(iodev->dev, "invalid buck 2 gpio: %d\n", gpio); | ||
| 650 | return -EINVAL; | ||
| 651 | } | ||
| 652 | pdata->buck2_set3 = gpio; | ||
| 653 | |||
| 654 | return 0; | ||
| 655 | } | ||
| 656 | |||
| 657 | static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, | ||
| 658 | struct max8998_platform_data *pdata) | ||
| 659 | { | ||
| 660 | struct device_node *pmic_np = iodev->dev->of_node; | ||
| 661 | struct device_node *regulators_np, *reg_np; | ||
| 662 | struct max8998_regulator_data *rdata; | ||
| 663 | unsigned int i; | ||
| 664 | int ret; | ||
| 665 | |||
| 666 | regulators_np = of_get_child_by_name(pmic_np, "regulators"); | ||
| 667 | if (!regulators_np) { | ||
| 668 | dev_err(iodev->dev, "could not find regulators sub-node\n"); | ||
| 669 | return -EINVAL; | ||
| 670 | } | ||
| 671 | |||
| 672 | /* count the number of regulators to be supported in pmic */ | ||
| 673 | pdata->num_regulators = of_get_child_count(regulators_np); | ||
| 674 | |||
| 675 | rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * | ||
| 676 | pdata->num_regulators, GFP_KERNEL); | ||
| 677 | if (!rdata) | ||
| 678 | return -ENOMEM; | ||
| 679 | |||
| 680 | pdata->regulators = rdata; | ||
| 681 | for (i = 0; i < ARRAY_SIZE(regulators); ++i) { | ||
| 682 | reg_np = of_get_child_by_name(regulators_np, | ||
| 683 | regulators[i].name); | ||
| 684 | if (!reg_np) | ||
| 685 | continue; | ||
| 686 | |||
| 687 | rdata->id = regulators[i].id; | ||
| 688 | rdata->initdata = of_get_regulator_init_data( | ||
| 689 | iodev->dev, reg_np); | ||
| 690 | rdata->reg_node = reg_np; | ||
| 691 | ++rdata; | ||
| 692 | } | ||
| 693 | pdata->num_regulators = rdata - pdata->regulators; | ||
| 694 | |||
| 695 | ret = max8998_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); | ||
| 696 | if (ret) | ||
| 697 | return -EINVAL; | ||
| 698 | |||
| 699 | if (of_find_property(pmic_np, "max8998,pmic-buck-voltage-lock", NULL)) | ||
| 700 | pdata->buck_voltage_lock = true; | ||
| 701 | |||
| 702 | ret = of_property_read_u32(pmic_np, | ||
| 703 | "max8998,pmic-buck1-default-dvs-idx", | ||
| 704 | &pdata->buck1_default_idx); | ||
| 705 | if (!ret && pdata->buck1_default_idx >= 4) { | ||
| 706 | pdata->buck1_default_idx = 0; | ||
| 707 | dev_warn(iodev->dev, "invalid value for default dvs index, using 0 instead\n"); | ||
| 708 | } | ||
| 709 | |||
| 710 | ret = of_property_read_u32(pmic_np, | ||
| 711 | "max8998,pmic-buck2-default-dvs-idx", | ||
| 712 | &pdata->buck2_default_idx); | ||
| 713 | if (!ret && pdata->buck2_default_idx >= 2) { | ||
| 714 | pdata->buck2_default_idx = 0; | ||
| 715 | dev_warn(iodev->dev, "invalid value for default dvs index, using 0 instead\n"); | ||
| 716 | } | ||
| 717 | |||
| 718 | ret = of_property_read_u32_array(pmic_np, | ||
| 719 | "max8998,pmic-buck1-dvs-voltage", | ||
| 720 | pdata->buck1_voltage, | ||
| 721 | ARRAY_SIZE(pdata->buck1_voltage)); | ||
| 722 | if (ret) { | ||
| 723 | dev_err(iodev->dev, "buck1 voltages not specified\n"); | ||
| 724 | return -EINVAL; | ||
| 725 | } | ||
| 726 | |||
| 727 | ret = of_property_read_u32_array(pmic_np, | ||
| 728 | "max8998,pmic-buck2-dvs-voltage", | ||
| 729 | pdata->buck2_voltage, | ||
| 730 | ARRAY_SIZE(pdata->buck2_voltage)); | ||
| 731 | if (ret) { | ||
| 732 | dev_err(iodev->dev, "buck2 voltages not specified\n"); | ||
| 733 | return -EINVAL; | ||
| 734 | } | ||
| 735 | |||
| 736 | return 0; | ||
| 737 | } | ||
| 738 | |||
| 624 | static int max8998_pmic_probe(struct platform_device *pdev) | 739 | static int max8998_pmic_probe(struct platform_device *pdev) |
| 625 | { | 740 | { |
| 626 | struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 741 | struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
| 627 | struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev); | 742 | struct max8998_platform_data *pdata = iodev->pdata; |
| 628 | struct regulator_config config = { }; | 743 | struct regulator_config config = { }; |
| 629 | struct regulator_dev **rdev; | 744 | struct regulator_dev **rdev; |
| 630 | struct max8998_data *max8998; | 745 | struct max8998_data *max8998; |
| @@ -637,6 +752,12 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 637 | return -ENODEV; | 752 | return -ENODEV; |
| 638 | } | 753 | } |
| 639 | 754 | ||
| 755 | if (IS_ENABLED(CONFIG_OF) && iodev->dev->of_node) { | ||
| 756 | ret = max8998_pmic_dt_parse_pdata(iodev, pdata); | ||
| 757 | if (ret) | ||
| 758 | return ret; | ||
| 759 | } | ||
| 760 | |||
| 640 | max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data), | 761 | max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data), |
| 641 | GFP_KERNEL); | 762 | GFP_KERNEL); |
| 642 | if (!max8998) | 763 | if (!max8998) |
| @@ -750,13 +871,15 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 750 | } | 871 | } |
| 751 | 872 | ||
| 752 | config.dev = max8998->dev; | 873 | config.dev = max8998->dev; |
| 874 | config.of_node = pdata->regulators[i].reg_node; | ||
| 753 | config.init_data = pdata->regulators[i].initdata; | 875 | config.init_data = pdata->regulators[i].initdata; |
| 754 | config.driver_data = max8998; | 876 | config.driver_data = max8998; |
| 755 | 877 | ||
| 756 | rdev[i] = regulator_register(®ulators[index], &config); | 878 | rdev[i] = regulator_register(®ulators[index], &config); |
| 757 | if (IS_ERR(rdev[i])) { | 879 | if (IS_ERR(rdev[i])) { |
| 758 | ret = PTR_ERR(rdev[i]); | 880 | ret = PTR_ERR(rdev[i]); |
| 759 | dev_err(max8998->dev, "regulator init failed\n"); | 881 | dev_err(max8998->dev, "regulator %s init failed (%d)\n", |
| 882 | regulators[index].name, ret); | ||
| 760 | rdev[i] = NULL; | 883 | rdev[i] = NULL; |
| 761 | goto err; | 884 | goto err; |
| 762 | } | 885 | } |
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index 46f23014759b..042a8734bd28 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c | |||
| @@ -253,7 +253,7 @@ static const struct rtc_class_ops max8998_rtc_ops = { | |||
| 253 | static int max8998_rtc_probe(struct platform_device *pdev) | 253 | static int max8998_rtc_probe(struct platform_device *pdev) |
| 254 | { | 254 | { |
| 255 | struct max8998_dev *max8998 = dev_get_drvdata(pdev->dev.parent); | 255 | struct max8998_dev *max8998 = dev_get_drvdata(pdev->dev.parent); |
| 256 | struct max8998_platform_data *pdata = dev_get_platdata(max8998->dev); | 256 | struct max8998_platform_data *pdata = max8998->pdata; |
| 257 | struct max8998_rtc_info *info; | 257 | struct max8998_rtc_info *info; |
| 258 | int ret; | 258 | int ret; |
| 259 | 259 | ||
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h index bfb48b6fcc74..84844e0a5704 100644 --- a/include/linux/mfd/max8998-private.h +++ b/include/linux/mfd/max8998-private.h | |||
| @@ -137,6 +137,7 @@ struct irq_domain; | |||
| 137 | /** | 137 | /** |
| 138 | * struct max8998_dev - max8998 master device for sub-drivers | 138 | * struct max8998_dev - max8998 master device for sub-drivers |
| 139 | * @dev: master device of the chip (can be used to access platform data) | 139 | * @dev: master device of the chip (can be used to access platform data) |
| 140 | * @pdata: platform data for the driver and subdrivers | ||
| 140 | * @i2c: i2c client private data for regulator | 141 | * @i2c: i2c client private data for regulator |
| 141 | * @rtc: i2c client private data for rtc | 142 | * @rtc: i2c client private data for rtc |
| 142 | * @iolock: mutex for serializing io access | 143 | * @iolock: mutex for serializing io access |
| @@ -150,6 +151,7 @@ struct irq_domain; | |||
| 150 | */ | 151 | */ |
| 151 | struct max8998_dev { | 152 | struct max8998_dev { |
| 152 | struct device *dev; | 153 | struct device *dev; |
| 154 | struct max8998_platform_data *pdata; | ||
| 153 | struct i2c_client *i2c; | 155 | struct i2c_client *i2c; |
| 154 | struct i2c_client *rtc; | 156 | struct i2c_client *rtc; |
| 155 | struct mutex iolock; | 157 | struct mutex iolock; |
diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h index ca56bb03bc69..e3956a654cbc 100644 --- a/include/linux/mfd/max8998.h +++ b/include/linux/mfd/max8998.h | |||
| @@ -58,10 +58,12 @@ enum { | |||
| 58 | * max8998_regulator_data - regulator data | 58 | * max8998_regulator_data - regulator data |
| 59 | * @id: regulator id | 59 | * @id: regulator id |
| 60 | * @initdata: regulator init data (contraints, supplies, ...) | 60 | * @initdata: regulator init data (contraints, supplies, ...) |
| 61 | * @reg_node: DT node of regulator (unused on non-DT platforms) | ||
| 61 | */ | 62 | */ |
| 62 | struct max8998_regulator_data { | 63 | struct max8998_regulator_data { |
| 63 | int id; | 64 | int id; |
| 64 | struct regulator_init_data *initdata; | 65 | struct regulator_init_data *initdata; |
| 66 | struct device_node *reg_node; | ||
| 65 | }; | 67 | }; |
| 66 | 68 | ||
| 67 | /** | 69 | /** |
