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

Module Stop Control (MSTP) register layout for the Renesas RA8D2. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for ra8_mstp_regs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  r_mstp_regs_t
 Memory layout of the Module Stop Control Register block. More...

Enumerations

enum  ra8_mstp_addr_t : uintptr_t { k_ra8_mstp_base_addr = 0x40203000UL }
enum  ra8_mstp_block_size_t : uint8_t { k_ra8_mstp_block_bytes = 20U }
 Expected byte size of the MSTP register block. More...
enum  ra8_mstp_reg_t : uint8_t {
  k_ra8_mstp_reg_a = 0U ,
  k_ra8_mstp_reg_b = 1U ,
  k_ra8_mstp_reg_c = 2U ,
  k_ra8_mstp_reg_d = 3U ,
  k_ra8_mstp_reg_e = 4U
}
 Which of MSTPCRA..MSTPCRE owns the bit. More...
enum  ra8_mstp_t : uint16_t {
  k_ra8_mstp_sram0 = (uint16_t)(k_ra8_mstp_reg_a << 8) ,
  k_ra8_mstp_sram1 = (uint16_t)((k_ra8_mstp_reg_a << 8) | 1U) ,
  k_ra8_mstp_sram2 = (uint16_t)((k_ra8_mstp_reg_a << 8) | 2U) ,
  k_ra8_mstp_sram3 = (uint16_t)((k_ra8_mstp_reg_a << 8) | 3U) ,
  k_ra8_mstp_dmac0_dtc0 ,
  k_ra8_mstp_dmac1_dtc1 ,
  k_ra8_mstp_i3c = (uint16_t)((k_ra8_mstp_reg_b << 8) | 4U) ,
  k_ra8_mstp_iic2 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 7U) ,
  k_ra8_mstp_iic1 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 8U) ,
  k_ra8_mstp_iic0 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 9U) ,
  k_ra8_mstp_usbfs = (uint16_t)((k_ra8_mstp_reg_b << 8) | 11U) ,
  k_ra8_mstp_usbhs = (uint16_t)((k_ra8_mstp_reg_b << 8) | 12U) ,
  k_ra8_mstp_ospi0 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 16U) ,
  k_ra8_mstp_ospi1 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 17U) ,
  k_ra8_mstp_spi1 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 18U) ,
  k_ra8_mstp_spi0 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 19U) ,
  k_ra8_mstp_sci9 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 22U) ,
  k_ra8_mstp_sci8 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 23U) ,
  k_ra8_mstp_sci7 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 24U) ,
  k_ra8_mstp_sci6 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 25U) ,
  k_ra8_mstp_sci5 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 26U) ,
  k_ra8_mstp_sci4 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 27U) ,
  k_ra8_mstp_sci3 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 28U) ,
  k_ra8_mstp_sci2 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 29U) ,
  k_ra8_mstp_sci1 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 30U) ,
  k_ra8_mstp_sci0 = (uint16_t)((k_ra8_mstp_reg_b << 8) | 31U) ,
  k_ra8_mstp_cac = (uint16_t)(k_ra8_mstp_reg_c << 8) ,
  k_ra8_mstp_crc = (uint16_t)((k_ra8_mstp_reg_c << 8) | 1U) ,
  k_ra8_mstp_glcdc = (uint16_t)((k_ra8_mstp_reg_c << 8) | 4U) ,
  k_ra8_mstp_drw = (uint16_t)((k_ra8_mstp_reg_c << 8) | 6U) ,
  k_ra8_mstp_ssie1 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 7U) ,
  k_ra8_mstp_ssie0 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 8U) ,
  k_ra8_mstp_mipi_dsi = (uint16_t)((k_ra8_mstp_reg_c << 8) | 10U) ,
  k_ra8_mstp_sdhi1 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 11U) ,
  k_ra8_mstp_sdhi0 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 12U) ,
  k_ra8_mstp_doc = (uint16_t)((k_ra8_mstp_reg_c << 8) | 13U) ,
  k_ra8_mstp_elc = (uint16_t)((k_ra8_mstp_reg_c << 8) | 14U) ,
  k_ra8_mstp_ceu = (uint16_t)((k_ra8_mstp_reg_c << 8) | 16U) ,
  k_ra8_mstp_mipi_csi = (uint16_t)((k_ra8_mstp_reg_c << 8) | 17U) ,
  k_ra8_mstp_pdmif = (uint16_t)((k_ra8_mstp_reg_c << 8) | 24U) ,
  k_ra8_mstp_canfd1 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 26U) ,
  k_ra8_mstp_canfd0 = (uint16_t)((k_ra8_mstp_reg_c << 8) | 27U) ,
  k_ra8_mstp_ethphyclk = (uint16_t)((k_ra8_mstp_reg_c << 8) | 28U) ,
  k_ra8_mstp_eswm = (uint16_t)((k_ra8_mstp_reg_c << 8) | 30U) ,
  k_ra8_mstp_rsip = (uint16_t)((k_ra8_mstp_reg_c << 8) | 31U) ,
  k_ra8_mstp_agt1 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 4U) ,
  k_ra8_mstp_agt0 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 5U) ,
  k_ra8_mstp_pdg = (uint16_t)((k_ra8_mstp_reg_d << 8) | 6U) ,
  k_ra8_mstp_poeg_d = (uint16_t)((k_ra8_mstp_reg_d << 8) | 11U) ,
  k_ra8_mstp_poeg_c = (uint16_t)((k_ra8_mstp_reg_d << 8) | 12U) ,
  k_ra8_mstp_poeg_b = (uint16_t)((k_ra8_mstp_reg_d << 8) | 13U) ,
  k_ra8_mstp_poeg_a = (uint16_t)((k_ra8_mstp_reg_d << 8) | 14U) ,
  k_ra8_mstp_dac12_1 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 19U) ,
  k_ra8_mstp_dac12_0 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 20U) ,
  k_ra8_mstp_adc16h = (uint16_t)((k_ra8_mstp_reg_d << 8) | 21U) ,
  k_ra8_mstp_tsn = (uint16_t)((k_ra8_mstp_reg_d << 8) | 22U) ,
  k_ra8_mstp_acmphs3 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 25U) ,
  k_ra8_mstp_acmphs2 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 26U) ,
  k_ra8_mstp_acmphs1 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 27U) ,
  k_ra8_mstp_acmphs0 = (uint16_t)((k_ra8_mstp_reg_d << 8) | 28U) ,
  k_ra8_mstp_ulpt1 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 8U) ,
  k_ra8_mstp_ulpt0 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 9U) ,
  k_ra8_mstp_gpt13 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 18U) ,
  k_ra8_mstp_gpt12 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 19U) ,
  k_ra8_mstp_gpt11 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 20U) ,
  k_ra8_mstp_gpt10 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 21U) ,
  k_ra8_mstp_gpt4_9 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 27U) ,
  k_ra8_mstp_gpt3 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 28U) ,
  k_ra8_mstp_gpt2 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 29U) ,
  k_ra8_mstp_gpt1 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 30U) ,
  k_ra8_mstp_gpt0 = (uint16_t)((k_ra8_mstp_reg_e << 8) | 31U)
}
 Packed (reg << 8) | bit module-stop identifier. More...

