Expand description
Minimal TPU device layer for SG2002.
Bare-metal, OS-agnostic TPU driver for the CVITEK SG2002 SoC.
§Usage
ⓘ
use tpu_sg2002::{TpuDevice, TpuConfig, KernelFns, LogLevel, TimeStamp};
use core::ptr::NonNull;
struct MyKernelFns;
impl KernelFns for MyKernelFns {
fn sleep_ms(&self, ms: u32) { /* ... */ }
fn now_us(&self) -> TimeStamp { /* ... */ }
fn log(&self, level: LogLevel, msg: &str) { /* ... */ }
}
let tdma_base = NonNull::new(0x0C00_0000 as *mut u8).unwrap();
let tiu_base = NonNull::new(0x0C01_0000 as *mut u8).unwrap();
let mut tpu = TpuDevice::new(tdma_base, tiu_base, TpuConfig::default(), MyKernelFns);
tpu.platform_init().expect("TPU init failed");Re-exports§
pub use platform::TdmaReg;pub use platform::TpuRegBackup;pub use platform::TdmaSyncStatus;pub use platform::TiuCtrlStatus;pub use platform::TIMEOUT_US;pub use pmu::TpuPmu;pub use pmu::TpuPmuEvent;pub use pmu::PmuSummary;pub use registers::TiuLaneNum;
Modules§
- ioctrl
- IOCTL argument structures matching
cvi_tpu_ioctl.h. - platform
- TPU Platform abstraction layer for SG2002.
- pmu
- TPU Performance Monitoring Unit (PMU) for SG2002.
- registers
- Hardware register definitions for the SG2002 TPU.
Structs§
- CpuSync
Desc - CPU sync descriptor embedded in command buffers.
- DmaHeader
- DMA buffer header used by the TPU firmware.
- Dmabuf
View - Borrowed view of a TPU command DMA buffer.
- TpuConfig
- TPU device configuration.
- TpuDevice
- TPU device handle.
- TpuTdma
PioInfo - TDMA PIO submission info.
Enums§
Traits§
- Kernel
Fns - Kernel functions required by the TPU device layer.
Functions§
- parse_
dmabuf_ ⚠view - Parse a TPU command DMA buffer from a raw CPU-accessible pointer.