mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH next v2] arm: rockchip: add support for CM3 on IO board
@ 2023-03-30 16:11 Rouven Czerwinski
  2023-04-03  7:11 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Rouven Czerwinski @ 2023-03-30 16:11 UTC (permalink / raw)
  To: barebox; +Cc: Rouven Czerwinski

From: Rouven Czerwinski <rouven@czerwinskis.de>

Working:
- RKBIN DDR training (rk3566_ddr_1056MHz_v1.13.bin)
- RKBIN TF-A (v1.34) from RKBIN
- Environment storage
- DHCP, ping and link detection

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
---
v2:
- rebase on next and adjust to RK356x changes
- update rockchip boards documentation

 Documentation/boards/rockchip.rst    |  1 +
 arch/arm/boards/Makefile             |  1 +
 arch/arm/boards/radxa-cm3/.gitignore |  1 +
 arch/arm/boards/radxa-cm3/Makefile   |  3 ++
 arch/arm/boards/radxa-cm3/board.c    | 56 ++++++++++++++++++++++++++++
 arch/arm/boards/radxa-cm3/lowlevel.c | 28 ++++++++++++++
 arch/arm/dts/Makefile                |  1 +
 arch/arm/dts/rk3566-cm3-io.dts       | 55 +++++++++++++++++++++++++++
 arch/arm/mach-rockchip/Kconfig       |  6 +++
 images/Makefile.rockchip             |  7 ++++
 10 files changed, 159 insertions(+)
 create mode 100644 arch/arm/boards/radxa-cm3/.gitignore
 create mode 100644 arch/arm/boards/radxa-cm3/Makefile
 create mode 100644 arch/arm/boards/radxa-cm3/board.c
 create mode 100644 arch/arm/boards/radxa-cm3/lowlevel.c
 create mode 100644 arch/arm/dts/rk3566-cm3-io.dts

diff --git a/Documentation/boards/rockchip.rst b/Documentation/boards/rockchip.rst
index 0e8738bbf1..583b4f1720 100644
--- a/Documentation/boards/rockchip.rst
+++ b/Documentation/boards/rockchip.rst
@@ -60,6 +60,7 @@ Supported Boards
 - Rockchip RK3568 Bananapi R2 Pro
 - Pine64 Quartz64 Model A
 - Radxa ROCK3 Model A
+- Radxa CM3 (RK3566) IO Board
 
 The steps described in the following target the RK3568 and the RK3568 EVB but
 generally apply to both SoCs and all boards.
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 37b1650e63..b204c257f6 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -190,3 +190,4 @@ obj-$(CONFIG_MACH_RK3568_BPI_R2PRO)			+= rockchip-rk3568-bpi-r2pro/
 obj-$(CONFIG_MACH_PINE64_QUARTZ64)		+= pine64-quartz64/
 obj-$(CONFIG_MACH_RADXA_ROCK3)			+= radxa-rock3/
 obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP)	+= variscite-dt8mcustomboard-imx8mp/
