]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/mcsdk-tools.git/blobdiff - post/src/post.c
update mcsdk_tools based on platform library 00.03
[keystone-rtos/mcsdk-tools.git] / post / src / post.c
old mode 100644 (file)
new mode 100755 (executable)
index 18b56ad..417e7df
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2011-12 Texas Instruments Incorporated - http://www.ti.com
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
 #include "platform.h"
 #include "types.h"
 #include "post.h"
-#include "net.h"
-#include "cpmacdrv.h"
 #include "target.h"
-#include "qm_api.h"
-#include "cpdma_api.h"
 #include "pscapi.h"
 
+#if !(defined(_EVMC6657L_))
+  #include "net.h"
+  #include "cpmacdrv.h"
+  #include "qm_api.h"
+  #include "cpdma_api.h"
+#else
+  #include "evmc665x_phy.h"
+  #include "evmc665x_emac.h"
+#endif
+
 /* CSL EMAC include */
-#include <ti/csl/csl_cpsw.h>
-#include <ti/csl/csl_cpsgmii.h>
-#include <ti/csl/csl_cpsgmiiAux.h>
-#include <ti/csl/cslr_cpsgmii.h>
+#if !(defined(_EVMC6657L_))
+  #include <ti/csl/csl_cpsw.h>
+  #include <ti/csl/csl_cpsgmii.h>
+  #include <ti/csl/csl_cpsgmiiAux.h>
+  #include <ti/csl/cslr_cpsgmii.h>
+  #include <ti/csl/csl_mdioAux.h>
+#else
+  #include <ti/csl/csl_sgmii.h>
+  #include <ti/csl/cslr_sgmii.h>
+#endif
+
 #include <ti/csl/csl_mdio.h>
-#include <ti/csl/csl_mdioAux.h>
 
 /* BootCfg module include */
 #include <ti/csl/csl_bootcfg.h>
@@ -318,14 +330,29 @@ post_test_nor
     platform_device_close(p_device->handle);
     return test_result;
 }
+#if !(defined(_EVMC6657L_))
+  /** Number of ports in the ethernet subsystem */
+  #define         NUM_PORTS                   3u
+
+  /** Number of MAC/GMII ports in the ethernet switch */
+  #define         NUM_MAC_PORTS               2u
+
+
+#else
+  /** Number of ports in the ethernet subsystem */
+  #define         NUM_PORTS                   1u
+
+  /** Number of MAC/GMII ports in the ethernet switch */
+  #define         NUM_MAC_PORTS               1u
 
-/** Number of ports in the ethernet subsystem */
-#define         NUM_PORTS                   3u
+#endif
 
-/** Number of MAC/GMII ports in the ethernet switch */
-#define         NUM_MAC_PORTS               2u
+/*Define LoopBack Mode for C6657*/
+#define MAC_LOOPBACK                    (1 << 0)
+#define EXT_COPPER_LOOPBACK             (1 << 3)
+#define EXT_FIBER_LOOPBACK              (1 << 4)
 
-/* Define LoopBack modes */
+/* Define LoopBack modes for C6678 & C6670*/
 #define CPSW_LOOPBACK_NONE           0
 #define CPSW_LOOPBACK_INTERNAL       1
 #define CPSW_LOOPBACK_EXTERNAL       2
@@ -334,11 +361,13 @@ post_test_nor
 int32_t cpswSimTest = 1;
 int32_t cpswLpbkMode = CPSW_LOOPBACK_EXTERNAL;
 #else
+int32_t LpbkMode = EXT_COPPER_LOOPBACK;
 int32_t cpswSimTest = 0;
 int32_t cpswLpbkMode = CPSW_LOOPBACK_INTERNAL;
 #endif
 int32_t cpswEvm6678 = 0;
 
+#if !(defined(_EVMC6657L_))
 /** ============================================================================
  *   @n@b Init_SGMII
  *
@@ -433,7 +462,7 @@ int32_t Init_sgmii (uint32_t macPortNum)
         CSL_SGMII_endRxTxSoftReset (macPortNum);
 
            /* Wait for SGMII Link */
