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

Cross-TU shared surface for the ra8_eth driver split. More...

#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_eth.h"
#include "ra8_rmac.h"
Include dependency graph for ra8_eth_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_eth_state_t
 Driver-private NIC state. More...

Enumerations

enum  ra8_eth_phy_t : uint16_t {
  k_ra8_eth_phy_addr_default = 0U ,
  k_ra8_eth_phy_reg_bmcr = 0U ,
  k_ra8_eth_phy_reg_bmsr = 1U ,
  k_ra8_eth_phy_reg_anlpar = 5U ,
  k_ra8_eth_phy_reg_gbsr = 10U ,
  k_ra8_eth_phy_bmsr_link_up = 0x0004U ,
  k_ra8_eth_phy_bmsr_an_done = 0x0020U ,
  k_ra8_eth_phy_bmcr_speed100 = 0x2000U ,
  k_ra8_eth_phy_bmcr_speed1000 = 0x0040U ,
  k_ra8_eth_phy_bmcr_duplex = 0x0100U ,
  k_ra8_eth_phy_anlpar_10h = 0x0020U ,
  k_ra8_eth_phy_anlpar_10f = 0x0040U ,
  k_ra8_eth_phy_anlpar_100h = 0x0080U ,
  k_ra8_eth_phy_anlpar_100f = 0x0100U ,
  k_ra8_eth_phy_gbsr_1000h = 0x0400U ,
  k_ra8_eth_phy_gbsr_1000f = 0x0800U ,
  k_ra8_eth_phy_speed_10 = 10U ,
  k_ra8_eth_phy_speed_100 = 100U ,
  k_ra8_eth_phy_speed_1000 = 1000U
}
 PHY-side MIIM constants shared by both ra8_eth TUs: the ra8_eth.c open path checks PHY readiness and ra8_eth_link.c polls link status. More...

Functions

ra8_rmac_port_t priv_ra8_eth_channel_to_port (uint8_t channel)
 Map a logical channel index to an RMAC port identifier.

Variables

volatile uint16_t g_ra8_eth_phy_bmsr_after_wait
 BMSR snapshot AFTER the auto-neg wait.
ra8_eth_state_t s_eth_state
 Singleton NIC runtime state.
bool g_eth_mac_speed_resynced
 Latch – true once ra8_eth_link_status has re-programmed MPIC.LSC / MPIC.PIPP to match the PHY's negotiated link.

Detailed Description

Cross-TU shared surface for the ra8_eth driver split.

Tag
[Ring 3 / HAL] {World: NS}

The ra8_eth driver is split across two translation units to stay under the per-file line-count cap: ra8_eth.c holds the ESWM block, the GWCA-backed NIC frame path (open / close / write / read / get_stats), and the test-inject hook; ra8_eth_link.c holds the PHY link-status poller plus the MAC speed/duplex resync that realigns MPIC with the PHY's auto-negotiation result. This src/-local header carries the handful of symbols both TUs share: the singleton NIC runtime state, the one-shot MAC-resync latch, and the channel-to-port mapping predicate. It is NOT part of the public ABI.

Definition in file ra8_eth_internal.h.

Enumeration Type Documentation

◆ ra8_eth_phy_t

enum ra8_eth_phy_t : uint16_t

PHY-side MIIM constants shared by both ra8_eth TUs: the ra8_eth.c open path checks PHY readiness and ra8_eth_link.c polls link status.

Enumerator
k_ra8_eth_phy_addr_default 

EK-RA8D2 PHY MDC address.

k_ra8_eth_phy_reg_bmcr 

BMCR (basic mode control).

k_ra8_eth_phy_reg_bmsr 

BMSR (basic mode status).

k_ra8_eth_phy_reg_anlpar 

ANLPAR (10/100 link partner).

k_ra8_eth_phy_reg_gbsr 

GBSR (1G link-partner ability).

k_ra8_eth_phy_bmsr_link_up 

BMSR.LINK_STATUS bit 2.

k_ra8_eth_phy_bmsr_an_done 

BMSR.AUTONEG_COMPLETE bit 5.

k_ra8_eth_phy_bmcr_speed100 

BMCR.SPEED_SELECT bit 13.

k_ra8_eth_phy_bmcr_speed1000 

BMCR.SPEED_MS bit 6 (1Gb).

k_ra8_eth_phy_bmcr_duplex 

BMCR.DUPLEX_MODE bit 8.

k_ra8_eth_phy_anlpar_10h 

