On Tuesday, 25 February 2025 08:55:47 Central European Summer Time Tomeu Vizoso wrote: > Add the bindings for the Neural Processing Unit IP from Rockchip. > > v2: > - Adapt to new node structure (one node per core, each with its own > IOMMU) > - Several misc. fixes from Sebastian Reichel > > Signed-off-by: Tomeu Vizoso <to...@tomeuvizoso.net> > Signed-off-by: Sebastian Reichel <sebastian.reic...@collabora.com> > --- > .../bindings/npu/rockchip,rknn-core.yaml | 152 > +++++++++++++++++++++ > 1 file changed, 152 insertions(+) > > diff --git a/Documentation/devicetree/bindings/npu/rockchip,rknn-core.yaml > b/Documentation/devicetree/bindings/npu/rockchip,rknn-core.yaml > new file mode 100644 > index > 0000000000000000000000000000000000000000..e8d0afe4a7d1c4f166cf13a9f4aa7c1901362a3f > --- /dev/null > +++ b/Documentation/devicetree/bindings/npu/rockchip,rknn-core.yaml > @@ -0,0 +1,152 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/npu/rockchip,rknn-core.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Neural Processing Unit IP from Rockchip > + > +maintainers: > + - Tomeu Vizoso <to...@tomeuvizoso.net> > + > +description: > + Rockchip IP for accelerating inference of neural networks, based on > NVIDIA's > + open source NVDLA IP. > + > +properties: > + $nodename: > + pattern: '^npu-core@[a-f0-9]+$' > + > + compatible: > + oneOf: > + - items: > + - enum: > + - rockchip,rk3588-rknn-core-top > + - const: rockchip,rknn-core-top > + - items: > + - enum: > + - rockchip,rk3588-rknn-core > + - const: rockchip,rknn-core > + > + reg: > + maxItems: 1
Hi Tomeu, as you probably know, RK3576 has quite a similar NPU. This is why I'm currently poking at this patch series. One of the differences I ran into was that the IOMMU of each NPU core now sits within the reg address space range of the core as described by the single reg item binding and assumed by the driver. This seemed weird to me at first, since I would've guessed the cores would be exactly the same, but I noticed that they kind of still are; the RK3588's NPU also has a "hole" between 0x2000 and 0x2fff on each core, which is where RK3576 put its IOMMU. This is some information I gleaned from the RK3588 TRM, specifically section 36.4.1 "Internal Address Mapping", which shows where each "part" of the NPU core has its address space. Right now we just represent this as a single reg item per core. I've played with the idea of splitting this up into the distinct ranges the TRM lists and giving each a reg-names entry, but this would require a major rework of the driver from what I can tell, including to the auto-generated register header. For now, my hack on RK3576 is to just ioremap the range defined by resource start to resource end inside rocket manually if I get -EBUSY trying to ioremap the resource proper. This is quite an ugly hack though, it means the IOMMU node still has its address overlapping with another node in the DT, and it also means we have an unavoidable error message printed into the kernel log. This is also what the vendor driver seems to do. What do you reckon is a reg setup in the binding that is both reasonable to implement in the driver while accurately describing the hardware? The RK3568, which uses a similar NPU design has the IOMMU at an offset of 0xb000 from the core's start of PC, so probably after any core specifics but before the global registers if I hazard a guess. For those without access to the TRM: splitting this up into multiple reg items per core precisely the way the TRM does it would result in no less than 10 reg items on RK3588, if I count correctly. Kind regards, Nicolas Frattaroli