PDK API Guide for J721E
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 (20U)
151 
152 /* Max number of DDR instances in board info */
153 #define BOARD_DDR_INFO_MAX (4U)
154 
155 #define BOARD_BOARD_NAME_LEN (16U)
156 #define BOARD_DESIGN_REV_LEN (2U)
157 #define BOARD_PROC_NUM_LEN (4U)
158 #define BOARD_VARIANT_LEN (2U)
159 #define BOARD_PCBREV_LEN (2U)
160 #define BOARD_SCHMBOM_REV_LEN (2U)
161 #define BOARD_SWREV_LEN (2U)
162 #define BOARD_VENDORID_LEN (2U)
163 #define BOARD_BUILD_WEEK_LEN (2U)
164 #define BOARD_BUILD_YEAR_LEN (2U)
165 #define BOARD_BOARDID_LEN (6U)
166 #define BOARD_SERIAL_NUM_LEN (4U)
167 #define BOARD_MAC_ADDR_LEN (192U)
168 
169 
170 /*************************************************************
171  * SoC Info Definitons *
172  *************************************************************/
173 
174 /* Default system clock value */
175 #define BOARD_SYS_CLK_DEFAULT (0xFFFFFFFFU)
176 
183 typedef struct {
184 
185  /* Header ID of the SOC */
187 
188  /* Name of the board */
189  char boardName[BOARD_MAX_ID_STR_LEN];
190 
191  /* Board version/revision info */
193 
194  /* Board serial number */
195  char serialNum[BOARD_MAX_ID_STR_LEN];
196 
197  /* Board configuration codes */
198  char configCodes[2*BOARD_MAX_ID_STR_LEN];
199 
200  /* Industrial Ethernet MAC address 0 */
201  char indEthMacID0[BOARD_MAX_ID_STR_LEN];
202 
203  /* Industrial Ethernet MAC address 3 */
204  char indEthMacID3[BOARD_MAX_ID_STR_LEN];
205 
206 } Board_IDInfo;
207 
208 typedef struct
209 {
210  uint8_t macStructType;
211  uint16_t macLength;
212  uint16_t macControl;
213  uint8_t macAddress[BOARD_MAC_ADDR_LEN];
214 } __attribute__((packed)) Board_macInfo;
215 
216 typedef struct
217 {
218  uint8_t ddrStructType;
219  uint16_t ddrStructLen;
220  uint16_t ddrCtrl;
221 } __attribute__((packed)) Board_ddrInfo;
222 
223 typedef struct
224 {
226  uint16_t boardInfoLength;
227  char boardName[BOARD_BOARD_NAME_LEN];
228  char designRev[BOARD_DESIGN_REV_LEN];
229  char procNum[BOARD_PROC_NUM_LEN];
230  char variant[BOARD_VARIANT_LEN];
231  char pcbRev[BOARD_PCBREV_LEN];
232  char schbomRev[BOARD_SCHMBOM_REV_LEN];
233  char swRev[BOARD_SWREV_LEN];
234  char vendorID[BOARD_VENDORID_LEN];
235  char buildWeek[BOARD_BUILD_WEEK_LEN];
236  char buildYear[BOARD_BUILD_YEAR_LEN];
237  char boardID[BOARD_BOARDID_LEN];
238  char serialNum[BOARD_SERIAL_NUM_LEN];
239 } __attribute__((packed)) Board_boardInfo;
240 
241 typedef struct
242 {
243  uint32_t magicNumber;
245  uint16_t payloadSize;
246 } __attribute__((packed)) Board_headerInfo;
247 
254 typedef struct
255 {
256  /* Header info of the board */
257  Board_headerInfo headerInfo;
258 
259  /* Board id Info of the board */
260  Board_boardInfo boardInfo;
261 
262  /* DDR info of the board */
263  Board_ddrInfo ddrInfo;
264 
265  /* DDR info array to be used on platforms with multiple DDR instances */
266  Board_ddrInfo multiDdrInfo[BOARD_DDR_INFO_MAX];
267 
268  /* Mac Info of the board */
269  Board_macInfo macInfo;
270 
271  /* End of the structure */
272  uint8_t endList;
273 
274 } __attribute__((packed)) Board_IDInfo_v2;
275 
279 typedef struct {
280 
281  /* System clock value in Hz */
282  uint32_t sysClock;
283 
284 } Board_SoCInfo;
285 
291 typedef enum {
311 
312 typedef uint32_t Board_initCfg;
313 #define BOARD_INIT_ALL (0xFFFFFFFFU)
314 #define BOARD_INIT_UNLOCK_MMR (1 << 1U)
315 #define BOARD_INIT_PLL (1 << 2U)
316 #define BOARD_INIT_PLL_MCU (1 << 3U)
317 #define BOARD_INIT_PLL_MAIN (1 << 4U)
318 #define BOARD_INIT_MODULE_CLOCK (1 << 5U)
319 #define BOARD_INIT_MODULE_CLOCK_MCU (1 << 6U)
320 #define BOARD_INIT_MODULE_CLOCK_MAIN (1 << 7U)
321 #define BOARD_INIT_DDR (1 << 8U)
322 #define BOARD_INIT_WATCHDOG_DISABLE (1 << 9U)
323 #define BOARD_INIT_PINMUX_CONFIG (1 << 10U)
324 #define BOARD_INIT_PINMUX_CONFIG_MAIN (1 << 11U)
325 #define BOARD_INIT_PINMUX_CONFIG_MCU (1 << 12U)
326 #define BOARD_INIT_UART_STDIO (1 << 13U)
327 #define BOARD_INIT_ICSS_PINMUX (1 << 14U)
328 #define BOARD_INIT_ETH_PHY (1 << 15U)
329 #define BOARD_INIT_ECC (1 << 16U)
330 #define BOARD_INIT_PLL_OPP_HIGH (1 << 17U)
331 #define BOARD_INIT_PLL_OPP_OD (1 << 18U)
332 #define BOARD_INIT_PLL_OPP_NOM (1 << 19U)
333 /* iceK2G requires board specific Ethernet configurations for
334  proper operation of Ethernet interfaces. Applications
335  using NSS(Gigabit) or ICSS(10/100mbps) Ethernet inteface
336  should call Board_init() with config control macro
337  'BOARD_INIT_ETH_PHY' for initializing Gigabit Ethernet PHY and
338  'BOARD_INIT_ICSS_ETH_PHY' to invoke the PRU_ICSS Ethernet PHY
339  initialization */
340 /* Config control bit definition for 10/100 Ethernet PHY intialization */
341 #define BOARD_INIT_ICSS_ETH_PHY (1 << 20U)
342 /* Flag to enable EMIF pin mux configuration during Board_init.
343  EMIF pin mux is done as part of default pin mux as configuring EMIF pinmux
344  while system is running from SDRAM/DDR can corrupt the memory.
345  Use this flag only from the applications which are not running from SDRAM/DDR
346 */
347 #define BOARD_INIT_EMIF_PINMUX (1 << 21U)
348 /* Applies only to devices with DDR ECC support.
349  BOARD_DDR_ENABLE_DDR_MEM_PRIME macro in board_cfg.h should be enabled
350  to prime the DDR Memory for ECC.
351 */
352 #define BOARD_INIT_DDR_ECC (1 << 22U)
353 /* Initializes SerDes module */
354 #define BOARD_INIT_SERDES_PHY (1 << 23U)
355 /* Initializes I2C controller instances used by the board */
356 #define BOARD_INIT_I2C (1 << 24U)
357 /* De-Initializes I2C controller instances used by the board */
358 #define BOARD_DEINIT_I2C (1 << 25U)
359 #define BOARD_INIT_CPSW9G_ETH_PHY (1 << 26U)
360 
361 /* Configures ENET Control(mac mode, delay settings) for CPSW/ICCS ports */
362 #define BOARD_INIT_ENETCTRL_CPSW3G (1 << 27U)
363 #define BOARD_INIT_ENETCTRL_CPSW2G (1 << 27U)
364 #define BOARD_INIT_ENETCTRL_CPSW9G (1 << 28U)
365 #define BOARD_INIT_ENETCTRL_ICSS (1 << 29U)
366 #define BOARD_INIT_DEFAULT BOARD_INIT_ALL
367 #define BOARD_INIT_CPSW5G_ETH_PHY (BOARD_INIT_CPSW9G_ETH_PHY)
368 #define BOARD_INIT_ENETCTRL_CPSW5G (BOARD_INIT_ENETCTRL_CPSW9G)
369 /* Re-using I2C init and deinit flag values for below two macros as '1 << 31' causing
370  * build failure for C7x. I2C flags are not used/supported by any platforms
371  */
372 #define BOARD_INIT_CPSW2G_MAIN_ETH_PHY (1 << 24U)
373 #define BOARD_INIT_ENETCTRL_CPSW2G_MAIN (1 << 25U)
374 
375 #define BOARD_DEINIT_ALL (0xFFFFFFFFU)
376 #define BOARD_DEINIT_LOCK_MMR (1 << 1U)
377 #define BOARD_DEINIT_MODULE_CLOCK (1 << 2U)
378 #define BOARD_DEINIT_UART_STDIO (1 << 3U)
379 #define BOARD_DEINIT_DEFAULT BOARD_DEINIT_ALL
380 
381 #define BOARD_RESOURCE_ALL (0xFFFFU)
382 #define BOARD_RESOURCE_MMR (1U)
383 #define BOARD_RESOURCE_MODULE_CLOCK (2U)
384 #define BOARD_RESOURCE_UART_STDIO (3U)
385 #define BOARD_RESOURCE_SCICLIENT (4U)
386 
387 
389 
390 /* @} */
391 
398 
399 /*************************************************************
400  * APIs *
401  *************************************************************/
402 
412 Board_STATUS Board_getIDInfo(Board_IDInfo *info);
413 
425 Board_STATUS Board_getIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress);
426 
438 Board_STATUS Board_writeIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress);
439 
449 Board_STATUS Board_getSoCInfo(Board_SoCInfo *socInfo);
450 
460 Board_STATUS Board_init(Board_initCfg cfg);
461 
476 Board_STATUS Board_initLite(Board_initCfg cfg);
477 
488 Board_STATUS Board_deinit(Board_initCfg cfg);
489 
497 Board_STATUS Board_releaseResource (uint32_t resourceID);
498 
509 
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 #endif
515 /* @} */
#define BOARD_BUILD_YEAR_LEN
Definition: board.h:164
#define BOARD_DDR_INFO_MAX
Definition: board.h:153
#define BOARD_BUILD_WEEK_LEN
Definition: board.h:163
#define BOARD_PCBREV_LEN
Definition: board.h:159
Board_boardInfo boardInfo
Definition: board.h:260
uint16_t macControl
Definition: board.h:212
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:312
#define BOARD_DESIGN_REV_LEN
Definition: board.h:156
This structure contains SoC specific information.
Definition: board.h:279
Board_ddrInfo ddrInfo
Definition: board.h:263
Board_STATUS Board_deinit(Board_initCfg cfg)
Board library deinitialization function.
uint8_t macStructType
Definition: board.h:210
#define BOARD_MAC_ADDR_LEN
Definition: board.h:167
uint8_t headerStructType
Definition: board.h:244
This structure contains board specific information.
Definition: board.h:183
#define BOARD_SWREV_LEN
Definition: board.h:161
uint8_t ddrStructType
Definition: board.h:218
void(* Board_thermalMgmtCallbackFunction_t)(Board_DDRTempEventType DDRTempEventType)
Definition: board.h:388
typedef __attribute__
UInteger224 (802.1AS, 10.3.4 time-synchronization spanning tree priority vectors )
uint32_t sysClock
Definition: board.h:282
#define BOARD_PROC_NUM_LEN
Definition: board.h:157
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:219
Board_headerInfo headerInfo
Definition: board.h:257
#define BOARD_SERIAL_NUM_LEN
Definition: board.h:166
Board_STATUS Board_initLite(Board_initCfg cfg)
Board library initialization function with limited module initializations.
uint16_t ddrCtrl
Definition: board.h:220
Board_STATUS Board_getSoCInfo(Board_SoCInfo *socInfo)
Get SoC information.
#define BOARD_BOARD_NAME_LEN
Definition: board.h:155
Board_STATUS Board_DDRTempMonitoringInit(Board_thermalMgmtCallbackFunction_t callbackFunction)
Initialize Board DDR Temperature monitoring.
Board_DDRTempEventType
Enumeration of reported temperature event types.
Definition: board.h:291
#define BOARD_VENDORID_LEN
Definition: board.h:162
uint8_t endList
Definition: board.h:272
Board_macInfo macInfo
Definition: board.h:269
uint16_t macLength
Definition: board.h:211
uint8_t boardInfoStructType
Definition: board.h:225
Definition: board.h:293
Board_STATUS Board_getIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress)
Get board information - v2.
#define BOARD_BOARDID_LEN
Definition: board.h:165
#define BOARD_SCHMBOM_REV_LEN
Definition: board.h:160
uint32_t magicNumber
Definition: board.h:243
uint16_t version
Definition: tisci_core.h:443
#define BOARD_VARIANT_LEN
Definition: board.h:158
uint8_t header
Definition: icssg_priv.h:115
uint16_t boardInfoLength
Definition: board.h:226
#define BOARD_MAX_ID_STR_LEN
Definition: board.h:150
uint16_t payloadSize
Definition: board.h:245