/* * Set the input direction. I'm not sure this is right; we should * be able to do input without disabling output.
*/ staticint via_gpio_dir_input(struct gpio_chip *chip, unsignedint nr)
{ struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); struct viafb_gpio *gpio; unsignedlong flags;
/* * Set up entries for all GPIOs which have been configured to * operate as such (as opposed to as i2c ports).
*/ for (i = 0; i < VIAFB_NUM_PORTS; i++) { if (port_cfg[i].mode != VIA_MODE_GPIO) continue; for (gpio = viafb_all_gpios;
gpio < viafb_all_gpios + VIAFB_NUM_GPIOS; gpio++) if (gpio->vg_port_index == port_cfg[i].ioport_index) {
viafb_gpio_config.active_gpios[ngpio] = gpio;
viafb_gpio_config.gpio_names[ngpio] =
gpio->vg_name;
ngpio++;
}
}
viafb_gpio_config.gpio_chip.ngpio = ngpio;
viafb_gpio_config.gpio_chip.names = viafb_gpio_config.gpio_names;
viafb_gpio_config.vdev = vdev; if (ngpio == 0) {
printk(KERN_INFO "viafb: no GPIOs configured\n"); return 0;
} /* * Enable the ports. They come in pairs, with a single * enable bit for both.
*/
spin_lock_irqsave(&viafb_gpio_config.vdev->reg_lock, flags); for (i = 0; i < ngpio; i += 2)
viafb_gpio_enable(viafb_gpio_config.active_gpios[i]);
spin_unlock_irqrestore(&viafb_gpio_config.vdev->reg_lock, flags); /* * Get registered.
*/
viafb_gpio_config.gpio_chip.base = -1; /* Dynamic */
viafb_gpio_config.gpio_chip.label = "via-gpio";
ret = gpiochip_add_data(&viafb_gpio_config.gpio_chip,
&viafb_gpio_config); if (ret) {
printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret);
viafb_gpio_config.gpio_chip.ngpio = 0;
}
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.