1 #ifndef CYGONCE_POWERPC_QUICC2_SCC_SERIAL_H
2 #define CYGONCE_POWERPC_QUICC2_SCC_SERIAL_H
4 // ====================================================================
8 // Device I/O - Description of PowerPC QUICC2/SCC serial hardware
10 // ====================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 // Copyright (C) 2002 Gary Thomas
17 // eCos is free software; you can redistribute it and/or modify it under
18 // the terms of the GNU General Public License as published by the Free
19 // Software Foundation; either version 2 or (at your option) any later version.
21 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
22 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 // You should have received a copy of the GNU General Public License along
27 // with eCos; if not, write to the Free Software Foundation, Inc.,
28 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 // As a special exception, if other files instantiate templates or use macros
31 // or inline functions from this file, or you compile this file and link it
32 // with other works to produce a work based on this file, this file does not
33 // by itself cause the resulting work to be covered by the GNU General Public
34 // License. However the source code for this file must still be made available
35 // in accordance with section (3) of the GNU General Public License.
37 // This exception does not invalidate any other reasons why a work based on
38 // this file might be covered by the GNU General Public License.
40 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
41 // at http://sources.redhat.com/ecos/ecos-license/
42 // -------------------------------------------
43 //####ECOSGPLCOPYRIGHTEND####
44 // ====================================================================
45 //#####DESCRIPTIONBEGIN####
48 // Contributors: gthomas
50 // Purpose: Internal interfaces for serial I/O drivers
53 //####DESCRIPTIONEND####
55 // ====================================================================
57 // Description of serial ports using QUICC2/SCC
59 // macro for aligning buffers to cache lines
60 #define ALIGN_TO_CACHELINES(b) ((cyg_uint8 *)(((CYG_ADDRESS)(b) + (HAL_DCACHE_LINE_SIZE-1)) & ~(HAL_DCACHE_LINE_SIZE-1)))
62 #define UART_BIT_RATE(n) \
63 ((((int)(CYGHWR_HAL_POWERPC_BOARD_SPEED*1000000))/(n * 64))-1)
65 // SCC PSMR masks ....
66 #define QUICC2_SCC_PSMR_ASYNC 0x8000
67 #define QUICC2_SCC_PSMR_SB(n) ((n-1)<<14) // Stop bits (1=1sb, 2=2sb)
68 #define QUICC2_SCC_PSMR_CLEN(n) ((n-5)<<12) // Character Length (5-8)
69 #define QUICC2_SCC_PSMR_PE(n) (n<<4) // Parity enable(0=disabled, 1=enabled)
70 #define QUICC2_SCC_PSMR_RPM(n) (n<<2) // Rx Parity mode (0=odd, 1=low, 2=even, 3=high)
71 #define QUICC2_SCC_PSMR_TPM(n) (n) // Tx Parity mode (0=odd, 1=low, 2=even, 3=high)
74 #define QUICC2_SCC_DSR_FULL 0x7e7e
75 #define QUICC2_SCC_DSR_HALF 0x467e
78 #define QUICC2_SCC_GSMR_H_INIT 0x00000060
79 #define QUICC2_SCC_GSMR_L_INIT 0x00028004
80 #define QUICC2_SCC_GSMR_L_ENT 0x00000010
81 #define QUICC2_SCC_GSMR_L_ENR 0x00000020
83 // SCC Events (interrupts)
84 #define QUICC2_SCCE_BRK 0x0040
85 #define QUICC2_SCCE_BSY 0x0004
86 #define QUICC2_SCCE_TX 0x0002
87 #define QUICC2_SCCE_RX 0x0001
89 // CP commands for SCC1 and SCC2
90 #define QUICC2_CPCR_SCC1 0x00800000
91 #define QUICC2_CPCR_SCC2 0x04A00000
92 #define QUICC2_CPCR_READY 0x00010000
93 #define QUICC2_CPCR_INIT_TX_RX 0x0
94 #define QUICC2_CPCR_INIT_RX 0x1
95 #define QUICC2_CPCR_INIT_TX 0x2
96 #define QUICC2_CPCR_STOP_TX 0x4
97 #define QUICC2_CPCR_RESTART_TX 0x6
98 #define QUICC2_CPCR_RESET 0x80000000
100 // SCC Buffer descriptor control bits
101 #define QUICC2_BD_CTL_Ready 0x8000 // Buffer contains data (tx) or is empty (rx)
102 #define QUICC2_BD_CTL_Wrap 0x2000 // Last buffer in list
103 #define QUICC2_BD_CTL_Int 0x1000 // Generate interrupt when empty (tx) or full (rx)
105 // PORT configuration masks for SCC1 and SCC2
106 #define QUICC2_SCC1_PORTC_PPAR (0x00020000)
107 #define QUICC2_SCC1_PORTD_PPAR (0x00000003)
108 #define QUICC2_SCC1_PORTD_PDIR (0x00000002)
110 #define QUICC2_SCC2_PORTC_PPAR (0x00080000)
111 #define QUICC2_SCC2_PORTD_PPAR (0x00000018)
112 #define QUICC2_SCC2_PORTD_PDIR (0x00000010)
114 // SCC clock Route register constants
115 #define QUICC2_CMX_SCC1_CLR 0x00ffffff
116 #define QUICC2_CMX_SCC1_BRG1 0x00000000
117 #define QUICC2_CMX_SCC1_BRG2 0x09000000
118 #define QUICC2_CMX_SCC1_BRG3 0x12000000
119 #define QUICC2_CMX_SCC1_BRG4 0x1b000000
121 #define QUICC2_CMX_SCC2_CLR 0xff00ffff
122 #define QUICC2_CMX_SCC2_BRG1 0x00000000
123 #define QUICC2_CMX_SCC2_BRG2 0x00090000
124 #define QUICC2_CMX_SCC2_BRG3 0x00120000
125 #define QUICC2_CMX_SCC2_BRG4 0x001b0000
127 static unsigned int select_word_length[] = {
128 QUICC2_SCC_PSMR_CLEN(5), // 5 bits / word (char)
129 QUICC2_SCC_PSMR_CLEN(6),
130 QUICC2_SCC_PSMR_CLEN(7),
131 QUICC2_SCC_PSMR_CLEN(8)
134 static unsigned int select_stop_bits[] = {
135 QUICC2_SCC_PSMR_SB(1), // 0.5 stop bit ??
136 QUICC2_SCC_PSMR_SB(1), // 1 stop bit
137 QUICC2_SCC_PSMR_SB(2), // 1.5 stop bit
138 QUICC2_SCC_PSMR_SB(2) // 2 stop bits
142 static unsigned int select_parity[] = {
143 QUICC2_SCC_PSMR_PE(0), // No parity
144 QUICC2_SCC_PSMR_PE(1)|QUICC2_SCC_PSMR_TPM(2)|QUICC2_SCC_PSMR_RPM(2), // Even parity
145 QUICC2_SCC_PSMR_PE(1)|QUICC2_SCC_PSMR_TPM(0)|QUICC2_SCC_PSMR_RPM(0), // Odd parity
146 QUICC2_SCC_PSMR_PE(1)|QUICC2_SCC_PSMR_TPM(3)|QUICC2_SCC_PSMR_RPM(3), // High (mark) parity
147 QUICC2_SCC_PSMR_PE(1)|QUICC2_SCC_PSMR_TPM(1)|QUICC2_SCC_PSMR_RPM(1), // Low (space) parity
151 // Baud rate values, will be used by the macro ...
152 #define QUICC2_BRG_EN 0x00010000
153 static unsigned long select_baud[] = {
178 // Board control and status registers
179 #define QUICC2_BCSR_EN_SCC1 0x02000000
180 #define QUICC2_BCSR_EN_SCC2 0x01000000
182 typedef struct bcsr {
183 volatile unsigned long bcsr0;
184 volatile unsigned long bcsr1;
185 volatile unsigned long bcsr2;
186 volatile unsigned long bcsr3;
190 typedef struct scc_bd{
196 typedef struct quicc2_scc_serial_info {
197 unsigned long scc_cpcr; // Selects scc for cpcr
198 volatile struct scc_regs_8260 *scc_regs; // Ptr to scc registers
199 volatile t_Scc_Pram *scc_pram; // Ptr to scc pram
200 volatile int *brg; // Ptr to baud rate generator
201 struct scc_bd *txbd, *rxbd; // Next Tx, Rx descriptor to use
202 struct scc_bd *tbase, *rbase; // First Tx, Rx descriptor
203 int txsize, rxsize; // Length of individual buffers
204 unsigned int int_vector;
205 cyg_interrupt serial_interrupt;
206 cyg_handle_t serial_interrupt_handle;
207 } quicc2_scc_serial_info;
209 #endif // CYGONCE_POWERPC_QUICC_SMC_SERIAL_H