Re: [PATCH V3] board: rockchip: add Powkiddy X55

2024-05-07 Thread Kever Yang



On 2024/5/3 05:40, Chris Morgan wrote:

From: Chris Morgan 

The Powkiddy X55 is a Rockchip RK3566 based handheld gaming device.
UART, ADC, eMMC, and SDMMC are tested to work in U-Boot and this
successfully boots mainline Linux.

Kernel commit:
e99adc97e21a ("arm64: dts: rockchip: Add Powkiddy X55")

Signed-off-by: Chris Morgan 
---

Changes since V2:
  - Refactored to use the upstream device tree from Linux.
  - Removed logic for handling the adc button and instead simply try to
boot from sdmmc0 as a valid target first.

---
  arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi |  9 +++
  arch/arm/mach-rockchip/rk3568/Kconfig|  6 ++
  board/powkiddy/x55/Kconfig   | 15 +
  board/powkiddy/x55/MAINTAINERS   |  7 +++
  board/powkiddy/x55/Makefile  |  6 ++
  board/powkiddy/x55/x55.c | 39 +
  configs/powkiddy-x55-rk3566_defconfig| 59 
  doc/board/rockchip/rockchip.rst  |  1 +
  include/configs/powkiddy-x55-rk3566.h| 12 
  9 files changed, 154 insertions(+)
  create mode 100644 arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
  create mode 100644 board/powkiddy/x55/Kconfig
  create mode 100644 board/powkiddy/x55/MAINTAINERS
  create mode 100644 board/powkiddy/x55/Makefile
  create mode 100644 board/powkiddy/x55/x55.c
  create mode 100644 configs/powkiddy-x55-rk3566_defconfig
  create mode 100644 include/configs/powkiddy-x55-rk3566.h

diff --git a/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi 
b/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
new file mode 100644
index 00..c440201ec7
--- /dev/null
+++ b/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   u-boot,spl-boot-order = , , 
+   };
+};
diff --git a/arch/arm/mach-rockchip/rk3568/Kconfig 
b/arch/arm/mach-rockchip/rk3568/Kconfig
index af537d912a..014ebf9f0b 100644
--- a/arch/arm/mach-rockchip/rk3568/Kconfig
+++ b/arch/arm/mach-rockchip/rk3568/Kconfig
@@ -22,6 +22,11 @@ config TARGET_ODROID_M1_RK3568
help
  Hardkernel ODROID-M1 single board computer with a RK3568B2 SoC.
  
+config TARGET_POWKIDDY_X55_RK3566

+   bool "Powkiddy X55"
+   help
+ Powkiddy X55 handheld gaming console with an RK3566 SoC.
+
  config TARGET_QUARTZ64_RK3566
bool "Pine64 Quartz64"
help
@@ -48,5 +53,6 @@ source "board/rockchip/evb_rk3568/Kconfig"
  source "board/anbernic/rgxx3_rk3566/Kconfig"
  source "board/hardkernel/odroid_m1/Kconfig"
  source "board/pine64/quartz64_rk3566/Kconfig"
+source "board/powkiddy/x55/Kconfig"
  
  endif

