Hi,

On 7/25/25 1:35 PM, Benjamin Hahn wrote:
Add new imx8mp-libra-fpsc board.
USB is not working yet, as the entry in the upstream devicetree is
missing.

Signed-off-by: Benjamin Hahn <b.h...@phytec.de>
---
  arch/arm/dts/imx8mp-libra-rdk-fpsc-u-boot.dtsi     |   78 +
  arch/arm/mach-imx/imx8m/Kconfig                    |    9 +
  board/phytec/imx8mp-libra-fpsc/Kconfig             |   16 +
  board/phytec/imx8mp-libra-fpsc/MAINTAINERS         |    8 +
  board/phytec/imx8mp-libra-fpsc/Makefile            |   10 +
  board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c |  114 ++
  .../phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.env |   30 +
  board/phytec/imx8mp-libra-fpsc/lpddr4_timing.c     | 1846 ++++++++++++++++++++
  board/phytec/imx8mp-libra-fpsc/spl.c               |  131 ++
  configs/imx8mp-libra-fpsc_defconfig                |  170 ++
  include/configs/imx8mp-libra-fpsc.h                |   27 +
  11 files changed, 2439 insertions(+)

diff --git a/arch/arm/dts/imx8mp-libra-rdk-fpsc-u-boot.dtsi 
b/arch/arm/dts/imx8mp-libra-rdk-fpsc-u-boot.dtsi
new file mode 100644
index 000000000000..8f0f86d9f09e
--- /dev/null
+++ b/arch/arm/dts/imx8mp-libra-rdk-fpsc-u-boot.dtsi
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 PHYTEC Messtechnik GmbH
+ */
+
+#include "imx8mp-u-boot.dtsi"
+
+/ {
+       wdt-reboot {
+               compatible = "wdt-reboot";
+               wdt = <&wdog1>;
+               bootph-pre-ram;
+       };
+};
+
+&reg_usdhc2_vmmc {
+       bootph-pre-ram;
+};
+
+&pinctrl_uart4 {
+       bootph-pre-ram;
+};
+
+&pinctrl_usdhc2 {
+       bootph-pre-ram;
+};
+
+&pinctrl_usdhc3 {
+       bootph-pre-ram;
+};
+
+&pinctrl_wdog {
+       bootph-pre-ram;
+};
+
+&gpio1 {
+       bootph-pre-ram;
+};
+
+&gpio2 {
+       bootph-pre-ram;
+};
+
+&gpio3 {
+       bootph-pre-ram;
+};
+
+&gpio4 {
+       bootph-pre-ram;
+};
+
+&gpio5 {
+       bootph-pre-ram;
+};
+
+&uart4 {
+       bootph-pre-ram;
+};
+
+&i2c1 {
+       bootph-pre-ram;
+};
+
+&pmic {
+       bootph-pre-ram;
+};
+
+&usdhc2 {
+       bootph-pre-ram;
+};
+
+&usdhc3 {
+       bootph-pre-ram;
+};
+
+&wdog1 {
+       bootph-pre-ram;
+};
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index 74416a788473..2e4b86473c63 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -345,6 +345,14 @@ config TARGET_PHYCORE_IMX8MP
        select IMX8M_LPDDR4
        imply OF_UPSTREAM
+config TARGET_IMX8MP_LIBRA_FPSC
+       bool "PHYTEC Libra FPSC i.MX 8M Plus"
+       select IMX8MP
+       select SUPPORT_SPL
+       select IMX8M_LPDDR4
+       help
+         i.MX8M Plus Libra is an FPSC SOM based on NXP i.MX8MP.
+
  config TARGET_IMX8MM_CL_IOT_GATE
        bool "CompuLab iot-gate-imx8"
        select IMX8MM
@@ -411,6 +419,7 @@ source "board/msc/sm2s_imx8mp/Kconfig"
  source "board/mntre/imx8mq_reform2/Kconfig"
  source "board/phytec/phycore_imx8mm/Kconfig"
  source "board/phytec/phycore_imx8mp/Kconfig"
+source "board/phytec/imx8mp-libra-fpsc/Kconfig"
  source "board/polyhex/imx8mp_debix_model_a/Kconfig"
  source "board/purism/librem5/Kconfig"
  source "board/ronetix/imx8mq-cm/Kconfig"
