[PATCH v2] ARM: rockchip: Add support for Pine64 PineTab 2

Dang Huynh danct12 at riseup.net
Tue Dec 3 02:24:09 PST 2024


The Pine64 PineTab 2 tablet is basically the Quartz64 but as
a finished product.

There are (currently) two revisions, v0.1 and v2.0.

v0.1 was sent to developers and there are a few units around
(probably less than 10?)

v2.0 is the consumer available version, this version changed the
display reset pin and hooked WLAN/BT chip to a GPIO.

Signed-off-by: Dang Huynh <danct12 at riseup.net>
---
Changes in v2:
- Apply changes requested by Ahmad Fatoum
- Unsplit relocation function as it doesn't seem to work correctly
- Link to v1: https://lore.kernel.org/r/20241202-pt2-init-v1-1-bd1ebdc747e0@riseup.net
---
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/pine64-pinetab2/.gitignore |  1 +
 arch/arm/boards/pine64-pinetab2/Makefile   |  3 ++
 arch/arm/boards/pine64-pinetab2/board.c    | 54 ++++++++++++++++++++++++++++++
 arch/arm/boards/pine64-pinetab2/lowlevel.c | 37 ++++++++++++++++++++
 arch/arm/configs/multi_v8_defconfig        |  1 +
 arch/arm/configs/rockchip_v8_defconfig     |  1 +
 arch/arm/dts/Makefile                      |  1 +
 arch/arm/dts/rk3566-pinetab2-v0-1.dts      |  6 ++++
 arch/arm/dts/rk3566-pinetab2-v2-0.dts      |  6 ++++
 arch/arm/dts/rk3566-pinetab2.dtsi          | 46 +++++++++++++++++++++++++
 arch/arm/mach-rockchip/Kconfig             | 15 +++++++++
 images/Makefile.rockchip                   |  2 ++
 13 files changed, 174 insertions(+)

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 67d91616f623be9eddd370485707eeb25d3ebe40..b6b3894c6b40eb1c4129a55145fd8a2e77efe066 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -172,6 +172,7 @@ obj-$(CONFIG_MACH_MNT_REFORM)			+= mnt-reform/
 obj-$(CONFIG_MACH_SKOV_ARM9CPU)			+= skov-arm9cpu/
 obj-$(CONFIG_MACH_RK3568_EVB)			+= rockchip-rk3568-evb/
 obj-$(CONFIG_MACH_RK3568_BPI_R2PRO)			+= rockchip-rk3568-bpi-r2pro/
+obj-$(CONFIG_MACH_PINE64_PINETAB2)		+= pine64-pinetab2/
 obj-$(CONFIG_MACH_PINE64_QUARTZ64)		+= pine64-quartz64/
 obj-$(CONFIG_MACH_RADXA_ROCK3)			+= radxa-rock3/
 obj-$(CONFIG_MACH_RADXA_ROCK5)			+= radxa-rock5/
