1 /******************************************************************************\r
2 * Copyright (c) 2010-2018 Texas Instruments Incorporated - http://www.ti.com\r
3 *\r
4 * Redistribution and use in source and binary forms, with or without\r
5 * modification, are permitted provided that the following conditions\r
6 * are met:\r
7 *\r
8 * Redistributions of source code must retain the above copyright\r
9 * notice, this list of conditions and the following disclaimer.\r
10 *\r
11 * Redistributions in binary form must reproduce the above copyright\r
12 * notice, this list of conditions and the following disclaimer in the\r
13 * documentation and/or other materials provided with the\r
14 * distribution.\r
15 *\r
16 * Neither the name of Texas Instruments Incorporated nor the names of\r
17 * its contributors may be used to endorse or promote products derived\r
18 * from this software without specific prior written permission.\r
19 *\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31 *\r
32 *****************************************************************************/\r
33 \r
34 #include "board_internal.h"\r
35 #include "board_cfg.h"\r
36 \r
37 Board_STATUS Board_internalInitI2C()\r
38 {\r
39 I2C_Params i2cParams;\r
40 int i;\r
41 Board_STATUS ret = BOARD_SOK;\r
42 uint8_t flag = 0;\r
43 \r
44 /* Board i2c usage does not depend on interrupts */\r
45 for (i=0; i < I2C_HWIP_MAX_CNT; i++)\r
46 {\r
47 /* Check if interrupt set to true. Change it to false and raise a flag\r
48 Note that number of i2c instances will not exceed 8 */\r
49 if (((I2C_HwAttrs *)I2C_config[i].hwAttrs)->enableIntr == true)\r
50 {\r
51 flag |= (1<<i);\r
52 ((I2C_HwAttrs *)I2C_config[i].hwAttrs)->enableIntr = false;\r
53 }\r
54 }\r
55 \r
56 I2C_init();\r
57 \r
58 I2C_Params_init(&i2cParams);\r
59 \r
60 /* Internal handle for I2C1 */\r
61 Board_obj.i2cHandle = I2C_open(BOARD_I2C_EEPROM_INSTANCE, &i2cParams);\r
62 if (Board_obj.i2cHandle == NULL)\r
63 ret = BOARD_I2C_OPEN_FAIL;\r
64 \r
65 /* Restore the original I2C_config table */\r
66 for (i=0; i < I2C_HWIP_MAX_CNT; i++)\r
67 {\r
68 if (flag & (1<<i))\r
69 ((I2C_HwAttrs *)I2C_config[i].hwAttrs)->enableIntr = true;\r
70 }\r
71 \r
72 return ret;\r
73 }\r
74 \r
75 Board_STATUS Board_uartStdioInit()\r
76 {\r
77 Board_IDInfo id;\r
78 Board_STATUS ret;\r
79 ret = Board_getIDInfo(&id);\r
80 socId_t socId = Board_soc_detect();\r
81 if (ret != BOARD_SOK)\r
82 {\r
83 return ret;\r
84 }\r
85 \r
86 #if defined (_TMS320C6X)\r
87 /*\r
88 * AM5 DSP does not have a default Xbar connection for UART\r
89 * interrupt, need the following Xbar interrupt configuration\r
90 */\r
91 /* Use reserved DSP1_IRQ_34 */\r
92 CSL_xbarDspIrqConfigure(1,\r
93 CSL_XBAR_INST_DSP1_IRQ_34,\r
94 CSL_XBAR_UART3_IRQ);\r
95 #endif\r
96 \r
97 /* Check if version is 1.0 or 1.1 */\r
98 if ((id.version[0] == '1' && id.version[2] == '0' && socId == SOC_ID_AM572x) ||\r
99 (id.version[0] == '1' && id.version[2] == '1' && socId == SOC_ID_AM572x))\r
100 UART_stdioInit(BOARD_UART_INSTANCE_ALPHA);\r
101 else\r
102 UART_stdioInit(BOARD_UART_INSTANCE_BETA);\r
103 return BOARD_SOK;\r
104 }\r