/* * $Id: gpio.c,v 1.4 2003/05/19 22:24:18 lethal Exp $ * by Greg Banks * (c) 2000 PocketPenguins Inc * * GPIO pin support for HD64465 companion chip. */ #include #include #include #include #include #include #include #define _PORTOF(portpin) (((portpin)>>3)&0x7) #define _PINOF(portpin) ((portpin)&0x7) /* Register addresses parametrised on port */ #define GPIO_CR(port) (HD64465_REG_GPACR+((port)<<1)) #define GPIO_DR(port) (HD64465_REG_GPADR+((port)<<1)) #define GPIO_ICR(port) (HD64465_REG_GPAICR+((port)<<1)) #define GPIO_ISR(port) (HD64465_REG_GPAISR+((port)<<1)) #define GPIO_NPORTS 5 #define MODNAME "hd64465_gpio" EXPORT_SYMBOL(hd64465_gpio_configure); EXPORT_SYMBOL(hd64465_gpio_get_pin); EXPORT_SYMBOL(hd64465_gpio_get_port); EXPORT_SYMBOL(hd64465_gpio_register_irq); EXPORT_SYMBOL(hd64465_gpio_set_pin); EXPORT_SYMBOL(hd64465_gpio_set_port); EXPORT_SYMBOL(hd64465_gpio_unregister_irq); /* TODO: each port should be protected with a spinlock */ void hd64465_gpio_configure(int portpin, int direction) { unsigned short cr; unsigned int shift = (_PINOF(portpin)<<1); cr = inw(GPIO_CR(_PORTOF(portpin))); cr &= ~(3<