mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ARM: boards: add support for Samsung Galaxy S8 and S20 5G
@ 2025-09-02 14:00 Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 1/3] video: simplefb-client: switch to dev_get_resource Ivaylo Ivanov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ivaylo Ivanov @ 2025-09-02 14:00 UTC (permalink / raw)
  To: Sascha Hauer, Ahmad Fatoum; +Cc: barebox

Hey folks,

This patchset focuses on adding support for S8 and S20. It's designed to
allow adding support for new exynos devices easy, with the primary
differentiating factor being the device tree. Currently, the same built
barebox-exynos.img can be booted on both S20 and S8 without any changes
in the code, as it can dynamically recognize what device it's booting on
based on the tree provided at x0 from the previous bootloader (s-boot).

On these devices, barebox will be used as a shim after the stock bootloader
(s-boot), replacing the linux kernel image in the boot.img.

Please read the patch commit messages, I've tried to describe everything
well enough. Thanks!

Best regards,
Ivaylo

Changes in V2:
- drop the applied patch
- s/Since/If in 1/3
- add r-b tag on 1/3 from Ahmad
- add a simple defaultenv that autoboots a fit image from memory
- change is_compat to is_model
- rework the entry to deal with SP in assembly and jump us to C
- set up properly before touching fdts
- beautify postcore a bit
- enable deep probe on both platforms in DT

Ivaylo Ivanov (3):
  video: simplefb-client: switch to dev_get_resource
  ARM: boards: add support for Samsung Galaxy S8 (dreamlte)
  ARM: boards: add support for Samsung Galaxy S20 5G (x1s)

 arch/arm/Kconfig                              |  5 ++
 arch/arm/boards/Makefile                      |  1 +
 arch/arm/boards/samsung-exynos/Makefile       |  5 ++
 arch/arm/boards/samsung-exynos/board.c        | 69 +++++++++++++++
 .../defaultenv-exynos/boot/ramfit             | 16 ++++
 .../defaultenv-exynos/init/bootsource         |  3 +
 arch/arm/boards/samsung-exynos/entry.S        | 31 +++++++
 arch/arm/boards/samsung-exynos/lowlevel.c     | 83 +++++++++++++++++++
 arch/arm/dts/Makefile                         |  2 +
 arch/arm/dts/exynos8895-dreamlte.dts          | 13 +++
 arch/arm/dts/exynos990-x1s.dts                | 13 +++
 arch/arm/mach-samsung/Kconfig                 | 13 +++
 drivers/video/simplefb-client.c               |  5 +-
 images/Makefile                               |  1 +
 images/Makefile.exynos                        |  8 ++
 15 files changed, 265 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/boards/samsung-exynos/Makefile
 create mode 100644 arch/arm/boards/samsung-exynos/board.c
 create mode 100644 arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
 create mode 100644 arch/arm/boards/samsung-exynos/defaultenv-exynos/init/bootsource
 create mode 100644 arch/arm/boards/samsung-exynos/entry.S
 create mode 100644 arch/arm/boards/samsung-exynos/lowlevel.c
 create mode 100644 arch/arm/dts/exynos8895-dreamlte.dts
 create mode 100644 arch/arm/dts/exynos990-x1s.dts
 create mode 100644 arch/arm/mach-samsung/Kconfig
 create mode 100644 images/Makefile.exynos

-- 
2.43.0




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

* [PATCH v2 1/3] video: simplefb-client: switch to dev_get_resource
  2025-09-02 14:00 [PATCH v2 0/3] ARM: boards: add support for Samsung Galaxy S8 and S20 5G Ivaylo Ivanov
