diff options
author | imp <imp@FreeBSD.org> | 2008-08-19 22:17:14 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2008-08-19 22:17:14 +0000 |
commit | 22fd66a8292e0811d9f236972a7832459dde32ea (patch) | |
tree | 4e47480027d32f700c8633e0fd9f0e103ca46393 /sys/arm | |
parent | 22fa49d38263862b11570ad854335412d1901dda (diff) | |
download | FreeBSD-src-22fd66a8292e0811d9f236972a7832459dde32ea.zip FreeBSD-src-22fd66a8292e0811d9f236972a7832459dde32ea.tar.gz |
Provide hooks into the GPIO lines and the ability to set/clear
interrupts from them. This should be more generalized, but is
sufficient for now.
Submitted by: Hans Petter Selasky
Diffstat (limited to 'sys/arm')
-rw-r--r-- | sys/arm/at91/at91_pio.c | 43 | ||||
-rw-r--r-- | sys/arm/at91/at91_piovar.h | 4 |
2 files changed, 47 insertions, 0 deletions
diff --git a/sys/arm/at91/at91_pio.c b/sys/arm/at91/at91_pio.c index f8c1863..5db5994 100644 --- a/sys/arm/at91/at91_pio.c +++ b/sys/arm/at91/at91_pio.c @@ -349,6 +349,49 @@ at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask) PIO[PIO_CODR / 4] = data_mask; } +uint8_t +at91_pio_gpio_get(uint32_t pio, uint32_t data_mask) +{ + uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio); + + data_mask &= PIO[PIO_PDSR / 4]; + + return (data_mask ? 1 : 0); +} + +void +at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch) +{ + uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio); + + if (use_deglitch) + PIO[PIO_IFER / 4] = data_mask; + else + PIO[PIO_IFDR / 4] = data_mask; + return; +} + +void +at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, + int enable_interrupt) +{ + uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio); + + if (enable_interrupt) + PIO[PIO_IER / 4] = data_mask; + else + PIO[PIO_IDR / 4] = data_mask; + return; +} + +uint32_t +at91_pio_gpio_clear_interrupt(uint32_t pio) +{ + uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio); + /* reading this register will clear the interrupts */ + return (PIO[PIO_ISR / 4]); +} + static device_method_t at91_pio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, at91_pio_probe), diff --git a/sys/arm/at91/at91_piovar.h b/sys/arm/at91/at91_piovar.h index 6cfd6d5..1326085 100644 --- a/sys/arm/at91/at91_piovar.h +++ b/sys/arm/at91/at91_piovar.h @@ -35,5 +35,9 @@ void at91_pio_gpio_output(uint32_t pio, uint32_t output_enable_mask, int use_pullup); void at91_pio_gpio_set(uint32_t pio, uint32_t data_mask); void at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask); +uint8_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask); +void at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch); +void at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, int enable_interrupt); +uint32_t at91_pio_gpio_clear_interrupt(uint32_t pio); #endif /* ARM_AT91_AT91_PIOVAR_H */ |