|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
NSC veneers for the Clock Generation Circuit (CGC) driver. More...
#include <stdint.h>#include "ra8_cgc.h"#include "ra8_cgc_regs.h"#include "ra8_err.h"#include "ra8_nsc_veneer.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_nsc_cgc_pll2_enable (uint8_t mul_int, uint8_t mul_quarters, ra8_plodiv_t p_div_code) |
| NSC veneer: bring up PLL2 with the given multiplier and divider. | |
| ra8_err_t | ra8_nsc_cgc_usbfs_clock_enable (void) |
| NSC veneer: bring up the USB-FS module clock (USBCKCR / USBCKDIVCR). | |
| ra8_err_t | ra8_nsc_cgc_get_clock_hz (ra8_clock_id_t id, uint32_t *hz_out) |
| NSC veneer: query a clock-tree frequency. | |
NSC veneers for the Clock Generation Circuit (CGC) driver.
Exposes the secure-side CGC primitives needed to bring up the USB-FS 48 MHz reference clock to Non-Secure callers across the TrustZone boundary. The CGC PLL2 / USBCKCR / USBCKDIVCR register block lives in the System Control region which is permanently Secure on the RA8D2 – writes from a Non-Secure context complete silently and leave the registers in their reset state. The veneers in this file are the only safe path for NS code to request CGC operations.
Each entry is a Non-Secure Callable function (cmse_nonsecure_entry) that simply forwards to the matching ra8_cgc_* API, with pointer arguments (where present) range-checked to ensure they live in NS memory before the secure driver dereferences them.
Definition in file ra8_nsc_cgc.h.
|
nodiscard |
NSC veneer: query a clock-tree frequency.
Forwards to ra8_cgc_get_clock_hz with NS range-validation of the hz_out destination so the secure driver can never write outside the Non-Secure data region.
| [in] | id | Clock identifier (ra8_clock_id_t). |
| [out] | hz_out | NS destination for the current frequency in Hz. |
| k_ra8_ok | Frequency stored at *hz_out. |
| k_ra8_err_null_ptr | hz_out was NULL. |
| k_ra8_err_invalid_arg | hz_out outside NS region or bad id. |
Range-checks hz_out against the NS data region and forwards to ra8_cgc_get_clock_hz.
| [in] | id | Clock identifier. |
| [out] | hz_out | NS destination for the frequency in Hz. |
| k_ra8_ok | Frequency stored. |
| k_ra8_err_null_ptr | hz_out was NULL. |
| k_ra8_err_invalid_arg | hz_out outside NS region or bad id. |
Definition at line 121 of file ra8_nsc_cgc.c.
References ra8_cgc_get_clock_hz(), RA8_CHECK_NULL_PTR, RA8_NSC_CHECK_NS_RANGE_RW, RA8_NSC_VENEER, and s_tag.
|
nodiscard |
NSC veneer: bring up PLL2 with the given multiplier and divider.
Forwards to ra8_cgc_pll2_enable. PLL2 is required for the USB-FS 48 MHz reference clock; see ra8_nsc_cgc_usbfs_clock_enable for the full bring-up sequence.
| [in] | mul_int | PLL2 multiplier integer part (1..255). |
| [in] | mul_quarters | PLL2 multiplier quarter part (0..3). |
| [in] | p_div_code | PLL2 P-divider code (ra8_plodiv_t). |
| k_ra8_ok | PLL2 locked. |
| k_ra8_err_invalid_arg | mul_int is 0 or mul_quarters > 3. |
| k_ra8_err_hw_timeout | PLL2SF handshake timed out. |
Forwards to ra8_cgc_pll2_enable. No pointer arguments crossing the TZ boundary, so no NS range-check is needed.
| [in] | mul_int | PLL2 multiplier integer part. |
| [in] | mul_quarters | PLL2 multiplier quarter part. |
| [in] | p_div_code | PLL2 P-divider code. |
| k_ra8_ok | PLL2 locked. |
| k_ra8_err_invalid_arg | Bad multiplier. |
| k_ra8_err_hw_timeout | PLL2SF handshake timed out. |
Definition at line 63 of file ra8_nsc_cgc.c.
References ra8_cgc_pll2_enable(), and RA8_NSC_VENEER.
|
nodiscard |
NSC veneer: bring up the USB-FS module clock (USBCKCR / USBCKDIVCR).
Forwards to ra8_cgc_usbfs_clock_enable. Must run before any NS caller releases MSTPB11 (USBFS), otherwise the SREQ -> SRDY handshake hangs silently. ra8_nsc_cgc_pll2_enable must have been called first to lock PLL2 at the canonical 240 MHz target.
| k_ra8_ok | USB-FS module clock running at 48 MHz. |
| k_ra8_err_hw_timeout | USBCKSRDY handshake never completed. |
NSC veneer: bring up the USB-FS module clock (USBCKCR / USBCKDIVCR).
Forwards to ra8_cgc_usbfs_clock_enable.
| k_ra8_ok | USB-FS clock running. |
| k_ra8_err_hw_timeout | USBCKSRDY never came up. |
Definition at line 90 of file ra8_nsc_cgc.c.
References ra8_cgc_usbfs_clock_enable(), and RA8_NSC_VENEER.