+obj-$(CONFIG_MACH_RADXA_CM3)			+= radxa-cm3/
diff --git a/arch/arm/boards/radxa-cm3/.gitignore b/arch/arm/boards/radxa-cm3/.gitignore
new file mode 100644
index 0000000000..f458f794b5
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/.gitignore
@@ -0,0 +1 @@
+sdram-init.bin
diff --git a/arch/arm/boards/radxa-cm3/Makefile b/arch/arm/boards/radxa-cm3/Makefile
new file mode 100644
index 0000000000..b37b6c870b
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/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/radxa-cm3/board.c b/arch/arm/boards/radxa-cm3/board.c
new file mode 100644
index 0000000000..14b6784179
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/board.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <bootsource.h>
+#include <common.h>
+#include <deep-probe.h>
+#include <init.h>
+#include <mach/rockchip/bbu.h>
+
+struct cm3_model {
+	const char *name;
+	const char *shortname;
+};
+
+static int cm3_probe(struct device *dev)
+{
+	enum bootsource bootsource = bootsource_get();
+	int instance = bootsource_get_instance();
+	const struct cm3_model *model;
+
+	model = device_get_match_data(dev);
+
+	barebox_set_model(model->name);
+	barebox_set_hostname(model->shortname);
+
+	if (bootsource == BOOTSOURCE_MMC && instance == 1)
+		of_device_enable_path("/chosen/environment-sd");
+	else
+		of_device_enable_path("/chosen/environment-emmc");
+
+	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
+				"/dev/mmc0");
+	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+
+	return 0;
+}
+
+static const struct cm3_model cm3_io = {
+	.name = "Radxa CM3 on IO Board",
+	.shortname = "cm3-io",
+};
+
+static const struct of_device_id cm3_of_match[] = {
+	{
+		.compatible = "radxa,cm3-io",
+		.data = &cm3_io,
+	},
+	{ /* sentinel */ },
+};
+
+static struct driver cm3_io_board_driver = {
+	.name = "board-cm3-io",
+	.probe = cm3_probe,
+	.of_compatible = cm3_of_match,
+};
+coredevice_platform_driver(cm3_io_board_driver);
+
+BAREBOX_DEEP_PROBE_ENABLE(cm3_of_match);
diff --git a/arch/arm/boards/radxa-cm3/lowlevel.c b/arch/arm/boards/radxa-cm3/lowlevel.c
new file mode 100644
index 0000000000..ee620c0aeb
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/lowlevel.c
@@ -0,0 +1,28 @@
+// 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_cm3_io_start[];
+
+ENTRY_FUNCTION(start_radxa_cm3_io, r0, r1, r2)
+{
+	/*
+	 * Enable vccio4 1.8V and vccio6 1.8V
+	 * Needed for GMAC to work.
+	 * FIXME: This is done by the io-domain driver as well, but there
+	 * currently is no mechanism to make sure the driver gets probed
+	 * before its consumers. Remove this setup once this issue is
+	 * resolved.
+	 */
+	writel(RK_SETBITS(0x50), 0xfdc20140);
+
+	putc_ll('>');
+
+	relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	setup_c();
+
+	rk3568_barebox_entry(__dtb_rk3566_cm3_io_start);
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a7cceb461..220e1617e3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -109,6 +109,7 @@ lwl-$(CONFIG_MACH_PROTONIC_STM32MP1) += \
 	stm32mp151-prtt1s.dtb.o
 lwl-$(CONFIG_MACH_RADXA_ROCK) += rk3188-radxarock.dtb.o
 lwl-$(CONFIG_MACH_RADXA_ROCK3) += rk3568-rock-3a.dtb.o
+lwl-$(CONFIG_MACH_RADXA_CM3) += rk3566-cm3-io.dtb.o
 lwl-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += rk3288-phycore-som.dtb.o
 lwl-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o
 lwl-$(CONFIG_MACH_RK3568_EVB) += rk3568-evb1-v10.dtb.o
diff --git a/arch/arm/dts/rk3566-cm3-io.dts b/arch/arm/dts/rk3566-cm3-io.dts
new file mode 100644
index 0000000000..81f896b943
--- /dev/null
+++ b/arch/arm/dts/rk3566-cm3-io.dts
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include <arm64/rockchip/rk3566-radxa-cm3-io.dts>
+#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";
+		};
+	};
+
+	memory@a00000 {
+		device_type = "memory";
+		reg = <0x0 0x00a00000 0x0 0x7f600000>;
+	};
+};
+
+&sdhci {
+	no-sd;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_emmc: partition@408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
+
+&sdmmc0 {
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_sd: partition@408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 9b4913d5da..ae08fc8ce3 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -91,6 +91,12 @@ config MACH_RADXA_ROCK3
        help
 	  Say Y here if you are using a Radxa ROCK3
 
+config MACH_RADXA_CM3
+       select ARCH_RK3568
+       bool "Radxa CM3"
+       help
+	  Say Y here if you are using a Radxa CM3
+
 endif
 
 comment "select board features:"
diff --git a/images/Makefile.rockchip b/images/Makefile.rockchip
index 33c76caf79..490e1ddb4d 100644
--- a/images/Makefile.rockchip
+++ b/images/Makefile.rockchip
@@ -23,6 +23,9 @@ image-$(CONFIG_MACH_PINE64_QUARTZ64) += barebox-quartz64a.img
 pblb-$(CONFIG_MACH_RADXA_ROCK3) += start_rock3a
 image-$(CONFIG_MACH_RADXA_ROCK3) += barebox-rock3a.img
 
+pblb-$(CONFIG_MACH_RADXA_CM3) += start_radxa-cm3-io.img
+image-$(CONFIG_MACH_RADXA_CM3) += barebox-radxa-cm3-io.img
+
 quiet_cmd_rkimg_image = RK-IMG $@
       cmd_rkimg_image = $(objtree)/scripts/rkimage -o $@ $(word 2,$^) $(word 1,$^)
 
@@ -41,3 +44,7 @@ $(obj)/barebox-quartz64a.img: $(obj)/start_quartz64a.pblb \
 $(obj)/barebox-rock3a.img: $(obj)/start_rock3a.pblb \
                 $(board)/radxa-rock3/sdram-init.bin
 	$(call if_changed,rkimg_image)
+
+$(obj)/barebox-radxa-cm3-io.img: $(obj)/start_radxa_cm3_io.pblb \
+                $(board)/radxa-cm3/sdram-init.bin
+	$(call if_changed,rkimg_image)
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next v2] arm: rockchip: add support for CM3 on IO board
  2023-03-30 16:11 [PATCH next v2] arm: rockchip: add support for CM3 on IO board Rouven Czerwinski
@ 2023-04-03  7:11 ` Sascha Hauer
  2023-04-04 12:28   ` Rouven Czerwinski
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2023-04-03  7:11 UTC (permalink / raw)
  To: Rouven Czerwinski; +Cc: barebox, Rouven Czerwinski

On Thu, Mar 30, 2023 at 06:11:01PM +0200, Rouven Czerwinski wrote:
> From: Rouven Czerwinski <rouven@czerwinskis.de>
> 
> Working:
> - RKBIN DDR training (rk3566_ddr_1056MHz_v1.13.bin)
> - RKBIN TF-A (v1.34) from RKBIN
> - Environment storage
> - DHCP, ping and link detection
> 
> Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
> ---
> v2:
> - rebase on next and adjust to RK356x changes
> - update rockchip boards documentation
> 
> +	memory@a00000 {
> +		device_type = "memory";
> +		reg = <0x0 0x00a00000 0x0 0x7f600000>;
> +	};

Now that we have a driver reading back the memory settings from the
controller this shouldn't be needed anymore. I dropped the memory node
while applying, please check if it works.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next v2] arm: rockchip: add support for CM3 on IO board
  2023-04-03  7:11 ` Sascha Hauer
@ 2023-04-04 12:28   ` Rouven Czerwinski
  0 siblings, 0 replies; 3+ messages in thread