@ 2025-09-02 14:00 ` Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 2/3] ARM: boards: add support for Samsung Galaxy S8 (dreamlte) Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 3/3] ARM: boards: add support for Samsung Galaxy S20 5G (x1s) Ivaylo Ivanov
  2 siblings, 0 replies; 4+ messages in thread
From: Ivaylo Ivanov @ 2025-09-02 14:00 UTC (permalink / raw)
  To: Sascha Hauer, Ahmad Fatoum; +Cc: barebox

If the framebuffer memory resource resides in ram, it has already
been requested and mapped, so only get the resource to avoid
requesting a busy resource. This is also the approach for linux.

While at it, use IOMEM for mem->start and drop an unnecessary newline.

Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/video/simplefb-client.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/video/simplefb-client.c b/drivers/video/simplefb-client.c
index dafec617..41ad8ffa 100644
--- a/drivers/video/simplefb-client.c
+++ b/drivers/video/simplefb-client.c
@@ -96,7 +96,7 @@ static int simplefb_probe(struct device *dev)
 	if (ret)
 		return ret;
 
-	mem = dev_request_mem_resource(dev, 0);
+	mem = dev_get_resource(dev, IORESOURCE_MEM, 0);
 	if (IS_ERR(mem)) {
 		dev_err(dev, "No memory resource\n");
 		return PTR_ERR(mem);
@@ -116,10 +116,9 @@ static int simplefb_probe(struct device *dev)
 	info->blue = params.format->blue;
 	info->transp = params.format->transp;
 
-	info->screen_base = (void *)mem->start;
+	info->screen_base = IOMEM(mem->start);
 	info->screen_size = resource_size(mem);
 
-
 	info->fbops = &simplefb_ops;
 
 	info->dev.parent = dev;
-- 
2.43.0




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

* [PATCH v2 2/3] ARM: boards: add support for Samsung Galaxy S8 (dreamlte)
  2025-09-02 14:00 [PATCH v2 0/3] ARM: boards: add support for Samsung Galaxy S8 and S20 5G Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 1/3] video: simplefb-client: switch to dev_get_resource Ivaylo Ivanov
@ 2025-09-02 14:00 ` Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 3/3] ARM: boards: add support for Samsung Galaxy S20 5G (x1s) Ivaylo Ivanov
  2 siblings, 0 replies; 4+ messages in thread
From: Ivaylo Ivanov @ 2025-09-02 14:00 UTC (permalink / raw)
  To: Sascha Hauer, Ahmad Fatoum; +Cc: barebox

Phones utilizing an exynos SoC boot android with samsung's proprietary
bootloader, called s-boot (s-lk on newer devices). However, not only is
it closed source, it also enforces some limitations that prevent us from
booting mainline linux cleanly on them, such as an applied overlay device
tree, disabled framebuffer refreshing, misaligned kernel image at boot.
Therefore, having another stage bootloader, loaded as a linux kernel
image by s-boot, is best.

Add support for Samsung Galaxy S8, utilizing the exynos 8895 SoC. Support
is modelled to be as reusable on other devices as possible, requiring
only a minimal set of changes to boot - a barebox device tree, which in
this case is basically imported torvalds tree for dreamlte, that is then
matched from the downstream device tree, provided by s-boot at x0.

For certain devices the stack set up by the previous bootloader is not
enough. Since the idea of this board support is to be as generic as
possible, setting a fixed stack top via ENTRY_FUNCTION_WITHSTACK does
not make sense, due to different exynos devices having different memory
layouts - exynos8895's dram starts at 0x80000000, whereas exynos7870's
starts at 0x40000000. Instead, set the SP as early as possible in
assembly by offsetting the image by 0x80000 and letting it grow from
there.

Barebox has to be packaged as an android boot image:

mkbootimg --kernel images/barebox-exynos.img \
--ramdisk ramdisk.bin \
--dt stock.dtb
--cmdline "buildvariant=eng" \
--base 0x10000000 \
--kernel_offset 0x00008000 \
--ramdisk_offset 0x01000000 \
--second_offset 0x00f00000 \
--tags_offset 0x00000100 \
--os_version 9.0.0 \
--os_patch_level 2019-10 \
--pagesize 2048 \
--hash sha1 \
--output boot.img

And then flashed to the boot partition:

heimdall flash --BOOT boot.img

