Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gpio/gpiobus.c
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | gpio_check_flags(uint32_t caps, uint32_t flags) | ||||
flags &= caps; | flags &= caps; | ||||
/* Cannot mix input/output together. */ | /* Cannot mix input/output together. */ | ||||
if (flags & GPIO_PIN_INPUT && flags & GPIO_PIN_OUTPUT) | if (flags & GPIO_PIN_INPUT && flags & GPIO_PIN_OUTPUT) | ||||
return (EINVAL); | return (EINVAL); | ||||
/* Cannot mix pull-up/pull-down together. */ | /* Cannot mix pull-up/pull-down together. */ | ||||
if (flags & GPIO_PIN_PULLUP && flags & GPIO_PIN_PULLDOWN) | if (flags & GPIO_PIN_PULLUP && flags & GPIO_PIN_PULLDOWN) | ||||
return (EINVAL); | return (EINVAL); | ||||
/* Cannot mix output and interrupt flags together */ | |||||
if (flags & GPIO_PIN_OUTPUT && flags & GPIO_INTR_MASK) | |||||
return (EINVAL); | |||||
/* Only one interrupt flag can be defined at once */ | |||||
if ((flags & GPIO_INTR_MASK) & ((flags & GPIO_INTR_MASK) - 1)) | |||||
return (EINVAL); | |||||
/* The interrupt attached flag cannot be set */ | |||||
if (flags & GPIO_INTR_ATTACHED) | |||||
return (EINVAL); | |||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
gpio_pin_get_by_bus_pinnum(device_t busdev, uint32_t pinnum, gpio_pin_t *ppin) | gpio_pin_get_by_bus_pinnum(device_t busdev, uint32_t pinnum, gpio_pin_t *ppin) | ||||
{ | { | ||||
gpio_pin_t pin; | gpio_pin_t pin; | ||||
▲ Show 20 Lines • Show All 980 Lines • Show Last 20 Lines |