static int orion_gpio_get_value(struct gpio_chip *chip, unsigned pin) { int val; if (readl(GPIO_IO_CONF(pin)) & (1 << (pin & 31))) val = readl(GPIO_DATA_IN(pin)) ^ readl(GPIO_IN_POL(pin)); else val = readl(GPIO_OUT(pin)); return (val >> (pin & 31)) & 1; }
int gpio_get_value(unsigned pin) { int val; if (readl(GPIO_IO_CONF(pin)) & (1 << (pin & 31))) val = readl(GPIO_DATA_IN(pin)) ^ readl(GPIO_IN_POL(pin)); else val = readl(GPIO_OUT(pin)); return (val >> (pin & 31)) & 1; }
static irqreturn_t irq_handler(int i, void *blah, struct pt_regs *regs) #endif { u32 reg; int negate = 0; struct timeval tv; int counter, dcd; long deltv; int data; static int last_dcd = -1; static int count = 0; count++; /* First thing first - flip the bit */ reg = readl(GPIO_IN_POL(19)); if (reg & (1<< 19)) {reg &= ~(1<<19);negate=1;} else reg |= (1<< 19); writel(reg, GPIO_IN_POL(19)); /* Now read the actual data */ counter = 0; do { counter++; if (counter > RS_ISR_PASS_LIMIT) { printk(KERN_WARNING LIRC_DRIVER_NAME ": AIEEEE: " "We're caught!\n"); break; } if (1 /*(status & hardware[type].signal_pin_change) && sense != -1*/) { /* get current time */ do_gettimeofday(&tv); /* New mode, written by Trent Piepho <*****@*****.**>. */ /* * The old format was not very portable. * We now use an int to pass pulses * and spaces to user space. * * If PULSE_BIT is set a pulse has been * received, otherwise a space has been * received. The driver needs to know if your * receiver is active high or active low, or * the space/pulse sense could be * inverted. The bits denoted by PULSE_MASK are * the length in microseconds. Lengths greater * than or equal to 16 seconds are clamped to * PULSE_MASK. All other bits are unused. * This is a much simpler interface for user * programs, as well as eliminating "out of * phase" errors with space/pulse * autodetection. */ /* calc time since last interrupt in microseconds */ dcd = (negate /*reg & (1<< 19)*/) /*//(status & hardware[type].signal_pin)*/ ? 0 : 1; if (dcd == last_dcd) { printk(KERN_WARNING LIRC_DRIVER_NAME ": ignoring spike: %d %d %lx %lx %lx %lx\n", dcd, sense, tv.tv_sec, lasttv.tv_sec, tv.tv_usec, lasttv.tv_usec); continue; } deltv = tv.tv_sec-lasttv.tv_sec; if (tv.tv_sec < lasttv.tv_sec || (tv.tv_sec == lasttv.tv_sec && tv.tv_usec < lasttv.tv_usec)) { printk(KERN_WARNING LIRC_DRIVER_NAME ": AIEEEE: your clock just jumped " "backwards\n"); printk(KERN_WARNING LIRC_DRIVER_NAME ": %d %d %lx %lx %lx %lx\n", dcd, sense, tv.tv_sec, lasttv.tv_sec, tv.tv_usec, lasttv.tv_usec); data = PULSE_MASK; } else if (deltv > 15) { data = PULSE_MASK; /* really long time */ if (!(dcd^sense)) { /* sanity check */ printk ("ERROR\n"); printk(KERN_WARNING LIRC_DRIVER_NAME ": AIEEEE: " "%d %d %lx %lx %lx %lx\n", dcd, sense, tv.tv_sec, lasttv.tv_sec, tv.tv_usec, lasttv.tv_usec); /* * detecting pulse while this * MUST be a space! */ sense = sense ? 0 : 1; } } else data = (int) (deltv*1000000 + tv.tv_usec - lasttv.tv_usec); frbwrite(dcd^sense ? data : (data|PULSE_BIT)); #if 0 // Original code below - WTF ??!! lasttv = tv; #else memcpy (&lasttv, &tv, sizeof(struct timeval)); #endif last_dcd = dcd; wake_up_interruptible(&rbuf.wait_poll); } } while (0);//!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */ return IRQ_HANDLED; }