This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] AM2634: Integration of PHY driver on custom board

Part Number: AM2634

Hi experts,

Can you guide me on how to add PHY drivers on my custom board?

  • Hi,

    The AM263x has the DP83869HMRGZT and DP83826ERHBT PHYs on-board. To make the process easy to understand, lets integrate DP83TC812 PHY on a custom board based on the AM263x. The following guide is verified on MCU_PLUS_SDK v09.01 with syscfg v1.18 and CCS v12.5

    Adding PHY drivers on a custom board can be divided into 2 parts:

    1. Integration of the PHY driver
    2. Custom board config for the PHY driver

    1. Integration of the PHY driver

    The first step is to get the Header (.h) and C (.c) files for the PHY driver. Incase you are using a TI PHY, you can find some RTOS and linux drivers at: https://github.com/TexasInstruments/ti-ethernet-software/blob/main/README.md. If you don't find the required driver here, please raise an E2E for the same and TI experts will guide you.

    To integrate your PHY driver follow the steps below:

    1. Add the public header file to the following path: C:\ti\mcu_plus_sdk\source\networking\enet\core\incldue\phy.
    2. Add the private header file and the C file to the following path:  C:\ti\mcu_plus_sdk\source\networking\enet\core\src\phy.
    3. In the dp83tc812.c file, fix the include files paths to point to the correct files according to the MCU_PLUS_SDK/source/networking/enet directory structure. 
    4. In the PHY driver file, define a structure of type EnetPhy_Drv. This structure holds the details of the PHY, details of the supported functions, register details and function pointers for the PHY. 
    5. In this structure, if device specific implementations are not needed, use the Generic PHY driver functions. The generic PHY driver can be found at: C:\ti\mcu_plus_sdk\source\networking\enet\core\src\phy\generic_phy.c
    6. In the makefile at: C:\ti\workarea\mcu_plus_sdk\source\networking\enet\makefile.cpsw.am263x.r5f.ti-arm-clangadd the dp83tc812.c file in the FILES_common array.
    7. Rebuild the enet cpsw library using the following command: 

      # TO CLEAN
      gmake -s -f makefile.am263x enet-cpsw_r5f.ti-arm-clang_clean
       
      # TO BUILD
      gmake -s -f makefile.am263x enet-cpsw_r5f.ti-arm-clang

      Now the PHY driver for DP83TC812 has been integrated in the enet library to work with CPSW. Please note that not all the features of the PHY are supported.

    2. Custom board config for the PHY driver

    1. In your application, open the syscfg, go to enet (CPSW) →Board config → Enable custom board.

      This will disable the auto-generation of the generic configuration and custom PHY driver can be used.
    2. You will have to write a 'C' file  that is specific to the board. You can refer the following example file from the SDK : C:\ti\mcu_plus_sdk\examples\networking\enet_layer2_multi_channel\am263x-cc\r5fss0-0_freertos\enet_custom_board_config.c
    3. In this C file, include the header file for the PHY driver which was step 1 in point 1.
    4. In this C file, Extern the EnetPhy_Drv which is defined in the above driver files. 
    5. Define a Cfg struct (DP83tc812_Cfg in this case) for the PHY driver. (refer the phy driver include file for the structure)

    6. Modify the EnetBoard_PortCfg to point to the correct .extendedCfg and .extendedCfgSize for the required ports.
    7. Reference code for points 3-6 is shown below
      #include <networking/enet/core/include/phy/dp83tc812.h>
       
      /* PHY drivers */
      extern EnetPhy_Drv gEnetPhyDrvGeneric;
      extern EnetPhy_Drv gEnetPhyDrvDp83tc812;
       
      /*! \brief All the registered PHY specific drivers. */
      static const EnetPhyDrv_Handle gEnetPhyDrvs[] =
      {
          &gEnetPhyDrvDp83tc812,
          &gEnetPhyDrvGeneric,   /* Generic PHY - must be last */
      };
       
      /* Create a config struct for the PHY */
      /*!
       * \brief Common Processor Board (CPB) board's DP83tc812 PHY configuration.
       */
      static const Dp83tc812_Cfg gEnetCpbBoard_dp83tc812PhyCfg =
      {
          .txClkShiftEn = true,
          .rxClkShiftEn = true,
          .interruptEn = false,
          .sgmiiAutoNegEn = true,
          .MasterSlaveMode = DP83TC812_MASTER_SLAVE_STRAP,
      };
       
      /*
       * AM263x board configuration.
       *
       * 1 x RGMII PHY connected to AM263x CPSW_3G MAC port.
       */
      static const EnetBoard_PortCfg gEnetCpbBoard_am263xEthPort[] =
      {
          {    /* "CPSW3G" */
              .enetType = ENET_CPSW_3G,
              .instId   = 0U,
              .macPort  = ENET_MAC_PORT_1,
              .mii      = { ENET_MAC_LAYER_GMII, ENET_MAC_SUBLAYER_REDUCED },
              .phyCfg   =
              {
                  .phyAddr         = 0,
                  .isStrapped      = false,
                  .skipExtendedCfg = false,
                  .extendedCfg     = &gEnetCpbBoard_dp83tc812PhyCfg,
                  .extendedCfgSize = sizeof(gEnetCpbBoard_dp83tc812PhyCfg),
              },
              .flags    = 0U,
          },
          {    /* "CPSW3G" */
              .enetType = ENET_CPSW_3G,
              .instId   = 0U,
              .macPort  = ENET_MAC_PORT_2,
              .mii      = { ENET_MAC_LAYER_GMII, ENET_MAC_SUBLAYER_REDUCED },
              .phyCfg   =
              {
                  .phyAddr         = 3,
                  .isStrapped      = false,
                  .skipExtendedCfg = false,
                  .extendedCfg     = &gEnetCpbBoard_dp83tc812PhyCfg,
                  .extendedCfgSize = sizeof(gEnetCpbBoard_dp83tc812PhyCfg),
              },
              .flags    = 0U,
          },
      };

      Now compile your application with this custom board config file.

    Regards,
    Shaunak