diff --git a/README b/README
index 9672c6ab8d5b..97d06eaefd63 100644
--- a/README
+++ b/README
@@ -159,6 +159,11 @@ Notes:
 	compatible (see Rockchip Media Process Platform (MPP) and
 	downstream gstreamer-rockchip plugin for those kernels).
 
+  mesa backend
+	Use the variable RK_MESA_DRIVER to select which mesa backend to use
+	for mesa. By default it is set to either "panfrost" or "lima"
+	depending on SoC.
+
 U-Boot Environment:
 ------------------
 	In order to configure U-Boot to be able to store its environment into the
diff --git a/conf/machine/include/px30.inc b/conf/machine/include/px30.inc
index 8173cb19be2c..4918ee45d1ab 100644
--- a/conf/machine/include/px30.inc
+++ b/conf/machine/include/px30.inc
@@ -21,3 +21,4 @@ UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3288.inc b/conf/machine/include/rk3288.inc
index 06fda69a3eb7..0fccae7896aa 100644
--- a/conf/machine/include/rk3288.inc
+++ b/conf/machine/include/rk3288.inc
@@ -16,3 +16,4 @@ KERNEL_IMAGETYPE ?= "zImage"
 UBOOT_SUFFIX ?= "bin"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3328.inc b/conf/machine/include/rk3328.inc
index e6f810dcd2ca..cdc2e2df2703 100644
--- a/conf/machine/include/rk3328.inc
+++ b/conf/machine/include/rk3328.inc
@@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "lima"
diff --git a/conf/machine/include/rk3399.inc b/conf/machine/include/rk3399.inc
index cd1be49064ed..06326946f1e3 100644
--- a/conf/machine/include/rk3399.inc
+++ b/conf/machine/include/rk3399.inc
@@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3566.inc b/conf/machine/include/rk3566.inc
index 6386ec7eb51c..4d84bf8a11a2 100644
--- a/conf/machine/include/rk3566.inc
+++ b/conf/machine/include/rk3566.inc
@@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3568.inc b/conf/machine/include/rk3568.inc
index bcf9dd8b0f44..dedda3b8f47e 100644
--- a/conf/machine/include/rk3568.inc
+++ b/conf/machine/include/rk3568.inc
@@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
index 6ec344abae5b..5a085ab29ebc 100644
--- a/conf/machine/include/rk3588s.inc
+++ b/conf/machine/include/rk3588s.inc
@@ -23,3 +23,4 @@ TFA_PLATFORM = "rk3588"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/recipes-graphics/mesa/mesa.bbappend b/recipes-graphics/mesa/mesa.bbappend
index f22280754a14..9e9bf9afc4a0 100644
--- a/recipes-graphics/mesa/mesa.bbappend
+++ b/recipes-graphics/mesa/mesa.bbappend
@@ -1,9 +1,4 @@
-PACKAGECONFIG:append:rk3288 = " panfrost"
-PACKAGECONFIG:append:rk3328 = " lima"
-PACKAGECONFIG:append:rk3399 = " panfrost"
-PACKAGECONFIG:append:rk3566 = " panfrost"
-PACKAGECONFIG:append:rk3568 = " panfrost"
-PACKAGECONFIG:append:rk3588s = " panfrost"
-PACKAGECONFIG:append:px30 = " panfrost"
+PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'panfrost', 'panfrost', '', d)}"
+PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'lima', 'lima', '', d)}"
 
 RRECOMMENDS:mesa-megadriver:append:rk3588s = " linux-firmware-mali-csffw-arch108"
