PDK-6945: Board: am64x evm eeprom test validated for board ID read
authorM V Pratap Reddy <x0257344@ti.com>
Fri, 11 Dec 2020 16:35:08 +0000 (22:05 +0530)
committerVishal Mahaveer <vishalm@ti.com>
Fri, 11 Dec 2020 19:35:20 +0000 (13:35 -0600)
 - Added board ID info read functions in am64x evm board library

packages/ti/board/diag/button/build/am64x_evm/GPIO_Button_config.c
packages/ti/board/diag/eeprom/src/eeprom_test_v2.c
packages/ti/board/diag/eeprom/src/eeprom_test_v2.h
packages/ti/board/src/am64x_evm/board_info.c

index 15e02e61a13a1fcb6810cc153eedd97b2bdfe617..8b6950f6057c877acae3cd9adc846d9e24961564 100755 (executable)
 #include <ti/board/board.h>\r
 \r
 #define BOARD_DIAG_PUSH_BUTTON0                       (0x012B) /* Port1 & Pin43 */\r
-#define BOARD_DIAG_PUSH_BUTTON1                       (0x0006) /* Port0 & pin6 */\r
 \r
 /* GPIO Driver board specific pin configuration structure */\r
 GPIO_PinConfig gpioPinConfigs[] = {\r
     BOARD_DIAG_PUSH_BUTTON0 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,\r
-    BOARD_DIAG_PUSH_BUTTON1 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING\r
 };\r
 \r
 /* GPIO Driver call back functions */\r
