summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmut Dikcizgi2023-01-26 00:00:50 +0100
committerMahmut Dikcizgi2023-01-26 00:00:50 +0100
commit7e33f913d59009016d88cd98e3deec223141920c (patch)
tree7366324e5766362411b7618a6358619e94761bb1
downloadaur-7e33f913d59009016d88cd98e3deec223141920c.tar.gz
Radxa fork of Linux 5.10 which is based on the fork of Rockchip BSP.
Signed-off-by: Mahmut Dikcizgi <boogiepop@gmx.com>
-rw-r--r--.SRCINFO80
-rw-r--r--0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch42
-rw-r--r--0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch63
-rw-r--r--0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch85
-rw-r--r--0004-Update-existing-ROCK-4-OPP-settings.patch63
-rw-r--r--0005-Add-additional-ROCK-4-products.patch203
-rw-r--r--0006-Enable-DMC-for-ROCK-4.patch354
-rw-r--r--0007-Fix-ROCK-4-OTG-switch.patch40
-rw-r--r--0008-Add-pwm-fan-for-ROCK-4C.patch66
-rw-r--r--0009-VENDOR-Add-Radxa-overlays.patch110
-rw-r--r--0010-Fix-dangling-pointer-compiler-bug.patch33
-rw-r--r--0011-Disable-tristate-for-non-modules.patch43
-rw-r--r--0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch51
-rw-r--r--0013-Disable-tristate-for-builtin-dependencies.patch24
-rw-r--r--0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch89
-rw-r--r--0015-Disable-tristate-for-essential-boot-services.patch39
-rw-r--r--0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch26
-rw-r--r--0017-Modfy-GPU-node-for-Panfrost-driver.patch29
-rw-r--r--0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch39
-rw-r--r--0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch1193
-rw-r--r--0020-gcc-ignore-stringop-overread-warnings.patch13
-rw-r--r--0021-dma-buf-add-dma_resv_get_singleton-v2.patch115
-rw-r--r--0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch264
-rw-r--r--0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch248
-rw-r--r--0024-MALI-bifrost-avoid-fence-double-free.patch26
-rw-r--r--0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch40
-rw-r--r--0026-Enable_AV1_decoder_on_3588.patch20
-rw-r--r--PKGBUILD279
-rw-r--r--extlinux.arch.template9
-rw-r--r--linux.preset10
30 files changed, 3696 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..784d9746c3dc
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,80 @@
+pkgbase = linux-radxa-rkbsp5-git
+ pkgver = 5.10
+ pkgrel = 1
+ url = https://github.com/radxa
+ arch = aarch64
+ license = GPL2
+ makedepends = xmlto
+ makedepends = docbook-xsl
+ makedepends = kmod
+ makedepends = inetutils
+ makedepends = bc
+ makedepends = git
+ makedepends = uboot-tools
+ makedepends = vboot-utils
+ makedepends = dtc
+ options = !strip
+ source = git+https://github.com/radxa/kernel.git#branch=linux-5.10-gen-rkr3.4
+ source = git+https://github.com/radxa/overlays.git#branch=main
+ source = linux.preset
+ source = extlinux.arch.template
+ source = 0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch
+ source = 0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch
+ source = 0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch
+ source = 0004-Update-existing-ROCK-4-OPP-settings.patch
+ source = 0005-Add-additional-ROCK-4-products.patch
+ source = 0006-Enable-DMC-for-ROCK-4.patch
+ source = 0007-Fix-ROCK-4-OTG-switch.patch
+ source = 0008-Add-pwm-fan-for-ROCK-4C.patch
+ source = 0009-VENDOR-Add-Radxa-overlays.patch
+ source = 0010-Fix-dangling-pointer-compiler-bug.patch
+ source = 0011-Disable-tristate-for-non-modules.patch
+ source = 0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch
+ source = 0013-Disable-tristate-for-builtin-dependencies.patch
+ source = 0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch
+ source = 0015-Disable-tristate-for-essential-boot-services.patch
+ source = 0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch
+ source = 0017-Modfy-GPU-node-for-Panfrost-driver.patch
+ source = 0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch
+ source = 0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch
+ source = 0020-gcc-ignore-stringop-overread-warnings.patch
+ source = 0021-dma-buf-add-dma_resv_get_singleton-v2.patch
+ source = 0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch
+ source = 0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch
+ source = 0024-MALI-bifrost-avoid-fence-double-free.patch
+ source = 0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch
+ source = 0026-Enable_AV1_decoder_on_3588.patch
+ b2sums = SKIP
+ b2sums = SKIP
+ b2sums = b5ebfe78b703b7d5ea31be16513ff4e91d0ca7f13657c6d09ff92ef4f1566bf501a4b536b7f48791055d0b327724ada23a3f5a34247c5effe3fe2ff7e1acd8eb
+ b2sums = d8208257c8f2e23a9dbcf2a1bbd11b5a638679cd49dd03d4ea190d1ecd94e2760cccb2cd1cda890816a9c338ce2f38c859961f4ab3a22fca458a453ca0d5f2fc
+ b2sums = 74b6d76888267785ac99e58bdb852c667865d44353821c01052734d58e1213c16290aabff7ae6c95ac6b24893fe5109897f949d814ccec55cc69af9885fc62f6
+ b2sums = 461eb48692574f48d37a9a236b3a17992493cf07a39ab72f78fa0ac4f04e3ff9896f16e721c111f865d9aa3d3f0d7b7c082fe2f319eee0e1a6c54db44f0a6e53
+ b2sums = 2703d12281e60e2b9f057bbb3ac28e190f77c4ad8cfccc6f1a316b9bc6434e7ca296221eeb8992134c2d365a5afea7b7adf1d9516e3c89c3fc03f0941f65e5c2
+ b2sums = 376e54c72261c803d40e3ddca06e39b72c85fe4d8743e79cac1c8ced3feb953760471a6784cc4922b0bcf00004f9b2a9407094b6075883c5ce82786ff357cb3b
+ b2sums = c09942deeead81798f47e07f72e6b8748e8b44682d72a1bd0d50e7c9f20e9ae8243c248a234ecc1f48112c40d2690c5ab171fdc9ba55101f4cc5294888c9f49b
+ b2sums = 6277d3f4e43eb20b735e8ef933f4e9fccc5077484f2c7051b7f47bfae77ffce13387199650cc90adf14d4dc941bb376d9e52d48bab37412afe9437e5d081a130
+ b2sums = 4d42cee746b74a2f2982187a568b939cc1d3f3e3bc18472fea0ce9eb27d658170f434a14526e339fb36d2936a7a17b59a699a4c351152a56f8ab7743e670c05a
+ b2sums = 53b3d818d3d8bdcebe5bf1b25f6196615fe605f4d9f282d0f2effa44bd1480241b0d4e5eedfbc34fa27e2ce90ee634799e3aefad1bd701c250c502e4b2178d71
+ b2sums = 4908b5a94c02a4eb0fe8bb9983289f1b8acbb1b8ebb541643c7ec4ac5de87be949efbdec839d34603b045500b13033f836385bdbf3e935fcd8d221f71028d604
+ b2sums = e612cf028aaf8f99c2735a6e1640170af51e62aa86a8cc795694ac089b2f31be93e67c6ee394cd22d290a787cd9f064861b0bb173033069710881280432ad45f
+ b2sums = bde631de66dde60339c7fa306b06a9100ac41adaeb16788c800157324a288a97629c41dda5076698c1ef71b8b7f44b5eba619b6aac92d0d5c59e796fb2aa407a
+ b2sums = 1836fb5f211c4feb279de7d241799ff483eb6d4728cdba74ad44c8808a5d5be0077c53a315ae4f6d16f157156f5d6d00a5428a857f4164659e7a2feb584f5ec9
+ b2sums = 16b725f25bc150675888dcc03125cd285f2c73f7955d90d521af9a139d717836afab07a995f7018e19cdad41964061800503e40e32656ee54bf69c22e8c8a53f
+ b2sums = 8a6c96251c48048ff653285646347853d5df5264d1bf0bf798a48d3636480263125f92c5cb21f7d4b4988b6d831636d34de1b882c0209110178117e3ea1a0630
+ b2sums = f5ab48ee96b6df65ec20742e5bb2badffa7ed926f5020d64bdcfe1fe924fff9cafdb70c7983084f4294ab5663c5b56eeb51e96df176253175e9bde52121c3164
+ b2sums = 1bf65b95368a4134086b03598943f6d4025fefec436e170b95fa8478523755187c427ab038ae3fe3aef319c6a266e58c1d360575fd08720dd60957578054fa28
+ b2sums = d7c4496318bd3fc5294af88bcdeafa49b04683d1e1fe7312b0317872fdecb929ef8e62b86332e87eddd49c1f5e7ddb9a59372dcbf0514158f7d75947e81f7d8d
+ b2sums = 7dc970eebf837940c67ae61f809f9e0cc6ae9e2a033ca7975b2c4055190b23ddd190170e75949834d54818f08016743d66c6ede5175f6cf988bec2e6aa4f008d
+ b2sums = b3b9b04b0f73d07c1927c0def7e5cc991144a7e65a01dab4ec1b2dd01f092e001da3fc07e852ebefb1530509e25a99730217a9208b6a26b0333c288ca1151935
+ b2sums = 86010c037ed11f25de26f0e1a35109488b00af3ec11cceff979694c6730d6501cffa292798042ae6a60d839b438f6abf90b6ecc08ab0a4fa597d564493ab9c9b
+ b2sums = afe3cf59d21517ef62bb456b831c638dc54107258e4f4412b8ebab2fa871a26c2aab3c16bf6a39b692611540febf2c68b6dece570266fc5c0a7349ffc05da7d0
+ b2sums = f96570ec79e310c21c8f98a95e3775bde05133bf4db25413596791d96ee7142702ecd5f5e358df4d852cbab9f909a455d438277978ed9d4e0f2fd4a3d43df082
+ b2sums = 053bd95a861c9ee1cc8fa7a9af787d927c9110fffd2780c4972ce97ee2ade1ff567071158e89734b2352ac0c98aff82259c241baa0cee263919ec012c9ef9478
+ b2sums = ea47ec8ba687f3a82d790797bb772ef04dd0dd5ab64d7f2c674659068c0332374c49e0e58b9ae7768bc7c6bfb67830b96b74a981ed4639fc1a8ef9f1fea9acb5
+ b2sums = 4dccfcdd1f2e9c3ba556a0c15541b6e7522e12e0d3e0153937266026fe365f54ed45ab77f7e24397acc61c0a170803214ddc452d46f7659c57eba5b82107d7d2
+ b2sums = 7c61be00b97a8acb759c35f23969cdfb4e739a8c88fd147d2af4594fa14100a2da90b160e04b8632c3dca703ff2c1973138d7f765c5b9a7039c6aae7f0078d9a
+
+pkgname = linux-radxa-rkbsp5-headers
+
+pkgname = linux-radxa-rkbsp5
diff --git a/0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch b/0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch
new file mode 100644
index 000000000000..eb00292b23c7
--- /dev/null
+++ b/0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Xiongwei Song <sxwjean@gmail.com>
+Date: Fri, 14 Jan 2022 14:07:24 -0800
+Subject: [PATCH] mm: page_alloc: fix building error on -Werror=array-compare
+
+Arthur Marsh reported we would hit the error below when building kernel
+with gcc-12:
+
+ CC mm/page_alloc.o
+ mm/page_alloc.c: In function `mem_init_print_info':
+ mm/page_alloc.c:8173:27: error: comparison between two arrays [-Werror=array-compare]
+ 8173 | if (start <= pos && pos < end && size > adj) \
+ |
+
+In C++20, the comparision between arrays should be warned.
+
+Link: https://lkml.kernel.org/r/20211125130928.32465-1-sxwjean@me.com
+Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
+Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Yuntian Zhang <yt@radxa.com>
+---
+ mm/page_alloc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mm/page_alloc.c b/mm/page_alloc.c
+index 190069eb12..ba31b2d94a 100644
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -7840,7 +7840,7 @@ void __init mem_init_print_info(const char *str)
+ */
+ #define adj_init_size(start, end, size, pos, adj) \
+ do { \
+- if (start <= pos && pos < end && size > adj) \
++ if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \
+ size -= adj; \
+ } while (0)
+
+--
+2.36.1
+
diff --git a/0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch b/0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch
new file mode 100644
index 000000000000..0297080520d0
--- /dev/null
+++ b/0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Sat, 12 Feb 2022 09:14:49 -0800
+Subject: [PATCH] etherdevice: Adjust ether_addr* prototypes to silence
+ -Wstringop-overead
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+With GCC 12, -Wstringop-overread was warning about an implicit cast from
+char[6] to char[8]. However, the extra 2 bytes are always thrown away,
+alignment doesn't matter, and the risk of hitting the edge of unallocated
+memory has been accepted, so this prototype can just be converted to a
+regular char *. Silences:
+
+net/core/dev.c: In function ‘bpf_prog_run_generic_xdp’: net/core/dev.c:4618:21: warning: ‘ether_addr_equal_64bits’ reading 8 bytes from a region of size 6 [-Wstringop-overread]
+ 4618 | orig_host = ether_addr_equal_64bits(eth->h_dest, > skb->dev->dev_addr);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+net/core/dev.c:4618:21: note: referencing argument 1 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’}
+net/core/dev.c:4618:21: note: referencing argument 2 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’}
+In file included from net/core/dev.c:91: include/linux/etherdevice.h:375:20: note: in a call to function ‘ether_addr_equal_64bits’
+ 375 | static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
+ | ^~~~~~~~~~~~~~~~~~~~~~~
+
+Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Tested-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Link: https://lore.kernel.org/netdev/20220212090811.uuzk6d76agw2vv73@pengutronix.de
+Cc: Jakub Kicinski <kuba@kernel.org>
+Cc: "David S. Miller" <davem@davemloft.net>
+Cc: netdev@vger.kernel.org
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Yuntian Zhang <yt@radxa.com>
+---
+ include/linux/etherdevice.h | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
+index 2e5debc037..99209f5091 100644
+--- a/include/linux/etherdevice.h
++++ b/include/linux/etherdevice.h
+@@ -127,7 +127,7 @@ static inline bool is_multicast_ether_addr(const u8 *addr)
+ #endif
+ }
+
+-static inline bool is_multicast_ether_addr_64bits(const u8 addr[6+2])
++static inline bool is_multicast_ether_addr_64bits(const u8 *addr)
+ {
+ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+ #ifdef __BIG_ENDIAN
+@@ -352,8 +352,7 @@ static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
+ * Please note that alignment of addr1 & addr2 are only guaranteed to be 16 bits.
+ */
+
+-static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
+- const u8 addr2[6+2])
++static inline bool ether_addr_equal_64bits(const u8 *addr1, const u8 *addr2)
+ {
+ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+ u64 fold = (*(const u64 *)addr1) ^ (*(const u64 *)addr2);
+--
+2.36.1
+
diff --git a/0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch b/0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch
new file mode 100644
index 000000000000..529aeaabe36d
--- /dev/null
+++ b/0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch
@@ -0,0 +1,85 @@
+From 2edabfb2562a8899b7f00194f536a6f6bef0cc8b Mon Sep 17 00:00:00 2001
+From: Damon Ding <damon.ding@rock-chips.com>
+Date: Tue, 13 Dec 2022 11:04:42 +0800
+Subject: [PATCH] drm/rockchip: vop: Use clipped src/dst coordinates
+
+Some linux app(cusor) may set negative coordinates(crtc_x/y)
+
+And some linux app(mpv) may set coordinates outside the screen.
+
+These are both unsupported on rockchip vop.
+
+so we use clipped coordinates here.
+
+Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
+Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
+Change-Id: Id2322113f0973271997575678cda478a9987266b
+---
+ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 35 ++++++++++++---------
+ 1 file changed, 21 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+index d7ea1f80ea12..96099755633f 100644
+--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
++++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+@@ -1758,14 +1758,6 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
+ if (WARN_ON(!crtc_state))
+ return -EINVAL;
+
+- src->x1 = state->src_x;
+- src->y1 = state->src_y;
+- src->x2 = state->src_x + state->src_w;
+- src->y2 = state->src_y + state->src_h;
+- dest->x1 = state->crtc_x;
+- dest->y1 = state->crtc_y;
+- dest->x2 = state->crtc_x + state->crtc_w;
+- dest->y2 = state->crtc_y + state->crtc_h;
+ vop_plane_state->zpos = state->zpos;
+ vop_plane_state->blend_mode = state->pixel_blend_mode;
+
+@@ -1775,8 +1767,22 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
+ if (ret)
+ return ret;
+
+- if (!state->visible)
++ if (!state->visible) {
++ DRM_ERROR("%s is invisible(src: pos[%d, %d] rect[%d x %d] dst: pos[%d, %d] rect[%d x %d]\n",
++ plane->name, state->src_x >> 16, state->src_y >> 16, state->src_w >> 16,
++ state->src_h >> 16, state->crtc_x, state->crtc_y, state->crtc_w,
++ state->crtc_h);
+ return 0;
++ }
++
++ src->x1 = state->src.x1;
++ src->y1 = state->src.y1;
++ src->x2 = state->src.x2;
++ src->y2 = state->src.y2;
++ dest->x1 = state->dst.x1;
++ dest->y1 = state->dst.y1;
++ dest->x2 = state->dst.x2;
++ dest->y2 = state->dst.y2;
+
+ vop_plane_state->format = vop_convert_format(fb->format->format);
+ if (vop_plane_state->format < 0)
+@@ -1785,12 +1791,13 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
+ vop = to_vop(crtc);
+ vop_data = vop->data;
+
+- if (state->src_w >> 16 < 4 || state->src_h >> 16 < 4 ||
+- state->crtc_w < 4 || state->crtc_h < 4) {
++ if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
++ drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) {
+ DRM_ERROR("Invalid size: %dx%d->%dx%d, min size is 4x4\n",
+- state->src_w >> 16, state->src_h >> 16,
+- state->crtc_w, state->crtc_h);
+- return -EINVAL;
++ drm_rect_width(src) >> 16, drm_rect_height(src) >> 16,
++ drm_rect_width(dest), drm_rect_height(dest));
++ state->visible = false;
++ return 0;
+ }
+
+ if (drm_rect_width(src) >> 16 > vop_data->max_input.width ||
+--
+2.34.1
+
diff --git a/0004-Update-existing-ROCK-4-OPP-settings.patch b/0004-Update-existing-ROCK-4-OPP-settings.patch
new file mode 100644
index 000000000000..855257993f9e
--- /dev/null
+++ b/0004-Update-existing-ROCK-4-OPP-settings.patch
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Thu, 3 Nov 2022 10:46:07 +0800
+Subject: [PATCH] Update existing ROCK 4 OPP settings
+
+---
+ arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 1 -
+ arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a.dts | 1 +
+ arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts | 1 +
+ arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts | 1 +
+ 4 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index d62219f7d3e0..179eb3f94a96 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -9,7 +9,6 @@
+ #include <dt-bindings/pwm/pwm.h>
+ #include "rk3399.dtsi"
+ #include "rk3399-linux.dtsi"
+-#include "rk3399-opp.dtsi"
+
+ / {
+ aliases {
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a.dts
+index 32f869c2e66b..790fe973f169 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a.dts
+@@ -6,6 +6,7 @@
+
+ /dts-v1/;
+ #include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-opp.dtsi"
+
+ / {
+ model = "Radxa ROCK Pi 4A";
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts
+index 4f16d11eb22a..55a0a919e0fc 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts
+@@ -6,6 +6,7 @@
+
+ /dts-v1/;
+ #include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-opp.dtsi"
+
+ / {
+ model = "Radxa ROCK Pi 4B";
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts
+index 5df898013916..d120c07a0db1 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts
+@@ -7,6 +7,7 @@
+
+ /dts-v1/;
+ #include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-opp.dtsi"
+
+ / {
+ model = "Radxa ROCK Pi 4C";
+--
+2.38.1
+
diff --git a/0005-Add-additional-ROCK-4-products.patch b/0005-Add-additional-ROCK-4-products.patch
new file mode 100644
index 000000000000..e549946fc814
--- /dev/null
+++ b/0005-Add-additional-ROCK-4-products.patch
@@ -0,0 +1,203 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Thu, 3 Nov 2022 11:01:57 +0800
+Subject: [PATCH] Add additional ROCK 4 products
+
+Currently they are just copies of the original dts
+with different OPP configuration.
+---
+ arch/arm64/boot/dts/rockchip/Makefile | 3 +
+ .../boot/dts/rockchip/rk3399-rock-pi-4a-plus.dts | 29 +++++++++
+ .../boot/dts/rockchip/rk3399-rock-pi-4b-plus.dts | 61 +++++++++++++++++++
+ .../boot/dts/rockchip/rk3399-rock-4se.dts | 61 +++++++++++++++++++
+ 4 files changed, 154 insertions(+)
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a-plus.dts
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b-plus.dts
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
+
+diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile
+index faa656ae960b..4889edb78d3e 100644
+--- a/arch/arm64/boot/dts/rockchip/Makefile
++++ b/arch/arm64/boot/dts/rockchip/Makefile
+@@ -56,6 +56,9 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-pinebook-pro.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-puma-haikou.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-roc-pc.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-roc-pc-mezzanine.dtb
++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-4se.dtb
++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4a-plus.dtb
++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4b-plus.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-4c-plus.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4a.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4b.dtb
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a-plus.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a-plus.dts
+new file mode 100644
+index 000000000000..d2ca5649b2dd
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4a-plus.dts
+@@ -0,0 +1,29 @@
++// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
++/*
++ * Copyright (c) 2019 Akash Gajjar <Akash_Gajjar@mentor.com>
++ * Copyright (c) 2019 Pragnesh Patel <Pragnesh_Patel@mentor.com>
++ */
++
++/dts-v1/;
++#include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-op1-opp.dtsi"
++
++/ {
++ model = "Radxa ROCK Pi 4A+";
++ compatible = "radxa,rockpi4a-plus", "radxa,rockpi4", "rockchip,rk3399";
++};
++
++&pinctrl {
++ usb2 {
++ vcc5v0_host_en: vcc5v0-host-en {
++ rockchip,pins = <4 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++};
++
++&vcc5v0_host {
++ enable-active-high;
++ gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&vcc5v0_host_en>;
++};
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b-plus.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b-plus.dts
+new file mode 100644
+index 000000000000..8c54d42c761a
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b-plus.dts
+@@ -0,0 +1,61 @@
++// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
++/*
++ * Copyright (c) 2019 Akash Gajjar <Akash_Gajjar@mentor.com>
++ * Copyright (c) 2019 Pragnesh Patel <Pragnesh_Patel@mentor.com>
++ */
++
++/dts-v1/;
++#include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-op1-opp.dtsi"
++
++/ {
++ model = "Radxa ROCK Pi 4B+";
++ compatible = "radxa,rockpi4b-plus", "radxa,rockpi4", "rockchip,rk3399";
++};
++
++&pinctrl {
++ usb2 {
++ vcc5v0_host_en: vcc5v0-host-en {
++ rockchip,pins = <4 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++};
++
++&sdio0 {
++ status = "okay";
++
++ brcmf: wifi@1 {
++ compatible = "brcm,bcm4329-fmac";
++ reg = <1>;
++ interrupt-parent = <&gpio0>;
++ interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
++ interrupt-names = "host-wake";
++ pinctrl-names = "default";
++ pinctrl-0 = <&wifi_host_wake_l>;
++ };
++};
++
++&uart0 {
++ status = "okay";
++
++ bluetooth {
++ compatible = "brcm,bcm4345c5";
++ clocks = <&rk808 1>;
++ clock-names = "lpo";
++ device-wakeup-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_HIGH>;
++ host-wakeup-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_HIGH>;
++ shutdown-gpios = <&gpio0 RK_PB1 GPIO_ACTIVE_HIGH>;
++ max-speed = <1500000>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
++ vbat-supply = <&vcc3v3_sys>;
++ vddio-supply = <&vcc_1v8>;
++ };
++};
++
++&vcc5v0_host {
++ enable-active-high;
++ gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&vcc5v0_host_en>;
++};
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
+new file mode 100644
+index 000000000000..962ca9139db2
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
+@@ -0,0 +1,61 @@
++// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
++/*
++ * Copyright (c) 2019 Akash Gajjar <Akash_Gajjar@mentor.com>
++ * Copyright (c) 2019 Pragnesh Patel <Pragnesh_Patel@mentor.com>
++ */
++
++/dts-v1/;
++#include "rk3399-rock-pi-4.dtsi"
++#include "rk3399-t-opp.dtsi"
++
++/ {
++ model = "Radxa ROCK 4SE";
++ compatible = "radxa,rock-4se", "rockchip,rk3399";
++};
++
++&pinctrl {
++ usb2 {
++ vcc5v0_host_en: vcc5v0-host-en {
++ rockchip,pins = <4 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++};
++
++&sdio0 {
++ status = "okay";
++
++ brcmf: wifi@1 {
++ compatible = "brcm,bcm4329-fmac";
++ reg = <1>;
++ interrupt-parent = <&gpio0>;
++ interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
++ interrupt-names = "host-wake";
++ pinctrl-names = "default";
++ pinctrl-0 = <&wifi_host_wake_l>;
++ };
++};
++
++&uart0 {
++ status = "okay";
++
++ bluetooth {
++ compatible = "brcm,bcm4345c5";
++ clocks = <&rk808 1>;
++ clock-names = "lpo";
++ device-wakeup-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_HIGH>;
++ host-wakeup-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_HIGH>;
++ shutdown-gpios = <&gpio0 RK_PB1 GPIO_ACTIVE_HIGH>;
++ max-speed = <1500000>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
++ vbat-supply = <&vcc3v3_sys>;
++ vddio-supply = <&vcc_1v8>;
++ };
++};
++
++&vcc5v0_host {
++ enable-active-high;
++ gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&vcc5v0_host_en>;
++};
+--
+2.38.1
+
diff --git a/0006-Enable-DMC-for-ROCK-4.patch b/0006-Enable-DMC-for-ROCK-4.patch
new file mode 100644
index 000000000000..b0606f367d0f
--- /dev/null
+++ b/0006-Enable-DMC-for-ROCK-4.patch
@@ -0,0 +1,354 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Wed, 21 Dec 2022 12:21:04 +0800
+Subject: [PATCH] Enable DMC for ROCK 4
+
+---
+ .../boot/dts/rockchip/rk3399-op1-opp.dtsi | 60 +++++++++++++++++++
+ arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi | 60 +++++++++++++++++++
+ .../boot/dts/rockchip/rk3399-rock-4c-plus.dts | 29 +++++++++
+ .../boot/dts/rockchip/rk3399-rock-4se.dts | 21 +++++++
+ .../boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 34 +++++++++++
+ .../arm64/boot/dts/rockchip/rk3399-t-opp.dtsi | 46 ++++++++++++++
+ 6 files changed, 250 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi
+index 69cc9b05baa5..af78f332cc56 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi
+@@ -110,6 +110,62 @@ opp05 {
+ opp-microvolt = <1075000>;
+ };
+ };
++
++ dmc_opp_table: opp-table3 {
++ compatible = "operating-points-v2";
++
++ opp-200000000 {
++ opp-hz = /bits/ 64 <200000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-300000000 {
++ opp-hz = /bits/ 64 <300000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-328000000 {
++ opp-hz = /bits/ 64 <328000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-400000000 {
++ opp-hz = /bits/ 64 <400000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-416000000 {
++ opp-hz = /bits/ 64 <416000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-528000000 {
++ opp-hz = /bits/ 64 <528000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-600000000 {
++ opp-hz = /bits/ 64 <600000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-666000000 {
++ opp-hz = /bits/ 64 <666000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-800000000 {
++ opp-hz = /bits/ 64 <800000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-856000000 {
++ opp-hz = /bits/ 64 <856000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-928000000 {
++ opp-hz = /bits/ 64 <928000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ };
+ };
+
+ &cpu_l0 {
+@@ -136,6 +192,10 @@ &cpu_b1 {
+ operating-points-v2 = <&cluster1_opp>;
+ };
+
++&dmc {
++ operating-points-v2 = <&dmc_opp_table>;
++};
++
+ &gpu {
+ operating-points-v2 = <&gpu_opp_table>;
+ };
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi
+index f9f2cc8abec7..8ddc600c1810 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi
+@@ -316,6 +316,62 @@ opp-800000000 {
+ opp-microvolt = <900000>;
+ };
+ };
++
++ dmc_opp_table: opp-table3 {
++ compatible = "operating-points-v2";
++
++ opp-200000000 {
++ opp-hz = /bits/ 64 <200000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-300000000 {
++ opp-hz = /bits/ 64 <300000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-328000000 {
++ opp-hz = /bits/ 64 <328000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-400000000 {
++ opp-hz = /bits/ 64 <400000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-416000000 {
++ opp-hz = /bits/ 64 <416000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-528000000 {
++ opp-hz = /bits/ 64 <528000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-600000000 {
++ opp-hz = /bits/ 64 <600000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-666000000 {
++ opp-hz = /bits/ 64 <666000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-800000000 {
++ opp-hz = /bits/ 64 <800000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-856000000 {
++ opp-hz = /bits/ 64 <856000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-928000000 {
++ opp-hz = /bits/ 64 <928000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ };
+ };
+
+ &cpu_l0 {
+@@ -352,6 +408,10 @@ &dmc {
+ operating-points-v2 = <&dmc_opp_table>;
+ };
+
++&dmc {
++ operating-points-v2 = <&dmc_opp_table>;
++};
++
+ &gpu {
+ operating-points-v2 = <&gpu_opp_table>;
+ };
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
+index 76e38a771fb0..cabe1d230e44 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
+@@ -914,6 +914,35 @@ &rkvdec {
+
+ &dmc {
+ status = "okay";
++ center-supply = <&vdd_log>;
++ upthreshold = <40>;
++ downdifferential = <20>;
++ system-status-freq = <
++ /*system status freq(KHz)*/
++ SYS_STATUS_NORMAL 666000
++ SYS_STATUS_REBOOT 666000
++ SYS_STATUS_SUSPEND 328000
++ SYS_STATUS_VIDEO_1080P 666000
++ SYS_STATUS_VIDEO_4K 666000
++ SYS_STATUS_VIDEO_4K_10B 666000
++ SYS_STATUS_PERFORMANCE 666000
++ SYS_STATUS_BOOST 666000
++ SYS_STATUS_DUALVIEW 666000
++ SYS_STATUS_ISP 666000
++ >;
++ vop-bw-dmc-freq = <
++ /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */
++ 0 762 416000
++ 763 99999 666000
++ >;
++
++ vop-pn-msch-readlatency = <
++ 0 0x20
++ 4 0x20
++ >;
++
++ auto-min-freq = <328000>;
++ auto-freq-en = <0>;
+ };
+
+ &rga {
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
+index 962ca9139db2..8d50996dad09 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4se.dts
+@@ -13,6 +13,27 @@ / {
+ compatible = "radxa,rock-4se", "rockchip,rk3399";
+ };
+
++&dmc {
++ system-status-freq = <
++ /*system status freq(KHz)*/
++ SYS_STATUS_NORMAL 666000
++ SYS_STATUS_REBOOT 666000
++ SYS_STATUS_SUSPEND 328000
++ SYS_STATUS_VIDEO_1080P 666000
++ SYS_STATUS_VIDEO_4K 666000
++ SYS_STATUS_VIDEO_4K_10B 666000
++ SYS_STATUS_PERFORMANCE 666000
++ SYS_STATUS_BOOST 666000
++ SYS_STATUS_DUALVIEW 666000
++ SYS_STATUS_ISP 666000
++ >;
++ vop-bw-dmc-freq = <
++ /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */
++ 0 762 416000
++ 763 99999 666000
++ >;
++};
++
+ &pinctrl {
+ usb2 {
+ vcc5v0_host_en: vcc5v0-host-en {
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index 56d1a77333d6..273c6cc44499 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -234,6 +234,40 @@ &cpu_b1 {
+ cpu-supply = <&vdd_cpu_b>;
+ };
+
++&dmc {
++ status = "okay";
++ center-supply = <&vdd_log>;
++ upthreshold = <40>;
++ downdifferential = <20>;
++ system-status-freq = <
++ /*system status freq(KHz)*/
++ SYS_STATUS_NORMAL 856000
++ SYS_STATUS_REBOOT 856000
++ SYS_STATUS_SUSPEND 328000
++ SYS_STATUS_VIDEO_1080P 666000
++ SYS_STATUS_VIDEO_4K 856000
++ SYS_STATUS_VIDEO_4K_10B 856000
++ SYS_STATUS_PERFORMANCE 856000
++ SYS_STATUS_BOOST 856000
++ SYS_STATUS_DUALVIEW 856000
++ SYS_STATUS_ISP 856000
++ >;
++ vop-bw-dmc-freq = <
++ /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */
++ 0 762 416000
++ 763 3012 666000
++ 3013 99999 856000
++ >;
++
++ vop-pn-msch-readlatency = <
++ 0 0x20
++ 4 0x20
++ >;
++
++ auto-min-freq = <328000>;
++ auto-freq-en = <0>;
++};
++
+ &emmc_phy {
+ status = "okay";
+ };
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-t-opp.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-t-opp.dtsi
+index 1ababadda9df..8d8e4e357834 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-t-opp.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-t-opp.dtsi
+@@ -83,6 +83,48 @@ opp03 {
+ opp-microvolt = <975000 975000 1150000>;
+ };
+ };
++
++ dmc_opp_table: opp-table3 {
++ compatible = "operating-points-v2";
++
++ opp-200000000 {
++ opp-hz = /bits/ 64 <200000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-300000000 {
++ opp-hz = /bits/ 64 <300000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-328000000 {
++ opp-hz = /bits/ 64 <328000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-400000000 {
++ opp-hz = /bits/ 64 <400000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-416000000 {
++ opp-hz = /bits/ 64 <416000000>;
++ opp-microvolt = <900000>;
++ };
++ opp-528000000 {
++ opp-hz = /bits/ 64 <528000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-600000000 {
++ opp-hz = /bits/ 64 <600000000>;
++ opp-microvolt = <900000>;
++ status = "disabled";
++ };
++ opp-666000000 {
++ opp-hz = /bits/ 64 <666000000>;
++ opp-microvolt = <900000>;
++ };
++ };
+ };
+
+ &cpu_l0 {
+@@ -109,6 +151,10 @@ &cpu_b1 {
+ operating-points-v2 = <&cluster1_opp>;
+ };
+
++&dmc {
++ operating-points-v2 = <&dmc_opp_table>;
++};
++
+ &gpu {
+ operating-points-v2 = <&gpu_opp_table>;
+ };
+--
+2.39.0
+
diff --git a/0007-Fix-ROCK-4-OTG-switch.patch b/0007-Fix-ROCK-4-OTG-switch.patch
new file mode 100644
index 000000000000..d06a174e48de
--- /dev/null
+++ b/0007-Fix-ROCK-4-OTG-switch.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Wed, 21 Dec 2022 17:00:39 +0800
+Subject: [PATCH] Fix ROCK 4 OTG switch
+
+---
+ arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index 273c6cc44499..dfeef2b2de5d 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -837,11 +837,7 @@ &u2phy0 {
+ status = "okay";
+
+ u2phy0_otg: otg-port {
+- status = "okay";
+- };
+-
+- u2phy0_host: host-port {
+- phy-supply = <&vcc5v0_host>;
++ rockchip,vbus-always-on;
+ status = "okay";
+ };
+ };
+@@ -889,8 +885,9 @@ &usbdrd3_0 {
+ };
+
+ &usbdrd_dwc3_0 {
+- status = "okay";
+ dr_mode = "otg";
++ extcon = <&u2phy0>;
++ status = "okay";
+ };
+
+ &usbdrd3_1 {
+--
+2.39.0
+
diff --git a/0008-Add-pwm-fan-for-ROCK-4C.patch b/0008-Add-pwm-fan-for-ROCK-4C.patch
new file mode 100644
index 000000000000..95f4065bb998
--- /dev/null
+++ b/0008-Add-pwm-fan-for-ROCK-4C.patch
@@ -0,0 +1,66 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Sat, 14 Jan 2023 18:26:12 +0800
+Subject: [PATCH] Add pwm-fan for ROCK 4C+
+
+The default thermal governor is power allocator, which does not support
+pwm-fan. Please change to either step-wise or fair-share governor to enable
+automatic fan control.
+---
+ .../boot/dts/rockchip/rk3399-rock-4c-plus.dts | 25 +++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
+index bc0649e5b1aa..777ed7407a5a 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4c-plus.dts
+@@ -27,6 +27,13 @@ aliases {
+ mmc2 = &sdio0;
+ };
+
++ fan0: pwm-fan {
++ compatible = "pwm-fan";
++ #cooling-cells = <2>;
++ cooling-levels = <0 64 128 192 255>;
++ pwms = <&pwm3 0 40000 0>;
++ };
++
+ fiq_debugger: fiq-debugger {
+ status = "okay";
+ compatible = "rockchip,fiq-debugger";
+@@ -240,6 +247,6 @@ &gpu {
+
+ &threshold {
+- temperature = <85000>;
++ temperature = <60000>;
+ };
+
+ &target {
+@@ -250,6 +258,24 @@ &soc_crit {
+ temperature = <105000>;
+ };
+
++&soc_thermal {
++ sustainable-power = <5000>; /* milliwatts */
++ cooling-maps {
++ map3 {
++ trip = <&target>;
++ cooling-device =
++ <&fan0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
++ contribution = <8192>;
++ };
++ map4 {
++ trip = <&threshold>;
++ cooling-device =
++ <&fan0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
++ contribution = <8192>;
++ };
++ };
++};
++
+ &tsadc {
+ /* tshut mode 0:CRU 1:GPIO */
+ rockchip,hw-tshut-mode = <1>;
+--
+2.39.0
+
diff --git a/0009-VENDOR-Add-Radxa-overlays.patch b/0009-VENDOR-Add-Radxa-overlays.patch
new file mode 100644
index 000000000000..c834c420b1ed
--- /dev/null
+++ b/0009-VENDOR-Add-Radxa-overlays.patch
@@ -0,0 +1,110 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Yuntian Zhang <yt@radxa.com>
+Date: Mon, 23 May 2022 15:36:50 +0800
+Subject: [PATCH] VENDOR: Add Radxa overlays
+
+Signed-off-by: Yuntian Zhang <yt@radxa.com>
+---
+ arch/arm64/boot/dts/amlogic/Makefile | 5 +++++
+ arch/arm64/boot/dts/rockchip/Makefile | 18 +++++++++++++++--
+ scripts/Makefile.dtbinst | 11 +++++++----
+ scripts/Makefile.lib | 6 ++++++
+ 4 files changed, 34 insertions(+), 6 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
+index f231280cd8..f9e467edff 100644
+--- a/arch/arm64/boot/dts/amlogic/Makefile
++++ b/arch/arm64/boot/dts/amlogic/Makefile
+@@ -1,4 +1,9 @@
++DTC_FLAGS_meson-g12a-radxa-zero := -@
++DTC_FLAGS_meson-g12b-radxa-zero2 := -@
++
++subdir-y += overlays
++
+ # SPDX-License-Identifier: GPL-2.0
+ dtb-$(CONFIG_ARCH_MESON) += meson-axg-s400.dtb
+ dtb-$(CONFIG_ARCH_MESON) += meson-g12a-sei510.dtb
+ dtb-$(CONFIG_ARCH_MESON) += meson-g12a-sei510-android.dtb
+diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile
+index 7cccbd7c6e..69399d2d41 100644
+--- a/arch/arm64/boot/dts/rockchip/Makefile
++++ b/arch/arm64/boot/dts/rockchip/Makefile
+@@ -1,4 +1,20 @@
++DTC_FLAGS_rk3328-rock-pi-e := -@
++DTC_FLAGS_rk3399-rock-4se := -@
++DTC_FLAGS_rk3399-rock-pi-4a-plus := -@
++DTC_FLAGS_rk3399-rock-pi-4b-plus := -@
++DTC_FLAGS_rk3399-rock-4c-plus := -@
++DTC_FLAGS_rk3399-rock-pi-4a := -@
++DTC_FLAGS_rk3399-rock-pi-4b := -@
++DTC_FLAGS_rk3399-rock-pi-4c := -@
++DTC_FLAGS_rk3399pro-rock-pi-n10 := -@
++DTC_FLAGS_rk3568-rock-3a := -@
++DTC_FLAGS_rk3588-rock-5b := -@
++DTC_FLAGS_rk3588-rock-5b-v11 := -@
++DTC_FLAGS_rk3588s-rock-5a := -@
++
++subdir-y += overlays
++
+ # SPDX-License-Identifier: GPL-2.0
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += px30-evb.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += px30-evb-ddr3-v10.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += px30-evb-ddr3-v10-avb.dtb
+@@ -178,5 +178,3 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-rock-5a.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-tablet-rk806-single-v10.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-tablet-v10.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-tablet-v11.dtb
+-
+-subdir-y := $(dts-dirs) overlay
+\ No newline at end of file
+diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst
+index 7b68939815d0..46f4739a2458 100644
+--- a/scripts/Makefile.dtbinst
++++ b/scripts/Makefile.dtbinst
+@@ -18,11 +18,11 @@ include scripts/Kbuild.include
+ include $(src)/Makefile
+
+ dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
+-dtbos := $(addprefix $(dst)/, $(dtbo-y))
+-readmes := $(addprefix $(dst)/, $(dtbotxt-y))
++scrs := $(addprefix $(dst)/, $(scr-y))
++dtbotxts:= $(addprefix $(dst)/, $(dtbotxt-y))
+ subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))
+
+-__dtbs_install: $(dtbs) $(dtbos) $(readmes) $(subdirs)
++__dtbs_install: $(dtbs) $(scrs) $(dtbotxts) $(subdirs)
+ @:
+
+ quiet_cmd_dtb_install = INSTALL $@
+@@ -34,7 +34,10 @@ $(dst)/%.dtb: $(obj)/%.dtb
+ $(dst)/%.dtbo: $(obj)/%.dtbo
+ $(call cmd,dtb_install)
+
+-$(dst)/README.rockchip-overlays: $(src)/README.rockchip-overlays
++$(dst)/%.scr: $(obj)/%.scr
++ $(call cmd,dtb_install)
++
++$(dst)/README.overlays: $(src)/README.overlays
+ $(call cmd,dtb_install)
+
+ PHONY += $(subdirs)
+diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
+index d142577866..f48d411b65 100644
+--- a/scripts/Makefile.lib
++++ b/scripts/Makefile.lib
+@@ -460,6 +460,12 @@ quiet_cmd_uimage = UIMAGE $@
+ -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
+ -n $(UIMAGE_NAME) -d $< $@
+
++quiet_cmd_scr = MKIMAGE $@
++ cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@
++
++$(obj)/%.scr: $(src)/%.cmd FORCE
++ $(call if_changed,scr)
++
+ # XZ
+ # ---------------------------------------------------------------------------
+ # Use xzkern to compress the kernel image and xzmisc to compress other things.
+--
+2.36.1
+
diff --git a/0010-Fix-dangling-pointer-compiler-bug.patch b/0010-Fix-dangling-pointer-compiler-bug.patch
new file mode 100644
index 000000000000..69d2c5512120
--- /dev/null
+++ b/0010-Fix-dangling-pointer-compiler-bug.patch
@@ -0,0 +1,33 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Yuntian Zhang <yt@radxa.com>
+Date: Mon, 16 May 2022 19:16:48 +0800
+Subject: [PATCH] Fix dangling-pointer compiler bug
+
+https://bugzilla.kernel.org/show_bug.cgi?id=215851
+
+Signed-off-by: Yuntian Zhang <yt@radxa.com>
+---
+ Makefile | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 35533e1411..380f5613a0 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1020,6 +1020,13 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
+ # change __FILE__ to the relative path from the srctree
+ KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+
++# Workaround the latest gcc bug
++# https://bugzilla.kernel.org/show_bug.cgi?id=215851
++KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
++KBUILD_CFLAGS += $(call cc-disable-warning, address)
++KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncatio)
++
+ # include additional Makefiles when needed
+ include-y := scripts/Makefile.extrawarn
+ include-$(CONFIG_KASAN) += scripts/Makefile.kasan
+--
+2.37.0
+
diff --git a/0011-Disable-tristate-for-non-modules.patch b/0011-Disable-tristate-for-non-modules.patch
new file mode 100644
index 000000000000..00c853787c61
--- /dev/null
+++ b/0011-Disable-tristate-for-non-modules.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com>
+Date: Sun, 9 Oct 2022 20:57:28 +0800
+Subject: [PATCH] Disable tristate for non-modules
+
+---
+ drivers/rkflash/Kconfig | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/rkflash/Kconfig b/drivers/rkflash/Kconfig
+index 5c2f4295da15..b92659757a02 100644
+--- a/drivers/rkflash/Kconfig
++++ b/drivers/rkflash/Kconfig
+@@ -29,7 +29,7 @@ config RK_SFTL
+ Say Y when you have a board with Slc Nand Flash register as block device.
+
+ config RK_NANDC_NAND
+- tristate "Rockchip NANDC Slc Nand Devices support"
++ bool "Rockchip NANDC Slc Nand Devices support"
+ default n
+ depends on RK_NAND != y
+ help
+@@ -41,7 +41,7 @@ config RK_NANDC_NAND
+ Nandc controller.
+
+ config RK_SFC_NAND
+- tristate "Rockchip SFC Spi Nand Devices support"
++ bool "Rockchip SFC Spi Nand Devices support"
+ default n
+ depends on RK_NAND != y
+ help
+@@ -63,7 +63,7 @@ config RK_SFC_NAND_MTD
+ Say Y when you wanna use mtd interface for SFC_NAND flash.
+
+ config RK_SFC_NOR
+- tristate "Rockchip SFC Spi Nor Devices Support"
++ bool "Rockchip SFC Spi Nor Devices Support"
+ select CRYPTO
+ select CRYPTO_LIB_ARC4
+ default n
+--
+2.38.0
+
diff --git a/0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch b/0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch
new file mode 100644
index 000000000000..c4aead15ca8c
--- /dev/null
+++ b/0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com>
+Date: Mon, 10 Oct 2022 10:57:00 +0800
+Subject: [PATCH] Disable tristate for modules that uses unexported symbols
+
+---
+ drivers/media/platform/rockchip/hdmirx/Kconfig | 2 +-
+ drivers/soc/rockchip/Kconfig | 2 +-
+ drivers/staging/android/fiq_debugger/Kconfig | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/media/platform/rockchip/hdmirx/Kconfig b/drivers/media/platform/rockchip/hdmirx/Kconfig
+index 4074cfe15ada..84bfa8afbdab 100644
+--- a/drivers/media/platform/rockchip/hdmirx/Kconfig
++++ b/drivers/media/platform/rockchip/hdmirx/Kconfig
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+
+ config VIDEO_ROCKCHIP_HDMIRX
+- tristate "Rockchip HDMI Receiver driver"
++ bool "Rockchip HDMI Receiver driver"
+ depends on VIDEO_V4L2
+ select MEDIA_CONTROLLER
+ select VIDEO_V4L2_SUBDEV_API
+diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
+index 24c5010726e6..9fd1eebbf12d 100644
+--- a/drivers/soc/rockchip/Kconfig
++++ b/drivers/soc/rockchip/Kconfig
+@@ -131,7 +131,7 @@ config ROCKCHIP_RAMDISK
+ device.
+
+ config ROCKCHIP_SUSPEND_MODE
+- tristate "Rockchip suspend mode config"
++ bool "Rockchip suspend mode config"
+ depends on ROCKCHIP_SIP
+ help
+ Say Y here if you want to set the suspend mode to the ATF.
+diff --git a/drivers/staging/android/fiq_debugger/Kconfig b/drivers/staging/android/fiq_debugger/Kconfig
+index 6ee93bc42d54..a23a613eab8a 100644
+--- a/drivers/staging/android/fiq_debugger/Kconfig
++++ b/drivers/staging/android/fiq_debugger/Kconfig
+@@ -1,5 +1,5 @@
+ config FIQ_DEBUGGER
+- tristate "FIQ Mode Serial Debugger"
++ bool "FIQ Mode Serial Debugger"
+ default n
+ depends on ARM || ARM64
+ help
+--
+2.38.0
+
diff --git a/0013-Disable-tristate-for-builtin-dependencies.patch b/0013-Disable-tristate-for-builtin-dependencies.patch
new file mode 100644
index 000000000000..2d8f0b9e4fbc
--- /dev/null
+++ b/0013-Disable-tristate-for-builtin-dependencies.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com>
+Date: Mon, 10 Oct 2022 11:05:56 +0800
+Subject: [PATCH] Disable tristate for builtin dependencies
+
+---
+ drivers/media/cec/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/cec/Kconfig b/drivers/media/cec/Kconfig
+index 9ba3a00dce31..e04df844c9b7 100644
+--- a/drivers/media/cec/Kconfig
++++ b/drivers/media/cec/Kconfig
+@@ -1,6 +1,6 @@
+ # SPDX-License-Identifier: GPL-2.0-only
+ config CEC_CORE
+- tristate
++ bool
+
+ config CEC_NOTIFIER
+ bool
+--
+2.38.0
+
diff --git a/0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch b/0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch
new file mode 100644
index 000000000000..0d55bc8659ca
--- /dev/null
+++ b/0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch
@@ -0,0 +1,89 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com>
+Date: Mon, 10 Oct 2022 10:37:39 +0800
+Subject: [PATCH] Revert "dma-buf/sw_sync: build sw-sync as module for gki"
+
+This reverts commit 70e8a5ecc49df2b401f7d286c060da051afeb02d.
+---
+ drivers/dma-buf/Kconfig | 9 +--------
+ drivers/dma-buf/Makefile | 3 +--
+ drivers/dma-buf/sync_debug.c | 2 ++
+ drivers/dma-buf/sync_debug.h | 2 +-
+ 4 files changed, 5 insertions(+), 11 deletions(-)
+
+diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
+index 151b7407471d..8be7c48d5c6e 100644
+--- a/drivers/dma-buf/Kconfig
++++ b/drivers/dma-buf/Kconfig
+@@ -41,7 +41,7 @@ config SYNC_FILE
+ Documentation/driver-api/sync_file.rst.
+
+ config SW_SYNC
+- tristate "Sync File Validation Framework"
++ bool "Sync File Validation Framework"
+ default n
+ depends on SYNC_FILE
+ help
+@@ -52,13 +52,6 @@ config SW_SYNC
+ WARNING: improper use of this can result in deadlocking kernel
+ drivers from userspace. Intended for test and debug only.
+
+-config SW_SYNC_DEBUG
+- bool "SW Sync Debug"
+- depends on DEBUG_FS && SW_SYNC && NO_GKI
+- default SW_SYNC
+- help
+- To get current fence point and timeline status.
+-
+ config UDMABUF
+ bool "userspace dmabuf misc driver"
+ default n
+diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile
+index 66c2dc4b6881..f1db46828575 100644
+--- a/drivers/dma-buf/Makefile
++++ b/drivers/dma-buf/Makefile
+@@ -5,8 +5,7 @@ obj-$(CONFIG_DMABUF_HEAPS) += dma-heap.o
+ obj-$(CONFIG_DMABUF_HEAPS) += heaps/
+ obj-$(CONFIG_DMABUF_CACHE) += dma-buf-cache.o
+ obj-$(CONFIG_SYNC_FILE) += sync_file.o
+-obj-$(CONFIG_SW_SYNC) += sw_sync.o
+-obj-$(CONFIG_SW_SYNC_DEBUG) += sync_debug.o
++obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o
+ obj-$(CONFIG_UDMABUF) += udmabuf.o
+ obj-$(CONFIG_DMABUF_SYSFS_STATS) += dma-buf-sysfs-stats.o
+ obj-$(CONFIG_DMABUF_HEAPS_ROCKCHIP) += rk_heaps/
+diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
+index 101394f16930..a2f906741ce0 100644
+--- a/drivers/dma-buf/sync_debug.c
++++ b/drivers/dma-buf/sync_debug.c
+@@ -8,6 +8,7 @@
+ #include <linux/debugfs.h>
+ #include "sync_debug.h"
+
++#ifdef CONFIG_DEBUG_FS
+ static struct dentry *dbgfs;
+
+ static LIST_HEAD(sync_timeline_list_head);
+@@ -188,3 +189,4 @@ static __init int sync_debugfs_init(void)
+ return 0;
+ }
+ late_initcall(sync_debugfs_init);
++#endif
+diff --git a/drivers/dma-buf/sync_debug.h b/drivers/dma-buf/sync_debug.h
+index fb676da19755..ee84997da6b4 100644
+--- a/drivers/dma-buf/sync_debug.h
++++ b/drivers/dma-buf/sync_debug.h
+@@ -62,9 +62,9 @@ struct sync_pt {
+ struct rb_node node;
+ };
+
++#ifdef CONFIG_DEBUG_FS
+ extern const struct file_operations sw_sync_debugfs_fops;
+
+-#ifdef CONFIG_SW_SYNC_DEBUG
+ void sync_timeline_debug_add(struct sync_timeline *obj);
+ void sync_timeline_debug_remove(struct sync_timeline *obj);
+ void sync_file_debug_add(struct sync_file *fence);
+--
+2.38.0
+
diff --git a/0015-Disable-tristate-for-essential-boot-services.patch b/0015-Disable-tristate-for-essential-boot-services.patch
new file mode 100644
index 000000000000..fb1da80446ed
--- /dev/null
+++ b/0015-Disable-tristate-for-essential-boot-services.patch
@@ -0,0 +1,39 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Thu, 3 Nov 2022 19:27:24 +0800
+Subject: [PATCH] Disable tristate for essential boot services
+
+---
+ drivers/gpio/Kconfig | 2 +-
+ drivers/pinctrl/Kconfig | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
+index 88edf9d46b37..0f2efbe28480 100644
+--- a/drivers/gpio/Kconfig
++++ b/drivers/gpio/Kconfig
+@@ -496,7 +496,7 @@ config GPIO_REG
+ can be used to represent any register as a set of GPIO signals.
+
+ config GPIO_ROCKCHIP
+- tristate "Rockchip GPIO support"
++ bool "Rockchip GPIO support"
+ depends on ARCH_ROCKCHIP || COMPILE_TEST
+ select GPIOLIB_IRQCHIP
+ default ARCH_ROCKCHIP
+diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
+index f38f98fe55a7..1a1effc28787 100644
+--- a/drivers/pinctrl/Kconfig
++++ b/drivers/pinctrl/Kconfig
+@@ -207,7 +207,7 @@ config PINCTRL_OXNAS
+ select MFD_SYSCON
+
+ config PINCTRL_ROCKCHIP
+- tristate "Rockchip gpio and pinctrl driver"
++ bool "Rockchip gpio and pinctrl driver"
+ depends on ARCH_ROCKCHIP || COMPILE_TEST
+ depends on OF
+ select GPIOLIB
+--
+2.38.1
+
diff --git a/0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch b/0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch
new file mode 100644
index 000000000000..f2bf447217ab
--- /dev/null
+++ b/0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch
@@ -0,0 +1,26 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntian <yt@radxa.com>
+Date: Thu, 3 Nov 2022 17:02:09 +0800
+Subject: [PATCH] Revert "ANDROID: clk: Enable writable debugfs files"
+
+This reverts commit 861a024589b3f42ca93877bf74f8a67f59c66ca8.
+---
+ drivers/clk/clk.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
+index bec881941483..f5f3e9db05ad 100644
+--- a/drivers/clk/clk.c
++++ b/drivers/clk/clk.c
+@@ -3107,7 +3107,7 @@ static int clk_dump_show(struct seq_file *s, void *data)
+ }
+ DEFINE_SHOW_ATTRIBUTE(clk_dump);
+
+-#define CLOCK_ALLOW_WRITE_DEBUGFS
++#undef CLOCK_ALLOW_WRITE_DEBUGFS
+ #ifdef CLOCK_ALLOW_WRITE_DEBUGFS
+ /*
+ * This can be dangerous, therefore don't provide any real compile time
+--
+2.38.1
+
diff --git a/0017-Modfy-GPU-node-for-Panfrost-driver.patch b/0017-Modfy-GPU-node-for-Panfrost-driver.patch
new file mode 100644
index 000000000000..10d0acab176a
--- /dev/null
+++ b/0017-Modfy-GPU-node-for-Panfrost-driver.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntan <yt@radxa.com>
+Date: Mon, 5 Dec 2022 17:35:53 +0800
+Subject: [PATCH] Modfy GPU node for Panfrost driver
+
+This change is necessary for panfrost to detect GPU in RK3399 SoC.
+
+This partially reverts eca1fb47441368e146603effffc59902dc7d2d76.
+---
+ arch/arm64/boot/dts/rockchip/rk3399.dtsi | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+index 64b2d7f2fee5..d8a975ab85a5 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+@@ -2200,7 +2200,8 @@ gpu: gpu@ff9a0000 {
+ compatible = "arm,malit860",
+ "arm,malit86x",
+ "arm,malit8xx",
+- "arm,mali-midgard";
++ "arm,mali-midgard",
++ "rockchip,rk3399-mali", "arm,mali-t860";
+ reg = <0x0 0xff9a0000 0x0 0x10000>;
+ interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH 0>,
+ <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH 0>,
+--
+2.38.1
+
diff --git a/0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch b/0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch
new file mode 100644
index 000000000000..a69f0871e3a7
--- /dev/null
+++ b/0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch
@@ -0,0 +1,39 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntan <yt@radxa.com>
+Date: Tue, 6 Dec 2022 16:10:47 +0800
+Subject: [PATCH] VENDOR: Version tagging linux-libc-dev as well
+
+---
+ scripts/package/builddeb | 2 +-
+ scripts/package/mkdebian | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/package/builddeb b/scripts/package/builddeb
+index 91a502bb97e8..6eb5af462341 100755
+--- a/scripts/package/builddeb
++++ b/scripts/package/builddeb
+@@ -215,7 +215,7 @@ if [ "$ARCH" != "um" ]; then
+ fi
+
+ deploy_libc_headers debian/linux-libc-dev
+- create_package linux-libc-dev debian/linux-libc-dev
++ create_package linux-libc-dev-$version debian/linux-libc-dev
+ fi
+
+ create_package "$packagename" "$tmpdir"
+diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
+index 60a2a63a5e90..c300ca732afd 100755
+--- a/scripts/package/mkdebian
++++ b/scripts/package/mkdebian
+@@ -184,7 +184,7 @@ Description: Linux kernel, version $version
+ This package contains the Linux kernel, modules and corresponding other
+ files, version: $version.
+
+-Package: linux-libc-dev
++Package: linux-libc-dev-$version
+ Section: devel
+ Provides: linux-kernel-headers
+ Architecture: $debarch
+--
+2.38.1
+
diff --git a/0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch b/0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch
new file mode 100644
index 000000000000..567360ca1e58
--- /dev/null
+++ b/0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch
@@ -0,0 +1,1193 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ZHANG Yuntan <yt@radxa.com>
+Date: Wed, 14 Dec 2022 12:13:47 +0800
+Subject: [PATCH] Add ROCK 4 Core IO Board (Fuhai)
+
+---
+ arch/arm64/boot/dts/rockchip/Makefile | 1 +
+ .../dts/rockchip/rk3399-rock-4-core-io.dts | 562 +++++++++++++++++
+ .../boot/dts/rockchip/rk3399-rock-4-core.dtsi | 591 ++++++++++++++++++
+ 3 files changed, 1154 insertions(+)
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-rock-4-core-io.dts
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-rock-4-core.dtsi
+
+diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile
+index fb4270f89050..436836c2e76e 100644
+--- a/arch/arm64/boot/dts/rockchip/Makefile
++++ b/arch/arm64/boot/dts/rockchip/Makefile
+@@ -72,6 +72,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-pinebook-pro.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-puma-haikou.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-roc-pc.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-roc-pc-mezzanine.dtb
++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-4-core-io.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-4se.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4a-plus.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4b-plus.dtb
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core-io.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core-io.dts
+new file mode 100644
+index 000000000000..a2c27b569ec7
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core-io.dts
+@@ -0,0 +1,562 @@
++// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
++/*
++ * Copyright (c) 2019 Akash Gajjar <Akash_Gajjar@mentor.com>
++ * Copyright (c) 2019 Pragnesh Patel <Pragnesh_Patel@mentor.com>
++ */
++
++/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
++#include <dt-bindings/pwm/pwm.h>
++#include "rk3399-rock-4-core.dtsi"
++
++/ {
++ model = "Radxa ROCK 4 Core IO Board";
++ compatible = "radxa,rock-4-core-io", "rockchip,rk3399";
++
++ clkin_gmac: external-gmac-clock {
++ compatible = "fixed-clock";
++ clock-frequency = <125000000>;
++ clock-output-names = "clkin_gmac";
++ #clock-cells = <0>;
++ };
++
++ hdmi_sound: hdmi-sound {
++ status = "okay";
++ compatible = "rockchip,hdmi";
++ rockchip,mclk-fs = <256>;
++ rockchip,card-name = "rockchip-hdmi0";
++ rockchip,cpu = <&i2s2>;
++ rockchip,codec = <&hdmi>;
++ rockchip,jack-det;
++ };
++
++ sdio_pwrseq: sdio-pwrseq {
++ compatible = "mmc-pwrseq-simple";
++ clocks = <&rk818 1>;
++ clock-names = "ext_clock";
++ pinctrl-names = "default";
++ pinctrl-0 = <&wifi_enable_h>;
++ reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
++ };
++
++ es8316_sound: es8316-sound {
++ status = "okay";
++ compatible = "simple-audio-card";
++ simple-audio-card,format = "i2s";
++ simple-audio-card,mclk-fs = <256>;
++ simple-audio-card,name = "rockchip-es8316";
++ simple-audio-card,dai-link@0 {
++ format = "i2s";
++ cpu {
++ sound-dai = <&i2s0>;
++ };
++ codec {
++ sound-dai = <&es8316>;
++ };
++ };
++ };
++
++ rk_headset: rk-headset {
++ status = "okay";
++ compatible = "rockchip_headset";
++ headset_gpio = <&gpio1 RK_PA0 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&hp_det>;
++ io-channels = <&saradc 2>;
++ };
++
++ vcc5v0_sys: vcc5v0-sys {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc5v0_sys";
++ regulator-min-microvolt = <5000000>;
++ regulator-max-microvolt = <5000000>;
++ regulator-always-on;
++ regulator-boot-on;
++ vin-supply = <&vcc12v_dcin>;
++ };
++
++ vcc12v_dcin: dc-12v {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc12v_dcin";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <12000000>;
++ regulator-max-microvolt = <12000000>;
++ };
++
++ vcc_0v9: vcc-0v9 {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_0v9";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <900000>;
++ regulator-max-microvolt = <900000>;
++ vin-supply = <&vcc3v3_sys>;
++ };
++
++ vcc3v3_pcie: vcc3v3-pcie-regulator {
++ compatible = "regulator-fixed";
++ enable-active-high;
++ gpio = <&gpio2 RK_PD2 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&pcie_pwr_en>;
++ regulator-name = "vcc3v3_pcie";
++ regulator-always-on;
++ regulator-boot-on;
++ vin-supply = <&vcc5v0_sys>;
++ };
++
++ vcc3v3_sys: vcc3v3-sys {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc3v3_sys";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ vin-supply = <&vcc5v0_sys>;
++ };
++
++ vcc5v0_host: vcc5v0-host-regulator {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc5v0_host";
++ regulator-always-on;
++ vin-supply = <&vcc5v0_sys>;
++ };
++
++ vcc5v0_typec: vcc5v0-typec-regulator {
++ compatible = "regulator-fixed";
++ enable-active-high;
++ gpio = <&gpio1 RK_PA3 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&vcc5v0_typec_en>;
++ regulator-name = "vcc5v0_typec";
++ regulator-always-on;
++ vin-supply = <&vcc5v0_sys>;
++ };
++
++ vcc_lan: vcc3v3-phy-regulator {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_lan";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vdd_log: vdd-log {
++ compatible = "pwm-regulator";
++ pwms = <&pwm2 0 25000 1>;
++ regulator-name = "vdd_log";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <800000>;
++ regulator-max-microvolt = <1400000>;
++ vin-supply = <&vcc5v0_sys>;
++ };
++
++ leds {
++ compatible = "gpio-leds";
++ pinctrl-names = "default";
++ pinctrl-0 = <&power_led_gpio>, <&status_led_gpio>;
++
++ power-status {
++ label = "power";
++ gpios = <&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "default-on";
++ status = "disabled";
++ };
++
++ system-status {
++ label = "status";
++ gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "heartbeat";
++ };
++ };
++
++ camera_pwdn_gpio: camera-pwdn-gpio {
++ status = "disabled";
++ compatible = "regulator-fixed";
++ regulator-name = "camera_pwdn_gpio";
++ regulator-always-on;
++ regulator-boot-on;
++ enable-active-high;
++ gpio = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&cam_pwdn_gpio>;
++ };
++
++ clk_cam_24m: external-camera-clock-24m {
++ status = "disabled";
++ compatible = "fixed-clock";
++ clock-frequency = <24000000>;
++ clock-output-names = "clk_cam_24m";
++ #clock-cells = <0>;
++ };
++};
++
++&i2c4 {
++ status = "okay";
++};
++
++&fusb0 {
++ status = "okay";
++};
++
++&gmac {
++ assigned-clocks = <&cru SCLK_RMII_SRC>;
++ assigned-clock-parents = <&clkin_gmac>;
++ clock_in_out = "input";
++ phy-supply = <&vcc_lan>;
++ phy-mode = "rgmii";
++ pinctrl-names = "default";
++ pinctrl-0 = <&rgmii_pins>;
++ snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
++ snps,reset-active-low;
++ snps,reset-delays-us = <0 10000 50000>;
++ tx_delay = <0x28>;
++ rx_delay = <0x11>;
++ status = "okay";
++};
++
++&hdmi {
++ pinctrl-names = "default";
++ pinctrl-0 = <&hdmi_i2c_xfer>, <&hdmi_cec>;
++ #address-cells = <1>;
++ #size-cells = <0>;
++ #sound-dai-cells = <0>;
++ status = "okay";
++};
++
++&hdmi_in_vopl {
++ status = "disabled";
++};
++
++&route_hdmi {
++ connect = <&vopb_out_hdmi>;
++ status = "okay";
++};
++
++&hdmi_sound {
++ status = "okay";
++};
++
++&i2c1 {
++ i2c-scl-rising-time-ns = <300>;
++ i2c-scl-falling-time-ns = <15>;
++ status = "okay";
++
++ es8316: es8316@11 {
++ compatible = "everest,es8316";
++ reg = <0x11>;
++ clocks = <&cru SCLK_I2S_8CH_OUT>;
++ clock-names = "mclk";
++ pinctrl-names = "default";
++ pinctrl-0 = <&i2s_8ch_mclk>;
++ #sound-dai-cells = <0>;
++ };
++};
++
++&i2s0 {
++ status = "okay";
++ rockchip,playback-channels = <2>;
++ rockchip,capture-channels = <2>;
++ #sound-dai-cells = <0>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&i2s0_8ch_bus>;
++};
++
++&i2s2 {
++ #sound-dai-cells = <0>;
++ status = "okay";
++};
++
++&pcie_phy {
++ status = "okay";
++};
++
++&pcie0 {
++ ep-gpios = <&gpio4 RK_PD3 GPIO_ACTIVE_HIGH>;
++ max-link-speed = <2>;
++ num-lanes = <4>;
++ pinctrl-0 = <&pcie_clkreqnb_cpm>;
++ pinctrl-names = "default";
++ vpcie0v9-supply = <&vcc_0v9>;
++ vpcie1v8-supply = <&vcc_1v8>;
++ vpcie3v3-supply = <&vcc3v3_pcie>;
++ status = "okay";
++};
++
++&pinctrl {
++ bt {
++ bt_enable_h: bt-enable-h {
++ rockchip,pins = <0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++
++ bt_host_wake_l: bt-host-wake-l {
++ rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++
++ bt_wake_l: bt-wake-l {
++ rockchip,pins = <2 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++
++ pcie {
++ pcie_pwr_en: pcie-pwr-en {
++ rockchip,pins = <2 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++
++ sdio0 {
++ sdio0_bus4: sdio0-bus4 {
++ rockchip,pins = <2 RK_PC4 1 &pcfg_pull_up_20ma>,
++ <2 RK_PC5 1 &pcfg_pull_up_20ma>,
++ <2 RK_PC6 1 &pcfg_pull_up_20ma>,
++ <2 RK_PC7 1 &pcfg_pull_up_20ma>;
++ };
++
++ sdio0_cmd: sdio0-cmd {
++ rockchip,pins = <2 RK_PD0 1 &pcfg_pull_up_20ma>;
++ };
++
++ sdio0_clk: sdio0-clk {
++ rockchip,pins = <2 RK_PD1 1 &pcfg_pull_none_20ma>;
++ };
++ };
++
++ leds {
++ power_led_gpio: power_led_gpio {
++ rockchip,pins = <3 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++
++ status_led_gpio: status_led_gpio {
++ rockchip,pins = <3 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++
++ usb-typec {
++ vcc5v0_typec_en: vcc5v0-typec-en {
++ rockchip,pins = <1 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
++ };
++ };
++
++ wifi {
++ wifi_enable_h: wifi-enable-h {
++ rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++
++ wifi_host_wake_l: wifi-host-wake-l {
++ rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
++ };
++ };
++
++ i2s0 {
++ i2s0_8ch_bus: i2s0-8ch-bus {
++ rockchip,pins =
++ <3 RK_PD0 1 &pcfg_pull_none>,
++ <3 RK_PD1 1 &pcfg_pull_none>,
++ <3 RK_PD2 1 &pcfg_pull_none>,
++ <3 RK_PD3 1 &pcfg_pull_none>,
++ <3 RK_PD7 1 &pcfg_pull_none>;
++ };
++
++ i2s_8ch_mclk: i2s-8ch-mclk {
++ rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>;
++ };
++ };
++
++ headphone {
++ hp_det: hp-det {
++ rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
++ };
++ };
++
++ camera {
++ cam_pwdn_gpio: cam-pwdn-gpio {
++ rockchip,pins = <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>;
++ };
++ };
++};
++
++&pwm2 {
++ status = "okay";
++};
++
++&saradc {
++ status = "okay";
++
++ vref-supply = <&vcc_1v8>;
++};
++
++&sdio0 {
++ #address-cells = <1>;
++ #size-cells = <0>;
++ bus-width = <4>;
++ clock-frequency = <50000000>;
++ cap-sdio-irq;
++ cap-sd-highspeed;
++ keep-power-in-suspend;
++ mmc-pwrseq = <&sdio_pwrseq>;
++ non-removable;
++ pinctrl-names = "default";
++ pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
++ sd-uhs-sdr104;
++};
++
++&tcphy0 {
++ status = "okay";
++};
++
++&tcphy1 {
++ status = "okay";
++};
++
++&tsadc {
++ status = "okay";
++
++ /* tshut mode 0:CRU 1:GPIO */
++ rockchip,hw-tshut-mode = <1>;
++ /* tshut polarity 0:LOW 1:HIGH */
++ rockchip,hw-tshut-polarity = <1>;
++};
++
++&u2phy0 {
++ status = "okay";
++
++ u2phy0_otg: otg-port {
++ status = "okay";
++ };
++
++ u2phy0_host: host-port {
++ phy-supply = <&vcc5v0_host>;
++ status = "okay";
++ };
++};
++
++&u2phy1 {
++ status = "okay";
++
++ u2phy1_otg: otg-port {
++ status = "okay";
++ };
++
++ u2phy1_host: host-port {
++ phy-supply = <&vcc5v0_host>;
++ status = "okay";
++ };
++};
++
++&uart0 {
++ pinctrl-names = "default";
++ pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
++};
++
++&uart2 {
++ status = "okay";
++};
++
++&usb_host0_ehci {
++ status = "okay";
++};
++
++&usb_host0_ohci {
++ status = "okay";
++};
++
++&usb_host1_ehci {
++ status = "okay";
++};
++
++&usb_host1_ohci {
++ status = "okay";
++};
++
++&usbdrd3_0 {
++ status = "okay";
++};
++
++&usbdrd_dwc3_0 {
++ status = "okay";
++ dr_mode = "otg";
++};
++
++&usbdrd3_1 {
++ status = "okay";
++};
++
++&usbdrd_dwc3_1 {
++ status = "okay";
++ dr_mode = "host";
++};
++
++&display_subsystem {
++ status = "okay";
++};
++
++&vopb {
++ status = "okay";
++ assigned-clocks = <&cru DCLK_VOP0_DIV>;
++ assigned-clock-parents = <&cru PLL_CPLL>;
++};
++
++&vopb_mmu {
++ status = "okay";
++};
++
++&vopl {
++ status = "okay";
++ assigned-clocks = <&cru DCLK_VOP1_DIV>;
++ assigned-clock-parents = <&cru PLL_VPLL>;
++};
++
++&vopl_mmu {
++ status = "okay";
++};
++
++&mipi_dphy_rx0 {
++ status = "okay";
++
++ ports {
++ #address-cells = <1>;
++ #size-cells = <0>;
++
++ port@0 {
++ reg = <0>;
++ #address-cells = <1>;
++ #size-cells = <0>;
++ };
++
++ port@1 {
++ reg = <1>;
++ #address-cells = <1>;
++ #size-cells = <0>;
++
++ dphy_rx0_out: endpoint@0 {
++ reg = <0>;
++ remote-endpoint = <&isp0_mipi_in>;
++ };
++ };
++ };
++};
++
++&isp0_mmu {
++ status = "okay";
++};
++
++&rkisp1_0 {
++ status = "okay";
++
++ port {
++ #address-cells = <1>;
++ #size-cells = <0>;
++
++ isp0_mipi_in: endpoint@0 {
++ reg = <0>;
++ remote-endpoint = <&dphy_rx0_out>;
++ };
++ };
++};
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core.dtsi
+new file mode 100644
+index 000000000000..daa480da841b
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-4-core.dtsi
+@@ -0,0 +1,591 @@
++/*
++ * Copyright (c) 2016 Fuzhou Rockchip Electronics Co., Ltd
++ *
++ * This file is dual-licensed: you can use it either under the terms
++ * of the GPL or the X11 license, at your option. Note that this dual
++ * licensing only applies to this file, and not this project as a
++ * whole.
++ *
++ * a) This file is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This file is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Or, alternatively,
++ *
++ * b) Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or
++ * sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
++#include <dt-bindings/pwm/pwm.h>
++#include <dt-bindings/input/input.h>
++#include "rk3399.dtsi"
++#include "rk3399-linux.dtsi"
++#include "rk3399-opp.dtsi"
++#include "rk3399-vop-clk-set.dtsi"
++
++/ {
++ aliases {
++ mmc0 = &sdmmc;
++ mmc1 = &sdhci;
++ mmc2 = &sdio0;
++ };
++
++ vcc1v8_s0: vcc1v8-s0 {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc1v8_s0";
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ regulator-always-on;
++ };
++
++ vcc_sys: vcc-sys {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_sys";
++ regulator-min-microvolt = <5000000>;
++ regulator-max-microvolt = <5000000>;
++ regulator-always-on;
++ };
++
++ vcc_phy: vcc-phy-regulator {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_phy";
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
++ vcc3v3_sys: vcc3v3-sys {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc3v3_sys";
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ regulator-always-on;
++ vin-supply = <&vcc_sys>;
++ };
++
++ vdd_log: vdd-log {
++ compatible = "pwm-regulator";
++ pwms = <&pwm2 0 25000 1>;
++ regulator-name = "vdd_log";
++ regulator-min-microvolt = <800000>;
++ regulator-max-microvolt = <1400000>;
++ regulator-always-on;
++ regulator-boot-on;
++
++ /* for rockchip boot on */
++ rockchip,pwm_id= <2>;
++ rockchip,pwm_voltage = <900000>;
++
++ vin-supply = <&vcc_sys>;
++ };
++};
++
++&emmc_phy {
++ status = "okay";
++};
++
++&sdhci {
++ bus-width = <8>;
++ mmc-hs400-1_8v;
++ supports-emmc;
++ non-removable;
++ mmc-hs400-enhanced-strobe;
++ status = "okay";
++};
++
++&i2c0 {
++ status = "okay";
++ i2c-scl-rising-time-ns = <168>;
++ i2c-scl-falling-time-ns = <4>;
++ clock-frequency = <400000>;
++
++ vdd_cpu_b: syr827@40 {
++ compatible = "silergy,syr827";
++ reg = <0x40>;
++ regulator-compatible = "fan53555-reg";
++ pinctrl-names = "default";
++ pinctrl-0 = <&vsel1_gpio>;
++ vsel-gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;
++ regulator-name = "vdd_cpu_b";
++ regulator-min-microvolt = <712500>;
++ regulator-max-microvolt = <1500000>;
++ regulator-ramp-delay = <1000>;
++ fcs,suspend-voltage-selector = <1>;
++ regulator-always-on;
++ regulator-boot-on;
++ vin-supply = <&vcc_sys>;
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vdd_gpu: syr828@41 {
++ compatible = "silergy,syr828";
++ reg = <0x41>;
++ regulator-compatible = "fan53555-reg";
++ pinctrl-names = "default";
++ pinctrl-0 = <&vsel2_gpio>;
++ vsel-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
++ regulator-name = "vdd_gpu";
++ regulator-min-microvolt = <712500>;
++ regulator-max-microvolt = <1500000>;
++ regulator-ramp-delay = <1000>;
++ fcs,suspend-voltage-selector = <1>;
++ regulator-always-on;
++ regulator-boot-on;
++ vin-supply = <&vcc_sys>;
++ regulator-initial-mode = <1>; /* 1:force PWM 2:auto */
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ rk818: pmic@1c {
++ compatible = "rockchip,rk818";
++ status = "okay";
++ reg = <0x1c>;
++ clock-output-names = "rk818-clkout1", "wifibt_32kin";
++ interrupt-parent = <&gpio1>;
++ interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
++ extcon = <&fusb0>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&pmic_int_l>;
++ rockchip,system-power-controller;
++ rk818,support_dc_chg = <1>;/*1: dc chg; 0:usb chg*/
++ wakeup-source;
++ #clock-cells = <1>;
++
++ vcc1-supply = <&vcc_sys>;
++ vcc2-supply = <&vcc_sys>;
++ vcc3-supply = <&vcc_sys>;
++ vcc4-supply = <&vcc_sys>;
++ vcc6-supply = <&vcc_sys>;
++ vcc7-supply = <&vcc3v3_sys>;
++ vcc8-supply = <&vcc_sys>;
++ vcc9-supply = <&vcc3v3_sys>;
++
++ regulators {
++ vdd_cpu_l: DCDC_REG1 {
++ regulator-name = "vdd_cpu_l";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <750000>;
++ regulator-max-microvolt = <1350000>;
++ regulator-ramp-delay = <6001>;
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vdd_center: DCDC_REG2 {
++ regulator-name = "vdd_center";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <800000>;
++ regulator-max-microvolt = <1350000>;
++ regulator-ramp-delay = <6001>;
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcc_ddr: DCDC_REG3 {
++ regulator-name = "vcc_ddr";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ };
++ };
++
++ vcc_1v8: DCDC_REG4 {
++ regulator-name = "vcc_1v8";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <1800000>;
++ };
++ };
++
++ vcca3v0_codec: LDO_REG1 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3000000>;
++ regulator-max-microvolt = <3000000>;
++ regulator-name = "vcca3v0_codec";
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcc3v0_tp: LDO_REG2 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3000000>;
++ regulator-max-microvolt = <3000000>;
++ regulator-name = "vcc3v0_tp";
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcca1v8_codec: LDO_REG3 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ regulator-name = "vcca1v8_codec";
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcc_power_on: LDO_REG4 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ regulator-name = "vcc_power_on";
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <3300000>;
++ };
++ };
++
++ vcc_3v0: LDO_REG5 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3000000>;
++ regulator-max-microvolt = <3000000>;
++ regulator-name = "vcc_3v0";
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <3000000>;
++ };
++ };
++
++ vcc_1v5: LDO_REG6 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <1500000>;
++ regulator-max-microvolt = <1500000>;
++ regulator-name = "vcc_1v5";
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <1500000>;
++ };
++ };
++
++ vcc1v8_dvp: LDO_REG7 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ regulator-name = "vcc1v8_dvp";
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcc3v3_s3: LDO_REG8 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ regulator-name = "vcc3v3_s3";
++ regulator-state-mem {
++ regulator-off-in-suspend;
++ };
++ };
++
++ vcc_sd: LDO_REG9 {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <3000000>;
++ regulator-name = "vcc_sd";
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <3000000>;
++ };
++ };
++
++ vcc3v3_s0: SWITCH_REG {
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-name = "vcc3v3_s0";
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ };
++ };
++
++ boost_otg: DCDC_BOOST {
++ regulator-name = "boost_otg";
++ regulator-always-on;
++ regulator-boot-on;
++ regulator-min-microvolt = <5000000>;
++ regulator-max-microvolt = <5000000>;
++ regulator-state-mem {
++ regulator-on-in-suspend;
++ regulator-suspend-microvolt = <5000000>;
++ };
++ };
++
++ otg_switch: OTG_SWITCH {
++ regulator-name = "otg_switch";
++ };
++ };
++
++ battery {
++ compatible = "rk818-battery";
++ ocv_table = <3400 3675 3689 3716 3740 3756 3768 3780
++ 3793 3807 3827 3853 3896 3937 3974 4007 4066
++ 4110 4161 4217 4308>;
++ design_capacity = <7916>;
++ design_qmax = <8708>;
++ bat_res = <65>;
++ max_input_current = <3000>;
++ max_chrg_current = <3000>;
++ max_chrg_voltage = <4350>;
++ sleep_enter_current = <300>;
++ sleep_exit_current = <300>;
++ power_off_thresd = <3400>;
++ zero_algorithm_vol = <3950>;
++ fb_temperature = <105>;
++ sample_res = <20>;
++ max_soc_offset = <60>;
++ energy_mode = <0>;
++ monitor_sec = <5>;
++ virtual_power = <0>;
++ power_dc2otg = <0>;
++ };
++ };
++};
++
++&i2c4 {
++ status = "disabled";
++
++ fusb0: fusb30x@22 {
++ compatible = "fairchild,fusb302";
++ reg = <0x22>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&fusb0_int>;
++ int-n-gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
++ vbus-5v-gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_HIGH>;
++ status = "disabled";
++ };
++};
++
++&cpu_l0 {
++ cpu-supply = <&vdd_cpu_l>;
++};
++
++&cpu_l1 {
++ cpu-supply = <&vdd_cpu_l>;
++};
++
++&cpu_l2 {
++ cpu-supply = <&vdd_cpu_l>;
++};
++
++&cpu_l3 {
++ cpu-supply = <&vdd_cpu_l>;
++};
++
++&cpu_b0 {
++ cpu-supply = <&vdd_cpu_b>;
++};
++
++&cpu_b1 {
++ cpu-supply = <&vdd_cpu_b>;
++};
++
++&gpu {
++ status = "okay";
++ mali-supply = <&vdd_gpu>;
++};
++
++&threshold {
++ temperature = <85000>;
++};
++
++&target {
++ temperature = <100000>;
++};
++
++&soc_crit {
++ temperature = <105000>;
++};
++
++&tsadc {
++ status = "okay";
++ /* tshut mode 0:CRU 1:GPIO */
++ rockchip,hw-tshut-mode = <1>;
++ /* tshut polarity 0:LOW 1:HIGH */
++ rockchip,hw-tshut-polarity = <1>;
++ rockchip,hw-tshut-temp = <110000>;
++};
++
++&saradc {
++ status = "okay";
++};
++
++&pwm2 {
++ status = "okay";
++};
++
++&io_domains {
++ status = "okay";
++
++ bt656-supply = <&vcc_3v0>; /* bt656_gpio2ab_ms */
++ audio-supply = <&vcc_1v8>; /* audio_gpio3d4a_ms */
++ sdmmc-supply = <&vcc_sd>; /* sdmmc_gpio4b_ms */
++ gpio1830-supply = <&vcc_3v0>; /* gpio1833_gpio4cd_ms */
++};
++
++&spi1 {
++ status = "disabled";
++ max-freq = <10000000>;
++
++ spiflash: spi-flash@0 {
++ #address-cells = <0x1>;
++ #size-cells = <1>;
++ compatible = "jedec,spi-nor";
++ reg = <0x0>;
++ status = "disabled";
++ spi-max-frequency = <10000000>;
++
++ partitions {
++ compatible = "fixed-partitions";
++ #address-cells = <1>;
++ #size-cells = <1>;
++
++ loader@0 {
++ label = "loader";
++ reg = <0x0 0x400000>;
++ };
++ };
++ };
++};
++
++&pinctrl {
++ pmic {
++ pmic_int_l: pmic-int-l {
++ rockchip,pins =
++ <1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
++ };
++
++ vsel1_gpio: vsel1-gpio {
++ rockchip,pins =
++ <1 17 RK_FUNC_GPIO &pcfg_pull_down>;
++ };
++
++ vsel2_gpio: vsel2-gpio {
++ rockchip,pins =
++ <1 14 RK_FUNC_GPIO &pcfg_pull_down>;
++ };
++ };
++
++ fusb30x {
++ fusb0_int: fusb0-int {
++ rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>;
++ };
++ };
++};
++
++&pvtm {
++ status = "okay";
++};
++
++&pmu_pvtm {
++ status = "okay";
++};
++
++&pmu_io_domains {
++ status = "okay";
++ pmu1830-supply = <&vcc_1v8>;
++};
++
++&sdmmc {
++ clock-frequency = <150000000>;
++ clock-freq-min-max = <100000 150000000>;
++ no-sdio;
++ no-mmc;
++ bus-width = <4>;
++ cap-mmc-highspeed;
++ cap-sd-highspeed;
++ disable-wp;
++ sd-uhs-sdr104;
++ num-slots = <1>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&sdmmc_clk &sdmmc_cd &sdmmc_cmd &sdmmc_bus4>;
++ vqmmc-supply = <&vcc_sd>;
++ status = "okay";
++};
++
++&sdhci {
++ max-frequency = <150000000>;
++ bus-width = <8>;
++ mmc-hs400-1_8v;
++ mmc-hs400-enhanced-strobe;
++ non-removable;
++ status = "okay";
++};
++
++
++&rockchip_suspend {
++ status = "okay";
++ rockchip,sleep-debug-en = <0>;
++ rockchip,sleep-mode-config = <
++ (0
++ | RKPM_SLP_ARMPD
++ | RKPM_SLP_PERILPPD
++ | RKPM_SLP_DDR_RET
++ | RKPM_SLP_PLLPD
++ | RKPM_SLP_CENTER_PD
++ | RKPM_SLP_AP_PWROFF
++ )
++ >;
++ rockchip,wakeup-config = <
++ (0
++ | RKPM_GPIO_WKUP_EN
++ | RKPM_PWM_WKUP_EN
++ )
++ >;
++ rockchip,pwm-regulator-config = <
++ (0
++ | PWM2_REGULATOR_EN
++ )
++ >;
++ rockchip,power-ctrl =
++ <&gpio1 17 GPIO_ACTIVE_HIGH>,
++ <&gpio1 14 GPIO_ACTIVE_HIGH>;
++};
+--
+2.39.0
+
diff --git a/0020-gcc-ignore-stringop-overread-warnings.patch b/0020-gcc-ignore-stringop-overread-warnings.patch
new file mode 100644
index 000000000000..84a3e6989f01
--- /dev/null
+++ b/0020-gcc-ignore-stringop-overread-warnings.patch
@@ -0,0 +1,13 @@
+--- kernel-linux-5.10-gen-rkr3.4/Makefile 2023-01-19 18:19:05.876849374 +0100
++++ kernel-linux-5.10-gen-rkr3.4/Makefile.new 2023-01-19 18:19:29.209457186 +0100
+@@ -1028,6 +1028,10 @@
+ KBUILD_CFLAGS += $(call cc-disable-warning, address)
+ KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncatio)
++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overread)
++KBUILD_CFLAGS += $(call cc-disable-warning, implicit-fallthrough)
++KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
++KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
+
+ # include additional Makefiles when needed
+ include-y := scripts/Makefile.extrawarn
diff --git a/0021-dma-buf-add-dma_resv_get_singleton-v2.patch b/0021-dma-buf-add-dma_resv_get_singleton-v2.patch
new file mode 100644
index 000000000000..0c81695803a5
--- /dev/null
+++ b/0021-dma-buf-add-dma_resv_get_singleton-v2.patch
@@ -0,0 +1,115 @@
+From 628b9127e29ac2a00852a59e13d45108c5c4e778 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Wed, 3 Nov 2021 10:02:08 +0100
+Subject: [PATCH 1/5] dma-buf: add dma_resv_get_singleton v2
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Add a function to simplify getting a single fence for all the fences in
+the dma_resv object.
+
+v2: fix ref leak in error handling
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Link: https://patchwork.freedesktop.org/patch/msgid/20220321135856.1331-3-christian.koenig@amd.com
+(cherry picked from commit 92cedee6a6a3e6fcc3ffc0e3866baae5f6f76ac1)
+---
+ drivers/dma-buf/dma-resv.c | 59 ++++++++++++++++++++++++++++++++++++++
+ include/linux/dma-resv.h | 2 ++
+ 2 files changed, 61 insertions(+)
+
+diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
+index 1187e5e80ede..4c4ec20b99f7 100644
+--- a/drivers/dma-buf/dma-resv.c
++++ b/drivers/dma-buf/dma-resv.c
+@@ -33,6 +33,7 @@
+ */
+
+ #include <linux/dma-resv.h>
++#include <linux/dma-fence-array.h>
+ #include <linux/export.h>
+ #include <linux/mm.h>
+ #include <linux/sched/mm.h>
+@@ -517,6 +518,64 @@ int dma_resv_get_fences_rcu(struct dma_resv *obj,
+ }
+ EXPORT_SYMBOL_GPL(dma_resv_get_fences_rcu);
+
++/**
++ * dma_resv_get_singleton - Get a single fence for all the fences
++ * @obj: the reservation object
++ * @write: true if we should return all fences
++ * @fence: the resulting fence
++ *
++ * Get a single fence representing all the fences inside the resv object.
++ * Returns either 0 for success or -ENOMEM.
++ *
++ * Warning: This can't be used like this when adding the fence back to the resv
++ * object since that can lead to stack corruption when finalizing the
++ * dma_fence_array.
++ *
++ * Returns 0 on success and negative error values on failure.
++ */
++int dma_resv_get_singleton(struct dma_resv *obj, bool write,
++ struct dma_fence **fence)
++{
++ struct dma_fence_array *array;
++ struct dma_fence **fences;
++ unsigned count;
++ int r;
++
++ if (!write) {
++ *fence = dma_resv_get_excl_rcu(obj);
++ return 0;
++ }
++
++ r = dma_resv_get_fences_rcu(obj, NULL, &count, &fences);
++ if (r)
++ return r;
++
++ if (count == 0) {
++ *fence = NULL;
++ return 0;
++ }
++
++ if (count == 1) {
++ *fence = fences[0];
++ kfree(fences);
++ return 0;
++ }
++
++ array = dma_fence_array_create(count, fences,
++ dma_fence_context_alloc(1),
++ 1, false);
++ if (!array) {
++ while (count--)
++ dma_fence_put(fences[count]);
++ kfree(fences);
++ return -ENOMEM;
++ }
++
++ *fence = &array->base;
++ return 0;
++}
++EXPORT_SYMBOL_GPL(dma_resv_get_singleton);
++
+ /**
+ * dma_resv_wait_timeout_rcu - Wait on reservation's objects
+ * shared and/or exclusive fences.
+diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
+index d44a77e8a7e3..171ff5e7ff88 100644
+--- a/include/linux/dma-resv.h
++++ b/include/linux/dma-resv.h
+@@ -283,6 +283,8 @@ int dma_resv_get_fences_rcu(struct dma_resv *obj,
+ unsigned *pshared_count,
+ struct dma_fence ***pshared);
+
++int dma_resv_get_singleton(struct dma_resv *obj, bool write,
++ struct dma_fence **fence);
+ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
+
+ long dma_resv_wait_timeout_rcu(struct dma_resv *obj, bool wait_all, bool intr,
+--
+2.38.1
+
diff --git a/0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch b/0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch
new file mode 100644
index 000000000000..e2705d388d51
--- /dev/null
+++ b/0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch
@@ -0,0 +1,264 @@
+From e2efe6b72f4ceb3511dcd847a172d47d59ce2ed1 Mon Sep 17 00:00:00 2001
+From: Jason Ekstrand <jason@jlekstrand.net>
+Date: Wed, 8 Jun 2022 10:21:41 -0500
+Subject: [PATCH 2/5] dma-buf: Add an API for exporting sync files (v14)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Modern userspace APIs like Vulkan are built on an explicit
+synchronization model. This doesn't always play nicely with the
+implicit synchronization used in the kernel and assumed by X11 and
+Wayland. The client -> compositor half of the synchronization isn't too
+bad, at least on intel, because we can control whether or not i915
+synchronizes on the buffer and whether or not it's considered written.
+
+The harder part is the compositor -> client synchronization when we get
+the buffer back from the compositor. We're required to be able to
+provide the client with a VkSemaphore and VkFence representing the point
+in time where the window system (compositor and/or display) finished
+using the buffer. With current APIs, it's very hard to do this in such
+a way that we don't get confused by the Vulkan driver's access of the
+buffer. In particular, once we tell the kernel that we're rendering to
+the buffer again, any CPU waits on the buffer or GPU dependencies will
+wait on some of the client rendering and not just the compositor.
+
+This new IOCTL solves this problem by allowing us to get a snapshot of
+the implicit synchronization state of a given dma-buf in the form of a
+sync file. It's effectively the same as a poll() or I915_GEM_WAIT only,
+instead of CPU waiting directly, it encapsulates the wait operation, at
+the current moment in time, in a sync_file so we can check/wait on it
+later. As long as the Vulkan driver does the sync_file export from the
+dma-buf before we re-introduce it for rendering, it will only contain
+fences from the compositor or display. This allows to accurately turn
+it into a VkFence or VkSemaphore without any over-synchronization.
+
+By making this an ioctl on the dma-buf itself, it allows this new
+functionality to be used in an entirely driver-agnostic way without
+having access to a DRM fd. This makes it ideal for use in driver-generic
+code in Mesa or in a client such as a compositor where the DRM fd may be
+hard to reach.
+
+v2 (Jason Ekstrand):
+ - Use a wrapper dma_fence_array of all fences including the new one
+ when importing an exclusive fence.
+
+v3 (Jason Ekstrand):
+ - Lock around setting shared fences as well as exclusive
+ - Mark SIGNAL_SYNC_FILE as a read-write ioctl.
+ - Initialize ret to 0 in dma_buf_wait_sync_file
+
+v4 (Jason Ekstrand):
+ - Use the new dma_resv_get_singleton helper
+
+v5 (Jason Ekstrand):
+ - Rename the IOCTLs to import/export rather than wait/signal
+ - Drop the WRITE flag and always get/set the exclusive fence
+
+v6 (Jason Ekstrand):
+ - Drop the sync_file import as it was all-around sketchy and not nearly
+ as useful as import.
+ - Re-introduce READ/WRITE flag support for export
+ - Rework the commit message
+
+v7 (Jason Ekstrand):
+ - Require at least one sync flag
+ - Fix a refcounting bug: dma_resv_get_excl() doesn't take a reference
+ - Use _rcu helpers since we're accessing the dma_resv read-only
+
+v8 (Jason Ekstrand):
+ - Return -ENOMEM if the sync_file_create fails
+ - Predicate support on IS_ENABLED(CONFIG_SYNC_FILE)
+
+v9 (Jason Ekstrand):
+ - Add documentation for the new ioctl
+
+v10 (Jason Ekstrand):
+ - Go back to dma_buf_sync_file as the ioctl struct name
+
+v11 (Daniel Vetter):
+ - Go back to dma_buf_export_sync_file as the ioctl struct name
+ - Better kerneldoc describing what the read/write flags do
+
+v12 (Christian König):
+ - Document why we chose to make it an ioctl on dma-buf
+
+v13 (Jason Ekstrand):
+ - Rebase on Christian König's fence rework
+
+v14 (Daniel Vetter & Christian König):
+ - Use dma_rev_usage_rw to get the properly inverted usage to pass to
+ dma_resv_get_singleton()
+ - Clean up the sync_file and fd if copy_to_user() fails
+
+Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
+Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
+Signed-off-by: Jason Ekstrand <jason.ekstrand@collabora.com>
+Acked-by: Simon Ser <contact@emersion.fr>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Cc: Sumit Semwal <sumit.semwal@linaro.org>
+Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
+Signed-off-by: Simon Ser <contact@emersion.fr>
+Link: https://patchwork.freedesktop.org/patch/msgid/20220608152142.14495-2-jason@jlekstrand.net
+(cherry picked from commit 20e10881a043af63f2962a9e6bca64661225b383)
+---
+ drivers/dma-buf/dma-buf.c | 67 ++++++++++++++++++++++++++++++++++++
+ include/uapi/linux/dma-buf.h | 35 +++++++++++++++++++
+ 2 files changed, 102 insertions(+)
+
+diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
+index 023f34ed98af..437f3620dce8 100644
+--- a/drivers/dma-buf/dma-buf.c
++++ b/drivers/dma-buf/dma-buf.c
+@@ -20,6 +20,7 @@
+ #include <linux/debugfs.h>
+ #include <linux/module.h>
+ #include <linux/seq_file.h>
++#include <linux/sync_file.h>
+ #include <linux/poll.h>
+ #include <linux/dma-resv.h>
+ #include <linux/mm.h>
+@@ -266,6 +267,9 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
+ * Note that this only signals the completion of the respective fences, i.e. the
+ * DMA transfers are complete. Cache flushing and any other necessary
+ * preparations before CPU access can begin still need to happen.
++ *
++ * As an alternative to poll(), the set of fences on DMA buffer can be
++ * exported as a &sync_file using &dma_buf_sync_file_export.
+ */
+
+ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
+@@ -463,6 +467,64 @@ static long dma_buf_set_name_user(struct dma_buf *dmabuf, const char __user *buf
+ return ret;
+ }
+
++#if IS_ENABLED(CONFIG_SYNC_FILE)
++static long dma_buf_export_sync_file(struct dma_buf *dmabuf,
++ void __user *user_data)
++{
++ struct dma_buf_export_sync_file arg;
++ struct dma_fence *fence = NULL;
++ struct sync_file *sync_file;
++ bool write;
++ int fd, ret;
++
++ if (copy_from_user(&arg, user_data, sizeof(arg)))
++ return -EFAULT;
++
++ if (arg.flags & ~DMA_BUF_SYNC_RW)
++ return -EINVAL;
++
++ if ((arg.flags & DMA_BUF_SYNC_RW) == 0)
++ return -EINVAL;
++
++ fd = get_unused_fd_flags(O_CLOEXEC);
++ if (fd < 0)
++ return fd;
++
++ write = (arg.flags & DMA_BUF_SYNC_WRITE);
++ ret = dma_resv_get_singleton(dmabuf->resv, write, &fence);
++ if (ret)
++ goto err_put_fd;
++
++ if (!fence)
++ fence = dma_fence_get_stub();
++
++ sync_file = sync_file_create(fence);
++
++ dma_fence_put(fence);
++
++ if (!sync_file) {
++ ret = -ENOMEM;
++ goto err_put_fd;
++ }
++
++ arg.fd = fd;
++ if (copy_to_user(user_data, &arg, sizeof(arg))) {
++ ret = -EFAULT;
++ goto err_put_file;
++ }
++
++ fd_install(fd, sync_file->file);
++
++ return 0;
++
++err_put_file:
++ fput(sync_file->file);
++err_put_fd:
++ put_unused_fd(fd);
++ return ret;
++}
++#endif
++
+ static long dma_buf_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
+ {
+@@ -545,6 +607,11 @@ static long dma_buf_ioctl(struct file *file,
+
+ return ret;
+
++#if IS_ENABLED(CONFIG_SYNC_FILE)
++ case DMA_BUF_IOCTL_EXPORT_SYNC_FILE:
++ return dma_buf_export_sync_file(dmabuf, (void __user *)arg);
++#endif
++
+ default:
+ return -ENOTTY;
+ }
+diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
+index 6236c644624d..522bcee5498e 100644
+--- a/include/uapi/linux/dma-buf.h
++++ b/include/uapi/linux/dma-buf.h
+@@ -37,6 +37,40 @@ struct dma_buf_sync {
+
+ #define DMA_BUF_NAME_LEN 32
+
++/**
++ * struct dma_buf_export_sync_file - Get a sync_file from a dma-buf
++ *
++ * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the
++ * current set of fences on a dma-buf file descriptor as a sync_file. CPU
++ * waits via poll() or other driver-specific mechanisms typically wait on
++ * whatever fences are on the dma-buf at the time the wait begins. This
++ * is similar except that it takes a snapshot of the current fences on the
++ * dma-buf for waiting later instead of waiting immediately. This is
++ * useful for modern graphics APIs such as Vulkan which assume an explicit
++ * synchronization model but still need to inter-operate with dma-buf.
++ */
++struct dma_buf_export_sync_file {
++ /**
++ * @flags: Read/write flags
++ *
++ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
++ *
++ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
++ * the returned sync file waits on any writers of the dma-buf to
++ * complete. Waiting on the returned sync file is equivalent to
++ * poll() with POLLIN.
++ *
++ * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on
++ * any users of the dma-buf (read or write) to complete. Waiting
++ * on the returned sync file is equivalent to poll() with POLLOUT.
++ * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this
++ * is equivalent to just DMA_BUF_SYNC_WRITE.
++ */
++ __u32 flags;
++ /** @fd: Returned sync file descriptor */
++ __s32 fd;
++};
++
+ #define DMA_BUF_BASE 'b'
+ #define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+
+@@ -46,6 +80,7 @@ struct dma_buf_sync {
+ #define DMA_BUF_SET_NAME _IOW(DMA_BUF_BASE, 1, const char *)
+ #define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, u32)
+ #define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, u64)
++#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
+
+ struct dma_buf_sync_partial {
+ __u64 flags;
+--
+2.38.1
+
diff --git a/0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch b/0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch
new file mode 100644
index 000000000000..52a6a38672dc
--- /dev/null
+++ b/0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch
@@ -0,0 +1,248 @@
+From 520309591712f72a36f87d086f005e9f2c21f388 Mon Sep 17 00:00:00 2001
+From: Jason Ekstrand <jason@jlekstrand.net>
+Date: Wed, 8 Jun 2022 10:21:42 -0500
+Subject: [PATCH 3/5] dma-buf: Add an API for importing sync files (v10)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This patch is analogous to the previous sync file export patch in that
+it allows you to import a sync_file into a dma-buf. Unlike the previous
+patch, however, this does add genuinely new functionality to dma-buf.
+Without this, the only way to attach a sync_file to a dma-buf is to
+submit a batch to your driver of choice which waits on the sync_file and
+claims to write to the dma-buf. Even if said batch is a no-op, a submit
+is typically way more overhead than just attaching a fence. A submit
+may also imply extra synchronization with other work because it happens
+on a hardware queue.
+
+In the Vulkan world, this is useful for dealing with the out-fence from
+vkQueuePresent. Current Linux window-systems (X11, Wayland, etc.) all
+rely on dma-buf implicit sync. Since Vulkan is an explicit sync API, we
+get a set of fences (VkSemaphores) in vkQueuePresent and have to stash
+those as an exclusive (write) fence on the dma-buf. We handle it in
+Mesa today with the above mentioned dummy submit trick. This ioctl
+would allow us to set it directly without the dummy submit.
+
+This may also open up possibilities for GPU drivers to move away from
+implicit sync for their kernel driver uAPI and instead provide sync
+files and rely on dma-buf import/export for communicating with other
+implicit sync clients.
+
+We make the explicit choice here to only allow setting RW fences which
+translates to an exclusive fence on the dma_resv. There's no use for
+read-only fences for communicating with other implicit sync userspace
+and any such attempts are likely to be racy at best. When we got to
+insert the RW fence, the actual fence we set as the new exclusive fence
+is a combination of the sync_file provided by the user and all the other
+fences on the dma_resv. This ensures that the newly added exclusive
+fence will never signal before the old one would have and ensures that
+we don't break any dma_resv contracts. We require userspace to specify
+RW in the flags for symmetry with the export ioctl and in case we ever
+want to support read fences in the future.
+
+There is one downside here that's worth documenting: If two clients
+writing to the same dma-buf using this API race with each other, their
+actions on the dma-buf may happen in parallel or in an undefined order.
+Both with and without this API, the pattern is the same: Collect all
+the fences on dma-buf, submit work which depends on said fences, and
+then set a new exclusive (write) fence on the dma-buf which depends on
+said work. The difference is that, when it's all handled by the GPU
+driver's submit ioctl, the three operations happen atomically under the
+dma_resv lock. If two userspace submits race, one will happen before
+the other. You aren't guaranteed which but you are guaranteed that
+they're strictly ordered. If userspace manages the fences itself, then
+these three operations happen separately and the two render operations
+may happen genuinely in parallel or get interleaved. However, this is a
+case of userspace racing with itself. As long as we ensure userspace
+can't back the kernel into a corner, it should be fine.
+
+v2 (Jason Ekstrand):
+ - Use a wrapper dma_fence_array of all fences including the new one
+ when importing an exclusive fence.
+
+v3 (Jason Ekstrand):
+ - Lock around setting shared fences as well as exclusive
+ - Mark SIGNAL_SYNC_FILE as a read-write ioctl.
+ - Initialize ret to 0 in dma_buf_wait_sync_file
+
+v4 (Jason Ekstrand):
+ - Use the new dma_resv_get_singleton helper
+
+v5 (Jason Ekstrand):
+ - Rename the IOCTLs to import/export rather than wait/signal
+ - Drop the WRITE flag and always get/set the exclusive fence
+
+v6 (Jason Ekstrand):
+ - Split import and export into separate patches
+ - New commit message
+
+v7 (Daniel Vetter):
+ - Fix the uapi header to use the right struct in the ioctl
+ - Use a separate dma_buf_import_sync_file struct
+ - Add kerneldoc for dma_buf_import_sync_file
+
+v8 (Jason Ekstrand):
+ - Rebase on Christian König's fence rework
+
+v9 (Daniel Vetter):
+ - Fix -EINVAL checks for the flags parameter
+ - Add documentation about read/write fences
+ - Add documentation about the expected usage of import/export and
+ specifically call out the possible userspace race.
+
+v10 (Simon Ser):
+ - Fix a typo in the docs
+
+Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
+Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
+Signed-off-by: Jason Ekstrand <jason.ekstrand@collabora.com>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Cc: Sumit Semwal <sumit.semwal@linaro.org>
+Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
+Signed-off-by: Simon Ser <contact@emersion.fr>
+Link: https://patchwork.freedesktop.org/patch/msgid/20220608152142.14495-3-jason@jlekstrand.net
+(cherry picked from commit 594740497e998d30477ab26093bfb81c28cd3ff1)
+---
+ drivers/dma-buf/dma-buf.c | 42 +++++++++++++++++++++++++++++++
+ include/uapi/linux/dma-buf.h | 49 ++++++++++++++++++++++++++++++++++++
+ 2 files changed, 91 insertions(+)
+
+diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
+index 437f3620dce8..41ebb645efda 100644
+--- a/drivers/dma-buf/dma-buf.c
++++ b/drivers/dma-buf/dma-buf.c
+@@ -523,6 +523,46 @@ static long dma_buf_export_sync_file(struct dma_buf *dmabuf,
+ put_unused_fd(fd);
+ return ret;
+ }
++
++static long dma_buf_import_sync_file(struct dma_buf *dmabuf,
++ const void __user *user_data)
++{
++ struct dma_buf_import_sync_file arg;
++ struct dma_fence *fence;
++ bool write;
++ int ret = 0;
++
++ if (copy_from_user(&arg, user_data, sizeof(arg)))
++ return -EFAULT;
++
++ if (arg.flags & ~DMA_BUF_SYNC_RW)
++ return -EINVAL;
++
++ if ((arg.flags & DMA_BUF_SYNC_RW) == 0)
++ return -EINVAL;
++
++ fence = sync_file_get_fence(arg.fd);
++ if (!fence)
++ return -EINVAL;
++
++ write = (arg.flags & DMA_BUF_SYNC_WRITE);
++
++ dma_resv_lock(dmabuf->resv, NULL);
++
++ if (write) {
++ dma_resv_add_excl_fence(dmabuf->resv, fence);
++ } else {
++ ret = dma_resv_reserve_shared(dmabuf->resv, 1);
++ if (!ret)
++ dma_resv_add_shared_fence(dmabuf->resv, fence);
++ }
++
++ dma_resv_unlock(dmabuf->resv);
++
++ dma_fence_put(fence);
++
++ return ret;
++}
+ #endif
+
+ static long dma_buf_ioctl(struct file *file,
+@@ -610,6 +650,8 @@ static long dma_buf_ioctl(struct file *file,
+ #if IS_ENABLED(CONFIG_SYNC_FILE)
+ case DMA_BUF_IOCTL_EXPORT_SYNC_FILE:
+ return dma_buf_export_sync_file(dmabuf, (void __user *)arg);
++ case DMA_BUF_IOCTL_IMPORT_SYNC_FILE:
++ return dma_buf_import_sync_file(dmabuf, (const void __user *)arg);
+ #endif
+
+ default:
+diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
+index 522bcee5498e..b4ceeaedfa87 100644
+--- a/include/uapi/linux/dma-buf.h
++++ b/include/uapi/linux/dma-buf.h
+@@ -48,6 +48,24 @@ struct dma_buf_sync {
+ * dma-buf for waiting later instead of waiting immediately. This is
+ * useful for modern graphics APIs such as Vulkan which assume an explicit
+ * synchronization model but still need to inter-operate with dma-buf.
++ *
++ * The intended usage pattern is the following:
++ *
++ * 1. Export a sync_file with flags corresponding to the expected GPU usage
++ * via DMA_BUF_IOCTL_EXPORT_SYNC_FILE.
++ *
++ * 2. Submit rendering work which uses the dma-buf. The work should wait on
++ * the exported sync file before rendering and produce another sync_file
++ * when complete.
++ *
++ * 3. Import the rendering-complete sync_file into the dma-buf with flags
++ * corresponding to the GPU usage via DMA_BUF_IOCTL_IMPORT_SYNC_FILE.
++ *
++ * Unlike doing implicit synchronization via a GPU kernel driver's exec ioctl,
++ * the above is not a single atomic operation. If userspace wants to ensure
++ * ordering via these fences, it is the respnosibility of userspace to use
++ * locks or other mechanisms to ensure that no other context adds fences or
++ * submits work between steps 1 and 3 above.
+ */
+ struct dma_buf_export_sync_file {
+ /**
+@@ -71,6 +89,36 @@ struct dma_buf_export_sync_file {
+ __s32 fd;
+ };
+
++/**
++ * struct dma_buf_import_sync_file - Insert a sync_file into a dma-buf
++ *
++ * Userspace can perform a DMA_BUF_IOCTL_IMPORT_SYNC_FILE to insert a
++ * sync_file into a dma-buf for the purposes of implicit synchronization
++ * with other dma-buf consumers. This allows clients using explicitly
++ * synchronized APIs such as Vulkan to inter-op with dma-buf consumers
++ * which expect implicit synchronization such as OpenGL or most media
++ * drivers/video.
++ */
++struct dma_buf_import_sync_file {
++ /**
++ * @flags: Read/write flags
++ *
++ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
++ *
++ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
++ * this inserts the sync_file as a read-only fence. Any subsequent
++ * implicitly synchronized writes to this dma-buf will wait on this
++ * fence but reads will not.
++ *
++ * If DMA_BUF_SYNC_WRITE is set, this inserts the sync_file as a
++ * write fence. All subsequent implicitly synchronized access to
++ * this dma-buf will wait on this fence.
++ */
++ __u32 flags;
++ /** @fd: Sync file descriptor */
++ __s32 fd;
++};
++
+ #define DMA_BUF_BASE 'b'
+ #define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+
+@@ -81,6 +129,7 @@ struct dma_buf_export_sync_file {
+ #define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, u32)
+ #define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, u64)
+ #define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
++#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file)
+
+ struct dma_buf_sync_partial {
+ __u64 flags;
+--
+2.38.1
+
diff --git a/0024-MALI-bifrost-avoid-fence-double-free.patch b/0024-MALI-bifrost-avoid-fence-double-free.patch
new file mode 100644
index 000000000000..2a47a7a1378a
--- /dev/null
+++ b/0024-MALI-bifrost-avoid-fence-double-free.patch
@@ -0,0 +1,26 @@
+From d1ce2f15fac0e7c3ee27d312016c5fce0608bcae Mon Sep 17 00:00:00 2001
+From: Icecream95 <ixn@disroot.org>
+Date: Tue, 6 Dec 2022 15:17:33 +1300
+Subject: [PATCH 8/9] MALI: bifrost: Avoid fence double-free
+
+Probably this corresponds to CVE-2022-42716.
+
+---
+ drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.c b/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.c
+index 6c43c029a324..715ccd62e375 100644
+--- a/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.c
++++ b/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.c
+@@ -1550,7 +1550,6 @@ static int kbase_kcpu_fence_signal_prepare(
+ dma_fence_put(fence_out);
+
+ current_command->info.fence.fence = NULL;
+- kfree(fence_out);
+
+ return ret;
+ }
+--
+2.38.1
+
diff --git a/0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch b/0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch
new file mode 100644
index 000000000000..7d106e8f3180
--- /dev/null
+++ b/0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch
@@ -0,0 +1,40 @@
+From 1a0e71a04479dbd6ef08f46b4911ddc64b47347d Mon Sep 17 00:00:00 2001
+From: Icecream95 <ixn@disroot.org>
+Date: Tue, 6 Dec 2022 16:52:06 +1300
+Subject: [PATCH 5/5] drm/rockchip: Re-add implicit fencing support for planes
+
+Similar to 63d5e06aa381 ("drm/rockchip: Add implicit fencing support
+for planes") but after the code was removed and VOP2 was added in the
+downstream kernel.
+
+Note that upstream VOP2 does not have this line as it was added since
+29a840842743 ("drm/<driver>: drm_gem_plane_helper_prepare_fb is now
+the default") removed the need.
+
+---
+ drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+index df4a3291d3da..f9675d9320d4 100644
+--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
++++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+@@ -10,6 +10,7 @@
+ #include <drm/drm_crtc_helper.h>
+ #include <drm/drm_debugfs.h>
+ #include <drm/drm_flip_work.h>
++#include <drm/drm_gem_framebuffer_helper.h>
+ #include <drm/drm_fourcc.h>
+ #include <drm/drm_plane_helper.h>
+ #include <drm/drm_probe_helper.h>
+@@ -4622,6 +4623,7 @@ static const struct drm_plane_helper_funcs vop2_plane_helper_funcs = {
+ .atomic_check = vop2_plane_atomic_check,
+ .atomic_update = vop2_plane_atomic_update,
+ .atomic_disable = vop2_plane_atomic_disable,
++ .prepare_fb = drm_gem_fb_prepare_fb,
+ };
+
+ /**
+--
+2.38.1
+
diff --git a/0026-Enable_AV1_decoder_on_3588.patch b/0026-Enable_AV1_decoder_on_3588.patch
new file mode 100644
index 000000000000..245227f41797
--- /dev/null
+++ b/0026-Enable_AV1_decoder_on_3588.patch
@@ -0,0 +1,20 @@
+--- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi 2023-01-13 10:37:34.000000000 +0100
++++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi.new 2023-01-19 23:52:47.348912968 +0100
+@@ -3449,7 +3449,7 @@
+ rockchip,srv = <&mpp_srv>;
+ rockchip,taskqueue-node = <11>;
+ power-domains = <&power RK3588_PD_AV1>;
+- status = "disabled";
++ status = "okay";
+ };
+
+ av1d_mmu: iommu@fdca0000 {
+@@ -3461,7 +3461,7 @@
+ clock-names = "aclk", "iface";
+ #iommu-cells = <0>;
+ power-domains = <&power RK3588_PD_AV1>;
+- status = "disabled";
++ status = "okay";
+ };
+
+ rkisp_unite: rkisp-unite@fdcb0000 {
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..54748f72f1c3
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,279 @@
+# AArch64 multi-platform
+# Maintainer: Mahmut Dikcizgi <boogiepop a~t gmx com>
+# Contributor: Kevin Mihelich <kevin@archlinuxarm.org>
+
+buildarch=8
+_pkgver=5.10
+_user="radxa"
+_kernel=linux-radxa-rkbsp5
+pkgbase=$_kernel-git
+pkgname=("${_kernel}-headers" $_kernel)
+pkgver=$_pkgver
+pkgrel=1
+arch=('aarch64')
+license=('GPL2')
+url="https://github.com/${_user}"
+_kernelrepo="kernel"
+_overlayrepo="overlays"
+_kernelbranch=linux-5.10-gen-rkr3.4
+_overlaybranch=main
+_desc="Radxa fork of Linux 5.10 which is based on the fork of Rockchip BSP.
+Minimum supported boards:
+RK3399 based rock4[a/b/c/se/io/se] boards
+RK3588 based rock5[a/b/nx] modules boards
+It is possible to make other RK3588 and RK3399 board with few DTS adapdations"
+
+makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'git' 'uboot-tools' 'vboot-utils' 'dtc')
+options=('!strip')
+
+# Patch1-19 comes from Radxa: https://github.com/radxa-repo/bsp/tree/main/linux/rockchip
+# Patch20: Warning Supressions for buildsystem not to quit including DistCC builds
+# Patch21-25: icecream95's mesa speed patches from kernel 6.x https://gitlab.com/panfork/rk3588-implicit-sync
+# Patch22: Force Enabling AV1 decoder in 3588. This may be implemented in radxa git as well soon
+source=(git+https://github.com/$_user/$_kernelrepo.git#branch=$_kernelbranch
+ git+https://github.com/$_user/$_overlayrepo.git#branch=$_overlaybranch
+ 'linux.preset'
+ 'extlinux.arch.template'
+ '0001-mm-page_alloc-fix-building-error-on-Werror-array-com.patch'
+ '0002-etherdevice-Adjust-ether_addr-prototypes-to-silence-.patch'
+ '0003-drm-rockchip-vop-Use-clipped-src-dst-coordinates.patch'
+ '0004-Update-existing-ROCK-4-OPP-settings.patch'
+ '0005-Add-additional-ROCK-4-products.patch'
+ '0006-Enable-DMC-for-ROCK-4.patch'
+ '0007-Fix-ROCK-4-OTG-switch.patch'
+ '0008-Add-pwm-fan-for-ROCK-4C.patch'
+ '0009-VENDOR-Add-Radxa-overlays.patch'
+ '0010-Fix-dangling-pointer-compiler-bug.patch'
+ '0011-Disable-tristate-for-non-modules.patch'
+ '0012-Disable-tristate-for-modules-that-uses-unexported-sy.patch'
+ '0013-Disable-tristate-for-builtin-dependencies.patch'
+ '0014-Revert-dma-buf-sw_sync-build-sw-sync-as-module-for-g.patch'
+ '0015-Disable-tristate-for-essential-boot-services.patch'
+ '0016-Revert-ANDROID-clk-Enable-writable-debugfs-files.patch'
+ '0017-Modfy-GPU-node-for-Panfrost-driver.patch'
+ '0018-VENDOR-Version-tagging-linux-libc-dev-as-well.patch'
+ '0019-Add-ROCK-4-Core-IO-Board-Fuhai.patch'
+ '0020-gcc-ignore-stringop-overread-warnings.patch'
+ '0021-dma-buf-add-dma_resv_get_singleton-v2.patch'
+ '0022-dma-buf-Add-an-API-for-exporting-sync-files-v14.patch'
+ '0023-dma-buf-Add-an-API-for-importing-sync-files-v10.patch'
+ '0024-MALI-bifrost-avoid-fence-double-free.patch'
+ '0025-drm-rockchip-Re-add-implicit-fencing-support-for-pla.patch'
+ '0026-Enable_AV1_decoder_on_3588.patch')
+b2sums=('SKIP'
+ 'SKIP'
+ 'b5ebfe78b703b7d5ea31be16513ff4e91d0ca7f13657c6d09ff92ef4f1566bf501a4b536b7f48791055d0b327724ada23a3f5a34247c5effe3fe2ff7e1acd8eb'
+ 'd8208257c8f2e23a9dbcf2a1bbd11b5a638679cd49dd03d4ea190d1ecd94e2760cccb2cd1cda890816a9c338ce2f38c859961f4ab3a22fca458a453ca0d5f2fc'
+ '74b6d76888267785ac99e58bdb852c667865d44353821c01052734d58e1213c16290aabff7ae6c95ac6b24893fe5109897f949d814ccec55cc69af9885fc62f6'
+ '461eb48692574f48d37a9a236b3a17992493cf07a39ab72f78fa0ac4f04e3ff9896f16e721c111f865d9aa3d3f0d7b7c082fe2f319eee0e1a6c54db44f0a6e53'
+ '2703d12281e60e2b9f057bbb3ac28e190f77c4ad8cfccc6f1a316b9bc6434e7ca296221eeb8992134c2d365a5afea7b7adf1d9516e3c89c3fc03f0941f65e5c2'
+ '376e54c72261c803d40e3ddca06e39b72c85fe4d8743e79cac1c8ced3feb953760471a6784cc4922b0bcf00004f9b2a9407094b6075883c5ce82786ff357cb3b'
+ 'c09942deeead81798f47e07f72e6b8748e8b44682d72a1bd0d50e7c9f20e9ae8243c248a234ecc1f48112c40d2690c5ab171fdc9ba55101f4cc5294888c9f49b'
+ '6277d3f4e43eb20b735e8ef933f4e9fccc5077484f2c7051b7f47bfae77ffce13387199650cc90adf14d4dc941bb376d9e52d48bab37412afe9437e5d081a130'
+ '4d42cee746b74a2f2982187a568b939cc1d3f3e3bc18472fea0ce9eb27d658170f434a14526e339fb36d2936a7a17b59a699a4c351152a56f8ab7743e670c05a'
+ '53b3d818d3d8bdcebe5bf1b25f6196615fe605f4d9f282d0f2effa44bd1480241b0d4e5eedfbc34fa27e2ce90ee634799e3aefad1bd701c250c502e4b2178d71'
+ '4908b5a94c02a4eb0fe8bb9983289f1b8acbb1b8ebb541643c7ec4ac5de87be949efbdec839d34603b045500b13033f836385bdbf3e935fcd8d221f71028d604'
+ 'e612cf028aaf8f99c2735a6e1640170af51e62aa86a8cc795694ac089b2f31be93e67c6ee394cd22d290a787cd9f064861b0bb173033069710881280432ad45f'
+ 'bde631de66dde60339c7fa306b06a9100ac41adaeb16788c800157324a288a97629c41dda5076698c1ef71b8b7f44b5eba619b6aac92d0d5c59e796fb2aa407a'
+ '1836fb5f211c4feb279de7d241799ff483eb6d4728cdba74ad44c8808a5d5be0077c53a315ae4f6d16f157156f5d6d00a5428a857f4164659e7a2feb584f5ec9'
+ '16b725f25bc150675888dcc03125cd285f2c73f7955d90d521af9a139d717836afab07a995f7018e19cdad41964061800503e40e32656ee54bf69c22e8c8a53f'
+ '8a6c96251c48048ff653285646347853d5df5264d1bf0bf798a48d3636480263125f92c5cb21f7d4b4988b6d831636d34de1b882c0209110178117e3ea1a0630'
+ 'f5ab48ee96b6df65ec20742e5bb2badffa7ed926f5020d64bdcfe1fe924fff9cafdb70c7983084f4294ab5663c5b56eeb51e96df176253175e9bde52121c3164'
+ '1bf65b95368a4134086b03598943f6d4025fefec436e170b95fa8478523755187c427ab038ae3fe3aef319c6a266e58c1d360575fd08720dd60957578054fa28'
+ 'd7c4496318bd3fc5294af88bcdeafa49b04683d1e1fe7312b0317872fdecb929ef8e62b86332e87eddd49c1f5e7ddb9a59372dcbf0514158f7d75947e81f7d8d'
+ '7dc970eebf837940c67ae61f809f9e0cc6ae9e2a033ca7975b2c4055190b23ddd190170e75949834d54818f08016743d66c6ede5175f6cf988bec2e6aa4f008d'
+ 'b3b9b04b0f73d07c1927c0def7e5cc991144a7e65a01dab4ec1b2dd01f092e001da3fc07e852ebefb1530509e25a99730217a9208b6a26b0333c288ca1151935'
+ '86010c037ed11f25de26f0e1a35109488b00af3ec11cceff979694c6730d6501cffa292798042ae6a60d839b438f6abf90b6ecc08ab0a4fa597d564493ab9c9b'
+ 'afe3cf59d21517ef62bb456b831c638dc54107258e4f4412b8ebab2fa871a26c2aab3c16bf6a39b692611540febf2c68b6dece570266fc5c0a7349ffc05da7d0'
+ 'f96570ec79e310c21c8f98a95e3775bde05133bf4db25413596791d96ee7142702ecd5f5e358df4d852cbab9f909a455d438277978ed9d4e0f2fd4a3d43df082'
+ '053bd95a861c9ee1cc8fa7a9af787d927c9110fffd2780c4972ce97ee2ade1ff567071158e89734b2352ac0c98aff82259c241baa0cee263919ec012c9ef9478'
+ 'ea47ec8ba687f3a82d790797bb772ef04dd0dd5ab64d7f2c674659068c0332374c49e0e58b9ae7768bc7c6bfb67830b96b74a981ed4639fc1a8ef9f1fea9acb5'
+ '4dccfcdd1f2e9c3ba556a0c15541b6e7522e12e0d3e0153937266026fe365f54ed45ab77f7e24397acc61c0a170803214ddc452d46f7659c57eba5b82107d7d2'
+ '7c61be00b97a8acb759c35f23969cdfb4e739a8c88fd147d2af4594fa14100a2da90b160e04b8632c3dca703ff2c1973138d7f765c5b9a7039c6aae7f0078d9a')
+
+pkgver(){
+ #gets the commit count of both repos + _pkgrel and sums them to calculate the revision number
+ cd overlays
+ local _ocommits="$(git rev-list --count HEAD)"
+ local _ocommit="$(git rev-parse --short HEAD)"
+ cd ../kernel
+ local _kcommits="$(git rev-list --count HEAD)"
+ local _kcommit="$(git rev-parse --short HEAD)"
+
+ local _revnum=$(($_kcommits + $_ocommits + $pkgrel))
+ local _version="${_pkgver}.${_revnum}.${_kcommit}.${_ocommit}"
+ echo $_version > pkgver
+ printf $_version
+}
+
+prepare() {
+ cd kernel
+ cp -rf ../overlays/arch .
+ # patch with radxa patches and dont care if they fail
+ for p in ../*.patch; do
+ echo "Patching with ${p}"
+ patch -p1 -N -i $p || true
+ done
+
+ # this is only for local builds so there is no need to integrity check
+ for p in ../../custom/*.patch; do
+ echo "Custom Patching with ${p}"
+ patch -p1 -N -i $p || true
+ done
+
+ if [ -f ../../custom/config ]; then
+ echo "Using User Specific Config"
+ cp -f ../../custom/config ./.config
+ else
+ cp -f arch/arm64/configs/rockchip_linux_defconfig ./.config
+ fi
+
+ # fix distcc build which does not support gcc plugins
+ sed -i 's/CONFIG_GCC_PLUGINS=y/CONFIG_GCC_PLUGINS=n/g' .config
+
+ # enable faster DMA transfer provided through patches 21-25
+ echo "\nCONFIG_SYNC_FILE=y" >> .config
+}
+
+build() {
+ cd kernel
+
+ local _version="$(<pkgver)"
+ _version="${_version/"$_pkgver"/}"
+ _version="${_version//\./-}"
+ sed -i "5s/.*/EXTRAVERSION = ${_version}/" Makefile
+ echo "-radxa-rkbsp" > .scmversion
+ # should result in kernelmaj.kernelmin.patchver-totalcommitnum-hashofkernel-hashofoverlays-radxa-rkbsp
+
+ make -j$(nproc) olddefconfig prepare
+ make -s kernelrelease > version
+ unset LDFLAGS
+ make -j$(nproc) ${MAKEFLAGS} Image modules
+ make -j$(nproc) ${MAKEFLAGS} DTC_FLAGS="-@" dtbs
+}
+
+_package-git() {
+ pkgdesc="The Linux Kernel and modules - ${_desc}"
+ depends=('coreutils' 'kmod' 'mkinitcpio>=0.7')
+ optdepends=('wireless-regdb: to set the correct wireless channels of your country')
+ provides=("linux=${pkgver}" "linux-rkbsp")
+ conflicts=('linux')
+ backup=("etc/mkinitcpio.d/${_kernel}.preset")
+
+ cd kernel
+
+ local _version="$(<version)"
+
+ # install dtbs
+ make INSTALL_DTBS_PATH="${pkgdir}/boot/dtbs/$_kernel" dtbs_install
+
+ # install extlinux template
+ install -Dm644 ../extlinux.arch.template "$pkgdir/boot/extlinux/extlinux.arch.template"
+
+ # install modules
+ make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
+
+ # copy kernel
+ install -Dm644 arch/arm64/boot/Image "$pkgdir/usr/lib/modules/$_version/vmlinuz"
+
+ # remove build and source links
+ rm "$pkgdir/usr/lib/modules/$_version"/{source,build}
+
+ # sed expression for following substitutions
+ local _subst="
+ s|%PKGBASE%|${_kernel}|g
+ s|%KERNVER%|${_version}|g
+ "
+
+ # used by mkinitcpio to name the kernel
+ echo "$_kernel" | install -Dm644 /dev/stdin "$pkgdir/usr/lib/modules/$_version/pkgbase"
+
+ # install mkinitcpio preset file
+ sed "$_subst" ../linux.preset |
+ install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$_kernel.preset"
+}
+
+_package-git-headers() {
+ pkgdesc="Header files and scripts for building modules for linux kernel - ${_desc}"
+ provides=("linux-headers=${pkgver}" "linux-rkbsp-headers")
+ conflicts=('linux-headers')
+
+ cd kernel
+ local _version="$(<version)"
+ local builddir="$pkgdir/usr/lib/modules/$_version/build"
+
+ echo "Installing build files..."
+ install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map version
+ install -Dt "$builddir/kernel" -m644 kernel/Makefile
+ install -Dt "$builddir/arch/arm64" -m644 arch/arm64/Makefile
+ cp -t "$builddir" -a scripts
+
+ # add xfs and shmem for aufs building
+ mkdir -p "$builddir"/{fs/xfs,mm}
+
+ echo "Installing headers..."
+ cp -t "$builddir" -a include
+ cp -t "$builddir/arch/arm64" -a arch/arm64/include
+ install -Dt "$builddir/arch/arm64/kernel" -m644 arch/arm64/kernel/asm-offsets.s
+ mkdir -p "$builddir/arch/arm"
+ cp -t "$builddir/arch/arm" -a arch/arm/include
+
+ install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
+ install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
+
+ # https://bugs.archlinux.org/task/13146
+ install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
+
+ # https://bugs.archlinux.org/task/20402
+ install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
+ install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
+ install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
+
+ # https://bugs.archlinux.org/task/71392
+ install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
+
+ echo "Installing KConfig files..."
+ find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
+
+ echo "Removing unneeded architectures..."
+ local arch
+ for arch in "$builddir"/arch/*/; do
+ [[ $arch = */arm64/ || $arch == */arm/ ]] && continue
+ echo "Removing $(basename "$arch")"
+ rm -r "$arch"
+ done
+
+ echo "Removing documentation..."
+ rm -r "$builddir/Documentation"
+
+ echo "Removing broken symlinks..."
+ find -L "$builddir" -type l -printf 'Removing %P\n' -delete
+
+ echo "Removing loose objects..."
+ find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
+
+ echo "Stripping build tools..."
+ local file
+ while read -rd '' file; do
+ case "$(file -bi "$file")" in
+ application/x-sharedlib\;*) # Libraries (.so)
+ strip -v $STRIP_SHARED "$file" ;;
+ application/x-archive\;*) # Libraries (.a)
+ strip -v $STRIP_STATIC "$file" ;;
+ application/x-executable\;*) # Binaries
+ strip -v $STRIP_BINARIES "$file" ;;
+ application/x-pie-executable\;*) # Relocatable binaries
+ strip -v $STRIP_SHARED "$file" ;;
+ esac
+ done < <(find "$builddir" -type f -perm -u+x ! -name -print0)
+
+ echo "Adding symlink..."
+ mkdir -p "$pkgdir/usr/src"
+ ln -sr "$builddir" "$pkgdir/usr/src/$_kernel"
+}
+
+for _p in ${pkgname[@]}; do
+ eval "package_${_p}() {
+ _package${_p#${_kernel}}
+ }"
+done \ No newline at end of file
diff --git a/extlinux.arch.template b/extlinux.arch.template
new file mode 100644
index 000000000000..0a540f869526
--- /dev/null
+++ b/extlinux.arch.template
@@ -0,0 +1,9 @@
+#timeout 10
+#menu title select kernel
+
+label Archlinux
+ kernel /vmlinuz-linux-radxa-rkbsp5
+ initrd /initramfs-linux-radxa-rkbsp5.img
+ devicetreedir /dtbs/linux-radxa-rkbsp5
+ fdtoverlays /dtbs/linux-radxa-rkbsp5/rockchip/overlays/rk3588-uart7-m2.dtbo
+ append root=UUID=CHANGEME earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=0 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M
diff --git a/linux.preset b/linux.preset
new file mode 100644
index 000000000000..ca3832faa636
--- /dev/null
+++ b/linux.preset
@@ -0,0 +1,10 @@
+# mkinitcpio preset file for the '%PKGBASE%' package
+
+ALL_config="/etc/mkinitcpio.conf"
+ALL_kver="%KERNVER%"
+
+PRESETS=('default')
+
+#default_config="/etc/mkinitcpio.conf"
+default_image="/boot/initramfs-%PKGBASE%.img"
+#default_options=""