]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pdk_k2g_1_0_1_0_eng/packages/ti/board/diag/common/K2G/platform_test.h
Add alpha files for car
[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1_0_eng / packages / ti / board / diag / common / K2G / platform_test.h
1 /*
2  * Copyright (c) 2015, 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  */
34 /**
35  *  \file    platform_test.h
36  *
37  *  \brief  This file contains the common definitions for platform test
38  *
39  *****************************************************************************/
41 #ifndef _PLATFORM_TEST_H_
42 #define _PLATFORM_TEST_H_
44 #include "platform.h"
45 //#include "resource_mgr.h"
47 #define PTR_NULL                ((void *) 0)
49 #define PLATFORM_TEST_VER "01.00.00"
51 /* Platform test return codes */
52 #define TEST_PASS     (0)
53 #define TEST_FAIL     (-1)
55 /* Default platform init flag values */
56 #define PLATFORM_INIT_FLAGS_PLL    (0)
57 #define PLATFORM_INIT_FLAGS_DDR    (0)
58 #define PLATFORM_INIT_FLAGS_TCSL   (1)
59 #define PLATFORM_INIT_FLAGS_PHY    (1)
60 #define PLATFORM_INIT_FLAGS_ECC    (1)
62 /* Default platform init config values */
63 #define PLATFORM_INIT_CONFIG_PLLM          (0)
64 #define PLATFORM_INIT_CONFIG_PLLD          (0)
65 #define PLATFORM_INIT_CONFIG_PREDIV        (0)
66 #define PLATFORM_INIT_CONFIG_POSTDIV       (0)
67 #define PLATFORM_INIT_CONFIG_MASTERCORE    (0)
70 #ifdef AUDIODC_DIAG_TESTS
71 /* Maximum supported platform test options */
72 #define PLATFORM_TEST_COUNT        (3)
73 #define PLATFORM_TEST_START        (0)
74 #define PLATFORM_AUTO_TEST_COUNT   (0)
76 #else
77 /* Maximum supported platform test options */
78 #define PLATFORM_TEST_COUNT        (27)
79 #define PLATFORM_TEST_START        (3)
80 #define PLATFORM_AUTO_TEST_COUNT   (20)
81 #endif
83 #define PLATFORM_MEM_TEST_START    (3)
84 #define PLATFORM_MEM_TEST_COUNT    (6)
86 /* UART settings  */
87 #define PLATFORM_TEST_UART_BAUD    (115200)
89 /* Flag to enable/disable auto execution for platform tests */
90 #ifdef ENABLE_AUTO_RUN
91 #define PLATFORM_TEST_AUTO_RUN  (1)
92 #else
93 #define PLATFORM_TEST_AUTO_RUN  (0)
94 #endif
96 //#define GALILEO_SIM_TEST         (1)
98 #define PLATFORM_TEST_AUTO_ALL    (0)
99 #define PLATFORM_TEST_AUTO_MEM    (1)
100 #define PLATFORM_TEST_GET_INFO    (98)
101 #define PLATFORM_TEST_ID_PROG     (99)
103 /** Value of system clock in Hz */
104 #define PLATFORM_TEST_SYS_CLK     (600000000)
106 #define PLATFORM_TEST_DEBUG 1
108 #if (PLATFORM_TEST_DEBUG)
109 #define IFDEBUGPRINT(x)   (x)
110 #else
111 #define IFDEBUGPRINT(x)
112 #endif
114 /** EEPROM and Board ID configuration defines */
115 #define EEPROM_ID_HEADER_LENGTH       (4)
116 #define EEPROM_ID_BOARD_LENGTH        (8)
117 #define EEPROM_ID_VERSION_LENGTH      (4)
118 #define EEPROM_ID_SERIAL_NO_LENGTH    (12)
119 #define EEPROM_ID_CONFIG_LENGTH       (32)
121 #define EEPROM_ID_HEADER_ADDR         (0)
122 #define EEPROM_ID_BOARD_ADDR          (EEPROM_ID_HEADER_ADDR + EEPROM_ID_HEADER_LENGTH)
123 #define EEPROM_ID_VERSION_ADDR        (EEPROM_ID_BOARD_ADDR + EEPROM_ID_BOARD_LENGTH)
124 #define EEPROM_ID_SERIAL_NO_ADDR      (EEPROM_ID_VERSION_ADDR + EEPROM_ID_VERSION_LENGTH)
125 #define EEPROM_ID_CONFIG_ADDR         (EEPROM_ID_SERIAL_NO_ADDR + EEPROM_ID_SERIAL_NO_LENGTH)
127 #define UART_ID_DB9                    (0)
128 #define UART_ID_UART2USB               (1)
129 #define UART_ID_SERIAL_HEADER          (2)
131 /** Indicates audio test in loopback mode */
132 #define AUDIO_TEST_MODE_LOOPBACK       (0)
133 /** Indicates audio test in playback mode */
134 #define AUDIO_TEST_MODE_PLAYBACK       (1)
136 /* Platform test return type */
137 typedef int16_t TEST_STATUS;
139 /**
140  *  \brief Platform test table structure
141  *
142  */
143 typedef struct diagTestTable_s
145     uint8_t testName[50];
146         TEST_STATUS (*testFunction)(void *);
147         void  *args;
148         uint32_t pass;
149         uint32_t fail;
150 } diagTestTable_t;
152 /*
153    Intention of test arguments is to maintain all the configurations
154    in one place instead of fixing in each test function.
155    Test arguments are primarily required for memory test functions
156    for communicating the information like sector, block, size etc.
157    Test arguments are provided for all the tests for
158    maintaining consistent API signature and for future use.
159    Some of the test functions may not use the test arguments in the
160    current implementation.
162    Test argument structures shall be extended during the test
163    implementation based on the need.
164 */
166 /**
167  *  \brief DDR test argument structure
168  *
169  */
170 typedef struct
172     uint8_t  autoRun; /** Flag to enable/disable test auto run */
173     uint32_t region1;
174     uint32_t region2;
175     uint32_t count;
176         uint32_t clkSel;
177 } ddrTestArgs_t;
179 /**
180  *  \brief NAND test argument structure
181  *
182  */
183 typedef struct
185     uint8_t  autoRun;     /** Flag to enable/disable test auto run */
186     uint32_t blockNum;    /** NAND flash block number to execute read/write */
187     uint32_t blockLen;    /** Length in bytes to read/write from NAND flash */
188     uint32_t devId;       /** NAND flash device ID */
189     uint8_t  testPattern; /** Test Pattern */
191 } nandTestArgs_t;
193 /**
194  *  \brief QSPI flash test argument structure
195  *
196  */
197 typedef struct
199     uint8_t  autoRun;     /** Flag to enable/disable test auto run */
200     uint32_t sectNum;     /** QSPI flash sector number to execute read/write */
201     uint32_t blockLen;    /** Length in bytes to read/write from QSPI flash */
202     uint32_t devId;       /** QSPI flash device ID */
203     uint8_t  testPattern; /** Test Pattern */
205 } qspiFlashTestArgs_t;
207 /**
208  *  \brief SPI nor test argument structure
209  *
210  */
211 typedef struct
213     uint8_t  autoRun;     /** Flag to enable/disable test auto run */
214     uint32_t sectNum;     /** NOR flash sector number to execute read/write */
215     uint32_t blockLen;    /** Length in bytes to read/write from NOR flash */
216     uint32_t devId;       /** NOR flash device ID */
217     uint8_t  testPattern; /** Test Pattern */
219 } spiNorTestArgs_t;
221 /**
222  *  \brief I2C EEPROM test argument structure
223  *
224  */
225 typedef struct
227     uint8_t  autoRun;    /** Flag to enable/disable test auto run */
228     uint16_t offset;     /** EEPROM offset to execute read/write */
229     uint16_t blockLen;   /** Length in bytes to read/write from EEPROM */
230     uint8_t  i2cPortNum; /** EEPROM I2C port number */
231     uint8_t  slaveAddr;  /** Slave address of I2C device */
233 } i2cEepromTestArgs_t;
235 /**
236  *  \brief EMMC test argument structure
237  *
238  */
239 typedef struct
241     uint8_t autoRun; /** Flag to enable/disable test auto run */
243 } emmcTestArgs_t;
245 /**
246  *  \brief SD test argument structure
247  *
248  */
249 typedef struct
251     uint8_t autoRun; /** Flag to enable/disable test auto run */
253 } sdTestArgs_t;
255 /**
256  *  \brief PCIe test argument structure
257  *
258  */
259 typedef struct
261     uint8_t  autoRun;       /** Flag to enable/disable test auto run */
262     uint8_t  mode;          /** Test mode */
264 } pcieTestArgs_t;
266 /**
267  *  \brief DCAN test argument structure
268  *
269  */
270 typedef struct
272     uint8_t autoRun; /** Flag to enable/disable test auto run */
274 } dcanTestArgs_t;
276 /**
277  *  \brief HDMI test argument structure
278  *
279  */
280 typedef struct
282     uint8_t autoRun; /** Flag to enable/disable test auto run */
284 } hdmiTestArgs_t;
286 /**
287  *  \brief LCD test argument structure
288  *
289  */
290 typedef struct
292     uint8_t autoRun; /** Flag to enable/disable test auto run */
294 } lcdTestArgs_t;
296 /**
297  *  \brief Touch test argument structure
298  *
299  */
300 typedef struct
302     uint8_t autoRun; /** Flag to enable/disable test auto run */
304 } touchTestArgs_t;
306 /**
307  *  \brief Ethernet test argument structure
308  *
309  */
310 typedef struct
312     uint8_t autoRun; /** Flag to enable/disable test auto run */
314 } ethernetTestArgs_t;
316 /**
317  *  \brief UART test argument structure
318  *
319  */
320 typedef struct
322     uint8_t  autoRun;   /** Flag to enable/disable test auto run */
323     uint32_t baudRate;  /** UART baudrate to run the test */
324     uint8_t  uartPort;  /** UART port number */
325     uint8_t  uartId;    /** UART port ID on EVM
326                             0 - DB9 connector
327                             1 - UART to USB port
328                             2 - SoC Serial Header */
329         uint8_t  loopback;  /** Flag to indicate UART loopback tesr
330                                 0 - UART serial test on ports indicated by 'uartPort'
331                                 1 - UART loopback test with ports indicated by uartPort'
332                                     and 'uartLBPort' */
333     uint8_t  uartLBPort; /** Second UART port number for loopback test */
334     uint8_t  uartLBId;  /** Second UART port ID for loopback test
335                             0 - DB9 connector
336                             1 - UART to USB port
337                             2 - SoC Serial Header */
338 } uartTestArgs_t;
340 /**
341  *  \brief Audio clock test argument structure
342  *
343  */
344 typedef struct
346     uint8_t  autoRun;      /** Flag to enable/disable test auto run */
347     uint32_t sysClk;       /** CPU clock value */
348     uint32_t cptsCmpRate;  /** CPTS comparator rate */
349     uint32_t tsCmpOutClks; /** TS comparator clock count */
350     uint8_t  i2cPortNum;   /** CS2000 I2C port number */
351     uint8_t  i2cSlaveAddr; /** I2C slave address for CS2000 */
352     uint8_t  spiPortNum;   /** DAC 8550 SPI port number */
353     uint32_t spiCs;        /** DAC 8550 SPI chip select */
354     uint32_t spiClk;       /** SPI clock value */
356 } audioClkTestArgs_t;
358 /**
359  *  \brief MLB test argument structure
360  *
361  */
362 typedef struct
364     uint8_t autoRun; /** Flag to enable/disable test auto run */
366 } mlbTestArgs_t;
368 /**
369  *  \brief Temperature sensor test argument structure
370  *
371  */
372 typedef struct
374     uint8_t  autoRun;      /** Flag to enable/disable test auto run */
375     uint8_t  i2cPortNum;   /** Temperature sensor I2C port number */
376     uint8_t  i2cSlaveAddr; /** I2C slave address for temperature sensor */
377 } tempSensorTestArgs_t;
380 /**
381  *  \brief Audio test argument structure
382  *
383  */
384 typedef struct
386     uint8_t  autoRun;      /** Flag to enable/disable test auto run */
387     uint8_t  mcaspNum;     /** McASP instance number */
388     uint8_t  mode;         /** Mode of the test
389                                                    0 - Loopback Mode
390                                                    1 - Tone Play Mode */
391 } audioTestArgs_t;
393 /**
394  *  \brief LED test argument structure
395  *
396  */
397 typedef struct
399     uint8_t  autoRun;      /** Flag to enable/disable test auto run */
400 } ledTestArgs_t;
402 /**
403  *  \brief Expansion connector test argument structure
404  *
405  */
406 typedef struct
408     uint8_t  autoRun;      /** Flag to enable/disable test auto run */
409 } expConnTestArgs_t;
411 /**
412  *  \brief Test arguments for external tests
413  *
414  */
415 typedef struct
417     uint8_t  autoRun;       /** Flag to enable/disable test auto run */
418     uint8_t* testImageName; /** Name of the test Image */
419 } extTestArgs_t;
422 /**
423  *  \brief    Diagnostic test main function
424  *
425  *  \return   Platform_STATUS
426  */
427 Platform_STATUS diag_main (void);
429 /**
430  *  \brief    Executes all the diagnostic tests
431  *
432  *  \param    testArgs [IN]   Test arguments
433  *
434  *  \return   TEST_STATUS
435  */
436 TEST_STATUS run_external_tests(void *testArgs);
438 /**
439  *  \brief    Initializes platform test modules
440  *
441  *  \return    - Platform_EOK on Success or error code
442  */
443 Platform_STATUS initPlatform(void);
445 /**
446  *  \brief    Reads user input for deciding the test result
447  *
448  *  \return    - Platform_EOK on Success or error code
449  */
450 Platform_STATUS getTestResult(char *str);
452 /**
453  *  \brief    Function to generate delay in secs
454  *
455  *  \return    - None
456  */
457 void delay_secs(uint32_t secs);
459 /**
460  *  \brief    Function to exit the test
461  *
462  *  This function should be called by standalone diagnostic
463  *  tests at the end of the test to return to diagnostic test framework
464  *
465  *  \param result [IN]  Test result
466  *                      0 - Test Pass
467  *                      1 - Test Fail
468  *
469  */
470 void testExit(int result);
472 uint32_t CheckId(void);
473 void id_programming(void);
474 void displayBoardInfo(void);
475 Platform_STATUS GetIdValues(void);
476 void DisplayBoardIdError(void);
478 TEST_STATUS bmcTest(void *);
480 void extTestExit(void);
482 /**
483  *  \brief    Configures GPIO switch for serial port
484  *
485  *  This function selects the GPIO configuration for serial switch
486  *  between DB9 and 'UART to USB' ports on K2G EVM
487  *
488  *  \param portId [IN]  - Port ID; DB9 or 'UART to USB'
489  *
490  *  \return    - None
491  */
492 void configSerPortSwitch(uint8_t portId);
494 #endif // _PLATFORM_TEST_H_
496 /* Nothing past this point */