index 172b99174aae3f816e65dbde624f6d8fb1e5c5f0..c78e2f5686acbc7b69e6ac026910eaea7b2390ff 100755 (executable)
@@ -74,10 +74,10 @@ Board_I2cInitCfg_t boardI2cInitCfg[MAX_NUM_OF_BOARDS] = {
 boardProgInfo_t boardProgInfo[MAX_NUM_OF_BOARDS] = {
     {"EVM Board\0",                 BOARD_I2C_EEPROM_ADDR,     true}
 };
-#elif defined(SOC_AM64X)
+#elif defined(am64x_evm)
 boardProgInfo_t boardProgInfo[MAX_NUM_OF_BOARDS] = {
-    {"CP Board\0",                  CP_EEPROM_SLAVE_ADDR,        true},
-    {"IO Link Board\0",             IOLINK_EEPROM_SLAVE_ADDR,    false}
+    {"AM64x EVM\0",                 EVM_EEPROM_SLAVE_ADDR,       true},
+    {"AM64x IO-Link Board\0",       IOLINK_EEPROM_SLAVE_ADDR,    false}
 };
 Board_I2cInitCfg_t boardI2cInitCfg[MAX_NUM_OF_BOARDS] = {
     {0,     BOARD_SOC_DOMAIN_MAIN, false},
@@ -261,12 +261,6 @@ int main(void)
     /* Detecting Boards */
     enableWKUPI2C();
 #endif
-#if defined(am64x_evm) && !defined (__aarch64__)
-    /* MCU I2C instance will be active by default for R5 core.
-     * Need to update HW attrs to enable MAIN I2C instance.
-     */
-       enableMAINI2C(BOARD_I2C_EEPROM_INSTANCE, CSL_I2C0_CFG_BASE);
-#endif
 #if !(defined(SOC_TPR12))
        for(index = STARTING_BOARD_NUM; index < MAX_NUM_OF_BOARDS; index++)
     {
index 9895e20b2ed38452d2bf27c3ad1b7086317e7fcd..4308e7ace88db9e28db481632d568dc8bb2032f5 100755 (executable)
@@ -95,8 +95,8 @@ extern "C" {
 #define I2C_INSTANCE                            (0U)
 #define MAX_NUM_OF_BOARDS                       (2U)
 
-#define CP_EEPROM_SLAVE_ADDR                    (0x50U)
-#define IOLINK_EEPROM_SLAVE_ADDR              (0x52U)
+#define EVM_EEPROM_SLAVE_ADDR                   (0x50U)
+#define IOLINK_EEPROM_SLAVE_ADDR                (0x52U)
 #define STARTING_BOARD_NUM                      (1U)
 #else  /* j721e_evm */
 #define MAX_NUM_OF_BOARDS                       (9U)
index f2bd33a78e5c9b9f52a1dc9c8f16046318a2e84d..abb3935fb6fd8bc3176e9003a042cfe74f6ff620 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************\r
- * Copyright (c) 2019 Texas Instruments Incorporated - http://www.ti.com\r
+ * Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com\r
  *\r
  *  Redistribution and use in source and binary forms, with or without\r
  *  modification, are permitted provided that the following conditions\r
  *\r
  *****************************************************************************/\r
 \r
-/** \r
+/**\r
  *  \file board_info.c\r
  *\r
  *  \brief This file contains the functions to read/write board info data \r
  *\r
  */\r
 \r
+#include "board_utils.h"\r
 #include "board_internal.h"\r
 #include "board_cfg.h"\r
 #include <stdio.h>\r
 #include <string.h>\r
 \r
+extern Board_I2cInitCfg_t gBoardI2cInitCfg;\r
+\r
 /**\r
  *  @brief  This function is not supported by this platform.\r
  *\r
@@ -57,6 +60,10 @@ Board_STATUS Board_getIDInfo(Board_IDInfo *info)
 \r
 /**\r
  *  @brief      Get board information.\r
+ *  \r
+ *  This function requires the information of I2C instance and domain\r
+ *  to which board ID EEPROM is connected. This need to be set using\r
+ *  Board_setI2cInitConfig() before calling this function.\r
  *\r
  *  @param[out] Board_STATUS\r
  *    Returns status on API call\r
@@ -68,7 +75,170 @@ Board_STATUS Board_getIDInfo(Board_IDInfo *info)
  */\r
 Board_STATUS Board_getIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress)\r
 {\r
-    return BOARD_SOK;\r
+    Board_STATUS ret = BOARD_SOK;\r
+    I2C_Transaction i2cTransaction;\r
+    I2C_Handle handle = NULL;\r
+    uint16_t offsetAddress = BOARD_EEPROM_HEADER_ADDR;\r
+    uint8_t rdBuff[3];\r
+    char txBuf[2] = {0x00, 0x00};\r
+    bool status;\r
+\r
+    handle = Board_getI2CHandle(gBoardI2cInitCfg.socDomain,\r
+                                gBoardI2cInitCfg.i2cInst);\r
+    if(handle == NULL)\r
+    {\r
+        ret = BOARD_I2C_OPEN_FAIL;\r
+    }\r
+\r
+    I2C_transactionInit(&i2cTransaction);\r
+\r
+    i2cTransaction.slaveAddress = slaveAddress;\r
+    i2cTransaction.writeBuf = (uint8_t *)&txBuf[0];\r
+    i2cTransaction.writeCount = 2;\r
+\r
+    /* Get header info */\r
+    txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress)>>8);\r
+    txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+    i2cTransaction.readBuf = &info->headerInfo;\r
+    i2cTransaction.readCount = BOARD_EEPROM_HEADER_FIELD_SIZE;\r
+\r
+    status = I2C_transfer(handle, &i2cTransaction);\r
+    if (status == false)\r
+    {\r
+        ret = BOARD_I2C_TRANSFER_FAIL;\r
+        Board_i2cDeInit();\r
+        return ret;\r
+    }\r
+\r
+    /* Checking whether the board contents are flashed or not */\r
+    if (info->headerInfo.magicNumber == BOARD_EEPROM_MAGIC_NUMBER)\r
+    {\r
+        offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+        txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+        txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+        i2cTransaction.readBuf = &info->boardInfo;\r
+        i2cTransaction.readCount = BOARD_EEPROM_TYPE_SIZE +\r
+                                    BOARD_EEPROM_STRUCT_LENGTH_SIZE;\r
+        status = I2C_transfer(handle, &i2cTransaction);\r
+        if (status == false)\r
+        {\r
+            ret = BOARD_I2C_TRANSFER_FAIL;\r
+            Board_i2cDeInit();\r
+            return ret;\r
+        }\r
+\r
+        offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+        txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+        txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+        i2cTransaction.readBuf = info->boardInfo.boardName;\r
+        i2cTransaction.readCount = info->boardInfo.boardInfoLength;\r
+\r
+        status = I2C_transfer(handle, &i2cTransaction);\r
+        if (status == false)\r
+        {\r
+            ret = BOARD_I2C_TRANSFER_FAIL;\r
+            Board_i2cDeInit();\r
+            return ret;\r
+        }\r
+\r
+        offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+        txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+        txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+        i2cTransaction.readBuf = &rdBuff[0];\r
+        i2cTransaction.readCount = BOARD_EEPROM_TYPE_SIZE +\r
+                                    BOARD_EEPROM_STRUCT_LENGTH_SIZE;\r
+\r
+        status = I2C_transfer(handle, &i2cTransaction);\r
+        if (status == false)\r
+        {\r
+            ret = BOARD_I2C_TRANSFER_FAIL;\r
+            Board_i2cDeInit();\r
+            return ret;\r
+        }\r
+\r
+        /* Checking whether DDR field is present or not */\r
+        if (rdBuff[0] == BOARD_DDR_FIELD_TYPE)\r
+        {\r
+            memcpy(&info->ddrInfo, &rdBuff[0], sizeof(rdBuff));\r
+\r
+            offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+            txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress)>>8);\r
+            txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+            i2cTransaction.readBuf = &info->ddrInfo.ddrCtrl;\r
+            i2cTransaction.readCount = info->ddrInfo.ddrStructLen;\r
+\r
+            status = I2C_transfer(handle, &i2cTransaction);\r
+            if (status == false)\r
+            {\r
+                ret = BOARD_I2C_TRANSFER_FAIL;\r
+                Board_i2cDeInit();\r
+                return ret;\r
+            }\r
+\r
+            offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+            txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+            txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+            i2cTransaction.readBuf = &rdBuff[0];\r
+            i2cTransaction.readCount = BOARD_EEPROM_TYPE_SIZE +\r
+                                        BOARD_EEPROM_STRUCT_LENGTH_SIZE;\r
+            status = I2C_transfer(handle, &i2cTransaction);\r
+            if (status == false)\r
+            {\r
+                ret = BOARD_I2C_TRANSFER_FAIL;\r
+                Board_i2cDeInit();\r
+                return ret;\r
+            }\r
+        }\r
+\r
+        /* Checking whether MAC id field is present or not */\r
+        if(rdBuff[0] == BOARD_MACINFO_FIELD_TYPE)\r
+        {\r
+            memcpy(&info->macInfo, &rdBuff[0], sizeof(rdBuff));\r
+\r
+            offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+            txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+            txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+            i2cTransaction.readBuf = &info->macInfo.macControl;\r
+            i2cTransaction.readCount = info->macInfo.macLength;\r
+\r
+            status = I2C_transfer(handle, &i2cTransaction);\r
+            if (status == false)\r
+            {\r
+                ret = BOARD_I2C_TRANSFER_FAIL;\r
+                Board_i2cDeInit();\r
+                return ret;\r
+            }\r
+\r
+            offsetAddress = offsetAddress + i2cTransaction.readCount;\r
+            txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress)>>8);\r
+            txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+            i2cTransaction.readBuf = &rdBuff[0];\r
+            i2cTransaction.readCount = BOARD_EEPROM_TYPE_SIZE;\r
+\r
+            status = I2C_transfer(handle, &i2cTransaction);\r
+            if (status == false)\r
+            {\r
+                ret = BOARD_I2C_TRANSFER_FAIL;\r
+                Board_i2cDeInit();\r
+                return ret;\r
+            }\r
+        }\r
+\r
+        if(rdBuff[0] == BOARD_ENDLIST)\r
+        {\r
+            info->endList = rdBuff[0];\r
+        }\r
+    }\r
+    else\r
+    {\r
+        ret = BOARD_INVALID_PARAM;\r
+        Board_i2cDeInit();\r
+        return ret;\r
+    }\r
+\r
+    Board_i2cDeInit();\r
+\r
+    return ret;\r
 }\r
 \r
 /**\r
@@ -86,6 +256,10 @@ Board_STATUS Board_writeIDInfo(Board_IDInfo *info)
 /**\r
  *  @brief  Write board id contents to specific EEPROM.\r
  *\r
+ *  This function requires the information of I2C instance and domain\r
+ *  to which board ID EEPROM is connected. This need to be set using\r
+ *  Board_setI2cInitConfig() before calling this function.\r
+ *\r
  *  @param[out] Board_STATUS\r
  *    Returns status on API call\r
  * @param[out] info\r
@@ -96,5 +270,109 @@ Board_STATUS Board_writeIDInfo(Board_IDInfo *info)
  */\r
 Board_STATUS Board_writeIDInfo_v2(Board_IDInfo_v2 *info, uint8_t slaveAddress)\r
 {\r
-    return BOARD_SOK;\r
+    Board_STATUS ret = BOARD_SOK;\r
+    I2C_Transaction i2cTransaction;\r
+    I2C_Handle handle = NULL;\r
+    uint16_t offsetSize = 2;\r
+    uint16_t offsetAddress = BOARD_EEPROM_HEADER_ADDR;\r
+    char txBuf[BOARD_EEPROM_MAX_BUFF_LENGTH + 2 + 1];\r
+    bool status;\r
+\r
+    /* Checking the structure is valid or not */\r
+    if (info->headerInfo.magicNumber != BOARD_EEPROM_MAGIC_NUMBER)\r
+    {\r
+        ret = BOARD_INVALID_PARAM;\r
+        return ret;\r
+    }\r
+\r
+    handle = Board_getI2CHandle(gBoardI2cInitCfg.socDomain,\r
+                                gBoardI2cInitCfg.i2cInst);\r
+    if(handle == NULL)\r
+    {\r
+        ret = BOARD_I2C_OPEN_FAIL;\r
+    }\r
+\r
+    I2C_transactionInit(&i2cTransaction);\r
+\r
+    /* Transferring Header and Board Info field */\r
+    i2cTransaction.slaveAddress = slaveAddress;\r
+    i2cTransaction.writeBuf = &txBuf[0];\r
+    i2cTransaction.writeCount = BOARD_EEPROM_HEADER_FIELD_SIZE +\r
+                                BOARD_EEPROM_TYPE_SIZE +\r
+                                BOARD_EEPROM_STRUCT_LENGTH_SIZE +\r
+                                info->boardInfo.boardInfoLength +\r
+                                offsetSize;\r
+    txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+    txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+    memcpy(&txBuf[2], &info->headerInfo, i2cTransaction.writeCount);\r
+\r
+    i2cTransaction.readBuf = NULL;\r
+    i2cTransaction.readCount = 0;\r
+\r
+    status = I2C_transfer(handle, &i2cTransaction);\r
+    if (status == false)\r
+    {\r
+        ret = BOARD_I2C_TRANSFER_FAIL;\r
+        Board_i2cDeInit();\r
+        return ret;\r
+    }\r
+\r
+    /* Checking whether DDR field is included or not */\r
+    if (info->ddrInfo.ddrStructType == BOARD_DDR_FIELD_TYPE)\r
+    {\r
+        offsetAddress = offsetAddress + i2cTransaction.writeCount;\r
+        i2cTransaction.writeCount = info->ddrInfo.ddrStructLen +\r
+                                     BOARD_EEPROM_TYPE_SIZE +\r
+                                     BOARD_EEPROM_STRUCT_LENGTH_SIZE +\r
+                                     offsetSize;\r
+        txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+        txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+        memcpy(&txBuf[2], &info->ddrInfo, i2cTransaction.writeCount);\r
+\r
+        status = I2C_transfer(handle, &i2cTransaction);\r
+        if (status == false)\r
+        {\r
+            ret = BOARD_I2C_TRANSFER_FAIL;\r
+            Board_i2cDeInit();\r
+            return ret;\r
+        }\r
+    }\r
+\r
+    /* Checking whether MAC id field is included or not */\r
+    if (info->macInfo.macStructType == BOARD_MACINFO_FIELD_TYPE)\r
+    {\r
+        offsetAddress = offsetAddress + i2cTransaction.writeCount;\r
+        i2cTransaction.writeCount = info->macInfo.macLength +\r
+                                     BOARD_EEPROM_TYPE_SIZE +\r
+                                     BOARD_EEPROM_STRUCT_LENGTH_SIZE +\r
+                                     offsetSize;\r
+        txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress) >> 8);\r
+        txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+        memcpy(&txBuf[2], &info->macInfo, i2cTransaction.writeCount);\r
+\r
+        status = I2C_transfer(handle, &i2cTransaction);\r
+        if (status == false)\r
+        {\r
+            ret = BOARD_I2C_TRANSFER_FAIL;\r
+            Board_i2cDeInit();\r
+            return ret;\r
+        }\r
+    }\r
+\r
+    offsetAddress = offsetAddress + i2cTransaction.writeCount;\r
+    i2cTransaction.writeCount = BOARD_EEPROM_TYPE_SIZE + offsetSize;\r
+    txBuf[0] = (char)(((uint32_t) 0xFF00 & offsetAddress)>>8);\r
+    txBuf[1] = (char)((uint32_t) 0xFF & offsetAddress);\r
+    memcpy(&txBuf[2], &info->endList, i2cTransaction.writeCount);\r
+\r
+    status = I2C_transfer(handle, &i2cTransaction);\r
+    if (status == false)\r
+    {\r
+        ret = BOARD_I2C_TRANSFER_FAIL;\r
+        Board_i2cDeInit();\r
+        return ret;\r
+    }\r
+\r
+    Board_i2cDeInit();\r
+    return ret;\r
 }\r