Currently, only a minimal set of features work. It's possible to
boot a FIT image packaged as a ramdisk with mkbootimg.

Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
---
 arch/arm/Kconfig                              |  5 ++
 arch/arm/boards/Makefile                      |  1 +
 arch/arm/boards/samsung-exynos/Makefile       |  5 ++
 arch/arm/boards/samsung-exynos/board.c        | 65 +++++++++++++++
 .../defaultenv-exynos/boot/ramfit             | 12 +++
 .../defaultenv-exynos/init/bootsource         |  3 +
 arch/arm/boards/samsung-exynos/entry.S        | 31 +++++++
 arch/arm/boards/samsung-exynos/lowlevel.c     | 80 +++++++++++++++++++
 arch/arm/dts/Makefile                         |  1 +
 arch/arm/dts/exynos8895-dreamlte.dts          | 13 +++
 arch/arm/mach-samsung/Kconfig                 | 13 +++
 images/Makefile                               |  1 +
 images/Makefile.exynos                        |  8 ++
 13 files changed, 238 insertions(+)
 create mode 100644 arch/arm/boards/samsung-exynos/Makefile
 create mode 100644 arch/arm/boards/samsung-exynos/board.c
 create mode 100644 arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
 create mode 100644 arch/arm/boards/samsung-exynos/defaultenv-exynos/init/bootsource
 create mode 100644 arch/arm/boards/samsung-exynos/entry.S
 create mode 100644 arch/arm/boards/samsung-exynos/lowlevel.c
 create mode 100644 arch/arm/dts/exynos8895-dreamlte.dts
 create mode 100644 arch/arm/mach-samsung/Kconfig
 create mode 100644 images/Makefile.exynos

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7a395270..095f189f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -212,6 +212,10 @@ config ARCH_ROCKCHIP
 	select HAS_DEBUG_LL
 	imply GPIO_ROCKCHIP
 
+config ARCH_SAMSUNG
+	bool "ARM Exynos boards"
+	depends on ARCH_MULTIARCH
+
 config ARCH_STM32MP
 	bool "STMicroelectronics STM32MP"
 	depends on 32BIT
@@ -268,6 +272,7 @@ source "arch/arm/mach-k3/Kconfig"
 source "arch/arm/mach-omap/Kconfig"
 source "arch/arm/mach-pxa/Kconfig"
 source "arch/arm/mach-rockchip/Kconfig"
+source "arch/arm/mach-samsung/Kconfig"
 source "arch/arm/mach-socfpga/Kconfig"
 source "arch/arm/mach-sunxi/Kconfig"
 source "arch/arm/mach-stm32mp/Kconfig"
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index ac1fa74d..ff2efe04 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MACH_CHUMBY)			+= chumby_falconwing/
 obj-$(CONFIG_MACH_CLEP7212)			+= clep7212/
 obj-$(CONFIG_MACH_DFI_FS700_M60)		+= dfi-fs700-m60/
 obj-$(CONFIG_MACH_DIGI_CCIMX6ULSBCPRO)		+= digi-ccimx6ulsom/
+obj-$(CONFIG_MACH_EXYNOS)			+= samsung-exynos/
 obj-$(CONFIG_MACH_DUCKBILL)			+= duckbill/
 obj-$(CONFIG_MACH_DSS11)			+= dss11/
 obj-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK)		+= efika-mx-smartbook/