diff --git a/arch/arm/boards/pine64-pinetab2/.gitignore b/arch/arm/boards/pine64-pinetab2/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..f458f794b54c96b74489d368cb9f44955db11126
--- /dev/null
+++ b/arch/arm/boards/pine64-pinetab2/.gitignore
@@ -0,0 +1 @@
+sdram-init.bin
diff --git a/arch/arm/boards/pine64-pinetab2/Makefile b/arch/arm/boards/pine64-pinetab2/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..b37b6c870bb4d88cbc6f45435caa0a4a8a3d12d6
--- /dev/null
+++ b/arch/arm/boards/pine64-pinetab2/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/pine64-pinetab2/board.c b/arch/arm/boards/pine64-pinetab2/board.c
new file mode 100644
index 0000000000000000000000000000000000000000..29f81adb4d34e542d188dac91b0c1d38b87e3c02
--- /dev/null
+++ b/arch/arm/boards/pine64-pinetab2/board.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <bootsource.h>
+#include <common.h>
+#include <init.h>
+#include <mach/rockchip/bbu.h>
+
+struct pinetab2_model {
+	const char *name;
+	const char *shortname;
+};
+
+static int pinetab2_probe(struct device *dev)
+{
+	const struct pinetab2_model *model = device_get_match_data(dev);
+	enum bootsource bootsource = bootsource_get();
+	int instance = bootsource_get_instance();
+
+	barebox_set_model(model->name);
+	barebox_set_hostname(model->shortname);
+
+	if (bootsource == BOOTSOURCE_MMC && instance == 0)
+		of_device_enable_path("/chosen/environment-sd");
+	else
+		of_device_enable_path("/chosen/environment-emmc");
+
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc0");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc1");
+
+	return 0;
+}
+
+static const struct pinetab2_model pinetab2_v01 = {
+	.name = "Pine64 PineTab 2 v0.1",
+	.shortname = "pinetab2-v01",
+};
+
+static const struct pinetab2_model pinetab2_v20 = {
+	.name = "Pine64 PineTab 2 v2.0",
+	.shortname = "pinetab2-v20",
+};
+
+static const struct of_device_id pinetab2_of_match[] = {
+	{ .compatible = "pine64,pinetab2-v0.1", .data = &pinetab2_v01, },
+	{ .compatible = "pine64,pinetab2-v2.0", .data = &pinetab2_v20, },
+	{ /* sentinel */ },
+};
+BAREBOX_DEEP_PROBE_ENABLE(pinetab2_of_match);
+
+static struct driver pinetab2_board_driver = {
+	.name = "board-pinetab2",
+	.probe = pinetab2_probe,
+	.of_compatible = pinetab2_of_match,
+};
+coredevice_platform_driver(pinetab2_board_driver);
diff --git a/arch/arm/boards/pine64-pinetab2/lowlevel.c b/arch/arm/boards/pine64-pinetab2/lowlevel.c
new file mode 100644
index 0000000000000000000000000000000000000000..73ca6866f082c096c21accde0a27c511f55bc7dd
--- /dev/null
+++ b/arch/arm/boards/pine64-pinetab2/lowlevel.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <common.h>
+#include <asm/barebox-arm.h>
+#include <mach/rockchip/hardware.h>
+#include <mach/rockchip/atf.h>
+#include <debug_ll.h>
+
+extern char __dtb_rk3566_pinetab2_v0_1_start[];
+extern char __dtb_rk3566_pinetab2_v2_0_start[];
+
+ENTRY_FUNCTION(start_pinetab2_v0, r0, r1, r2)
+{
+	putc_ll('>');
+
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	rk3568_barebox_entry(__dtb_rk3566_pinetab2_v0_1_start);
+}
+
+ENTRY_FUNCTION(start_pinetab2_v2, r0, r1, r2)
+{
+	putc_ll('>');
+
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	rk3568_barebox_entry(__dtb_rk3566_pinetab2_v2_0_start);
+}
diff --git a/arch/arm/configs/multi_v8_defconfig b/arch/arm/configs/multi_v8_defconfig
index 39d5dd3fc1678f6a7a719f6ebcabc16b3d02f7ee..fc32ab5a06e4e19eac116369d9dad7dcf990d284 100644
--- a/arch/arm/configs/multi_v8_defconfig
+++ b/arch/arm/configs/multi_v8_defconfig
@@ -29,6 +29,7 @@ CONFIG_MACH_TQMLS1046A=y
 CONFIG_MACH_BEAGLEPLAY=y
 CONFIG_MACH_RK3568_EVB=y
 CONFIG_MACH_RK3568_BPI_R2PRO=y
+CONFIG_MACH_PINE64_PINETAB2=y
 CONFIG_MACH_PINE64_QUARTZ64=y
 CONFIG_MACH_RADXA_ROCK3=y
 CONFIG_MACH_RADXA_ROCK5=y
diff --git a/arch/arm/configs/rockchip_v8_defconfig b/arch/arm/configs/rockchip_v8_defconfig
index 216a88e82457e2c928eb85f739134fda3f36c7c8..e000a1d4ee5746d5b6fe53489249469b1a2b887a 100644
--- a/arch/arm/configs/rockchip_v8_defconfig
+++ b/arch/arm/configs/rockchip_v8_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_MACH_RK3568_EVB=y
 CONFIG_MACH_RK3568_BPI_R2PRO=y
+CONFIG_MACH_PINE64_PINETAB2=y
 CONFIG_MACH_PINE64_QUARTZ64=y
 CONFIG_MACH_PROTONIC_MECSBC=y
 CONFIG_MACH_RADXA_ROCK3=y
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index fe32b812f6037f382954a84f9ab40cfc8715e367..b9727fd5f91bc7681c910df7e8f18d694fd9f0e4 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -83,6 +83,7 @@ lwl-$(CONFIG_MACH_PHYTEC_PHYCORE_IMX7) += imx7d-phyboard-zeta.dtb.o
 lwl-$(CONFIG_MACH_PHYTEC_PHYCORE_STM32MP1) += stm32mp157c-phycore-stm32mp1-3.dtb.o
 lwl-$(CONFIG_MACH_PHYTEC_SOM_IMX8MM) += imx8mm-phyboard-polis-rdk.dtb.o
 lwl-$(CONFIG_MACH_PHYTEC_SOM_IMX8MQ) += imx8mq-phytec-phycore-som.dtb.o
+lwl-$(CONFIG_MACH_PINE64_PINETAB2) += rk3566-pinetab2-v0-1.dtb.o rk3566-pinetab2-v2-0.dtb.o
 lwl-$(CONFIG_MACH_PINE64_QUARTZ64) += rk3566-quartz64-a.dtb.o
 lwl-$(CONFIG_MACH_PLATHOME_OPENBLOCKS_AX3) += armada-xp-openblocks-ax3-4-bb.dtb.o
 lwl-$(CONFIG_MACH_PLATHOME_OPENBLOCKS_A6) += kirkwood-openblocks_a6-bb.dtb.o