diff --git a/board/phytec/imx8mp-libra-fpsc/Kconfig 
b/board/phytec/imx8mp-libra-fpsc/Kconfig
new file mode 100644
index 000000000000..449bfda79632
--- /dev/null
+++ b/board/phytec/imx8mp-libra-fpsc/Kconfig
@@ -0,0 +1,16 @@
+if TARGET_IMX8MP_LIBRA_FPSC
+
+config SYS_BOARD
+       default "imx8mp-libra-fpsc"
+
+config SYS_VENDOR
+       default "phytec"
+
+config IMX_CONFIG
+       default "board/phytec/phycore_imx8mp/imximage-8mp-sd.cfg"

This does not seem to be right. I guess you want to have a copy of that file for this board.

+
+config SYS_CONFIG_NAME
+       default "imx8mp-libra-fpsc"
+
+source "board/phytec/common/Kconfig"
+endif
diff --git a/board/phytec/imx8mp-libra-fpsc/MAINTAINERS 
b/board/phytec/imx8mp-libra-fpsc/MAINTAINERS
new file mode 100644
index 000000000000..16b18b605e0d
--- /dev/null
+++ b/board/phytec/imx8mp-libra-fpsc/MAINTAINERS
@@ -0,0 +1,8 @@
+Libra-i.MX 8M Plus
+M:      Teresa Remmet <t.rem...@phytec.de>
+W:     
https://www.phytec.eu/en/produkte/system-on-modules/phycore-imx-8m-plus-fpsc/
+S:      Maintained
+F:      arch/arm/dts/imx8mp-libra-rdk-fpsc-u-boot.dtsi
+F:      board/phytec/imx8mp-libra-fpsc/
+F:      configs/imx8mp-libra-fpsc_defconfig
+F:      include/configs/imx8mp-libra-fpsc.h
diff --git a/board/phytec/imx8mp-libra-fpsc/Makefile 
b/board/phytec/imx8mp-libra-fpsc/Makefile
new file mode 100644
index 000000000000..8f956eb2ffbb
--- /dev/null
+++ b/board/phytec/imx8mp-libra-fpsc/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2025 PHYTEC Messtechnik GmbH
+
+obj-y += imx8mp-libra-fpsc.o
+
+ifdef CONFIG_SPL_BUILD
+obj-y += spl.o
+obj-$(CONFIG_IMX8M_LPDDR4) += lpddr4_timing.o
+endif
diff --git a/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c 
b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
new file mode 100644
index 000000000000..89b3b6f90ecb
--- /dev/null
+++ b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 PHYTEC Messtechnik GmbH
+ */
+
+#include <asm/arch/clock.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/global_data.h>
+#include <linux/io.h>
+#include <asm/mach-imx/boot_mode.h>
+#include <dwc3-uboot.h>
+#include <env.h>
+#include <init.h>
+#include <fdt_support.h>
+#include <jffs2/load_kernel.h>
+#include <miiphy.h>
+#include <mtd_node.h>
+#include <usb.h>
+#include <i2c.h>
+
+#if IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION)

There is not need for this guard. Please drop it.

