aboutsummaryrefslogtreecommitdiff
path: root/scripts/cru.c
diff options
context:
space:
mode:
authorNick Moore <nicholasvmoore@gmail.com>2026-11-17 08:13:59 -0600
committerNick Moore <nicholasvmoore@gmail.com>2026-11-17 08:14:12 -0600
commit8a4e71cb0f3dda9c3c9f981f825302ce69616719 (patch)
treee1dd11ef23cea3cbd1d50a933c1dd11054407580 /scripts/cru.c
RK3328 VPU clock fix: DTS patch, CRU tool, boot-pin units, watchdog, write-ups
Out-of-box RK3328 BSP kernels boot the video decoder clocks at 100 MHz and the mpp driver's auto-frequency path never fires, capping 4K HEVC decode at 33.8 fps (57% of datasheet spec). Consumer-node clock assignment at 400 MHz restores the driver's own declared advanced rate: 70.2 fps decode, 40.8 fps dec->RGA. Includes a no-rebuild boot-pin alternative (OpenRC + systemd) and a repin watchdog.
Diffstat (limited to 'scripts/cru.c')
-rw-r--r--scripts/cru.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/cru.c b/scripts/cru.c
new file mode 100644
index 0000000..f1e2645
--- /dev/null
+++ b/scripts/cru.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+/* RK3328 CRU peek/poke: ./cru <off> [value] (off relative to CRU base) */
+#define CRU_BASE 0xff440000
+
+int main(int argc, char **argv)
+{
+ int fd = open("/dev/mem", O_RDWR | O_SYNC);
+ if (fd < 0) { perror("/dev/mem"); return 1; }
+ volatile unsigned int *cru = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, CRU_BASE & ~0xfffUL);
+ if (cru == MAP_FAILED) { perror("mmap"); return 1; }
+ volatile unsigned int *reg = cru + ((CRU_BASE & 0xfff) + strtoul(argv[1], 0, 0)) / 4;
+ if (argc == 3) {
+ *reg = strtoul(argv[2], 0, 0);
+ printf("wrote 0x%x\n", *reg);
+ } else {
+ printf("0x%x\n", *reg);
+ }
+ return 0;
+}