diff --git a/arch/arm/dts/rk3566-pinetab2-v0-1.dts b/arch/arm/dts/rk3566-pinetab2-v0-1.dts
new file mode 100644
index 0000000000000000000000000000000000000000..2b89d69775df637f663c257295335db878d28442
--- /dev/null
+++ b/arch/arm/dts/rk3566-pinetab2-v0-1.dts
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include <arm64/rockchip/rk3566-pinetab2-v0.1.dts>
+#include "rk3566-pinetab2.dtsi"
diff --git a/arch/arm/dts/rk3566-pinetab2-v2-0.dts b/arch/arm/dts/rk3566-pinetab2-v2-0.dts
new file mode 100644
index 0000000000000000000000000000000000000000..404ada593c5ca970fb3144f1829cef4e3ce5160d
--- /dev/null
+++ b/arch/arm/dts/rk3566-pinetab2-v2-0.dts
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include <arm64/rockchip/rk3566-pinetab2-v2.0.dts>
+#include "rk3566-pinetab2.dtsi"
diff --git a/arch/arm/dts/rk3566-pinetab2.dtsi b/arch/arm/dts/rk3566-pinetab2.dtsi
new file mode 100644
index 0000000000000000000000000000000000000000..47ac12384d37016cd5912d552e2cb9c817c80475
--- /dev/null
+++ b/arch/arm/dts/rk3566-pinetab2.dtsi
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include <arm64/rockchip/rk3566-pinetab2.dtsi>
+#include "rk356x.dtsi"
+
+/ {
+	chosen: chosen {
+		environment-sd {
+			compatible = "barebox,environment";
+			device-path = &environment_sd;
+			status = "disabled";
+		};
+
+		environment-emmc {
+			compatible = "barebox,environment";
+			device-path = &environment_emmc;
+			status = "disabled";
+		};
+	};
+};
+
+&sdhci {
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_emmc: partition at 408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
+
+&sdmmc0 {
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_sd: partition at 408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ddaab7c2841481ff10a59becf011c0762ee54b27..7042506f2b13ed8662d47baf07c71703ad174535 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -79,6 +79,21 @@ config MACH_RK3568_BPI_R2PRO
 	help
 	  Say Y here if you are using a RK3568 Bananpi R2 Pro
 
+config MACH_PINE64_PINETAB2
+	select ARCH_RK3568
+	bool "Pine64 PineTab 2"
+	help
+	  Say Y here if you are using a Pine64 PineTab 2
+
+	  This will build Barebox for two revisions of PineTab 2:
+
+	  - v0.1: distributed to several OS developers for early OS bring
+	          up. Not many of them are available and was superseded
+	          by rev 2.0.
+
+	  - v2.0: distributed to consumers. Use this if you intend to ship
+	          Barebox to the general public.
+
 config MACH_PINE64_QUARTZ64
 	select ARCH_RK3568
 	bool "Pine64 Quartz64"
diff --git a/images/Makefile.rockchip b/images/Makefile.rockchip
index 6619beae73e2a527b9b9343c229001c8b46a7642..761c6b81498931e5f51b185ed9b2e4ebe16f78bc 100644
--- a/images/Makefile.rockchip
+++ b/images/Makefile.rockchip
@@ -31,6 +31,8 @@ image-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += barebox-rk3288-phycore-som.img
 
 $(call build_rockchip_image, CONFIG_MACH_RK3568_EVB, start_rk3568_evb, rockchip-rk3568-evb/sdram-init.bin, rk3568-evb)
 $(call build_rockchip_image, CONFIG_MACH_RK3568_BPI_R2PRO, start_rk3568_bpi_r2pro, rockchip-rk3568-bpi-r2pro/sdram-init.bin, rk3568-bpi-r2pro)
+$(call build_rockchip_image, CONFIG_MACH_PINE64_PINETAB2, start_pinetab2_v0, pine64-pinetab2/sdram-init.bin, pinetab2-v0)
+$(call build_rockchip_image, CONFIG_MACH_PINE64_PINETAB2, start_pinetab2_v2, pine64-pinetab2/sdram-init.bin, pinetab2-v2)
 $(call build_rockchip_image, CONFIG_MACH_PINE64_QUARTZ64, start_quartz64a, pine64-quartz64/sdram-init.bin, quartz64a)
 $(call build_rockchip_image, CONFIG_MACH_PROTONIC_MECSBC, start_mecsbc, protonic-mecsbc/sdram-init.bin, mecsbc)
 $(call build_rockchip_image, CONFIG_MACH_RADXA_ROCK3, start_rock3a, radxa-rock3/sdram-init.bin, rock3a)

---
base-commit: 7a3cb7e6fd6338144972b7c83675fb5c709ea6f8
change-id: 20241202-pt2-init-7122fe34f0d6

Best regards,
-- 
Dang Huynh <danct12 at riseup.net>




More information about the barebox mailing list