2 * Copyright (C) 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
13 #include "uart16550.h"
17 #define BASE 0xb8058000
18 #define MAX_BAUD 1152000
21 /* === END OF CONFIG === */
24 #define OFS_RCV_BUFFER (0*REG_OFFSET)
25 #define OFS_TRANS_HOLD (0*REG_OFFSET)
26 #define OFS_SEND_BUFFER (0*REG_OFFSET)
27 #define OFS_INTR_ENABLE (1*REG_OFFSET)
28 #define OFS_INTR_ID (2*REG_OFFSET)
29 #define OFS_DATA_FORMAT (3*REG_OFFSET)
30 #define OFS_LINE_CONTROL (3*REG_OFFSET)
31 #define OFS_MODEM_CONTROL (4*REG_OFFSET)
32 #define OFS_RS232_OUTPUT (4*REG_OFFSET)
33 #define OFS_LINE_STATUS (5*REG_OFFSET)
34 #define OFS_MODEM_STATUS (6*REG_OFFSET)
35 #define OFS_RS232_INPUT (6*REG_OFFSET)
36 #define OFS_SCRATCH_PAD (7*REG_OFFSET)
38 #define OFS_DIVISOR_LSB (0*REG_OFFSET)
39 #define OFS_DIVISOR_MSB (1*REG_OFFSET)
42 /* memory-mapped read/write of the port */
43 #define UART16550_READ(y) (*((volatile uint32*)(BASE + y)))
44 #define UART16550_WRITE(y, z) ((*((volatile uint32*)(BASE + y))) = z)
46 #define DEBUG_LED (*(unsigned short*)0xb7ffffc0)
47 #define OutputLED(x) (DEBUG_LED = x)
49 void Uart16550Init(uint32 baud
, uint8 data
, uint8 parity
, uint8 stop
)
51 /* disable interrupts */
52 UART16550_WRITE(OFS_INTR_ENABLE
, 0);
54 /* set up buad rate */
59 UART16550_WRITE(OFS_LINE_CONTROL
, 0x80);
62 divisor
= MAX_BAUD
/ baud
;
63 UART16550_WRITE(OFS_DIVISOR_LSB
, divisor
& 0xff);
64 UART16550_WRITE(OFS_DIVISOR_MSB
, (divisor
& 0xff00)>>8);
67 UART16550_WRITE(OFS_LINE_CONTROL
, 0x0);
71 UART16550_WRITE(OFS_DATA_FORMAT
, data
| parity
| stop
);
74 uint8
Uart16550GetPoll()
76 while((UART16550_READ(OFS_LINE_STATUS
) & 0x1) == 0);
77 return UART16550_READ(OFS_RCV_BUFFER
);
81 void Uart16550Put(uint8 byte
)
83 while ((UART16550_READ(OFS_LINE_STATUS
) &0x20) == 0);
84 UART16550_WRITE(OFS_SEND_BUFFER
, byte
);
This page took 0.041925 seconds and 5 git commands to generate.