Functions

static volatile r_mstp_regs_tra8_mstp (void)
 Get pointer to the MSTP register block.
ra8_mstp_reg_t ra8_mstp_id_reg (ra8_mstp_t id)
 Extract the register index from a packed MSTP id.
uint8_t ra8_mstp_id_bit (ra8_mstp_t id)
 Extract the bit number from a packed MSTP id.

Detailed Description

Module Stop Control (MSTP) register layout for the Renesas RA8D2.

Every RA-family peripheral has a Module Stop bit. When that bit is 1 the peripheral is clock-gated off and does not respond to bus accesses. Module Stop Control Registers A..E (MSTPCRA..MSTPCRE) at 0x40203000 (Secure alias) hold 32 bits each, one bit per peripheral. The Non-Secure alias is at 0x50203000 and is referenced once TrustZone is wired up.

The exact MSTP bit for each peripheral is documented in HUM Chapter 11 "Low Power Mode", sections 11.2.6..11.2.10 (MSTPCRA..E). Bit assignments here are taken from the per-register tables on pages 443..450 (Rev. 1.30) and cited inline.

Drivers must NOT write these registers directly. The substrate file libs/ra8_hal/src/ra8_mstp.c exposes a ref-counted ra8_mstp_enable(id) / ra8_mstp_disable(id) pair that tracks shared modules (DMAC + DTC, RSIP + TRNG, etc.) so two unrelated drivers can both request the same MSTP bit without trampling each other.

Encoding

ra8_mstp_t is a 16-bit value packed as (reg << 8) | bit:

  • reg 0..4 selects MSTPCRA..MSTPCRE.
  • bit 0..31 selects the bit within the register.

Names in the enum follow the canonical "MSTP target module" column from the HUM tables, prefixed with k_ra8_mstp_.

