wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * NS16550 Serial Port |
| 3 | * originally from linux source (arch/ppc/boot/ns16550.h) |
| 4 | * modified slightly to |
| 5 | * have addresses as offsets from CFG_ISA_BASE |
| 6 | * added a few more definitions |
| 7 | * added prototypes for ns16550.c |
| 8 | * reduced no of com ports to 2 |
| 9 | * modifications (c) Rob Taylor, Flying Pig Systems. 2000. |
| 10 | */ |
| 11 | |
| 12 | #if (CFG_NS16550_REG_SIZE == 1) |
| 13 | struct NS16550 { |
| 14 | unsigned char rbr; /* 0 */ |
| 15 | unsigned char ier; /* 1 */ |
| 16 | unsigned char fcr; /* 2 */ |
| 17 | unsigned char lcr; /* 3 */ |
| 18 | unsigned char mcr; /* 4 */ |
| 19 | unsigned char lsr; /* 5 */ |
| 20 | unsigned char msr; /* 6 */ |
| 21 | unsigned char scr; /* 7 */ |
| 22 | } __attribute__ ((packed)); |
| 23 | #elif (CFG_NS16550_REG_SIZE == 2) |
| 24 | struct NS16550 { |
| 25 | unsigned short rbr; /* 0 */ |
| 26 | unsigned short ier; /* 1 */ |
| 27 | unsigned short fcr; /* 2 */ |
| 28 | unsigned short lcr; /* 3 */ |
| 29 | unsigned short mcr; /* 4 */ |
| 30 | unsigned short lsr; /* 5 */ |
| 31 | unsigned short msr; /* 6 */ |
| 32 | unsigned short scr; /* 7 */ |
| 33 | } __attribute__ ((packed)); |
| 34 | #elif (CFG_NS16550_REG_SIZE == 4) |
| 35 | struct NS16550 { |
| 36 | unsigned long rbr; /* 0 */ |
| 37 | unsigned long ier; /* 1 */ |
| 38 | unsigned long fcr; /* 2 */ |
| 39 | unsigned long lcr; /* 3 */ |
| 40 | unsigned long mcr; /* 4 */ |
| 41 | unsigned long lsr; /* 5 */ |
| 42 | unsigned long msr; /* 6 */ |
| 43 | unsigned long scr; /* 7 */ |
| 44 | } __attribute__ ((packed)); |
| 45 | #elif (CFG_NS16550_REG_SIZE == -4) |
| 46 | struct NS16550 { |
| 47 | unsigned char rbr; /* 0 */ |
| 48 | int pad1:24; |
| 49 | unsigned char ier; /* 1 */ |
| 50 | int pad2:24; |
| 51 | unsigned char fcr; /* 2 */ |
| 52 | int pad3:24; |
| 53 | unsigned char lcr; /* 3 */ |
| 54 | int pad4:24; |
| 55 | unsigned char mcr; /* 4 */ |
| 56 | int pad5:24; |
| 57 | unsigned char lsr; /* 5 */ |
| 58 | int pad6:24; |
| 59 | unsigned char msr; /* 6 */ |
| 60 | int pad7:24; |
| 61 | unsigned char scr; /* 7 */ |
| 62 | int pad8:24; |
wdenk | 2e5983d | 2003-07-15 20:04:06 +0000 | [diff] [blame^] | 63 | #ifdef CONFIG_OMAP1510 |
| 64 | unsigned char mdr1; /* mode select reset TL16C750*/ |
| 65 | int pad9:24; |
| 66 | unsigned long pad[10]; |
| 67 | unsigned char osc_12m_sel; |
| 68 | int pad10:24; |
| 69 | #endif |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 70 | } __attribute__ ((packed)); |
| 71 | #else |
| 72 | #error "Please define NS16550 registers size." |
| 73 | #endif |
| 74 | |
| 75 | #define thr rbr |
| 76 | #define iir fcr |
| 77 | #define dll rbr |
| 78 | #define dlm ier |
| 79 | |
| 80 | typedef volatile struct NS16550 *NS16550_t; |
| 81 | |
| 82 | #define FCR_FIFO_EN 0x01 /* Fifo enable */ |
| 83 | #define FCR_RXSR 0x02 /* Receiver soft reset */ |
| 84 | #define FCR_TXSR 0x04 /* Transmitter soft reset */ |
| 85 | |
| 86 | #define MCR_DTR 0x01 |
| 87 | #define MCR_RTS 0x02 |
| 88 | #define MCR_DMA_EN 0x04 |
| 89 | #define MCR_TX_DFR 0x08 |
| 90 | |
| 91 | #define LCR_WLS_MSK 0x03 /* character length slect mask */ |
| 92 | #define LCR_WLS_5 0x00 /* 5 bit character length */ |
| 93 | #define LCR_WLS_6 0x01 /* 6 bit character length */ |
| 94 | #define LCR_WLS_7 0x02 /* 7 bit character length */ |
| 95 | #define LCR_WLS_8 0x03 /* 8 bit character length */ |
| 96 | #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */ |
| 97 | #define LCR_PEN 0x08 /* Parity eneble */ |
| 98 | #define LCR_EPS 0x10 /* Even Parity Select */ |
| 99 | #define LCR_STKP 0x20 /* Stick Parity */ |
| 100 | #define LCR_SBRK 0x40 /* Set Break */ |
| 101 | #define LCR_BKSE 0x80 /* Bank select enable */ |
| 102 | |
| 103 | #define LSR_DR 0x01 /* Data ready */ |
| 104 | #define LSR_OE 0x02 /* Overrun */ |
| 105 | #define LSR_PE 0x04 /* Parity error */ |
| 106 | #define LSR_FE 0x08 /* Framing error */ |
| 107 | #define LSR_BI 0x10 /* Break */ |
| 108 | #define LSR_THRE 0x20 /* Xmit holding register empty */ |
| 109 | #define LSR_TEMT 0x40 /* Xmitter empty */ |
| 110 | #define LSR_ERR 0x80 /* Error */ |
| 111 | |
wdenk | 2e5983d | 2003-07-15 20:04:06 +0000 | [diff] [blame^] | 112 | #ifdef CONFIG_OMAP1510 |
| 113 | #define OSC_12M_SEL 0x01 /* selects 6.5 * current clk div */ |
| 114 | #endif |
| 115 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 116 | /* useful defaults for LCR */ |
| 117 | #define LCR_8N1 0x03 |
| 118 | |
| 119 | void NS16550_init (NS16550_t com_port, int baud_divisor); |
| 120 | void NS16550_putc (NS16550_t com_port, char c); |
| 121 | char NS16550_getc (NS16550_t com_port); |
| 122 | int NS16550_tstc (NS16550_t com_port); |
| 123 | void NS16550_reinit (NS16550_t com_port, int baud_divisor); |