sun55iw3: HDMI display pipeline (DE33/RCQ), PCIe/NVMe on U-Boot 2026.07 and board support (#10587)

* sunxi-7.2: add Sun55iw3 display patches (disabled for rework) and PCIe/NVMe U-Boot support

- Add Sun55iw3 HDMI display pipeline patches 7000-7005, SPI NOR enable
  and IOMMU fix to the normal sunxi-7.2 series (no separate family).
  Patches that conflict with the current series (7000,7001,7002,7004)
  are added disabled (-) for now to allow a clean build; they will
  be re-enabled and rebased via the kernel-patch workflow.
- Add U-Boot v2026.07 PCIe/NVMe support for sun55i-a523 (DWC glue,
  PHY, clocks, SPI, NVMe boot target - NVMe before network).
- Series.conf updated with ordered entries; board configs remain
  standard (no KERNELPATCHDIR override, no additional family).

The series now builds cleanly for a full image; the kernel tree can be
inspected after 'compile.sh build', then the disabled patches can be
fixed in the worktree and regenerated with 'kernel-patch' /
'rewrite-kernel-patches' / CREATE_PATCHES flow as suggested.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:glm-5.3-flash

* sunxi-7.2: enable Sun55iw3 display as single integrated patch

Collapse the previously disabled Sun55iw3 (A523/T527) DE33/RCQ HDMI
patches into one 7000-drm-sun55i-a523-hdmi.patch, based on the series
state, and enable it. Validated with a full radxa-cubie-a5e trixie edge
build; patching applies clean and the kernel compiles.

* sunxi-7.2: split A523 backports into 3 patches, enable e906 remoteproc, mark boards with video output

- Split the Sun55iw3 (A523/T527) work into three patches: 7000 drm/HDMI
  (12 files), 7001 cedrus video engine (4 files), 7002 clk + dts board
  configs (8 files); drop the stale 7000-drm-sun55i-a523-hdmi-v2.patch
  residue. series.conf points to the three active patches.
- Enable the e906 RISC-V remoteproc on radxa-cubie-a5e (mboxes,
  memory-region, memory-mappings) so remoteproc0/msgbox come up like on
  avaota-a1; validated BASE + 3 patches reproduce the FINAL tree and the
  cubie dtb compiles.
- Set HAS_VIDEO_OUTPUT=yes on radxa-cubie-a5e and avaota-a1 so the
  desktop image builds (interactive.sh forces BUILD_DESKTOP=no without it).
- h728/x96qpro+ and orangepi-4a dts tweaks included in 7002.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: reload overlay/cursor blender blocks on every flip (cursor invisible)

The v35x DE commits its datapath only through the RCQ, and flip-min
reloads just the fb-address shadow blocks on page flips. Xorg stages
the cursor plane (channel 8, pipe 2) *after* the initial full reload,
so its blender pipe stays disabled in hardware: the cursor layer is
live (ATTCTL=enabled) but the blender never composites it, hence a
working, moving, invisible X cursor.

Keep the primary UI channel (pipe 0) on the cheap fb-address-only
path, but reload the shared blender blocks plus the whole overlay/
cursor channel register files on every flip so their enable state,
position and blend mode reach the hardware.

Validated BASE + 7000/7001/7002/7003 applies cleanly and the resulting
sun55i_de.c matches the worktree fix.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: refine A523 dts/clk patch after review

- Restore upstream 2025 Arm Ltd copyright and add author attribution
  in the Cubie A5e device tree.
- Revert all regulator changes (cldo1 back to 1800mV, cldo3 to 3300mV,
  drop always-on/vin-supply/force-polyfase additions) so the three
  boards keep mainline regulator values.
- Move linux,cma under a /reserved-memory node on avaota (kept pinned
  with reg/alloc-ranges); qualify the orangepi-4a comment instead of
  claiming the pool is pinned, and mark its HDMI as untested.
- Drop the h728-x96qpro+ device tree changes (no active Armbian board).
- Fix the video-codec comment to reflect quirk_no_sram skipping the
  SRAM claim instead of the syscon no-op.
- Restore leds/common.h and function/color properties for the Cubie
  power/user LEDs.
- Add the Cubie A5e U-Boot board patches (defconfig + dts, PCIe/NVMe)
  that were missing from the branch and keep msdos partition layout
  (eGON overwrites GPT, issue #10647).

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: power Cubie A5e HDMI via hvcc-supply (reg_bldo3)

The Cubie A5e hdmi node relied on the AXP717 bldo3 being always-on to
power the HDMI PHY. After restoring upstream regulator values in the
previous commit, bldo3 is no longer forced on and the image lost video
on this board. Wire hvcc-supply = <&reg_bldo3> on the hdmi node (as the
Avaota does) so sun8i_dw_hdmi drives the LDO on enable instead.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: power Cubie A5e HDMI via hvcc-supply (reg_cldo1)

The Cubie A5e schematic feeds VCC18-HDMI from CLDO1_1V8 (reg_cldo1),
not BLDO3. Fix the hvcc-supply phandle so the sun8i_dw_hdmi driver
enables the correct 1.8 V rail at probe. Avaota A1 keeps reg_bldo3.

Refresh megous 0026 (sun4i clockevent zero-interval floor) for the
current vanilla 7.2.4 base: the min-delta raise (TIMER_SYNC_TICKS + 1)
is already upstream, so only the set_next_event floor hunk remains,
allowing the kernel patch series to apply on a clean worktree.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: force CLDO1/BLDO3/ALDO2 always-on for Cubie A5e HDMI PHY

Restore the regulator-always-on flags on reg_cldo1, reg_bldo3 and reg_aldo2
that were present in image 7.2.2 (the first one with working HDMI on Cubie
A5e) but were lost when upstream acted on the pmic. The sun8i_dw_hdmi PHY
needs these rails powered; with hvcc-supply pointing at reg_cldo1 video
comes up and stays up.

Also enable the previously-committed arm64-dts-sun55i-a527-cubie-a5e-
enable-spi-nor.patch in series.conf (it was never activated, so 7.2.4
lost /dev/mtd0). The 7002 cubie section was regenerated so it applies
cleanly on a trimmed vanilla tree.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: force Xorg SWcursor on sun55iw3 boards with video output

The DE33 RCQ backend stages the primary UI channel; the cursor plane
(channel 8, per-channel OVL/blender pipe) framebuffer fetch returns
black, so hardware cursors on those boards render invisible with a black
square around the pointer (the cursor still works). Install an Xorg
modesetting SWcursor config for every sun55iw3 board with
HAS_VIDEO_OUTPUT=yes (Cubie A5E, Avaota A1) until the channel-8 fetch
is fixed.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* Revert "sunxi-7.2: force Xorg SWcursor on sun55iw3 boards with video output"

This reverts commit 105fc55e98.

* sunxi-7.2: fix DE33 HDMI primary/cursor update path (RCQ backstop, phys7 cursor)

The v35x DE commits its datapath only through the RCQ and relies on the
TCON vblank IRQ to trigger the RCQ arm. On cursor-only atomic flips the
devices stays idle and the IRQ does not fire, so the staged cursor
pipeline never reaches the hardware (invisible cursor). Follow the
sun4i sibling drivers and drive the arm from a hrtimer backstop in
commit() when no vblank IRQ is outstanding.

Also avoid physical mixer channel 8: its per-channel OVL/blender
framebuffer fetch returns black regardless of configuration (VSU
passthrough and direct programming both reproduce it), so the X cursor
used to render as a black box. Map the DE logical channels as
{0,6,8,7} - cursor on phys7 - instead of the mainline {0,6,7,8}.

And reorder sun4i_crtc_atomic_disable to tear down the TCON before
disabling the vblank, matching sun4i-crtc teardown order.

Validated BASE + 7000..7004 apply cleanly; sun8i_mixer.c and
sun4i_crtc.c from the series match the working tree byte-for-byte, and
the HW cursor on phys7 tracks the mouse on Cubie A5e.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle

* sunxi-7.2: fix arm_sched race in the DE33 RCQ backstop (review fix)

CodeRabbit round 2. The blind spot was the scheduling check

    if (!hrtimer_active(&de->arm_timer))
        sun55i_de_schedule_arm(de);

hrtimer_active() stays true while the timer callback is running, so a
commit racing with sun55i_de_arm_timer() sees the hrtimer as active
even though the callback already decided not to re-arm (do_arm cleared
arm_pending) and will return HRTIMER_NORESTART: a staged cursor/overlay
update sits in arm_pending forever without a timer and never reaches
the hardware.

Track the arm state explicitly instead: de->arm_sched is set when the
hrtimer is queued (schedule_arm / vblank_quirk), cleared when the
callback runs, and re-set on retry. commit()/vblank_quirk() schedule on
!de->arm_sched, closing the lost-update race under arm_lock.

7003 regenerated as a fresh diff over the re-indexed 7000; the resulting
sun55i_de.c/.h are byte-identical to the build worktree (incl. the stale
{0,6,7,8} comment corrected to {0,6,8,7}) and both objects recompile
clean.

Other findings from the same review were evaluated and skipped with a
reason (see PR): pcie CFG0/CFG1 mirrors the vendor BSP layout (NVMe Gen2
boots on both boards); pcie probe region_count=2 matches the sunxi
dw-pcie pattern; iommu DMA32 constraint has no effect on these <4GiB
boards; NVMe boot-target order is deliberate (NVMe stays the LAST boot
target so SD/USB/eMMC are tried first).

* sunxi-7.2: wire orangepi-4a HDMI 1v8 rail (hvcc) and fix hunk count

VCC18-HDMI on orangepi-4a is fed by CLDO1 of the AXP717; the dw-hdmi
driver consumes the rail through hvcc-supply (sun8i_dw_hdmi.c). Wire it to
reg_cldo1 like cubie-a5e, so the 1.8V PHY supply is driven by the driver.
VDD09-HDMI (0.9V) comes from DCDC2 (vdd-gpu-sys), already regulator-always-on.

Adding the line bumped the &usbphy hunk's post-image by one; updated the
hunk count +519,17 -> +519,18 (git apply was silently dropping the trailing
+}; that closes &hdmi_out, producing an unterminated node).

Validated: the opi4a dts from the patch is byte-identical to the build
worktree and the sun55i-t527-orangepi-4a.dtb compiles clean.
HDMI on this board stays enabled for community testing.

* sunxi-7.2: align RGMII MAC delays of Cubie A5e and Avaota A1 to mainline

Both RGMII ports on the Cubie A5e (300/400) and the Avaota A1
(100/300 and 100/100) carried per-board MAC delays that deviated from
what upstream validates. Mainline (Orange Pi 4A, rgmii-id) uses MAC
tx 0 / rx 300 and saturates ~0.94 Gbps with no errors; the Orange Pi
4A was already aligned.

Set gmac0/gmac1 to tx 0 / rx 300 on both boards (gpio0 and gpio1 use
the allwinner,tx-delay-ps/allwinner,rx-delay-ps properties; gmac1 on
the mac variant uses tx-internal-delay-ps/rx-internal-delay-ps driven
by dwmac-sun55i). Both links verified at 1 Gbps on the Cubie A5e.

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Co-Authored-By: big pickle <big-pickle@users.noreply.github.com>

* sunxi-7.2: rework sun55i A523 DE33/HDMI driver for mainline API

Rebase the DE33/HDMI driver on the mainline RCQ backstop API
(.uses_rcq, guarded update/frontend paths, mixer IRQ quirk) and
re-enable 0039/0044 in the series. Build-tested on A523
(radxa-cubie-a5e) and regression-tested on H616 (orangepizero3).

* sunxi-7.2: split E906 remoteproc wiring out of 7002 into 7005

The 7002 clk-and-dts patch carried the cubie-a5e E906 RISC-V remoteproc
wiring (riscvsram0/1, e906_dram, vdev0 buf/vrings reservations plus the
&e906_rproc mbox/memory-mappings node) right next to the HDMI/display
pieces. Since the E906 firmware work lives in a separate tree, move that
block to a dedicated 7005 patch so 7002 stays display/HDMI-only.

Keep the linux,cma pin (DE fetch aperture) and the &de/&hdmi/&hdmi_out
pieces in 7002. msgbox already comes from the base dtsi, not 7002.

* sunxi-7.2: fix sun55i channel map regression and RCQ arm timing

The mainline-API rework re-enabled 0039, which removed the mixer .map[]
field and the phy_index plumbing, so UI planes are created with logical
channels (vi_num + i = 1..3) again. sun55i_de_layer_update still expected
physical channels 6..8 and silently rejected every UI plane: green
background, and once past the guard the cursor landed on phys 8, which
fetches black on this die.

Translate logical->phys inside sun55i_de_layer_update with the de352 map
{0, 6, 8, 7} (primary->6, overlay->8, cursor->7), so the cursor sits on
the working phys 7 and the broken phys 8 stays with the overlay Xorg
leaves unused. Verified on Avaota A1 (HDMI 1080p60): Xorg cursor renders
and follows the mouse, PORT2CHN mux reads 0xa980, cursor OVL staged at
phys 7 (AR24 64x64), phys 8 stays empty.

Also fix the RCQ arm timing, measured on the same board via /dev/mem
sampling (114944 samples): the TCON line counter runs RAW 0..vtotal, not
doubled, so tcon_line_double now defaults off; arm_target keeps the
vendor vbp + 3% math but is clamped to half the leading blanking (the
vendor's ~line-69 target at 1080p60 arms inside active video); mode_set
clears arm_sched after hrtimer_cancel (a canceled timer never would,
freezing the pipeline after a mode change); and the hrtimer callback
re-reads the beam position and defers instead of arming inside active
video. With 400 injected cursor moves the arms cluster at lines 20-21
(active starts at 41): no tearing.

Signed-off-by: Juan Sanchez <juanesf91@gmail.com>
Co-authored-by: opencode <noreply@opencode.ai>

* sunxi-7.2: rework sun55i msgbox and E906 remoteproc for upstream

Replace the msgbox and E906 remoteproc implementations with the
upstream-oriented rework: DT schema YAML bindings for both drivers
(allwinner,sun55i-a523-msgbox.yaml / allwinner,sun55i-a523-rproc.yaml),
msgbox with the ARM-block IRQ plus a 2ms poller fallback, and the E906
remoteproc on the standard mbox + reserved-memory virtio layout. Update
the e906 DT node, keep the cubie-a5e board wiring in 7005, and drop the
last E906 remnants from 7002.

Also refresh linux-sunxi64-edge.config for 7.2.6 and disable three stock
patches that no longer apply there (0088 and the sun4i-a10 PMU dts fix
are upstream, 0012 tps65185 hunk 7 context changed).

Verified on Avaota A1 with the 7.2.6 image and linux-image deb:
sun55i-msgbox 3003000.mailbox ready (12 channels, irq=20), remoteproc0
(7130000.rproc) available with the e906_dram@60000000 reservation; the
HDMI/cursor pipeline from the previous commit is unaffected.

Signed-off-by: Juan Sanchez <juanesf91@gmail.com>
Co-authored-by: opencode <noreply@opencode.ai>

* sunxi-7.2: address review findings on sun55i msgbox and E906 remoteproc

- dt-bindings: mailbox: drop 'interrupts' from required; the driver has
  an IRQ-less polling path, so the edge may be absent on some boards.
- remoteproc: sun55i_e906: on start failure, re-assert resets and
  disable the bus clock so we unwind cleanly instead of leaking.
- remoteproc: sun55i_e906: free the mbox channel before destroying its
  workqueue, both on rproc_add() failure and in remove(), so a pending
  rx callback cannot queue work on a destroyed workqueue.
- remoteproc: sun55i_e906: track pending virtqueue notifications in a
  bitmap guarded by a spinlock, so a vq notification arriving while work
  is already queued is no longer overwritten and lost.

Signed-off-by: Juan Sanchez <juanesf91@gmail.com>
Co-authored-by: opencode <noreply@opencode.ai>

* sunxi-7.2: series.conf: fix tabs on sun4i-drm patch entries

Use a single tab indent for the patches.drm/0032..0048 entries, matching
the rest of the file (they had spaces instead of tabs).

Signed-off-by: Juan Sanchez <juanesf91@gmail.com>
Co-authored-by: opencode <noreply@opencode.ai>

---------

Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Signed-off-by: Juan Sanchez <juanesf91@gmail.com>
Co-authored-by: big pickle <big-pickle@users.noreply.github.com>
Co-authored-by: opencode <noreply@opencode.ai>
This commit is contained in:
juanesf 2026-09-17 18:35:04 -03:00 • committed by GitHub
parent 9f94ef4577
commit 0648ff3c41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 13968 additions and 428 deletions

5
.gitignore vendored
View file

@ -31,5 +31,10 @@ ubuntu-*-cloudimg-console.log
Dockerfile
.dockerignore
# scratch validation trees
/scratch_verify/
/scratch_kcheck/
/scratch_patches/
# Runtime symlink created by extensions/seeed-rk.sh (points into cache/sources)
extensions/seeed_armbian_extension

View file

@ -10,7 +10,7 @@ OVERLAY_PREFIX="sun55i-t527"
KERNEL_TARGET="edge"
KERNEL_TEST_TARGET="edge"
BOOT_FDT_FILE="allwinner/sun55i-t527-avaota-a1.dtb"
HAS_VIDEO_OUTPUT="no"
HAS_VIDEO_OUTPUT="yes"
# Mainline U-Boot needs FAT boot + ext4 root
IMAGE_PARTITION_TABLE="msdos"

View file

@ -10,7 +10,15 @@ OVERLAY_PREFIX="sun55i-a527"
KERNEL_TARGET="current,edge"
KERNEL_TEST_TARGET="current,edge"
BOOT_FDT_FILE="sun55i-a527-cubie-a5e.dtb"
HAS_VIDEO_OUTPUT="no" # quoted so the build-list inventory (it parses only quoted values) sees it
HAS_VIDEO_OUTPUT="yes"
# GPT is overwritten by the eGON bootloader image at 0x2000 (issue #10647):
# use msdos partition table with the boot partition after the bootloader
IMAGE_PARTITION_TABLE="msdos"
BOOTFS_TYPE="fat"
BOOTSTART="8192"
BOOTSIZE="512"
ROOTSTART="1056768"
PACKAGE_LIST_BOARD="rfkill bluetooth bluez bluez-tools"

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,90 @@
diff --git a/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml b/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml
index 01f2afa02..05ecc664e 100644
--- a/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml
+++ b/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml
@@ -24,6 +24,7 @@ properties:
- allwinner,sun50i-a64-video-engine
- allwinner,sun50i-h5-video-engine
- allwinner,sun50i-h6-video-engine
+ - allwinner,sun55i-a523-video-engine
reg:
maxItems: 1
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 77d73c0d3..abf24d6a3 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -660,6 +660,22 @@ static const struct cedrus_variant sun50i_h616_cedrus_variant = {
.mod_rate = 600000000,
};
+/*
+ * A523 (sun55iw3) shares the H264/H265/MPEG2 register layout with the
+ * H6/D1 family; the per-frame register programming matches cedrus 1:1
+ * (see RE notes). VE module clock parent runs at 432 MHz like the D1.
+ * Start minimal: 8-bit H264/H265/MPEG2 only. VP8 and 10-bit HEVC not
+ * yet validated on this SoC.
+ */
+static const struct cedrus_variant sun55i_a523_cedrus_variant = {
+ .capabilities = CEDRUS_CAPABILITY_UNTILED |
+ CEDRUS_CAPABILITY_MPEG2_DEC |
+ CEDRUS_CAPABILITY_H264_DEC |
+ CEDRUS_CAPABILITY_H265_DEC,
+ .mod_rate = 432000000,
+ .quirk_no_sram = true,
+};
+
static const struct of_device_id cedrus_dt_match[] = {
{
.compatible = "allwinner,sun4i-a10-video-engine",
@@ -709,6 +725,10 @@ static const struct of_device_id cedrus_dt_match[] = {
.compatible = "allwinner,sun50i-h616-video-engine",
.data = &sun50i_h6_cedrus_variant,
},
+ {
+ .compatible = "allwinner,sun55i-a523-video-engine",
+ .data = &sun55i_a523_cedrus_variant,
+ },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, cedrus_dt_match);
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h
index 38f28f092..d2e038407 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
@@ -175,6 +175,13 @@ struct cedrus_dec_ops {
struct cedrus_variant {
unsigned int capabilities;
unsigned int mod_rate;
+ /*
+ * Newer SoCs (e.g. A523/sun55iw3) have no dedicated VE SRAM region to
+ * remap via the system-control block; the VE does physical DMA from
+ * the CMA pool with the IOMMU in bypass. Skip sunxi_sram_claim() for
+ * those, which would otherwise fail with -ENOENT (no allwinner,sram).
+ */
+ bool quirk_no_sram;
};
struct cedrus_dev {
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
index bb9bb6771..eb28cde49 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
@@ -289,11 +289,13 @@ int cedrus_hw_probe(struct cedrus_dev *dev)
return ret;
}
- ret = sunxi_sram_claim(dev->dev);
- if (ret) {
- dev_err(dev->dev, "Failed to claim SRAM\n");
+ if (!variant->quirk_no_sram) {
+ ret = sunxi_sram_claim(dev->dev);
+ if (ret) {
+ dev_err(dev->dev, "Failed to claim SRAM\n");
- goto err_mem;
+ goto err_mem;
+ }
}
dev->ahb_clk = devm_clk_get(dev->dev, "ahb");

View file

@ -0,0 +1,681 @@
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
index 3abbb16..ded3c24 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
@@ -3,6 +3,9 @@
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/clock/sun6i-rtc.h>
+#include <dt-bindings/clock/sun8i-de2.h>
+#include <dt-bindings/clock/sun8i-tcon-top.h>
+#include <dt-bindings/reset/sun8i-de2.h>
#include <dt-bindings/clock/sun55i-a523-ccu.h>
#include <dt-bindings/thermal/thermal.h>
#include <dt-bindings/clock/sun55i-a523-mcu-ccu.h>
@@ -19,6 +22,12 @@
#address-cells = <2>;
#size-cells = <2>;
+ de: display-engine {
+ compatible = "allwinner,sun50i-h6-display-engine";
+ allwinner,pipelines = <&mixer0>;
+ status = "disabled";
+ };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -147,6 +156,220 @@
status = "disabled";
};
+ /*
+ * Display pipeline (DE33 -> TCON-TOP -> TCON-TV -> DW-HDMI ->
+ * Inno HDMI PHY). Addresses from the vendor DTB; HDMI PHY split
+ * (controller@5520000 + phy@5530000) and the DE SRAM region are
+ * best-guesses pending hardware verification. Most nodes reuse
+ * the H6/H616 drivers via compatible fallbacks; only CLK_HDMI
+ * (TMDS) and the hdmi-phy variant were added for the A523.
+ */
+ bus@5000000 {
+ compatible = "allwinner,sun50i-h616-de33",
+ "allwinner,sun50i-a64-de2";
+ reg = <0x5000000 0x400000>;
+ allwinner,sram = <&de_sram 1>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges = <0 0x5000000 0x400000>;
+
+ display_clocks: clock@8000 {
+ compatible = "allwinner,sun50i-h616-de33-clk";
+ reg = <0x8000 0x100>;
+ clocks = <&ccu CLK_DE>, <&ccu CLK_BUS_DE>;
+ clock-names = "mod", "bus";
+ resets = <&ccu RST_BUS_DE>;
+ power-domains = <&pck600 PD_DE>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
+
+ mixer0: mixer@100000 {
+ compatible = "allwinner,sun55i-a523-de33-mixer-0";
+ reg = <0x100000 0x100000>,
+ <0x8100 0x40>,
+ <0x280000 0x20000>,
+ <0x8000 0x60>;
+ reg-names = "engine", "top", "display", "detop";
+ clocks = <&display_clocks CLK_BUS_MIXER0>,
+ <&display_clocks CLK_MIXER0>;
+ clock-names = "bus", "mod";
+ resets = <&display_clocks RST_MIXER0>;
+ power-domains = <&pck600 PD_DE>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ mixer0_out: port@1 {
+ reg = <1>;
+
+ mixer0_out_tcon_top_mixer0: endpoint {
+ remote-endpoint = <&tcon_top_mixer0_in_mixer0>;
+ };
+ };
+ };
+ };
+ };
+
+ tcon_top: tcon-top@5500000 {
+ compatible = "allwinner,sun50i-h6-tcon-top";
+ reg = <0x5500000 0x1000>;
+ clocks = <&ccu CLK_BUS_DISPLAY0_TOP>,
+ <&ccu CLK_TCON_TV0>;
+ clock-names = "bus", "tcon-tv0";
+ clock-output-names = "tcon-top-tv0";
+ resets = <&ccu RST_BUS_DISPLAY0_TOP>;
+ #clock-cells = <1>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ tcon_top_mixer0_in: port@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+
+ tcon_top_mixer0_in_mixer0: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&mixer0_out_tcon_top_mixer0>;
+ };
+ };
+
+ tcon_top_mixer0_out: port@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+
+ tcon_top_mixer0_out_tcon_tv0: endpoint@2 {
+ reg = <2>;
+ remote-endpoint = <&tcon_tv0_in_tcon_top_mixer0>;
+ };
+ };
+
+ tcon_top_hdmi_in: port@4 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <4>;
+
+ tcon_top_hdmi_in_tcon_tv0: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&tcon_tv0_out_tcon_top>;
+ };
+ };
+
+ tcon_top_hdmi_out: port@5 {
+ reg = <5>;
+
+ tcon_top_hdmi_out_hdmi: endpoint {
+ remote-endpoint = <&hdmi_in_tcon_top>;
+ };
+ };
+ };
+ };
+
+ tcon_tv0: lcd-controller@5503000 {
+ compatible = "allwinner,sun50i-h6-tcon-tv",
+ "allwinner,sun8i-r40-tcon-tv";
+ reg = <0x5503000 0x1000>;
+ interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_TCON_TV0>,
+ <&tcon_top CLK_TCON_TOP_TV0>;
+ clock-names = "ahb", "tcon-ch1";
+ resets = <&ccu RST_BUS_TCON_TV0>;
+ reset-names = "lcd";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ tcon_tv0_in: port@0 {
+ reg = <0>;
+
+ tcon_tv0_in_tcon_top_mixer0: endpoint {
+ remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>;
+ };
+ };
+
+ tcon_tv0_out: port@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+
+ tcon_tv0_out_tcon_top: endpoint@1 {
+ reg = <1>;
+ remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>;
+ };
+ };
+ };
+ };
+
+ hdmi: hdmi@5520000 {
+ compatible = "allwinner,sun55i-a523-dw-hdmi",
+ "allwinner,sun50i-h6-dw-hdmi";
+ reg = <0x5520000 0x10000>;
+ reg-io-width = <1>;
+ interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_HDMI>, <&ccu CLK_HDMI_24M>,
+ <&ccu CLK_HDMI>, <&ccu CLK_HDMI_CEC>;
+ clock-names = "iahb", "isfr", "tmds", "cec";
+ resets = <&ccu RST_BUS_HDMI_MAIN>;
+ reset-names = "ctrl";
+ power-domains = <&pck600 PD_VO0>;
+ phys = <&hdmi_phy>;
+ phy-names = "phy";
+ status = "disabled";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ hdmi_in: port@0 {
+ reg = <0>;
+
+ hdmi_in_tcon_top: endpoint {
+ remote-endpoint = <&tcon_top_hdmi_out_hdmi>;
+ };
+ };
+
+ hdmi_out: port@1 {
+ reg = <1>;
+ };
+ };
+ };
+
+ hdmi_phy: hdmi-phy@5530000 {
+ compatible = "allwinner,sun55i-a523-hdmi-phy",
+ "allwinner,sun50i-h616-hdmi-phy";
+ reg = <0x5530000 0x10000>;
+ clocks = <&ccu CLK_BUS_HDMI>, <&ccu CLK_HDMI_24M>;
+ clock-names = "bus", "mod";
+ resets = <&ccu RST_BUS_HDMI_SUB>;
+ reset-names = "phy";
+ power-domains = <&pck600 PD_VO0>;
+ #phy-cells = <0>;
+ };
+
+ video-codec@1c0e000 {
+ compatible = "allwinner,sun55i-a523-video-engine";
+ reg = <0x01c0e000 0x2000>;
+ interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>,
+ <&ccu CLK_MBUS_VE>;
+ clock-names = "ahb", "mod", "ram";
+ resets = <&ccu RST_BUS_VE>;
+/*
+ * Minimal bring-up: no iommus/allwinner,sram. The driver
+ * marks this variant quirk_no_sram and skips the SRAM
+ * claim, and the IOMMU is in bypass at reset so the VE
+ * does physical DMA from the CMA pool. Add
+ * iommus = <&iommu 3>;
+ * allwinner,sram = <&ve_sram 1>;
+ * once an IOMMU node + ve_sram region are wired up.
+ */
+ };
+
pio: pinctrl@2000000 {
compatible = "allwinner,sun55i-a523-pinctrl";
reg = <0x2000000 0x800>;
@@ -604,6 +827,13 @@
#address-cells = <1>;
#size-cells = <1>;
ranges;
+
+ /* DE (display engine) SRAM region claimed by the DE33 bus */
+ de_sram: sram-section@0 {
+ compatible = "allwinner,sun50i-h616-sram-c",
+ "allwinner,sun50i-a64-sram-c";
+ reg = <0x0000 0x1e000>;
+ };
};
dma: dma-controller@3002000 {
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
index b239d49..6bf3f96 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
// Copyright (C) 2025 Arm Ltd.
+// Author: piotr.oniszczuk@gmail.com
/dts-v1/;
@@ -13,6 +14,9 @@
compatible = "radxa,cubie-a5e", "allwinner,sun55i-a527";
aliases {
+ mmc0 = &mmc0;
+ mmc1 = &mmc1;
+ mmc2 = &mmc2;
ethernet0 = &gmac0;
ethernet1 = &gmac1;
serial0 = &uart0;
@@ -23,6 +27,44 @@
stdout-path = "serial0:115200n8";
};
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+
+ /*
+ * The display engine's layer DMA master has a limited fetch
+ * aperture and can only reach low DRAM (it reads the RCQ pool at
+ * ~0x43000000 but not 0x4b100000). The kernel's default CMA is
+ * high (~0xf0000000), so scanout fetches zeros (black). Pin CMA
+ * just above the kernel image (ends ~0x42c70000) and the RCQ
+ * pool (~0x43000000), below the dtb (~0x49ff6000).
+ */
+ linux,cma {
+ compatible = "shared-dma-pool";
+ reusable;
+ /* pin low: the DE fetch aperture only reaches DRAM below
+ * ~0x4b100000; stop at 0x48000000 to stay clear of the
+ * secmon@48000000/48100000 and vdev@4ae00000 no-map
+ * reservations (overlap hands out no-map pages -> oops) */
+ reg = <0x0 0x43000000 0x0 0x5000000>;
+ alloc-ranges = <0x0 0x43000000 0x0 0x5000000>;
+ size = <0x0 0x5000000>;
+ linux,cma-default;
+ };
+ };
+
+ hdmi-connector {
+ compatible = "hdmi-connector";
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
+
leds {
compatible = "gpio-leds";
@@ -38,6 +80,7 @@
function = LED_FUNCTION_ACTIVITY;
color = <LED_COLOR_ID_BLUE>;
gpios = <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */
+ linux,default-trigger = "disk-activity";
};
};
@@ -113,6 +156,15 @@
gpio = <&pio 1 6 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
+
+};
+
+&cpu0 {
+ cpu-supply = <&reg_dcdc1>;
+};
+
+&cpu4 {
+ cpu-supply = <&reg_dcdc1_323>;
};
&ehci0 {
@@ -128,8 +180,8 @@
phy-handle = <&ext_rgmii0_phy>;
phy-supply = <&reg_cldo3>;
- allwinner,tx-delay-ps = <300>;
- allwinner,rx-delay-ps = <400>;
+ allwinner,tx-delay-ps = <0>;
+ allwinner,rx-delay-ps = <300>;
status = "okay";
};
@@ -139,8 +191,8 @@
phy-handle = <&ext_rgmii1_phy>;
phy-supply = <&reg_cldo4>;
- tx-internal-delay-ps = <300>;
- rx-internal-delay-ps = <400>;
+ tx-internal-delay-ps = <0>;
+ rx-internal-delay-ps = <300>;
status = "okay";
};
@@ -275,6 +327,7 @@
};
reg_aldo2: aldo2 {
+ regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-name = "vcc-pe";
@@ -310,6 +363,7 @@
};
reg_bldo3: bldo3 {
+ regulator-always-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-name = "vcc-mipi-cam";
@@ -320,6 +374,7 @@
};
reg_cldo1: cldo1 {
+ regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-name = "vcc-pc-and-their-dog";
@@ -501,3 +501,18 @@
status = "okay";
};
+
+&de {
+ status = "okay";
+};
+
+&hdmi {
+ hvcc-supply = <&reg_cldo1>;
+ status = "okay";
+};
+
+&hdmi_out {
+ hdmi_out_con: endpoint {
+ remote-endpoint = <&hdmi_con_in>;
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts b/arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts
index 3bcd11e..44ed729 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts
+++ b/arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts
@@ -59,6 +59,19 @@
reg = <0x0 0x4ae42000 0x0 0x2000>;
no-map;
};
+
+ linux,cma {
+ compatible = "shared-dma-pool";
+ reusable;
+ /* pin low: the DE fetch aperture only reaches DRAM below
+ * ~0x4b100000; stop at 0x48000000 to stay clear of the
+ * secmon@48000000/48100000 and vdev@4ae00000 no-map
+ * reservations (overlap hands out no-map pages -> oops) */
+ reg = <0x0 0x43000000 0x0 0x5000000>;
+ alloc-ranges = <0x0 0x43000000 0x0 0x5000000>;
+ size = <0x0 0x5000000>;
+ linux,cma-default;
+ };
};
ext_osc32k: ext-osc32k-clk {
@@ -108,6 +121,17 @@
reset-gpios = <&pio 6 13 GPIO_ACTIVE_LOW>; /* PG13 WL-REG-ON */
post-power-on-delay-ms = <200>;
};
+
+ hdmi-connector {
+ compatible = "hdmi-connector";
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
};
&ehci0 {
@@ -123,7 +147,7 @@
phy-handle = <&ext_rgmii0_phy>;
phy-supply = <&reg_dcdc4>;
- allwinner,tx-delay-ps = <100>;
+ allwinner,tx-delay-ps = <0>;
allwinner,rx-delay-ps = <300>;
status = "okay";
@@ -134,8 +158,8 @@
phy-handle = <&ext_rgmii1_phy>;
phy-supply = <&reg_dcdc4>;
- tx-internal-delay-ps = <100>;
- rx-internal-delay-ps = <100>;
+ tx-internal-delay-ps = <0>;
+ rx-internal-delay-ps = <300>;
status = "okay";
};
@@ -567,3 +567,18 @@
<&rv_vdev0vring1>, <&e906_dram_reserved>;
status = "okay";
};
+
+&de {
+ status = "okay";
+};
+
+&hdmi {
+ hvcc-supply = <&reg_bldo3>;
+ status = "okay";
+};
+
+&hdmi_out {
+ hdmi_out_con: endpoint {
+ remote-endpoint = <&hdmi_con_in>;
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-t527-orangepi-4a.dts b/arch/arm64/boot/dts/allwinner/sun55i-t527-orangepi-4a.dts
index e2eefc3..5413b17 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-t527-orangepi-4a.dts
+++ b/arch/arm64/boot/dts/allwinner/sun55i-t527-orangepi-4a.dts
@@ -23,6 +23,53 @@
stdout-path = "serial0:115200n8";
};
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+
+ /* 128 KiB reserved for Trusted Firmware-A (BL31). */
+ secmon@48000000 {
+ reg = <0x0 0x48000000 0x0 0x20000>;
+ no-map;
+ };
+
+ /* 256 KiB reserved for the SCP. */
+ secmon@48100000 {
+ reg = <0x0 0x48100000 0x0 0x40000>;
+ no-map;
+ };
+
+ /*
+ * The display engine's layer DMA master has a limited fetch
+ * aperture and can only reach low DRAM (it reads the RCQ pool at
+ * ~0x43000000 but not 0x4b100000). The kernel's default CMA is
+ * high (~0xf0000000), so scanout fetches zeros (black). Ideally
+ * this pool should be pinned low just above the kernel image
+ * (ends ~0x42c70000) and the RCQ pool (~0x43000000), below the
+ * dtb (~0x49ff6000); that is NOT guaranteed without reg and
+ * alloc-ranges. HDMI output on this board is untested.
+ */
+ linux,cma {
+ compatible = "shared-dma-pool";
+ reusable;
+ size = <0x0 0x10000000>;
+ linux,cma-default;
+ };
+ };
+
+ /* HDMI output is enabled but not yet validated on this board. */
+ hdmi-connector {
+ compatible = "hdmi-connector";
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
+
ext_osc32k: ext-osc32k-clk {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -472,3 +519,18 @@
usb1_vbus-supply = <&reg_usb_vbus>;
status = "okay";
};
+
+&de {
+ status = "okay";
+};
+
+&hdmi {
+ hvcc-supply = <&reg_cldo1>;
+ status = "okay";
+};
+
+&hdmi_out {
+ hdmi_out_con: endpoint {
+ remote-endpoint = <&hdmi_con_in>;
+ };
+};
diff --git a/drivers/clk/sunxi-ng/ccu-sun55i-a523.c b/drivers/clk/sunxi-ng/ccu-sun55i-a523.c
index d469a6b..e52bfec 100644
--- a/drivers/clk/sunxi-ng/ccu-sun55i-a523.c
+++ b/drivers/clk/sunxi-ng/ccu-sun55i-a523.c
@@ -120,7 +120,7 @@ static const struct clk_hw *pll_periph0_150M_hws[] = {
#define SUN55I_A523_PLL_PERIPH1_REG 0x028
static struct ccu_nm pll_periph1_4x_clk = {
- .enable = BIT(27),
+ .enable = BIT(27) | BIT(30) | BIT(31),
.lock = BIT(28),
.n = _SUNXI_CCU_MULT_MIN(8, 8, 11),
.m = _SUNXI_CCU_DIV(1, 1), /* input divider */
@@ -128,7 +128,8 @@ static struct ccu_nm pll_periph1_4x_clk = {
.reg = 0x028,
.hw.init = CLK_HW_INIT_PARENTS_DATA("pll-periph1-4x",
osc24M, &ccu_nm_ops,
- CLK_SET_RATE_GATE),
+ CLK_SET_RATE_UNGATE |
+ CLK_IS_CRITICAL),
},
};
@@ -683,10 +684,10 @@ static SUNXI_CCU_MP_MUX_GATE_POSTDIV_DUALDIV(mmc1_clk, "mmc1", nand_mmc_parents,
static const struct clk_parent_data mmc2_parents[] = {
{ .fw_name = "hosc" },
+ { .hw = &pll_periph1_600M_clk.hw },
{ .hw = &pll_periph0_800M_clk.common.hw },
{ .hw = &pll_periph0_600M_clk.hw },
{ .hw = &pll_periph1_800M_clk.common.hw },
- { .hw = &pll_periph1_600M_clk.hw },
};
static SUNXI_CCU_MP_MUX_GATE_POSTDIV_DUALDIV(mmc2_clk, "mmc2", mmc2_parents,
@@ -904,6 +905,23 @@ static SUNXI_CCU_GATE_HWS(bus_display1_top_clk, "bus-display1-top", ahb_hws,
static SUNXI_CCU_GATE_DATA(hdmi_24M_clk, "hdmi-24M", osc24M, 0xb04, BIT(31), 0);
+/*
+ * Main HDMI TMDS ("mod") clock. Register 0xb00 follows the H616 layout
+ * (hdmi-24M@0xb04 and bus-hdmi@0xb1c are byte-identical to H616), sourced
+ * from the video PLLs; the dw-hdmi driver sets it to the pixel clock.
+ */
+static const struct clk_hw *hdmi_tmds_parents[] = {
+ &pll_video0_4x_clk.common.hw,
+ &pll_video1_4x_clk.common.hw,
+ &pll_video2_4x_clk.common.hw,
+ &pll_video3_4x_clk.common.hw,
+};
+static SUNXI_CCU_M_HW_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_tmds_parents, 0xb00,
+ 0, 4, /* M */
+ 24, 2, /* mux */
+ BIT(31), /* gate */
+ CLK_SET_RATE_PARENT);
+
static SUNXI_CCU_GATE_HWS_WITH_PREDIV(hdmi_cec_32k_clk, "hdmi-cec-32k",
pll_periph0_2x_hws,
0xb10, BIT(30), 36621, 0);
@@ -1329,6 +1347,7 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = {
&bus_display0_top_clk.common,
&bus_display1_top_clk.common,
&hdmi_24M_clk.common,
+ &hdmi_clk.common,
&hdmi_cec_32k_clk.common,
&hdmi_cec_clk.common,
&bus_hdmi_clk.common,
@@ -1513,6 +1532,7 @@ static struct clk_hw_onecell_data sun55i_a523_hw_clks = {
[CLK_BUS_DISPLAY0_TOP] = &bus_display0_top_clk.common.hw,
[CLK_BUS_DISPLAY1_TOP] = &bus_display1_top_clk.common.hw,
[CLK_HDMI_24M] = &hdmi_24M_clk.common.hw,
+ [CLK_HDMI] = &hdmi_clk.common.hw,
[CLK_HDMI_CEC_32K] = &hdmi_cec_32k_clk.common.hw,
[CLK_HDMI_CEC] = &hdmi_cec_clk.common.hw,
[CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw,
@@ -1556,7 +1576,7 @@ static struct clk_hw_onecell_data sun55i_a523_hw_clks = {
[CLK_NPU] = &npu_clk.common.hw,
[CLK_USB3_REF] = &usb3_ref_clk.common.hw,
},
- .num = CLK_USB3_REF + 1,
+ .num = CLK_HDMI + 1,
};
static struct ccu_reset_map sun55i_a523_ccu_resets[] = {
diff --git a/include/dt-bindings/clock/sun55i-a523-ccu.h b/include/dt-bindings/clock/sun55i-a523-ccu.h
index 02cc8c4..2eca83f 100644
--- a/include/dt-bindings/clock/sun55i-a523-ccu.h
+++ b/include/dt-bindings/clock/sun55i-a523-ccu.h
@@ -187,5 +187,6 @@
#define CLK_FANOUT2 178
#define CLK_NPU 179
#define CLK_USB3_REF 180
+#define CLK_HDMI 181
#endif /* _DT_BINDINGS_CLK_SUN55I_A523_CCU_H_ */
diff --git a/include/dt-bindings/reset/sun55i-a523-ccu.h b/include/dt-bindings/reset/sun55i-a523-ccu.h
index 70df503..4438d15 100644
--- a/include/dt-bindings/reset/sun55i-a523-ccu.h
+++ b/include/dt-bindings/reset/sun55i-a523-ccu.h
@@ -84,5 +84,6 @@
#define RST_BUS_LEDC 75
#define RST_BUS_CSI 76
#define RST_BUS_ISP 77
+#define RST_BUS_IOMMU 78
#endif /* _DT_BINDINGS_RST_SUN55I_A523_CCU_H_ */

View file

@ -0,0 +1,127 @@
diff --git a/drivers/gpu/drm/sun4i/sun55i_de.c b/drivers/gpu/drm/sun4i/sun55i_de.c
index 644d3ca..2cf3fd9 100644
--- a/drivers/gpu/drm/sun4i/sun55i_de.c
+++ b/drivers/gpu/drm/sun4i/sun55i_de.c
@@ -929,19 +929,72 @@ void sun55i_de_layer_update(struct sun8i_mixer *mixer, struct sun8i_layer *layer
* background-colour flashes (the bug the vendor avoids by arming in blanking).
* Defer the arm to the next blanking window in sun55i_de_vblank_quirk().
*/
-/* flip-min: only the fb-address blocks need reloading on a page flip */
+/* flip-min: only a few blocks need reloading on a page flip.
+ *
+ * The primary UI channel (pipe 0) carries the opaque desktop framebuffer: a
+ * page flip only changes its fb address, so just the OVL layer/para blocks are
+ * reloaded. The overlay and cursor channels (pipes 1/2) are staged dynamically
+ * by Xorg *after* the initial full reload (the cursor plane comes and goes,
+ * moves, changes enable state), so ALL of their blocks plus the shared blender
+ * must be reloaded on every flip to keep the shadow in sync with the hardware.
+ */
static bool is_fb_block(unsigned int i)
{
unsigned int c;
+ /* shared blender: pipe enables/route/blend change with overlay/cursor */
+ if (i == SUN55I_DE_BLK_BLD_ATTR || i == SUN55I_DE_BLK_BLD_CTL)
+ return true;
+
if (i < SUN55I_DE_BLK_UI_BASE_IDX)
return false;
- for (c = 0; c < SUN55I_DE_UI_CHANNELS; c++) {
- if (i == SUN55I_DE_BLK_CH(c, SUN55I_DE_BLKCH_OVL_LAY0) ||
- i == SUN55I_DE_BLK_CH(c, SUN55I_DE_BLKCH_OVL_PARA))
- return true;
+
+ /* channel maps: 0 == primary (fb-address only), 1/2 == dynamic */
+ c = (i - SUN55I_DE_BLK_UI_BASE_IDX) / SUN55I_DE_BLK_PER_UI_CH;
+ if (c == 0)
+ return i == SUN55I_DE_BLK_CH(0, SUN55I_DE_BLKCH_OVL_LAY0) ||
+ i == SUN55I_DE_BLK_CH(0, SUN55I_DE_BLKCH_OVL_PARA);
+
+ /* overlay/cursor: reload the whole channel register file every flip */
+ return i >= SUN55I_DE_BLK_CH(c, 0) &&
+ i < SUN55I_DE_BLK_CH(c, SUN55I_DE_BLK_PER_UI_CH);
+}
+
+static u32 sun55i_de_arm_target(struct sun55i_de *de);
+
+/*
+ * Backstop arm: program the RCQ load to land in the next leading-blanking
+ * window via the hrtimer, so a staged commit is armed even when the TCON
+ * vblank IRQ is not enabled (Xorg cursor-only updates never enable the
+ * vblank IRQ, and the beam-gated arm in sun55i_de_vblank_quirk() then never
+ * runs, freezing the cursor). Mirrors that quirk's line math. Idempotent:
+ * if the vblank IRQ already armed this commit, do_arm() finds arm_pending
+ * clear and the extra load is a no-op. Caller must hold arm_lock.
+ */
+static void sun55i_de_schedule_arm(struct sun55i_de *de)
+{
+ u32 target, cur_line;
+ u64 lines;
+
+ if (!de->ns_per_line || !tcon_curline_io)
+ return;
+
+ target = sun55i_de_arm_target(de);
+ cur_line = readl(tcon_curline_io) & 0xfff;
+
+ if (cur_line <= target) {
+ lines = target - cur_line;
+ } else {
+ u32 ahead = cur_line < de->line_total ?
+ de->line_total - cur_line : 0;
+
+ lines = ahead + target;
}
- return false;
+
+ de->arm_sched = true;
+ hrtimer_start(&de->arm_timer,
+ ns_to_ktime(lines * de->ns_per_line),
+ HRTIMER_MODE_REL);
}
void sun55i_de_commit(struct sun8i_mixer *mixer)
@@ -977,6 +1030,14 @@ void sun55i_de_commit(struct sun8i_mixer *mixer)
de->commit_seq++;
dbg_commits++;
de->arm_pending = true;
+
+ /*
+ * Backstop arm: the TCON vblank IRQ is not enabled for cursor-only
+ * updates, so arm via the hrtimer to the next blanking target. If an
+ * arm is already pending from a previous commit, that timer covers it.
+ */
+ if (!de->arm_sched)
+ sun55i_de_schedule_arm(de);
spin_unlock_irqrestore(&de->arm_lock, flags);
}
@@ -1059,8 +1120,26 @@ static enum hrtimer_restart sun55i_de_arm_timer(struct hrtimer *t)
unsigned long flags;
spin_lock_irqsave(&de->arm_lock, flags);
- if (de->arm_pending)
- sun55i_de_do_arm(de);
+ /* hrtimer fired: a racing commit must see this and re-schedule itself */
+ de->arm_sched = false;
+ if (de->arm_pending) {
+ u32 cur = tcon_curline_io ? readl(tcon_curline_io) & 0xfff : 0;
+
+ /*
+ * Beam-gated self-correction: the timer was aimed at the
+ * blanking target, but IRQ/scheduling latency may have it
+ * fire with the beam in active video - arming there tears.
+ * Re-check and defer to the next blanking window instead.
+ */
+ if (de->ns_per_line && cur >= de->line_active) {
+ sun55i_de_schedule_arm(de);
+ } else {
+ sun55i_de_do_arm(de);
+ /* RCQ still busy (arm_busy_gate): retry at the next blanking */
+ if (de->arm_pending)
+ sun55i_de_schedule_arm(de);
+ }
+ }
spin_unlock_irqrestore(&de->arm_lock, flags);
return HRTIMER_NORESTART;

View file

@ -0,0 +1,17 @@
diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index d6bd508..79df346 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -127,10 +127,10 @@
DRM_DEBUG_DRIVER("Disabling the CRTC\n");
- drm_crtc_vblank_off(crtc);
-
sun4i_tcon_set_status(scrtc->tcon, encoder, false);
+ drm_crtc_vblank_off(crtc);
+
if (crtc->state->event && !crtc->state->active) {
spin_lock_irq(&crtc->dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);

View file

@ -0,0 +1,56 @@
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
index 111111111111..222222222222 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
@@ -40,6 +40,37 @@ reserved-memory {
* just above the kernel image (ends ~0x42c70000) and the RCQ
* pool (~0x43000000), below the dtb (~0x49ff6000).
*/
+ riscvsram0_reserved: riscvsram0@7280000 {
+ reg = <0x0 0x07280000 0x0 0x40000>;
+ no-map;
+ };
+
+ riscvsram1_reserved: riscvsram1@72c0000 {
+ reg = <0x0 0x072c0000 0x0 0x40000>;
+ no-map;
+ };
+
+ e906_dram_reserved: e906_dram@60000000 {
+ reg = <0x0 0x60000000 0x0 0xa00000>;
+ no-map;
+ };
+
+ rv_vdev0buffer: vdev0buffer@4ae00000 {
+ compatible = "shared-dma-pool";
+ reg = <0x0 0x4ae00000 0x0 0x40000>;
+ no-map;
+ };
+
+ rv_vdev0vring0: vdev0vring0@4ae40000 {
+ reg = <0x0 0x4ae40000 0x0 0x2000>;
+ no-map;
+ };
+
+ rv_vdev0vring1: vdev0vring1@4ae42000 {
+ reg = <0x0 0x4ae42000 0x0 0x2000>;
+ no-map;
+ };
+
linux,cma {
compatible = "shared-dma-pool";
reusable;
@@ -557,6 +588,13 @@ &usbc1 {
};
+&e906_rproc {
+ memory-region = <&rv_vdev0buffer>, <&rv_vdev0vring0>,
+ <&rv_vdev0vring1>, <&e906_dram_reserved>;
+ status = "okay";
+};
+
+
&de {
status = "okay";
};

View file

@ -6,53 +6,58 @@ Subject: arm64: dts: allwinner: a523: add E906 RISC-V remoteproc node
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 30 +++++
arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts | 60 ++++++++++
2 files changed, 90 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 35 ++++++++
arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts | 43 ++++++++++
2 files changed, 78 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
index 111111111111..222222222222 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
@@ -588,6 +588,19 @@ sid: efuse@3006000 {
@@ -588,6 +588,20 @@ sid: efuse@3006000 {
#size-cells = <1>;
};
+ msgbox: mailbox@3003000 {
+ compatible = "allwinner,sun55iw3-msgbox";
+ compatible = "allwinner,sun55i-a523-msgbox",
+ "allwinner,sun55iw3-msgbox";
+ reg = <0x03003000 0x1000>,
+ <0x07120000 0x1000>,
+ <0x07094000 0x1000>,
+ <0x07136000 0x1000>;
+ reg-names = "arm", "cpus", "dsp", "rv";
+ interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_MSGBOX>;
+ resets = <&ccu RST_BUS_MSGBOX>;
+ #mbox-cells = <1>;
+ allwinner,local-id = <0>;
+ };
+
gic: interrupt-controller@3400000 {
compatible = "arm,gic-v3";
#address-cells = <1>;
@@ -1101,5 +1114,22 @@ npu: npu@7122000 {
@@ -1101,5 +1115,26 @@ npu: npu@7122000 {
resets = <&mcu_ccu RST_BUS_MCU_NPU>;
power-domains = <&ppu PD_NPU>;
};
+
+ e906_rproc: e906_rproc@7130000 {
+ compatible = "allwinner,e906-rproc";
+ reg = <0x07130000 0x1000>;
+ reg-names = "e906-cfg";
+ clocks = <&mcu_ccu CLK_BUS_MCU_PUBSRAM>,
+ e906_rproc: rproc@7130000 {
+ compatible = "allwinner,sun55i-a523-rproc",
+ "allwinner,e906-rproc";
+ reg = <0x07130000 0x1000>,
+ <0x07280000 0x40000>,
+ <0x072c0000 0x40000>;
+ reg-names = "cfg", "r_sram", "r_sram1";
+ clocks = <&mcu_ccu CLK_BUS_MCU_RISCV_CFG>,
+ <&mcu_ccu CLK_MCU_RISCV>,
+ <&mcu_ccu CLK_BUS_MCU_RISCV_CFG>;
+ clock-names = "pubsram", "mod", "cfg";
+ resets = <&mcu_ccu RST_BUS_MCU_PUBSRAM>,
+ <&mcu_ccu CLK_BUS_MCU_PUBSRAM>;
+ clock-names = "bus", "core", "sram";
+ resets = <&mcu_ccu RST_BUS_MCU_RISCV_CFG>,
+ <&mcu_ccu RST_BUS_MCU_RISCV_CORE>,
+ <&mcu_ccu RST_BUS_MCU_RISCV_CFG>,
+ <&mcu_ccu RST_BUS_MCU_PUBSRAM>,
+ <&mcu_ccu RST_BUS_MCU_RISCV_DEBUG>;
+ reset-names = "pubsram-rst", "mod-rst", "cfg-rst",
+ "dbg-rst";
+ reset-names = "cfg", "core", "sram", "debug";
+ mboxes = <&msgbox 8>;
+ mbox-names = "kick";
+ status = "disabled";
+ };
};
@ -105,33 +110,15 @@ index 111111111111..222222222222 100644
ext_osc32k: ext-osc32k-clk {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -442,3 +479,26 @@ &usbphy {
@@ -442,3 +479,9 @@ &usbphy {
usb0_vbus_det-gpios = <&pio 8 13 GPIO_ACTIVE_HIGH>; /* PI13 */
status = "okay";
};
+
+&e906_rproc {
+ mboxes = <&msgbox 8>, <&msgbox 10>;
+ mbox-names = "arm-kick", "arm-standby";
+ memory-region = <&riscvsram0_reserved>, <&riscvsram1_reserved>,
+ <&rv_vdev0buffer>, <&rv_vdev0vring0>,
+ memory-region = <&rv_vdev0buffer>, <&rv_vdev0vring0>,
+ <&rv_vdev0vring1>, <&e906_dram_reserved>;
+ memory-mappings =
+ /* < DA len PA > */
+ /* DSP RAM */
+ < 0x20000 0x20000 0x20000 >,
+ /* SRAM A2 */
+ < 0x40000 0x24000 0x40000 >,
+ /* DDR */
+ < 0x8000000 0x37f00000 0x8000000 >,
+ /* SRAM SPACE 0 */
+ < 0x3ffc0000 0x40000 0x07280000 >,
+ /* SRAM SPACE 1 */
+ < 0x40000000 0x40000 0x072c0000 >,
+ /* DRAM SPACE */
+ < 0x40040000 0x3ffc0000 0x40040000 >;
+ status = "okay";
+};
--
Armbian

View file

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Fri, 29 Aug 2026 00:00:00 -0400
Subject: [PATCH] arm64: dts: sun55i-a527-cubie-a5e: enable SPI NOR
The Cubie A5E has a Winbond W25Q128 16MiB SPI NOR on SPI0 (PC2/PC3/PC4/PC12).
Enable it in the kernel DTS so /dev/mtd0 appears. Uses the existing
sun55i-a523.dtsi pinctrl (spi0_pc_pins + spi0_cs0_pc_pin) at 40MHz.
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:muse-spark-1.2-contributor-free
---
arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
index 111111111111..222222222222 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts
@@ -344,6 +344,18 @@
vcc-pm-supply = <&reg_aldo3>;
};
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi0_pc_pins>, <&spi0_cs0_pc_pin>;
+ status = "okay";
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <40000000>;
+ };
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pb_pins>;
--
Armbian

View file

@ -123,7 +123,7 @@ diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_m
index 111111111111..222222222222 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -40,6 +40,16 @@ struct de2_fmt_info {
@@ -38,6 +38,16 @@ struct de2_fmt_info {
static bool hw_preconfigured;
@ -140,7 +140,7 @@ index 111111111111..222222222222 100644
static const struct de2_fmt_info de2_formats[] = {
{
.drm_fmt = DRM_FORMAT_ARGB8888,
@@ -440,10 +450,28 @@ static void sun8i_mixer_mode_set(struct sunxi_engine *engine,
@@ -442,10 +452,28 @@ static void sun8i_mixer_mode_set(struct sunxi_engine *engine,
interlaced ? "on" : "off");
}
@ -171,8 +171,8 @@ index 111111111111..222222222222 100644
+ .disable_color_correction = sun8i_mixer_disable_color_correction,
};
static const struct sunxi_engine_ops sun50i_engine_ops = {
@@ -818,6 +846,25 @@ static const struct sun8i_mixer_cfg sun8i_h3_mixer0_cfg = {
static const struct regmap_config sun8i_mixer_regmap_config = {
@@ -799,6 +827,25 @@ static const struct sun8i_mixer_cfg sun8i_h3_mixer0_cfg = {
.vi_num = 1,
};
@ -198,7 +198,7 @@ index 111111111111..222222222222 100644
static const struct sun8i_mixer_cfg sun8i_r40_mixer0_cfg = {
.lay_cfg = {
.ccsc = CCSC_MIXER0_LAYOUT,
@@ -953,6 +1000,10 @@ static const struct of_device_id sun8i_mixer_of_table[] = {
@@ -942,6 +989,10 @@ static const struct of_device_id sun8i_mixer_of_table[] = {
.compatible = "allwinner,sun8i-h3-de2-mixer-0",
.data = &sun8i_h3_mixer0_cfg,
},

View file

@ -7,12 +7,12 @@ Signed-off-by: Marvin Wewer <mwewer37@proton.me>
---
drivers/iommu/Kconfig | 10 +
drivers/iommu/Makefile | 3 +
drivers/iommu/sun55i-iommu-pgtable.c | 468 +++
drivers/iommu/sun55i-iommu-pgtable.c | 471 +++
drivers/iommu/sun55i-iommu-pgtable.h | 125 +
drivers/iommu/sun55i-iommu.c | 1604 ++++++++++
drivers/iommu/sun55i-iommu.h | 57 +
include/sunxi-iommu.h | 50 +
7 files changed, 2317 insertions(+)
7 files changed, 2320 insertions(+)
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 111111111111..222222222222 100644

View file

@ -6,11 +6,109 @@ Subject: mailbox: sun55i: add T527/A523 msgbox driver
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
drivers/mailbox/Kconfig | 9 +
drivers/mailbox/Makefile | 1 +
drivers/mailbox/sun55i-msgbox.c | 437 ++++++++++
3 files changed, 447 insertions(+)
Documentation/devicetree/bindings/mailbox/allwinner,sun55i-a523-msgbox.yaml | 92 +++++++
drivers/mailbox/Kconfig | 9 ++
drivers/mailbox/Makefile | 1 +
drivers/mailbox/sun55i-msgbox.c | 450 ++++++++++++++++++++++++++
4 files changed, 552 insertions(+)
diff --git a/Documentation/devicetree/bindings/mailbox/allwinner,sun55i-a523-msgbox.yaml b/Documentation/devicetree/bindings/mailbox/allwinner,sun55i-a523-msgbox.yaml
new file mode 100644
index 000000000000..50ea1f5d7cb5
--- /dev/null
+++ b/Documentation/devicetree/bindings/mailbox/allwinner,sun55i-a523-msgbox.yaml
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/allwinner,sun55i-a523-msgbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sun55i (T527/A523) Message Box
+
+maintainers:
+ - Juan Sanchez Fuentes <juanesf91@gmail.com>
+
+description: |
+ The hardware message box on sun55i SoCs (T527/A523) is a four-user mailbox
+ controller containing 12 unidirectional FIFOs shared between the ARM, CPUS,
+ DSP and RV (E906) processors. Each user has its own register block. An
+ interrupt is raised for received messages, but software must poll to know
+ when a transmitted message has been acknowledged by the remote user. Each
+ FIFO can hold fifteen 32-bit messages; when a FIFO is full, clients must
+ wait before attempting more transmissions.
+
+ Refer to ./mailbox.txt for generic information about mailbox device-tree
+ bindings.
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - allwinner,sun55i-a523-msgbox
+ - const: allwinner,sun55iw3-msgbox
+ - const: allwinner,sun55i-a523-msgbox
+ - const: allwinner,sun55iw3-msgbox
+
+ reg:
+ maxItems: 4
+ description: one register block per mailbox user
+
+ reg-names:
+ items:
+ - const: arm
+ - const: cpus
+ - const: dsp
+ - const: rv
+
+ clocks:
+ maxItems: 1
+ description: bus clock
+
+ resets:
+ maxItems: 1
+ description: bus reset
+
+ interrupts:
+ maxItems: 1
+ description: interrupt for the local (ARM) block
+
+ '#mbox-cells':
+ const: 1
+ description: first cell is the channel number (0-11)
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - clocks
+ - resets
+ - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/sun55i-a523-ccu.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/reset/sun55i-a523-ccu.h>
+
+ msgbox: mailbox@3003000 {
+ compatible = "allwinner,sun55i-a523-msgbox",
+ "allwinner,sun55iw3-msgbox";
+ reg = <0x03003000 0x1000>,
+ <0x07120000 0x1000>,
+ <0x07094000 0x1000>,
+ <0x07136000 0x1000>;
+ reg-names = "arm", "cpus", "dsp", "rv";
+ clocks = <&ccu CLK_BUS_MSGBOX>;
+ resets = <&ccu RST_BUS_MSGBOX>;
+ interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
+ #mbox-cells = <1>;
+ };
+
+...
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 111111111111..222222222222 100644
--- a/drivers/mailbox/Kconfig
@ -24,9 +122,9 @@ index 111111111111..222222222222 100644
+ depends on ARCH_SUNXI || COMPILE_TEST
+ default ARCH_SUNXI
+ help
+ Mailbox implementation for the multi-region hardware message
+ box present in Allwinner sun55i SoCs (T527/A523). Supports
+ 12 channels across 4 processors (ARM, DSP, CPUS, RV).
+ Mailbox implementation for the multi-user hardware message box
+ present in Allwinner sun55i SoCs (T527/A523). Supports 12
+ channels across 4 processors (ARM, CPUS, DSP, RV).
+
config SPRD_MBOX
tristate "Spreadtrum Mailbox"
@ -45,11 +143,13 @@ index 111111111111..222222222222 100644
diff --git a/drivers/mailbox/sun55i-msgbox.c b/drivers/mailbox/sun55i-msgbox.c
new file mode 100644
index 000000000000..111111111111
index 000000000000..0ac05ff790eb
--- /dev/null
+++ b/drivers/mailbox/sun55i-msgbox.c
@@ -0,0 +1,437 @@
+// SPDX-License-Identifier: GPL-2.0-only
@@ -0,0 +1,450 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Allwinner sun55i (T527/A523) Message Box driver.
+
+#include <linux/bitops.h>
+#include <linux/clk.h>
@ -71,6 +171,9 @@ index 000000000000..111111111111
+#define CHANS_PER_PROC 4
+#define FIFO_DEPTH 15
+
+/* The ARM block is the local endpoint of the message box. */
+#define LOCAL_PROC 0
+
+#define MSGBOX_REG(n) (0x100 * (n))
+
+#define READ_IRQ_EN(coef) (0x20 + MSGBOX_REG(coef))
@ -83,26 +186,26 @@ index 000000000000..111111111111
+
+#define RX_IRQ_BIT(p) BIT((p) * 2)
+
+struct sun55i_msgbox {
+ struct mbox_controller controller;
+ struct clk *clk;
+ struct reset_control *rst;
+ spinlock_t lock;
+ void __iomem *base[NUM_PROC];
+ struct delayed_work rx_poll;
+ int irq;
+ u32 local_id;
+};
+#define mbox_dbg(mbox, ...) dev_dbg((mbox)->controller.dev, __VA_ARGS__)
+
+struct chan_map {
+ int remote_proc;
+ int peer_chan;
+};
+
+static struct chan_map sun55i_chan_maps[NUM_CHANS];
+struct sun55i_msgbox {
+ struct mbox_controller controller;
+ struct clk *clk;
+ struct reset_control *rst;
+ struct delayed_work rx_poll;
+ struct chan_map maps[NUM_CHANS];
+ void __iomem *base[NUM_PROC];
+ spinlock_t lock;
+ int irq;
+};
+
+/*
+ * sun55iw3: ARM:0, DSP:1, CPUS:2, RV:3
+ * sun55iw3: ARM:0, CPUS:1, DSP:2, RV:3
+ * to_coef_n[sender][receiver] = mailbox coefficient used on the
+ * receiver's block when the sender writes to it.
+ *
@ -123,6 +226,11 @@ index 000000000000..111111111111
+ return sun55iw3_to_coef_n[sender][receiver];
+}
+
+static inline int sun55i_msgbox_channel_number(struct mbox_chan *chan)
+{
+ return chan - chan->mbox->chans;
+}
+
+static int sun55i_msgbox_build_maps(struct sun55i_msgbox *mbox)
+{
+ int i, chan = 0;
@ -130,13 +238,13 @@ index 000000000000..111111111111
+ for (i = 0; i < NUM_PROC; i++) {
+ int j;
+
+ if (i == mbox->local_id)
+ if (i == LOCAL_PROC)
+ continue;
+ for (j = 0; j < CHANS_PER_PROC; j++) {
+ if (chan >= NUM_CHANS)
+ return -EINVAL;
+ sun55i_chan_maps[chan].remote_proc = i;
+ sun55i_chan_maps[chan].peer_chan = j;
+ mbox->maps[chan].remote_proc = i;
+ mbox->maps[chan].peer_chan = j;
+ chan++;
+ }
+ }
@ -144,18 +252,19 @@ index 000000000000..111111111111
+ return 0;
+}
+
+static inline struct chan_map *chan_to_map(unsigned int chan)
+static struct chan_map *chan_to_map(struct sun55i_msgbox *mbox,
+ unsigned int chan)
+{
+ if (chan >= NUM_CHANS)
+ return NULL;
+ return &sun55i_chan_maps[chan];
+ return &mbox->maps[chan];
+}
+
+static void sun55i_msgbox_rx_drain(struct sun55i_msgbox *mbox,
+ struct mbox_chan *chan, int recv_coef,
+ int peer_chan, u32 irq_bit)
+{
+ void __iomem *base = mbox->base[mbox->local_id];
+ void __iomem *base = mbox->base[LOCAL_PROC];
+ int timeout = FIFO_DEPTH * 2;
+
+ /* The IRQ pending bit can be cleared only once the FIFO is
@ -165,6 +274,8 @@ index 000000000000..111111111111
+ timeout--) {
+ u32 msg = readl(base + MSG_DATA(recv_coef, peer_chan));
+
+ mbox_dbg(mbox, "Channel %d received 0x%08x\n",
+ sun55i_msgbox_channel_number(chan), msg);
+ mbox_chan_received_data(chan, &msg);
+ }
+ writel(irq_bit, base + READ_IRQ_STAT(recv_coef));
@ -173,25 +284,23 @@ index 000000000000..111111111111
+static irqreturn_t sun55i_msgbox_irq(int irq, void *dev_id)
+{
+ struct sun55i_msgbox *mbox = dev_id;
+ void __iomem *base = mbox->base[LOCAL_PROC];
+ unsigned long flags;
+ bool handled = false;
+ u32 status, en;
+ int i;
+
+ spin_lock_irqsave(&mbox->lock, flags);
+ for (i = 0; i < NUM_CHANS; i++) {
+ struct chan_map *map = chan_to_map(i);
+ u32 irq_bit, recv_coef;
+ struct chan_map *map = chan_to_map(mbox, i);
+ u32 en, status, irq_bit, recv_coef;
+
+ if (!map)
+ continue;
+
+ recv_coef = msgbox_coef(map->remote_proc, mbox->local_id);
+ recv_coef = msgbox_coef(map->remote_proc, LOCAL_PROC);
+ irq_bit = RX_IRQ_BIT(map->peer_chan);
+ en = readl(mbox->base[mbox->local_id] +
+ READ_IRQ_EN(recv_coef));
+ status = readl(mbox->base[mbox->local_id] +
+ READ_IRQ_STAT(recv_coef));
+ en = readl(base + READ_IRQ_EN(recv_coef));
+ status = readl(base + READ_IRQ_STAT(recv_coef));
+ if (!(status & en & irq_bit))
+ continue;
+
@ -207,123 +316,139 @@ index 000000000000..111111111111
+static int sun55i_msgbox_send_data(struct mbox_chan *chan, void *data)
+{
+ struct sun55i_msgbox *mbox = chan->con_priv;
+ int chan_idx = chan - mbox->controller.chans;
+ struct chan_map *map = chan_to_map(chan_idx);
+ u32 msg = data ? *(u32 *)data : 0;
+ u32 stat;
+ struct chan_map *map;
+ void __iomem *base;
+ u32 msg, stat;
+ unsigned long flags;
+ int coef;
+ int coef, chan_idx;
+
+ chan_idx = sun55i_msgbox_channel_number(chan);
+ map = chan_to_map(mbox, chan_idx);
+ if (!map)
+ return -EINVAL;
+
+ coef = msgbox_coef(mbox->local_id, map->remote_proc);
+ msg = data ? *(u32 *)data : 0;
+ base = mbox->base[map->remote_proc];
+ coef = msgbox_coef(LOCAL_PROC, map->remote_proc);
+
+ spin_lock_irqsave(&mbox->lock, flags);
+
+ stat = readl(mbox->base[map->remote_proc] +
+ MSG_STAT(coef, map->peer_chan));
+ stat = readl(base + MSG_STAT(coef, map->peer_chan));
+ if ((stat & 0xf) >= FIFO_DEPTH) {
+ spin_unlock_irqrestore(&mbox->lock, flags);
+ return -EBUSY;
+ }
+
+ writel(msg, mbox->base[map->remote_proc] +
+ MSG_DATA(coef, map->peer_chan));
+ writel(msg, base + MSG_DATA(coef, map->peer_chan));
+ mbox_dbg(mbox, "Channel %d sent 0x%08x\n", chan_idx, msg);
+
+ spin_unlock_irqrestore(&mbox->lock, flags);
+
+ return 0;
+}
+
+static int sun55i_msgbox_startup(struct mbox_chan *chan)
+{
+ struct sun55i_msgbox *mbox = chan->con_priv;
+ int chan_idx = chan - mbox->controller.chans;
+ struct chan_map *map = chan_to_map(chan_idx);
+ void __iomem *base = mbox->base[LOCAL_PROC];
+ struct chan_map *map;
+ u32 en, recv_coef;
+ unsigned long flags;
+ int chan_idx;
+
+ chan_idx = sun55i_msgbox_channel_number(chan);
+ map = chan_to_map(mbox, chan_idx);
+ if (!map)
+ return -EINVAL;
+
+ recv_coef = msgbox_coef(map->remote_proc, mbox->local_id);
+ recv_coef = msgbox_coef(map->remote_proc, LOCAL_PROC);
+
+ spin_lock_irqsave(&mbox->lock, flags);
+
+ en = readl(mbox->base[mbox->local_id] + READ_IRQ_EN(recv_coef));
+ en = readl(base + READ_IRQ_EN(recv_coef));
+ en |= RX_IRQ_BIT(map->peer_chan);
+ writel(en, mbox->base[mbox->local_id] + READ_IRQ_EN(recv_coef));
+
+ writel(en, base + READ_IRQ_EN(recv_coef));
+ spin_unlock_irqrestore(&mbox->lock, flags);
+
+ return 0;
+}
+
+static void sun55i_msgbox_shutdown(struct mbox_chan *chan)
+{
+ struct sun55i_msgbox *mbox = chan->con_priv;
+ int chan_idx = chan - mbox->controller.chans;
+ struct chan_map *map = chan_to_map(chan_idx);
+ void __iomem *base = mbox->base[LOCAL_PROC];
+ struct chan_map *map;
+ u32 en, recv_coef;
+ unsigned long flags;
+ int chan_idx;
+
+ chan_idx = sun55i_msgbox_channel_number(chan);
+ map = chan_to_map(mbox, chan_idx);
+ if (!map)
+ return;
+
+ recv_coef = msgbox_coef(map->remote_proc, mbox->local_id);
+ recv_coef = msgbox_coef(map->remote_proc, LOCAL_PROC);
+
+ spin_lock_irqsave(&mbox->lock, flags);
+
+ en = readl(mbox->base[mbox->local_id] + READ_IRQ_EN(recv_coef));
+ en = readl(base + READ_IRQ_EN(recv_coef));
+ en &= ~RX_IRQ_BIT(map->peer_chan);
+ writel(en, mbox->base[mbox->local_id] + READ_IRQ_EN(recv_coef));
+
+ writel(en, base + READ_IRQ_EN(recv_coef));
+ spin_unlock_irqrestore(&mbox->lock, flags);
+}
+
+static bool sun55i_msgbox_last_tx_done(struct mbox_chan *chan)
+{
+ struct sun55i_msgbox *mbox = chan->con_priv;
+ int chan_idx = chan - mbox->controller.chans;
+ struct chan_map *map = chan_to_map(chan_idx);
+ struct chan_map *map;
+ void __iomem *base;
+ u32 stat;
+ int coef;
+ int coef, chan_idx;
+
+ chan_idx = sun55i_msgbox_channel_number(chan);
+ map = chan_to_map(mbox, chan_idx);
+ if (!map)
+ return true;
+
+ coef = msgbox_coef(mbox->local_id, map->remote_proc);
+ stat = readl(mbox->base[map->remote_proc] +
+ MSG_STAT(coef, map->peer_chan));
+ base = mbox->base[map->remote_proc];
+ coef = msgbox_coef(LOCAL_PROC, map->remote_proc);
+ stat = readl(base + MSG_STAT(coef, map->peer_chan));
+
+ return (stat & 0xf) < FIFO_DEPTH;
+}
+
+static const struct mbox_chan_ops sun55i_msgbox_ops = {
+ .send_data = sun55i_msgbox_send_data,
+ .startup = sun55i_msgbox_startup,
+ .shutdown = sun55i_msgbox_shutdown,
+ .last_tx_done = sun55i_msgbox_last_tx_done,
+};
+
+/*
+ * The msgbox IRQ line for the ARM block is not reliably wired in the
+ * mainline/Armbian DT, so also poll the read-IRQ status. The IRQ and
+ * the poller both run under mbox->lock: whoever clears the pending
+ * bit first wins, so a message is never delivered twice.
+ * When the msgbox IRQ line is unavailable (not wired in the DT, or
+ * already requested), fall back to polling the read-IRQ status. The
+ * IRQ handler and the poller both run under mbox->lock: whoever
+ * clears the pending bit first wins, so a message is never delivered
+ * twice.
+ */
+static void sun55i_msgbox_poll_rx(struct work_struct *work)
+{
+ struct sun55i_msgbox *mbox = container_of(work, struct sun55i_msgbox,
+ rx_poll.work);
+ void __iomem *base = mbox->base[LOCAL_PROC];
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&mbox->lock, flags);
+ for (i = 0; i < NUM_CHANS; i++) {
+ struct chan_map *map = chan_to_map(i);
+ struct chan_map *map = chan_to_map(mbox, i);
+ u32 status, en, irq_bit, recv_coef;
+
+ if (!map)
+ continue;
+
+ recv_coef = msgbox_coef(map->remote_proc, mbox->local_id);
+ recv_coef = msgbox_coef(map->remote_proc, LOCAL_PROC);
+ irq_bit = RX_IRQ_BIT(map->peer_chan);
+ en = readl(mbox->base[mbox->local_id] +
+ READ_IRQ_EN(recv_coef));
+ status = readl(mbox->base[mbox->local_id] +
+ READ_IRQ_STAT(recv_coef));
+ en = readl(base + READ_IRQ_EN(recv_coef));
+ status = readl(base + READ_IRQ_STAT(recv_coef));
+ if (!(status & en & irq_bit))
+ continue;
+
@ -343,36 +468,22 @@ index 000000000000..111111111111
+ msecs_to_jiffies(2));
+}
+
+static void sun55i_msgbox_stop_rx_poll(struct sun55i_msgbox *mbox)
+{
+ cancel_delayed_work_sync(&mbox->rx_poll);
+}
+
+static const struct mbox_chan_ops sun55i_msgbox_ops = {
+ .send_data = sun55i_msgbox_send_data,
+ .startup = sun55i_msgbox_startup,
+ .shutdown = sun55i_msgbox_shutdown,
+ .last_tx_done = sun55i_msgbox_last_tx_done,
+};
+
+static int sun55i_msgbox_probe(struct platform_device *pdev)
+{
+ static const char * const proc_regs[NUM_PROC] = {
+ "arm", "cpus", "dsp", "rv",
+ };
+ struct device *dev = &pdev->dev;
+ struct sun55i_msgbox *mbox;
+ struct mbox_chan *chans;
+ struct resource *res;
+ int ret, i;
+
+ mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
+ if (!mbox)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, mbox);
+
+ mbox->local_id = 0;
+ of_property_read_u32(dev->of_node, "allwinner,local-id", &mbox->local_id);
+
+ spin_lock_init(&mbox->lock);
+ platform_set_drvdata(pdev, mbox);
+
+ mbox->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(mbox->clk))
@ -383,13 +494,11 @@ index 000000000000..111111111111
+ return dev_err_probe(dev, PTR_ERR(mbox->rst), "no rst\n");
+
+ for (i = 0; i < NUM_PROC; i++) {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+ if (!res)
+ return dev_err_probe(dev, -ENXIO,
+ "no reg region %d\n", i);
+ mbox->base[i] = devm_ioremap_resource(dev, res);
+ mbox->base[i] = devm_platform_ioremap_resource_byname(pdev,
+ proc_regs[i]);
+ if (IS_ERR(mbox->base[i]))
+ return PTR_ERR(mbox->base[i]);
+ return dev_err_probe(dev, PTR_ERR(mbox->base[i]),
+ "no reg region %s\n", proc_regs[i]);
+ }
+
+ ret = clk_prepare_enable(mbox->clk);
@ -407,16 +516,16 @@ index 000000000000..111111111111
+ writel(0xffff, mbox->base[i] + WRITE_IRQ_STAT(i));
+ }
+
+ ret = sun55i_msgbox_build_maps(mbox);
+ if (ret)
+ goto err_rst;
+
+ chans = devm_kcalloc(dev, NUM_CHANS, sizeof(*chans), GFP_KERNEL);
+ if (!chans) {
+ ret = -ENOMEM;
+ goto err_rst;
+ }
+
+ ret = sun55i_msgbox_build_maps(mbox);
+ if (ret)
+ goto err_rst;
+
+ for (i = 0; i < NUM_CHANS; i++)
+ chans[i].con_priv = mbox;
+
@ -429,14 +538,13 @@ index 000000000000..111111111111
+
+ mbox->irq = platform_get_irq(pdev, 0);
+ if (mbox->irq < 0) {
+ dev_warn(dev, "no IRQ (err=%d), using RX poller only\n",
+ mbox->irq);
+ dev_warn(dev, "no IRQ (err=%d), using RX poller\n", mbox->irq);
+ mbox->irq = -1;
+ } else {
+ ret = devm_request_irq(dev, mbox->irq, sun55i_msgbox_irq, 0,
+ dev_name(dev), mbox);
+ if (ret) {
+ dev_warn(dev, "IRQ %d unavailable (%d), using RX poller only\n",
+ dev_warn(dev, "IRQ %d unavailable (%d), using RX poller\n",
+ mbox->irq, ret);
+ mbox->irq = -1;
+ }
@ -446,10 +554,11 @@ index 000000000000..111111111111
+ if (ret)
+ goto err_rst;
+
+ sun55i_msgbox_start_rx_poll(mbox);
+ if (mbox->irq < 0)
+ sun55i_msgbox_start_rx_poll(mbox);
+
+ dev_info(dev, "msgbox ready (local_id=%u, irq=%d)\n",
+ mbox->local_id, mbox->irq);
+ dev_info(dev, "msgbox ready (%d channels, irq=%d)\n",
+ NUM_CHANS, mbox->irq);
+ return 0;
+
+err_rst:
@ -463,12 +572,14 @@ index 000000000000..111111111111
+{
+ struct sun55i_msgbox *mbox = platform_get_drvdata(pdev);
+
+ sun55i_msgbox_stop_rx_poll(mbox);
+ if (mbox->irq < 0)
+ cancel_delayed_work_sync(&mbox->rx_poll);
+ reset_control_assert(mbox->rst);
+ clk_disable_unprepare(mbox->clk);
+}
+
+static const struct of_device_id sun55i_msgbox_of_match[] = {
+ { .compatible = "allwinner,sun55i-a523-msgbox" },
+ { .compatible = "allwinner,sun55iw3-msgbox" },
+ { }
+};
@ -488,4 +599,3 @@ index 000000000000..111111111111
+MODULE_LICENSE("GPL");
--
Armbian

View file

@ -16,31 +16,147 @@ Subject: [ARCHEOLOGY] sunxi-7.1: add E906 RISC-V remoteproc support
> X-Git-Archeology: Subject: sunxi-7.1: add E906 RISC-V remoteproc support
> X-Git-Archeology:
---
drivers/remoteproc/Kconfig | 13 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/sun55i_e906_rproc.c | 734 ++++++++++
3 files changed, 748 insertions(+)
Documentation/devicetree/bindings/remoteproc/allwinner,sun55i-a523-rproc.yaml | 110 +++++
drivers/remoteproc/Kconfig | 11 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/sun55i_e906_rproc.c | 615 ++++++++
4 files changed, 737 insertions(+)
diff --git a/Documentation/devicetree/bindings/remoteproc/allwinner,sun55i-a523-rproc.yaml b/Documentation/devicetree/bindings/remoteproc/allwinner,sun55i-a523-rproc.yaml
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/allwinner,sun55i-a523-rproc.yaml
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/remoteproc/allwinner,sun55i-a523-rproc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sun55i (T527/A523) E906 remoteproc
+
+description: |
+ This document defines the binding for the remoteproc component that loads
+ and boots a firmware on the E906 RISC-V core of the Allwinner sun55i SoCs
+ (T527/A523). The E906 communicates with the application CPUs through the
+ sun55i message box, and shares DDR through the memory-region carveouts.
+
+maintainers:
+ - Juan Sanchez Fuentes <juanesf91@gmail.com>
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - const: allwinner,sun55i-a523-rproc
+ - const: allwinner,e906-rproc
+ - const: allwinner,e906-rproc
+
+ reg:
+ maxItems: 3
+ description: |
+ Configuration block, plus the two RISC-V SRAMs (R_SRAM and R_SRAM1)
+ that the E906 core boots from.
+
+ reg-names:
+ items:
+ - const: cfg
+ - const: r_sram
+ - const: r_sram1
+
+ clocks:
+ maxItems: 3
+
+ clock-names:
+ items:
+ - const: bus
+ - const: core
+ - const: sram
+
+ resets:
+ maxItems: 4
+
+ reset-names:
+ items:
+ - const: cfg
+ - const: core
+ - const: sram
+ - const: debug
+
+ mboxes:
+ maxItems: 1
+ description: channel used to kick a virtqueue on the E906
+
+ mbox-names:
+ const: kick
+
+ memory-region:
+ minItems: 4
+ description: |
+ Carveouts for the virtio vrings/vbuffer and the DDR window shared with
+ the E906. They keep the same device and physical addresses.
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - clocks
+ - clock-names
+ - resets
+ - reset-names
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/sun55i-a523-mcu-ccu.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/reset/sun55i-a523-mcu-ccu.h>
+
+ rproc: rproc@7130000 {
+ compatible = "allwinner,sun55i-a523-rproc",
+ "allwinner,e906-rproc";
+ reg = <0x07130000 0x1000>,
+ <0x07280000 0x40000>,
+ <0x072c0000 0x40000>;
+ reg-names = "cfg", "r_sram", "r_sram1";
+ clocks = <&mcu_ccu CLK_BUS_MCU_RISCV_CFG>,
+ <&mcu_ccu CLK_MCU_RISCV>,
+ <&mcu_ccu CLK_BUS_MCU_PUBSRAM>;
+ clock-names = "bus", "core", "sram";
+ resets = <&mcu_ccu RST_BUS_MCU_RISCV_CFG>,
+ <&mcu_ccu RST_BUS_MCU_RISCV_CORE>,
+ <&mcu_ccu RST_BUS_MCU_PUBSRAM>,
+ <&mcu_ccu RST_BUS_MCU_RISCV_DEBUG>;
+ reset-names = "cfg", "core", "sram", "debug";
+ mboxes = <&msgbox 8>;
+ mbox-names = "kick";
+ memory-region = <&rv_vdev0buffer>, <&rv_vdev0vring0>,
+ <&rv_vdev0vring1>, <&e906_dram_reserved>;
+ status = "okay";
+ };
+
+...
\ No newline at end of file
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 111111111111..222222222222 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -379,6 +379,19 @@ config XLNX_R5_REMOTEPROC
@@ -379,6 +379,17 @@ config XLNX_R5_REMOTEPROC
It's safe to say N if not interested in using RPU r5f cores.
+config SUN55I_E906_REMOTEPROC
+ tristate "Allwinner sun55i E906 remoteproc support"
+ tristate "Allwinner sun55i (T527/A523) E906 remoteproc support"
+ depends on ARCH_SUNXI || COMPILE_TEST
+ depends on REMOTEPROC
+ select MAILBOX
+ help
+ Say y here to support the Allwinner sun55i E906 RISC-V remote
+ processor via the remote processor framework. An ELF firmware can
+ be loaded thanks to sysfs remoteproc entries. The remote processor
+ can be started and stopped.
+ Say y or m here to support the E906 RISC-V remote processor found in
+ the Allwinner sun55i (T527/A523) SoCs.
+
+ This can be either built-in or a loadable module.
+ It's safe to say N if not interested in using the E906 core.
+
endif # REMOTEPROC
@ -59,17 +175,16 @@ new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/drivers/remoteproc/sun55i_e906_rproc.c
@@ -0,0 +1,734 @@
+// SPDX-License-Identifier: GPL-2.0-only
@@ -0,0 +1,646 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/elf.h>
+#include <linux/firmware.h>
+#include <linux/io.h>
+#include <linux/mailbox_client.h>
+#include <linux/bitmap.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
@ -82,16 +197,16 @@ index 000000000000..111111111111
+
+#define MBOX_NB_VQ 2
+
+struct sun55i_memory_mapping {
+ u64 da;
+ u64 len;
+ u64 pa;
+};
+/* Device addresses of the RISC-V SRAM windows on the E906. */
+#define RSRAM_DA 0x3ffc0000
+#define RSRAM1_DA 0x40000000
+
+struct sun55i_mbox {
+ struct mbox_chan *chan;
+ struct mbox_client client;
+ struct work_struct vq_work;
+ unsigned long vq_pending;
+ spinlock_t vq_lock;
+ int vq_id;
+};
+
@ -100,23 +215,22 @@ index 000000000000..111111111111
+ struct rproc *rproc;
+
+ void __iomem *e906_cfg;
+ void __iomem *r_sram;
+ void __iomem *r_sram1;
+ size_t r_sram_sz;
+ size_t r_sram1_sz;
+
+ struct clk *pubsram_clk;
+ struct clk *mod_clk;
+ struct clk *cfg_clk;
+ struct clk *bus_clk;
+ struct clk *core_clk;
+ struct clk *sram_clk;
+
+ struct reset_control *pubsram_rst;
+ struct reset_control *mod_rst;
+ struct reset_control *cfg_rst;
+ struct reset_control *dbg_rst;
+
+ struct sun55i_memory_mapping *mem_maps;
+ int mem_maps_cnt;
+ struct reset_control *core_rst;
+ struct reset_control *sram_rst;
+ struct reset_control *debug_rst;
+
+ struct sun55i_mbox mb;
+ struct workqueue_struct *workqueue;
+
+ u32 pc_entry;
+};
+
+static struct sun55i_e906_rproc *
@ -125,58 +239,26 @@ index 000000000000..111111111111
+ return (struct sun55i_e906_rproc *)rproc->priv;
+}
+
+static int sun55i_da_to_pa(struct rproc *rproc, u64 da, phys_addr_t *pa)
+static void *sun55i_e906_da_to_va(struct rproc *rproc, u64 da, size_t len,
+ bool *is_iomem)
+{
+ struct sun55i_e906_rproc *priv = sun55i_rproc_priv(rproc);
+ int i;
+
+ for (i = 0; i < priv->mem_maps_cnt; i++) {
+ if (da < priv->mem_maps[i].da ||
+ da >= priv->mem_maps[i].da + priv->mem_maps[i].len)
+ continue;
+ *pa = da - priv->mem_maps[i].da + priv->mem_maps[i].pa;
+ return 0;
+ /* RISC-V SRAM window 0 (R_SRAM). */
+ if (da >= RSRAM_DA && da + len <= RSRAM_DA + priv->r_sram_sz) {
+ if (is_iomem)
+ *is_iomem = true;
+ return priv->r_sram + (da - RSRAM_DA);
+ }
+
+ return -EINVAL;
+}
+
+static int sun55i_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da)
+{
+ struct sun55i_e906_rproc *priv = sun55i_rproc_priv(rproc);
+ int i;
+
+ for (i = 0; i < priv->mem_maps_cnt; i++) {
+ if (pa < priv->mem_maps[i].pa ||
+ pa >= priv->mem_maps[i].pa + priv->mem_maps[i].len)
+ continue;
+ *da = pa - priv->mem_maps[i].pa + priv->mem_maps[i].da;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static void *sun55i_da_to_va(struct rproc *rproc, u64 da, size_t len,
+ bool *is_iomem)
+{
+ struct rproc_mem_entry *carveout;
+ phys_addr_t pa;
+ int ret;
+
+ ret = sun55i_da_to_pa(rproc, da, &pa);
+ if (ret)
+ return NULL;
+
+ list_for_each_entry(carveout, &rproc->carveouts, node) {
+ if (pa >= carveout->dma &&
+ pa < carveout->dma + carveout->len) {
+ if (is_iomem)
+ *is_iomem = true;
+ return carveout->va + (pa - carveout->dma);
+ }
+ /* RISC-V SRAM window 1 (R_SRAM1). */
+ if (da >= RSRAM1_DA && da + len <= RSRAM1_DA + priv->r_sram1_sz) {
+ if (is_iomem)
+ *is_iomem = true;
+ return priv->r_sram1 + (da - RSRAM1_DA);
+ }
+
+ /* Shared DDR is handled by the core through the carveouts. */
+ return NULL;
+}
+
@ -202,9 +284,22 @@ index 000000000000..111111111111
+{
+ struct sun55i_mbox *mb = container_of(work, struct sun55i_mbox, vq_work);
+ struct rproc *rproc = dev_get_drvdata(mb->client.dev);
+ unsigned long pending, flags;
+ int vq_id, oflow_vq;
+
+ if (rproc_vq_interrupt(rproc, mb->vq_id) == IRQ_NONE)
+ dev_dbg(&rproc->dev, "no message in vq%d\n", mb->vq_id);
+ spin_lock_irqsave(&mb->vq_lock, flags);
+ pending = mb->vq_pending;
+ mb->vq_pending = 0;
+ oflow_vq = mb->vq_id;
+ mb->vq_id = -1;
+ spin_unlock_irqrestore(&mb->vq_lock, flags);
+
+ for_each_set_bit(vq_id, &pending, BITS_PER_LONG)
+ if (rproc_vq_interrupt(rproc, vq_id) == IRQ_NONE)
+ dev_dbg(&rproc->dev, "no message in vq%d\n", vq_id);
+
+ if (oflow_vq >= 0 && rproc_vq_interrupt(rproc, oflow_vq) == IRQ_NONE)
+ dev_dbg(&rproc->dev, "no message in vq%d\n", oflow_vq);
+}
+
+static void sun55i_mb_rx_callback(struct mbox_client *cl, void *data)
@ -212,8 +307,18 @@ index 000000000000..111111111111
+ struct rproc *rproc = dev_get_drvdata(cl->dev);
+ struct sun55i_e906_rproc *priv = sun55i_rproc_priv(rproc);
+ struct sun55i_mbox *mb = container_of(cl, struct sun55i_mbox, client);
+ u32 vq_id = *(u32 *)data;
+ unsigned long flags;
+
+ mb->vq_id = *(u32 *)data;
+ if (vq_id < BITS_PER_LONG) {
+ spin_lock_irqsave(&mb->vq_lock, flags);
+ mb->vq_pending |= BIT(vq_id);
+ spin_unlock_irqrestore(&mb->vq_lock, flags);
+ } else {
+ spin_lock_irqsave(&mb->vq_lock, flags);
+ mb->vq_id = vq_id;
+ spin_unlock_irqrestore(&mb->vq_lock, flags);
+ }
+ queue_work(priv->workqueue, &mb->vq_work);
+}
+
@ -247,6 +352,8 @@ index 000000000000..111111111111
+ return 0;
+ }
+ INIT_WORK(&priv->mb.vq_work, sun55i_mb_vq_work);
+ spin_lock_init(&priv->mb.vq_lock);
+ priv->mb.vq_id = -1;
+ return 0;
+}
+
@ -264,39 +371,37 @@ index 000000000000..111111111111
+{
+ int ret;
+
+ ret = reset_control_assert(priv->mod_rst);
+ ret = reset_control_assert(priv->core_rst);
+ if (ret)
+ return ret;
+ ret = reset_control_assert(priv->cfg_rst);
+ if (ret)
+ return ret;
+ return reset_control_assert(priv->dbg_rst);
+ return reset_control_assert(priv->debug_rst);
+}
+
+static int sun55i_e906_deassert(struct sun55i_e906_rproc *priv)
+{
+ int ret;
+
+ ret = reset_control_deassert(priv->mod_rst);
+ ret = reset_control_deassert(priv->core_rst);
+ if (ret)
+ return ret;
+ ret = reset_control_deassert(priv->cfg_rst);
+ if (ret)
+ return ret;
+ return reset_control_deassert(priv->dbg_rst);
+ return reset_control_deassert(priv->debug_rst);
+}
+
+static int sun55i_e906_enable_sram(struct sun55i_e906_rproc *priv)
+{
+ int ret;
+
+ if (priv->pubsram_rst) {
+ ret = reset_control_deassert(priv->pubsram_rst);
+ if (ret)
+ return ret;
+ }
+ ret = reset_control_deassert(priv->sram_rst);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(priv->pubsram_clk);
+ ret = clk_prepare_enable(priv->sram_clk);
+ if (ret)
+ return ret;
+
@ -317,18 +422,21 @@ index 000000000000..111111111111
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(priv->cfg_clk);
+ ret = clk_prepare_enable(priv->bus_clk);
+ if (ret) {
+ dev_err(dev, "cfg clk enable failed\n");
+ dev_err(dev, "bus clk enable failed\n");
+ sun55i_e906_assert(priv);
+ return ret;
+ }
+
+ /* set start vector */
+ writel(priv->pc_entry, priv->e906_cfg + E906_STA_ADD_REG);
+ writel(rproc->bootaddr, priv->e906_cfg + E906_STA_ADD_REG);
+
+ ret = clk_prepare_enable(priv->mod_clk);
+ ret = clk_prepare_enable(priv->core_clk);
+ if (ret) {
+ dev_err(dev, "mod clk enable failed\n");
+ dev_err(dev, "core clk enable failed\n");
+ clk_disable_unprepare(priv->bus_clk);
+ sun55i_e906_assert(priv);
+ return ret;
+ }
+
@ -341,22 +449,22 @@ index 000000000000..111111111111
+ int ret;
+
+ /* reset before turning off the clock for rv core */
+ ret = reset_control_assert(priv->mod_rst);
+ ret = reset_control_assert(priv->core_rst);
+ if (ret)
+ return ret;
+
+ clk_disable_unprepare(priv->mod_clk);
+ clk_disable_unprepare(priv->cfg_clk);
+ clk_disable_unprepare(priv->core_clk);
+ clk_disable_unprepare(priv->bus_clk);
+
+ ret = reset_control_assert(priv->cfg_rst);
+ if (ret)
+ return ret;
+
+ ret = reset_control_assert(priv->dbg_rst);
+ ret = reset_control_assert(priv->debug_rst);
+ if (ret)
+ return ret;
+
+ clk_disable_unprepare(priv->pubsram_clk);
+ clk_disable_unprepare(priv->sram_clk);
+
+ return 0;
+}
@ -368,7 +476,7 @@ index 000000000000..111111111111
+
+ pm_runtime_get_sync(priv->dev);
+
+ ret = clk_prepare_enable(priv->pubsram_clk);
+ ret = clk_prepare_enable(priv->sram_clk);
+ if (ret)
+ return ret;
+
@ -376,11 +484,11 @@ index 000000000000..111111111111
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(priv->cfg_clk);
+ ret = clk_prepare_enable(priv->bus_clk);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(priv->mod_clk);
+ ret = clk_prepare_enable(priv->core_clk);
+ if (ret)
+ return ret;
+
@ -412,17 +520,7 @@ index 000000000000..111111111111
+
+static int sun55i_e906_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+ struct sun55i_e906_rproc *priv = sun55i_rproc_priv(rproc);
+ struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data;
+ int ret;
+
+ if (fw->size < sizeof(*ehdr))
+ return -EINVAL;
+
+ priv->pc_entry = ehdr->e_entry;
+
+ ret = rproc_elf_load_rsc_table(rproc, fw);
+ if (ret) {
+ if (rproc_elf_load_rsc_table(rproc, fw)) {
+ rproc->cached_table = NULL;
+ rproc->table_ptr = NULL;
+ rproc->table_sz = 0;
@ -467,12 +565,8 @@ index 000000000000..111111111111
+ return -EINVAL;
+ }
+
+ ret = sun55i_pa_to_da(rproc, rmem->base, &da);
+ if (ret) {
+ dev_err(dev, "memory-region %pa not in mappings\n",
+ &rmem->base);
+ return -EINVAL;
+ }
+ /* Shared DDR keeps the same address for both ends. */
+ da = rmem->base;
+
+ mem = rproc_mem_entry_init(dev, NULL,
+ (dma_addr_t)rmem->base,
@ -520,61 +614,14 @@ index 000000000000..111111111111
+ return 0;
+}
+
+static int sun55i_e906_find_rsc_table(struct rproc *rproc,
+ const struct firmware *fw,
+ struct elf32_shdr **find_shdr)
+{
+ struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data;
+ struct elf32_shdr *shdr;
+ const char *name_table;
+ const u8 *elf_data = fw->data;
+ size_t shdr_end, str_end;
+ u32 i;
+
+ if (fw->size < sizeof(*ehdr) ||
+ ehdr->e_ident[EI_CLASS] != ELFCLASS32)
+ return -EINVAL;
+
+ shdr_end = (size_t)ehdr->e_shoff +
+ (size_t)ehdr->e_shnum * sizeof(*shdr);
+ if (shdr_end > fw->size)
+ return -EINVAL;
+
+ if (ehdr->e_shstrndx >= ehdr->e_shnum)
+ return -EINVAL;
+
+ shdr = (struct elf32_shdr *)(elf_data + ehdr->e_shoff);
+ str_end = (size_t)shdr[ehdr->e_shstrndx].sh_offset +
+ shdr[ehdr->e_shstrndx].sh_size;
+ if (str_end > fw->size)
+ return -EINVAL;
+
+ name_table = (const char *)(elf_data +
+ shdr[ehdr->e_shstrndx].sh_offset);
+
+ for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
+ if (shdr->sh_name + sizeof(".resource_table") >
+ shdr[ehdr->e_shstrndx].sh_size)
+ continue;
+ if (strncmp(name_table + shdr->sh_name, ".resource_table",
+ sizeof(".resource_table") - 1))
+ continue;
+ *find_shdr = shdr;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static struct resource_table *
+sun55i_e906_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
+{
+ struct device *dev = &rproc->dev;
+ const struct firmware *fw;
+ struct elf32_shdr *shdr;
+ struct resource_table *table;
+ int ret;
+
+ ret = request_firmware(&fw, rproc->firmware, dev);
+ ret = request_firmware(&fw, rproc->firmware, &rproc->dev);
+ if (ret < 0)
+ return ERR_PTR(-ENODEV);
+
@ -584,16 +631,14 @@ index 000000000000..111111111111
+ return ERR_PTR(ret);
+ }
+
+ ret = sun55i_e906_find_rsc_table(rproc, fw, &shdr);
+ if (ret) {
+ release_firmware(fw);
+ return ERR_PTR(-ENODEV);
+ }
+
+ *table_sz = shdr->sh_size;
+ table = rproc_elf_find_loaded_rsc_table(rproc, fw);
+ release_firmware(fw);
+
+ return rproc_da_to_va(rproc, shdr->sh_addr, *table_sz, NULL);
+ if (!table)
+ return ERR_PTR(-ENODEV);
+
+ *table_sz = rproc->table_sz;
+ return table;
+}
+
+static const struct rproc_ops sun55i_e906_rproc_ops = {
@ -602,7 +647,7 @@ index 000000000000..111111111111
+ .start = sun55i_e906_start,
+ .stop = sun55i_e906_stop,
+ .attach = sun55i_e906_attach,
+ .da_to_va = sun55i_da_to_va,
+ .da_to_va = sun55i_e906_da_to_va,
+ .kick = sun55i_e906_kick,
+ .parse_fw = sun55i_e906_parse_fw,
+ .load = sun55i_e906_load,
@ -617,89 +662,71 @@ index 000000000000..111111111111
+ struct device *dev = priv->dev;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct resource *res;
+ u32 *map_array;
+ int ret, i, count;
+
+ priv->pubsram_clk = devm_clk_get(dev, "pubsram");
+ if (IS_ERR(priv->pubsram_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->pubsram_clk),
+ "no pubsram clock\n");
+ priv->sram_clk = devm_clk_get(dev, "sram");
+ if (IS_ERR(priv->sram_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->sram_clk),
+ "no sram clock\n");
+
+ priv->mod_clk = devm_clk_get(dev, "mod");
+ if (IS_ERR(priv->mod_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->mod_clk),
+ "no mod clock\n");
+ priv->core_clk = devm_clk_get(dev, "core");
+ if (IS_ERR(priv->core_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->core_clk),
+ "no core clock\n");
+
+ priv->cfg_clk = devm_clk_get(dev, "cfg");
+ if (IS_ERR(priv->cfg_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->cfg_clk),
+ "no cfg clock\n");
+ priv->bus_clk = devm_clk_get(dev, "bus");
+ if (IS_ERR(priv->bus_clk))
+ return dev_err_probe(dev, PTR_ERR(priv->bus_clk),
+ "no bus clock\n");
+
+ if (of_property_match_string(dev->of_node, "reset-names",
+ "pubsram-rst") >= 0) {
+ priv->pubsram_rst = devm_reset_control_get_exclusive(dev,
+ "pubsram-rst");
+ if (IS_ERR(priv->pubsram_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->pubsram_rst),
+ "no pubsram-rst reset\n");
+ }
+ priv->sram_rst = devm_reset_control_get_exclusive(dev, "sram");
+ if (IS_ERR(priv->sram_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->sram_rst),
+ "no sram reset\n");
+
+ priv->mod_rst = devm_reset_control_get_exclusive(dev, "mod-rst");
+ if (IS_ERR(priv->mod_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->mod_rst),
+ "no mod-rst reset\n");
+ priv->core_rst = devm_reset_control_get_exclusive(dev, "core");
+ if (IS_ERR(priv->core_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->core_rst),
+ "no core reset\n");
+
+ priv->cfg_rst = devm_reset_control_get_exclusive(dev, "cfg-rst");
+ priv->cfg_rst = devm_reset_control_get_exclusive(dev, "cfg");
+ if (IS_ERR(priv->cfg_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->cfg_rst),
+ "no cfg-rst reset\n");
+ "no cfg reset\n");
+
+ priv->dbg_rst = devm_reset_control_get_exclusive(dev, "dbg-rst");
+ if (IS_ERR(priv->dbg_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->dbg_rst),
+ "no dbg-rst reset\n");
+ priv->debug_rst = devm_reset_control_get_exclusive(dev, "debug");
+ if (IS_ERR(priv->debug_rst))
+ return dev_err_probe(dev, PTR_ERR(priv->debug_rst),
+ "no debug reset\n");
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "e906-cfg");
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
+ if (!res) {
+ dev_err(dev, "no e906-cfg resource\n");
+ dev_err(dev, "no cfg resource\n");
+ return -ENXIO;
+ }
+ priv->e906_cfg = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->e906_cfg))
+ return PTR_ERR(priv->e906_cfg);
+
+ count = of_property_count_elems_of_size(dev->of_node,
+ "memory-mappings",
+ sizeof(u32) * 3);
+ if (count <= 0) {
+ dev_err(dev, "no memory-mappings\n");
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "r_sram");
+ if (!res) {
+ dev_err(dev, "no r_sram resource\n");
+ return -ENXIO;
+ }
+ priv->r_sram_sz = resource_size(res);
+ priv->r_sram = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->r_sram))
+ return PTR_ERR(priv->r_sram);
+
+ priv->mem_maps_cnt = count;
+ priv->mem_maps = devm_kcalloc(dev, count, sizeof(*priv->mem_maps),
+ GFP_KERNEL);
+ if (!priv->mem_maps)
+ return -ENOMEM;
+
+ map_array = devm_kcalloc(dev, count * 3, sizeof(u32), GFP_KERNEL);
+ if (!map_array)
+ return -ENOMEM;
+
+ ret = of_property_read_u32_array(dev->of_node, "memory-mappings",
+ map_array, count * 3);
+ if (ret) {
+ dev_err(dev, "failed to read memory-mappings\n");
+ return ret;
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "r_sram1");
+ if (!res) {
+ dev_err(dev, "no r_sram1 resource\n");
+ return -ENXIO;
+ }
+ priv->r_sram1_sz = resource_size(res);
+ priv->r_sram1 = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->r_sram1))
+ return PTR_ERR(priv->r_sram1);
+
+ for (i = 0; i < count; i++) {
+ priv->mem_maps[i].da = map_array[i * 3];
+ priv->mem_maps[i].len = map_array[i * 3 + 1];
+ priv->mem_maps[i].pa = map_array[i * 3 + 2];
+ }
+
+ devm_kfree(dev, map_array);
+ return 0;
+}
+
@ -747,8 +774,8 @@ index 000000000000..111111111111
+ ret = rproc_add(rproc);
+ if (ret) {
+ pm_runtime_disable(dev);
+ destroy_workqueue(priv->workqueue);
+ sun55i_free_mbox(rproc);
+ destroy_workqueue(priv->workqueue);
+ rproc_free(rproc);
+ return ret;
+ }
@ -770,13 +797,14 @@ index 000000000000..111111111111
+ struct sun55i_e906_rproc *priv = sun55i_rproc_priv(rproc);
+
+ rproc_del(rproc);
+ destroy_workqueue(priv->workqueue);
+ sun55i_free_mbox(rproc);
+ destroy_workqueue(priv->workqueue);
+ pm_runtime_disable(&pdev->dev);
+ rproc_free(rproc);
+}
+
+static const struct of_device_id sun55i_e906_rproc_of_match[] = {
+ { .compatible = "allwinner,sun55i-a523-rproc" },
+ { .compatible = "allwinner,e906-rproc" },
+ { }
+};
@ -794,6 +822,6 @@ index 000000000000..111111111111
+
+MODULE_DESCRIPTION("Allwinner T527/A523 E906 RISC-V remoteproc driver");
+MODULE_LICENSE("GPL");
\ No newline at end of file
--
Armbian

View file

@ -14,14 +14,17 @@ heavy interrupt load (expired hrtimers make the core fall back to
min_delta_ticks), and matches the intval=0 read back from a wedged
machine over /dev/mem.
Floor the programmed interval at one tick and raise the registered
minimum so the core does not request an interval the timer cannot
generate.
The registered minimum is already TIMER_SYNC_TICKS + 1 in the vanilla
kernel (upstream "clocksource/drivers/timer-sun4i: Advertise a real
minimum delta"), so only the floor in set_next_event is missing here.
Floor the programmed interval at one tick so the core does not request
an interval the timer cannot generate.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/clocksource/timer-sun4i.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clocksource/timer-sun4i.c | 5 +++--
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-sun4i.c b/drivers/clocksource/timer-sun4i.c
index 111111111111..222222222222 100644

View file

@ -437,7 +437,8 @@
patches.megous/pb-7.2/0009-video-sun5i-eink-per-format-layer-attributes.patch
patches.megous/pb-7.2/0010-video-sun5i-eink-Program-DEBE-in-the-vendor-epdc_hw_.patch
patches.megous/pb-7.2/0011-video-sun5i-eink-Write-the-palette-to-the-pipe0-pale.patch
patches.megous/pb-7.2/0012-regulator-tps65185-Port-PocketBook-support-from-the-.patch
# DISABLED 2026-09-14: hunk 7 fails on 7.2.6 (context changed)
# patches.megous/pb-7.2/0012-regulator-tps65185-Port-PocketBook-support-from-the-.patch
patches.megous/pb-7.2/0013-video-sun5i-eink-Use-the-split-tps65185-supplies.patch
patches.megous/pb-7.2/0014-video-sun5i-eink-Per-frame-metadata-in-a-leading-buf.patch
patches.megous/pb-7.2/0015-iio-adc-sun4i-gpadc-Don-t-busy-wait-100ms-on-every-t.patch
@ -454,23 +455,23 @@
#
################################################################################
patches.drm/0032-clk-sunxi-ng-de2-Fix-Display-Engine-3.3-definitions.patch
patches.drm/0033-drm-sun4i-Add-support-for-DE33-CSC.patch
patches.drm/0034-drm-sun4i-vi_layer-Limit-formats-for-DE33.patch
patches.drm/0035-clk-sunxi-ng-de2-Export-register-regmap-for-DE33.patch
patches.drm/0036-dt-bindings-display-allwinner-Add-DE33-planes.patch
patches.drm/0037-drm-sun4i-Add-planes-driver.patch
patches.drm/0038-dt-bindings-display-allwinner-Split-H616-DE33-layer-.patch
patches.drm/0039-drm-sun4i-switch-DE33-to-new-bindings.patch
patches.drm/0040-dt-bindings-display-Add-H616-display-engine-compatib.patch
patches.drm/0041-drm-sun4i-Add-support-for-H616-TCON-TOP.patch
patches.drm/0042-drm-sun4i-tcon-Add-support-for-R40-LCD.patch
patches.drm/0043-drm-sun4i-Add-H616-TCON-TV-support.patch
patches.drm/0044-drm-sun4i-Add-support-for-H616-HDMI-PHY.patch
patches.drm/0045-drm-sun4i-Add-compatible-for-H616-display-engine.patch
patches.drm/0046-arm64-dts-allwinner-h616-Add-display-pipeline.patch
patches.drm/0047-arm64-dts-allwinner-h616-Enable-HDMI-on-several-boar.patch
patches.drm/0048-T95-broken-CD.patch
patches.drm/0032-clk-sunxi-ng-de2-Fix-Display-Engine-3.3-definitions.patch
patches.drm/0033-drm-sun4i-Add-support-for-DE33-CSC.patch
patches.drm/0034-drm-sun4i-vi_layer-Limit-formats-for-DE33.patch
patches.drm/0035-clk-sunxi-ng-de2-Export-register-regmap-for-DE33.patch
patches.drm/0036-dt-bindings-display-allwinner-Add-DE33-planes.patch
patches.drm/0037-drm-sun4i-Add-planes-driver.patch
patches.drm/0038-dt-bindings-display-allwinner-Split-H616-DE33-layer-.patch
patches.drm/0039-drm-sun4i-switch-DE33-to-new-bindings.patch
patches.drm/0040-dt-bindings-display-Add-H616-display-engine-compatib.patch
patches.drm/0041-drm-sun4i-Add-support-for-H616-TCON-TOP.patch
patches.drm/0042-drm-sun4i-tcon-Add-support-for-R40-LCD.patch
patches.drm/0043-drm-sun4i-Add-H616-TCON-TV-support.patch
patches.drm/0044-drm-sun4i-Add-support-for-H616-HDMI-PHY.patch
patches.drm/0045-drm-sun4i-Add-compatible-for-H616-display-engine.patch
patches.drm/0046-arm64-dts-allwinner-h616-Add-display-pipeline.patch
patches.drm/0047-arm64-dts-allwinner-h616-Enable-HDMI-on-several-boar.patch
patches.drm/0048-T95-broken-CD.patch
################################################################################
#
@ -581,6 +582,7 @@
patches.armbian/arm64-dts-sun50i-h6-pine-h64-add-wifi-rtl8723cs.patch
patches.armbian/arm64-dts-sun50i-h6-pine-h64-enable-usb3.patch
patches.armbian/arm64-dts-sun50i-h6-tanix-enable-ethernet.patch
patches.armbian/arm64-dts-sun55i-a527-cubie-a5e-enable-spi-nor.patch
patches.armbian/arm64-dts-sun55i-a527-cubie-a5e-enable-usbc-pcie-combophy.patch
patches.armbian/arm64-dts-sun55i-dtsi-add-iommu-usbc-pcie-combophy-nodes.patch
patches.armbian/arm64-dts-sun55i-t527-avaota-a1-enable-wifi-bt.patch
@ -698,3 +700,11 @@
patches.armbian/dt-bindings-display-allwinner-add-h3-h5-tv-encoder-and-mixer1.patch
patches.armbian/include-uapi-drm_fourcc-add-ARM-tiled-format-modifier.patch
patches.armbian/media-dt-bindings-allwinner-sun4i-a10-ir-add-a523-compatible.patch
# Sun55iw3 (A523/T527) HDMI display pipeline (DE33/RCQ) + board extras
patches.armbian/7000-drm-sun55i-a523-hdmi.patch
patches.armbian/7001-cedrus-sun55i-video-engine.patch
patches.armbian/7002-clk-and-dts-sun55i-a523.patch
patches.armbian/7003-drm-sun55i-a523-cursor-rcq.patch
patches.armbian/7004-drm-sun4i-a523-crtc-vblank-order.patch
patches.armbian/7005-clk-and-dts-sun55i-a523-remoteproc.patch

View file

@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Thu, 23 Oct 2025 09:10:08 +0000
Subject: arm64: dts: allwinner: sun55i-a523: Add PCIe and Combophy nodes
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
dts/upstream/src/arm64/allwinner/sun55i-a523.dtsi | 37 ++++
1 file changed, 37 insertions(+)
diff --git a/dts/upstream/src/arm64/allwinner/sun55i-a523.dtsi b/dts/upstream/src/arm64/allwinner/sun55i-a523.dtsi
index 111111111111..222222222222 100644
@@ -2,6 +2,7 @@
// Copyright (C) 2023-2024 Arm Ltd.
#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/phy/phy.h>
#include <dt-bindings/clock/sun6i-rtc.h>
#include <dt-bindings/clock/sun55i-a523-ccu.h>
#include <dt-bindings/clock/sun55i-a523-mcu-ccu.h>
@@ -828,6 +829,42 @@
assigned-clock-rates = <200000000>, <100000000>;
};
+ combophy: phy@4f00000 {
+ compatible = "allwinner,inno-combphy";
+ reg = <0x04f00000 0x80000>, /* Sub-System Application Registers */
+ <0x04f80000 0x80000>; /* Combo INNO PHY Registers */
+ reg-names = "phy-ctl", "phy-clk";
+ #phy-cells = <1>;
+ clocks = <&ccu CLK_USB3_REF>, <&ccu CLK_PLL_PERIPH0_200M>;
+ clock-names = "phyclk_ref","refclk_par";
+ resets = <&ccu RST_BUS_PCIE_USB3>;
+ reset-names = "phy_rst";
+ };
+
+ pcie: pcie@4800000 {
+ compatible = "allwinner,sun55i-pcie-v210-rc";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ bus-range = <0x0 0xff>;
+ reg = <0x04800000 0x480000>;
+ reg-names = "dbi";
+ device_type = "pci";
+ ranges = <0x00000800 0 0x20000000 0x20000000 0 0x01000000
+ 0x81000000 0 0x21000000 0x21000000 0 0x01000000
+ 0x82000000 0 0x22000000 0x22000000 0 0x0e000000>;
+ phys = <&combophy PHY_TYPE_PCIE>;
+ phy-names = "pcie-phy";
+ #interrupt-cells = <1>;
+ num-edma = <4>;
+ max-link-speed = <2>;
+ num-ib-windows = <8>;
+ num-ob-windows = <8>;
+ linux,pci-domain = <0>;
+ clocks = <&osc24M>, <&ccu CLK_PCIE_AUX>;
+ clock-names = "hosc", "pclk_aux";
+ power-domains = <&pck600 PD_PCIE>;
+ };
+
nmi_intc: interrupt-controller@7010320 {
compatible = "allwinner,sun55i-a523-nmi";
reg = <0x07010320 0xc>;
--
Armbian

View file

@ -0,0 +1,130 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Sat, 25 Oct 2025 16:50:43 +0000
Subject: arm64: dts: allwinner: sun55i-a527-cubie-a5e: Enable SPI0 and PCIe
with ComboPHY
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
dts/upstream/src/arm64/allwinner/sun55i-a527-cubie-a5e.dts | 83 ++++++++++
1 file changed, 83 insertions(+)
diff --git a/dts/upstream/src/arm64/allwinner/sun55i-a527-cubie-a5e.dts b/dts/upstream/src/arm64/allwinner/sun55i-a527-cubie-a5e.dts
index 111111111111..222222222222 100644
--- a/dts/upstream/src/arm64/allwinner/sun55i-a527-cubie-a5e.dts
+++ b/dts/upstream/src/arm64/allwinner/sun55i-a527-cubie-a5e.dts
@@ -45,6 +45,30 @@
gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
enable-active-high;
};
+
+ reg_pcie_vcc3v3: regulator-pcie-vcc3v3 {
+ compatible = "regulator-fixed";
+ regulator-name = "pcie-pwren";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ gpio = <&r_pio 0 11 GPIO_ACTIVE_HIGH>;
+ enable-active-high;
+ regulator-always-on;
+ regulator-boot-on;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie_pwren_pins>;
+ };
+
+ reg_vcc_3v3: vcc-3v3 {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc-3v3";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ gpio = <&r_pio 0 7 GPIO_ACTIVE_HIGH>;
+ regulator-always-on;
+ regulator-boot-on;
+ enable-active-high;
+ };
};
&ehci0 {
@@ -104,6 +128,30 @@
vcc-pi-supply = <&reg_cldo3>;
vcc-pj-supply = <&reg_cldo4>;
vcc-pk-supply = <&reg_cldo1>;
+
+ pcie0_pins_ph: pcie0-ph {
+ pins = "PH19";
+ function = "pcie0";
+ allwinner,pinmux = <6>;
+ drive-strength = <20>;
+ bias-pull-up;
+ power-source = <3300>;
+ };
+
+ spi0_pins: spi0-pins {
+ pins = "PC2","PC4", "PC12";
+ allwinner,pinmux = <4>;
+ function = "spi0";
+ drive-strength = <10>;
+ };
+
+ spi0_cs_pin: spi0-cs0-pin {
+ pins = "PC3";
+ allwinner,pinmux = <4>;
+ function = "spi0";
+ drive-strength = <10>;
+ bias-pull-up; /* cs, hold, wp should be pulled up */
+ };
};
&r_i2c0 {
@@ -282,6 +330,14 @@
* vcc-pl-supply = <&reg_aldo3>;
*/
vcc-pm-supply = <&reg_aldo3>;
+
+ pcie_pwren_pins: pcie-pwren-pins {
+ allwinner,pins = "PL11";
+ function = "gpio_out";
+ allwinner,pinmux = <1>;
+ drive-strength = <10>;
+ bias-disable; //bias-pull-up; or bias-pull-down;
+ };
};
&uart0 {
@@ -290,6 +346,33 @@
status = "okay";
};
+&combophy {
+ select3v3-supply = <&reg_vcc_3v3>;
+ status = "okay";
+};
+
+&spi0 {
+ pinctrl-0 = <&spi0_pins>, <&spi0_cs_pin>;
+ pinctrl-names = "default";
+ status = "okay";
+ w25q128: flash@0 {
+ compatible = "winbond,w25q128fw", "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <24000000>;
+ vcc-supply = <&reg_cldo1>;
+ status = "okay";
+ };
+};
+
+&pcie {
+ reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>;
+ wake-gpios = <&pio 7 12 GPIO_ACTIVE_HIGH>;
+ num-lanes = <1>;
+ slot-3v3-supply = <&reg_pcie_vcc3v3>;
+ switch-sel-gpios = <&pio 1 6 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+};
+
&usb_otg {
/*
* The USB-C port is the primary power supply, so in this configuration
--
Armbian

View file

@ -0,0 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Sat, 25 Oct 2025 10:00:00 +0000
Subject: Enable PCIe, NVMe, SPI and GPIO support in radxa-cubie-a5e_defconfig (and DRAM 936MHz)
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
1 file changed, 21 insertions(+)
diff --git a/configs/radxa-cubie-a5e_defconfig b/configs/radxa-cubie-a5e_defconfig
index 111111111111..222222222222 100644
--- a/configs/radxa-cubie-a5e_defconfig
+++ b/configs/radxa-cubie-a5e_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_DEFAULT_DEVICE_TREE="allwinner/sun55i-a527-cubie-a5e"
CONFIG_SPL=y
+CONFIG_DRAM_CLK=936
CONFIG_DRAM_SUNXI_DX_ODT=0x07070707
CONFIG_DRAM_SUNXI_DX_DRI=0x0d0d0d0d
CONFIG_DRAM_SUNXI_CA_DRI=0x0e0e
@@ -33,3 +34,23 @@ CONFIG_AXP_DCDC2_VOLT=920
CONFIG_AXP_DCDC3_VOLT=1100
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_OHCI_HCD=y
+CONFIG_PHY_SUN55I_PCIE_USB3=y
+CONFIG_PCI=y
+CONFIG_PCIE_SUN55I_RC=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_NVME=y
+CONFIG_NVME_PCI=y
+CONFIG_SPI_SUNXI=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_LSBLK=y
+CONFIG_CMD_CAT=y
+CONFIG_BLKMAP=y
+CONFIG_MTD=y
+CONFIG_SPI=y
+CONFIG_CMD_SF=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_BOOTDEV_SPI_FLASH=y
+CONFIG_CMD_BOOTDEV=y
+CONFIG_SPL_SPI_SUNXI=y
--
Armbian

View file

@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Sat, 25 Oct 2025 10:00:00 +0000
Subject: clk: sunxi: Add PCIe and USB3 clock support for SUN55I A523
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
2 files changed, 4 insertions(+)
diff --git a/drivers/clk/sunxi/clk_a523.c b/drivers/clk/sunxi/clk_a523.c
index 111111111111..222222222222 100644
--- a/drivers/clk/sunxi/clk_a523.c
+++ b/drivers/clk/sunxi/clk_a523.c
@@ -46,6 +46,8 @@ static struct ccu_clk_gate a523_gates[] = {
[CLK_BUS_EHCI0] = GATE(0xa8c, BIT(4)),
[CLK_BUS_EHCI1] = GATE(0xa8c, BIT(5)),
[CLK_BUS_OTG] = GATE(0xa8c, BIT(8)),
+ [CLK_USB3_REF] = GATE(0x0A84, BIT(31)),
+ [CLK_PCIE_AUX] = GATE(0xaa0, BIT(31)),
};
static struct ccu_reset a523_resets[] = {
@@ -75,6 +77,7 @@ static struct ccu_reset a523_resets[] = {
[RST_BUS_EHCI0] = RESET(0xa8c, BIT(20)),
[RST_BUS_EHCI1] = RESET(0xa8c, BIT(21)),
[RST_BUS_OTG] = RESET(0xa8c, BIT(24)),
+ [RST_BUS_PCIE_USB3] = RESET(0xaac, BIT(24)),
};
const struct ccu_desc a523_ccu_desc = {
diff --git a/dts/upstream/include/dt-bindings/clock/sun55i-a523-ccu.h b/dts/upstream/include/dt-bindings/clock/sun55i-a523-ccu.h
index 111111111111..222222222222 100644
--- a/dts/upstream/include/dt-bindings/clock/sun55i-a523-ccu.h
+++ b/dts/upstream/include/dt-bindings/clock/sun55i-a523-ccu.h
@@ -186,5 +186,6 @@
#define CLK_FANOUT1 177
#define CLK_FANOUT2 178
#define CLK_NPU 179
+#define CLK_USB3_REF 180
#endif /* _DT_BINDINGS_CLK_SUN55I_A523_CCU_H_ */
--
Armbian

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,705 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Sat, 25 Oct 2025 20:32:35 +0000
Subject: phy: allwinner: Add SUN55I INNO combo PHY driver for PCIe/USB3
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
drivers/phy/allwinner/Kconfig | 8 +
drivers/phy/allwinner/Makefile | 1 +
drivers/phy/allwinner/phy-sun55i-pcie-usb3.c | 656 ++++++++++
3 files changed, 665 insertions(+)
diff --git a/drivers/phy/allwinner/Kconfig b/drivers/phy/allwinner/Kconfig
index 111111111111..222222222222 100644
--- a/drivers/phy/allwinner/Kconfig
+++ b/drivers/phy/allwinner/Kconfig
@@ -33,3 +33,11 @@ config PHY_SUN50I_USB3
help
Enable this to support the USB3 transceiver that is part of
Allwinner sun50i SoCs.
+
+config PHY_SUN55I_PCIE_USB3
+ bool "Allwinner SUN55I INNO COMBO PHY Driver"
+ depends on ARCH_SUNXI
+ select PHY
+ help
+ Enable this to support the Allwinner sun55i PCIe/USB3.0 combo PHY
+ with INNOSILICON IP block.
diff --git a/drivers/phy/allwinner/Makefile b/drivers/phy/allwinner/Makefile
index 111111111111..222222222222 100644
--- a/drivers/phy/allwinner/Makefile
+++ b/drivers/phy/allwinner/Makefile
@@ -5,3 +5,4 @@
obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o
obj-$(CONFIG_PHY_SUN50I_USB3) += phy-sun50i-usb3.o
+obj-$(CONFIG_PHY_SUN55I_PCIE_USB3) += phy-sun55i-pcie-usb3.o
\ No newline at end of file
diff --git a/drivers/phy/allwinner/phy-sun55i-pcie-usb3.c b/drivers/phy/allwinner/phy-sun55i-pcie-usb3.c
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/drivers/phy/allwinner/phy-sun55i-pcie-usb3.c
@@ -0,0 +1,657 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Allwinner PIPE USB3.0 PCIE Combo Phy driver
+ *
+ * Copyright(c) 2020 - 2024 Allwinner Technology Co.,Ltd. All rights reserved.
+ *
+ * sun55i-inno-combophy.c: chenhuaqiang <chenhuaqiang@allwinnertech.com>
+ */
+
+
+#include <clk-uclass.h>
+#include <dm.h>
+#include <log.h>
+#include <dm/device.h>
+#include <dm/device_compat.h>
+#include <dm/lists.h>
+#include <dt-bindings/phy/phy.h>
+#include <generic-phy.h>
+#include <asm/io.h>
+#include <power-domain.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <power/regulator.h>
+#include <reset.h>
+
+
+#define sun55i_COMBOPHY_CTL_BASE 0x04f00000
+#define sun55i_COMBOPHY_CLK_BASE 0x04f80000
+
+/* PCIE USB3 Sub-System Registers */
+/* Sub-System Version Reset Register */
+#define PCIE_USB3_SYS_VER 0x00
+
+/* CCMU Base Address */
+#define SUNXI_CCMU_BASE 0x02001000
+#define SUNXI_CCM_BASE (SUNXI_CCMU_BASE)
+
+/* Sub-System PCIE Bus Gating Reset Register */
+#define PCIE_BRG_REG_RST 16
+#define PCIE_BGR_REG (SUNXI_CCM_BASE + 0x0aac)
+
+/* Sub-System PCIE Bus Gating Reset Register */
+#define PCIE_COMBO_PHY_BGR 0x04
+#define PCIE_SLV_ACLK_EN BIT(18)
+#define PCIE_ACLK_EN BIT(17)
+#define PCIE_HCLK_EN BIT(16)
+#define PCIE_PERSTN BIT(1)
+#define PCIE_PW_UP_RSTN BIT(0)
+
+/* Sub-System USB3 Bus Gating Reset Register */
+#define USB3_COMBO_PHY_BGR 0x08
+#define USB3_ACLK_EN BIT(17)
+#define USB3_HCLK_EN BIT(16)
+#define USB3_U2_PHY_RSTN BIT(4)
+#define USB3_U2_PHY_MUX_EN BIT(3)
+#define USB3_U2_PHY_MUX_SEL BIT(0)
+#define USB3_RESETN BIT(0)
+
+/* Sub-System PCIE PHY Control Register */
+#define PCIE_COMBO_PHY_CTL 0x10
+#define PHY_USE_SEL BIT(31) /* 0:PCIE; 1:USB3 */
+#define PHY_CLK_SEL BIT(30) /* 0:internal clk; 1:external clk */
+#define PHY_BIST_EN BIT(16)
+#define PHY_PIPE_SW BIT(9)
+#define PHY_PIPE_SEL BIT(8) /* 0:rstn by PCIE or USB3; 1:rstn by PHY_PIPE_SW */
+#define PHY_PIPE_CLK_INVERT BIT(4)
+#define PHY_FPGA_SYS_RSTN BIT(1) /* for FPGA */
+#define PHY_RSTN BIT(0)
+
+/* PHY CLK Registers (offset from sun55i_COMBOPHY_CLK_BASE) */
+#define PCIE_REF_CLK_REG_PCIE_REF_CLK_GATING_CLEAR_MASK 0x80000000
+
+/* Registers */
+#define COMBO_REG_SYSVER(comb_base_addr) ((comb_base_addr) \
+ + PCIE_USB3_SYS_VER)
+#define COMBO_REG_PCIEBGR(comb_base_addr) ((comb_base_addr) \
+ + PCIE_COMBO_PHY_BGR)
+#define COMBO_REG_USB3BGR(comb_base_addr) ((comb_base_addr) \
+ + USB3_COMBO_PHY_BGR)
+#define COMBO_REG_PHYCTRL(comb_base_addr) ((comb_base_addr) \
+ + PCIE_COMBO_PHY_CTL)
+
+/* Sub-System Version Number */
+#define COMBO_VERSION_01 (0x10000)
+#define COMBO_VERSION_ANY (0x0)
+
+enum phy_use_sel {
+ PHY_USE_BY_PCIE = 0, /* PHY used by PCIE */
+ PHY_USE_BY_USB3, /* PHY used by USB3 */
+ PHY_USE_BY_PCIE_USB3_U2,/* PHY used by PCIE & USB3_U2 */
+};
+
+enum phy_refclk_sel {
+ INTER_SIG_REF_CLK = 0, /* PHY use internal single end reference clock */
+ EXTER_DIF_REF_CLK, /* PHY use external single end reference clock */
+};
+
+struct sun55i_combophy_of_data {
+ bool has_cfg_clk;
+ bool has_slv_clk;
+ bool has_phy_mbus_clk;
+ bool has_phy_ahb_clk;
+ bool has_pcie_axi_clk;
+ bool has_u2_phy_mux;
+ bool need_noppu_rst;
+ bool has_u3_phy_data_quirk;
+ bool need_optimize_jitter;
+};
+
+struct sun55i_combphy {
+ struct device *dev;
+ struct phy *phy;
+ void __iomem *phy_ctl; /* parse dts, control the phy mode, reset and power */
+ void __iomem *phy_clk; /* parse dts, set the phy clock */
+
+ struct reset_ctl reset;
+ struct reset_ctl noppu_reset;
+
+ struct clk *phyclk_ref;
+ struct clk *refclk_par;
+ struct clk *phyclk_cfg;
+ struct clk *cfgclk_par;
+ struct clk *phy_mclk;
+ struct clk *phy_hclk;
+ struct clk *phy_axi;
+ struct clk *phy_axi_par;
+ __u8 mode;
+ __u32 vernum; /* version number */
+ enum phy_use_sel user;
+ enum phy_refclk_sel ref;
+ const struct sun55i_combophy_of_data *drvdata;
+
+ struct udevice *select3v3_supply;
+ bool initialized;
+};
+
+static void sun55i_combphy_usb3_phy_set(struct sun55i_combphy *combphy, bool enable)
+{
+ u32 val, tmp = 0;
+
+ val = readl(combphy->phy_clk + 0x1418);
+ tmp = GENMASK(17, 16);
+ if (enable) {
+ val &= ~tmp;
+ val |= BIT(25);
+ } else {
+ val |= tmp;
+ val &= ~BIT(25);
+ }
+ writel(val, combphy->phy_clk + 0x1418);
+
+ /* reg_rx_eq_bypass[3]=1, rx_ctle_res_cal_bypass */
+ val = readl(combphy->phy_clk + 0x0674);
+ if (enable)
+ val |= BIT(3);
+ else
+ val &= ~BIT(3);
+ writel(val, combphy->phy_clk + 0x0674);
+
+ /* rx_ctle_res_cal=0xf, 0x4->0xf */
+ val = readl(combphy->phy_clk + 0x0704);
+ tmp = GENMASK(9, 8) | BIT(11);
+ if (enable)
+ val |= tmp;
+ else
+ val &= ~tmp;
+ writel(val, combphy->phy_clk + 0x0704);
+
+ /* CDR_div_fin_gain1 */
+ val = readl(combphy->phy_clk + 0x0400);
+ if (enable)
+ val |= BIT(4);
+ else
+ val &= ~BIT(4);
+ writel(val, combphy->phy_clk + 0x0400);
+
+ /* CDR_div1_fin_gain1 */
+ val = readl(combphy->phy_clk + 0x0404);
+ tmp = GENMASK(3, 0) | BIT(5);
+ if (enable)
+ val |= tmp;
+ else
+ val &= ~tmp;
+ writel(val, combphy->phy_clk + 0x0404);
+
+ /* CDR_div3_fin_gain1 */
+ val = readl(combphy->phy_clk + 0x0408);
+ if (enable)
+ val |= BIT(5);
+ else
+ val &= ~BIT(5);
+ writel(val, combphy->phy_clk + 0x0408);
+
+ val = readl(combphy->phy_clk + 0x109c);
+ if (enable)
+ val |= BIT(1);
+ else
+ val &= ~BIT(1);
+ writel(val, combphy->phy_clk + 0x109c);
+
+ /* balance parm configure */
+ if (combphy->drvdata->has_u3_phy_data_quirk) {
+ val = readl(combphy->phy_clk + 0x0804);
+ if (enable)
+ val |= (0x6<<4);
+ else
+ val &= ~(0xf<<4);
+ writel(val, combphy->phy_clk + 0x0804);
+ }
+
+ /* SSC configure */
+ val = readl(combphy->phy_clk + 0x107c);
+ tmp = 0x3f << 12;
+ val = val & (~tmp);
+ val |= ((0x1 << 12) & tmp); /* div_N */
+ writel(val, combphy->phy_clk + 0x107c);
+
+ val = readl(combphy->phy_clk + 0x1020);
+ tmp = 0x1f << 0;
+ val = val & (~tmp);
+ val |= ((0x6 << 0) & tmp); /* modulation freq div */
+ writel(val, combphy->phy_clk + 0x1020);
+
+ val = readl(combphy->phy_clk + 0x1034);
+ tmp = 0x7f << 16;
+ val = val & (~tmp);
+ val |= ((0x9 << 16) & tmp); /* spread[6:0], 400*9=4410ppm ssc */
+ writel(val, combphy->phy_clk + 0x1034);
+
+ val = readl(combphy->phy_clk + 0x101c);
+ tmp = 0x1 << 27;
+ val = val & (~tmp);
+ val |= ((0x1 << 27) & tmp); /* choose downspread */
+
+ tmp = 0x1 << 28;
+ val = val & (~tmp);
+ if (enable)
+ val |= ((0x0 << 28) & tmp); /* don't disable ssc = 0 */
+ else
+ val |= ((0x1 << 28) & tmp); /* don't enable ssc = 1 */
+ writel(val, combphy->phy_clk + 0x101c);
+
+#ifdef SUN55i_INNO_COMMBOPHY_DEBUG
+ /* TX Eye configure bypass_en */
+ val = readl(combphy->phy_clk + 0x0ddc);
+ if (enable)
+ val |= BIT(4); /* 0x0ddc[4]=1 */
+ else
+ val &= ~BIT(4);
+ writel(val, combphy->phy_clk + 0x0ddc);
+
+ /* Leg_cur[6:0] - 7'd84 */
+ val = readl(combphy->phy_clk + 0x0ddc);
+ val |= ((0x54 & BIT(6)) >> 3); /* 0x0ddc[3] */
+ writel(val, combphy->phy_clk + 0x0ddc);
+
+ val = readl(combphy->phy_clk + 0x0de0);
+ val |= ((0x54 & GENMASK(5, 0)) << 2); /* 0x0de0[7:2] */
+ writel(val, combphy->phy_clk + 0x0de0);
+
+ /* Leg_curb[5:0] - 6'd18 */
+ val = readl(combphy->phy_clk + 0x0de4);
+ val |= ((0x12 & GENMASK(5, 1)) >> 1); /* 0x0de4[4:0] */
+ writel(val, combphy->phy_clk + 0x0de4);
+
+ val = readl(combphy->phy_clk + 0x0de8);
+ val |= ((0x12 & BIT(0)) << 7); /* 0x0de8[7] */
+ writel(val, combphy->phy_clk + 0x0de8);
+
+ /* Exswing_isel */
+ val = readl(combphy->phy_clk + 0x0028);
+ val |= (0x4 << 28); /* 0x28[30:28] */
+ writel(val, combphy->phy_clk + 0x0028);
+
+ /* Exswing_en */
+ val = readl(combphy->phy_clk + 0x0028);
+ if (enable)
+ val |= BIT(31); /* 0x28[31]=1 */
+ else
+ val &= ~BIT(31);
+ writel(val, combphy->phy_clk + 0x0028);
+#endif
+}
+
+static int sun55i_combphy_usb3_init(struct sun55i_combphy *combphy)
+{
+ sun55i_combphy_usb3_phy_set(combphy, true);
+
+ return 0;
+}
+
+// static int sun55i_combphy_usb3_exit(struct sun55i_combphy *combphy)
+// {
+// sun55i_combphy_usb3_phy_set(combphy, false);
+
+// return 0;
+// }
+
+static void sun55i_combphy_pcie_phy_enable(struct sun55i_combphy *combphy)
+{
+ u32 val;
+
+ /* set the phy:
+ * bit(18): slv aclk enable
+ * bit(17): aclk enable
+ * bit(16): hclk enbale
+ * bit(1) : pcie_presetn
+ * bit(0) : pcie_power_up_rstn
+ */
+ val = readl(combphy->phy_ctl + PCIE_COMBO_PHY_BGR);
+ val &= (~(0x03<<0));
+ val &= (~(0x03<<16));
+ val |= (0x03<<0);
+ if (combphy->drvdata->has_slv_clk)
+ val |= (0x07<<16);
+ else
+ val |= (0x03<<16);
+ writel(val, combphy->phy_ctl + PCIE_COMBO_PHY_BGR);
+
+
+ /* select phy mode, phy assert */
+ val = readl(combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+ val &= (~PHY_USE_SEL);
+ val &= (~(0x03<<8));
+ val &= (~PHY_FPGA_SYS_RSTN);
+ val &= (~PHY_RSTN);
+ writel(val, combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+
+ /* phy De-assert */
+ val = readl(combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+ val &= (~PHY_CLK_SEL);
+ val &= (~(0x03<<8));
+ val &= (~PHY_FPGA_SYS_RSTN);
+ val &= (~PHY_RSTN);
+ val |= PHY_RSTN;
+ writel(val, combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+
+ val = readl(combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+ val &= (~PHY_CLK_SEL);
+ val &= (~(0x03<<8));
+ val &= (~PHY_FPGA_SYS_RSTN);
+ val &= (~PHY_RSTN);
+ val |= PHY_RSTN;
+ val |= (PHY_FPGA_SYS_RSTN);
+ writel(val, combphy->phy_ctl + PCIE_COMBO_PHY_CTL);
+
+}
+
+static void sun55i_combphy_pcie_phy_100M(struct sun55i_combphy *combphy)
+{
+ u32 val;
+
+ val = readl(combphy->phy_clk + 0x1004);
+ val &= ~(0x3<<3);
+ val &= ~(0x1<<0);
+ val |= (0x1<<0);
+ val |= (0x1<<2);
+ val |= (0x1<<4);
+ writel(val, combphy->phy_clk + 0x1004);
+
+ val = readl(combphy->phy_clk + 0x1018);
+ val &= ~(0x3<<4);
+ val |= (0x3<<4);
+ writel(val, combphy->phy_clk + 0x1018);
+
+ val = readl(combphy->phy_clk + 0x101c);
+ val &= ~(0x0fffffff);
+ writel(val, combphy->phy_clk + 0x101c);
+
+ /* if need optimize jitter parm*/
+ if (combphy->drvdata->need_optimize_jitter) {
+ val = readl(combphy->phy_clk + 0x107c);
+ val &= ~(0x3ffff);
+ val |= (0x4<<12);
+ val |= 0x64;
+ writel(val, combphy->phy_clk + 0x107c);
+
+ val = readl(combphy->phy_clk + 0x1030);
+ val &= ~(0x3<<20);
+ writel(val, combphy->phy_clk + 0x1030);
+
+ val = readl(combphy->phy_clk + 0x1050);
+ val &= ~(0x7<<0);
+ val &= ~(0x7<<5);
+ val &= ~(0x3<<3);
+ val |= (0x3<<3);
+ writel(val, combphy->phy_clk + 0x1050);
+ } else {
+ val = readl(combphy->phy_clk + 0x107c);
+ val &= ~(0x3ffff);
+ val |= (0x2<<12);
+ val |= 0x32;
+ writel(val, combphy->phy_clk + 0x107c);
+
+ val = readl(combphy->phy_clk + 0x1030);
+ val &= ~(0x3<<20);
+ writel(val, combphy->phy_clk + 0x1030);
+
+ val = readl(combphy->phy_clk + 0x1050);
+ val &= ~(0x7<<5);
+ val |= (0x1<<5);
+ writel(val, combphy->phy_clk + 0x1050);
+ }
+
+ val = readl(combphy->phy_clk + 0x1054);
+ val &= ~(0x7<<5);
+ val |= (0x1<<5);
+ writel(val, combphy->phy_clk + 0x1054);
+
+ val = readl(combphy->phy_clk + 0x0804);
+ val &= ~(0xf<<4);
+ val |= (0xc<<4);
+ writel(val, combphy->phy_clk + 0x0804);
+
+ val = readl(combphy->phy_clk + 0x109c);
+ val &= ~(0x3<<8);
+ val |= (0x1<<1);
+ writel(val, combphy->phy_clk + 0x109c);
+
+ writel(0x80540a0a, combphy->phy_clk + 0x1418);
+}
+
+static int sun55i_combphy_pcie_init(struct sun55i_combphy *combphy)
+{
+ sun55i_combphy_pcie_phy_100M(combphy);
+
+ sun55i_combphy_pcie_phy_enable(combphy);
+
+ return 0;
+}
+
+static int sun55i_combphy_set_mode(struct sun55i_combphy *combphy)
+{
+ switch (combphy->mode) {
+ case PHY_TYPE_PCIE:
+ sun55i_combphy_pcie_init(combphy);
+ break;
+ case PHY_TYPE_USB3:
+ if (combphy->user == PHY_USE_BY_PCIE_USB3_U2) {
+ sun55i_combphy_pcie_init(combphy);
+ } else if (combphy->user == PHY_USE_BY_USB3) {
+ sun55i_combphy_usb3_init(combphy);
+ }
+ break;
+ default:
+ printf("incompatible PHY type\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static void combo_phy_mode_set(struct sun55i_combphy *combphy, bool enable)
+{
+ u32 val;
+
+ val = readl(COMBO_REG_PHYCTRL(combphy->phy_ctl));
+
+ /* Set PHY_USE_SEL based on user (default: clear for PCIE/PCIE_USB3_U2, set for USB3) */
+ val &= ~PHY_USE_SEL; /* Default: clear (PCIE mode) */
+ if (combphy->user == PHY_USE_BY_USB3)
+ val |= PHY_USE_SEL;
+
+ /* Set PHY_CLK_SEL based on ref (default: clear for internal, set for external) */
+ val &= ~PHY_CLK_SEL; /* Default: clear (internal clock) */
+ if (combphy->ref == EXTER_DIF_REF_CLK)
+ val |= PHY_CLK_SEL;
+
+ /* Set or clear PHY_RSTN based on enable */
+ if (enable)
+ val |= PHY_RSTN;
+ else
+ val &= ~PHY_RSTN;
+
+ writel(val, COMBO_REG_PHYCTRL(combphy->phy_ctl));
+}
+
+/* PCIE USB3 Sub-system Application */
+static void combo_pcie_clk_set(struct sun55i_combphy *combphy, bool enable)
+{
+ u32 val, tmp = 0;
+
+ val = readl(COMBO_REG_PCIEBGR(combphy->phy_ctl));
+ if (combphy->drvdata->has_slv_clk)
+ tmp = PCIE_SLV_ACLK_EN | PCIE_ACLK_EN | PCIE_HCLK_EN | PCIE_PERSTN | PCIE_PW_UP_RSTN;
+ else
+ tmp = PCIE_ACLK_EN | PCIE_HCLK_EN | PCIE_PERSTN | PCIE_PW_UP_RSTN;
+ if (enable)
+ val |= tmp;
+ else
+ val &= ~tmp;
+ writel(val, COMBO_REG_PCIEBGR(combphy->phy_ctl));
+}
+
+static void combo_usb3_clk_set(struct sun55i_combphy *combphy, bool enable)
+{
+ u32 val, tmp = 0;
+
+ val = readl(COMBO_REG_USB3BGR(combphy->phy_ctl));
+ if (combphy->drvdata->has_u2_phy_mux)
+ tmp = USB3_ACLK_EN | USB3_HCLK_EN | USB3_U2_PHY_MUX_SEL | USB3_U2_PHY_RSTN | USB3_U2_PHY_MUX_EN;
+ else
+ tmp = USB3_ACLK_EN | USB3_HCLK_EN | USB3_RESETN;
+ if (enable)
+ val |= tmp;
+ else
+ val &= ~tmp;
+ writel(val, COMBO_REG_USB3BGR(combphy->phy_ctl));
+}
+
+static u32 combo_sysver_get(struct sun55i_combphy *combphy)
+{
+ u32 reg;
+
+ reg = readl(COMBO_REG_SYSVER(combphy->phy_ctl));
+
+ return reg;
+}
+
+static void pcie_usb3_sub_system_enable(struct sun55i_combphy *combphy)
+{
+ combo_phy_mode_set(combphy, true);
+
+ if (combphy->user == PHY_USE_BY_PCIE)
+ combo_pcie_clk_set(combphy, true);
+ else if (combphy->user == PHY_USE_BY_USB3)
+ combo_usb3_clk_set(combphy, true);
+ else if (combphy->user == PHY_USE_BY_PCIE_USB3_U2) {
+ combo_pcie_clk_set(combphy, true);
+ combo_usb3_clk_set(combphy, true);
+ }
+
+ combphy->vernum = combo_sysver_get(combphy);
+}
+
+static int pcie_usb3_sub_system_init(void *phy)
+{
+ struct sun55i_combphy *combphy = (struct sun55i_combphy *)(phy);
+ unsigned long reg_value = 0;
+
+ if (combphy->initialized)
+ return 0;
+
+ reg_value = readl(PCIE_BGR_REG);
+ reg_value |= (1 << PCIE_BRG_REG_RST);
+ writel(reg_value, PCIE_BGR_REG);
+
+ reg_value = 0x81000001;
+ writel(reg_value, 0x2001a84);
+
+ pcie_usb3_sub_system_enable(combphy);
+
+ combphy->initialized = true;
+
+ return 0;
+}
+
+int sun55i_combphy_init(struct phy *phy)
+{
+ struct sun55i_combphy *combphy = dev_get_priv(phy->dev);
+ int ret;
+
+ if (!combphy) {
+ printf("PHY drvdata not set!\n");
+ return -EIO;
+ }
+
+ if (combphy->select3v3_supply) {
+ ret = regulator_set_enable_if_allowed(combphy->select3v3_supply, true);
+ if (ret && ret != -EALREADY) {
+ printf("PHY: Failed to enable 3.3V supply: %d\n", ret);
+ return ret;
+ }
+ }
+
+ ret = reset_deassert(&combphy->reset);
+ if (ret) {
+ printf("PHY: Failed to deassert reset: %d\n", ret);
+ regulator_set_enable(combphy->select3v3_supply, false);
+ return ret;
+ }
+
+ ret = pcie_usb3_sub_system_init(combphy);
+ if (ret) {
+ printf("PHY: failed to init sub system\n");
+ reset_assert(&combphy->reset);
+ regulator_set_enable(combphy->select3v3_supply, false);
+ return ret;
+ }
+
+ ret = sun55i_combphy_set_mode(combphy);
+ if (ret) {
+ printf("PHY: invalid number of arguments\n");
+ reset_assert(&combphy->reset);
+ regulator_set_enable(combphy->select3v3_supply, false);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct sun55i_combophy_of_data sun55i_inno_v1_of_data = {
+ .has_cfg_clk = false,
+};
+
+static int sun55i_inno_phy_probe(struct udevice *dev)
+{
+ struct sun55i_combphy *combphy = dev_get_priv(dev);
+ int ret;
+
+ combphy->phy_ctl = dev_read_addr_name_ptr(dev, "phy-ctl");
+ if (!combphy->phy_ctl)
+ return -ENODEV;
+
+ combphy->phy_clk = dev_read_addr_name_ptr(dev, "phy-clk");
+ if (!combphy->phy_clk)
+ return -ENODEV;
+
+ ret = reset_get_by_index(dev, 0, &combphy->reset);
+ if (ret)
+ return ret;
+
+ ret = device_get_supply_regulator(dev, "select3v3-supply", &combphy->select3v3_supply);
+ if (ret)
+ return ret;
+
+ combphy->drvdata = (const struct sun55i_combophy_of_data *)dev_get_driver_data(dev);
+ combphy->user = PHY_USE_BY_PCIE;
+ combphy->mode = PHY_TYPE_PCIE;
+ combphy->ref = EXTER_DIF_REF_CLK;
+
+ return 0;
+}
+
+static const struct phy_ops sun55i_inno_phy_ops = {
+ .init = sun55i_combphy_init,
+};
+
+static const struct udevice_id sun55i_inno_phy_of_match_table[] = {
+ {
+ .compatible = "allwinner,inno-combphy",
+ .data = (ulong)&sun55i_inno_v1_of_data,
+ },
+ {},
+};
+
+U_BOOT_DRIVER(sun55i_inno_combophy) = {
+ .name = "sun55i_inno_combophy",
+ .id = UCLASS_PHY,
+ .of_match = sun55i_inno_phy_of_match_table,
+ .ops = &sun55i_inno_phy_ops,
+ .probe = sun55i_inno_phy_probe,
+ .priv_auto = sizeof(struct sun55i_combphy),
+};
--
Armbian

View file

@ -0,0 +1,205 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Mon, 10 Nov 2025 22:10:36 +0000
Subject: spi: sunxi: Add support for Allwinner A523 SPI controllers in SPL
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
arch/arm/mach-sunxi/spl_spi_sunxi.c | 107 ++++++----
1 file changed, 68 insertions(+), 39 deletions(-)
diff --git a/arch/arm/mach-sunxi/spl_spi_sunxi.c b/arch/arm/mach-sunxi/spl_spi_sunxi.c
index 111111111111..222222222222 100644
--- a/arch/arm/mach-sunxi/spl_spi_sunxi.c
+++ b/arch/arm/mach-sunxi/spl_spi_sunxi.c
@@ -101,6 +101,8 @@
#define SPI0_CLK_DIV_BY_4 0x1001
#define SPI0_CLK_DIV_BY_32 0x100f
+#define SUN55I_BUF_STA_REG 0x400
+
/*****************************************************************************/
/*
@@ -110,22 +112,29 @@
*/
static void spi0_pinmux_setup(unsigned int pin_function)
{
+ if (IS_ENABLED(CONFIG_MACH_SUN55I_A523)) {
+ sunxi_gpio_set_cfgpin(SUNXI_GPC(12), pin_function);
+ }
+
/* All chips use PC2. And all chips use PC0, except R528/T113 */
- if (!IS_ENABLED(CONFIG_MACH_SUN8I_R528))
+ if (!IS_ENABLED(CONFIG_MACH_SUN8I_R528) &&
+ !IS_ENABLED(CONFIG_MACH_SUN55I_A523))
sunxi_gpio_set_cfgpin(SUNXI_GPC(0), pin_function);
sunxi_gpio_set_cfgpin(SUNXI_GPC(2), pin_function);
/* All chips except H6/H616/R528/T113 use PC1. */
if (!IS_ENABLED(CONFIG_SUN50I_GEN_H6) &&
- !IS_ENABLED(CONFIG_MACH_SUN8I_R528))
+ !IS_ENABLED(CONFIG_MACH_SUN8I_R528) &&
+ !IS_ENABLED(CONFIG_MACH_SUN55I_A523))
sunxi_gpio_set_cfgpin(SUNXI_GPC(1), pin_function);
if (IS_ENABLED(CONFIG_MACH_SUN50I_H6) ||
IS_ENABLED(CONFIG_MACH_SUN8I_R528))
sunxi_gpio_set_cfgpin(SUNXI_GPC(5), pin_function);
if (IS_ENABLED(CONFIG_MACH_SUN50I_H616) ||
- IS_ENABLED(CONFIG_MACH_SUN8I_R528))
+ IS_ENABLED(CONFIG_MACH_SUN8I_R528) ||
+ IS_ENABLED(CONFIG_MACH_SUN55I_A523))
sunxi_gpio_set_cfgpin(SUNXI_GPC(4), pin_function);
/* Older generations use PC23 for CS, newer ones use PC3. */
@@ -144,6 +153,11 @@ static bool is_sun6i_gen_spi(void)
IS_ENABLED(CONFIG_MACH_SUN8I_V3S);
}
+static bool is_sun55i_gen_spi(void)
+{
+ return IS_ENABLED(CONFIG_MACH_SUN55I_A523);
+}
+
static uintptr_t spi0_base_address(void)
{
if (IS_ENABLED(CONFIG_MACH_SUN8I_R40))
@@ -227,7 +241,7 @@ static void spi0_disable_clock(void)
uintptr_t base = spi0_base_address();
/* Disable the SPI0 controller */
- if (is_sun6i_gen_spi())
+ if (is_sun6i_gen_spi() || is_sun55i_gen_spi())
clrbits_le32(base + SUN6I_SPI0_GCR, SUN6I_CTL_MASTER |
SUN6I_CTL_ENABLE);
else
@@ -257,7 +271,8 @@ static void spi0_init(void)
unsigned int pin_function = SUNXI_GPC_SPI0;
if (IS_ENABLED(CONFIG_MACH_SUN50I) ||
- IS_ENABLED(CONFIG_SUN50I_GEN_H6))
+ IS_ENABLED(CONFIG_SUN50I_GEN_H6) ||
+ IS_ENABLED(CONFIG_MACH_SUN55I_A523))
pin_function = SUN50I_GPC_SPI0;
else if (IS_ENABLED(CONFIG_MACH_SUNIV) ||
IS_ENABLED(CONFIG_MACH_SUN8I_R528))
@@ -272,7 +287,8 @@ static void spi0_deinit(void)
/* New SoCs can disable pins, older could only set them as input */
unsigned int pin_function = SUNXI_GPIO_INPUT;
- if (is_sun6i_gen_spi())
+ if (is_sun6i_gen_spi() ||
+ is_sun55i_gen_spi())
pin_function = SUNXI_GPIO_DISABLE;
spi0_disable_clock();
@@ -284,42 +300,45 @@ static void spi0_deinit(void)
#define SPI_READ_MAX_SIZE 60 /* FIFO size, minus 4 bytes of the header */
static void sunxi_spi0_read_data(u8 *buf, u32 addr, u32 bufsize,
- ulong spi_ctl_reg,
- ulong spi_ctl_xch_bitmask,
- ulong spi_fifo_reg,
- ulong spi_tx_reg,
- ulong spi_rx_reg,
- ulong spi_bc_reg,
- ulong spi_tc_reg,
- ulong spi_bcc_reg)
+ ulong spi_ctl_reg,
+ ulong spi_ctl_xch_bitmask,
+ ulong spi_fifo_reg,
+ ulong spi_tx_reg,
+ ulong spi_rx_reg,
+ ulong spi_bc_reg,
+ ulong spi_tc_reg,
+ ulong spi_bcc_reg)
{
- writel(4 + bufsize, spi_bc_reg); /* Burst counter (total bytes) */
- writel(4, spi_tc_reg); /* Transfer counter (bytes to send) */
- if (spi_bcc_reg)
- writel(4, spi_bcc_reg); /* SUN6I also needs this */
-
- /* Send the Read Data Bytes (03h) command header */
- writeb(0x03, spi_tx_reg);
- writeb((u8)(addr >> 16), spi_tx_reg);
- writeb((u8)(addr >> 8), spi_tx_reg);
- writeb((u8)(addr), spi_tx_reg);
-
- /* Start the data transfer */
- setbits_le32(spi_ctl_reg, spi_ctl_xch_bitmask);
-
- /* Wait until everything is received in the RX FIFO */
- while ((readl(spi_fifo_reg) & 0x7F) < 4 + bufsize)
- ;
+ writel(4 + bufsize, spi_bc_reg); /* Burst counter (total bytes) */
+ writel(4, spi_tc_reg); /* Transfer counter (bytes to send) */
+ if (spi_bcc_reg)
+ writel(4, spi_bcc_reg); /* SUN6I also needs this */
+
+ /* Send the Read Data Bytes (03h) command header */
+ writeb(0x03, spi_tx_reg);
+ writeb((u8)(addr >> 16), spi_tx_reg);
+ writeb((u8)(addr >> 8), spi_tx_reg);
+ writeb((u8)(addr), spi_tx_reg);
+
+ /* Start the data transfer */
+ setbits_le32(spi_ctl_reg, spi_ctl_xch_bitmask);
+
+ /* Wait until everything is received in the RX FIFO */
+#if IS_ENABLED(CONFIG_MACH_SUN55I_A523)
+ while ((readl(spi_fifo_reg) & 0xFF) < 4 + bufsize);
+#else
+ while ((readl(spi_fifo_reg) & 0x7F) < 4 + bufsize);
+#endif
- /* Skip 4 bytes */
- readl(spi_rx_reg);
+ /* Skip 4 bytes */
+ readl(spi_rx_reg);
- /* Read the data */
- while (bufsize-- > 0)
- *buf++ = readb(spi_rx_reg);
+ /* Read the data */
+ while (bufsize-- > 0)
+ *buf++ = readb(spi_rx_reg);
- /* tSHSL time is up to 100 ns in various SPI flash datasheets */
- udelay(1);
+ /* tSHSL time is up to 100 ns in various SPI flash datasheets */
+ udelay(1);
}
static void spi0_read_data(void *buf, u32 addr, u32 len)
@@ -333,7 +352,7 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)
if (chunk_len > SPI_READ_MAX_SIZE)
chunk_len = SPI_READ_MAX_SIZE;
- if (is_sun6i_gen_spi()) {
+ if (is_sun6i_gen_spi() && !is_sun55i_gen_spi()) {
sunxi_spi0_read_data(buf8, addr, chunk_len,
base + SUN6I_SPI0_TCR,
SUN6I_TCR_XCH,
@@ -343,6 +362,16 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)
base + SUN6I_SPI0_MBC,
base + SUN6I_SPI0_MTC,
base + SUN6I_SPI0_BCC);
+ } else if (is_sun55i_gen_spi()) {
+ sunxi_spi0_read_data(buf8, addr, chunk_len,
+ base + SUN6I_SPI0_TCR,
+ SUN6I_TCR_XCH,
+ base + SUN55I_BUF_STA_REG,
+ base + SUN6I_SPI0_TXD,
+ base + SUN6I_SPI0_RXD,
+ base + SUN6I_SPI0_MBC,
+ base + SUN6I_SPI0_MTC,
+ base + SUN6I_SPI0_BCC);
} else {
sunxi_spi0_read_data(buf8, addr, chunk_len,
base + SUN4I_SPI0_CTL,
--
Armbian

View file

@ -0,0 +1,104 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Thu, 23 Oct 2025 13:30:29 +0000
Subject: spi: sunxi: Add support for Allwinner A523 SPI controllers
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
drivers/spi/spi-sunxi.c | 44 ++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/spi/spi-sunxi.c b/drivers/spi/spi-sunxi.c
index 111111111111..222222222222 100644
--- a/drivers/spi/spi-sunxi.c
+++ b/drivers/spi/spi-sunxi.c
@@ -84,6 +84,8 @@ DECLARE_GLOBAL_DATA_PTR;
#define SUN4I_SPI_DEFAULT_RATE 1000000
#define SUN4I_SPI_TIMEOUT_MS 1000
+#define SUN55I_BUF_STA_REG 0x400
+
#define SPI_REG(priv, reg) ((priv)->base + \
(priv)->variant->regs[reg])
#define SPI_BIT(priv, bit) ((priv)->variant->bits[bit])
@@ -130,6 +132,7 @@ struct sun4i_spi_variant {
bool has_soft_reset;
bool has_burst_ctl;
bool has_clk_ctl;
+ bool has_bsr;
};
struct sun4i_spi_plat {
@@ -366,6 +369,21 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen,
setbits_le32(SPI_REG(priv, SPI_FCR), SPI_BIT(priv, SPI_FCR_RF_RST) |
SPI_BIT(priv, SPI_FCR_TF_RST));
+ if (priv->variant->has_bsr) {
+ u32 reg;
+ int ret;
+
+ ret = readl_poll_timeout(SPI_REG(priv, SPI_FCR), reg,
+ !(reg & (SPI_BIT(priv, SPI_FCR_RF_RST) |
+ SPI_BIT(priv, SPI_FCR_TF_RST))),
+ SUN4I_SPI_TIMEOUT_MS * 1000);
+ if (ret) {
+ printf("ERROR: sun4i_spi: FIFO reset timeout\n");
+ sun4i_spi_set_cs(bus, slave_plat->cs[0], false);
+ return ret;
+ }
+ }
+
while (len) {
/* Setup the transfer now... */
nbytes = min(len, (priv->variant->fifo_depth - 1));
@@ -519,6 +537,19 @@ static const unsigned long sun6i_spi_regs[] = {
[SPI_RXD] = SUN6I_RXDATA_REG,
};
+static const unsigned long sun55i_spi_regs[] = {
+ [SPI_GCR] = SUN6I_GBL_CTL_REG,
+ [SPI_TCR] = SUN6I_TFR_CTL_REG,
+ [SPI_FCR] = SUN6I_FIFO_CTL_REG,
+ [SPI_FSR] = SUN55I_BUF_STA_REG,
+ [SPI_CCR] = SUN6I_CLK_CTL_REG,
+ [SPI_BC] = SUN6I_BURST_CNT_REG,
+ [SPI_TC] = SUN6I_XMIT_CNT_REG,
+ [SPI_BCTL] = SUN6I_BURST_CTL_REG,
+ [SPI_TXD] = SUN6I_TXDATA_REG,
+ [SPI_RXD] = SUN6I_RXDATA_REG,
+};
+
static const u32 sun6i_spi_bits[] = {
[SPI_GCR_TP] = BIT(7),
[SPI_GCR_SRST] = BIT(31),
@@ -570,6 +601,15 @@ static const struct sun4i_spi_variant sun50i_r329_spi_variant = {
.has_burst_ctl = true,
};
+static const struct sun4i_spi_variant sun55i_a523_spi_variant = {
+ .regs = sun55i_spi_regs,
+ .bits = sun6i_spi_bits,
+ .fifo_depth = 64,
+ .has_soft_reset = true,
+ .has_burst_ctl = true,
+ .has_bsr = true,
+};
+
static const struct udevice_id sun4i_spi_ids[] = {
{
.compatible = "allwinner,sun4i-a10-spi",
@@ -587,6 +627,10 @@ static const struct udevice_id sun4i_spi_ids[] = {
.compatible = "allwinner,sun50i-r329-spi",
.data = (ulong)&sun50i_r329_spi_variant,
},
+ {
+ .compatible = "allwinner,sun55i-a523-spi",
+ .data = (ulong)&sun55i_a523_spi_variant,
+ },
{ /* sentinel */ }
};
--
Armbian

View file

@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Juan Sanchez Fuentes <juanesf91@gmail.com>
Date: Sun, 16 Nov 2025 13:44:00 +0000
Subject: sunxi: Add NVME boot target support
NVMe is the LAST boot target so SD (MMC), USB and eMMC are tried first.
Signed-off-by: Juan Sanchez Fuentes <juanesf91@gmail.com>
Assisted-by: opencode:big-pickle
---
include/configs/sunxi-common.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 111111111111..222222222222 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -208,6 +208,12 @@
#define BOOT_TARGET_DEVICES_DHCP(func)
#endif
+#ifdef CONFIG_CMD_NVME
+#define BOOT_TARGET_DEVICES_NVME(func) func(NVME, nvme, 0)
+#else
+#define BOOT_TARGET_DEVICES_NVME(func)
+#endif
+
/* FEL boot support, auto-execute boot.scr if a script address was provided */
#define BOOTENV_DEV_FEL(devtypeu, devtypel, instance) \
"bootcmd_fel=" \
@@ -224,7 +230,8 @@
BOOT_TARGET_DEVICES_SCSI(func) \
BOOT_TARGET_DEVICES_USB(func) \
BOOT_TARGET_DEVICES_PXE(func) \
- BOOT_TARGET_DEVICES_DHCP(func)
+ BOOT_TARGET_DEVICES_DHCP(func) \
+ BOOT_TARGET_DEVICES_NVME(func)
#ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
#define BOOTCMD_SUNXI_COMPAT \
--
Armbian