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

Cross-translation-unit seam for the EK-RA8D2 BSP implementation. More...

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

Go to the source code of this file.

Enumerations

enum  panel_pll_const_t : uint16_t {
  k_panel_pclka_mhz = 60U ,
  k_panel_pll_nmul = 48U
}
 MIPI panel PLL bring-up constants (pending datasheet confirm). More...

Functions

bool priv_ra8_board_uart_console_is_up (void)
 Report whether ra8_board_uart_console_init has succeeded.
ra8_err_t priv_ra8_board_eth_eswm_bring_up (uint32_t *out_eswclk_hz)
 Bring up the Ethernet clock, power, MSTP, and COMA boundary.
ra8_err_t priv_ra8_board_eth_etha_to_config (void)
 Walk the board Ethernet ETHA from RESET to CONFIG.

Detailed Description

Cross-translation-unit seam for the EK-RA8D2 BSP implementation.

Tag
[Ring 5 / BSP] {World: S}

The EK-RA8D2 board-support implementation is split across several translation units (ra8_board_ek_ra8d2*.c) that share one library. This header carries the only declarations that must be visible to more than one of those units: the MIPI/MIPI-DSI panel PLL constant block, which is authored alongside the Octo-SPI bring-up in the primary unit but consumed by the MIPI panel bring-up in a sibling unit, and the console readiness predicate the stream binding needs. Keeping them here keeps a single source-of-truth and avoids an "undeclared identifier" break if either unit moves.

Since
0.1.0

Definition in file ra8_board_ek_ra8d2_internal.h.

Enumeration Type Documentation

◆ panel_pll_const_t

enum panel_pll_const_t : uint16_t

MIPI panel PLL bring-up constants (pending datasheet confirm).

These two coefficients seed the D-PHY PLL solve in the MIPI panel bring-up path. k_panel_pclka_mhz assumes the chip's CGC reset default and k_panel_pll_nmul is the integer multiplier the placeholder 480 Mbps/lane target lands on. They live in this shared header because they are authored next to the Octo-SPI reset timings in the primary unit yet referenced from the MIPI panel config in a sibling unit.

Invariant
Values are placeholders until the panel datasheet is confirmed; both are interim self-consistent constants.
See also
s_mipi_phy_cfg
Since
0.1.0
Enumerator
k_panel_pclka_mhz 

PCLKA assumed CGC reset default.

k_panel_pll_nmul 

PLL integer multiplier.

Definition at line 50 of file ra8_board_ek_ra8d2_internal.h.

Function Documentation

◆ priv_ra8_board_eth_eswm_bring_up()

ra8_err_t priv_ra8_board_eth_eswm_bring_up ( uint32_t * out_eswclk_hz)

Bring up the Ethernet clock, power, MSTP, and COMA boundary.

Initializes ESWCLK and ESWPHYCLK, powers the ESWM domain, and publishes the live ESWCLK frequency. It then acquires the ESWM module-stop reference and runs the COMA reset, buffer-pool readiness poll, and agent clock fan-out. These steps implement the prerequisites described by HUM Ch 9.10.23 "EtherSW Clock (ESWCLK)" p 405 and Ch 31 "Ethernet Common Agent (COMA)" p 1590.

Parameters
[out]out_eswclk_hzPublished ESWCLK frequency on success.
Returns
The first CGC, MSTP, or COMA result.
Return values
k_ra8_okClock, power, module-stop, and COMA bring-up completed.
k_ra8_err_null_ptrout_eswclk_hz is nullptr.
k_ra8_err_invalid_stateAn Ethernet module-stop reference count is saturated.
k_ra8_err_hw_timeoutA clock, module-stop, or COMA readiness poll timed out.
Precondition
Fake MMIO and module-stop state are initialized.
out_eswclk_hz points to writable storage.
Postcondition
Success publishes the configured ESWCLK frequency.
Failure stops before later Ethernet stages.
Note
Library-private; host tests call this production boundary directly to exercise sequential error propagation.
Since
0.1.0

Bring up the Ethernet clock, power, MSTP, and COMA boundary.

Factored out of ra8_board_ethernet_init to keep that function under the project's NASA Rule 4 / clang-tidy function-size threshold. Runs the four upstream gates the RMAC / ETHA register windows hang off: ESWCLK / ESWPHYCLK, PDCTRESWM power-on, MSTPC30 (ESWM) MSTP release, MSTPC28 (ETHPHYCLK) MSTP release, and finally the chip-generic COMA RRC/RCEC/CABPIRM bring-up via ra8_eth_coma_bringup. out_eswclk_hz receives the live ESWCLK frequency so the caller can plumb it into ra8_rmac_config_t.

