46static const char*
s_tag =
"CGC";
94typedef enum : uint32_t {
124typedef enum : uint32_t {
144typedef enum : uint16_t {
171 if (expected != 0U) {
277 const uint32_t mul_quarters_field =
279 const uint32_t pll2ccr =
286 const uint16_t pll2ccr2 =
451typedef enum : uint32_t {
468typedef enum : uint32_t {
493 if (expected != 0U) {
541 *ckcr = (uint8_t)(*ckcr | sreq_mask);
549 *ckcr = (uint8_t)(src | sreq_mask | srdy_mask);
550 *ckcr = (uint8_t)(*ckcr & (uint8_t)~sreq_mask);
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).
ra8_err_t priv_ra8_cgc_wait_oscsf_clear(uint8_t bit)
Bounded poll on a single OSCSF flag becoming clear.
ra8_err_t priv_ra8_cgc_wait_oscsf_set(uint8_t bit)
Bounded poll on a single OSCSF flag becoming set.
High-level Clock Generation Circuit driver.
Cross-TU sharing for the split Clock Generation Circuit driver.
@ k_ra8_cgc_quarters_per_unit
PLL multiplier 0.25 step.
Clock Generation Circuit (CGC) field layouts for the Renesas RA8D2.
@ k_ra8_pll2cr_run
Clear PLL2STP -> PLL2 runs.
@ k_ra8_pll2cr_stop
Set PLL2STP -> PLL2 stops.
@ k_ra8_pll2ccr_mask_quarters
11-bit (mul*4) field.
@ k_ra8_pll2ccr_mask_plidiv
PL2IDIV 2-bit field.
@ k_ra8_plidiv_div2
PLL input divide by 2.
ra8_plodiv_t
PLL output divider codes for PLODIVP/Q/R fields in PLLCCR2.
@ k_ra8_plodiv_div6
PLL output divide by 6.
@ k_ra8_plodiv_div4
PLL output divide by 4.
@ k_ra8_pllccr2_shift_plodivp
PLODIVP field starts at bit 0.
@ k_ra8_pllccr2_shift_plodivr
PLODIVR field starts at bit 8.
@ k_ra8_pllccr2_shift_plodivq
PLODIVQ field starts at bit 4.
@ k_ra8_pllccr_shift_quarters
(mul * 4) goes here.
@ k_ra8_pllccr_shift_plsrcsel
PLSRCSEL field is bit 4.
@ k_ra8_plsrcsel_main
Main-oscillator input (default on EK board).
@ k_ra8_hococr_hcstp
HCSTP: 0 operating, 1 stopped.
ra8_usbhs_clock_local_t
Local sentinels for the USB60CKCR SREQ/SRDY handshake.
@ k_ra8_usbhs_div4_code
USB60CKDIVCR codepoint /4.
@ k_ra8_usbhs_srdy_poll_limit
Iterations before timeout.
ra8_usbfs_mstp_local_t
Local sentinels for the USBFS module-stop pre-step.
@ k_ra8_mstpb11_usbfs_mask
MSTPCRB.MSTPB11 (USBFS0).
ra8_err_t ra8_cgc_pll2_enable(uint8_t mul_int, uint8_t mul_quarters, ra8_plodiv_t p_div_code)
Implementation of ra8_cgc_pll2_enable().
ra8_usbfs_clock_local_t
Local sentinels for the USBCKSRDY handshake and divider codes.
@ k_ra8_usbfs_srdy_poll_limit
Iterations before timeout.
@ k_ra8_usbfs_div8_code
USBCKDIVCR codepoint for /8.
@ k_ra8_usbfs_div5_code
USBCKDIVCR codepoint for /5.
ra8_usbhs_mstp_local_t
Local sentinels for the USBHS module-stop pre-step.
@ k_ra8_mstpb12_usbhs_mask
MSTPCRB.MSTPB12 (USBHS).
ra8_err_t priv_ra8_cgc_ensure_hoco_running_for_usb_ck(void)
Ensure HOCO is running so a USBCKCR/USB60CKCR/ESWCKCR SREQ->SRDY handshake can drain.
ra8_pll2_local_t
Local constants for the PLL2 bring-up path.
@ k_ra8_pll2_usbfs_quarters
Fractional quarter-steps (none).
@ k_ra8_pll2_usbfs_mul
Integer multiplier for PLL2 USBFS path.
@ k_ra8_pll2_max_quarters
Max value of PLL2MULNF[7:6].
static ra8_err_t internal_wait_usb60cksrdy(uint8_t expected)
Spin until USB60CKCR.USB60CKSRDY matches the expected value.
static ra8_err_t internal_pll2_program_protected(uint32_t pll2ccr, uint16_t pll2ccr2)
PRCR-protected stop+program+restart body of ra8_cgc_pll2_enable.
static ra8_err_t internal_wait_usbcksrdy(uint8_t expected)
Spin until USBCKCR.USBCKSRDY matches the expected value.
static ra8_err_t internal_usb60ckcr_switch_to_pll2p_div4(void)
PRCR-protected USB60CKCR / USB60CKDIVCR handshake body.
static volatile uint8_t s_pll2_status_probe
Last value read back from R_SYSTEM->OSCSF at the end of internal_usb60ckcr_switch_to_pll2p_div4.
static ra8_err_t internal_usbckcr_switch_to_pll2p_div5(void)
PRCR-protected USBCKCR / USBCKDIVCR handshake body.
static volatile uint8_t s_usb60ckcr_probe
Last value read back from R_SYSTEM->USB60CKCR at the end of internal_usb60ckcr_switch_to_pll2p_div4.
ra8_err_t ra8_cgc_usbfs_clock_enable(void)
Bring up the 48 MHz USB-FS clock from PLL2P / 5.
ra8_err_t ra8_cgc_usbhs_pll_enable(void)
Bring up the USBHS PHY 60 MHz reference clock + module clock path.
Validation and Error-Checking Macros for ra8-firmware.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
static ra8_err_t ra8_hw_wait_flag_clear8(volatile const uint8_t *reg, uint8_t mask, uint32_t budget)
Spin until (*reg & mask) == 0 or budget runs out.
static ra8_err_t ra8_hw_wait_flag_set8(volatile const uint8_t *reg, uint8_t mask, uint32_t budget)
Spin until (*reg & mask) != 0 or budget runs out.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
#define ra8_log_info(tag, message)
RA8 log info.
#define ra8_log_error(tag, message)
RA8 log error.
Ref-counted Module Stop Control wrapper for the RA8D2.
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.
Scoped PRCR unlock helper.
#define RA8_PROTECTED_WRITE(unlock_val)
Scoped PRCR unlock block.
System Control (SYSC) register layout for the Renesas RA8D2.
static volatile uint8_t * ra8_sys_usbckcr(void)
Get pointer to the 8-bit USBCKCR (USB-FS source select).
@ k_ra8_prcr_unlock_cgc
RA8 prcr unlock cgc.
static volatile uint32_t * ra8_sys_pll2ccr(void)
Get pointer to the 32-bit PLL2CCR register (PLL2 input/mul/source).
static volatile uint16_t * ra8_sys_pll2ccr2(void)
Get pointer to the 16-bit PLL2CCR2 register (PLL2 output dividers).
@ k_ra8_oscsf_bit_pll2sf
PLL2 stabilisation flag.
@ k_ra8_oscsf_bit_moscsf
Main oscillator stab flag.
@ k_ra8_oscsf_bit_hocosf
HOCO stabilisation flag.
static volatile uint8_t * ra8_sys_hococr(void)
Get pointer to the 8-bit HOCOCR register.
static volatile uint8_t * ra8_sys_pll2cr(void)
Get pointer to the 8-bit PLL2CR register (PLL2 stop control).
static volatile uint8_t * ra8_sys_usbckdivcr(void)
Get pointer to the 8-bit USBCKDIVCR (USB clock divider).
static volatile uint8_t * ra8_sys_usb60ckdivcr(void)
Get pointer to the 8-bit USB60CKDIVCR (USBHS 60MHz divider).
static volatile uint8_t * ra8_sys_oscsf(void)
Get pointer to the 8-bit OSCSF (oscillation stabilisation) register.
static volatile uint8_t * ra8_sys_usb60ckcr(void)
Get pointer to the 8-bit USB60CKCR (USBHS 60MHz source select).
@ k_ra8_usbcksel_pll2p
PLL2P.
@ k_ra8_usbckcr_mask_sel
USBCKSEL field is 4 bits wide.
@ k_ra8_usbckcr_bit_srdy
USBCKSRDY – handshake ready.
@ k_ra8_usbckcr_bit_sreq
USBCKSREQ – request switch.
Named Time Unit Constants for Delay / Timeout / Tick Math.
volatile uint32_t MSTPCRB
Module Stop Control Register B (+0x04).