39static const char*
s_tag =
"ETHGPT";
82typedef enum : uint32_t {
194 const uint64_t tiv = (scaled + half) / (uint64_t)clk_hz;
195 if (tiv > (uint64_t)UINT32_MAX) {
198 *out_tiv = (uint32_t)tiv;
283 *out_enabled = ((tmec >> (uint32_t)timer) & 1U) != 0U;
345 const uint64_t sec_lo = (uint64_t)reg->
PTPGPTPTMM;
364 const uint64_t lo = (uint64_t)reg->
PTPAVTPTML;
367 const uint64_t hi = (uint64_t)reg->
PTPAVTPTMU;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_HW_REGISTER_ACCESS
Mark an MMIO accessor function (returns volatile register pointer).
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_VALIDATE_INIT(initialized, tag, message)
Precondition: module must be initialized.
#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_out_of_range
Sensor or peripheral output out of valid range.
@ 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.
ra8_err_t ra8_eth_gptp_timer_disable(ra8_gptp_timer_idx_t timer)
Stop one timer unit (PTPTMDC.TDq).
ra8_err_t ra8_eth_gptp_timer_is_enabled(ra8_gptp_timer_idx_t timer, bool *out_enabled)
Report whether one timer unit is enabled.
ra8_err_t ra8_eth_gptp_get_increment(ra8_gptp_timer_idx_t timer, uint32_t *out_tiv)
Read one timer unit's increment register PTPTIVCt.
static volatile r_gptp_timer_regs_t * internal_timer(ra8_gptp_timer_idx_t timer)
Point at one timer unit's register block.
ra8_err_t ra8_eth_gptp_ip_version(uint32_t *out_version)
Read the read-only PTPIPV IP-version word.
static bool s_gptp_configured
True once ra8_eth_gptp_init has programmed the block.
ra8_err_t ra8_eth_gptp_tiv_from_hz(uint32_t clk_hz, uint32_t *out_tiv)
Derive PTPTIVCt.TIV from a clk frequency.
ra8_err_t ra8_eth_gptp_timer_enable(ra8_gptp_timer_idx_t timer)
Start one timer unit (PTPTMEC.TEq).
static void internal_stop_all(void)
Stop every timer unit in the block.
ra8_err_t ra8_eth_gptp_enter_stop(void)
Stop both timers and assert the ESWM module-stop gate.
ra8_err_t ra8_eth_gptp_get_time(ra8_gptp_timer_idx_t timer, uint64_t *out_sec, uint32_t *out_nsec)
Read one timer unit's 78-bit GPTP time.
ra8_err_t ra8_eth_gptp_set_offset(ra8_gptp_timer_idx_t timer, uint64_t sec, uint32_t nsec)
Load one timer unit's additive 78-bit offset.
gptp_field_t
Bit widths, shifts and masks of the GPTP timer registers.
@ k_gptp_subns_shift
5.27 fixed-point scale of TIV.
@ k_gptp_mask_nsec
Mask for GPTPL / TOVL [29:0].
@ k_gptp_shift_sec_u
Seconds upper part starts at 2^32.
@ k_gptp_round_half
Round-to-nearest divisor for TIV.
@ k_gptp_mask_sec_u
Mask for GPTPU / TOVU [15:0].
static void internal_write_offset(ra8_gptp_timer_idx_t timer, uint64_t sec, uint32_t nsec)
Write the 78-bit offset of one timer unit in the mandated order.
ra8_err_t ra8_eth_gptp_get_avtp_ns(ra8_gptp_timer_idx_t timer, uint64_t *out_ns)
Read one timer unit's 64-bit AVTP nanosecond counter.
static void internal_stop(ra8_gptp_timer_idx_t timer)
Stop one timer unit without validating its index.
ra8_err_t ra8_eth_gptp_set_increment(ra8_gptp_timer_idx_t timer, uint32_t tiv)
Write one timer unit's increment register PTPTIVCt.
ra8_err_t ra8_eth_gptp_deinit(void)
Stop both timers, clear their configuration and gate the block off.
ra8_err_t ra8_eth_gptp_exit_stop(void)
Release the ESWM module-stop gate again.
ra8_err_t ra8_eth_gptp_init(const ra8_eth_gptp_cfg_t *cfg)
Power up the GPTP block and programme both timers' increment.
Ethernet Generic PTP Timer (GPTP) driver – HUM Ch 35.
@ k_ra8_gptp_sec_max
Largest 48-bit seconds value.
@ k_ra8_gptp_ns_per_sec
Nanoseconds in one second.
@ k_ra8_gptp_nsec_max
Largest legal PTPTOVCtL.TOVL.
Ethernet controller base addresses for the Renesas RA8D2.
ra8_gptp_timer_idx_t
GPTP timer instance index (HUM Table 35.3 lists t = 0, 1).
@ k_ra8_gptp_timer_count
Number of timer units on this part.
static volatile r_gptp_regs_t * ra8_gptp(void)
Get pointer to the GPTP register block.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
Module Stop Control (MSTP) register layout for the Renesas RA8D2.
@ k_ra8_mstp_eswm
MSTPC30 ESWM.
volatile r_gptp_timer_regs_t TIMER[k_ra8_gptp_timer_count]
+0x0020 + 0x40 x t Per-timer blocks.
volatile uint32_t PTPTMDC
+0x0014 Timer Disable Configuration.
volatile uint32_t PTPTMEC
+0x0010 Timer Enable Configuration.
volatile uint32_t PTPIPV
+0x0000 IP Version (read-only).
One GPTP timer unit's register block (HUM Ch 35.3.2 / 35.3.3).
volatile uint32_t PTPAVTPTMU
+0x24 AVTP Timer Monitoring U.
volatile uint32_t PTPAVTPTML
+0x20 AVTP Timer Monitoring L.
volatile uint32_t PTPGPTPTMU
+0x38 GPTP Timer Monitoring U.
volatile uint32_t PTPTOVCU
+0x18 Timer Offset Value Cfg U.
volatile uint32_t PTPTOVCM
+0x14 Timer Offset Value Cfg M.
volatile uint32_t PTPGPTPTMM
+0x34 GPTP Timer Monitoring M.
volatile uint32_t PTPTIVC
+0x00 Timer Increment Value Cfg.
volatile uint32_t PTPTOVCL
+0x10 Timer Offset Value Cfg L.
volatile uint32_t PTPGPTPTML
+0x30 GPTP Timer Monitoring L.
Static configuration for ra8_eth_gptp_init.
uint32_t clk_hz
ESWCLK frequency in Hz feeding the GPTP counter.