Parameters
[out]out_eswclk_hzLive ESWCLK frequency in Hz on success.
Returns
Error code from the underlying CGC / MSTP / COMA paths.
Return values
k_ra8_okBring-up sequence completed.
k_ra8_err_hw_timeoutSub-step (eswclk, MSTP) timed out.
Precondition
out_eswclk_hz is a valid 32-bit pointer.
Single-threaded init context.
Postcondition
On k_ra8_ok, ESWM is fully clocked + COMA is out of reset.
*out_eswclk_hz holds the live ESWCLK frequency.
Note
Not thread-safe.
Since
0.1.0

Definition at line 265 of file ra8_board_ek_ra8d2_ethernet.c.

References k_ra8_mstp_eswm, k_ra8_ok, ra8_cgc_eswclk_hz(), ra8_cgc_eswclk_init(), ra8_eth_coma_bringup(), ra8_mstp_enable(), and RA8_PRIV.

Referenced by ra8_board_ethernet_init().

◆ priv_ra8_board_eth_etha_to_config()

ra8_err_t priv_ra8_board_eth_etha_to_config ( void )

Walk the board Ethernet ETHA from RESET to CONFIG.

Initializes ETHA1 in RESET with all error interrupts masked, then requests the ordered RESET-to-DISABLE-to-CONFIG transitions. Each transition polls EAMS until it reflects the EAMC request, as specified by HUM Ch 32.3.1.1 "EAMC : Mode Configuration Register" p 1630 and Ch 32.3.1.2 "EAMS : Mode Status Register" p 1631.

Returns
The first ETHA initialization or mode-transition result.
Return values
k_ra8_okETHA1 reached CONFIG mode.
k_ra8_err_invalid_stateThe ESWM module-stop reference count is saturated.
k_ra8_err_hw_timeoutThe ESWM release or an ETHA mode transition timed out.
Precondition
Fake MMIO and module-stop state are initialized.
The ESWM module-stop reference may be acquired by this call.
Postcondition
Success leaves ETHA1 in CONFIG.
Failure is propagated before later board initialization.
Note
Library-private; host tests call this production boundary directly to exercise sequential error propagation.
Since
0.1.0

Walk the board Ethernet ETHA from RESET to CONFIG.

Per FSP r_rmac_phy_open, RMAC.MPIC is only writable while the paired ETHA is in CONFIG mode (writes are silently dropped in other modes). This helper drives ETHA into CONFIG so ra8_rmac_init can land the MPIC programming; internal_eth_etha_to_operation flips to OPERATION afterwards so MDIO traffic can start.

Returns
k_ra8_ok on success; otherwise propagates ra8_etha_set_mode.
Return values
k_ra8_okWalked to CONFIG.
k_ra8_err_invalid_argra8_etha_set_mode rejected an argument.
Precondition
priv_ra8_board_eth_eswm_bring_up has succeeded.
Single-threaded init context.
Postcondition
ETHA1 EAMC reflects CONFIG; busy-wait between writes mirrors FSP r_rmac_phy_set_operation_mode.
EAMS.OPS == CONFIG (best-effort; FSP does not poll either).
Note
Not thread-safe.
Since
0.1.0

Definition at line 307 of file ra8_board_ek_ra8d2_ethernet.c.

References k_ra8_board_eth_etha_port, k_ra8_board_eth_etha_step_iters, k_ra8_etha_opc_config, k_ra8_etha_opc_disable, k_ra8_etha_opc_reset, k_ra8_ok, ra8_etha_init(), ra8_etha_set_mode(), and RA8_PRIV.

Referenced by ra8_board_ethernet_init().

◆ priv_ra8_board_uart_console_is_up()

bool priv_ra8_board_uart_console_is_up ( void )
nodiscard

Report whether ra8_board_uart_console_init has succeeded.

The console's "is it up" flag is private to the comms translation unit – the write / read / flush entry points there consult it directly. The stream binding in a sibling unit needs the same answer before it hands an ra8_io_stream_t to an application, so the flag is published as a predicate rather than as a mutable extern: a caller can ask, and cannot lie about it.

Library-private (RA8_PRIV): production code outside libs/ra8_board_ek_ra8d2 must use the public console API, which enforces the same state itself.

Returns
bool Console readiness.
Return values
truera8_board_uart_console_init returned k_ra8_ok at least once, so SCI8 is configured and PD02 / PD03 are routed.
falseThe console has never come up; nothing may be written to it.
Precondition
The BSP comms translation unit is linked into the image.
Called from a single-threaded application or boot context.
Postcondition
No board, pin or peripheral state is modified.
The returned value reflects the flag at the moment of the call.
Note
Not thread-safe against a concurrent ra8_board_uart_console_init.
See also
ra8_board_uart_console_init The call that sets the flag.
Since
0.1.0

Report whether ra8_board_uart_console_init has succeeded.

Definition at line 343 of file ra8_board_ek_ra8d2_comms.c.

References RA8_PRIV, and s_uart_console_initialized.

Referenced by ra8_board_console_stream().