Ethernet Firmware
|
The default implementation of Ethernet Firmware provided in this software package enables CPSW switch support on TI EVMs, currently supporting J721E, J7200 and J784S4 TI EVMs. So Ethernet Firmware's default implementation is board specific, and porting is required when enabling a new platform.
The main porting steps will be explained throughout this document, and they can be summarized into three distintive operations: board initialization, MAC address pool initialization and MAC port and PHY configuration.
This is a big category that encompasses any board level initialization outside of CPSW peripheral, either internal or external to the Jacinto 7 SoC. Ethernet Firmware configures CPSW peripheral using Enet LLD.
The configuration steps described in the following sections is not an exhaustive list, but rather the ones most commonly used.
The MII interface type is configurable per Ethernet port: RMII, RGMII, SGMII, QSGMII, etc. The supported interface types is SoC dependent, please refer to the TRM to find out which MII interface types are supported in a given SoC.
The interface type is configured Control Module's CTRLMMR_ENET<n>_CTRL
register, where <n>
is the port number. Note that the RGMII internal transmit delay is also configured in the same register.
For TI EVMs, the Ethernet port interface type is configured via PDK board library using BOARD_INIT_ENETCTRL_CPSW9G
init flag, as follows:
Alternatively, MII interface type could also be configured by bootloader.
The SoC modules (such as CPSW, SerDes, UART, Timers) which are needed by Ethernet Firmware need to be explicitly turned on via sciclient before using them. Note that some of these modules might have already been turned on by the bootloader, so this step could be skipped for such modules.
The code snippet below shows the SerDes module being turned on:
This sciclient API can be used for other modules as well, passing the appropriate moduleId
. Please refer to the Sciclient PM API Interface documentation in the PDK API Guide for further information.
EnetAppUtils_setDeviceState()
helper function provided as part of Enet LLD apputils can also be used to turn on and reset modules. Note that this helper function asserts that the sciclient calls return no errors.
The bootloader will initialize a set of base pins needed for its initial operation, but may not necessarily configure all pins required for Ethernet. Those pins have to be explicitly setup by Ethernet Firmware RTOS app.
It's highly recommended to use TI's SYSCONFIG tool for pinmux configuration. SYSCONFIG can generate a C file output with the requested pinmux settings. The settings in this file can be directly passed to Board_pinmuxUpdate()
, which is PDK board library's API used to update the mux configuration of a set of pins:
It's recommended that pinmux settings done in this step is limited to the pins used for Ethernet related functionality in order to avoid overwriting the pinmux settings done by others (i.e. bootloader, other processing cores).
During the initialization stage of Ethernet Firmware, the Ethernet ports are opened, which triggers a PHY state machine in Enet LLD that takes care of configuring the Ethernet PHYs via MDIO. However, this excludes any board level setting, such as taking the PHY out of reset.
Often times PHYs are taken out of reset at board level at power-on reset (POR). When not, explicit action must taken - usually by driving a GPIO line. This can be done by bootloader or at this stage in Ethernet Firmware's board init.
SerDes has to be configured in advance for the Ethernet ports in Q/SGMII mode. For multi-link case, where lanes of the same SerDes are configured for different functionality (i.e. Ethernet, PCIe, USB), this is typically done by the bootloader. In single-link or when all lanes are for Ethernet related functionality, the bootloader may not configure SerDes and Ethernet Firmware must do it via CSL Serdes.
The SerDes reference clock(s) rate must be set consistently with the clock requirement of the intended SerDes function as indicated via refClk
argument of CSL_serdesRefclkSel()
function.
The code snippet below shows how the SerDes reference clocks are being configured to 100MHz for J721E SerDes used for Q/SGMII operation. It's worth noting that the clock rate set in params.refClock
and PMLIBClkRateSet()
are consistently set to 100MHz.
Alternatively, user may choose to use Enet LLD's EnetAppUtils_clkRateSet()
helper function to set the clocks. This is a simple wrapper on top of PDK PM library APIs.
SerDes module configuration is done using CSL SerDes APIs. For TI EVM support, PDK Board library provides helper functions, such as Board_serdesCfgSgmii()
and Board_serdesCfgQsgmii()
to configure SerDes according to TI EVM capabilities. Ethernet Firmware uses these helper functions. Users may choose to implement their own SerDes configuration functions using CSL.
The CSL SerDes library support can be found at the following locations:
<pdk>/packages/ti/csl/src/ip/serdes_cd/V0
<pdk>/packages/ti/csl/src/ip/serdes_cd/V1
<pdk>/packages/ti/csl/src/ip/serdes_cd/V2
<pdk>/packages/ti/csl/ src/ip/serdes_cd/V3
Similar to any other SoC module, CPSW clocks must be configured and the module must be explicitly turned on via Sciclient.
The following clocks must be configured for proper operation of CPSW: CPPI_CLK_CLK
, RGMII_MHZ_5_CLK
, RGMII_MHZ_CLK
, and RGMII_MHZ_250_CLK
. Optionally, when using time synchronization, CPTS source clock must also be configured, the source is selected from a list of possible sources which is SoC dependent. Please refer to TRM of the specific SoC being used.
Alternatively, user may choose to use Enet LLD's helper functions as shown below:
Ethernet Firmware requires a pool of MAC addresses to be used during its lifecycle, for its own usage and for the virtual MAC clients. A MAC address is given to each virtual client as they attach to Ethernet Firmware at runtime.
The pool size requirement is as follows:
It's worth noting that the required MAC address pool can exceed the number of physical Ethernet ports, as the pool size also depends on the number of virtual clients being enabled.
In the default implementation of Ethernet Firmware for TI EVMs, a total of 6 x MAC addresses are required for Linux and RTOS SDK releases.
Count | Owner | Core | Usage |
---|---|---|---|
1 | Ethernet Firmware | mcu2_0 | lwIP stack |
2 | Linux virtual clients | mpu1_0 | 1 x virtual switch port (eth1) |
1 x virtual MAC port (eth2) | |||
2 | RTOS virtual clients | mcu2_1 | 1 x virtual switch port (netif1) |
1 x virtual MAC port (netif2) | |||
1 | AUTOSAR virtual MAC | mcu2_1 | 1 x virtual switch port |
For QNX SDK releases, a total of 4 x MAC addresses are required as MAC-only feature is not enabled which reduces the overall count.
Count | Owner | Core | Usage |
---|---|---|---|
1 | Ethernet Firmware | mcu2_0 | lwIP stack |
1 | QNX virtual client | mpu1_0 | 1 x virtual switch port |
1 | RTOS virtual clients | mcu2_1 | 1 x virtual switch port |
1 | AUTOSAR virtual MAC | mcu2_1 | 1 x virtual switch port |
The pool of MAC addresses is usually provisioned in an EEPROM memory, so the Ethernet Firmware RTOS application must read them from that memory and populate the pool which is passed to Ethernet Firmware at open time via EthFw_Config.
The code snippet below shows the configuration parameters where the MAC address pool must be populated:
In TI Jacinto 7 EVMs, the EEPROMs in the expansion boards are flashed with a number of MAC addresses:
Note: In TI EVMs, there is a potential conflict when Ethernet Firmware tries to read EEPROM memories via I2C at the same time that another processing core (i.e. A72) is also using the same I2C bus (see ETHFW-1580). Due to this limitation, Ethernet Firmware uses a static MAC address pool for Linux/QNX SDKs as a temporary workaround. The static MAC address pool must not be used in production code.
The RTOS application passes to Ethernet Firmware the list of MAC ports intended to be used. Ethernet Firmware then enables each of them during its initialization stage when EthFw_init() is called. At that time, Ethernet Firmware will call the EthFw_Config.setPortCfg() callback for each MAC port.
It's expected that the implementation of EthFw_Config.setPortCfg() callback will:
ENETPHY_INVALID_PHYADDR
.The following code snippet shows the relevant functions and configuration parameters involved in MAC and PHY configuration:
The implementation of EthFwBoard_setPortCfg()
for TI EVMs provided in the SDK is slightly different than the one shown in the code snippet above. Instead, it's organized based on the expansion boards supported in the different TI EVMs. This is an implementation decision, so user should choose the approach that works best for their system.
Starting with SDK 8.2.1, board initialization has been moved from Enet LLD to Ethernet Firmware repository:
<pdk>/packages/ti/drv/enet/examples/utils/V1/
.<ethfw>/utils/board/
.This implementation is specific to TI EVMs (Ethernet port configuration, PHYs being used, etc), and can be used as reference when porting Ethernet Firmware to a new platform.
It has been made a separate library because it's required in two scenarios:
There EthFw board library is composed of four main board initialization functions:
Revision | Date | Author | Description ------— |
---|---|---|---|
0.1 | 25 Aug 2022 | Misael Lopez | Initial version of porting guide |