diff --git a/board/powkiddy/x55/Kconfig b/board/powkiddy/x55/Kconfig
new file mode 100644
index 00..a7b3ed4d0d
--- /dev/null
+++ b/board/powkiddy/x55/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_POWKIDDY_X55_RK3566
+
+config SYS_BOARD
+   default "x55"
+
+config SYS_VENDOR
+   default "powkiddy"
+
+config SYS_CONFIG_NAME
+   default "powkiddy-x55-rk3566"
+
+config BOARD_SPECIFIC_OPTIONS
+   def_bool y
+
+endif
diff --git a/board/powkiddy/x55/MAINTAINERS b/board/powkiddy/x55/MAINTAINERS
new file mode 100644
index 00..01ae8da19d
--- /dev/null
+++ b/board/powkiddy/x55/MAINTAINERS
@@ -0,0 +1,7 @@
+X55
+M: Chris Morgan 
+S: Maintained
+F: board/powkiddy/x55
+F: include/configs/powkiddy-x55-rk3566.h
+F: configs/powkiddy-x55-rk3566_defconfig
+F: arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
diff --git a/board/powkiddy/x55/Makefile b/board/powkiddy/x55/Makefile
new file mode 100644
index 00..55c8c16aa1
--- /dev/null
+++ b/board/powkiddy/x55/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2023 Chris Morgan 
+#
+
+obj-y += x55.o
diff --git a/board/powkiddy/x55/x55.c b/board/powkiddy/x55/x55.c
new file mode 100644
index 00..b2703e6382
--- /dev/null
+++ b/board/powkiddy/x55/x55.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Chris Morgan 
+ */
+
+#include 
+
+#define GPIO4_BASE 0xfe77
+#define GPIO_SWPORT_DR_L   0x
+#define GPIO_SWPORT_DDR_L  0x0008
+#define GPIO_B4BIT(12)
+#define GPIO_B5BIT(13)
+#define GPIO_B6BIT(14)
+
+#define GPIO_WRITEMASK(bits)   ((bits) << 16)
+
+/*
+ * Start LED very early so user knows device is on. Set color
+ * to red.
+ */
+void spl_board_init(void)
+{
+   /* Set GPIO4_B4, GPIO4_B5, and GPIO4_B6 to output. */
+   writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | \
+  (GPIO_B6 | GPIO_B5 | GPIO_B4),
+  (GPIO4_BASE + GPIO_SWPORT_DDR_L));
+   /* Set GPIO4_B5 and GPIO4_B6 to 0 and GPIO4_B4 to 1. */
+   writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | GPIO_B4,
+  (GPIO4_BASE + GPIO_SWPORT_DR_L));
+}
+
+int rk_board_late_init(void)
+{
+   

[PATCH V3] board: rockchip: add Powkiddy X55

2024-05-02 Thread Chris Morgan
From: Chris Morgan 

The Powkiddy X55 is a Rockchip RK3566 based handheld gaming device.
UART, ADC, eMMC, and SDMMC are tested to work in U-Boot and this
successfully boots mainline Linux.

Kernel commit:
e99adc97e21a ("arm64: dts: rockchip: Add Powkiddy X55")

Signed-off-by: Chris Morgan 
---

Changes since V2:
 - Refactored to use the upstream device tree from Linux.
 - Removed logic for handling the adc button and instead simply try to
   boot from sdmmc0 as a valid target first.

---
 arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi |  9 +++
 arch/arm/mach-rockchip/rk3568/Kconfig|  6 ++
 board/powkiddy/x55/Kconfig   | 15 +
 board/powkiddy/x55/MAINTAINERS   |  7 +++
 board/powkiddy/x55/Makefile  |  6 ++
 board/powkiddy/x55/x55.c | 39 +
 configs/powkiddy-x55-rk3566_defconfig| 59 
 doc/board/rockchip/rockchip.rst  |  1 +
 include/configs/powkiddy-x55-rk3566.h| 12 
 9 files changed, 154 insertions(+)
 create mode 100644 arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
 create mode 100644 board/powkiddy/x55/Kconfig
 create mode 100644 board/powkiddy/x55/MAINTAINERS
 create mode 100644 board/powkiddy/x55/Makefile
 create mode 100644 board/powkiddy/x55/x55.c
 create mode 100644 configs/powkiddy-x55-rk3566_defconfig
 create mode 100644 include/configs/powkiddy-x55-rk3566.h

diff --git a/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi 
b/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
new file mode 100644
index 00..c440201ec7
--- /dev/null
+++ b/arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   u-boot,spl-boot-order = , , 
+   };
+};
diff --git a/arch/arm/mach-rockchip/rk3568/Kconfig 
b/arch/arm/mach-rockchip/rk3568/Kconfig
index af537d912a..014ebf9f0b 100644
--- a/arch/arm/mach-rockchip/rk3568/Kconfig
+++ b/arch/arm/mach-rockchip/rk3568/Kconfig
@@ -22,6 +22,11 @@ config TARGET_ODROID_M1_RK3568
help
  Hardkernel ODROID-M1 single board computer with a RK3568B2 SoC.
 
