Lines Matching +full:pin +full:- +full:val

1 /*-
55 #define GPIO_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
56 #define GPIO_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
58 mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \
60 #define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
77 return (sc->busdev); in mpc85xx_gpio_get_bus()
88 /* Get a specific pin's capabilities. */
90 mpc85xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) in mpc85xx_gpio_pin_getcaps() argument
93 if (!VALID_PIN(pin)) in mpc85xx_gpio_pin_getcaps()
101 /* Get a specific pin's name. */
103 mpc85xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name) in mpc85xx_gpio_pin_getname() argument
106 if (!VALID_PIN(pin)) in mpc85xx_gpio_pin_getname()
109 snprintf(name, GPIOMAXNAME, "GPIO%d", pin); in mpc85xx_gpio_pin_getname()
110 name[GPIOMAXNAME-1] = '\0'; in mpc85xx_gpio_pin_getname()
115 /* Set a specific output pin's value. */
117 mpc85xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value) in mpc85xx_gpio_pin_set() argument
123 if (!VALID_PIN(pin) || value > 1) in mpc85xx_gpio_pin_set()
127 pinbit = 31 - pin; in mpc85xx_gpio_pin_set()
129 outvals = bus_read_4(sc->out_res, 0); in mpc85xx_gpio_pin_set()
132 bus_write_4(sc->out_res, 0, outvals); in mpc85xx_gpio_pin_set()
139 /* Get a specific pin's input value. */
141 mpc85xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *value) in mpc85xx_gpio_pin_get() argument
145 if (!VALID_PIN(pin)) in mpc85xx_gpio_pin_get()
148 *value = (bus_read_4(sc->in_res, 0) >> (31 - pin)) & 1; in mpc85xx_gpio_pin_get()
153 /* Toggle a pin's output value. */
155 mpc85xx_gpio_pin_toggle(device_t dev, uint32_t pin) in mpc85xx_gpio_pin_toggle() argument
158 uint32_t val; in mpc85xx_gpio_pin_toggle() local
160 if (!VALID_PIN(pin)) in mpc85xx_gpio_pin_toggle()
165 val = bus_read_4(sc->out_res, 0); in mpc85xx_gpio_pin_toggle()
166 val ^= (1 << (31 - pin)); in mpc85xx_gpio_pin_toggle()
167 bus_write_4(sc->out_res, 0, val); in mpc85xx_gpio_pin_toggle()
206 sc->dev = dev; in mpc85xx_gpio_attach()
212 sc->out_res = bus_alloc_resource_any(dev, in mpc85xx_gpio_attach()
214 if (sc->out_res == NULL) { in mpc85xx_gpio_attach()
221 sc->in_res = bus_alloc_resource_any(dev, in mpc85xx_gpio_attach()
223 if (sc->in_res == NULL) { in mpc85xx_gpio_attach()
229 sc->busdev = gpiobus_attach_bus(dev); in mpc85xx_gpio_attach()
230 if (sc->busdev == NULL) { in mpc85xx_gpio_attach()
247 if (sc->out_res != NULL) { in mpc85xx_gpio_detach()
250 rman_get_rid(sc->out_res), sc->out_res); in mpc85xx_gpio_detach()
253 if (sc->in_res != NULL) { in mpc85xx_gpio_detach()
256 rman_get_rid(sc->in_res), sc->in_res); in mpc85xx_gpio_detach()