ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_eth_media.c
Go to the documentation of this file.
1
19
20#include "ra8_check.h"
21#include "ra8_err.h"
22#include "ra8_eth.h"
23#include "ra8_ether_regs.h"
24#include "ra8_log.h"
25
27{
29 static const char* const local_eth_media_tag = "ETH";
30
31 RA8_CHECK_RANGE_TAG((uint32_t)port,
32 0U,
33 (uint32_t)k_ra8_eth_mii_port_1,
35 local_eth_media_tag);
36
37 /* Port m -> MIICRm control register + MIIRR.RGRSTm enable bit. */
38 volatile uint32_t* miicr = (port == k_ra8_eth_mii_port_0) ? ra8_eswm_miicr0() : ra8_eswm_miicr1();
39 const uint32_t rgrst = (port == k_ra8_eth_mii_port_0) ? (uint32_t)k_ra8_eswm_miirr_rgrst0
40 : (uint32_t)k_ra8_eswm_miirr_rgrst1;
41
42 /* Write MIICR before enabling the per-port RGMII block so the pin mux is
43 * in the correct mode the instant the data pins go live. */
44 /* HUM Ch 29 "Layer 3 Ethernet Switch Module (ESWM)" p 1287 */
45 *miicr = (uint32_t)k_ra8_eswm_miicr_txcide | (uint32_t)k_ra8_eswm_miicr_miisel_rgmii;
46
47 /* HUM Ch 29.2.1.2 "MIIRR : Media-independent Interface Reset Register"
48 * p 1289: RGRSTm is 0 = Reset, 1 = Enable -- set it to bring the RGMII
49 * block out of reset so TXC is generated and the RMAC RX state machine is
50 * clocked. */
51 /* HUM Ch 29.2.1.2 "MIIRR : Media-independent Interface Reset Register" p 1289 */
52 uint32_t miirr = *ra8_eswm_miirr();
53 miirr |= rgrst;
54 /* HUM Ch 29.2.1.2 "MIIRR : Media-independent Interface Reset Register" p 1289 */
55 *ra8_eswm_miirr() = miirr;
56
57 ra8_log_info(local_eth_media_tag, "rgmii_select");
58 return k_ra8_ok;
59}
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_RANGE_TAG(value, min, max, errcode, tag)
Tagged range check (adds a component tag to the log line).
Definition ra8_check.h:311
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Ethernet Switch Module (ESWM) + frame TX/RX driver.
ra8_eth_mii_port_t
ESWM media-interface port selector (m = 0, 1).
Definition ra8_eth.h:137
@ k_ra8_eth_mii_port_0
ESWM media port 0 (RMAC0 / ETHA0).
Definition ra8_eth.h:138
@ 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.
Ethernet controller base addresses for the Renesas RA8D2.
static volatile uint32_t * ra8_eswm_miicr1(void)
Get pointer to ESWM.MIICR1 (32-bit, RMAC port 1).
static volatile uint32_t * ra8_eswm_miicr0(void)
Get pointer to ESWM.MIICR0 (32-bit, RMAC port 0).
@ k_ra8_eswm_miirr_rgrst0
RGMII0 enable (1 = enable, 0 = reset).
@ k_ra8_eswm_miirr_rgrst1
RGMII1 enable (1 = enable, 0 = reset).
static volatile uint32_t * ra8_eswm_miirr(void)
Get pointer to ESWM.MIIRR (32-bit).
@ k_ra8_eswm_miicr_miisel_rgmii
MIISEL = RGMII.
@ k_ra8_eswm_miicr_txcide
TXCIDE – TXC internal delay.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
Definition ra8_log.h:364