Hardware constraints

  • Read-back required: HUM 11.2.6 Note 2 says "When changing the value of this bit, only execute subsequent instructions after reading this bit to check that the value was updated." The ref-counted helper in ra8_mstp.c performs the read-back; the register layout itself is just a memory-mapped r_mstp_regs_t.
  • DMAC / DTC ordering: HUM 11.2.6 Note 1 says "When rewriting the MSTPAi bit from 0 to 1, disable the DMAC and DTC before setting MSTPAi bit (i = 22, 23)." Caller responsibility – ra8_mstp does not poke the DMAC channel registers.
  • MSTPCR is NOT PRCR-protected. The CGC, LVD and LPM groups sit behind PRCR; the module-stop block does not.

Definition in file ra8_mstp_regs.h.

Enumeration Type Documentation

◆ ra8_mstp_addr_t

enum ra8_mstp_addr_t : uintptr_t
Enumerator
k_ra8_mstp_base_addr 

R_MSTP block base.

(anon).

Definition at line 67 of file ra8_mstp_regs.h.

◆ ra8_mstp_block_size_t

enum ra8_mstp_block_size_t : uint8_t

Expected byte size of the MSTP register block.

Enumerator
k_ra8_mstp_block_bytes 

5 x uint32_t = 20 bytes.

Definition at line 96 of file ra8_mstp_regs.h.

◆ ra8_mstp_reg_t

enum ra8_mstp_reg_t : uint8_t

Which of MSTPCRA..MSTPCRE owns the bit.

Enumerator
k_ra8_mstp_reg_a 

RA8 mstp register a.

k_ra8_mstp_reg_b 

RA8 mstp register b.

k_ra8_mstp_reg_c 

RA8 mstp register c.

k_ra8_mstp_reg_d 

RA8 mstp register d.

k_ra8_mstp_reg_e 

RA8 mstp register e.

Definition at line 118 of file ra8_mstp_regs.h.

◆ ra8_mstp_t

enum ra8_mstp_t : uint16_t

Packed (reg << 8) | bit module-stop identifier.

Every peripheral the firmware can ungate has an entry below. Each value packs the (MSTPCR register, bit) pair from HUM Ch 11.2.6..10 into a single uint16_t. Drivers feed these into ra8_mstp_enable(id) / ra8_mstp_disable(id), never write the register directly.

Bit numbering matches the manual exactly (0-based from the LSB), which is also what the 32-bit registers expect.

Enumerator
k_ra8_mstp_sram0 

MSTPA0 SRAM0.

k_ra8_mstp_sram1 

MSTPA1 SRAM1.

k_ra8_mstp_sram2 

MSTPA2 SRAM2.

k_ra8_mstp_sram3 

MSTPA3 SRAM3.

k_ra8_mstp_dmac0_dtc0 

MSTPA22 DMAC0+DTC0 (shared).

k_ra8_mstp_dmac1_dtc1 

MSTPA23 DMAC1+DTC1 (shared).

k_ra8_mstp_i3c 

MSTPB4 I3C.

k_ra8_mstp_iic2 

MSTPB7 IIC2.

k_ra8_mstp_iic1 

MSTPB8 IIC1.

k_ra8_mstp_iic0 

MSTPB9 IIC0.

k_ra8_mstp_usbfs 

MSTPB11 USBFS0.

k_ra8_mstp_usbhs 

MSTPB12 USBHS.

k_ra8_mstp_ospi0 

MSTPB16 OSPI0+DOTF0.

k_ra8_mstp_ospi1 

MSTPB17 OSPI1+DOTF1.

k_ra8_mstp_spi1 

MSTPB18 SPI1.

k_ra8_mstp_spi0 

MSTPB19 SPI0.

k_ra8_mstp_sci9 

MSTPB22 SCI9.

k_ra8_mstp_sci8 

MSTPB23 SCI8.

k_ra8_mstp_sci7 

MSTPB24 SCI7.

k_ra8_mstp_sci6 

MSTPB25 SCI6.

k_ra8_mstp_sci5 

MSTPB26 SCI5.

k_ra8_mstp_sci4 

MSTPB27 SCI4.

k_ra8_mstp_sci3 

MSTPB28 SCI3.

k_ra8_mstp_sci2 

MSTPB29 SCI2.

k_ra8_mstp_sci1 

MSTPB30 SCI1.

k_ra8_mstp_sci0 

MSTPB31 SCI0.

k_ra8_mstp_cac 

MSTPC0 CAC.

k_ra8_mstp_crc 

MSTPC1 CRC.

k_ra8_mstp_glcdc 

MSTPC4 GLCDC.

k_ra8_mstp_drw 

MSTPC6 2D Drawing.

k_ra8_mstp_ssie1 

MSTPC7 SSIE1.

k_ra8_mstp_ssie0 

