• Home
  • Raw
  • Download

Lines Matching refs:gpio_charger

25 struct gpio_charger {  struct
51 static inline struct gpio_charger *psy_to_gpio_charger(struct power_supply *psy) in psy_to_gpio_charger() argument
56 static int set_charge_current_limit(struct gpio_charger *gpio_charger, int val) in set_charge_current_limit() argument
59 int ndescs = gpio_charger->current_limit_gpios->ndescs; in set_charge_current_limit()
60 struct gpio_desc **gpios = gpio_charger->current_limit_gpios->desc; in set_charge_current_limit()
63 if (!gpio_charger->current_limit_map_size) in set_charge_current_limit()
66 for (i = 0; i < gpio_charger->current_limit_map_size; i++) { in set_charge_current_limit()
67 if (gpio_charger->current_limit_map[i].limit_ua <= val) in set_charge_current_limit()
70 mapping = gpio_charger->current_limit_map[i]; in set_charge_current_limit()
77 gpio_charger->charge_current_limit = mapping.limit_ua; in set_charge_current_limit()
79 dev_dbg(gpio_charger->dev, "set charge current limit to %d (requested: %d)\n", in set_charge_current_limit()
80 gpio_charger->charge_current_limit, val); in set_charge_current_limit()
88 struct gpio_charger *gpio_charger = psy_to_gpio_charger(psy); in gpio_charger_get_property() local
92 val->intval = gpiod_get_value_cansleep(gpio_charger->gpiod); in gpio_charger_get_property()
95 if (gpiod_get_value_cansleep(gpio_charger->charge_status)) in gpio_charger_get_property()
101 val->intval = gpio_charger->charge_current_limit; in gpio_charger_get_property()
113 struct gpio_charger *gpio_charger = psy_to_gpio_charger(psy); in gpio_charger_set_property() local
117 return set_charge_current_limit(gpio_charger, val->intval); in gpio_charger_set_property()
186 struct gpio_charger *gpio_charger) in init_charge_current_limit() argument
191 gpio_charger->current_limit_gpios = devm_gpiod_get_array_optional(dev, in init_charge_current_limit()
193 if (IS_ERR(gpio_charger->current_limit_gpios)) { in init_charge_current_limit()
195 return PTR_ERR(gpio_charger->current_limit_gpios); in init_charge_current_limit()
198 if (!gpio_charger->current_limit_gpios) in init_charge_current_limit()
211 gpio_charger->current_limit_map = devm_kmalloc_array(dev, in init_charge_current_limit()
212 len / 2, sizeof(*gpio_charger->current_limit_map), GFP_KERNEL); in init_charge_current_limit()
213 if (!gpio_charger->current_limit_map) in init_charge_current_limit()
216 gpio_charger->current_limit_map_size = len / 2; in init_charge_current_limit()
219 (u32*) gpio_charger->current_limit_map, len); in init_charge_current_limit()
223 for (i=0; i < gpio_charger->current_limit_map_size; i++) { in init_charge_current_limit()
224 if (gpio_charger->current_limit_map[i].limit_ua > cur_limit) { in init_charge_current_limit()
229 cur_limit = gpio_charger->current_limit_map[i].limit_ua; in init_charge_current_limit()
233 len = gpio_charger->current_limit_map_size - 1; in init_charge_current_limit()
234 set_charge_current_limit(gpio_charger, in init_charge_current_limit()
235 gpio_charger->current_limit_map[len].limit_ua); in init_charge_current_limit()
256 struct gpio_charger *gpio_charger; in gpio_charger_probe() local
268 gpio_charger = devm_kzalloc(dev, sizeof(*gpio_charger), GFP_KERNEL); in gpio_charger_probe()
269 if (!gpio_charger) in gpio_charger_probe()
271 gpio_charger->dev = dev; in gpio_charger_probe()
277 gpio_charger->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); in gpio_charger_probe()
278 if (IS_ERR(gpio_charger->gpiod)) { in gpio_charger_probe()
280 return dev_err_probe(dev, PTR_ERR(gpio_charger->gpiod), in gpio_charger_probe()
284 if (gpio_charger->gpiod) { in gpio_charger_probe()
293 gpio_charger->charge_status = charge_status; in gpio_charger_probe()
298 ret = init_charge_current_limit(dev, gpio_charger); in gpio_charger_probe()
301 if (gpio_charger->current_limit_map) { in gpio_charger_probe()
307 charger_desc = &gpio_charger->charger_desc; in gpio_charger_probe()
316 psy_cfg.drv_data = gpio_charger; in gpio_charger_probe()
331 gpio_charger->charger = devm_power_supply_register(dev, charger_desc, in gpio_charger_probe()
333 if (IS_ERR(gpio_charger->charger)) { in gpio_charger_probe()
334 ret = PTR_ERR(gpio_charger->charger); in gpio_charger_probe()
339 gpio_charger->irq = gpio_charger_get_irq(dev, gpio_charger->charger, in gpio_charger_probe()
340 gpio_charger->gpiod); in gpio_charger_probe()
342 charge_status_irq = gpio_charger_get_irq(dev, gpio_charger->charger, in gpio_charger_probe()
343 gpio_charger->charge_status); in gpio_charger_probe()
344 gpio_charger->charge_status_irq = charge_status_irq; in gpio_charger_probe()
346 platform_set_drvdata(pdev, gpio_charger); in gpio_charger_probe()
356 struct gpio_charger *gpio_charger = dev_get_drvdata(dev); in gpio_charger_suspend() local
359 gpio_charger->wakeup_enabled = in gpio_charger_suspend()
360 !enable_irq_wake(gpio_charger->irq); in gpio_charger_suspend()
367 struct gpio_charger *gpio_charger = dev_get_drvdata(dev); in gpio_charger_resume() local
369 if (device_may_wakeup(dev) && gpio_charger->wakeup_enabled) in gpio_charger_resume()
370 disable_irq_wake(gpio_charger->irq); in gpio_charger_resume()
371 power_supply_changed(gpio_charger->charger); in gpio_charger_resume()