williamr@4
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
2 |
// All rights reserved.
|
williamr@4
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
williamr@4
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
7 |
//
|
williamr@4
|
8 |
// Initial Contributors:
|
williamr@4
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@4
|
10 |
//
|
williamr@4
|
11 |
// Contributors:
|
williamr@4
|
12 |
//
|
williamr@4
|
13 |
// Description:
|
williamr@4
|
14 |
// omap3530/omap3530_drivers/uart/omap3530_uart.h
|
williamr@4
|
15 |
// This file is part of the Beagle Base port
|
williamr@4
|
16 |
//
|
williamr@4
|
17 |
|
williamr@4
|
18 |
#ifndef __OMAP3530_UART_H__
|
williamr@4
|
19 |
#define __OMAP3530_UART_H__
|
williamr@4
|
20 |
|
williamr@4
|
21 |
#include <assp/omap3530_assp/omap3530_hardware_base.h>
|
williamr@4
|
22 |
#include <assp/omap3530_assp/omap3530_prcm.h>
|
williamr@4
|
23 |
//#include "assp/omap3530_assp/omap3530_prm.h"
|
williamr@4
|
24 |
#include <assp/omap3530_assp/omap3530_irqmap.h>
|
williamr@4
|
25 |
|
williamr@4
|
26 |
//#include "omap3530_prm.h"
|
williamr@4
|
27 |
|
williamr@4
|
28 |
|
williamr@4
|
29 |
namespace Omap3530Uart
|
williamr@4
|
30 |
{
|
williamr@4
|
31 |
using namespace TexasInstruments::Omap3530;
|
williamr@4
|
32 |
|
williamr@4
|
33 |
enum TUartNumber
|
williamr@4
|
34 |
{
|
williamr@4
|
35 |
EUartNone = -1,
|
williamr@4
|
36 |
EUart0 = 0,
|
williamr@4
|
37 |
EUart1,
|
williamr@4
|
38 |
EUart2
|
williamr@4
|
39 |
};
|
williamr@4
|
40 |
|
williamr@4
|
41 |
template< const TUartNumber aUartNumber >
|
williamr@4
|
42 |
struct TUartTraits
|
williamr@4
|
43 |
{
|
williamr@4
|
44 |
};
|
williamr@4
|
45 |
|
williamr@4
|
46 |
template<>
|
williamr@4
|
47 |
struct TUartTraits< EUart0 >
|
williamr@4
|
48 |
{
|
williamr@4
|
49 |
static const TUint32 KBaseAddress = Omap3530HwBase::KL4_Core + 0x0006A000;
|
williamr@4
|
50 |
static const TInt KInterruptId = EOmap3530_IRQ72_UART1_IRQ;
|
williamr@4
|
51 |
static const Prcm::TClock KInterfaceClock = Prcm::EClkUart1_I;
|
williamr@4
|
52 |
static const Prcm::TClock KFunctionClock = Prcm::EClkUart1_F;
|
williamr@4
|
53 |
// static const Omap3530Prm::TPrmId KPrmInterfaceClock = Omap3530Prm::EPrmClkUart1_I;
|
williamr@4
|
54 |
// static const Omap3530Prm::TPrmId KPrmFunctionClock = Omap3530Prm::EPrmClkUart1_F;
|
williamr@4
|
55 |
};
|
williamr@4
|
56 |
|
williamr@4
|
57 |
template<>
|
williamr@4
|
58 |
struct TUartTraits< EUart1 >
|
williamr@4
|
59 |
{
|
williamr@4
|
60 |
static const TUint32 KBaseAddress = Omap3530HwBase::KL4_Core + 0x0006C000;
|
williamr@4
|
61 |
static const TInt KInterruptId = EOmap3530_IRQ73_UART2_IRQ;
|
williamr@4
|
62 |
static const Prcm::TClock KInterfaceClock = Prcm::EClkUart2_I;
|
williamr@4
|
63 |
static const Prcm::TClock KFunctionClock = Prcm::EClkUart2_F;
|
williamr@4
|
64 |
// static const Omap3530Prm::TPrmId KPrmInterfaceClock = Omap3530Prm::EPrmClkUart2_I;
|
williamr@4
|
65 |
// static const Omap3530Prm::TPrmId KPrmFunctionClock = Omap3530Prm::EPrmClkUart2_F;
|
williamr@4
|
66 |
};
|
williamr@4
|
67 |
|
williamr@4
|
68 |
template<>
|
williamr@4
|
69 |
struct TUartTraits< EUart2 >
|
williamr@4
|
70 |
{
|
williamr@4
|
71 |
static const TUint32 KBaseAddress = Omap3530HwBase::KL4_Per + 0x00020000;
|
williamr@4
|
72 |
static const TInt KInterruptId = EOmap3530_IRQ74_UART3_IRQ;
|
williamr@4
|
73 |
static const Prcm::TClock KInterfaceClock = Prcm::EClkUart3_I;
|
williamr@4
|
74 |
static const Prcm::TClock KFunctionClock = Prcm::EClkUart3_F;
|
williamr@4
|
75 |
// static const Omap3530Prm::TPrmId KPrmInterfaceClock = Omap3530Prm::EPrmClkUart3_I;
|
williamr@4
|
76 |
// static const Omap3530Prm::TPrmId KPrmFunctionClock = Omap3530Prm::EPrmClkUart3_F;
|
williamr@4
|
77 |
};
|
williamr@4
|
78 |
|
williamr@4
|
79 |
// Forward declaration
|
williamr@4
|
80 |
class TUart;
|
williamr@4
|
81 |
|
williamr@4
|
82 |
|
williamr@4
|
83 |
/** Representation of general UART register set */
|
williamr@4
|
84 |
struct DLL
|
williamr@4
|
85 |
{
|
williamr@4
|
86 |
static const TInt KOffset = 0x00;
|
williamr@4
|
87 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
88 |
typedef TBitField<0,8> CLOCK_LSB;
|
williamr@4
|
89 |
};
|
williamr@4
|
90 |
|
williamr@4
|
91 |
struct RHR
|
williamr@4
|
92 |
{
|
williamr@4
|
93 |
static const TInt KOffset = 0x00;
|
williamr@4
|
94 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
95 |
typedef TBitField<0,8> Value;
|
williamr@4
|
96 |
};
|
williamr@4
|
97 |
|
williamr@4
|
98 |
struct THR
|
williamr@4
|
99 |
{
|
williamr@4
|
100 |
static const TInt KOffset = 0x00;
|
williamr@4
|
101 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
102 |
typedef TBitField<0,8> Value;
|
williamr@4
|
103 |
};
|
williamr@4
|
104 |
|
williamr@4
|
105 |
struct IER
|
williamr@4
|
106 |
{
|
williamr@4
|
107 |
static const TInt KOffset = 0x04;
|
williamr@4
|
108 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
109 |
typedef TSingleBitField<7> CTS_IT;
|
williamr@4
|
110 |
typedef TSingleBitField<6> RTS_IT;
|
williamr@4
|
111 |
typedef TSingleBitField<5> XOFF_IT;
|
williamr@4
|
112 |
typedef TSingleBitField<4> SLEEP_MODE;
|
williamr@4
|
113 |
typedef TSingleBitField<3> MODEM_STS_IT;
|
williamr@4
|
114 |
typedef TSingleBitField<2> LINE_STS_IT;
|
williamr@4
|
115 |
typedef TSingleBitField<1> THR_IT;
|
williamr@4
|
116 |
typedef TSingleBitField<0> RHR_IT;
|
williamr@4
|
117 |
};
|
williamr@4
|
118 |
|
williamr@4
|
119 |
struct IER_IRDA
|
williamr@4
|
120 |
{
|
williamr@4
|
121 |
static const TInt KOffset = 0x04;
|
williamr@4
|
122 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
123 |
typedef TSingleBitField<7> EOF_IT;
|
williamr@4
|
124 |
typedef TSingleBitField<6> LINE_STS_IT;
|
williamr@4
|
125 |
typedef TSingleBitField<5> TX_STATUS_IT;
|
williamr@4
|
126 |
typedef TSingleBitField<4> STS_FIFO_TRIG_IT;
|
williamr@4
|
127 |
typedef TSingleBitField<3> RX_OVERRUN_IT;
|
williamr@4
|
128 |
typedef TSingleBitField<2> LAST_RX_BYTE_IT;
|
williamr@4
|
129 |
typedef TSingleBitField<1> THR_IT;
|
williamr@4
|
130 |
typedef TSingleBitField<0> RHR_IT;
|
williamr@4
|
131 |
};
|
williamr@4
|
132 |
|
williamr@4
|
133 |
struct DLH
|
williamr@4
|
134 |
{
|
williamr@4
|
135 |
static const TInt KOffset = 0x04;
|
williamr@4
|
136 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
137 |
typedef TBitField<0,6> CLOCK_MSB;
|
williamr@4
|
138 |
};
|
williamr@4
|
139 |
|
williamr@4
|
140 |
struct FCR
|
williamr@4
|
141 |
{
|
williamr@4
|
142 |
static const TInt KOffset = 0x08;
|
williamr@4
|
143 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
144 |
typedef TSingleBitField<0> FIFO_EN;
|
williamr@4
|
145 |
typedef TSingleBitField<1> RX_FIFO_CLEAR;
|
williamr@4
|
146 |
typedef TSingleBitField<2> TX_FIFO_CLEAR;
|
williamr@4
|
147 |
typedef TSingleBitField<3> DMA_MODE;
|
williamr@4
|
148 |
struct TX_FIFO_TRIG : public TBitField<4,2>
|
williamr@4
|
149 |
{
|
williamr@4
|
150 |
enum TConstants
|
williamr@4
|
151 |
{
|
williamr@4
|
152 |
K8Char = 0 << KShift,
|
williamr@4
|
153 |
K16Char = 1 << KShift,
|
williamr@4
|
154 |
K32Char = 2 << KShift,
|
williamr@4
|
155 |
K56Char = 3 << KShift
|
williamr@4
|
156 |
};
|
williamr@4
|
157 |
};
|
williamr@4
|
158 |
struct RX_FIFO_TRIG : public TBitField<6,2>
|
williamr@4
|
159 |
{
|
williamr@4
|
160 |
static const TUint8 K8Char = 0 << KShift;
|
williamr@4
|
161 |
static const TUint8 K16Char = 1 << KShift;
|
williamr@4
|
162 |
static const TUint8 K56Char = 2 << KShift;
|
williamr@4
|
163 |
static const TUint8 K60Char = 3 << KShift;
|
williamr@4
|
164 |
};
|
williamr@4
|
165 |
};
|
williamr@4
|
166 |
|
williamr@4
|
167 |
struct IIR
|
williamr@4
|
168 |
{
|
williamr@4
|
169 |
static const TInt KOffset = 0x08;
|
williamr@4
|
170 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
171 |
typedef TBitField<6,2> FCR_MIRROR;
|
williamr@4
|
172 |
struct IT_TYPE : public TBitField<1,5>
|
williamr@4
|
173 |
{
|
williamr@4
|
174 |
enum TConstants
|
williamr@4
|
175 |
{
|
williamr@4
|
176 |
EModem = 0 << KShift,
|
williamr@4
|
177 |
ETHR = 1 << KShift,
|
williamr@4
|
178 |
ERHR = 2 << KShift,
|
williamr@4
|
179 |
ERxLineStatus = 3 << KShift,
|
williamr@4
|
180 |
ERxTimeout = 6 << KShift,
|
williamr@4
|
181 |
EXoff = 8 << KShift,
|
williamr@4
|
182 |
ECtsRts = 16 << KShift
|
williamr@4
|
183 |
};
|
williamr@4
|
184 |
};
|
williamr@4
|
185 |
typedef TSingleBitField<0> IT_PENDING;
|
williamr@4
|
186 |
};
|
williamr@4
|
187 |
|
williamr@4
|
188 |
struct EFR
|
williamr@4
|
189 |
{
|
williamr@4
|
190 |
static const TInt KOffset = 0x08;
|
williamr@4
|
191 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
192 |
typedef TSingleBitField<7> AUTO_CTS_EN;
|
williamr@4
|
193 |
typedef TSingleBitField<6> AUTO_RTS_EN;
|
williamr@4
|
194 |
typedef TSingleBitField<5> SPEC_CHAR;
|
williamr@4
|
195 |
typedef TSingleBitField<4> ENHANCED_EN;
|
williamr@4
|
196 |
struct SW_FLOW_CONTROL : public TBitField<0,4>
|
williamr@4
|
197 |
{
|
williamr@4
|
198 |
enum TFlowControl
|
williamr@4
|
199 |
{
|
williamr@4
|
200 |
ENone = 0,
|
williamr@4
|
201 |
EXonXoff1 = 8,
|
williamr@4
|
202 |
EXonXoff2 = 4,
|
williamr@4
|
203 |
EXonXoffBoth = 8 + 4,
|
williamr@4
|
204 |
};
|
williamr@4
|
205 |
};
|
williamr@4
|
206 |
};
|
williamr@4
|
207 |
|
williamr@4
|
208 |
struct LCR
|
williamr@4
|
209 |
{
|
williamr@4
|
210 |
static const TInt KOffset = 0x0c;
|
williamr@4
|
211 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
212 |
typedef TSingleBitField<7> DIV_EN;
|
williamr@4
|
213 |
typedef TSingleBitField<6> BREAK_EN;
|
williamr@4
|
214 |
typedef TSingleBitField<5> PARITY_TYPE2;
|
williamr@4
|
215 |
typedef TSingleBitField<4> PARITY_TYPE1;
|
williamr@4
|
216 |
typedef TSingleBitField<3> PARITY_EN;
|
williamr@4
|
217 |
struct NB_STOP : public TSingleBitField<2>
|
williamr@4
|
218 |
{
|
williamr@4
|
219 |
enum TConstants
|
williamr@4
|
220 |
{
|
williamr@4
|
221 |
E1Stop = 0 << KShift,
|
williamr@4
|
222 |
E1_5Stop = 1 << KShift,
|
williamr@4
|
223 |
E2Stop = 1 << KShift
|
williamr@4
|
224 |
};
|
williamr@4
|
225 |
};
|
williamr@4
|
226 |
struct CHAR_LENGTH : public TBitField<0,2>
|
williamr@4
|
227 |
{
|
williamr@4
|
228 |
enum TConstants
|
williamr@4
|
229 |
{
|
williamr@4
|
230 |
E5Bits = 0,
|
williamr@4
|
231 |
E6Bits = 1,
|
williamr@4
|
232 |
E7Bits = 2,
|
williamr@4
|
233 |
E8Bits = 3
|
williamr@4
|
234 |
};
|
williamr@4
|
235 |
};
|
williamr@4
|
236 |
|
williamr@4
|
237 |
/** Special magic number to enter MODEA */
|
williamr@4
|
238 |
static const TUint8 KConfigModeA = 0x80;
|
williamr@4
|
239 |
|
williamr@4
|
240 |
/** Special magic number to enter MODEB */
|
williamr@4
|
241 |
static const TUint8 KConfigModeB = 0xBF;
|
williamr@4
|
242 |
|
williamr@4
|
243 |
/** Special magic number to enter operational mode */
|
williamr@4
|
244 |
static const TUint8 KConfigModeOperational = 0x00;
|
williamr@4
|
245 |
};
|
williamr@4
|
246 |
|
williamr@4
|
247 |
struct MCR
|
williamr@4
|
248 |
{
|
williamr@4
|
249 |
static const TInt KOffset = 0x10;
|
williamr@4
|
250 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
251 |
typedef TSingleBitField<6> TCR_TLR;
|
williamr@4
|
252 |
typedef TSingleBitField<5> XON_EN;
|
williamr@4
|
253 |
typedef TSingleBitField<4> LOOPBACK_EN;
|
williamr@4
|
254 |
typedef TSingleBitField<3> CD_STS_CH;
|
williamr@4
|
255 |
typedef TSingleBitField<2> RI_STS_CH;
|
williamr@4
|
256 |
typedef TSingleBitField<1> RTS;
|
williamr@4
|
257 |
typedef TSingleBitField<0> DTR;
|
williamr@4
|
258 |
};
|
williamr@4
|
259 |
|
williamr@4
|
260 |
struct XON1_ADDR1
|
williamr@4
|
261 |
{
|
williamr@4
|
262 |
static const TInt KOffset = 0x10;
|
williamr@4
|
263 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
264 |
typedef TBitField<0,8> Value;
|
williamr@4
|
265 |
};
|
williamr@4
|
266 |
|
williamr@4
|
267 |
struct LSR
|
williamr@4
|
268 |
{
|
williamr@4
|
269 |
static const TInt KOffset = 0x14;
|
williamr@4
|
270 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
271 |
typedef TSingleBitField<7> RX_FIFO_STS;
|
williamr@4
|
272 |
typedef TSingleBitField<6> TX_SR_E;
|
williamr@4
|
273 |
typedef TSingleBitField<5> TX_FIFO_E;
|
williamr@4
|
274 |
typedef TSingleBitField<4> RX_BI;
|
williamr@4
|
275 |
typedef TSingleBitField<3> RX_FE;
|
williamr@4
|
276 |
typedef TSingleBitField<2> RX_PE;
|
williamr@4
|
277 |
typedef TSingleBitField<1> RX_OE;
|
williamr@4
|
278 |
typedef TSingleBitField<0> RX_FIFO_E;
|
williamr@4
|
279 |
};
|
williamr@4
|
280 |
|
williamr@4
|
281 |
struct XON2_ADDR2
|
williamr@4
|
282 |
{
|
williamr@4
|
283 |
static const TInt KOffset = 0x14;
|
williamr@4
|
284 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
285 |
typedef TBitField<0,8> Value;
|
williamr@4
|
286 |
};
|
williamr@4
|
287 |
|
williamr@4
|
288 |
struct XOFF1
|
williamr@4
|
289 |
{
|
williamr@4
|
290 |
static const TInt KOffset = 0x18;
|
williamr@4
|
291 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
292 |
typedef TBitField<0,8> Value;
|
williamr@4
|
293 |
};
|
williamr@4
|
294 |
|
williamr@4
|
295 |
struct TCR
|
williamr@4
|
296 |
{
|
williamr@4
|
297 |
static const TInt KOffset = 0x18;
|
williamr@4
|
298 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
299 |
typedef TBitField<4,4> RX_FIFO_TRIG_START;
|
williamr@4
|
300 |
typedef TBitField<0,4> RX_FIFO_TRIG_HALT;
|
williamr@4
|
301 |
};
|
williamr@4
|
302 |
|
williamr@4
|
303 |
struct MSR
|
williamr@4
|
304 |
{
|
williamr@4
|
305 |
static const TInt KOffset = 0x18;
|
williamr@4
|
306 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
307 |
typedef TSingleBitField<7> NCD_STS;
|
williamr@4
|
308 |
typedef TSingleBitField<6> NRI_STS;
|
williamr@4
|
309 |
typedef TSingleBitField<5> NDSR_STS;
|
williamr@4
|
310 |
typedef TSingleBitField<4> NCTS_STS;
|
williamr@4
|
311 |
typedef TSingleBitField<3> DCD_STS;
|
williamr@4
|
312 |
typedef TSingleBitField<2> RI_STS;
|
williamr@4
|
313 |
typedef TSingleBitField<1> DSR_STS;
|
williamr@4
|
314 |
typedef TSingleBitField<0> CTS_STS;
|
williamr@4
|
315 |
};
|
williamr@4
|
316 |
|
williamr@4
|
317 |
struct SPR
|
williamr@4
|
318 |
{
|
williamr@4
|
319 |
static const TInt KOffset = 0x1c;
|
williamr@4
|
320 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
321 |
typedef TBitField<0,8> SPR_WORD;
|
williamr@4
|
322 |
};
|
williamr@4
|
323 |
|
williamr@4
|
324 |
struct XOFF2
|
williamr@4
|
325 |
{
|
williamr@4
|
326 |
static const TInt KOffset = 0x1c;
|
williamr@4
|
327 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
328 |
typedef TBitField<0,8> Value;
|
williamr@4
|
329 |
};
|
williamr@4
|
330 |
|
williamr@4
|
331 |
struct TLR
|
williamr@4
|
332 |
{
|
williamr@4
|
333 |
static const TInt KOffset = 0x1c;
|
williamr@4
|
334 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
335 |
typedef TBitField<4,4> RX_FIFO_TRIG_DMA;
|
williamr@4
|
336 |
typedef TBitField<0,4> TX_FIFO_TRIG_DMA;
|
williamr@4
|
337 |
};
|
williamr@4
|
338 |
|
williamr@4
|
339 |
struct MDR1
|
williamr@4
|
340 |
{
|
williamr@4
|
341 |
static const TInt KOffset = 0x20;
|
williamr@4
|
342 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
343 |
typedef TSingleBitField<7> FRAME_END_MODE;
|
williamr@4
|
344 |
typedef TSingleBitField<6> SIP_MODE;
|
williamr@4
|
345 |
typedef TSingleBitField<5> SCT;
|
williamr@4
|
346 |
typedef TSingleBitField<4> SET_TXIR;
|
williamr@4
|
347 |
typedef TSingleBitField<3> IR_SLEEP;
|
williamr@4
|
348 |
struct MODE_SELECT : public TBitField<0,3>
|
williamr@4
|
349 |
{
|
williamr@4
|
350 |
enum TMode
|
williamr@4
|
351 |
{
|
williamr@4
|
352 |
EUart16x = 0,
|
williamr@4
|
353 |
ESIR = 1,
|
williamr@4
|
354 |
EUart16xAutoBaud = 2,
|
williamr@4
|
355 |
EUart13x = 3,
|
williamr@4
|
356 |
EMIR = 4,
|
williamr@4
|
357 |
EFIR = 5,
|
williamr@4
|
358 |
ECIR = 6,
|
williamr@4
|
359 |
EDisable = 7
|
williamr@4
|
360 |
};
|
williamr@4
|
361 |
};
|
williamr@4
|
362 |
};
|
williamr@4
|
363 |
|
williamr@4
|
364 |
struct MDR2
|
williamr@4
|
365 |
{
|
williamr@4
|
366 |
static const TInt KOffset = 0x24;
|
williamr@4
|
367 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
368 |
typedef TSingleBitField<6> IRRXINVERT;
|
williamr@4
|
369 |
struct CIR_PULSE_MODE : public TBitField<4,2>
|
williamr@4
|
370 |
{
|
williamr@4
|
371 |
enum TConstants
|
williamr@4
|
372 |
{
|
williamr@4
|
373 |
EPw3 = 0 << KShift,
|
williamr@4
|
374 |
EPw4 = 1 << KShift,
|
williamr@4
|
375 |
EPw5 = 2 << KShift,
|
williamr@4
|
376 |
EPw6 = 3 << KShift
|
williamr@4
|
377 |
};
|
williamr@4
|
378 |
};
|
williamr@4
|
379 |
typedef TSingleBitField<3> UART_PULSE;
|
williamr@4
|
380 |
struct STS_FIFO_TRIG : public TBitField<1,2>
|
williamr@4
|
381 |
{
|
williamr@4
|
382 |
enum TConstants
|
williamr@4
|
383 |
{
|
williamr@4
|
384 |
E1Entry = 0 << KShift,
|
williamr@4
|
385 |
E4Entry = 1 << KShift,
|
williamr@4
|
386 |
E7Entry = 2 << KShift,
|
williamr@4
|
387 |
E8Entry = 3 << KShift
|
williamr@4
|
388 |
};
|
williamr@4
|
389 |
};
|
williamr@4
|
390 |
typedef TSingleBitField<0> IRTX_UNDERRUN;
|
williamr@4
|
391 |
};
|
williamr@4
|
392 |
|
williamr@4
|
393 |
struct TXFLL
|
williamr@4
|
394 |
{
|
williamr@4
|
395 |
static const TInt KOffset = 0x28;
|
williamr@4
|
396 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
397 |
typedef TBitField<0,8> TX_FLL;
|
williamr@4
|
398 |
};
|
williamr@4
|
399 |
|
williamr@4
|
400 |
struct SFLSR
|
williamr@4
|
401 |
{
|
williamr@4
|
402 |
static const TInt KOffset = 0x28;
|
williamr@4
|
403 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
404 |
typedef TSingleBitField<4> OE_ERROR;
|
williamr@4
|
405 |
typedef TSingleBitField<3> FTL_ERROR;
|
williamr@4
|
406 |
typedef TSingleBitField<2> ABORT_DETECT;
|
williamr@4
|
407 |
typedef TSingleBitField<1> CRC_ERROR;
|
williamr@4
|
408 |
};
|
williamr@4
|
409 |
|
williamr@4
|
410 |
struct RESUME
|
williamr@4
|
411 |
{
|
williamr@4
|
412 |
static const TInt KOffset = 0x2c;
|
williamr@4
|
413 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
414 |
typedef TBitField<0,8> Value;
|
williamr@4
|
415 |
};
|
williamr@4
|
416 |
|
williamr@4
|
417 |
struct TXFLH
|
williamr@4
|
418 |
{
|
williamr@4
|
419 |
static const TInt KOffset = 0x2c;
|
williamr@4
|
420 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
421 |
typedef TBitField<0,5> TX_FLH;
|
williamr@4
|
422 |
};
|
williamr@4
|
423 |
|
williamr@4
|
424 |
struct RXFLL
|
williamr@4
|
425 |
{
|
williamr@4
|
426 |
static const TInt KOffset = 0x30;
|
williamr@4
|
427 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
428 |
typedef TBitField<0,8> RX_FLL;
|
williamr@4
|
429 |
};
|
williamr@4
|
430 |
|
williamr@4
|
431 |
struct SFREGL
|
williamr@4
|
432 |
{
|
williamr@4
|
433 |
static const TInt KOffset = 0x30;
|
williamr@4
|
434 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
435 |
typedef TBitField<0,8> Value;
|
williamr@4
|
436 |
};
|
williamr@4
|
437 |
|
williamr@4
|
438 |
struct SFREGH
|
williamr@4
|
439 |
{
|
williamr@4
|
440 |
static const TInt KOffset = 0x34;
|
williamr@4
|
441 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
442 |
typedef TBitField<0,4> Value;
|
williamr@4
|
443 |
};
|
williamr@4
|
444 |
|
williamr@4
|
445 |
struct RXFLH
|
williamr@4
|
446 |
{
|
williamr@4
|
447 |
static const TInt KOffset = 0x34;
|
williamr@4
|
448 |
static TDynReg8_W< TUart, KOffset > iMem;
|
williamr@4
|
449 |
typedef TBitField<0,4> RX_FLH;
|
williamr@4
|
450 |
};
|
williamr@4
|
451 |
|
williamr@4
|
452 |
struct BLR
|
williamr@4
|
453 |
{
|
williamr@4
|
454 |
typedef TSingleBitField<7> STS_FIFO_RESET;
|
williamr@4
|
455 |
typedef TSingleBitField<6> XBOF_TYPE;
|
williamr@4
|
456 |
};
|
williamr@4
|
457 |
|
williamr@4
|
458 |
struct UASR
|
williamr@4
|
459 |
{
|
williamr@4
|
460 |
static const TInt KOffset = 0x38;
|
williamr@4
|
461 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
462 |
struct PARITY_TYPE : public TBitField<6,2>
|
williamr@4
|
463 |
{
|
williamr@4
|
464 |
enum TConstants
|
williamr@4
|
465 |
{
|
williamr@4
|
466 |
ENone = 0 << KShift,
|
williamr@4
|
467 |
ESpace = 1 << KShift,
|
williamr@4
|
468 |
EEven = 2 << KShift,
|
williamr@4
|
469 |
EOdd = 3 << KShift
|
williamr@4
|
470 |
};
|
williamr@4
|
471 |
};
|
williamr@4
|
472 |
struct BIT_BY_CHAR : public TSingleBitField<5>
|
williamr@4
|
473 |
{
|
williamr@4
|
474 |
enum TConstants
|
williamr@4
|
475 |
{
|
williamr@4
|
476 |
E7Bit = 0 << KShift,
|
williamr@4
|
477 |
E8Bit = 1 << KShift
|
williamr@4
|
478 |
};
|
williamr@4
|
479 |
};
|
williamr@4
|
480 |
struct SPEED : public TBitField<0,5>
|
williamr@4
|
481 |
{
|
williamr@4
|
482 |
enum TBaud
|
williamr@4
|
483 |
{
|
williamr@4
|
484 |
EUnknown = 0,
|
williamr@4
|
485 |
E115200 = 1,
|
williamr@4
|
486 |
E57600 = 2,
|
williamr@4
|
487 |
E38400 = 3,
|
williamr@4
|
488 |
E28800 = 4,
|
williamr@4
|
489 |
E19200 = 5,
|
williamr@4
|
490 |
E14400 = 6,
|
williamr@4
|
491 |
E9600 = 7,
|
williamr@4
|
492 |
E4800 = 8,
|
williamr@4
|
493 |
E4800_2 = 9,
|
williamr@4
|
494 |
E1200 = 10
|
williamr@4
|
495 |
};
|
williamr@4
|
496 |
};
|
williamr@4
|
497 |
};
|
williamr@4
|
498 |
|
williamr@4
|
499 |
struct ACREG
|
williamr@4
|
500 |
{
|
williamr@4
|
501 |
static const TInt KOffset = 0x3c;
|
williamr@4
|
502 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
503 |
typedef TSingleBitField<7> PULSE_TYPE;
|
williamr@4
|
504 |
typedef TSingleBitField<6> SID_MOD;
|
williamr@4
|
505 |
typedef TSingleBitField<5> DIS_IR_RX;
|
williamr@4
|
506 |
typedef TSingleBitField<4> DIS_TX_UNDERRUN;
|
williamr@4
|
507 |
typedef TSingleBitField<3> SEND_SIP;
|
williamr@4
|
508 |
typedef TSingleBitField<2> SCTX_EN;
|
williamr@4
|
509 |
typedef TSingleBitField<1> ABORT_EN;
|
williamr@4
|
510 |
typedef TSingleBitField<0> EOT_EN;
|
williamr@4
|
511 |
};
|
williamr@4
|
512 |
|
williamr@4
|
513 |
struct SCR
|
williamr@4
|
514 |
{
|
williamr@4
|
515 |
static const TInt KOffset = 0x40;
|
williamr@4
|
516 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
517 |
typedef TSingleBitField<7> RX_TRIG_GRANU1;
|
williamr@4
|
518 |
typedef TSingleBitField<6> TX_TRIG_GRANU1;
|
williamr@4
|
519 |
typedef TSingleBitField<4> RX_CTS_WU_EN;
|
williamr@4
|
520 |
typedef TSingleBitField<3> TX_EMPTY_CTL_IT;
|
williamr@4
|
521 |
typedef TBitField<1,2> DMA_MODE2;
|
williamr@4
|
522 |
typedef TSingleBitField<0> DMA_MODE_CTL;
|
williamr@4
|
523 |
};
|
williamr@4
|
524 |
|
williamr@4
|
525 |
struct SSR
|
williamr@4
|
526 |
{
|
williamr@4
|
527 |
static const TInt KOffset = 0x44;
|
williamr@4
|
528 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
529 |
typedef TSingleBitField<1> RX_CTS_WU_STS;
|
williamr@4
|
530 |
typedef TSingleBitField<0> TX_FIFO_FULL;
|
williamr@4
|
531 |
};
|
williamr@4
|
532 |
|
williamr@4
|
533 |
struct EBLR
|
williamr@4
|
534 |
{
|
williamr@4
|
535 |
static const TInt KOffset = 0x48;
|
williamr@4
|
536 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
537 |
typedef TBitField<0,8> Value;
|
williamr@4
|
538 |
};
|
williamr@4
|
539 |
|
williamr@4
|
540 |
struct SYSC
|
williamr@4
|
541 |
{
|
williamr@4
|
542 |
static const TInt KOffset = 0x54;
|
williamr@4
|
543 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
544 |
struct IDLE_MODE : public TBitField<3,2>
|
williamr@4
|
545 |
{
|
williamr@4
|
546 |
enum TMode
|
williamr@4
|
547 |
{
|
williamr@4
|
548 |
EForceIdle = 0 << KShift,
|
williamr@4
|
549 |
ENoIdle = 1 << KShift,
|
williamr@4
|
550 |
ESmartIdle = 2 << KShift
|
williamr@4
|
551 |
};
|
williamr@4
|
552 |
};
|
williamr@4
|
553 |
typedef TSingleBitField<2> ENAWAKEUP;
|
williamr@4
|
554 |
typedef TSingleBitField<1> SOFTRESET;
|
williamr@4
|
555 |
typedef TSingleBitField<0> AUTOIDLE;
|
williamr@4
|
556 |
};
|
williamr@4
|
557 |
|
williamr@4
|
558 |
struct SYSS
|
williamr@4
|
559 |
{
|
williamr@4
|
560 |
static const TInt KOffset = 0x58;
|
williamr@4
|
561 |
static TDynReg8_R< TUart, KOffset > iMem;
|
williamr@4
|
562 |
typedef TSingleBitField<0> RESETDONE;
|
williamr@4
|
563 |
};
|
williamr@4
|
564 |
|
williamr@4
|
565 |
struct WER
|
williamr@4
|
566 |
{
|
williamr@4
|
567 |
static const TInt KOffset = 0x5c;
|
williamr@4
|
568 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
569 |
typedef TSingleBitField<6> EVENT_6_RLS_INTERRUPT;
|
williamr@4
|
570 |
typedef TSingleBitField<5> EVENT_5_RHR_INTERRUPT;
|
williamr@4
|
571 |
typedef TSingleBitField<4> EVENT_4_RX_ACTIVITY;
|
williamr@4
|
572 |
typedef TSingleBitField<2> EVENT_2_RI_ACTIVITY;
|
williamr@4
|
573 |
typedef TSingleBitField<0> EVENT_0_CTS_ACTIVITY;
|
williamr@4
|
574 |
};
|
williamr@4
|
575 |
|
williamr@4
|
576 |
struct CFPS
|
williamr@4
|
577 |
{
|
williamr@4
|
578 |
static const TInt KOffset = 0x60;
|
williamr@4
|
579 |
static TDynReg8_RW< TUart, KOffset > iMem;
|
williamr@4
|
580 |
typedef TBitField<0,8> Value;
|
williamr@4
|
581 |
};
|
williamr@4
|
582 |
|
williamr@4
|
583 |
|
williamr@4
|
584 |
class TUart
|
williamr@4
|
585 |
{
|
williamr@4
|
586 |
public:
|
williamr@4
|
587 |
enum TBaud
|
williamr@4
|
588 |
{
|
williamr@4
|
589 |
E1200,
|
williamr@4
|
590 |
E2400,
|
williamr@4
|
591 |
E4800,
|
williamr@4
|
592 |
E9600,
|
williamr@4
|
593 |
E14400,
|
williamr@4
|
594 |
E19200,
|
williamr@4
|
595 |
E28800,
|
williamr@4
|
596 |
E38400,
|
williamr@4
|
597 |
E57600,
|
williamr@4
|
598 |
E115200,
|
williamr@4
|
599 |
E230400,
|
williamr@4
|
600 |
E460800,
|
williamr@4
|
601 |
E921600,
|
williamr@4
|
602 |
E1843000,
|
williamr@4
|
603 |
E3688400,
|
williamr@4
|
604 |
E4000000, // FIR
|
williamr@4
|
605 |
|
williamr@4
|
606 |
KSupportedBaudCount
|
williamr@4
|
607 |
};
|
williamr@4
|
608 |
|
williamr@4
|
609 |
enum TParity
|
williamr@4
|
610 |
{
|
williamr@4
|
611 |
ENone,
|
williamr@4
|
612 |
EOdd,
|
williamr@4
|
613 |
EEven,
|
williamr@4
|
614 |
EMark,
|
williamr@4
|
615 |
ESpace
|
williamr@4
|
616 |
};
|
williamr@4
|
617 |
|
williamr@4
|
618 |
enum TDataBits
|
williamr@4
|
619 |
{
|
williamr@4
|
620 |
E5Data = ::Omap3530Uart::LCR::CHAR_LENGTH::E5Bits,
|
williamr@4
|
621 |
E6Data = ::Omap3530Uart::LCR::CHAR_LENGTH::E6Bits,
|
williamr@4
|
622 |
E7Data = ::Omap3530Uart::LCR::CHAR_LENGTH::E7Bits,
|
williamr@4
|
623 |
E8Data = ::Omap3530Uart::LCR::CHAR_LENGTH::E8Bits,
|
williamr@4
|
624 |
};
|
williamr@4
|
625 |
|
williamr@4
|
626 |
enum TStopBits
|
williamr@4
|
627 |
{
|
williamr@4
|
628 |
E1Stop = ::Omap3530Uart::LCR::NB_STOP::E1Stop,
|
williamr@4
|
629 |
E1_5Stop = ::Omap3530Uart::LCR::NB_STOP::E1_5Stop,
|
williamr@4
|
630 |
E2Stop = ::Omap3530Uart::LCR::NB_STOP::E2Stop,
|
williamr@4
|
631 |
};
|
williamr@4
|
632 |
|
williamr@4
|
633 |
enum TUartMode
|
williamr@4
|
634 |
{
|
williamr@4
|
635 |
EUart,
|
williamr@4
|
636 |
EUartAutoBaud,
|
williamr@4
|
637 |
ESIR,
|
williamr@4
|
638 |
EMIR,
|
williamr@4
|
639 |
EFIR,
|
williamr@4
|
640 |
ECIR,
|
williamr@4
|
641 |
|
williamr@4
|
642 |
KSupportedUartModes
|
williamr@4
|
643 |
};
|
williamr@4
|
644 |
|
williamr@4
|
645 |
enum TFifoTrigger
|
williamr@4
|
646 |
{
|
williamr@4
|
647 |
ETrigger8,
|
williamr@4
|
648 |
ETrigger16,
|
williamr@4
|
649 |
ETrigger32,
|
williamr@4
|
650 |
ETrigger56,
|
williamr@4
|
651 |
ETrigger60,
|
williamr@4
|
652 |
ETriggerUnchanged
|
williamr@4
|
653 |
};
|
williamr@4
|
654 |
|
williamr@4
|
655 |
enum TEnableState
|
williamr@4
|
656 |
{
|
williamr@4
|
657 |
EDisabled,
|
williamr@4
|
658 |
EEnabled
|
williamr@4
|
659 |
};
|
williamr@4
|
660 |
|
williamr@4
|
661 |
enum TInterrupt
|
williamr@4
|
662 |
{
|
williamr@4
|
663 |
EIntRhr = 0,
|
williamr@4
|
664 |
EIntThr = 1,
|
williamr@4
|
665 |
EIntLineStatus = 2,
|
williamr@4
|
666 |
EIntModemStatus = 3,
|
williamr@4
|
667 |
EIntXoff = 5,
|
williamr@4
|
668 |
EIntRts = 6,
|
williamr@4
|
669 |
EIntCts = 7
|
williamr@4
|
670 |
};
|
williamr@4
|
671 |
|
williamr@4
|
672 |
public:
|
williamr@4
|
673 |
inline TUart( const TUartNumber aUartNumber )
|
williamr@4
|
674 |
: iBase( (aUartNumber == EUart0 ) ? TUartTraits<EUart0>::KBaseAddress
|
williamr@4
|
675 |
: (aUartNumber == EUart1 ) ? TUartTraits<EUart1>::KBaseAddress
|
williamr@4
|
676 |
: (aUartNumber == EUart2 ) ? TUartTraits<EUart2>::KBaseAddress
|
williamr@4
|
677 |
: 0 ),
|
williamr@4
|
678 |
iUartNumber( aUartNumber )
|
williamr@4
|
679 |
{}
|
williamr@4
|
680 |
|
williamr@4
|
681 |
FORCE_INLINE TLinAddr Base() const
|
williamr@4
|
682 |
{ return iBase; }
|
williamr@4
|
683 |
|
williamr@4
|
684 |
IMPORT_C TInt InterruptId() const;
|
williamr@4
|
685 |
|
williamr@4
|
686 |
IMPORT_C Prcm::TClock PrcmInterfaceClk() const;
|
williamr@4
|
687 |
|
williamr@4
|
688 |
IMPORT_C Prcm::TClock PrcmFunctionClk() const;
|
williamr@4
|
689 |
|
williamr@4
|
690 |
// IMPORT_C TInt PrmInterfaceClk() const;
|
williamr@4
|
691 |
|
williamr@4
|
692 |
// IMPORT_C TInt PrmFunctionClk() const;
|
williamr@4
|
693 |
|
williamr@4
|
694 |
/** Reset and initialize the UART
|
williamr@4
|
695 |
* On return the UART will be in disable mode */
|
williamr@4
|
696 |
IMPORT_C void Init();
|
williamr@4
|
697 |
|
williamr@4
|
698 |
/** Defines which mode the UART will run in when enabled, but does not configure that mode
|
williamr@4
|
699 |
* You must call this before calling SetBaud to ensure that correct baud rate multiplier is used */
|
williamr@4
|
700 |
IMPORT_C void DefineMode( const TUartMode aMode );
|
williamr@4
|
701 |
|
williamr@4
|
702 |
/** Enabled the UART in the defined mode
|
williamr@4
|
703 |
* You must call DefineMode() and SetBaud() before calling Enable()
|
williamr@4
|
704 |
*/
|
williamr@4
|
705 |
IMPORT_C void Enable();
|
williamr@4
|
706 |
|
williamr@4
|
707 |
/** Disables the UART */
|
williamr@4
|
708 |
IMPORT_C void Disable();
|
williamr@4
|
709 |
|
williamr@4
|
710 |
/** Set the baud rate
|
williamr@4
|
711 |
* Do not call this while the UART is enabled
|
williamr@4
|
712 |
* You must have previously called DefineMode()
|
williamr@4
|
713 |
*/
|
williamr@4
|
714 |
IMPORT_C void SetBaud( const TBaud aBaud );
|
williamr@4
|
715 |
|
williamr@4
|
716 |
/** Set the data length, parity and stop bits */
|
williamr@4
|
717 |
IMPORT_C void SetDataFormat( const TDataBits aDataBits, const TStopBits aStopBits, const TParity aParity );
|
williamr@4
|
718 |
|
williamr@4
|
719 |
/** Setup the FIFO configuration */
|
williamr@4
|
720 |
IMPORT_C void EnableFifo( const TEnableState aState, const TFifoTrigger aRxTrigger = ETriggerUnchanged, const TFifoTrigger aTxTrigger = ETriggerUnchanged );
|
williamr@4
|
721 |
|
williamr@4
|
722 |
/** Enable a particular interrupt source */
|
williamr@4
|
723 |
IMPORT_C void EnableInterrupt( const TInterrupt aWhich );
|
williamr@4
|
724 |
|
williamr@4
|
725 |
/** Disable a particular interrupt source */
|
williamr@4
|
726 |
IMPORT_C void DisableInterrupt( const TInterrupt aWhich );
|
williamr@4
|
727 |
|
williamr@4
|
728 |
/** Disable all interrupts */
|
williamr@4
|
729 |
IMPORT_C void DisableAllInterrupts();
|
williamr@4
|
730 |
|
williamr@4
|
731 |
inline TBool TxFifoFull()
|
williamr@4
|
732 |
{ return SSR::iMem.Read(*this) bitand SSR::TX_FIFO_FULL::KMask; }
|
williamr@4
|
733 |
|
williamr@4
|
734 |
inline TBool TxFifoEmpty()
|
williamr@4
|
735 |
{ return LSR::iMem.Read(*this) bitand LSR::TX_FIFO_E::KMask; }
|
williamr@4
|
736 |
|
williamr@4
|
737 |
inline TBool RxFifoEmpty()
|
williamr@4
|
738 |
{ return !(LSR::iMem.Read(*this) bitand LSR::RX_FIFO_E::KMask); }
|
williamr@4
|
739 |
|
williamr@4
|
740 |
inline void Write( TUint8 aByte )
|
williamr@4
|
741 |
{ THR::iMem.Write( *this, aByte ); }
|
williamr@4
|
742 |
|
williamr@4
|
743 |
inline TUint8 Read()
|
williamr@4
|
744 |
{ return RHR::iMem.Read( *this ); }
|
williamr@4
|
745 |
|
williamr@4
|
746 |
private:
|
williamr@4
|
747 |
TUart();
|
williamr@4
|
748 |
|
williamr@4
|
749 |
public:
|
williamr@4
|
750 |
const TLinAddr iBase;
|
williamr@4
|
751 |
const TUartNumber iUartNumber : 8;
|
williamr@4
|
752 |
TUartMode iMode : 8;
|
williamr@4
|
753 |
::Omap3530Uart::MDR1::MODE_SELECT::TMode iTargetMode : 8;
|
williamr@4
|
754 |
};
|
williamr@4
|
755 |
|
williamr@4
|
756 |
|
williamr@4
|
757 |
} // Omap3530Uart
|
williamr@4
|
758 |
|
williamr@4
|
759 |
#endif // ndef __OMAP3530_UART_H__
|
williamr@4
|
760 |
|