Lines Matching refs:data
49 struct max8903_data *data = power_supply_get_drvdata(psy); in max8903_get_property() local
54 if (data->chg) { in max8903_get_property()
55 if (gpiod_get_value(data->chg)) in max8903_get_property()
58 else if (data->usb_in || data->ta_in) in max8903_get_property()
66 if (data->usb_in || data->ta_in) in max8903_get_property()
71 if (data->fault) in max8903_get_property()
83 struct max8903_data *data = _data; in max8903_dcin() local
94 ta_in = gpiod_get_value(data->dok); in max8903_dcin()
96 if (ta_in == data->ta_in) in max8903_dcin()
99 data->ta_in = ta_in; in max8903_dcin()
102 if (data->dcm) in max8903_dcin()
103 gpiod_set_value(data->dcm, ta_in); in max8903_dcin()
106 if (data->cen) { in max8903_dcin()
112 else if (data->usb_in) in max8903_dcin()
119 gpiod_set_value(data->cen, val); in max8903_dcin()
122 dev_dbg(data->dev, "TA(DC-IN) Charger %s.\n", ta_in ? in max8903_dcin()
125 old_type = data->psy_desc.type; in max8903_dcin()
127 if (data->ta_in) in max8903_dcin()
128 data->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; in max8903_dcin()
129 else if (data->usb_in) in max8903_dcin()
130 data->psy_desc.type = POWER_SUPPLY_TYPE_USB; in max8903_dcin()
132 data->psy_desc.type = POWER_SUPPLY_TYPE_BATTERY; in max8903_dcin()
134 if (old_type != data->psy_desc.type) in max8903_dcin()
135 power_supply_changed(data->psy); in max8903_dcin()
142 struct max8903_data *data = _data; in max8903_usbin() local
153 usb_in = gpiod_get_value(data->uok); in max8903_usbin()
155 if (usb_in == data->usb_in) in max8903_usbin()
158 data->usb_in = usb_in; in max8903_usbin()
163 if (data->cen) { in max8903_usbin()
169 else if (data->ta_in) in max8903_usbin()
176 gpiod_set_value(data->cen, val); in max8903_usbin()
179 dev_dbg(data->dev, "USB Charger %s.\n", usb_in ? in max8903_usbin()
182 old_type = data->psy_desc.type; in max8903_usbin()
184 if (data->ta_in) in max8903_usbin()
185 data->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; in max8903_usbin()
186 else if (data->usb_in) in max8903_usbin()
187 data->psy_desc.type = POWER_SUPPLY_TYPE_USB; in max8903_usbin()
189 data->psy_desc.type = POWER_SUPPLY_TYPE_BATTERY; in max8903_usbin()
191 if (old_type != data->psy_desc.type) in max8903_usbin()
192 power_supply_changed(data->psy); in max8903_usbin()
199 struct max8903_data *data = _data; in max8903_fault() local
209 fault = gpiod_get_value(data->flt); in max8903_fault()
211 if (fault == data->fault) in max8903_fault()
214 data->fault = fault; in max8903_fault()
217 dev_err(data->dev, "Charger suffers a fault and stops.\n"); in max8903_fault()
219 dev_err(data->dev, "Charger recovered from a fault.\n"); in max8903_fault()
226 struct max8903_data *data = platform_get_drvdata(pdev); in max8903_setup_gpios() local
232 data->dok = devm_gpiod_get_optional(dev, "dok", GPIOD_IN); in max8903_setup_gpios()
233 if (IS_ERR(data->dok)) in max8903_setup_gpios()
234 return dev_err_probe(dev, PTR_ERR(data->dok), in max8903_setup_gpios()
236 if (data->dok) { in max8903_setup_gpios()
237 gpiod_set_consumer_name(data->dok, data->psy_desc.name); in max8903_setup_gpios()
244 ta_in = gpiod_get_value(data->dok); in max8903_setup_gpios()
247 data->uok = devm_gpiod_get_optional(dev, "uok", GPIOD_IN); in max8903_setup_gpios()
248 if (IS_ERR(data->uok)) in max8903_setup_gpios()
249 return dev_err_probe(dev, PTR_ERR(data->uok), in max8903_setup_gpios()
251 if (data->uok) { in max8903_setup_gpios()
252 gpiod_set_consumer_name(data->uok, data->psy_desc.name); in max8903_setup_gpios()
259 usb_in = gpiod_get_value(data->uok); in max8903_setup_gpios()
263 if (!data->dok && !data->uok) { in max8903_setup_gpios()
281 data->cen = devm_gpiod_get(dev, "cen", flags); in max8903_setup_gpios()
282 if (IS_ERR(data->cen)) in max8903_setup_gpios()
283 return dev_err_probe(dev, PTR_ERR(data->cen), in max8903_setup_gpios()
285 gpiod_set_consumer_name(data->cen, data->psy_desc.name); in max8903_setup_gpios()
295 data->dcm = devm_gpiod_get_optional(dev, "dcm", flags); in max8903_setup_gpios()
296 if (IS_ERR(data->dcm)) in max8903_setup_gpios()
297 return dev_err_probe(dev, PTR_ERR(data->dcm), in max8903_setup_gpios()
299 gpiod_set_consumer_name(data->dcm, data->psy_desc.name); in max8903_setup_gpios()
301 data->chg = devm_gpiod_get_optional(dev, "chg", GPIOD_IN); in max8903_setup_gpios()
302 if (IS_ERR(data->chg)) in max8903_setup_gpios()
303 return dev_err_probe(dev, PTR_ERR(data->chg), in max8903_setup_gpios()
305 gpiod_set_consumer_name(data->chg, data->psy_desc.name); in max8903_setup_gpios()
307 data->flt = devm_gpiod_get_optional(dev, "flt", GPIOD_IN); in max8903_setup_gpios()
308 if (IS_ERR(data->flt)) in max8903_setup_gpios()
309 return dev_err_probe(dev, PTR_ERR(data->flt), in max8903_setup_gpios()
311 gpiod_set_consumer_name(data->flt, data->psy_desc.name); in max8903_setup_gpios()
313 data->usus = devm_gpiod_get_optional(dev, "usus", GPIOD_IN); in max8903_setup_gpios()
314 if (IS_ERR(data->usus)) in max8903_setup_gpios()
315 return dev_err_probe(dev, PTR_ERR(data->usus), in max8903_setup_gpios()
317 gpiod_set_consumer_name(data->usus, data->psy_desc.name); in max8903_setup_gpios()
319 data->fault = false; in max8903_setup_gpios()
320 data->ta_in = ta_in; in max8903_setup_gpios()
321 data->usb_in = usb_in; in max8903_setup_gpios()
328 struct max8903_data *data; in max8903_probe() local
333 data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL); in max8903_probe()
334 if (!data) in max8903_probe()
337 data->dev = dev; in max8903_probe()
338 platform_set_drvdata(pdev, data); in max8903_probe()
344 data->psy_desc.name = "max8903_charger"; in max8903_probe()
345 data->psy_desc.type = (data->ta_in) ? POWER_SUPPLY_TYPE_MAINS : in max8903_probe()
346 ((data->usb_in) ? POWER_SUPPLY_TYPE_USB : in max8903_probe()
348 data->psy_desc.get_property = max8903_get_property; in max8903_probe()
349 data->psy_desc.properties = max8903_charger_props; in max8903_probe()
350 data->psy_desc.num_properties = ARRAY_SIZE(max8903_charger_props); in max8903_probe()
353 psy_cfg.drv_data = data; in max8903_probe()
355 data->psy = devm_power_supply_register(dev, &data->psy_desc, &psy_cfg); in max8903_probe()
356 if (IS_ERR(data->psy)) { in max8903_probe()
358 return PTR_ERR(data->psy); in max8903_probe()
361 if (data->dok) { in max8903_probe()
362 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->dok), in max8903_probe()
366 "MAX8903 DC IN", data); in max8903_probe()
369 gpiod_to_irq(data->dok), ret); in max8903_probe()
374 if (data->uok) { in max8903_probe()
375 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->uok), in max8903_probe()
379 "MAX8903 USB IN", data); in max8903_probe()
382 gpiod_to_irq(data->uok), ret); in max8903_probe()
387 if (data->flt) { in max8903_probe()
388 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->flt), in max8903_probe()
392 "MAX8903 Fault", data); in max8903_probe()
395 gpiod_to_irq(data->flt), ret); in max8903_probe()