1 /**
2 * @file UART_soc.c
3 *
4 * @brief This file defines the UART interface structure specific to dra78x
5 */
6 /*
7 * Copyright (c) 2014 - 2018, Texas Instruments Incorporated
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37 /** ============================================================================*/
39 #include <ti/csl/csl_utils.h>
40 #include <ti/csl/cslr_device.h>
41 #include <ti/drv/uart/UART.h>
42 #include <ti/drv/uart/soc/UART_soc.h>
44 /* UART configuration structure */
45 UART_HwAttrs uartInitCfg[CSL_UART_PER_CNT] =
46 {
47 {
48 SOC_UART1_BASE,
49 #if defined (__TI_ARM_V7M4__)
50 44,
51 #elif defined(_TMS320C6X)
52 OSAL_REGINT_INTVEC_EVENT_COMBINER,
53 #endif
54 44,
55 CSL_UART_0_MODULE_FREQ,
56 0,
57 0,
58 0,
59 0,
60 0,
61 0,
62 0,
63 NULL,
64 UART_RXTRIGLVL_8,
65 UART_TXTRIGLVL_56,
66 FALSE, /* default DMA mode disabled */
67 FALSE, /* Loopback disabled by default */
68 TRUE, /* Interrupt enabled by default */
69 UART16x_OPER_MODE, /* operMode, 16x over sampling mode by default */
70 },
71 {
72 SOC_UART2_BASE,
73 #if defined (__TI_ARM_V7M4__)
74 43,
75 #elif defined(_TMS320C6X)
76 OSAL_REGINT_INTVEC_EVENT_COMBINER,
77 #endif
78 43,
79 CSL_UART_1_MODULE_FREQ,
80 0,
81 0,
82 0,
83 0,
84 0,
85 0,
86 0,
87 NULL,
88 UART_RXTRIGLVL_8,
89 UART_TXTRIGLVL_56,
90 FALSE,
91 FALSE, /* Loopback disabled by default */
92 TRUE, /* Interrupt enabled by default */
93 UART16x_OPER_MODE,
94 },
95 {
96 SOC_UART3_BASE,
97 #if defined (__TI_ARM_V7M4__)
98 45,
99 #elif defined(_TMS320C6X)
100 OSAL_REGINT_INTVEC_EVENT_COMBINER,
101 #endif
102 45,
103 CSL_UART_2_MODULE_FREQ,
104 0,
105 0,
106 0,
107 0,
108 0,
109 0,
110 0,
111 NULL,
112 UART_RXTRIGLVL_8,
113 UART_TXTRIGLVL_56,
114 FALSE,
115 FALSE, /* Loopback disabled by default */
116 TRUE, /* Interrupt enabled by default */
117 UART16x_OPER_MODE,
118 },
119 };
121 /* UART objects */
122 UART_V1_Object UartObjects[CSL_UART_PER_CNT];
124 /* UART configuration structure */
125 CSL_PUBLIC_CONST UART_Config UART_config[CSL_UART_PER_CNT + 1U] = {
126 {
127 &UART_FxnTable_v1,
128 &UartObjects[0],
129 &uartInitCfg[0]
130 },
132 {
133 &UART_FxnTable_v1,
134 &UartObjects[1],
135 &uartInitCfg[1]
136 },
138 {
139 &UART_FxnTable_v1,
140 &UartObjects[2],
141 &uartInitCfg[2]
142 },
144 {NULL, NULL, NULL}
145 };
147 /**
148 * \brief This API gets the SoC level of UART intial configuration
149 *
150 * \param index UART instance index.
151 * \param cfg Pointer to UART SOC initial config.
152 *
153 * \return 0 success: -1: error
154 *
155 */
156 int32_t UART_socGetInitCfg(uint32_t index, UART_HwAttrs *cfg)
157 {
158 int32_t ret = 0;
160 if (index < CSL_UART_PER_CNT)
161 {
162 *cfg = uartInitCfg[index];
163 }
164 else
165 {
166 ret = -1;
167 }
169 return ret;
170 }
172 /**
173 * \brief This API sets the SoC level of UART intial configuration
174 *
175 * \param index UART instance index.
176 * \param cfg Pointer to UART SOC initial config.
177 *
178 * \return 0 success: -1: error
179 *
180 */
181 int32_t UART_socSetInitCfg(uint32_t index, const UART_HwAttrs *cfg)
182 {
183 int32_t ret = 0;
185 if (index < CSL_UART_PER_CNT)
186 {
187 uartInitCfg[index] = *cfg;
188 }
189 else
190 {
191 ret = -1;
192 }
194 return ret;
195 }