-        if (!cpswSimTest && ((cpswLpbkMode == CPSW_LOOPBACK_EXTERNAL) || (cpswLpbkMode == CPSW_LOOPBACK_NONE)))
+        if (!cpswSimTest)
         {
                do
                {
@@ -660,6 +689,7 @@ int32_t Init_Cpsw (void)
     return 0;
 }
 
+#endif
 
 /******************************************************************************
  * Function:    post_test_emac_loopback
@@ -671,25 +701,30 @@ post_test_emac_loopback
 )
 {
     uint8_t   test_buf[POST_EMAC_TEST_PKT_LENGTH+14];
+#if (defined(_EVMC6657L_))
+    SGMII_Config config;
+    uint8_t mac_address[6];
+#endif
+
+#if !(defined(_EVMC6657L_))
     uint8_t   sw_port0_mac_addr[6] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15};
     uint8_t   mac_address[6];
+    uint8_t            ret;
     NET_DRV_DEVICE nDevice;
-    uint32_t modNum;
-    int32_t  ret;
+#endif
+
 
-    /* Note that if the sgmii power enable is requested the PA must be
-     * powered up first */
-    modNum = 8;
+#if !(defined(_EVMC6657L_))
+    int modNum = 8;
     if (modNum == TARGET_PWR_ETH(x))  {
         ret = (int32_t)pscEnableModule (TARGET_PWR_PA);
         if (ret != 0)
             return (POST_TEST_RESULT_FAILED);
     }
+#endif
 
-    ret = (int32_t)pscEnableModule(modNum);
-    if (ret != 0)
-        return (POST_TEST_RESULT_FAILED);
 
+#if !(defined(_EVMC6657L_))
     Init_Cpsw();
 
     /* Queue manager configuration */
@@ -739,11 +774,40 @@ post_test_emac_loopback
     platform_delay(100);
     
     /* Receive the loopback packet */
-    if (ret = cpmac_drv_receive (&nDevice, test_buf) < 0)
+    if (ret = cpmac_drv_receive (&nDevice, test_buf) <= 0)
     {
         return POST_TEST_RESULT_FAILED;
     }
 
+#else
+    sgmii_init();
+    EMAC_init();
+    config.loopbackEn = 1;
+    SGMII_config(&config);
+
+    platform_get_macaddr(PLATFORM_MAC_TYPE_EFUSE, mac_address);
+
+    /* Set the dest MAC address to be broadcast, so that PA firmware will not filter out */
+    memset(test_buf, 0xff, 6);
+    memcpy(&test_buf[6], mac_address, 6);
+
+    /* set the payload length to 256 bytes */
+    test_buf[12] = 0x01;
+    test_buf[13] = 0x00;
+
+    if(EMAC_Send(test_buf, POST_EMAC_TEST_PKT_LENGTH+14) < 0)
+    {
+        return POST_TEST_RESULT_FAILED;
+    }
+
+    platform_delay(1000);
+
+    if(EMAC_Recv(test_buf) < 0)
+    {
+        return POST_TEST_RESULT_FAILED;
+    }
+
+#endif
     return POST_TEST_RESULT_PASSED;
 }
 
@@ -909,7 +973,7 @@ main
 (
     void
 )
-{
+ {
     platform_init_flags     init_flags;
     platform_init_config    init_config;
     POST_TEST_ID            test_id = POST_TEST_IN_PROGRESS;
@@ -919,15 +983,17 @@ main
     char                    msg[9];
     uint8_t                 mac_addr[6];
     platform_info           info;
+#if !(defined(_EVMC6657L_)||defined(_EVMC6655L_))
     uint32_t                sa_enable;
+#endif
     uint32_t                acc_fail;
-    uint32_t platform_init_return_code = 0;
+    extern uint32_t platform_init_return_code;
 
     /* Turn on all the platform initialize flags */
     memset(&init_config, 0, sizeof(platform_init_config));
     memset(&init_flags, 0x01, sizeof(platform_init_flags));
 
-    init_flags.phy = 0;
+    init_flags.phy = 1;
     acc_fail = 0;
 
     /* Initialize the platform */
@@ -994,7 +1060,7 @@ main
             msg[3] = 0;
             post_write_uart(msg);
         }
-
+#if !(defined(_EVMC6657L_)||defined(_EVMC6655L_))
         sa_enable = *(volatile uint32_t *)0x20c0004;
         sa_enable &= 0x1;
 
@@ -1006,6 +1072,7 @@ main
         {
             post_write_uart("\r\n\rSA is disabled on this board.");
         }
+#endif
         /* Read the PLL Reset Type Status register and display on UART */
         reset_type = PLL_CTRL_REG_RSTYPE;
         post_hex_to_string(reset_type, 8, msg);