From: Rouven Czerwinski @ 2023-04-04 12:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Rouven Czerwinski

Hi Sascha,

On Mon, 2023-04-03 at 09:11 +0200, Sascha Hauer wrote:
> On Thu, Mar 30, 2023 at 06:11:01PM +0200, Rouven Czerwinski wrote:
> > From: Rouven Czerwinski <rouven@czerwinskis.de>
> > 
> > Working:
> > - RKBIN DDR training (rk3566_ddr_1056MHz_v1.13.bin)
> > - RKBIN TF-A (v1.34) from RKBIN
> > - Environment storage
> > - DHCP, ping and link detection
> > 
> > Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
> > ---
> > v2:
> > - rebase on next and adjust to RK356x changes
> > - update rockchip boards documentation
> > 
> > +       memory@a00000 {
> > +               device_type = "memory";
> > +               reg = <0x0 0x00a00000 0x0 0x7f600000>;
> > +       };
> 
> Now that we have a driver reading back the memory settings from the
> controller this shouldn't be needed anymore. I dropped the memory node
> while applying, please check if it works.

It does, thanks!

Best regards,
Rouven Czerwinski



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-04 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 16:11 [PATCH next v2] arm: rockchip: add support for CM3 on IO board Rouven Czerwinski
2023-04-03  7:11 ` Sascha Hauer
2023-04-04 12:28   ` Rouven Czerwinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox