1 /******************************************************************************
2 * Copyright (c) 2010 Texas Instruments Incorporated - http://www.ti.com
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *****************************************************************************/
34 /******************************************************************************
35 *
36 * File Name: evmc64x_i2c_uart.h
37 *
38 * Description: This contains UART specific structure, typedefs, function
39 * prototypes.
40 *
41 * History:
42 * AUG/11/2009, Amit Solanki, Created the file
43 * AUG/8/2010, Deepika Makhija, Modified for Dual UART
44 *
45 ******************************************************************************/
46 #ifndef _EVM64X_I2C_UART_H_
47 #define _EVM64X_I2C_UART_H_
49 /************************
50 * Include Files
51 ************************/
52 #include "types.h"
54 /************************
55 * Defines and Macros
56 ************************/
57 // UART I2C Slave Address
58 #define I2C_UART_ADDR (0x4D)
60 #define UARTA_SELECT (0x0 << 1)
61 #define UARTB_SELECT (0x1 << 1)
63 // UART register addresses
64 #define THR (0x00 << 3) // transmit FIFO, write only
65 #define RHR (0x00 << 3) // receive FIFO, read oly
66 #define IER (0x01 << 3) // interrup enable reg., R/W
67 #define FCR (0x02 << 3) // FIFO control, write only
68 #define IIR (0x02 << 3) // interrupt status, read only
69 #define LCR (0x03 << 3) // line control, R/W
70 #define MCR (0x04 << 3) // modem control, R/W
71 #define LSR (0x05 << 3) // Line status, R/W
72 #define MSR (0x06 << 3) // Modem status, R/W
73 #define SPR (0x07 << 3) // scratch pad, R/W
74 #define TXFIFO (0x08 << 3) // TX FIFO, R
75 #define RXFIFO (0x09 << 3) // RX FIFO, R
77 #define IODIR (0x0A << 3) // IO Direction Control R/W
78 #define IOSTATE (0x0B << 3) // IO State R/W
79 #define IOINTMSK (0x0C << 3) // IO Interrupt Mask R/W
80 #define IOCTRL (0x0E << 3) // IO Control R/W
81 #define EFCR (0x0F << 3) // Enhancede Function Reg R/W
83 // Special registers, LCR.7 must be set
84 // to 1 to R/W to these registers
85 #define DLL (0x00 << 3) // Baud rate divisor, LSB, R/W
86 #define DLM (0x01 << 3) // Baud rate divisor, MSB, R/W
87 #define EFR (0x02 << 3) // Enhanced register, R/W
88 #define XON1 (0x04 << 3) // Flow control
89 #define XON2 (0x05 << 3) // Flow control
90 #define XOFF1 (0x06 << 3) // Flow control
91 #define XOFF2 (0x07 << 3) // Flow control
93 // Mask to enable DLL and DLM
94 #define DLAB (0x80) // Way to swap mem banks
96 // for 19200 baudrate for crystal clock 14.7456 MHz
97 #define DLL_VAL (0x30)
98 #define DLM_VAL (0x00)
100 // Macros to be used for setting baudrate
101 #define BAUD_RATE_9600 (0x0060)
102 #define BAUD_RATE_19200 (0x0030)
103 #define BAUD_RATE_56000 (0x0010)
104 #define BAUD_RATE_115200 (0x0008)
106 /************************
107 * Structures and Enums
108 ************************/
109 typedef enum _UART_device
110 {
111 I2C_UART_A = 0,
112 I2C_UART_B
113 }UART_device;
115 /************************
116 * Function declarations
117 ************************/
118 void i2cUartInit(UART_device eUartDevice);
119 void i2cUartSetBaudRate(UART_device eUartDevice, UINT16 uiBaudRate);
120 UINT16 i2cUartReadBaudRate(UART_device eUartDevice);
121 UINT8 i2cUartRead(UART_device eUartDevice, UINT8 uchAddress);
122 void i2cUartWrite(UART_device eUartDevice, UINT8 uchAddress,
123 UINT8 uchByte);
124 void i2cUartLedSet(UINT32 uiLedNum);
125 void i2cUartLedClear(UINT32 uiLedNum);
127 #endif // _EVM64X_I2C_UART_H_