diff --git a/arch/arm/boards/samsung-exynos/Makefile b/arch/arm/boards/samsung-exynos/Makefile
new file mode 100644
index 00000000..6694e90d
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-y += board.o
+lwl-y += entry.o lowlevel.o
+bbenv-y += defaultenv-exynos
diff --git a/arch/arm/boards/samsung-exynos/board.c b/arch/arm/boards/samsung-exynos/board.c
new file mode 100644
index 00000000..2d0c2248
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/board.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+ */
+#include <common.h>
+#include <envfs.h>
+#include <init.h>
+#include <of.h>
+#include <deep-probe.h>
+#include <asm/memory.h>
+#include <linux/sizes.h>
+#include <asm/system.h>
+#include <of_address.h>
+
+#define EXYNOS8895_DECON0	0x12860000
+#define HW_SW_TRIG_CONTROL	0x70
+#define TRIG_AUTO_MASK_EN	BIT(12)
+#define SW_TRIG_EN		BIT(8)
+#define HW_TRIG_EN		BIT(0)
+
+static int exynos_postcore_init(void)
+{
+	void __iomem *trig_ctrl;
+
+	/*
+	 * ARM64 s-boot usually keeps framebuffer refreshing disabled after
+	 * jumping to kernel. Set the required bit so we can have output. This
+	 * should ideally be dropped from board files once we have a decon
+	 * driver.
+	 */
+	if (of_machine_is_compatible("samsung,exynos8895"))
+		trig_ctrl = IOMEM(EXYNOS8895_DECON0 + HW_SW_TRIG_CONTROL);
+	else
+		return 0;
+
+	writel(TRIG_AUTO_MASK_EN | SW_TRIG_EN | HW_TRIG_EN,
+	       trig_ctrl);
+
+	return 0;
+}
+coredevice_initcall(exynos_postcore_init);
+
+static inline int exynos_init(struct device *dev)
+{
+	barebox_set_model(of_get_model());
+	barebox_set_hostname("samsung-exynos");
+
+	defaultenv_append_directory(defaultenv_exynos);
+
+	return 0;
+}
+
+static const struct of_device_id exynos_of_match[] = {
+	{ .compatible = "samsung,dreamlte" },
+	{ /* Sentinel */},
+};
+
+MODULE_DEVICE_TABLE(of, exynos_of_match);
+
+static struct driver exynos_board_driver = {
+	.name = "board-exynos",
+	.probe = exynos_init,
+	.of_compatible = exynos_of_match,
+};
+postcore_platform_driver(exynos_board_driver);
diff --git a/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit b/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
new file mode 100644
index 00000000..0912c9fc
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#
+# Boot a FIT image, packaged as ramdisk in the boot.img and placed
+# in memory by s-boot.
+#
+if test "$global.model" = "Samsung Galaxy S8 (SM-G950F)"; then
+	global fit_offset=0x9000000
+fi
+
+addpart /dev/ram0 0x2000000@$global.fit_offset(fit)
+bootm -f /dev/ram0.fit
diff --git a/arch/arm/boards/samsung-exynos/defaultenv-exynos/init/bootsource b/arch/arm/boards/samsung-exynos/defaultenv-exynos/init/bootsource
new file mode 100644
index 00000000..99016c98
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/defaultenv-exynos/init/bootsource
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+global.boot.default=ramfit
diff --git a/arch/arm/boards/samsung-exynos/entry.S b/arch/arm/boards/samsung-exynos/entry.S
new file mode 100644
index 00000000..e9607f9f
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/entry.S
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <linux/linkage.h>
+#include <asm/barebox-arm64.h>
+#include <asm/image.h>
+
+#define IMAGE_FLAGS \
+	(ARM64_IMAGE_FLAG_PAGE_SIZE_4K << ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT) | \
+	(ARM64_IMAGE_FLAG_PHYS_BASE << ARM64_IMAGE_FLAG_PHYS_BASE_SHIFT)
+
+.section .text_head_entry_exynos
+ENTRY("start_exynos")
+	nop                        /* code0 */
+	b 2f                       /* code1 */
+	.xword 0x80000             /* Image load offset */
+	.xword _barebox_image_size /* Effective Image size */
+	.xword IMAGE_FLAGS	   /* Kernel flags */
+	.xword 0                   /* reserved */
+	.xword 0                   /* reserved */
+	.xword 0                   /* reserved */
+	.ascii ARM64_IMAGE_MAGIC   /* magic number */
+	.int   0                   /* reserved (PE-COFF offset) */
+	.asciz "barebox"	   /* unused for now */
+2:
+	adr x1, _text - .
+	mov sp, x1
+	/* Stack now grows into the 0x80000 image load offset specified
+	 * above. This is more than enough until FDT /memory is decoded.
+	 */
+	b lowlevel_exynos
+
+ENTRY_PROC_END(start_exynos)
diff --git a/arch/arm/boards/samsung-exynos/lowlevel.c b/arch/arm/boards/samsung-exynos/lowlevel.c
new file mode 100644
index 00000000..bb040611
--- /dev/null
+++ b/arch/arm/boards/samsung-exynos/lowlevel.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+ */
+#include <common.h>
+#include <pbl.h>
+#include <linux/sizes.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <asm/sections.h>
+#include <asm/cache.h>
+#include <asm/mmu.h>
+
+extern char __dtb_exynos8895_dreamlte_start[];
+
+/* called from assembly */
+void lowlevel_exynos(void *downstream_fdt);
+
+static bool is_model(const void *fdt, const char *prefix)
+{
+	int node, len;
+	const char *compat;
+
+	node = fdt_path_offset(fdt, "/");
+	if (node < 0)
+		return false;
+
+	/*
+	 * Samsung doesn't keep compatibles as consistent as model
+	 * strings. For example:
+	 *
+	 * compatible = "samsung,X1S EUR OPEN 05\0samsung,EXYNOS990";
+	 * compatible = "samsung, DREAMLTE KOR rev01", "samsung,EXYNOS8895";
+	 * compatible = "samsung, J7VE LTE LTN OPEN 00", "samsung,exynos7870";
+	 *
+	 * Use models for matching instead to avoid confusion.
+	 */
+	compat = fdt_getprop(fdt, node, "model", &len);
+	if (!compat)
+		return false;
+
+	while (*prefix) {
+		if (*compat++ != *prefix++)
+			return false;
+	}
+	return true;
+}
+
+static noinline void exynos_continue(void *downstream_fdt)
+{
+	void *fdt;
+	unsigned long membase, memsize;
+	char *__dtb_start;
+
+	/* select device tree dynamically */
+	if (is_model(downstream_fdt, "Samsung DREAMLTE")) {
+		__dtb_start = __dtb_exynos8895_dreamlte_start;
+	} else {
+		/* we didn't match any device */
+		return;
+	}
+	fdt = __dtb_start + get_runtime_offset();
+	fdt_find_mem(fdt, &membase, &memsize);
+
+	barebox_arm_entry(membase, memsize, fdt);
+}
+
+void lowlevel_exynos(void *downstream_fdt)
+{
+	arm_cpu_lowlevel_init();
+
+	relocate_to_current_adr();
+
+	setup_c();
+
+	if (!downstream_fdt || fdt_check_header(downstream_fdt))
+		return;
+
+	exynos_continue(downstream_fdt);
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 6612a514..a53834f7 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -13,6 +13,7 @@ lwl-$(CONFIG_MACH_BEAGLEPLAY) += k3-am625-beagleplay.dtb.o k3-am625-r5-beaglepla
 lwl-$(CONFIG_MACH_CLEP7212) += ep7212-clep7212.dtb.o
 lwl-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o imx6q-utilite.dtb.o
 lwl-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o imx6dl-dfi-fs700-m60-6s.dtb.o
+lwl-$(CONFIG_MACH_EXYNOS) += exynos8895-dreamlte.dtb.o
 lwl-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o
 lwl-$(CONFIG_MACH_KINDLE_MX50) += imx50-kindle-d01100.dtb.o imx50-kindle-d01200.dtb.o imx50-kindle-ey21.dtb.o
 lwl-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += imx51-genesi-efika-sb.dtb.o
diff --git a/arch/arm/dts/exynos8895-dreamlte.dts b/arch/arm/dts/exynos8895-dreamlte.dts
new file mode 100644
index 00000000..d28b7ec2
--- /dev/null
+++ b/arch/arm/dts/exynos8895-dreamlte.dts
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * Samsung Galaxy S8 (dreamlte/SM-G950F) barebox device tree source
+ *
+ * Copyright (c) 2025, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+ */
+
+/dts-v1/;
+#include <arm64/exynos/exynos8895-dreamlte.dts>
+
+/ {
+	barebox,deep-probe;
+};
diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
new file mode 100644
index 00000000..106a48a6
--- /dev/null
+++ b/arch/arm/mach-samsung/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+if ARCH_SAMSUNG
+
+config MACH_EXYNOS
+	bool "Samsung Exynos boards support"
+	depends on 64BIT
+	select CPU_V8
+	select ARM_PSCI_CLIENT
+	select HW_HAS_PCI
+	select OF_OVERLAY
+
+endif
diff --git a/images/Makefile b/images/Makefile
index e20d11e1..4be5c3cd 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -176,6 +176,7 @@ include $(srctree)/images/Makefile.mvebu
 include $(srctree)/images/Makefile.mxs
 include $(srctree)/images/Makefile.omap3
 include $(srctree)/images/Makefile.rockchip
+include $(srctree)/images/Makefile.exynos
 include $(srctree)/images/Makefile.sandbox
 include $(srctree)/images/Makefile.socfpga
 include $(srctree)/images/Makefile.stm32mp
diff --git a/images/Makefile.exynos b/images/Makefile.exynos
new file mode 100644
index 00000000..3beb9107
--- /dev/null
+++ b/images/Makefile.exynos
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# barebox image generation Makefile for exynos images
+#
+
+pblb-$(CONFIG_MACH_EXYNOS) += start_exynos
+FILE_barebox-exynos.img = start_exynos.pblb
+image-$(CONFIG_MACH_EXYNOS) += barebox-exynos.img
-- 
2.43.0




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

* [PATCH v2 3/3] ARM: boards: add support for Samsung Galaxy S20 5G (x1s)
  2025-09-02 14:00 [PATCH v2 0/3] ARM: boards: add support for Samsung Galaxy S8 and S20 5G Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 1/3] video: simplefb-client: switch to dev_get_resource Ivaylo Ivanov
  2025-09-02 14:00 ` [PATCH v2 2/3] ARM: boards: add support for Samsung Galaxy S8 (dreamlte) Ivaylo Ivanov
@ 2025-09-02 14:00 ` Ivaylo Ivanov
  2 siblings, 0 replies; 4+ messages in thread