MSTPC8 SSIE0.

k_ra8_mstp_mipi_dsi 

MSTPC10 MIPI DSI.

k_ra8_mstp_sdhi1 

MSTPC11 SDHI1.

k_ra8_mstp_sdhi0 

MSTPC12 SDHI0.

k_ra8_mstp_doc 

MSTPC13 DOC.

k_ra8_mstp_elc 

MSTPC14 ELC.

k_ra8_mstp_ceu 

MSTPC16 CEU.

k_ra8_mstp_mipi_csi 

MSTPC17 MIPI CSI.

k_ra8_mstp_pdmif 

MSTPC24 PDM-IF.

k_ra8_mstp_canfd1 

MSTPC26 CANFD1.

k_ra8_mstp_canfd0 

MSTPC27 CANFD0.

k_ra8_mstp_ethphyclk 

MSTPC28 Ether-PHY clock.

k_ra8_mstp_eswm 

MSTPC30 ESWM.

k_ra8_mstp_rsip 

MSTPC31 RSIP-E50D.

k_ra8_mstp_agt1 

MSTPD4 AGT1.

k_ra8_mstp_agt0 

MSTPD5 AGT0.

k_ra8_mstp_pdg 

MSTPD6 PDG.

k_ra8_mstp_poeg_d 

MSTPD11 POEG group D.

k_ra8_mstp_poeg_c 

MSTPD12 POEG group C.

k_ra8_mstp_poeg_b 

MSTPD13 POEG group B.

k_ra8_mstp_poeg_a 

MSTPD14 POEG group A.

k_ra8_mstp_dac12_1 

MSTPD19 DAC12 ch 1.

k_ra8_mstp_dac12_0 

MSTPD20 DAC12 ch 0.

k_ra8_mstp_adc16h 

MSTPD21 ADC16H.

k_ra8_mstp_tsn 

MSTPD22 Temperature.

k_ra8_mstp_acmphs3 

MSTPD25 ACMPHS3.

k_ra8_mstp_acmphs2 

MSTPD26 ACMPHS2.

k_ra8_mstp_acmphs1 

MSTPD27 ACMPHS1.

k_ra8_mstp_acmphs0 

MSTPD28 ACMPHS0.

k_ra8_mstp_ulpt1 

MSTPE8 ULPT1.

k_ra8_mstp_ulpt0 

MSTPE9 ULPT0.

k_ra8_mstp_gpt13 

MSTPE18 GPT13.

k_ra8_mstp_gpt12 

MSTPE19 GPT12.

k_ra8_mstp_gpt11 

MSTPE20 GPT11.

k_ra8_mstp_gpt10 

MSTPE21 GPT10.

k_ra8_mstp_gpt4_9 

MSTPE27 GPT4..GPT9.

k_ra8_mstp_gpt3 

MSTPE28 GPT3.

k_ra8_mstp_gpt2 

MSTPE29 GPT2.

k_ra8_mstp_gpt1 

MSTPE30 GPT1.

k_ra8_mstp_gpt0 

MSTPE31 GPT0.

Definition at line 140 of file ra8_mstp_regs.h.

Function Documentation

◆ ra8_mstp()

volatile r_mstp_regs_t * ra8_mstp ( void )
inlinestatic

Get pointer to the MSTP register block.

Definition at line 104 of file ra8_mstp_regs.h.

References k_ra8_mstp_base_addr.

Referenced by internal_mipi_phy_mstp_unstop(), internal_reg_ptr(), ra8_cgc_usbfs_clock_enable(), and ra8_cgc_usbhs_pll_enable().

◆ ra8_mstp_id_bit()

uint8_t ra8_mstp_id_bit ( ra8_mstp_t id)

Extract the bit number from a packed MSTP id.

Parameters
[in]idPacked id.
Returns
Bit position 0..31.

Defined in libs/ra8_hal/src/ra8_mstp.c.

Since
0.1.0
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.

Definition at line 139 of file ra8_mstp.c.

References k_ra8_mask_byte.

Referenced by internal_decode().

◆ ra8_mstp_id_reg()

ra8_mstp_reg_t ra8_mstp_id_reg ( ra8_mstp_t id)

Extract the register index from a packed MSTP id.

Parameters
[in]idPacked id.
Returns
Register index 0..4.

Real (non-inline) function so coverage tooling can attribute line counts to a single defining translation unit. The body is in libs/ra8_hal/src/ra8_mstp.c.

Since
0.1.0
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.

Definition at line 134 of file ra8_mstp.c.

References k_ra8_bits_per_byte, and k_ra8_mask_byte.

Referenced by internal_decode().