|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
MIPI CSI-2 receiver HAL driver – interrupt path and per-VC framing. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_hal_internal.h"#include "ra8_log.h"#include "ra8_mipi_csi.h"#include "ra8_mipi_csi_regs.h"#include "ra8_mstp.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_mipi_csi_irq_intern_t : uint16_t { k_ra8_mipi_csi_vc_invalid_idx = 0xFFU } |
| Internal limits used by this translation unit only. More... | |
Functions | |
| ra8_err_t | ra8_mipi_csi_attach_handler (ra8_mipi_csi_event_fn_t fn, void *ctx) |
| Attach the module-level CSI event callback. | |
| ra8_err_t | ra8_mipi_csi_attach_dl_handler (ra8_mipi_csi_dl_event_fn_t fn, void *ctx) |
| Attach the per-data-lane callback (MIPI CSI DL vector). | |
| ra8_err_t | ra8_mipi_csi_attach_vc_handler (ra8_mipi_csi_vc_event_fn_t fn, void *ctx) |
| Attach the per-VC callback (MIPI CSI VC vector). | |
| ra8_err_t | ra8_mipi_csi_attach_pm_handler (ra8_mipi_csi_pm_event_fn_t fn, void *ctx) |
| Attach the power-management callback (MIPI CSI PM vector). | |
| ra8_err_t | ra8_mipi_csi_attach_short_packet_handler (ra8_mipi_csi_short_event_fn_t fn, void *ctx) |
| Attach the short-packet FIFO callback (MIPI CSI GST vector). | |
| void | ra8_mipi_csi_dispatch (void) |
| ISR-side dispatcher for the receive vector. | |
| void | ra8_mipi_csi_dispatch_dl (void) |
| ISR-side dispatcher for the data-lane vector. | |
| void | ra8_mipi_csi_dispatch_vc (void) |
| ISR-side dispatcher for the per-VC vector. | |
| void | ra8_mipi_csi_dispatch_pm (void) |
| ISR-side dispatcher for the power-management vector. | |
| void | ra8_mipi_csi_dispatch_short_packet (void) |
| ISR-side dispatcher for the generic-short-packet vector. | |
| void | priv_ra8_mipi_csi_detach_all_handlers (void) |
| Detach every MIPI CSI-2 receiver callback (module / data-lane / virtual-channel / power-management / short-packet). | |
| static ra8_err_t | internal_format_to_bit (ra8_mipi_csi_data_format_t format, bool *is_high, uint32_t *bit) |
| static void | internal_recompute_dt_filter (void) |
| ra8_err_t | ra8_mipi_csi_set_virtual_channels (uint16_t vc_mask) |
| Filter which CSI-2 virtual channels the receiver will surface. | |
| ra8_err_t | ra8_mipi_csi_set_data_format (uint8_t vc, ra8_mipi_csi_data_format_t format) |
| Select the CSI-2 payload format the receiver should accept on a specific virtual channel. | |
| ra8_err_t | ra8_mipi_csi_attach_error_handler (ra8_mipi_csi_error_fn_t fn, void *ctx) |
| Register a callback invoked on ECC / CRC error reports. | |
Variables | |
| static const char * | s_tag = "MIPI_CSI" |
| Log tag prefix used by every ra8_log_* call below. | |
| static ra8_mipi_csi_event_fn_t | s_mipi_csi_fn |
| Currently-attached receive event callback. | |
| static void * | s_mipi_csi_ctx |
| Caller context forwarded to the receive event callback. | |
| static ra8_mipi_csi_dl_event_fn_t | s_mipi_csi_dl_fn |
| Currently-attached data-lane callback. | |
| static void * | s_mipi_csi_dl_ctx |
| Caller context forwarded to the data-lane callback. | |
| static ra8_mipi_csi_vc_event_fn_t | s_mipi_csi_vc_fn |
| Currently-attached per-VC callback. | |
| static void * | s_mipi_csi_vc_ctx |
| Caller context forwarded to the per-VC callback. | |
| static ra8_mipi_csi_pm_event_fn_t | s_mipi_csi_pm_fn |
| Currently-attached power-management callback. | |
| static void * | s_mipi_csi_pm_ctx |
| Caller context forwarded to the PM callback. | |
| static ra8_mipi_csi_short_event_fn_t | s_mipi_csi_gst_fn |
| Currently-attached short-packet FIFO callback. | |
| static void * | s_mipi_csi_gst_ctx |
| Caller context forwarded to the short-packet callback. | |
| static ra8_mipi_csi_error_fn_t | s_mipi_csi_err_fn |
| Callback invoked from dispatch_vc when an ECC/CRC error is decoded out of a VCST snapshot. | |
| static void * | s_mipi_csi_err_ctx |
| Caller context forwarded to the error callback. | |
| static uint8_t | s_mipi_csi_vc_format [k_ra8_mipi_csi_vc_count] |
| Software shadow of the per-VC payload format selection published by ra8_mipi_csi_set_data_format. | |
| static uint32_t | s_mipi_csi_vcie_saved [k_ra8_mipi_csi_vc_count] |
| Snapshot of VCIE(M) at the time the last ra8_mipi_csi_set_virtual_channels call masked it off. | |
MIPI CSI-2 receiver HAL driver – interrupt path and per-VC framing.
Companion translation unit to ra8_mipi_csi.c. Owns the interrupt-driven callback surface of the RA8D2 MIPI CSI-2 receiver: the attach-handler registration functions, the module / data-lane / virtual-channel / power-management / short-packet dispatchers, and the per-VC framing helpers (data-format shadow + error reporting) from HUM Ch 66 ("MIPI CSI Interface" p 3935-3972).
All the mutable callback function-pointer and context statics, plus the per-VC format shadow and saved-VCIE arrays, live here. The lifecycle code in ra8_mipi_csi.c detaches every callback through the promoted priv_ra8_mipi_csi_detach_all_handlers helper so that the mutable state stays owned by a single translation unit.
Every register access carries a HUM Ch 66 citation immediately above the access, per project policy.
Definition in file ra8_mipi_csi_irq.c.
| enum ra8_mipi_csi_irq_intern_t : uint16_t |
Internal limits used by this translation unit only.
k_ra8_mipi_csi_vc_invalid_idx is the sentinel VC id forwarded to the per-VC callback when reporting the "generic" (non-VC-attributable) MLF/ECD error aggregate.
| Enumerator | |
|---|---|
| k_ra8_mipi_csi_vc_invalid_idx | Sentinel for "generic" event. |
Definition at line 58 of file ra8_mipi_csi_irq.c.
|
static |
Definition at line 383 of file ra8_mipi_csi_irq.c.
References k_ra8_err_invalid_arg, k_ra8_mipi_csi_dteh_raw8_mask, k_ra8_mipi_csi_dteh_rgb888_mask, k_ra8_mipi_csi_dtel_yuv422_10_mask, k_ra8_mipi_csi_dtel_yuv422_8_mask, k_ra8_mipi_csi_format_off, k_ra8_mipi_csi_format_raw10, k_ra8_mipi_csi_format_raw8, k_ra8_mipi_csi_format_rgb888, k_ra8_mipi_csi_format_yuv420, k_ra8_mipi_csi_format_yuv422_10, k_ra8_mipi_csi_format_yuv422_8, and k_ra8_ok.
Referenced by internal_recompute_dt_filter(), and ra8_mipi_csi_set_data_format().
|
static |
Definition at line 422 of file ra8_mipi_csi_irq.c.
References internal_format_to_bit(), k_ra8_mipi_csi_off_dteh, k_ra8_mipi_csi_off_dtel, k_ra8_mipi_csi_vc_count, ra8_mipi_csi_reg32(), and s_mipi_csi_vc_format.
Referenced by ra8_mipi_csi_set_data_format().
| void priv_ra8_mipi_csi_detach_all_handlers | ( | void | ) |
Detach every MIPI CSI-2 receiver callback (module / data-lane / virtual-channel / power-management / short-packet).
Clears the ten callback function-pointer / context statics owned by ra8_mipi_csi_irq.c back to nullptr. Invoked by ra8_mipi_csi_deinit during teardown so that no stale callback can fire after the receiver has been gated. The per-VC error callback is left untouched, mirroring the pre-split ra8_mipi_csi_deinit behaviour.
Definition at line 361 of file ra8_mipi_csi_irq.c.
References s_mipi_csi_ctx, s_mipi_csi_dl_ctx, s_mipi_csi_dl_fn, s_mipi_csi_fn, s_mipi_csi_gst_ctx, s_mipi_csi_gst_fn, s_mipi_csi_pm_ctx, s_mipi_csi_pm_fn, s_mipi_csi_vc_ctx, and s_mipi_csi_vc_fn.
Referenced by ra8_mipi_csi_deinit().
|
nodiscard |
Attach the per-data-lane callback (MIPI CSI DL vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_dl. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 199 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_dl_ctx, and s_mipi_csi_dl_fn.
|
nodiscard |
Register a callback invoked on ECC / CRC error reports.
The CSI VC dispatcher already surfaces VCST contents. This helper filters those events down to the ECC + CRC error subset and decodes them into a ra8_mipi_csi_error_report_t for the caller. Pass fn = nullptr to detach.
| [in] | fn | Callback to invoke (or NULL to detach). |
| [in] | ctx | Caller-owned context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 489 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_err_ctx, and s_mipi_csi_err_fn.
|
nodiscard |
Attach the module-level CSI event callback.
Attach the receive-status callback (MIPI CSI RX vector).
Stores the supplied callback and opaque context for later invocation by ra8_mipi_csi_dispatch when a module-level event fires.
| [in] | fn | Event-callback function pointer (NULL to detach). |
| [in] | ctx | Opaque context passed back to the callback. |
| k_ra8_ok | Always returned in the current implementation. |
Definition at line 192 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_ctx, and s_mipi_csi_fn.
|
nodiscard |
Attach the power-management callback (MIPI CSI PM vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_pm. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 213 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_pm_ctx, and s_mipi_csi_pm_fn.
|
nodiscard |
Attach the short-packet FIFO callback (MIPI CSI GST vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_short_packet. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 220 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_gst_ctx, and s_mipi_csi_gst_fn.
|
nodiscard |
Attach the per-VC callback (MIPI CSI VC vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_vc. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 206 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_vc_ctx, and s_mipi_csi_vc_fn.
| void ra8_mipi_csi_dispatch | ( | void | ) |
ISR-side dispatcher for the receive vector.
Designed to be called from the wired-up MIPI CSI receive ISR (mipi_csi_rx_isr in the FSP layout). Reads RXST once, writes RACTDETC to RXSC to clear the sticky detect bit, then forwards the RXST snapshot to the registered callback.
Definition at line 228 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_off_rxsc, k_ra8_mipi_csi_off_rxst, k_ra8_mipi_csi_rxsc_ractdetc_mask, ra8_mipi_csi_reg32(), s_mipi_csi_ctx, and s_mipi_csi_fn.
| void ra8_mipi_csi_dispatch_dl | ( | void | ) |
ISR-side dispatcher for the data-lane vector.
Reads MIST + DLST0 + DLST1, W1C-clears DLSC0/DLSC1 (preserving the RO ULP bit), and invokes the data-lane callback once per lane that showed up in MIST.
Definition at line 244 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_dlsc_all_mask, k_ra8_mipi_csi_mist_dl0s_mask, k_ra8_mipi_csi_mist_dl1s_mask, k_ra8_mipi_csi_off_dlsc0, k_ra8_mipi_csi_off_dlsc1, k_ra8_mipi_csi_off_dlst0, k_ra8_mipi_csi_off_dlst1, k_ra8_mipi_csi_off_mist, ra8_mipi_csi_reg32(), s_mipi_csi_dl_ctx, and s_mipi_csi_dl_fn.
| void ra8_mipi_csi_dispatch_pm | ( | void | ) |
ISR-side dispatcher for the power-management vector.
Reads PMST, W1C-clears the lower 8 bits via PMSC, then invokes the PM callback.
Definition at line 330 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_off_pmsc, k_ra8_mipi_csi_off_pmst, k_ra8_mipi_csi_pmst_w1c_mask, ra8_mipi_csi_reg32(), s_mipi_csi_pm_ctx, and s_mipi_csi_pm_fn.
| void ra8_mipi_csi_dispatch_short_packet | ( | void | ) |
ISR-side dispatcher for the generic-short-packet vector.
Reads GSST, W1C-clears GOV via GSSC, then invokes the GST callback. The handler is expected to drain the FIFO via ra8_mipi_csi_read_short_packet.
Definition at line 346 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_gssc_govc_mask, k_ra8_mipi_csi_off_gssc, k_ra8_mipi_csi_off_gsst, ra8_mipi_csi_reg32(), s_mipi_csi_gst_ctx, and s_mipi_csi_gst_fn.
| void ra8_mipi_csi_dispatch_vc | ( | void | ) |
ISR-side dispatcher for the per-VC vector.
Reads MIST, then for every VC bit that is set walks the per-channel registers, clears each VCSC(M), and invokes the per-VC callback. Generic errors (MLF + ECD) are accumulated and delivered as a final callback with vc = 0xFF.
Definition at line 273 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_mist_vc_mask, k_ra8_mipi_csi_mist_vc_shift, k_ra8_mipi_csi_off_mist, k_ra8_mipi_csi_off_vcsc0, k_ra8_mipi_csi_off_vcst0, k_ra8_mipi_csi_vc_count, k_ra8_mipi_csi_vc_invalid_idx, k_ra8_mipi_csi_vcsc_per_vc_mask, k_ra8_mipi_csi_vcst_crc_mask, k_ra8_mipi_csi_vcst_ecc_mask, k_ra8_mipi_csi_vcst_ecd_mask, k_ra8_mipi_csi_vcst_generic_err_mask, ra8_mipi_csi_reg32(), ra8_mipi_csi_vc_off(), s_mipi_csi_err_ctx, s_mipi_csi_err_fn, s_mipi_csi_vc_ctx, and s_mipi_csi_vc_fn.
|
nodiscard |
Select the CSI-2 payload format the receiver should accept on a specific virtual channel.
The hardware filter (DTEL/DTEH) is global across virtual channels – selecting a format on one VC therefore enables the matching DT bit for the entire receiver. The driver records the per-VC selection in a software shadow so a subsequent call with k_ra8_mipi_csi_format_off can re-compute the union and clear the DT bit if no other VC still wants it. HUM Ch 66.3.10/66.3.11 pp 3943-3944.
| [in] | vc | Virtual channel index (0..15). |
| [in] | format | Payload format to accept (or _off to disable). |
| k_ra8_ok | Filter updated. |
| k_ra8_err_invalid_arg | vc > 15 or unknown format value. |
Definition at line 473 of file ra8_mipi_csi_irq.c.
References internal_format_to_bit(), internal_recompute_dt_filter(), k_ra8_err_invalid_arg, k_ra8_mipi_csi_vc_count, k_ra8_ok, and s_mipi_csi_vc_format.
|
nodiscard |
Filter which CSI-2 virtual channels the receiver will surface.
Each bit i of vc_mask enables VCi (i = 0..15). The driver disables VCIE on every channel whose bit is clear (so spurious traffic does not raise IRQs) and restores the previous IRQ mask on channels that are re-enabled. HUM Ch 66.3.20 "VCIE(M)" p 3952.
| [in] | vc_mask | Bitmap of accepted virtual channels (bit 0 = VC0). |
| k_ra8_ok | VCIE updated for every channel. |
| k_ra8_err_invalid_arg | vc_mask == 0 (would silence the receiver). |
Definition at line 444 of file ra8_mipi_csi_irq.c.
References k_ra8_err_invalid_arg, k_ra8_mipi_csi_off_vcie0, k_ra8_mipi_csi_vc_count, k_ra8_ok, ra8_log_error, ra8_mipi_csi_reg32(), ra8_mipi_csi_vc_off(), s_mipi_csi_vcie_saved, and s_tag.
|
static |
Caller context forwarded to the receive event callback.
Definition at line 74 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_handler(), and ra8_mipi_csi_dispatch().
|
static |
Caller context forwarded to the data-lane callback.
Definition at line 88 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_dl_handler(), and ra8_mipi_csi_dispatch_dl().
|
static |
Currently-attached data-lane callback.
Definition at line 81 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_dl_handler(), and ra8_mipi_csi_dispatch_dl().
|
static |
Caller context forwarded to the error callback.
Definition at line 149 of file ra8_mipi_csi_irq.c.
Referenced by ra8_mipi_csi_attach_error_handler(), and ra8_mipi_csi_dispatch_vc().
|
static |
Callback invoked from dispatch_vc when an ECC/CRC error is decoded out of a VCST snapshot.
Definition at line 141 of file ra8_mipi_csi_irq.c.
Referenced by ra8_mipi_csi_attach_error_handler(), and ra8_mipi_csi_dispatch_vc().
|
static |
Currently-attached receive event callback.
Definition at line 67 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_handler(), and ra8_mipi_csi_dispatch().
|
static |
Caller context forwarded to the short-packet callback.
Definition at line 132 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_short_packet_handler(), and ra8_mipi_csi_dispatch_short_packet().
|
static |
Currently-attached short-packet FIFO callback.
Definition at line 124 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_short_packet_handler(), and ra8_mipi_csi_dispatch_short_packet().
|
static |
Caller context forwarded to the PM callback.
Definition at line 116 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_pm_handler(), and ra8_mipi_csi_dispatch_pm().
|
static |
Currently-attached power-management callback.
Definition at line 109 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_pm_handler(), and ra8_mipi_csi_dispatch_pm().
|
static |
Caller context forwarded to the per-VC callback.
Definition at line 102 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_vc_handler(), and ra8_mipi_csi_dispatch_vc().
|
static |
Currently-attached per-VC callback.
Definition at line 95 of file ra8_mipi_csi_irq.c.
Referenced by priv_ra8_mipi_csi_detach_all_handlers(), ra8_mipi_csi_attach_vc_handler(), and ra8_mipi_csi_dispatch_vc().
|
static |
Software shadow of the per-VC payload format selection published by ra8_mipi_csi_set_data_format.
Definition at line 157 of file ra8_mipi_csi_irq.c.
Referenced by internal_recompute_dt_filter(), and ra8_mipi_csi_set_data_format().
|
static |
Snapshot of VCIE(M) at the time the last ra8_mipi_csi_set_virtual_channels call masked it off.
Restored when the channel is re-enabled.
Definition at line 165 of file ra8_mipi_csi_irq.c.
Referenced by ra8_mipi_csi_set_virtual_channels().
|
static |
Log tag prefix used by every ra8_log_* call below.
Definition at line 47 of file ra8_mipi_csi_irq.c.