Lines Matching +full:port +full:- +full:expander
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
30 * Driver for TI TCA64XX I2C GPIO expander module.
173 msgs[0].slave = sc->addr; in tca64xx_read()
178 msgs[1].slave = sc->addr; in tca64xx_read()
197 msg.slave = sc->addr; in tca64xx_write()
216 switch (compat_ptr->ocd_data) { in tca64xx_probe()
218 device_set_desc(dev, "TCA6416 I/O expander"); in tca64xx_probe()
221 device_set_desc(dev, "TCA6408 I/O expander"); in tca64xx_probe()
239 switch (compat_ptr->ocd_data) { in tca64xx_attach()
241 sc->in_port_reg = TCA6416_IN_PORT_REG; in tca64xx_attach()
242 sc->out_port_reg = TCA6416_OUT_PORT_REG; in tca64xx_attach()
243 sc->polarity_inv_reg = TCA6416_POLARITY_INV_REG; in tca64xx_attach()
244 sc->conf_reg = TCA6416_CONF_REG; in tca64xx_attach()
245 sc->num_pins = TCA6416_NUM_PINS; in tca64xx_attach()
248 sc->in_port_reg = TCA6408_IN_PORT_REG; in tca64xx_attach()
249 sc->out_port_reg = TCA6408_OUT_PORT_REG; in tca64xx_attach()
250 sc->polarity_inv_reg = TCA6408_POLARITY_INV_REG; in tca64xx_attach()
251 sc->conf_reg = TCA6408_CONF_REG; in tca64xx_attach()
252 sc->num_pins = TCA6408_NUM_PINS; in tca64xx_attach()
258 sc->pin_caps = TCA64XX_PIN_CAPS; in tca64xx_attach()
259 sc->chip = compat_ptr->ocd_data; in tca64xx_attach()
260 sc->dev = dev; in tca64xx_attach()
261 sc->addr = iicbus_get_addr(dev); in tca64xx_attach()
263 mtx_init(&sc->mtx, "tca64xx gpio", "gpio", MTX_DEF); in tca64xx_attach()
264 sc->busdev = gpiobus_attach_bus(dev); in tca64xx_attach()
265 if (sc->busdev == NULL) { in tca64xx_attach()
273 switch (sc->chip) { in tca64xx_attach()
295 if (sc->busdev != NULL) in tca64xx_detach()
296 gpiobus_detach_bus(sc->busdev); in tca64xx_detach()
298 mtx_destroy(&sc->mtx); in tca64xx_detach()
310 return (sc->busdev); in tca64xx_get_bus()
323 *maxpin = sc->num_pins-1; in tca64xx_pin_max()
335 if (pin >= sc->num_pins || caps == NULL) in tca64xx_pin_getcaps()
337 *caps = sc->pin_caps; in tca64xx_pin_getcaps()
353 if (pin >= sc->num_pins || pflags == NULL) in tca64xx_pin_getflags()
356 addr = TCA64XX_REG_ADDR(pin, sc->conf_reg); in tca64xx_pin_getflags()
363 addr = TCA64XX_REG_ADDR(pin, sc->polarity_inv_reg); in tca64xx_pin_getflags()
383 pins = sc->num_pins; in tca64xx_pin_setflags()
388 mtx_lock(&sc->mtx); in tca64xx_pin_setflags()
390 addr = TCA64XX_REG_ADDR(pin, sc->conf_reg); in tca64xx_pin_setflags()
395 addr = TCA64XX_REG_ADDR(pin, sc->polarity_inv_reg); in tca64xx_pin_setflags()
410 addr = TCA64XX_REG_ADDR(pin, sc->conf_reg); in tca64xx_pin_setflags()
415 addr = TCA64XX_REG_ADDR(pin, sc->polarity_inv_reg); in tca64xx_pin_setflags()
419 mtx_unlock(&sc->mtx); in tca64xx_pin_setflags()
430 if (pin >= sc->num_pins || name == NULL) in tca64xx_pin_getname()
448 pins = sc->num_pins; in tca64xx_pin_get()
449 addr = TCA64XX_REG_ADDR(pin, sc->in_port_reg); in tca64xx_pin_get()
474 pins = sc->num_pins; in tca64xx_pin_set()
475 addr = TCA64XX_REG_ADDR(pin, sc->out_port_reg); in tca64xx_pin_set()
483 mtx_lock(&sc->mtx); in tca64xx_pin_set()
487 mtx_unlock(&sc->mtx); in tca64xx_pin_set()
499 mtx_unlock(&sc->mtx); in tca64xx_pin_set()
504 mtx_unlock(&sc->mtx); in tca64xx_pin_set()
518 pins = sc->num_pins; in tca64xx_pin_toggle()
519 addr = TCA64XX_REG_ADDR(pin, sc->out_port_reg); in tca64xx_pin_toggle()
527 mtx_lock(&sc->mtx); in tca64xx_pin_toggle()
531 mtx_unlock(&sc->mtx); in tca64xx_pin_toggle()
540 mtx_unlock(&sc->mtx); in tca64xx_pin_toggle()
545 mtx_unlock(&sc->mtx); in tca64xx_pin_toggle()
562 TCA6416_IN_PORT_REG, tca64xx_regdump_sysctl, "A", "Input port 1"); in tca6416_regdump_setup()
566 "Input port 2"); in tca6416_regdump_setup()
570 "Output port 1"); in tca6416_regdump_setup()
574 "Output port 2"); in tca6416_regdump_setup()
603 TCA6408_IN_PORT_REG, tca64xx_regdump_sysctl, "A", "Input port 1"); in tca6408_regdump_setup()
607 "Output port 1"); in tca6408_regdump_setup()