staticint collie_bat_resume(struct ucb1x00_dev *dev)
{ if (wakeup_enabled)
disable_irq_wake(gpiod_to_irq(collie_bat_main.gpio_full));
/* things may have changed while we were away */
schedule_work(&bat_work); return 0;
} #else #define collie_bat_suspend NULL #define collie_bat_resume NULL #endif
/* Obtain all the main battery GPIOs */
collie_bat_main.gpio_full = gpiod_get(&dev->ucb->dev, "main battery full",
GPIOD_IN); if (IS_ERR(collie_bat_main.gpio_full)) return PTR_ERR(collie_bat_main.gpio_full);
collie_mbat_low = gpiod_get(&dev->ucb->dev, "main battery low",
GPIOD_IN); if (IS_ERR(collie_mbat_low)) {
ret = PTR_ERR(collie_mbat_low); goto err_put_gpio_full;
}
collie_bat_main.gpio_charge_on = gpiod_get(&dev->ucb->dev, "main charge on",
GPIOD_OUT_LOW); if (IS_ERR(collie_bat_main.gpio_charge_on)) {
ret = PTR_ERR(collie_bat_main.gpio_charge_on); goto err_put_mbat_low;
}
/* COLLIE_GPIO_MBAT_ON = GPIO 7 on the UCB (TC35143) */
collie_bat_main.gpio_bat = gpiochip_request_own_desc(gc,
7, "main battery",
GPIO_ACTIVE_HIGH,
GPIOD_OUT_LOW); if (IS_ERR(collie_bat_main.gpio_bat)) {
ret = PTR_ERR(collie_bat_main.gpio_bat); goto err_put_gpio_charge_on;
}
/* COLLIE_GPIO_TMP_ON = GPIO 9 on the UCB (TC35143) */
collie_bat_main.gpio_temp = gpiochip_request_own_desc(gc,
9, "main battery temp",
GPIO_ACTIVE_HIGH,
GPIOD_OUT_LOW); if (IS_ERR(collie_bat_main.gpio_temp)) {
ret = PTR_ERR(collie_bat_main.gpio_temp); goto err_free_gpio_bat;
}
/* * Obtain the backup battery COLLIE_GPIO_BBAT_ON which is * GPIO 8 on the UCB (TC35143)
*/
collie_bat_bu.gpio_bat = gpiochip_request_own_desc(gc,
8, "backup battery",
GPIO_ACTIVE_HIGH,
GPIOD_OUT_LOW); if (IS_ERR(collie_bat_bu.gpio_bat)) {
ret = PTR_ERR(collie_bat_bu.gpio_bat); goto err_free_gpio_temp;
}
mutex_init(&collie_bat_main.work_lock);
INIT_WORK(&bat_work, collie_bat_work);
psy_main_cfg.drv_data = &collie_bat_main;
collie_bat_main.psy = power_supply_register(&dev->ucb->dev,
&collie_bat_main_desc,
&psy_main_cfg); if (IS_ERR(collie_bat_main.psy)) {
ret = PTR_ERR(collie_bat_main.psy); goto err_psy_reg_main;
}
psy_bu_cfg.drv_data = &collie_bat_bu;
collie_bat_bu.psy = power_supply_register(&dev->ucb->dev,
&collie_bat_bu_desc,
&psy_bu_cfg); if (IS_ERR(collie_bat_bu.psy)) {
ret = PTR_ERR(collie_bat_bu.psy); goto err_psy_reg_bu;
}
ret = request_irq(gpiod_to_irq(collie_bat_main.gpio_full),
collie_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "main full", &collie_bat_main); if (ret) goto err_irq;
/* These are obtained from the machine */
gpiod_put(collie_bat_main.gpio_full);
gpiod_put(collie_mbat_low);
gpiod_put(collie_bat_main.gpio_charge_on); /* These are directly from the UCB so let's free them */
gpiochip_free_own_desc(collie_bat_main.gpio_bat);
gpiochip_free_own_desc(collie_bat_main.gpio_temp);
gpiochip_free_own_desc(collie_bat_bu.gpio_bat); /* * Now cancel the bat_work. We won't get any more schedules, * since all sources (isr and external_power_changed) are * unregistered now.
*/
cancel_work_sync(&bat_work);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.