ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_eth_media.c File Reference

ESWM media mux: select a port's MII/RGMII mode and release its block. More...

#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_eth.h"
#include "ra8_ether_regs.h"
#include "ra8_log.h"
Include dependency graph for ra8_eth_media.c:

Go to the source code of this file.

Functions

ra8_err_t ra8_eth_rgmii_select (ra8_eth_mii_port_t port)
 Select RGMII on a port's ESWM media-interface mux and enable it.

Detailed Description

ESWM media mux: select a port's MII/RGMII mode and release its block.

Tag
[Ring 2 / HAL] {World: S}

The media half of the Ethernet HAL, kept apart from the frame-level NIC API in ra8_eth.c. Choosing how a port talks to its PHY, and taking that port's interface block out of reset, happens once during bring-up and has nothing in common with opening a NIC or moving frames – and ra8_eth.c had grown to the 1000-line cap, which the file-size policy answers by splitting a responsibility rather than by granting a waiver.

Definition in file ra8_eth_media.c.

Function Documentation

◆ ra8_eth_rgmii_select()

ra8_err_t ra8_eth_rgmii_select ( ra8_eth_mii_port_t port)
nodiscard

Select RGMII on a port's ESWM media-interface mux and enable it.

The chip-generic ESWM RGMII media-select every RA8 RGMII board runs once during Ethernet bring-up. After power-on reset MIICRm.MIISEL reads 0 (GMII/MII) and MIIRR.RGRSTm reads 0 (RGMII block held in reset), so the RGMII data path is dead until the driver explicitly:

  1. Sets MIICRm = MIISEL = RGMII (01b) | TXCIDE (on-chip TX clock delay), matching the FSP "RGMII + 2 ns TX skew" board profile.
  2. Sets MIIRR.RGRSTm = 1. HUM Ch 29.2.1.2: RGRSTm is 1 = Enable, 0 = Reset – an ENABLE bit, not an active-high reset. Without it TXC is never generated and the RMAC RX state machine is unclocked, so every RMAC RX counter stays at 0.

It previously lived open-coded in the EK-RA8D2 board Ethernet bring-up; the accesses are chip-generic, so they belong here in the HAL. Which port is wired, and any board TX/RX skew choices in the PHY, remain board concerns.

Parameters
[in]portESWM media-interface port to route to RGMII. Must be a valid ra8_eth_mii_port_t (< k_ra8_eth_mii_port_count).
Returns
ra8_err_t Result code.
Return values
k_ra8_okPort routed to RGMII and its block enabled.
k_ra8_err_invalid_argport is out of range.
Precondition
The ESWM module-stop gate (k_ra8_mstp_eswm) has been released.
COMA has been brought up (ra8_eth_coma_bringup) so the media window is accessible.
Postcondition
On success MIICRport = TXCIDE | RGMII and MIIRR.RGRSTport = 1.
On k_ra8_err_invalid_arg no register was written.
Note
Not thread-safe; call from a single-threaded init context.
eth is HW-blocked on silicon (issue #21); this path is host-tested and sim-modeled, not hardware-validated.
Example:
(void)ra8_eth_rgmii_select(k_ra8_eth_mii_port_1); // EK-RA8D2 RJ45 = port 1
@ k_ra8_eth_mii_port_1
ESWM media port 1 (RMAC1 / ETHA1).
Definition ra8_eth.h:139
ra8_err_t ra8_eth_rgmii_select(ra8_eth_mii_port_t port)
Select RGMII on a port's ESWM media-interface mux and enable it.
ra8_err_t ra8_eth_coma_bringup(void)
Bring the COMA switch out of reset, init the buffer pool, and fan every per-agent clock out.
See also
ra8_eth_coma_bringup
Since
0.1.0

Log tag – block scope: this is the only function here that logs.

Definition at line 26 of file ra8_eth_media.c.

References k_ra8_err_invalid_arg, k_ra8_eswm_miicr_miisel_rgmii, k_ra8_eswm_miicr_txcide, k_ra8_eswm_miirr_rgrst0, k_ra8_eswm_miirr_rgrst1, k_ra8_eth_mii_port_0, k_ra8_eth_mii_port_1, k_ra8_ok, RA8_CHECK_RANGE_TAG, ra8_eswm_miicr0(), ra8_eswm_miicr1(), ra8_eswm_miirr(), and ra8_log_info.

Referenced by ehb_run_once(), and ra8_board_ethernet_init().