1 #ifndef PXA260_UART_H
2 #define PXA260_UART_H
3 
4 #include "pxa260_CPU.h"
5 #include "pxa260_IC.h"
6 
7 
8 /*
9 	PXA260 UARTs
10 
11 	PXA260 has three. they are identical, but at diff base addresses. this implements one. instanciate more than one of this struct to make all 3 work if needed.
12 	PURRPOSE: this is how linux talks to us :)
13 
14 
15 	by default we read nothing and write nowhere (buffer drains fast into nothingness)
16 	this can be changed by addidng appropriate callbacks
17 
18 */
19 
20 #define PXA260_FFUART_BASE	0x40100000UL
21 #define PXA260_BTUART_BASE	0x40200000UL
22 #define PXA260_STUART_BASE	0x40700000UL
23 #define PXA260_UART_SIZE	0x00010000UL
24 
25 #define UART_FIFO_DEPTH		64
26 
27 
28 #define UART_CHAR_BREAK		0x800
29 #define UART_CHAR_FRAME_ERR	0x400
30 #define UART_CHAR_PAR_ERR	0x200
31 #define UART_CHAR_NONE		0x100
32 
33 typedef UInt16	(*Pxa260UartReadF)(void* userData);
34 typedef void	(*Pxa260UartWriteF)(UInt16 chr, void* userData);
35 
36 #define UART_FIFO_EMPTY	0xFF
37 
38 typedef struct{
39 
40 	UInt8 read;
41 	UInt8 write;
42 	UInt16 buf[UART_FIFO_DEPTH];
43 
44 }UartFifo;
45 
46 typedef struct{
47 
48    Pxa260ic* ic;
49 	UInt32 baseAddr;
50 
51    Pxa260UartReadF readF;
52    Pxa260UartWriteF writeF;
53 	void* accessFuncsData;
54 
55 	UartFifo TX, RX;
56 
57 	UInt16 transmitShift;	//char currently "sending"
58 	UInt16 transmitHolding;	//holding register for no-fifo mode
59 
60 	UInt16 receiveHolding;	//char just received
61 
62 	UInt8 irq:5;
63 	UInt8 cyclesSinceRecv:3;
64 
65 	UInt8 IER;		//interrupt enable register
66 	UInt8 IIR;		//interrupt information register
67 	UInt8 FCR;		//fifo control register
68 	UInt8 LCR;		//line control register
69 	UInt8 LSR;		//line status register
70 	UInt8 MCR;		//modem control register
71 	UInt8 MSR;		//modem status register
72 	UInt8 SPR;		//scratchpad register
73 	UInt8 DLL;		//divisor latch low
74 	UInt8 DLH;		//divior latch high;
75 	UInt8 ISR;		//infrared selection register
76 
77 
78 
79 }Pxa260uart;
80 
81 void pxa260uartInit(Pxa260uart* uart, Pxa260ic* ic, UInt32 baseAddr, UInt8 irq);
82 void pxa260uartProcess(Pxa260uart* uart);		//write out data in TX fifo and read data into RX fifo
83 
84 void pxa260uartSetFuncs(Pxa260uart* uart, Pxa260UartReadF readF, Pxa260UartWriteF writeF, void* userData);
85 
86 #endif
87 
88