From: Ivaylo Ivanov @ 2025-09-02 14:00 UTC (permalink / raw)
  To: Sascha Hauer, Ahmad Fatoum; +Cc: barebox

Add support for Samsung Galaxy S20 5G, based on exynos 990, to the
current samsung board support. This platform, just like exynos8895,
needs a bit to be set in order to allow the framebuffer to refresh.

Barebox has to be packaged as an android boot image:

mkbootimg --kernel images/barebox-exynos.img \
--ramdisk ramdisk.bin \
--dt stock.dtb
--cmdline "buildvariant=eng" \
--base 0x10000000 \
--kernel_offset 0x00008000 \
--ramdisk_offset 0x01000000 \
--second_offset 0x00f00000 \
--tags_offset 0x00000100 \
--os_version 9.0.0 \
--os_patch_level 2019-10 \
--pagesize 2048 \
--hash sha1 \
--output boot.img

And then flashed to the boot partition:

heimdall flash --BOOT boot.img

Currently, only a minimal set of features work. It's possible to
boot a FIT image packaged as a ramdisk with mkbootimg.

Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
Tested-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>

---
The tester is also the one who upstreamed support for x1s in mainline
linux. He volunteered for me to upstream barebox support for it
alongside dreamlte, hence why I have my copyright in the x1s overlay
device tree.
---
 arch/arm/boards/samsung-exynos/board.c              |  4 ++++
 .../samsung-exynos/defaultenv-exynos/boot/ramfit    |  4 ++++
 arch/arm/boards/samsung-exynos/lowlevel.c           |  3 +++
 arch/arm/dts/Makefile                               |  3 ++-
 arch/arm/dts/exynos990-x1s.dts                      | 13 +++++++++++++
 5 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/exynos990-x1s.dts

