/* * Read all bytes waiting in the PS2 port. There should be * at the most one, but we loop for safety. If there was a * framing error, we have to manually clear the status. */ static irqreturn_t ps2_rxint(int irq, void *dev_id) { struct ps2if *ps2if = dev_id; unsigned int scancode, flag, status; status = sa1111_readl(ps2if->base + SA1111_PS2STAT); while (status & PS2STAT_RXF) { if (status & PS2STAT_STP) sa1111_writel(PS2STAT_STP, ps2if->base + SA1111_PS2STAT); flag = (status & PS2STAT_STP ? SERIO_FRAME : 0) | (status & PS2STAT_RXP ? 0 : SERIO_PARITY); scancode = sa1111_readl(ps2if->base + SA1111_PS2DATA) & 0xff; if (hweight8(scancode) & 1) flag ^= SERIO_PARITY; serio_interrupt(ps2if->io, scancode, flag); status = sa1111_readl(ps2if->base + SA1111_PS2STAT); } return IRQ_HANDLED; }
void sa1111_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) { struct sa1111_dev *sadev = SA1111_DEV(skt->dev); unsigned long status = sa1111_readl(sadev->mapbase + SA1111_PCSR); switch (skt->nr) { case 0: state->detect = status & PCSR_S0_DETECT ? 0 : 1; state->ready = status & PCSR_S0_READY ? 1 : 0; state->bvd1 = status & PCSR_S0_BVD1 ? 1 : 0; state->bvd2 = status & PCSR_S0_BVD2 ? 1 : 0; state->wrprot = status & PCSR_S0_WP ? 1 : 0; state->vs_3v = status & PCSR_S0_VS1 ? 0 : 1; state->vs_Xv = status & PCSR_S0_VS2 ? 0 : 1; break; case 1: state->detect = status & PCSR_S1_DETECT ? 0 : 1; state->ready = status & PCSR_S1_READY ? 1 : 0; state->bvd1 = status & PCSR_S1_BVD1 ? 1 : 0; state->bvd2 = status & PCSR_S1_BVD2 ? 1 : 0; state->wrprot = status & PCSR_S1_WP ? 1 : 0; state->vs_3v = status & PCSR_S1_VS1 ? 0 : 1; state->vs_Xv = status & PCSR_S1_VS2 ? 0 : 1; break; } }
/* * Write a byte to the PS2 port. We have to wait for the * port to indicate that the transmitter is empty. */ static int ps2_write(struct serio *io, unsigned char val) { struct ps2if *ps2if = io->port_data; unsigned long flags; unsigned int head; spin_lock_irqsave(&ps2if->lock, flags); /* * If the TX register is empty, we can go straight out. */ if (sa1111_readl(ps2if->base + SA1111_PS2STAT) & PS2STAT_TXE) { sa1111_writel(val, ps2if->base + SA1111_PS2DATA); } else { if (ps2if->head == ps2if->tail) enable_irq(ps2if->dev->irq[1]); head = (ps2if->head + 1) & (sizeof(ps2if->buf) - 1); if (head != ps2if->tail) { ps2if->buf[ps2if->head] = val; ps2if->head = head; } } spin_unlock_irqrestore(&ps2if->lock, flags); return 0; }
static void sa1111_stop_hc(struct sa1111_dev *dev) { unsigned int usb_rst; printk(KERN_DEBUG __FILE__ ": stopping SA-1111 OHCI USB Controller\n"); /* * Put the USB host controller into reset. */ usb_rst = sa1111_readl(dev->mapbase + SA1111_USB_RESET); sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, dev->mapbase + SA1111_USB_RESET); /* * Stop the USB clock. */ sa1111_disable_device(dev); #ifdef CONFIG_SA1100_BADGE4 if (machine_is_badge4()) { /* Disable power to the USB bus */ badge4_set_5V(BADGE4_5V_USB, 0); } #endif }
/* * Clear the input buffer. */ static void __devinit ps2_clear_input(struct ps2if *ps2if) { int maxread = 100; while (maxread--) { if ((sa1111_readl(ps2if->base + SA1111_PS2DATA) & 0xff) == 0xff) break; } }
static void dump_hci_status(struct usb_hcd *hcd, const char *label) { unsigned long status = sa1111_readl(hcd->regs + SA1111_USB_STATUS); dbg ("%s USB_STATUS = { %s%s%s%s%s}", label, ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""), ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""), ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "), ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "), ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : "")); }
static unsigned int __devinit ps2_test_one(struct ps2if *ps2if, unsigned int mask) { unsigned int val; sa1111_writel(PS2CR_ENA | mask, ps2if->base + SA1111_PS2CR); udelay(2); val = sa1111_readl(ps2if->base + SA1111_PS2STAT); return val & (PS2STAT_KBC | PS2STAT_KBD); }
/* * Completion of ps2 write */ static irqreturn_t ps2_txint(int irq, void *dev_id) { struct ps2if *ps2if = dev_id; unsigned int status; spin_lock(&ps2if->lock); status = sa1111_readl(ps2if->base + SA1111_PS2STAT); if (ps2if->head == ps2if->tail) { disable_irq_nosync(irq); /* done */ } else if (status & PS2STAT_TXE) { sa1111_writel(ps2if->buf[ps2if->tail], ps2if->base + SA1111_PS2DATA); ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); } spin_unlock(&ps2if->lock); return IRQ_HANDLED; }
static void sa1111_stop_hc(struct sa1111_dev *dev) { unsigned int usb_rst; dev_dbg(&dev->dev, "stopping SA-1111 OHCI USB Controller\n"); /* * Put the USB host controller into reset. */ usb_rst = sa1111_readl(dev->mapbase + USB_RESET); sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, dev->mapbase + USB_RESET); /* * Stop the USB clock. */ sa1111_disable_device(dev); }
int sa1111_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) { struct sa1111_dev *sadev = SA1111_DEV(skt->dev); unsigned int pccr_skt_mask, pccr_set_mask, val; unsigned long flags; switch (skt->nr) { case 0: pccr_skt_mask = PCCR_S0_RST|PCCR_S0_FLT|PCCR_S0_PWAITEN|PCCR_S0_PSE; break; case 1: pccr_skt_mask = PCCR_S1_RST|PCCR_S1_FLT|PCCR_S1_PWAITEN|PCCR_S1_PSE; break; default: return -1; } pccr_set_mask = 0; if (state->Vcc != 0) pccr_set_mask |= PCCR_S0_PWAITEN|PCCR_S1_PWAITEN; if (state->Vcc == 50) pccr_set_mask |= PCCR_S0_PSE|PCCR_S1_PSE; if (state->flags & SS_RESET) pccr_set_mask |= PCCR_S0_RST|PCCR_S1_RST; if (state->flags & SS_OUTPUT_ENA) pccr_set_mask |= PCCR_S0_FLT|PCCR_S1_FLT; local_irq_save(flags); val = sa1111_readl(sadev->mapbase + SA1111_PCCR); val &= ~pccr_skt_mask; val |= pccr_set_mask & pccr_skt_mask; sa1111_writel(val, sadev->mapbase + SA1111_PCCR); local_irq_restore(flags); return 0; }