40static const char*
s_tag =
"MSTP";
46typedef enum : uint8_t {
61typedef enum : uint16_t {
79typedef enum : uint32_t {
102typedef enum : uintptr_t {
170 const uint8_t reg = (uint8_t)reg_id;
229 const uint32_t mask = (uint32_t)1U << bit;
231 const bool seen_stopped = (*p & mask) != 0U;
232 const bool settled = (seen_stopped == expected_stopped);
233#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
235 if (ra8_fake_mmio_wait_eval(p, (uint32_t)i, settled)) {
252 const bool settled = ((*p & care_mask) == (expect & care_mask));
253#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
255 if (ra8_fake_mmio_wait_eval(p, (uint32_t)i, settled)) {
278 if (k_psar_addr[reg] == 0U) {
283 return *(
volatile const uint32_t*)k_psar_addr[reg];
353 if (prev == UINT8_MAX) {
368 const uint32_t mask = (uint32_t)1U << bit;
406 const uint32_t mask = (uint32_t)1U << bit;
441 const uint32_t mask = (uint32_t)1U << bit;
442 *out_stopped = ((*p & mask) != 0U);
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Named Bit Positions and Masks for Register Manipulation.
@ k_ra8_mask_byte
Low 8 bits mask.
@ k_ra8_bits_per_byte
Bits in a byte.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
#define ra8_log_info(tag, message)
RA8 log info.
static ra8_err_t internal_wait_readback(uint8_t reg, uint8_t bit, bool expected_stopped)
Read-back protocol from HUM 11.2.6 Note 2.
ra8_mstp_dim_t
Dimensions of the ref-count table.
@ k_ra8_mstp_reg_count
MSTPCRA..MSTPCRE.
@ k_ra8_mstp_bit_count
32 bits per register.
uint8_t ra8_mstp_id_bit(ra8_mstp_t id)
Extract the bit number from a packed MSTP id.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_is_stopped(ra8_mstp_t id, bool *out_stopped)
Read the current MSTP bit value for an id.
ra8_mstp_psar_t
R_PSCU Peripheral Security Attribution Register addresses (PSARB..E).
@ k_ra8_mstp_psarb_addr
PSARB: MSTPCRB attribution.
@ k_ra8_mstp_psard_addr
PSARD: MSTPCRD attribution.
@ k_ra8_mstp_psarc_addr
PSARC: MSTPCRC attribution.
@ k_ra8_mstp_psare_addr
PSARE: MSTPCRE attribution.
ra8_mstp_reg_t ra8_mstp_id_reg(ra8_mstp_t id)
Extract the register index from a packed MSTP id.
static uint8_t s_refcount[k_ra8_mstp_reg_count][k_ra8_mstp_bit_count]
Per-(register, bit) usage counter.
ra8_err_t ra8_mstp_get_refcount(ra8_mstp_t id, uint8_t *out_ref)
Read the current ref count for an MSTP id.
ra8_mstp_spin_t
Bounded spin budget for the read-back protocol (HUM 11.2.6 N2).
@ k_ra8_mstp_readback_spin
RA8 mstp readback spin.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
static volatile uint32_t * internal_reg_ptr(uint8_t reg)
Pointer to MSTPCRA..MSTPCRE indexed by register number.
ra8_mstp_init_val_t
Per-register safe all-stopped patterns for MSTPCRA..MSTPCRE.
@ k_ra8_mstp_all_stopped
RA8 mstp all stopped.
@ k_ra8_mstp_safe_stopped_a
MSTPCRA: bits 0-3 (SRAM0-3) kept 0.
static bool internal_decode(ra8_mstp_t id, uint8_t *out_reg, uint8_t *out_bit)
Decode an ra8_mstp_t id and validate its bit position.
ra8_err_t priv_ra8_mstp_wait_reg_settle_internal(uint8_t reg, uint32_t expect, uint32_t care_mask)
Implementation of priv_ra8_mstp_wait_reg_settle_internal() – masked settle poll.
uint32_t priv_ra8_mstp_ns_mask_internal(uint8_t reg)
Implementation of priv_ra8_mstp_ns_mask_internal() – reads PSARB..E.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
Ref-counted Module Stop Control wrapper for the RA8D2.
Cross-TU surface for the ra8_mstp module-stop driver (test access).
Module Stop Control (MSTP) register layout for the Renesas RA8D2.
static volatile r_mstp_regs_t * ra8_mstp(void)
Get pointer to the MSTP register block.
ra8_mstp_t
Packed (reg << 8) | bit module-stop identifier.
ra8_mstp_reg_t
Which of MSTPCRA..MSTPCRE owns the bit.
volatile uint32_t MSTPCRA
Module Stop Control Register A (+0x00).