+config TARGET_POWKIDDY_X55_RK3566
+   bool "Powkiddy X55"
+   help
+ Powkiddy X55 handheld gaming console with an RK3566 SoC.
+
 config TARGET_QUARTZ64_RK3566
bool "Pine64 Quartz64"
help
@@ -48,5 +53,6 @@ source "board/rockchip/evb_rk3568/Kconfig"
 source "board/anbernic/rgxx3_rk3566/Kconfig"
 source "board/hardkernel/odroid_m1/Kconfig"
 source "board/pine64/quartz64_rk3566/Kconfig"
+source "board/powkiddy/x55/Kconfig"
 
 endif
diff --git a/board/powkiddy/x55/Kconfig b/board/powkiddy/x55/Kconfig
new file mode 100644
index 00..a7b3ed4d0d
--- /dev/null
+++ b/board/powkiddy/x55/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_POWKIDDY_X55_RK3566
+
+config SYS_BOARD
+   default "x55"
+
+config SYS_VENDOR
+   default "powkiddy"
+
+config SYS_CONFIG_NAME
+   default "powkiddy-x55-rk3566"
+
+config BOARD_SPECIFIC_OPTIONS
+   def_bool y
+
+endif
diff --git a/board/powkiddy/x55/MAINTAINERS b/board/powkiddy/x55/MAINTAINERS
new file mode 100644
index 00..01ae8da19d
--- /dev/null
+++ b/board/powkiddy/x55/MAINTAINERS
@@ -0,0 +1,7 @@
+X55
+M: Chris Morgan 
+S: Maintained
+F: board/powkiddy/x55
+F: include/configs/powkiddy-x55-rk3566.h
+F: configs/powkiddy-x55-rk3566_defconfig
+F: arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
diff --git a/board/powkiddy/x55/Makefile b/board/powkiddy/x55/Makefile
new file mode 100644
index 00..55c8c16aa1
--- /dev/null
+++ b/board/powkiddy/x55/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2023 Chris Morgan 
+#
+
+obj-y += x55.o
diff --git a/board/powkiddy/x55/x55.c b/board/powkiddy/x55/x55.c
new file mode 100644
index 00..b2703e6382
--- /dev/null
+++ b/board/powkiddy/x55/x55.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Chris Morgan 
+ */
+
+#include 
+
+#define GPIO4_BASE 0xfe77
+#define GPIO_SWPORT_DR_L   0x
+#define GPIO_SWPORT_DDR_L  0x0008
+#define GPIO_B4BIT(12)
+#define GPIO_B5BIT(13)
+#define GPIO_B6BIT(14)
+
+#define GPIO_WRITEMASK(bits)   ((bits) << 16)
+
+/*
+ * Start LED very early so user knows device is on. Set color
+ * to red.
+ */
+void spl_board_init(void)
+{
+   /* Set GPIO4_B4, GPIO4_B5, and GPIO4_B6 to output. */
+   writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | \
+  (GPIO_B6 | GPIO_B5 | GPIO_B4),
+  (GPIO4_BASE + GPIO_SWPORT_DDR_L));
+   /* Set GPIO4_B5 and GPIO4_B6 to 0 and GPIO4_B4 to 1. */
+   writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | GPIO_B4,
+  (GPIO4_BASE + GPIO_SWPORT_DR_L));
+}
+
+int rk_board_late_init(void)
+{
+   /* Turn off red LED and turn on orange LED. */
+