ANLPAR bit 5: 10BASE-T.

k_ra8_eth_phy_anlpar_10f 

ANLPAR bit 6: 10BASE-T FD.

k_ra8_eth_phy_anlpar_100h 

ANLPAR bit 7: 100BASE-TX.

k_ra8_eth_phy_anlpar_100f 

ANLPAR bit 8: 100BASE-TX FD.

k_ra8_eth_phy_gbsr_1000h 

GBSR bit 10: 1000BASE-T HD.

k_ra8_eth_phy_gbsr_1000f 

GBSR bit 11: 1000BASE-T FD.

k_ra8_eth_phy_speed_10 

10 Mbps.

k_ra8_eth_phy_speed_100 

100 Mbps.

k_ra8_eth_phy_speed_1000 

1 Gbps.

Definition at line 41 of file ra8_eth_internal.h.

Function Documentation

◆ priv_ra8_eth_channel_to_port()

ra8_rmac_port_t priv_ra8_eth_channel_to_port ( uint8_t channel)

Map a logical channel index to an RMAC port identifier.

Shared mapping used by both ra8_eth translation units: the NIC frame path (ra8_eth.c) selects the RMAC port for teardown, and the link-status TU (ra8_eth_link.c) selects the port whose PHY it polls. Pure; no side effects.

Parameters
[in]channelChannel id from ra8_eth_cfg_t (0 or 1).
Returns
Matching ra8_rmac_port_t.
Return values
k_ra8_rmac_port_0channel == 0.
k_ra8_rmac_port_1channel != 0.
Precondition
channel was already range-checked by the caller.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
No global state is mutated.
Note
Thread safety: pure function, safe from any context.
Since
0.1.0

Definition at line 347 of file ra8_eth.c.

References k_ra8_rmac_port_0, and k_ra8_rmac_port_1.

Referenced by internal_bring_up_rmac(), ra8_eth_close(), and ra8_eth_link_status().

Variable Documentation

◆ g_eth_mac_speed_resynced

bool g_eth_mac_speed_resynced
extern

Latch – true once ra8_eth_link_status has re-programmed MPIC.LSC / MPIC.PIPP to match the PHY's negotiated link.

Reset to false in ra8_eth_open / ra8_eth_close. The MAC speed resync only needs to fire once per link bring-up; further calls to ra8_eth_link_status skip the MPIC write so they remain read-only status pollers. Defined here and updated from ra8_eth_link.c via ra8_eth_internal.h.

Note
File-scope state, not thread-safe.
Since
0.1.0

Reset to false in ra8_eth_open / ra8_eth_close. The MAC speed resync only needs to fire once per link bring-up; further calls to ra8_eth_link_status skip the MPIC write so they remain read-only status pollers. Defined once in ra8_eth.c and updated from ra8_eth_link.c via this declaration.

Warning
File-scope state, not thread-safe.
Since
0.1.0

Definition at line 294 of file ra8_eth.c.

Referenced by internal_resync_mac_speed(), ra8_eth_close(), ra8_eth_link_status(), and ra8_eth_open().

◆ g_ra8_eth_phy_bmsr_after_wait

volatile uint16_t g_ra8_eth_phy_bmsr_after_wait
extern

BMSR snapshot AFTER the auto-neg wait.

BMSR snapshot AFTER the internal_wait_for_autoneg poll.

Defined once in ra8_eth_link.c; referenced from ra8_eth.c via this declaration.

Note
Read externally by J-Link only; firmware never reads back.
Since
0.1.0
Note
Read externally by J-Link only; firmware never reads back.
Since
0.1.0

Definition at line 58 of file ra8_eth_link.c.

Referenced by internal_wait_for_autoneg().

◆ s_eth_state

ra8_eth_state_t s_eth_state
extern

Singleton NIC runtime state.

Defined here and shared with the split-out link-status TU (ra8_eth_link.c) via ra8_eth_internal.h.

Note
File-scope, not thread-safe.
Since
0.1.0

Defined once in ra8_eth.c and referenced from the split-out link-status TU (ra8_eth_link.c) via this declaration. Holds the cached configuration, the cumulative software counters, and the "open" flag.

Warning
Not safe to mutate outside the ra8_eth driver path.
Since
0.1.0

Definition at line 277 of file ra8_eth.c.

Referenced by internal_capture_state(), ra8_eth_close(), ra8_eth_get_stats(), ra8_eth_link_status(), ra8_eth_read(), and ra8_eth_write().