diff --git a/arch/arm/boards/samsung-exynos/board.c b/arch/arm/boards/samsung-exynos/board.c
index 2d0c2248..f26da64a 100644
--- a/arch/arm/boards/samsung-exynos/board.c
+++ b/arch/arm/boards/samsung-exynos/board.c
@@ -13,6 +13,7 @@
 #include <of_address.h>
 
 #define EXYNOS8895_DECON0	0x12860000
+#define EXYNOS990_DECON0	0x19050000
 #define HW_SW_TRIG_CONTROL	0x70
 #define TRIG_AUTO_MASK_EN	BIT(12)
 #define SW_TRIG_EN		BIT(8)
@@ -30,6 +31,8 @@ static int exynos_postcore_init(void)
 	 */
 	if (of_machine_is_compatible("samsung,exynos8895"))
 		trig_ctrl = IOMEM(EXYNOS8895_DECON0 + HW_SW_TRIG_CONTROL);
+	else if (of_machine_is_compatible("samsung,exynos990"))
+		trig_ctrl = IOMEM(EXYNOS990_DECON0 + HW_SW_TRIG_CONTROL);
 	else
 		return 0;
 
@@ -52,6 +55,7 @@ static inline int exynos_init(struct device *dev)
 
 static const struct of_device_id exynos_of_match[] = {
 	{ .compatible = "samsung,dreamlte" },
+	{ .compatible = "samsung,x1s" },
 	{ /* Sentinel */},
 };
 
