diff options
-rw-r--r-- | Documentation/devicetree/bindings/regulator/max8997-regulator.txt | 146 | ||||
-rw-r--r-- | drivers/mfd/max8997.c | 73 | ||||
-rw-r--r-- | drivers/regulator/max8997.c | 148 | ||||
-rw-r--r-- | include/linux/mfd/max8997-private.h | 1 | ||||
-rw-r--r-- | include/linux/mfd/max8997.h | 1 |
5 files changed, 366 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/regulator/max8997-regulator.txt b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt new file mode 100644 index 000000000000..9fd69a18b0ba --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt | |||
@@ -0,0 +1,146 @@ | |||
1 | * Maxim MAX8997 Voltage and Current Regulator | ||
2 | |||
3 | The Maxim MAX8997 is a multi-function device which includes volatage and | ||
4 | current regulators, rtc, charger controller and other sub-blocks. It is | ||
5 | interfaced to the host controller using a i2c interface. Each sub-block is | ||
6 | addressed by the host system using different i2c slave address. This document | ||
7 | describes the bindings for 'pmic' sub-block of max8997. | ||
8 | |||
9 | Required properties: | ||
10 | - compatible: Should be "maxim,max8997-pmic". | ||
11 | - reg: Specifies the i2c slave address of the pmic block. It should be 0x66. | ||
12 | |||
13 | - max8997,pmic-buck1-dvs-voltage: A set of 8 voltage values in micro-volt (uV) | ||
14 | units for buck1 when changing voltage using gpio dvs. Refer to [1] below | ||
15 | for additional information. | ||
16 | |||
17 | - max8997,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) | ||
18 | units for buck2 when changing voltage using gpio dvs. Refer to [1] below | ||
19 | for additional information. | ||
20 | |||
21 | - max8997,pmic-buck5-dvs-voltage: A set of 8 voltage values in micro-volt (uV) | ||
22 | units for buck5 when changing voltage using gpio dvs. Refer to [1] below | ||
23 | for additional information. | ||
24 | |||
25 | [1] If none of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional | ||
26 | property is specified, the 'max8997,pmic-buck[1/2/5]-dvs-voltage' | ||
27 | property should specify atleast one voltage level (which would be a | ||
28 | safe operating voltage). | ||
29 | |||
30 | If either of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional | ||
31 | property is specified, then all the eigth voltage values for the | ||
32 | 'max8997,pmic-buck[1/2/5]-dvs-voltage' should be specified. | ||
33 | |||
34 | Optional properties: | ||
35 | - interrupt-parent: Specifies the phandle of the interrupt controller to which | ||
36 | the interrupts from max8997 are delivered to. | ||
37 | - interrupts: Interrupt specifiers for two interrupt sources. | ||
38 | - First interrupt specifier is for 'irq1' interrupt. | ||
39 | - Second interrupt specifier is for 'alert' interrupt. | ||
40 | - max8997,pmic-buck1-uses-gpio-dvs: 'buck1' can be controlled by gpio dvs. | ||
41 | - max8997,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. | ||
42 | - max8997,pmic-buck5-uses-gpio-dvs: 'buck5' can be controlled by gpio dvs. | ||
43 | |||
44 | Additional properties required if either of the optional properties are used: | ||
45 | - max8997,pmic-ignore-gpiodvs-side-effect: When GPIO-DVS mode is used for | ||
46 | multiple bucks, changing the voltage value of one of the bucks may affect | ||
47 | that of another buck, which is the side effect of the change (set_voltage). | ||
48 | Use this property to ignore such side effects and change the voltage. | ||
49 | |||
50 | - max8997,pmic-buck125-default-dvs-idx: Default voltage setting selected from | ||
51 | the possible 8 options selectable by the dvs gpios. The value of this | ||
52 | property should be between 0 and 7. If not specified or if out of range, the | ||
53 | default value of this property is set to 0. | ||
54 | |||
55 | - max8997,pmic-buck125-dvs-gpios: GPIO specifiers for three host gpio's used | ||
56 | for dvs. The format of the gpio specifier depends in the gpio controller. | ||
57 | |||
58 | Regulators: The regulators of max8997 that have to be instantiated should be | ||
59 | included in a sub-node named 'regulators'. Regulator nodes included in this | ||
60 | sub-node should be of the format as listed below. | ||
61 | |||
62 | regulator_name { | ||
63 | standard regulator bindings here | ||
64 | }; | ||
65 | |||
66 | The following are the names of the regulators that the max8997 pmic block | ||
67 | supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number | ||
68 | as per the datasheet of max8997. | ||
69 | |||
70 | - LDOn | ||
71 | - valid values for n are 1 to 18 and 21 | ||
72 | - Example: LDO0, LD01, LDO2, LDO21 | ||
73 | - BUCKn | ||
74 | - valid values for n are 1 to 7. | ||
75 | - Example: BUCK1, BUCK2, BUCK3, BUCK7 | ||
76 | |||
77 | - ENVICHG: Battery Charging Current Monitor Output. This is a fixed | ||
78 | voltage type regulator | ||
79 | |||
80 | - ESAFEOUT1: (ldo19) | ||
81 | - ESAFEOUT2: (ld020) | ||
82 | |||
83 | - CHARGER_CV: main battery charger voltage control | ||
84 | - CHARGER: main battery charger current control | ||
85 | - CHARGER_TOPOFF: end of charge current threshold level | ||
86 | |||
87 | The bindings inside the regulator nodes use the standard regulator bindings | ||
88 | which are documented elsewhere. | ||
89 | |||
90 | Example: | ||
91 | |||
92 | max8997_pmic@66 { | ||
93 | compatible = "maxim,max8997-pmic"; | ||
94 | interrupt-parent = <&wakeup_eint>; | ||
95 | reg = <0x66>; | ||
96 | interrupts = <4 0>, <3 0>; | ||
97 | |||
98 | max8997,pmic-buck1-uses-gpio-dvs; | ||
99 | max8997,pmic-buck2-uses-gpio-dvs; | ||
100 | max8997,pmic-buck5-uses-gpio-dvs; | ||
101 | |||
102 | max8997,pmic-ignore-gpiodvs-side-effect; | ||
103 | max8997,pmic-buck125-default-dvs-idx = <0>; | ||
104 | |||
105 | max8997,pmic-buck125-dvs-gpios = <&gpx0 0 1 0 0>, /* SET1 */ | ||
106 | <&gpx0 1 1 0 0>, /* SET2 */ | ||
107 | <&gpx0 2 1 0 0>; /* SET3 */ | ||
108 | |||
109 | max8997,pmic-buck1-dvs-voltage = <1350000>, <1300000>, | ||
110 | <1250000>, <1200000>, | ||
111 | <1150000>, <1100000>, | ||
112 | <1000000>, <950000>; | ||
113 | |||
114 | max8997,pmic-buck2-dvs-voltage = <1100000>, <1100000>, | ||
115 | <1100000>, <1100000>, | ||
116 | <1000000>, <1000000>, | ||
117 | <1000000>, <1000000>; | ||
118 | |||
119 | max8997,pmic-buck5-dvs-voltage = <1200000>, <1200000>, | ||
120 | <1200000>, <1200000>, | ||
121 | <1200000>, <1200000>, | ||
122 | <1200000>, <1200000>; | ||
123 | |||
124 | regulators { | ||
125 | ldo1_reg: LDO1 { | ||
126 | regulator-name = "VDD_ABB_3.3V"; | ||
127 | regulator-min-microvolt = <3300000>; | ||
128 | regulator-max-microvolt = <3300000>; | ||
129 | }; | ||
130 | |||
131 | ldo2_reg: LDO2 { | ||
132 | regulator-name = "VDD_ALIVE_1.1V"; | ||
133 | regulator-min-microvolt = <1100000>; | ||
134 | regulator-max-microvolt = <1100000>; | ||
135 | regulator-always-on; | ||
136 | }; | ||
137 | |||
138 | buck1_reg: BUCK1 { | ||
139 | regulator-name = "VDD_ARM_1.2V"; | ||
140 | regulator-min-microvolt = <950000>; | ||
141 | regulator-max-microvolt = <1350000>; | ||
142 | regulator-always-on; | ||
143 | regulator-boot-on; | ||
144 | }; | ||
145 | }; | ||
146 | }; | ||
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index f123517065ec..abd5c80c7cf5 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c | |||
@@ -21,8 +21,10 @@ | |||
21 | * This driver is based on max8998.c | 21 | * This driver is based on max8998.c |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/err.h> | ||
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
25 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/of_irq.h> | ||
26 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
27 | #include <linux/pm_runtime.h> | 29 | #include <linux/pm_runtime.h> |
28 | #include <linux/module.h> | 30 | #include <linux/module.h> |
@@ -47,6 +49,13 @@ static struct mfd_cell max8997_devs[] = { | |||
47 | { .name = "max8997-led", .id = 2 }, | 49 | { .name = "max8997-led", .id = 2 }, |
48 | }; | 50 | }; |
49 | 51 | ||
52 | #ifdef CONFIG_OF | ||
53 | static struct of_device_id __devinitdata max8997_pmic_dt_match[] = { | ||
54 | { .compatible = "maxim,max8997-pmic", .data = TYPE_MAX8997 }, | ||
55 | {}, | ||
56 | }; | ||
57 | #endif | ||
58 | |||
50 | int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) | 59 | int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) |
51 | { | 60 | { |
52 | struct max8997_dev *max8997 = i2c_get_clientdata(i2c); | 61 | struct max8997_dev *max8997 = i2c_get_clientdata(i2c); |
@@ -123,6 +132,58 @@ int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask) | |||
123 | } | 132 | } |
124 | EXPORT_SYMBOL_GPL(max8997_update_reg); | 133 | EXPORT_SYMBOL_GPL(max8997_update_reg); |
125 | 134 | ||
135 | #ifdef CONFIG_OF | ||
136 | /* | ||
137 | * Only the common platform data elements for max8997 are parsed here from the | ||
138 | * device tree. Other sub-modules of max8997 such as pmic, rtc and others have | ||
139 | * to parse their own platform data elements from device tree. | ||
140 | * | ||
141 | * The max8997 platform data structure is instantiated here and the drivers for | ||
142 | * the sub-modules need not instantiate another instance while parsing their | ||
143 | * platform data. | ||
144 | */ | ||
145 | static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( | ||
146 | struct device *dev) | ||
147 | { | ||
148 | struct max8997_platform_data *pd; | ||
149 | |||
150 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); | ||
151 | if (!pd) { | ||
152 | dev_err(dev, "could not allocate memory for pdata\n"); | ||
153 | return ERR_PTR(-ENOMEM); | ||
154 | } | ||
155 | |||
156 | pd->ono = irq_of_parse_and_map(dev->of_node, 1); | ||
157 | |||
158 | /* | ||
159 | * ToDo: the 'wakeup' member in the platform data is more of a linux | ||
160 | * specfic information. Hence, there is no binding for that yet and | ||
161 | * not parsed here. | ||
162 | */ | ||
163 | |||
164 | return pd; | ||
165 | } | ||
166 | #else | ||
167 | static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( | ||
168 | struct device *dev) | ||
169 | { | ||
170 | return 0; | ||
171 | } | ||
172 | #endif | ||
173 | |||
174 | static inline int max8997_i2c_get_driver_data(struct i2c_client *i2c, | ||
175 | const struct i2c_device_id *id) | ||
176 | { | ||
177 | #ifdef CONFIG_OF | ||
178 | if (i2c->dev.of_node) { | ||
179 | const struct of_device_id *match; | ||
180 | match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node); | ||
181 | return (int)match->data; | ||
182 | } | ||
183 | #endif | ||
184 | return (int)id->driver_data; | ||
185 | } | ||
186 | |||
126 | static int max8997_i2c_probe(struct i2c_client *i2c, | 187 | static int max8997_i2c_probe(struct i2c_client *i2c, |
127 | const struct i2c_device_id *id) | 188 | const struct i2c_device_id *id) |
128 | { | 189 | { |
@@ -137,12 +198,21 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
137 | i2c_set_clientdata(i2c, max8997); | 198 | i2c_set_clientdata(i2c, max8997); |
138 | max8997->dev = &i2c->dev; | 199 | max8997->dev = &i2c->dev; |
139 | max8997->i2c = i2c; | 200 | max8997->i2c = i2c; |
140 | max8997->type = id->driver_data; | 201 | max8997->type = max8997_i2c_get_driver_data(i2c, id); |
141 | max8997->irq = i2c->irq; | 202 | max8997->irq = i2c->irq; |
142 | 203 | ||
204 | if (max8997->dev->of_node) { | ||
205 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); | ||
206 | if (IS_ERR(pdata)) { | ||
207 | ret = PTR_ERR(pdata); | ||
208 | goto err; | ||
209 | } | ||
210 | } | ||
211 | |||
143 | if (!pdata) | 212 | if (!pdata) |
144 | goto err; | 213 | goto err; |
145 | 214 | ||
215 | max8997->pdata = pdata; | ||
146 | max8997->ono = pdata->ono; | 216 | max8997->ono = pdata->ono; |
147 | 217 | ||
148 | mutex_init(&max8997->iolock); | 218 | mutex_init(&max8997->iolock); |
@@ -434,6 +504,7 @@ static struct i2c_driver max8997_i2c_driver = { | |||
434 | .name = "max8997", | 504 | .name = "max8997", |
435 | .owner = THIS_MODULE, | 505 | .owner = THIS_MODULE, |
436 | .pm = &max8997_pm, | 506 | .pm = &max8997_pm, |
507 | .of_match_table = of_match_ptr(max8997_pmic_dt_match), | ||
437 | }, | 508 | }, |
438 | .probe = max8997_i2c_probe, | 509 | .probe = max8997_i2c_probe, |
439 | .remove = max8997_i2c_remove, | 510 | .remove = max8997_i2c_remove, |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 64cf2ee38f6c..b56c4326853d 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/bug.h> | 24 | #include <linux/bug.h> |
25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
27 | #include <linux/of_gpio.h> | ||
27 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
28 | #include <linux/module.h> | 29 | #include <linux/module.h> |
29 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
@@ -31,6 +32,7 @@ | |||
31 | #include <linux/regulator/machine.h> | 32 | #include <linux/regulator/machine.h> |
32 | #include <linux/mfd/max8997.h> | 33 | #include <linux/mfd/max8997.h> |
33 | #include <linux/mfd/max8997-private.h> | 34 | #include <linux/mfd/max8997-private.h> |
35 | #include <linux/regulator/of_regulator.h> | ||
34 | 36 | ||
35 | struct max8997_data { | 37 | struct max8997_data { |
36 | struct device *dev; | 38 | struct device *dev; |
@@ -933,10 +935,145 @@ static struct regulator_desc regulators[] = { | |||
933 | max8997_charger_fixedstate_ops), | 935 | max8997_charger_fixedstate_ops), |
934 | }; | 936 | }; |
935 | 937 | ||
938 | #ifdef CONFIG_OF | ||
939 | static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, | ||
940 | struct max8997_platform_data *pdata, | ||
941 | struct device_node *pmic_np) | ||
942 | { | ||
943 | int i, gpio; | ||
944 | |||
945 | for (i = 0; i < 3; i++) { | ||
946 | gpio = of_get_named_gpio(pmic_np, | ||
947 | "max8997,pmic-buck125-dvs-gpios", i); | ||
948 | if (!gpio_is_valid(gpio)) { | ||
949 | dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); | ||
950 | return -EINVAL; | ||
951 | } | ||
952 | pdata->buck125_gpios[i] = gpio; | ||
953 | } | ||
954 | return 0; | ||
955 | } | ||
956 | |||
957 | static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | ||
958 | struct max8997_platform_data *pdata) | ||
959 | { | ||
960 | struct device_node *pmic_np, *regulators_np, *reg_np; | ||
961 | struct max8997_regulator_data *rdata; | ||
962 | unsigned int i, dvs_voltage_nr = 1, ret; | ||
963 | |||
964 | pmic_np = iodev->dev->of_node; | ||
965 | if (!pmic_np) { | ||
966 | dev_err(iodev->dev, "could not find pmic sub-node\n"); | ||
967 | return -ENODEV; | ||
968 | } | ||
969 | |||
970 | regulators_np = of_find_node_by_name(pmic_np, "regulators"); | ||
971 | if (!regulators_np) { | ||
972 | dev_err(iodev->dev, "could not find regulators sub-node\n"); | ||
973 | return -EINVAL; | ||
974 | } | ||
975 | |||
976 | /* count the number of regulators to be supported in pmic */ | ||
977 | pdata->num_regulators = 0; | ||
978 | for_each_child_of_node(regulators_np, reg_np) | ||
979 | pdata->num_regulators++; | ||
980 | |||
981 | rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * | ||
982 | pdata->num_regulators, GFP_KERNEL); | ||
983 | if (!rdata) { | ||
984 | dev_err(iodev->dev, "could not allocate memory for " | ||
985 | "regulator data\n"); | ||
986 | return -ENOMEM; | ||
987 | } | ||
988 | |||
989 | pdata->regulators = rdata; | ||
990 | for_each_child_of_node(regulators_np, reg_np) { | ||
991 | for (i = 0; i < ARRAY_SIZE(regulators); i++) | ||
992 | if (!of_node_cmp(reg_np->name, regulators[i].name)) | ||
993 | break; | ||
994 | |||
995 | if (i == ARRAY_SIZE(regulators)) { | ||
996 | dev_warn(iodev->dev, "don't know how to configure " | ||
997 | "regulator %s\n", reg_np->name); | ||
998 | continue; | ||
999 | } | ||
1000 | |||
1001 | rdata->id = i; | ||
1002 | rdata->initdata = of_get_regulator_init_data( | ||
1003 | iodev->dev, reg_np); | ||
1004 | rdata->reg_node = reg_np; | ||
1005 | rdata++; | ||
1006 | } | ||
1007 | |||
1008 | if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL)) | ||
1009 | pdata->buck1_gpiodvs = true; | ||
1010 | |||
1011 | if (of_get_property(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs", NULL)) | ||
1012 | pdata->buck2_gpiodvs = true; | ||
1013 | |||
1014 | if (of_get_property(pmic_np, "max8997,pmic-buck5-uses-gpio-dvs", NULL)) | ||
1015 | pdata->buck5_gpiodvs = true; | ||
1016 | |||
1017 | if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs || | ||
1018 | pdata->buck5_gpiodvs) { | ||
1019 | ret = max8997_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); | ||
1020 | if (ret) | ||
1021 | return -EINVAL; | ||
1022 | |||
1023 | if (of_property_read_u32(pmic_np, | ||
1024 | "max8997,pmic-buck125-default-dvs-idx", | ||
1025 | &pdata->buck125_default_idx)) { | ||
1026 | pdata->buck125_default_idx = 0; | ||
1027 | } else { | ||
1028 | if (pdata->buck125_default_idx >= 8) { | ||
1029 | pdata->buck125_default_idx = 0; | ||
1030 | dev_info(iodev->dev, "invalid value for " | ||
1031 | "default dvs index, using 0 instead\n"); | ||
1032 | } | ||
1033 | } | ||
1034 | |||
1035 | if (of_get_property(pmic_np, | ||
1036 | "max8997,pmic-ignore-gpiodvs-side-effect", NULL)) | ||
1037 | pdata->ignore_gpiodvs_side_effect = true; | ||
1038 | |||
1039 | dvs_voltage_nr = 8; | ||
1040 | } | ||
1041 | |||
1042 | if (of_property_read_u32_array(pmic_np, | ||
1043 | "max8997,pmic-buck1-dvs-voltage", | ||
1044 | pdata->buck1_voltage, dvs_voltage_nr)) { | ||
1045 | dev_err(iodev->dev, "buck1 voltages not specified\n"); | ||
1046 | return -EINVAL; | ||
1047 | } | ||
1048 | |||
1049 | if (of_property_read_u32_array(pmic_np, | ||
1050 | "max8997,pmic-buck2-dvs-voltage", | ||
1051 | pdata->buck2_voltage, dvs_voltage_nr)) { | ||
1052 | dev_err(iodev->dev, "buck2 voltages not specified\n"); | ||
1053 | return -EINVAL; | ||
1054 | } | ||
1055 | |||
1056 | if (of_property_read_u32_array(pmic_np, | ||
1057 | "max8997,pmic-buck5-dvs-voltage", | ||
1058 | pdata->buck5_voltage, dvs_voltage_nr)) { | ||
1059 | dev_err(iodev->dev, "buck5 voltages not specified\n"); | ||
1060 | return -EINVAL; | ||
1061 | } | ||
1062 | |||
1063 | return 0; | ||
1064 | } | ||
1065 | #else | ||
1066 | static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | ||
1067 | struct max8997_platform_data *pdata) | ||
1068 | { | ||
1069 | return 0; | ||
1070 | } | ||
1071 | #endif /* CONFIG_OF */ | ||
1072 | |||
936 | static __devinit int max8997_pmic_probe(struct platform_device *pdev) | 1073 | static __devinit int max8997_pmic_probe(struct platform_device *pdev) |
937 | { | 1074 | { |
938 | struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 1075 | struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
939 | struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); | 1076 | struct max8997_platform_data *pdata = iodev->pdata; |
940 | struct regulator_config config = { }; | 1077 | struct regulator_config config = { }; |
941 | struct regulator_dev **rdev; | 1078 | struct regulator_dev **rdev; |
942 | struct max8997_data *max8997; | 1079 | struct max8997_data *max8997; |
@@ -944,11 +1081,17 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
944 | int i, ret, size, nr_dvs; | 1081 | int i, ret, size, nr_dvs; |
945 | u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0; | 1082 | u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0; |
946 | 1083 | ||
947 | if (!pdata) { | 1084 | if (IS_ERR_OR_NULL(pdata)) { |
948 | dev_err(pdev->dev.parent, "No platform init data supplied.\n"); | 1085 | dev_err(pdev->dev.parent, "No platform init data supplied.\n"); |
949 | return -ENODEV; | 1086 | return -ENODEV; |
950 | } | 1087 | } |
951 | 1088 | ||
1089 | if (iodev->dev->of_node) { | ||
1090 | ret = max8997_pmic_dt_parse_pdata(iodev, pdata); | ||
1091 | if (ret) | ||
1092 | return ret; | ||
1093 | } | ||
1094 | |||
952 | max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data), | 1095 | max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data), |
953 | GFP_KERNEL); | 1096 | GFP_KERNEL); |
954 | if (!max8997) | 1097 | if (!max8997) |
@@ -1104,6 +1247,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1104 | config.dev = max8997->dev; | 1247 | config.dev = max8997->dev; |
1105 | config.init_data = pdata->regulators[i].initdata; | 1248 | config.init_data = pdata->regulators[i].initdata; |
1106 | config.driver_data = max8997; | 1249 | config.driver_data = max8997; |
1250 | config.of_node = pdata->regulators[i].reg_node; | ||
1107 | 1251 | ||
1108 | rdev[i] = regulator_register(®ulators[id], &config); | 1252 | rdev[i] = regulator_register(®ulators[id], &config); |
1109 | if (IS_ERR(rdev[i])) { | 1253 | if (IS_ERR(rdev[i])) { |
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 830152cfae33..6ae21bf47d64 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
@@ -316,6 +316,7 @@ enum max8997_irq { | |||
316 | #define MAX8997_NUM_GPIO 12 | 316 | #define MAX8997_NUM_GPIO 12 |
317 | struct max8997_dev { | 317 | struct max8997_dev { |
318 | struct device *dev; | 318 | struct device *dev; |
319 | struct max8997_platform_data *pdata; | ||
319 | struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */ | 320 | struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */ |
320 | struct i2c_client *rtc; /* slave addr 0x0c */ | 321 | struct i2c_client *rtc; /* slave addr 0x0c */ |
321 | struct i2c_client *haptic; /* slave addr 0x90 */ | 322 | struct i2c_client *haptic; /* slave addr 0x90 */ |
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h index 328d8e24b533..1d4a4fe6ac33 100644 --- a/include/linux/mfd/max8997.h +++ b/include/linux/mfd/max8997.h | |||
@@ -75,6 +75,7 @@ enum max8998_regulators { | |||
75 | struct max8997_regulator_data { | 75 | struct max8997_regulator_data { |
76 | int id; | 76 | int id; |
77 | struct regulator_init_data *initdata; | 77 | struct regulator_init_data *initdata; |
78 | struct device_node *reg_node; | ||
78 | }; | 79 | }; |
79 | 80 | ||
80 | enum max8997_muic_usb_type { | 81 | enum max8997_muic_usb_type { |