Lines Matching full:data

50 	struct max8903_data *data = power_supply_get_drvdata(psy);  in max8903_get_property()  local
55 if (data->chg) { in max8903_get_property()
56 if (gpiod_get_value(data->chg)) in max8903_get_property()
59 else if (data->usb_in || data->ta_in) in max8903_get_property()
67 if (data->usb_in || data->ta_in) in max8903_get_property()
72 if (data->fault) in max8903_get_property()
84 struct max8903_data *data = _data; in max8903_dcin() local
95 ta_in = gpiod_get_value(data->dok); in max8903_dcin()
97 if (ta_in == data->ta_in) in max8903_dcin()
100 data->ta_in = ta_in; in max8903_dcin()
103 if (data->dcm) in max8903_dcin()
104 gpiod_set_value(data->dcm, ta_in); in max8903_dcin()
107 if (data->cen) { in max8903_dcin()
113 else if (data->usb_in) in max8903_dcin()
120 gpiod_set_value(data->cen, val); in max8903_dcin()
123 dev_dbg(data->dev, "TA(DC-IN) Charger %s.\n", ta_in ? in max8903_dcin()
126 old_type = data->psy_desc.type; in max8903_dcin()
128 if (data->ta_in) in max8903_dcin()
129 data->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; in max8903_dcin()
130 else if (data->usb_in) in max8903_dcin()
131 data->psy_desc.type = POWER_SUPPLY_TYPE_USB; in max8903_dcin()
133 data->psy_desc.type = POWER_SUPPLY_TYPE_BATTERY; in max8903_dcin()
135 if (old_type != data->psy_desc.type) in max8903_dcin()
136 power_supply_changed(data->psy); in max8903_dcin()
143 struct max8903_data *data = _data; in max8903_usbin() local
154 usb_in = gpiod_get_value(data->uok); in max8903_usbin()
156 if (usb_in == data->usb_in) in max8903_usbin()
159 data->usb_in = usb_in; in max8903_usbin()
164 if (data->cen) { in max8903_usbin()
170 else if (data->ta_in) in max8903_usbin()
177 gpiod_set_value(data->cen, val); in max8903_usbin()
180 dev_dbg(data->dev, "USB Charger %s.\n", usb_in ? in max8903_usbin()
183 old_type = data->psy_desc.type; in max8903_usbin()
185 if (data->ta_in) in max8903_usbin()
186 data->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; in max8903_usbin()
187 else if (data->usb_in) in max8903_usbin()
188 data->psy_desc.type = POWER_SUPPLY_TYPE_USB; in max8903_usbin()
190 data->psy_desc.type = POWER_SUPPLY_TYPE_BATTERY; in max8903_usbin()
192 if (old_type != data->psy_desc.type) in max8903_usbin()
193 power_supply_changed(data->psy); in max8903_usbin()
200 struct max8903_data *data = _data; in max8903_fault() local
210 fault = gpiod_get_value(data->flt); in max8903_fault()
212 if (fault == data->fault) in max8903_fault()
215 data->fault = fault; in max8903_fault()
218 dev_err(data->dev, "Charger suffers a fault and stops.\n"); in max8903_fault()
220 dev_err(data->dev, "Charger recovered from a fault.\n"); in max8903_fault()
227 struct max8903_data *data = platform_get_drvdata(pdev); in max8903_setup_gpios() local
233 data->dok = devm_gpiod_get_optional(dev, "dok", GPIOD_IN); in max8903_setup_gpios()
234 if (IS_ERR(data->dok)) in max8903_setup_gpios()
235 return dev_err_probe(dev, PTR_ERR(data->dok), in max8903_setup_gpios()
237 if (data->dok) { in max8903_setup_gpios()
238 gpiod_set_consumer_name(data->dok, data->psy_desc.name); in max8903_setup_gpios()
245 ta_in = gpiod_get_value(data->dok); in max8903_setup_gpios()
248 data->uok = devm_gpiod_get_optional(dev, "uok", GPIOD_IN); in max8903_setup_gpios()
249 if (IS_ERR(data->uok)) in max8903_setup_gpios()
250 return dev_err_probe(dev, PTR_ERR(data->uok), in max8903_setup_gpios()
252 if (data->uok) { in max8903_setup_gpios()
253 gpiod_set_consumer_name(data->uok, data->psy_desc.name); in max8903_setup_gpios()
260 usb_in = gpiod_get_value(data->uok); in max8903_setup_gpios()
264 if (!data->dok && !data->uok) { in max8903_setup_gpios()
282 data->cen = devm_gpiod_get(dev, "cen", flags); in max8903_setup_gpios()
283 if (IS_ERR(data->cen)) in max8903_setup_gpios()
284 return dev_err_probe(dev, PTR_ERR(data->cen), in max8903_setup_gpios()
286 gpiod_set_consumer_name(data->cen, data->psy_desc.name); in max8903_setup_gpios()
296 data->dcm = devm_gpiod_get_optional(dev, "dcm", flags); in max8903_setup_gpios()
297 if (IS_ERR(data->dcm)) in max8903_setup_gpios()
298 return dev_err_probe(dev, PTR_ERR(data->dcm), in max8903_setup_gpios()
300 gpiod_set_consumer_name(data->dcm, data->psy_desc.name); in max8903_setup_gpios()
302 data->chg = devm_gpiod_get_optional(dev, "chg", GPIOD_IN); in max8903_setup_gpios()
303 if (IS_ERR(data->chg)) in max8903_setup_gpios()
304 return dev_err_probe(dev, PTR_ERR(data->chg), in max8903_setup_gpios()
306 gpiod_set_consumer_name(data->chg, data->psy_desc.name); in max8903_setup_gpios()
308 data->flt = devm_gpiod_get_optional(dev, "flt", GPIOD_IN); in max8903_setup_gpios()
309 if (IS_ERR(data->flt)) in max8903_setup_gpios()
310 return dev_err_probe(dev, PTR_ERR(data->flt), in max8903_setup_gpios()
312 gpiod_set_consumer_name(data->flt, data->psy_desc.name); in max8903_setup_gpios()
314 data->usus = devm_gpiod_get_optional(dev, "usus", GPIOD_IN); in max8903_setup_gpios()
315 if (IS_ERR(data->usus)) in max8903_setup_gpios()
316 return dev_err_probe(dev, PTR_ERR(data->usus), in max8903_setup_gpios()
318 gpiod_set_consumer_name(data->usus, data->psy_desc.name); in max8903_setup_gpios()
320 data->fault = false; in max8903_setup_gpios()
321 data->ta_in = ta_in; in max8903_setup_gpios()
322 data->usb_in = usb_in; in max8903_setup_gpios()
329 struct max8903_data *data; in max8903_probe() local
334 data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL); in max8903_probe()
335 if (!data) in max8903_probe()
338 data->dev = dev; in max8903_probe()
339 platform_set_drvdata(pdev, data); in max8903_probe()
345 data->psy_desc.name = "max8903_charger"; in max8903_probe()
346 data->psy_desc.type = (data->ta_in) ? POWER_SUPPLY_TYPE_MAINS : in max8903_probe()
347 ((data->usb_in) ? POWER_SUPPLY_TYPE_USB : in max8903_probe()
349 data->psy_desc.get_property = max8903_get_property; in max8903_probe()
350 data->psy_desc.properties = max8903_charger_props; in max8903_probe()
351 data->psy_desc.num_properties = ARRAY_SIZE(max8903_charger_props); in max8903_probe()
354 psy_cfg.drv_data = data; in max8903_probe()
356 data->psy = devm_power_supply_register(dev, &data->psy_desc, &psy_cfg); in max8903_probe()
357 if (IS_ERR(data->psy)) { in max8903_probe()
359 return PTR_ERR(data->psy); in max8903_probe()
362 if (data->dok) { in max8903_probe()
363 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->dok), in max8903_probe()
367 "MAX8903 DC IN", data); in max8903_probe()
370 gpiod_to_irq(data->dok), ret); in max8903_probe()
375 if (data->uok) { in max8903_probe()
376 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->uok), in max8903_probe()
380 "MAX8903 USB IN", data); in max8903_probe()
383 gpiod_to_irq(data->uok), ret); in max8903_probe()
388 if (data->flt) { in max8903_probe()
389 ret = devm_request_threaded_irq(dev, gpiod_to_irq(data->flt), in max8903_probe()
393 "MAX8903 Fault", data); in max8903_probe()
396 gpiod_to_irq(data->flt), ret); in max8903_probe()