2b68134925
- Strip the perf-trace debug instrumentation (dbg_* counters + HWSUB/rkopnu-trace dev_err); it served its purpose (proved the drm_sched glue is ~3% of a submit). No functional change. - README.md: full build+setup guide (kernel requirements, DT enablement, rocket blacklist, out-of-tree build, librknnrt + rk-llama.cpp rknpu2 userspace, perf notes, limitations). - dt/rk3588-npu-enable.dtso: the necessary DT patch -- mainline ships the RKNN cores + IOMMUs status=disabled; this enables them + OPP table (example board: CoolPi CM5 GenBook; supplies are board-specific). - config/rkopnu.config: kernel config fragment (DRM_ACCEL etc.). - LICENSE: GPL-2.0. A third party can now recreate the mainline-NPU stack from this repo alone.
76 lines
2.0 KiB
C
76 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright 2024-2025 Tomeu Vizoso <tomeu@tomeuvizoso.net> */
|
|
|
|
#ifndef __ROCKET_CORE_H__
|
|
#define __ROCKET_CORE_H__
|
|
|
|
#include <drm/gpu_scheduler.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/io.h>
|
|
#include <linux/mutex_types.h>
|
|
#include <linux/reset.h>
|
|
|
|
#include "rocket_registers.h"
|
|
|
|
#define rocket_pc_readl(core, reg) \
|
|
readl((core)->pc_iomem + (REG_PC_##reg))
|
|
#define rocket_pc_writel(core, reg, value) \
|
|
writel(value, (core)->pc_iomem + (REG_PC_##reg))
|
|
|
|
#define rocket_cna_readl(core, reg) \
|
|
readl((core)->cna_iomem + (REG_CNA_##reg) - REG_CNA_S_STATUS)
|
|
#define rocket_cna_writel(core, reg, value) \
|
|
writel(value, (core)->cna_iomem + (REG_CNA_##reg) - REG_CNA_S_STATUS)
|
|
|
|
#define rocket_core_readl(core, reg) \
|
|
readl((core)->core_iomem + (REG_CORE_##reg) - REG_CORE_S_STATUS)
|
|
#define rocket_core_writel(core, reg, value) \
|
|
writel(value, (core)->core_iomem + (REG_CORE_##reg) - REG_CORE_S_STATUS)
|
|
|
|
struct rocket_iommu_domain;
|
|
|
|
struct rocket_core {
|
|
struct device *dev;
|
|
struct rocket_device *rdev;
|
|
unsigned int index;
|
|
|
|
int irq;
|
|
void __iomem *pc_iomem;
|
|
void __iomem *cna_iomem;
|
|
void __iomem *core_iomem;
|
|
struct clk_bulk_data clks[4];
|
|
struct reset_control_bulk_data resets[2];
|
|
|
|
struct iommu_group *iommu_group;
|
|
struct rocket_iommu_domain *attached_domain; /* rkopnu: keep attached across jobs */
|
|
|
|
/*
|
|
* struct device for this core's rockchip-iommu (looked up via the
|
|
* "iommus" DT phandle). Used only to poll for its runtime-PM suspend
|
|
* completion when the whole NPU power unit goes idle; see
|
|
* rocket_device_pm_put() in rocket_device.c.
|
|
*/
|
|
struct device *iommu_dev;
|
|
|
|
struct mutex job_lock;
|
|
struct rocket_job *in_flight_job;
|
|
|
|
spinlock_t fence_lock;
|
|
|
|
struct {
|
|
struct workqueue_struct *wq;
|
|
struct work_struct work;
|
|
atomic_t pending;
|
|
} reset;
|
|
|
|
struct drm_gpu_scheduler sched;
|
|
u64 fence_context;
|
|
u64 emit_seqno;
|
|
};
|
|
|
|
int rocket_core_init(struct rocket_core *core);
|
|
void rocket_core_fini(struct rocket_core *core);
|
|
void rocket_core_reset(struct rocket_core *core);
|
|
|
|
#endif
|