Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/gpio/gpiokeys.c
Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | gpiokeys_attach_key(struct gpiokeys_softc *sc, phandle_t node, | ||||
else | else | ||||
device_printf(sc->sc_dev, "<%s> no linux,code or freebsd,code property\n", | device_printf(sc->sc_dev, "<%s> no linux,code or freebsd,code property\n", | ||||
key_name); | key_name); | ||||
err = gpio_pin_get_by_ofw_idx(sc->sc_dev, node, 0, &key->pin); | err = gpio_pin_get_by_ofw_idx(sc->sc_dev, node, 0, &key->pin); | ||||
if (err) { | if (err) { | ||||
device_printf(sc->sc_dev, "<%s> failed to map pin\n", key_name); | device_printf(sc->sc_dev, "<%s> failed to map pin\n", key_name); | ||||
if (name) | if (name) | ||||
free(name, M_OFWPROP); | OF_prop_free(name); | ||||
return; | return; | ||||
} | } | ||||
key->irq_res = gpio_alloc_intr_resource(sc->sc_dev, &key->irq_rid, | key->irq_res = gpio_alloc_intr_resource(sc->sc_dev, &key->irq_rid, | ||||
RF_ACTIVE, key->pin, GPIO_INTR_EDGE_BOTH); | RF_ACTIVE, key->pin, GPIO_INTR_EDGE_BOTH); | ||||
if (!key->irq_res) { | if (!key->irq_res) { | ||||
device_printf(sc->sc_dev, "<%s> cannot allocate interrupt\n", key_name); | device_printf(sc->sc_dev, "<%s> cannot allocate interrupt\n", key_name); | ||||
gpio_pin_release(key->pin); | gpio_pin_release(key->pin); | ||||
key->pin = NULL; | key->pin = NULL; | ||||
if (name) | if (name) | ||||
free(name, M_OFWPROP); | OF_prop_free(name); | ||||
return; | return; | ||||
} | } | ||||
if (bus_setup_intr(sc->sc_dev, key->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, | if (bus_setup_intr(sc->sc_dev, key->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, | ||||
NULL, gpiokey_intr, key, | NULL, gpiokey_intr, key, | ||||
&key->intr_hl) != 0) { | &key->intr_hl) != 0) { | ||||
device_printf(sc->sc_dev, "<%s> unable to setup the irq handler\n", key_name); | device_printf(sc->sc_dev, "<%s> unable to setup the irq handler\n", key_name); | ||||
bus_release_resource(sc->sc_dev, SYS_RES_IRQ, key->irq_rid, | bus_release_resource(sc->sc_dev, SYS_RES_IRQ, key->irq_rid, | ||||
key->irq_res); | key->irq_res); | ||||
gpio_pin_release(key->pin); | gpio_pin_release(key->pin); | ||||
key->pin = NULL; | key->pin = NULL; | ||||
key->irq_res = NULL; | key->irq_res = NULL; | ||||
if (name) | if (name) | ||||
free(name, M_OFWPROP); | OF_prop_free(name); | ||||
return; | return; | ||||
} | } | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->sc_dev, "<%s> code=%08x, autorepeat=%d, "\ | device_printf(sc->sc_dev, "<%s> code=%08x, autorepeat=%d, "\ | ||||
"repeat=%d, repeat_delay=%d\n", key_name, key->keycode, | "repeat=%d, repeat_delay=%d\n", key_name, key->keycode, | ||||
key->autorepeat, key->repeat, key->repeat_delay); | key->autorepeat, key->repeat, key->repeat_delay); | ||||
if (name) | if (name) | ||||
free(name, M_OFWPROP); | OF_prop_free(name); | ||||
} | } | ||||
static void | static void | ||||
gpiokeys_detach_key(struct gpiokeys_softc *sc, struct gpiokey *key) | gpiokeys_detach_key(struct gpiokeys_softc *sc, struct gpiokey *key) | ||||
{ | { | ||||
GPIOKEY_LOCK(key); | GPIOKEY_LOCK(key); | ||||
if (key->intr_hl) | if (key->intr_hl) | ||||
▲ Show 20 Lines • Show All 651 Lines • Show Last 20 Lines |