Annotation of funnyos/arch/sam7s64/dev/gpiobtn.c, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * $Id$
! 3: */
! 4: #include <sys/types.h>
! 5: #include <sys/device.h>
! 6: #include <sys/gpio.h>
! 7: #include <sys/devctl.h>
! 8:
! 9: #include <arch/sam7s64/dev/gpioledvar.h> /* for DCGPIOLED_TOGGLE */
! 10:
! 11: /*
! 12: * AT91SAM7S64 buttons.
! 13: * There are two buttons: below green led and below yellow led;
! 14: * first is on PA19 (13 pin) and generates FIQ,
! 15: * second is on PA20 (16 pin) and generates an IRQ to the core.
! 16: */
! 17:
! 18: int gpiobtn_attach(struct device *, uint32_t, uint8_t);
! 19: void gpiobtn_interrupt(struct device *);
! 20:
! 21: struct gpiobtn_dd {
! 22: /* minor of 'gpioled' device which we will control */
! 23: uint8_t gd_gpioledminor;
! 24: };
! 25:
! 26: struct driver gpiobtn_dr = {
! 27: sizeof(struct gpiobtn_dd),
! 28: gpiobtn_attach,
! 29: NULL,
! 30: gpiobtn_interrupt
! 31: };
! 32:
! 33:
! 34: int
! 35: gpiobtn_attach(struct device *self, uint32_t loc, uint8_t flags)
! 36: {
! 37: struct gpiobtn_dd *ddp = self->dv_devdata;
! 38: struct gpio_controller *gcp = self->dv_parent->dv_aux;
! 39: struct gpio_pin pin;
! 40:
! 41: pin.gp_pinno = loc;
! 42: pin.gp_pio = 1; /* PIO mode */
! 43: pin.gp_flags = GPIO_PIN_INPUT;
! 44:
! 45: /*
! 46: * we are provided with hint on which 'gpioled' device we will control.
! 47: * this hint is passed to us by devconfig as 'flags'.
! 48: */
! 49: ddp->gd_gpioledminor = flags;
! 50:
! 51: printf("p64 onboard button (pio pin %d)\n", pin.gp_pinno);
! 52:
! 53: /* talk to gpio controller */
! 54: gcp->gc_pinset(gcp->gc_selfdd, pin);
! 55:
! 56: return(0);
! 57: }
! 58:
! 59:
! 60: void
! 61: gpiobtn_interrupt(struct device *self)
! 62: {
! 63: struct gpiobtn_dd *ddp = self->dv_devdata;
! 64: /*
! 65: * Use devctl to toggle gpioled.
! 66: */
! 67:
! 68: devctl("gpioled", ddp->gd_gpioledminor, DCGPIOLED_TOGGLE, NULL);
! 69: }
! 70:
! 71:
CVSweb