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

NSC veneers for the Clock Generation Circuit driver. More...

#include "ra8_nsc_cgc.h"
#include <stdint.h>
#include "ra8_cgc.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_nsc_veneer.h"
Include dependency graph for ra8_nsc_cgc.c:

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.
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.

Variables

static const char * s_tag = "NSCCGC"
 Logging tag for the CGC veneers.

Detailed Description

NSC veneers for the Clock Generation Circuit driver.

Tag
[Ring 4 / NSC] {World: NSC}

Implements the Non-Secure Callable veneers declared in ra8_nsc_cgc.h. Each entry validates pointer arguments (when present) and forwards to the secure ra8_cgc_* API. The CGC register block (System Control) is permanently Secure on the RA8D2; this file is the only TZ-safe path for Non-Secure code to request clock-tree changes.

Definition in file ra8_nsc_cgc.c.

Function Documentation

◆ ra8_nsc_cgc_get_clock_hz()

ra8_err_t ra8_nsc_cgc_get_clock_hz ( ra8_clock_id_t id,
uint32_t * hz_out )
nodiscard

NSC veneer: query a clock-tree frequency.

Range-checks hz_out against the NS data region and forwards to ra8_cgc_get_clock_hz.

Parameters
[in]idClock identifier.
[out]hz_outNS destination for the frequency in Hz.
Returns
ra8_err_t outcome.
Return values
k_ra8_okFrequency stored.
k_ra8_err_null_ptrhz_out was NULL.
k_ra8_err_invalid_arghz_out outside NS region or bad id.
Precondition
TrustZone substrate up.
hz_out lies in NS data region.
Postcondition
On success *hz_out holds the frequency.
On failure *hz_out unchanged.
TrustZone:
NS->S boundary via cmse_nonsecure_entry. hz_out is cmse_check_address_range-validated.
Note
Thread-safe: serialised by the secure CGC driver.
Since
0.1.0

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.

Referenced by ns_exercise_veneers().

◆ ra8_nsc_cgc_pll2_enable()

ra8_err_t ra8_nsc_cgc_pll2_enable ( uint8_t mul_int,
uint8_t mul_quarters,
ra8_plodiv_t p_div_code )
nodiscard

NSC veneer: bring up PLL2 with the given multiplier and divider.

Forwards to ra8_cgc_pll2_enable. No pointer arguments crossing the TZ boundary, so no NS range-check is needed.

Parameters
[in]mul_intPLL2 multiplier integer part.
[in]mul_quartersPLL2 multiplier quarter part.
[in]p_div_codePLL2 P-divider code.
Returns
ra8_err_t from ra8_cgc_pll2_enable.
Return values
k_ra8_okPLL2 locked.
k_ra8_err_invalid_argBad multiplier.
k_ra8_err_hw_timeoutPLL2SF handshake timed out.
Precondition
TrustZone substrate up.
ra8_cgc_init has been called.
Postcondition
On success PLL2 is locked.
On failure no register state was mutated.
TrustZone:
NS->S boundary via cmse_nonsecure_entry. Scalar arguments only.
Note
Thread-safe: serialised by the secure CGC driver.
Since
0.1.0

Definition at line 63 of file ra8_nsc_cgc.c.

References ra8_cgc_pll2_enable(), and RA8_NSC_VENEER.

Referenced by ns_exercise_veneers().

◆ ra8_nsc_cgc_usbfs_clock_enable()

ra8_err_t ra8_nsc_cgc_usbfs_clock_enable ( void )
nodiscard

NSC veneer: bring up the USB-FS module clock.

NSC veneer: bring up the USB-FS module clock (USBCKCR / USBCKDIVCR).

Forwards to ra8_cgc_usbfs_clock_enable.

Returns
ra8_err_t from ra8_cgc_usbfs_clock_enable.
Return values
k_ra8_okUSB-FS clock running.
k_ra8_err_hw_timeoutUSBCKSRDY never came up.
Precondition
TrustZone substrate up.
PLL2 has been locked via ra8_nsc_cgc_pll2_enable.
Postcondition
On success USBCKCR is sourced from PLL2P at 48 MHz.
On failure no register state was mutated.
TrustZone:
NS->S boundary via cmse_nonsecure_entry. Argument-less call.
Note
Thread-safe: serialised by the secure CGC driver.
Since
0.1.0

Definition at line 90 of file ra8_nsc_cgc.c.

References ra8_cgc_usbfs_clock_enable(), and RA8_NSC_VENEER.

Referenced by ns_exercise_veneers().

Variable Documentation

◆ s_tag

const char* s_tag = "NSCCGC"
static

Logging tag for the CGC veneers.

Note
File-scope only.
Since
0.1.0

Definition at line 35 of file ra8_nsc_cgc.c.