source: svn/trunk/newcon3bcm2_21bu/dta/src/bcmuart.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 9.5 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2009, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bcmuart.h $
11 * $brcm_Revision: Hydra_Software_Devel/15 $
12 * $brcm_Date: 9/9/09 6:46p $
13 *
14 * Module Description:  Definitions for UART block
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /rockford/bsp/bcm97401/common/bcmuart.h $
19 *
20 * Hydra_Software_Devel/15   9/9/09 6:46p agin
21 * SWNOOS-369: Adapt for 7340 and 7342.
22 *
23 * Hydra_Software_Devel/14   5/20/08 2:16p rjlewis
24 * PR42856: updated for 97335 support.
25 *
26 * Hydra_Software_Devel/13   4/4/08 3:24p brianlee
27 * PR18303: 7325 does not have uart C.
28 *
29 * Hydra_Software_Devel/12   12/6/07 3:19p farshidf
30 * PR37975: 7335 No os
31 *
32 * Hydra_Software_Devel/11   10/14/07 1:09p jkim
33 * PR14344: Add 7325 support
34 *
35 * Hydra_Software_Devel/10   7/3/07 2:45p jkim
36 * PR14344: Add soap server support for 7405
37 *
38 * Hydra_Software_Devel/9   5/17/07 7:03p jkim
39 * PR14344: Adding 7405 support
40 *
41 * Hydra_Software_Devel/8   4/9/07 6:26p agin
42 * PR28241: Support GHS.
43 *
44 * Hydra_Software_Devel/7   7/19/06 11:09a jkim
45 * PR14344: Use (BCHP_VER >= BCHP_VER_B0) instead of (BCHP_REV_B0==1)
46 *
47 * Hydra_Software_Devel/6   6/27/06 2:02p garylin
48 * PR14344: fix comment for vxWorks
49 *
50 * Hydra_Software_Devel/5   6/21/06 9:53a jkim
51 * PR14344: Add support for B0
52 *
53 * Hydra_Software_Devel/4   1/30/06 1:22p agin
54 * PR19313: Use Uart0 as default for BCM97400.
55 *
56 * Hydra_Software_Devel/3   1/16/06 6:23p agin
57 * PR19076: Support BCM7400.
58 *
59 ***************************************************************************/
60#ifndef _BCMUART_H
61#define _BCMUART_H
62#if 0
63#include "bcmmips.h"
64#include "boardcfg.h"
65#else
66#define BCM_PHYS_TO_K1(x)   ((x) | 0xa0000000)
67#endif
68#include "bchp_common.h"
69#include "bchp_uarta.h"
70#include "bchp_uartb.h"
71
72#if BCHP_CHIP != 7325
73#include "bchp_uartc.h"
74#endif
75
76#if !defined _ASMLANGUAGE
77#if __cplusplus
78extern "C" {
79#endif
80#endif
81
82/* UART register base addresses */
83#if BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 || BCHP_CHIP == 7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342 || BCHP_CHIP==7550 || BCHP_CHIP==7552
84#define UARTA_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTA_RBR)
85#define UARTB_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTB_RBR)
86#define UARTC_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTC_RBR)
87#else
88#define UARTA_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTA_RCVSTAT)
89#define UARTB_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTB_RCVSTAT)
90#if (BCHP_VER >= BCHP_VER_B0) || (BCHP_CHIP==7552)
91/* B0 UARTC has changed to one like 7400 */
92#define UARTC_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTC_RBR)
93#else
94#define UARTC_ADR_BASE   BCM_PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_UARTC_RCVSTAT)
95#endif
96#endif
97
98/* Define console using UART_ADR_BASE here. Console could be UARTB or UARTC for 7401.
99 * No other files need to be modified for SDE.
100 */
101#if BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 || BCHP_CHIP == 7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342 || BCHP_CHIP==7550 || BCHP_CHIP==7552
102#define UART_ADR_BASE   UARTA_ADR_BASE
103#ifdef GHS
104#define console_out             uarta_out
105#else
106#define console_out             _writeasm
107#endif
108#else
109#define UART_ADR_BASE   UARTB_ADR_BASE
110#define console_out             uartb_out
111#endif
112
113#if BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 || BCHP_CHIP==7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342 || BCHP_CHIP==7550 || BCHP_CHIP==7552
114
115/* UART registers */
116#define UART_SDW_RBR            0x00
117#define UART_SDW_THR            0x00
118#define UART_SDW_DLL            0x00
119#define UART_SDW_DLH            0x04
120#define UART_SDW_IER            0x04
121#define UART_SDW_IIR            0x08
122#define UART_SDW_FCR            0x08
123#define UART_SDW_LCR            0x0c
124#define UART_SDW_MCR            0x10
125#define UART_SDW_LSR            0x14
126#define UART_SDW_MSR            0x18
127#define UART_SDW_SCR            0x1c
128
129#else
130
131/* used for UARTA and UARTB */
132#define UART_RXSTAT             0x00
133#define UART_RXDATA             0x04
134#define UART_CONTROL            0x0c
135#define UART_BAUDHI             0x10
136#define UART_BAUDLO             0x14
137#define UART_TXSTAT             0x18
138#define UART_TXDATA             0x1c
139
140/* used for UARTC */
141#define UART_SDW_RBR            0x00
142#define UART_SDW_THR            0x00
143#define UART_SDW_DLL            0x00
144#define UART_SDW_DLH            0x04
145#define UART_SDW_IER            0x04
146#define UART_SDW_IIR            0x08
147#define UART_SDW_FCR            0x08
148#define UART_SDW_LCR            0x0c
149#define UART_SDW_MCR            0x10
150#define UART_SDW_LSR            0x14
151#define UART_SDW_MSR            0x18
152#define UART_SDW_SCR            0x1c
153
154#endif
155
156/* LCR bit definitions */
157
158#define DLAB                            0x80
159#define EPS                             0x10
160#define PEN                             0x08
161#define STOP                            0x04
162#define DLS8                            0x03
163#define DLS_8BITS                       0x03 /* some common code uses this definition */
164#define DLS7                            0x02
165#define DLS6                            0x01
166#define DLS5                            0x00
167
168/* LSR bit definitions */
169#define RFE                             0x80
170#define TEMT                            0x40
171#define THRE                            0x20
172#define BI                              0x10
173#define FE                              0x08
174#define PE                              0x04
175#define OE                              0x02
176#define DR                              0x01
177
178/* IER bit definitions */
179#define PTIME                           0x80
180#define ETBEI                           0x02
181#define ERBFI                           0x01
182
183/* FCR bit definition */
184#define FIFOE                           0x1
185
186/* These boards don't have the old style uarts */
187#if !(BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 || BCHP_CHIP==7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342 || BCHP_CHIP==7550) || BCHP_CHIP==7552
188
189/* RXSTAT bit definitions */
190#define PARERR                          0x20
191#define FRAMEERR                        0x10
192#define OVERRUNERR                      0x08
193#define RXDATARDY                       0x04
194#define RXINTEN                         0x02
195
196/* CONTROL bit definitions */
197#define BITM8                           0x10
198#define PAREN                           0x08
199#define TXEN                            0x04
200#define RXEN                            0x02
201#define PODD                            0x01
202
203/* TXSTAT bit definitions */
204#define TXINTEN                         0x04
205#define TXIDLE                          0x02
206#define TXDREGEMT                       0x01
207
208#endif
209
210#if !defined _ASMLANGUAGE
211
212/**********************************************************************
213  Uart Register Structure
214 **********************************************************************/
215#if BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 ||BCHP_CHIP == 7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342 || BCHP_CHIP==7550 || BCHP_CHIP==7552
216typedef struct UartChannel {
217    volatile unsigned long sdw_rbr_thr_dll;     /* 0x00 */
218    volatile unsigned long sdw_dlh_ier; /* 0x04 */
219    volatile unsigned long sdw_iir_fcr; /* 0x08 */
220    volatile unsigned long sdw_lcr;     /* 0x0c */
221    volatile unsigned long sdw_mcr;     /* 0x10 */
222    volatile unsigned long sdw_lsr;     /* 0x14 */
223    volatile unsigned long sdw_msr;     /* 0x18 */
224    volatile unsigned long sdw_scr;     /* 0x1c */
225} UartChannel;
226
227/* UartChannelNew is used by soap server.
228 * define UartChannelNew the same as UartChannel
229 */
230typedef struct UartChannelNew {
231  volatile unsigned long sdw_rbr_thr_dll;       /* 0x00 */
232  volatile unsigned long sdw_dlh_ier;   /* 0x04 */
233  volatile unsigned long sdw_iir_fcr;   /* 0x08 */
234  volatile unsigned long sdw_lcr;       /* 0x0c */
235  volatile unsigned long sdw_mcr;       /* 0x10 */
236  volatile unsigned long sdw_lsr;       /* 0x14 */
237  volatile unsigned long sdw_msr;       /* 0x18 */
238  volatile unsigned long sdw_scr;       /* 0x1c */
239} UartChannelNew; /* Used for UARTC */
240
241#else
242typedef struct UartChannelNew {
243  volatile unsigned long sdw_rbr_thr_dll;       /* 0x00 */
244  volatile unsigned long sdw_dlh_ier;   /* 0x04 */
245  volatile unsigned long sdw_iir_fcr;   /* 0x08 */
246  volatile unsigned long sdw_lcr;       /* 0x0c */
247  volatile unsigned long sdw_mcr;       /* 0x10 */
248  volatile unsigned long sdw_lsr;       /* 0x14 */
249  volatile unsigned long sdw_msr;       /* 0x18 */
250  volatile unsigned long sdw_scr;       /* 0x1c */
251} UartChannelNew; /* Used for UARTC */
252
253typedef struct UartChannel {
254  volatile unsigned long rxstat;
255  volatile unsigned long rxdata;
256  volatile unsigned long unused;
257  volatile unsigned long control;
258  volatile unsigned long baudh;
259    /* When divide SysClk/2/(1+baudword) we should get 32*bit-rate */
260  volatile unsigned long baudl;
261  volatile unsigned long txstat;
262  volatile unsigned long txdata;
263} UartChannel;
264#endif
265
266#define UARTA ((volatile UartChannel *) UARTA_ADR_BASE)
267#define UARTB ((volatile UartChannel *) UARTB_ADR_BASE)
268#define UARTC ((volatile UartChannel *) UARTC_ADR_BASE)
269
270#define UART  ((volatile UartChannel *) UART_ADR_BASE)
271
272
273#endif /* _ASMLANGUAGE */
274
275#if !(BCHP_CHIP==7400 || BCHP_CHIP==7405 || BCHP_CHIP==7325 || BCHP_CHIP == 7335 || BCHP_CHIP==7340 || BCHP_CHIP==7342  || BCHP_CHIP==7550) || BCHP_CHIP==7552
276/******************************************************************
277 * Baud Rate Table
278 * XTALFREQ / baud rate / 16
279 ******************************************************************/
280#define BAUD_VAL(x)     (((XTALFREQ/8/(x) + 1)/2) - 1)
281#define BAUD_VAL_HI(x)  ((BAUD_VAL(x) >> 8) & 0xff)
282#define BAUD_VAL_LO(x)  (BAUD_VAL(x) & 0xff)
283
284#define BAUD_1200_HI    BAUD_VAL_HI(1200)
285#define BAUD_1200_LO    BAUD_VAL_LO(1200)
286#define BAUD_2400_HI    BAUD_VAL_HI(2400)
287#define BAUD_2400_LO    BAUD_VAL_LO(2400)
288#define BAUD_4800_HI    BAUD_VAL_HI(4800)
289#define BAUD_4800_LO    BAUD_VAL_LO(4800)
290#define BAUD_9600_HI    BAUD_VAL_HI(9600)
291#define BAUD_9600_LO    BAUD_VAL_LO(9600)
292#define BAUD_19200_HI   BAUD_VAL_HI(19200)
293#define BAUD_19200_LO   BAUD_VAL_LO(19200)
294#define BAUD_38400_HI   BAUD_VAL_HI(38400)
295#define BAUD_38400_LO   BAUD_VAL_LO(38400)
296#define BAUD_57600_HI   BAUD_VAL_HI(57600)
297#define BAUD_57600_LO   BAUD_VAL_LO(57600)
298#define BAUD_115200_HI  BAUD_VAL_HI(115200)
299#define BAUD_115200_LO  BAUD_VAL_LO(115200)
300#endif
301
302#if !defined _ASMLANGUAGE
303#if __cplusplus
304}
305#endif
306#endif
307
308#endif  /* _BCMUART_H */
Note: See TracBrowser for help on using the repository browser.