+#include "../common/imx8m_som_detection.h"
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define EEPROM_ADDR            0x51
+
+#define TUSB_PORT_POL_CRTL_REG 0xB
+#define TUSB_CUSTOM_POL                BIT(7)
+#define TUSB_P0_POL            BIT(0)
+
+/*
+ * WORKAROUND for PCM-937-L 1618.0, 1618.1.
+ * USB HUB TUSB8042A has swapped upstream pin polarity.
+ * Set i2c registers to inform the hub that the lines
+ * are swapped.
+ */
+void tusb8042a_swap_lines(void)
+{
+       const u8 pol_swap_val = (TUSB_CUSTOM_POL | TUSB_P0_POL);
+       const int addr = 0x44;
+       struct udevice *dev = 0;
+       int ret = i2c_get_chip_for_busnum(2, addr, 1, &dev);
+
+       if (!ret)
+               dm_i2c_write(dev, TUSB_PORT_POL_CRTL_REG, &pol_swap_val, 1);
+       else
+               printf("TUSB8042A: Failed to fixup USB HUB.\n");
+}
+
+static int setup_fec(void)
+{
+       struct iomuxc_gpr_base_regs *gpr =
+               (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
+
+       /* Use 125M anatop REF_CLK1 for ENET1, not from external */
+       clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
+
+       return 0;
+}
+
+int board_init(void)
+{
+#if IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION)
+       int ret = phytec_eeprom_data_setup(NULL, 0, EEPROM_ADDR);

What is the point of reading out the EEPROM at this stage if you are not using the information? Drop it and add it later when you actually need it.

+
+       if (ret)
+               printf("%s: EEPROM data init failed\n", __func__);
+#endif
+       tusb8042a_swap_lines();
+
+       setup_fec();
+
+       return 0;
+}
+
+int board_mmc_get_env_dev(int devno)
+{
+       return devno;
+}
+
+int board_late_init(void)
+{
+       switch (get_boot_device()) {
+       case SD2_BOOT:
+               env_set_ulong("mmcdev", 1);
+               if (!strcmp(env_get("boot_targets"), 
env_get_default("boot_targets")))
+                       env_set("boot_targets", "mmc1 mmc2 ethernet");
+               break;
+       case MMC3_BOOT:
+               env_set_ulong("mmcdev", 2);
+               break;
+       case USB_BOOT:
+               printf("Detect USB boot. Will enter fastboot mode!\n");
+               if (!strcmp(env_get("bootcmd"), env_get_default("bootcmd")))
+                       env_set("bootcmd", "fastboot 0; bootflow scan -lb;");
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+int board_phys_sdram_size(phys_size_t *size)
+{
+       if (!size)
+               return -EINVAL;
+
+       *size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE + 
PHYS_SDRAM_2_SIZE);
+
+       return 0;
+}
diff --git a/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.env 
b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.env
new file mode 100644
index 000000000000..edcd05aedd2e
--- /dev/null
+++ b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.env
@@ -0,0 +1,30 @@
+bootmeths=script
+boot_targets=mmc2 mmc1 ethernet
+boot_script_dhcp=boot.scr.uimg
+bootenv_addr_r=0x49100000
+console=ttymxc3,115200
+emmc_dev=2  /* This is needed by built-in uuu flash scripts */
+fdt_addr_r=0x48000000
+fdtfile=CONFIG_DEFAULT_FDT_FILE
+fdtoverlay_addr_r=0x49000000
+fit_fdtconf=conf-imx8mp-libra-rdk-fpsc.dtb
+ip_dyn=no
+ipaddr=192.168.3.11
+kernel_addr_r=0x5A080000
+kernel_comp_addr_r=0x60000000
+kernel_comp_size=0x2000000
+mmcautodetect=yes
+mmcdev=CONFIG_SYS_MMC_ENV_DEV
+mmcpart=1
+mmcroot=2
+netmask=255.225.255.0
+nfsroot=/srv/nfs
+no_bootenv=0
+no_extensions=0
+pxefile_addr_r=0x58600000
+ramdisk_addr_r=0x5e000000
+sd_dev=1    /* This is needed by built-in uuu flash scripts */

Can you bring both variables next to each other and use only a single comment line?

+script_offset_f=0x400000
+script_size_f=0x2000
+scriptaddr=0x58500000
+serverip=192.168.3.10
diff --git a/board/phytec/imx8mp-libra-fpsc/lpddr4_timing.c 
b/board/phytec/imx8mp-libra-fpsc/lpddr4_timing.c
new file mode 100644
index 000000000000..dd5b4ad8347a
--- /dev/null

<snip>

+++ b/board/phytec/imx8mp-libra-fpsc/spl.c
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2025 PHYTEC Messtechnik GmbH
+ */
+
+#include <config.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/ddr.h>
+#include <asm/arch/imx8mp_pins.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/global_data.h>
+#include <asm/mach-imx/boot_mode.h>
+#include <asm/mach-imx/gpio.h>
+#include <asm/mach-imx/mxc_i2c.h>
+#include <asm/mach-imx/iomux-v3.h>
+#include <hang.h>
+#include <init.h>
+#include <log.h>
+#include <power/pmic.h>
+#include <power/pca9450.h>
+#include <spl.h>
+
+#include "../common/imx8m_som_detection.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define EEPROM_ADDR            0x51

Why can't we have this defined in imx8m_som_detection.h?

Regards,
Wadim

Reply via email to