static int __init x3proto_devices_setup(void) { int ret, i; /* * IRLs are only needed for ILSEL mappings, so flip over the INTC * pins at a later point to enable the GPIOs to settle. */ x3proto_init_irq(); /* * Now that ILSELs are available, set up the baseboard GPIOs. */ ret = x3proto_gpio_setup(); if (unlikely(ret)) return ret; /* * Propagate dynamic GPIOs for the baseboard button device. */ for (i = 0; i < ARRAY_SIZE(baseboard_buttons); i++) baseboard_buttons[i].gpio = x3proto_gpio_chip.base + i; r8a66597_usb_host_resources[1].start = r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I); m66592_usb_peripheral_resources[1].start = m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I); smc91x_resources[1].start = smc91x_resources[1].end = ilsel_enable(ILSEL_LAN); return platform_add_devices(x3proto_devices, ARRAY_SIZE(x3proto_devices)); }
static int __init x3proto_devices_setup(void) { r8a66597_usb_host_resources[1].start = r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I); m66592_usb_peripheral_resources[1].start = m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I); smc91x_resources[1].start = smc91x_resources[1].end = ilsel_enable(ILSEL_LAN); return platform_add_devices(x3proto_devices, ARRAY_SIZE(x3proto_devices)); }
int __init x3proto_gpio_setup(void) { int ilsel; int ret, i; ilsel = ilsel_enable(ILSEL_KEY); if (unlikely(ilsel < 0)) return ilsel; ret = gpiochip_add(&x3proto_gpio_chip); if (unlikely(ret)) goto err_gpio; for (i = 0; i < NR_BASEBOARD_GPIOS; i++) { unsigned long flags; int irq = create_irq(); if (unlikely(irq < 0)) { ret = -EINVAL; goto err_irq; } spin_lock_irqsave(&x3proto_gpio_lock, flags); x3proto_gpio_irq_map[i] = irq; irq_set_chip_and_handler_name(irq, &dummy_irq_chip, handle_simple_irq, "gpio"); spin_unlock_irqrestore(&x3proto_gpio_lock, flags); } pr_info("registering '%s' support, handling GPIOs %u -> %u, " "bound to IRQ %u\n", x3proto_gpio_chip.label, x3proto_gpio_chip.base, x3proto_gpio_chip.base + x3proto_gpio_chip.ngpio, ilsel); irq_set_chained_handler(ilsel, x3proto_gpio_irq_handler); irq_set_irq_wake(ilsel, 1); return 0; err_irq: for (; i >= 0; --i) if (x3proto_gpio_irq_map[i]) destroy_irq(x3proto_gpio_irq_map[i]); ret = gpiochip_remove(&x3proto_gpio_chip); if (unlikely(ret)) pr_err("Failed deregistering GPIO\n"); err_gpio: synchronize_irq(ilsel); ilsel_disable(ILSEL_KEY); return ret; }
int __init x3proto_gpio_setup(void) { int ilsel, ret; ilsel = ilsel_enable(ILSEL_KEY); if (unlikely(ilsel < 0)) return ilsel; ret = gpiochip_add(&x3proto_gpio_chip); if (unlikely(ret)) goto err_gpio; x3proto_irq_domain = irq_domain_add_linear(NULL, NR_BASEBOARD_GPIOS, &x3proto_gpio_irq_ops, NULL); if (unlikely(!x3proto_irq_domain)) goto err_irq; pr_info("registering '%s' support, handling GPIOs %u -> %u, " "bound to IRQ %u\n", x3proto_gpio_chip.label, x3proto_gpio_chip.base, x3proto_gpio_chip.base + x3proto_gpio_chip.ngpio, ilsel); irq_set_chained_handler(ilsel, x3proto_gpio_irq_handler); irq_set_irq_wake(ilsel, 1); return 0; err_irq: gpiochip_remove(&x3proto_gpio_chip); ret = 0; err_gpio: synchronize_irq(ilsel); ilsel_disable(ILSEL_KEY); return ret; }