static int txx9_sio_kgdb_init(void) { struct uart_port *port = &uart_txx9_port[kgdb_txx9_ttyS]; unsigned int quot, sibgr; if (port->iotype != UPIO_MEM && port->iotype != UPIO_MEM32) return -1; /* Reset the UART. */ sio_out(port, TXX9_SIFCR, TXX9_SIFCR_SWRST); #ifdef CONFIG_CPU_TX49XX /* * TX4925 BUG WORKAROUND. Accessing SIOC register * immediately after soft reset causes bus error. */ iob(); udelay(1); #endif /* Wait until reset is complete. */ while (sio_in(port, TXX9_SIFCR) & TXX9_SIFCR_SWRST); /* Select the frame format and input clock. */ sio_out(port, TXX9_SILCR, TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT | ((port->flags & UPF_MAGIC_MULTIPLIER) ? TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG)); /* Select the input clock prescaler that fits the baud rate. */ quot = (port->uartclk + 8 * kgdb_txx9_baud) / (16 * kgdb_txx9_baud); if (quot < (256 << 1)) sibgr = (quot >> 1) | TXX9_SIBGR_BCLK_T0; else if (quot < ( 256 << 3))
static void m32r_sio_console_putchar(struct uart_port *port, int ch) { struct uart_sio_port *up = container_of(port, struct uart_sio_port, port); wait_for_xmitr(up); sio_out(up, SIOTXB, ch); }
/* * Print a string to the serial port trying not to disturb * any possible real use of the port... * * The console_lock must be held when we get here. */ static void m32r_sio_console_write(struct console *co, const char *s, unsigned int count) { struct uart_sio_port *up = &m32r_sio_ports[co->index]; unsigned int ier; /* * First save the UER then disable the interrupts */ ier = sio_in(up, SIOTRCR); sio_out(up, SIOTRCR, 0); uart_console_write(&up->port, s, count, m32r_sio_console_putchar); /* * Finally, wait for transmitter to become empty * and restore the IER */ wait_for_xmitr(up); sio_out(up, SIOTRCR, ier); }
static int m32r_sio_startup(struct uart_port *port) { struct uart_sio_port *up = container_of(port, struct uart_sio_port, port); int retval; sio_init(); /* * If the "interrupt" for this port doesn't correspond with any * hardware interrupt, we use a timer-based system. The original * driver used to do this with IRQ0. */ if (!up->port.irq) { unsigned int timeout = up->port.timeout; timeout = timeout > 6 ? (timeout / 2 - 2) : 1; up->timer.data = (unsigned long)up; mod_timer(&up->timer, jiffies + timeout); } else { retval = serial_link_irq_chain(up); if (retval) return retval; } /* * Finally, enable interrupts. Note: Modem status interrupts * are set via set_termios(), which will be occurring imminently * anyway, so we don't enable them here. * - M32R_SIO: 0x0c * - M32R_PLDSIO: 0x04 */ up->ier = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; sio_out(up, SIOTRCR, up->ier); /* * And clear the interrupt registers again for luck. */ sio_reset(); return 0; }
static void m32r_sio_shutdown(struct uart_port *port) { struct uart_sio_port *up = container_of(port, struct uart_sio_port, port); /* * Disable interrupts from this port */ up->ier = 0; sio_out(up, SIOTRCR, 0); /* * Disable break condition and FIFOs */ sio_init(); if (!up->port.irq) del_timer_sync(&up->timer); else serial_unlink_irq_chain(up); }
static inline void sio_set(struct uart_txx9_port *up, int offset, unsigned int value) { sio_out(up, offset, sio_in(up, offset) | value); }