diff --git a/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit b/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
index 0912c9fc..c8fc7e55 100644
--- a/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
+++ b/arch/arm/boards/samsung-exynos/defaultenv-exynos/boot/ramfit
@@ -8,5 +8,9 @@ if test "$global.model" = "Samsung Galaxy S8 (SM-G950F)"; then
 	global fit_offset=0x9000000
 fi
 
+if test "$global.model" = "Samsung Galaxy S20 5G"; then
+	global fit_offset=0x4000000
+fi
+
 addpart /dev/ram0 0x2000000@$global.fit_offset(fit)
 bootm -f /dev/ram0.fit
diff --git a/arch/arm/boards/samsung-exynos/lowlevel.c b/arch/arm/boards/samsung-exynos/lowlevel.c
index bb040611..fe6fd6ed 100644
--- a/arch/arm/boards/samsung-exynos/lowlevel.c
+++ b/arch/arm/boards/samsung-exynos/lowlevel.c
@@ -12,6 +12,7 @@
 #include <asm/mmu.h>
 
 extern char __dtb_exynos8895_dreamlte_start[];
+extern char __dtb_exynos990_x1s_start[];
 
 /* called from assembly */
 void lowlevel_exynos(void *downstream_fdt);
@@ -55,6 +56,8 @@ static noinline void exynos_continue(void *downstream_fdt)
 	/* select device tree dynamically */
 	if (is_model(downstream_fdt, "Samsung DREAMLTE")) {
 		__dtb_start = __dtb_exynos8895_dreamlte_start;
+	} else if (is_model(downstream_fdt, "Samsung X1S")) {
+		__dtb_start = __dtb_exynos990_x1s_start;
 	} else {
 		/* we didn't match any device */
 		return;
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a53834f7..58f05871 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -13,7 +13,8 @@ lwl-$(CONFIG_MACH_BEAGLEPLAY) += k3-am625-beagleplay.dtb.o k3-am625-r5-beaglepla
 lwl-$(CONFIG_MACH_CLEP7212) += ep7212-clep7212.dtb.o
 lwl-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o imx6q-utilite.dtb.o
 lwl-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o imx6dl-dfi-fs700-m60-6s.dtb.o
-lwl-$(CONFIG_MACH_EXYNOS) += exynos8895-dreamlte.dtb.o
+lwl-$(CONFIG_MACH_EXYNOS) += exynos8895-dreamlte.dtb.o \
+			exynos990-x1s.dtb.o
 lwl-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o
 lwl-$(CONFIG_MACH_KINDLE_MX50) += imx50-kindle-d01100.dtb.o imx50-kindle-d01200.dtb.o imx50-kindle-ey21.dtb.o
 lwl-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += imx51-genesi-efika-sb.dtb.o
diff --git a/arch/arm/dts/exynos990-x1s.dts b/arch/arm/dts/exynos990-x1s.dts
new file mode 100644
index 00000000..19d59eaa
--- /dev/null
+++ b/arch/arm/dts/exynos990-x1s.dts
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * Samsung Galaxy S20 5G (x1s/SM-G981B) barebox device tree source
+ *
+ * Copyright (c) 2025, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+ */
+
+/dts-v1/;
+#include <arm64/exynos/exynos990-x1s.dts>
+
+/ {
+	barebox,deep-probe;
+};
-- 
2.43.0




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

end of thread, other threads:[~2025-09-02 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-02 14:00 [PATCH v2 0/3] ARM: boards: add support for Samsung Galaxy S8 and S20 5G Ivaylo Ivanov
2025-09-02 14:00 ` [PATCH v2 1/3] video: simplefb-client: switch to dev_get_resource Ivaylo Ivanov
2025-09-02 14:00 ` [PATCH v2 2/3] ARM: boards: add support for Samsung Galaxy S8 (dreamlte) Ivaylo Ivanov
2025-09-02 14:00 ` [PATCH v2 3/3] ARM: boards: add support for Samsung Galaxy S20 5G (x1s) Ivaylo Ivanov

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