add ixp425_set_gpio to program the gpio interrupt type

This commit is contained in:
Sam Leffler 2009-06-22 20:38:55 +00:00
parent ad0be1f829
commit a8c053089c
3 changed files with 22 additions and 10 deletions

View File

@ -218,16 +218,7 @@ ata_avila_attach(device_t dev)
rman_set_bustag(&sc->sc_alt_ata, &sc->sc_expbus_tag);
rman_set_bushandle(&sc->sc_alt_ata, sc->sc_alt_ioh);
GPIO_CONF_WRITE_4(sa, IXP425_GPIO_GPOER,
GPIO_CONF_READ_4(sa, IXP425_GPIO_GPOER) | (1<<config->gpin));
/* set interrupt type */
GPIO_CONF_WRITE_4(sa, GPIO_TYPE_REG(config->gpin),
(GPIO_CONF_READ_4(sa, GPIO_TYPE_REG(config->gpin)) &~
GPIO_TYPE(config->gpin, GPIO_TYPE_MASK)) |
GPIO_TYPE(config->gpin, GPIO_TYPE_EDG_RISING));
/* clear ISR */
GPIO_CONF_WRITE_4(sa, IXP425_GPIO_GPISR, (1<<config->gpin));
ixp425_set_gpio(sa, config->gpin, GPIO_TYPE_EDG_RISING);
/* configure CS1/3 window, leaving timing unchanged */
EXP_BUS_WRITE_4(sc, sc->sc_16bit_off,

View File

@ -159,6 +159,25 @@ DB_SHOW_COMMAND(gpio, db_show_gpio)
}
#endif
void
ixp425_set_gpio(struct ixp425_softc *sc, int pin, int type)
{
uint32_t gpiotr = GPIO_CONF_READ_4(sc, GPIO_TYPE_REG(pin));
/* clear interrupt type */
GPIO_CONF_WRITE_4(sc, GPIO_TYPE_REG(pin),
gpiotr &~ GPIO_TYPE(pin, GPIO_TYPE_MASK));
/* clear any pending interrupt */
GPIO_CONF_WRITE_4(sc, IXP425_GPIO_GPISR, (1<<pin));
/* set new interrupt type */
GPIO_CONF_WRITE_4(sc, GPIO_TYPE_REG(pin),
gpiotr | GPIO_TYPE(pin, type));
/* configure gpio line as an input */
GPIO_CONF_WRITE_4(sc, IXP425_GPIO_GPOER,
GPIO_CONF_READ_4(sc, IXP425_GPIO_GPOER) | (1<<pin));
}
static __inline void
ixp425_gpio_ack(int irq)
{

View File

@ -65,6 +65,8 @@ struct ixp425_softc {
bus_dma_tag_t sc_dmat;
};
void ixp425_set_gpio(struct ixp425_softc *sc, int pin, int type);
struct ixppcib_softc {
device_t sc_dev;