2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Driver for 8250/16550-type serial ports
|
|
|
|
*
|
|
|
|
* Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Russell King.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2005-09-01 21:56:26 +07:00
|
|
|
#include <linux/serial_8250.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct old_serial_port {
|
|
|
|
unsigned int uart;
|
|
|
|
unsigned int baud_base;
|
|
|
|
unsigned int port;
|
|
|
|
unsigned int irq;
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned char hub6;
|
|
|
|
unsigned char io_type;
|
|
|
|
unsigned char *iomem_base;
|
|
|
|
unsigned short iomem_reg_shift;
|
2009-09-20 03:13:19 +07:00
|
|
|
unsigned long irqflags;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct serial8250_config {
|
|
|
|
const char *name;
|
|
|
|
unsigned short fifo_size;
|
|
|
|
unsigned short tx_loadsz;
|
|
|
|
unsigned char fcr;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
|
|
|
|
#define UART_CAP_EFR (1 << 9) /* UART has EFR */
|
|
|
|
#define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
|
|
|
|
#define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
|
|
|
|
#define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
|
2011-05-18 05:12:36 +07:00
|
|
|
#define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-06-23 16:43:04 +07:00
|
|
|
#define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
|
2005-06-23 21:05:41 +07:00
|
|
|
#define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
|
2005-11-06 16:07:03 +07:00
|
|
|
#define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
|
2008-09-03 04:35:44 +07:00
|
|
|
#define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
|
2012-07-12 19:00:31 +07:00
|
|
|
#define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
|
2005-06-23 16:43:04 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#define PROBE_RSA (1 << 0)
|
|
|
|
#define PROBE_ANY (~0)
|
|
|
|
|
|
|
|
#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_8250_SHARE_IRQ
|
|
|
|
#define SERIAL8250_SHARE_IRQS 1
|
|
|
|
#else
|
|
|
|
#define SERIAL8250_SHARE_IRQS 0
|
|
|
|
#endif
|
|
|
|
|
2012-03-09 07:12:09 +07:00
|
|
|
static inline int serial_in(struct uart_8250_port *up, int offset)
|
|
|
|
{
|
|
|
|
return up->port.serial_in(&up->port, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void serial_out(struct uart_8250_port *up, int offset, int value)
|
|
|
|
{
|
|
|
|
up->port.serial_out(&up->port, offset, value);
|
|
|
|
}
|
|
|
|
|
2012-04-11 04:10:58 +07:00
|
|
|
void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
|
|
|
|
|
2012-05-02 19:46:51 +07:00
|
|
|
static inline int serial_dl_read(struct uart_8250_port *up)
|
|
|
|
{
|
|
|
|
return up->dl_read(up);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void serial_dl_write(struct uart_8250_port *up, int value)
|
|
|
|
{
|
|
|
|
up->dl_write(up, value);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#if defined(__alpha__) && !defined(CONFIG_PCI)
|
|
|
|
/*
|
|
|
|
* Digital did something really horribly wrong with the OUT1 and OUT2
|
|
|
|
* lines on at least some ALPHA's. The failure mode is that if either
|
|
|
|
* is cleared, the machine locks up with endless interrupts.
|
|
|
|
*/
|
|
|
|
#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
|
|
|
|
#elif defined(CONFIG_SBC8560)
|
|
|
|
/*
|
|
|
|
* WindRiver did something similarly broken on their SBC8560 board. The
|
|
|
|
* UART tristates its IRQ output while OUT2 is clear, but they pulled
|
|
|
|
* the interrupt line _up_ instead of down, so if we register the IRQ
|
|
|
|
* while the UART is in that state, we die in an IRQ storm. */
|
|
|
|
#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
|
|
|
|
#else
|
|
|
|
#define ALPHA_KLUDGE_MCR 0
|
|
|
|
#endif
|
2012-09-08 01:06:23 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_8250_PNP
|
|
|
|
int serial8250_pnp_init(void);
|
|
|
|
void serial8250_pnp_exit(void);
|
|
|
|
#else
|
|
|
|
static inline int serial8250_pnp_init(void) { return 0; }
|
|
|
|
static inline void serial8250_pnp_exit(void) { }
|
|
|
|
#endif
|
|
|
|
|
2012-10-04 05:31:58 +07:00
|
|
|
#ifdef CONFIG_ARCH_OMAP1
|
|
|
|
static inline int is_omap1_8250(struct uart_8250_port *pt)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
switch (pt->port.mapbase) {
|
|
|
|
case OMAP1_UART1_BASE:
|
|
|
|
case OMAP1_UART2_BASE:
|
|
|
|
case OMAP1_UART3_BASE:
|
|
|
|
res = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int is_omap1510_8250(struct uart_8250_port *pt)
|
|
|
|
{
|
|
|
|
if (!cpu_is_omap1510())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return is_omap1_8250(pt);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int is_omap1_8250(struct uart_8250_port *pt)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int is_omap1510_8250(struct uart_8250_port *pt)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|