PDK API Guide for AM64x
board.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
46 #ifndef BOARD_UTILS_H_
47 #define BOARD_UTILS_H_
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
80 /* @} */
81 
82 
95 #include <stdint.h>
96 
97 #include <ti/csl/hw_types.h>
98 
114 /* w should be power of 2 */
115 #define BOARD_CACHE_LINE_SIZE (128)
116 #define board_roundup(n,w) (((n) + (w) - 1) & ~((w) - 1))
117 
118 /*************************************************************
119  * Return/Error values *
120  *************************************************************/
121 
122 #include <ti/board/board_cfg.h>
123 
125 #define BOARD_SOK 0
126 
127 #define BOARD_INVALID_PARAM -1
128 
129 #define BOARD_UNSUPPORTED_FEATURE -2
130 
131 #define BOARD_I2C_OPEN_FAIL -3
132 
133 #define BOARD_I2C_TRANSFER_FAIL -4
134 
135 #define BOARD_PINMUX_BAD_MEM_REGION -5
136 
137 #define BOARD_INIT_CLOCK_FAIL -6
138 
139 #define BOARD_INIT_DDR_FAIL -7
140 
141 #define BOARD_PINMUX_INVALID_MODE -8
142 
143 #define BOARD_FAIL -10
144 
145 /*************************************************************
146  * Init/Info Definitons *
147  *************************************************************/
148 
149 /* Max number of characters per ID entry field */
150 #define BOARD_MAX_ID_STR_LEN 20
151 
152 #define BOARD_BOARD_NAME_LEN (16U)
153 #define BOARD_DESIGN_REV_LEN (2U)
154 #define BOARD_PROC_NUM_LEN (4U)
155 #define BOARD_VARIANT_LEN (2U)
156 #define BOARD_PCBREV_LEN (2U)
157 #define BOARD_SCHMBOM_REV_LEN (2U)
158 #define BOARD_SWREV_LEN (2U)
159 #define BOARD_VENDORID_LEN (2U)
160 #define BOARD_BUILD_WEEK_LEN (2U)
161 #define BOARD_BUILD_YEAR_LEN (2U)
162 #define BOARD_BOARDID_LEN (6U)
163 #define BOARD_SERIAL_NUM_LEN (4U)
164 #define BOARD_MAC_ADDR_LEN (192U)
165 
166 
167 /*************************************************************
168  * SoC Info Definitons *
169  *************************************************************/
170 
171 /* Default system clock value */
172 #define BOARD_SYS_CLK_DEFAULT (0xFFFFFFFFU)
173 
180 typedef struct {
181 
182  /* Header ID of the SOC */
183  char header[BOARD_MAX_ID_STR_LEN];
184 
185  /* Name of the board */
186  char boardName[BOARD_MAX_ID_STR_LEN];
187 
188  /* Board version/revision info */
190 
191  /* Board serial number */
192  char serialNum[BOARD_MAX_ID_STR_LEN];
193 
194  /* Board configuration codes */
195  char configCodes[2*BOARD_MAX_ID_STR_LEN];
196 
197  /* Industrial Ethernet MAC address 0 */
198  char indEthMacID0[BOARD_MAX_ID_STR_LEN];
199 
200  /* Industrial Ethernet MAC address 3 */
201  char indEthMacID3[BOARD_MAX_ID_STR_LEN];
202 
203 } Board_IDInfo;
204 
205 typedef struct
206 {
207  uint8_t macStructType;
208  uint16_t macLength;
209  uint16_t macControl;
210  uint8_t macAddress[BOARD_MAC_ADDR_LEN];
211 } __attribute__((packed)) Board_macInfo;
212 
213 typedef struct
214 {
215  uint8_t ddrStructType;
216  uint16_t ddrStructLen;
217  uint16_t ddrCtrl;
218 } __attribute__((packed)) Board_ddrInfo;
219 
220 typedef struct
221 {
223  uint16_t boardInfoLength;
224  char boardName[BOARD_BOARD_NAME_LEN];
225  char designRev[BOARD_DESIGN_REV_LEN];
226  char procNum[BOARD_PROC_NUM_LEN];
227  char variant[BOARD_VARIANT_LEN];
228  char pcbRev[BOARD_PCBREV_LEN];
229  char schbomRev[BOARD_SCHMBOM_REV_LEN];
230  char swRev[BOARD_SWREV_LEN];
231  char vendorID[BOARD_VENDORID_LEN];
232  char buildWeek[BOARD_BUILD_WEEK_LEN];
233  char buildYear[BOARD_BUILD_YEAR_LEN];
234  char boardID[BOARD_BOARDID_LEN];
235  char serialNum[BOARD_SERIAL_NUM_LEN];
236 } __attribute__((packed)) Board_boardInfo;
237 
238 typedef struct
239 {
240  uint32_t magicNumber;
242  uint16_t payloadSize;
243 } __attribute__((packed)) Board_headerInfo;
244 
251 typedef struct
252 {
253  /* Header info of the board */
254  Board_headerInfo headerInfo;
255 
256  /* Board id Info of the board */
257  Board_boardInfo boardInfo;
258 
259  /* DDR info of the board */
260  Board_ddrInfo ddrInfo;
261 
262  /* Mac Info of the board */
263  Board_macInfo macInfo;
264 
265  /* End of the structure */
266  uint8_t endList;
267 
268 } __attribute__((packed)) Board_IDInfo_v2;
269 
273 typedef struct {
274 
275  /* System clock value in Hz */
276  uint32_t sysClock;
277 
278 } Board_SoCInfo;
279 
285 typedef enum {
305 
306 typedef uint32_t Board_initCfg;
307 #define BOARD_INIT_ALL (0xFFFFFFFFU)
308 #define BOARD_INIT_UNLOCK_MMR (1 << 1U)
309 #define BOARD_INIT_PLL (1 << 2U)
310 #define BOARD_INIT_PLL_MCU (1 << 3U)
311 #define BOARD_INIT_PLL_MAIN (1 << 4U)
312 #define BOARD_INIT_MODULE_CLOCK (1 << 5U)
313 #define BOARD_INIT_MODULE_CLOCK_MCU (1 << 6U)
314 #define BOARD_INIT_MODULE_CLOCK_MAIN (1 << 7U)
315 #define BOARD_INIT_DDR (1 << 8U)
316 #define BOARD_INIT_WATCHDOG_DISABLE (1 << 9U)
317 #define BOARD_INIT_PINMUX_CONFIG (1 << 10U)
318 #define BOARD_INIT_PINMUX_CONFIG_MAIN (1 << 11U)
319 #define BOARD_INIT_PINMUX_CONFIG_MCU (1 << 12U)
320 #define BOARD_INIT_UART_STDIO (1 << 13U)
321 #define BOARD_INIT_ICSS_PINMUX (1 << 14U)
322 #define BOARD_INIT_ETH_PHY (1 << 15U)
323 #define BOARD_INIT_ECC (1 << 16U)
324 #define BOARD_INIT_PLL_OPP_HIGH (1 << 17U)
325 #define BOARD_INIT_PLL_OPP_OD (1 << 18U)
326 #define BOARD_INIT_PLL_OPP_NOM (1 << 19U)
327 /* iceK2G requires board specific Ethernet configurations for
328  proper operation of Ethernet interfaces. Applications
329  using NSS(Gigabit) or ICSS(10/100mbps) Ethernet inteface
330  should call Board_init() with config control macro
331  'BOARD_INIT_ETH_PHY' for initializing Gigabit Ethernet PHY and
332  'BOARD_INIT_ICSS_ETH_PHY' to invoke the PRU_ICSS Ethernet PHY
333  initialization */
334 /* Config control bit definition for 10/100 Ethernet PHY intialization */
335 #define BOARD_INIT_ICSS_ETH_PHY (1 << 20U)
336 /* Flag to enable EMIF pin mux configuration during Board_init.
337  EMIF pin mux is done as part of default pin mux as configuring EMIF pinmux
338  while system is running from SDRAM/DDR can corrupt the memory.
339  Use this flag only from the applications which are not running from SDRAM/DDR
340 */
341 #define BOARD_INIT_EMIF_PINMUX (1 << 21U)
342 /* Applies only to devices with DDR ECC support */
343 #define BOARD_INIT_DDR_ECC (1 << 22U)
344 /* Initializes SerDes module */
345 #define BOARD_INIT_SERDES_PHY (1 << 23U)
346 /* Initializes I2C controller instances used by the board */
347 #define BOARD_INIT_I2C (1 << 24U)
348 /* De-Initializes I2C controller instances used by the board */
349 #define BOARD_DEINIT_I2C (1 << 25U)
350 #define BOARD_INIT_CPSW9G_ETH_PHY (1 << 26U)
351 
352 /* Configures ENET Control(mac mode, delay settings) for CPSW/ICCS ports */
353 #define BOARD_INIT_ENETCTRL_CPSW3G (1 << 27U)
354 #define BOARD_INIT_ENETCTRL_CPSW2G (1 << 27U)
355 #define BOARD_INIT_ENETCTRL_CPSW9G (1 << 28U)
356 #define BOARD_INIT_ENETCTRL_ICSS (1 << 29U)
357 #define BOARD_INIT_DEFAULT BOARD_INIT_ALL
358 #define BOARD_INIT_CPSW5G_ETH_PHY (BOARD_INIT_CPSW9G_ETH_PHY)
359 #define BOARD_INIT_ENETCTRL_CPSW5G (BOARD_INIT_ENETCTRL_CPSW9G)
360 
361 #define BOARD_DEINIT_ALL (0xFFFFFFFFU)
362 #define BOARD_DEINIT_LOCK_MMR (1 << 1U)
363 #define BOARD_DEINIT_MODULE_CLOCK (1 << 2U)
364 #define BOARD_DEINIT_UART_STDIO (1 << 3U)
365 #define BOARD_DEINIT_DEFAULT BOARD_DEINIT_ALL
366 
367 #define BOARD_RESOURCE_ALL (0xFFFFU)
368 #define BOARD_RESOURCE_MMR (1U)
369 #define BOARD_RESOURCE_MODULE_CLOCK (2U)
370 #define BOARD_RESOURCE_UART_STDIO (3U)
371 #define BOARD_RESOURCE_SCICLIENT (4U)
372 
373 
375 
376 /* @} */
377 
384 
385 /*************************************************************
386  * APIs *
387  *************************************************************/
388 
398 Board_STATUS Board_getIDInfo(Board_IDInfo *info);
399 
411 Board_STATUS Board_getIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress);
412 
424 Board_STATUS Board_writeIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress);
425 
435 Board_STATUS Board_getSoCInfo(Board_SoCInfo *socInfo);
436 
446 Board_STATUS Board_init(Board_initCfg cfg);
447 
462 Board_STATUS Board_initLite(Board_initCfg cfg);
463 
474 Board_STATUS Board_deinit(Board_initCfg cfg);
475 
483 Board_STATUS Board_releaseResource (uint32_t resourceID);
484 
495 
496 #ifdef __cplusplus
497 }
498 #endif
499 
500 #endif
501 /* @} */
#define BOARD_BUILD_YEAR_LEN
Definition: board.h:161
#define BOARD_BUILD_WEEK_LEN
Definition: board.h:160
#define BOARD_PCBREV_LEN
Definition: board.h:156
Board_boardInfo boardInfo
Definition: board.h:257
uint16_t macControl
Definition: board.h:209
Board_STATUS Board_releaseResource(uint32_t resourceID)
Board library function to release the resources.
Board_STATUS Board_init(Board_initCfg cfg)
Initialization functions for a specific board.
uint32_t Board_initCfg
Definition: board.h:306
#define BOARD_DESIGN_REV_LEN
Definition: board.h:153
This structure contains SoC specific information.
Definition: board.h:273
Board_ddrInfo ddrInfo
Definition: board.h:260
Board_STATUS Board_deinit(Board_initCfg cfg)
Board library deinitialization function.
uint8_t macStructType
Definition: board.h:207
#define BOARD_MAC_ADDR_LEN
Definition: board.h:164
uint8_t headerStructType
Definition: board.h:241
This structure contains board specific information.
Definition: board.h:180
#define BOARD_SWREV_LEN
Definition: board.h:158
uint8_t ddrStructType
Definition: board.h:215
void(* Board_thermalMgmtCallbackFunction_t)(Board_DDRTempEventType DDRTempEventType)
Definition: board.h:374
uint32_t sysClock
Definition: board.h:276
#define BOARD_PROC_NUM_LEN
Definition: board.h:154
Board_STATUS Board_writeIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress)
Set board information - v2.
Board_STATUS Board_getIDInfo(Board_IDInfo *info)
Get board information.
uint16_t ddrStructLen
Definition: board.h:216
Board_headerInfo headerInfo
Definition: board.h:254
#define BOARD_SERIAL_NUM_LEN
Definition: board.h:163
Board_STATUS Board_initLite(Board_initCfg cfg)
Board library initialization function with limited module initializations.
uint16_t ddrCtrl
Definition: board.h:217
Board_STATUS Board_getSoCInfo(Board_SoCInfo *socInfo)
Get SoC information.
#define BOARD_BOARD_NAME_LEN
Definition: board.h:152
Board_STATUS Board_DDRTempMonitoringInit(Board_thermalMgmtCallbackFunction_t callbackFunction)
Initialize Board DDR Temperature monitoring.
Board_DDRTempEventType
Enumeration of reported temperature event types.
Definition: board.h:285
#define BOARD_VENDORID_LEN
Definition: board.h:159
uint8_t endList
Definition: board.h:266
Board_macInfo macInfo
Definition: board.h:263
typedef __attribute__
uint16_t macLength
Definition: board.h:208
uint8_t boardInfoStructType
Definition: board.h:222
Definition: board.h:287
Board_STATUS Board_getIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress)
Get board information - v2.
#define BOARD_BOARDID_LEN
Definition: board.h:162
#define BOARD_SCHMBOM_REV_LEN
Definition: board.h:157
uint32_t magicNumber
Definition: board.h:240
uint16_t version
Definition: tisci_core.h:440
#define BOARD_VARIANT_LEN
Definition: board.h:155
uint16_t boardInfoLength
Definition: board.h:223
#define BOARD_MAX_ID_STR_LEN
Definition: board.h:150
uint16_t payloadSize
Definition: board.h:242