Skip to contentSkip to conversation

Add imx93-var-som support

PATCH In review Mathieu Othacehe 2 participants 5 messages Dec 9, 2023 – Dec 28, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add imx93-var-som support

Add support for the Variscite VAR-SOM-IMX93 evaluation kit. The SoM consists of an NXP iMX93 dual A55 CPU. The SoM is mounted on a Variscite Symphony SBC.

---
 arch/arm/dts/Makefile                         |    3 +-
 .../dts/imx93-var-som-symphony-u-boot.dtsi    |  152 ++
 arch/arm/dts/imx93-var-som-symphony.dts       |  223 +++
 arch/arm/dts/imx93-var-som.dtsi               |  205 +++
 arch/arm/include/asm/arch-imx9/clock.h        |    1 +
 arch/arm/mach-imx/imx9/Kconfig                |    6 +
 board/variscite/common/Kconfig                |    6 +
 board/variscite/common/eth.c                  |   59 +
 board/variscite/common/eth.h                  |   12 +
 board/variscite/common/extcon-ptn5150.c       |  137 ++
 board/variscite/common/extcon-ptn5150.h       |   40 +
 board/variscite/common/imx9_eeprom.c          |  188 +++
 board/variscite/common/imx9_eeprom.h          |   83 +
 board/variscite/common/mmc.c                  |   47 +
 board/variscite/imx93_var_som/Kconfig         |   14 +
 board/variscite/imx93_var_som/Makefile        |   18 +
 board/variscite/imx93_var_som/imx93_var_som.c |  147 ++
 .../variscite/imx93_var_som/lpddr4x_timing.c  | 1489 +++++++++++++++++
 board/variscite/imx93_var_som/spl.c           |  146 ++
 configs/imx93_var_som_defconfig               |  161 ++
 include/configs/imx93_var_som.h               |  175 ++
 21 files changed, 3311 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx93-var-som-symphony-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx93-var-som-symphony.dts
 create mode 100644 arch/arm/dts/imx93-var-som.dtsi
 create mode 100644 board/variscite/common/Kconfig
 create mode 100644 board/variscite/common/eth.c
 create mode 100644 board/variscite/common/eth.h
 create mode 100644 board/variscite/common/extcon-ptn5150.c
 create mode 100644 board/variscite/common/extcon-ptn5150.h
 create mode 100644 board/variscite/common/imx9_eeprom.c
 create mode 100644 board/variscite/common/imx9_eeprom.h
 create mode 100644 board/variscite/common/mmc.c
 create mode 100644 board/variscite/imx93_var_som/Kconfig
 create mode 100644 board/variscite/imx93_var_som/Makefile
 create mode 100644 board/variscite/imx93_var_som/imx93_var_som.c
 create mode 100644 board/variscite/imx93_var_som/lpddr4x_timing.c
 create mode 100644 board/variscite/imx93_var_som/spl.c
 create mode 100644 configs/imx93_var_som_defconfig
 create mode 100644 include/configs/imx93_var_som.h
arch/arm/dts/Makefile +2 -1
index 85fd5b1157b..e6b604a2232 100644
@@ -1057,7 +1057,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
 	imx8mq-librem5-r4.dtb
 
 dtb-$(CONFIG_ARCH_IMX9) += \
-	imx93-11x11-evk.dtb
+	imx93-11x11-evk.dtb \
+	imx93-var-som-symphony.dtb
 
 dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb \
 	imxrt1020-evk.dtb \
arch/arm/dts/imx93-var-som-symphony-u-boot.dtsi new file +152 -0

152 lines not on this page · raw message

arch/arm/dts/imx93-var-som-symphony.dts new file +223 -0

223 lines not on this page · raw message

arch/arm/dts/imx93-var-som.dtsi new file +205 -0

205 lines not on this page · raw message

arch/arm/include/asm/arch-imx9/clock.h +1 -0
index 1169ffd74d3..1ce6ac4c3a8 100644
@@ -222,6 +222,7 @@ u32 mxc_get_clock(enum mxc_clock clk);
 void dram_pll_init(ulong pll_val);
 void dram_enable_bypass(ulong clk_val);
 void dram_disable_bypass(void);
+void set_arm_core_max_clk(void);
 
 int configure_intpll(enum ccm_clk_src pll, u32 freq);
 
arch/arm/mach-imx/imx9/Kconfig +6 -0
index c51f80f311a..f532d98bd41 100644
@@ -31,9 +31,15 @@ config TARGET_IMX93_11X11_EVK
 	bool "imx93_11x11_evk"
 	select IMX93
 
+config TARGET_IMX93_VAR_SOM
+	bool "imx93_var_som"
+	select IMX93
+	select IMX9_LPDDR4X
+
 endchoice
 
 source "board/freescale/imx93_evk/Kconfig"
+source "board/variscite/imx93_var_som/Kconfig"
 
 endif
 
board/variscite/common/Kconfig new file +6 -0
new file mode 100644
index 00000000000..fffa3a5c530
@@ -0,0 +1,6 @@
+config EXTCON_PTN5150
+	bool "NXP PTN5150 CC LOGIC USB EXTCON support"
+	default n
+	help
+	  Say Y here to enable support for USB peripheral and USB host
+	  detection by NXP PTN5150 CC (Configuration Channel) logic chip.
board/variscite/common/eth.c new file +59 -0

59 lines not on this page · raw message

board/variscite/common/eth.h new file +12 -0
new file mode 100644
index 00000000000..a335c08b8ce
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2023 Variscite Ltd.
+ *
+ */
+
+#ifndef _MX9_ETH_H_
+#define _MX9_ETH_H_
+
+int var_setup_mac(struct var_eeprom *eeprom);
+
+#endif /* _MX9_ETH_H_ */
board/variscite/common/extcon-ptn5150.c new file +137 -0

137 lines not on this page · raw message

board/variscite/common/extcon-ptn5150.h new file +40 -0
new file mode 100644
index 00000000000..69917747c7a
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Driver for NXP PTN5150 CC LOGIC USB EXTCON support
+ *
+ * Copyright 2022 Variscite Ltd.
+ * Author: Nate Drude <[email protected]>
+ */
+#ifndef __EXTCON_PTN5150_H
+#define __EXTCON_PTN5150_H
+
+#include <linux/bitfield.h>
+#include <usb.h>
+
+#define PTN5150_ID_REG				0x1
+#define   PTN5150_ID_VENDOR_MASK		GENMASK(2, 0)
+#define   PTN5150_ID_VERSION_MASK		GENMASK(7, 3)
+
+#define PTN5150_CC_STATUS_REG			0x4
+#define   PTN5150_CC_STATUS_ATTACH_MASK		GENMASK(4, 2)
+#define   PTN5150_CC_STATUS_NOT_CONNECTED	0x0
+#define   PTN5150_CC_STATUS_DFP			0x1
+#define   PTN5150_CC_STATUS_UFP			0x2
+
+struct extcon_ptn5150_i2c_cfg {
+	int bus;
+	int addr;
+};
+
+struct extcon_ptn5150 {
+	struct extcon_ptn5150_i2c_cfg i2c_cfg;
+	struct udevice *i2c_dev;
+};
+
+int extcon_ptn5150_setup(struct extcon_ptn5150 *port);
+int extcon_ptn5150_parse_fdt(struct extcon_ptn5150 *port);
+int extcon_ptn5150_phy_mode(struct extcon_ptn5150 *port);
+int extcon_ptn5150_cc_status(struct extcon_ptn5150 *port);
+int extcon_ptn5150_init(struct extcon_ptn5150 *port);
+
+#endif /* __EXTCON_PTN5150_H */
board/variscite/common/imx9_eeprom.c new file +188 -0

188 lines not on this page · raw message

board/variscite/common/imx9_eeprom.h new file +83 -0

83 lines not on this page · raw message

board/variscite/common/mmc.c new file +47 -0

47 lines not on this page · raw message

board/variscite/imx93_var_som/Kconfig new file +14 -0
new file mode 100644
index 00000000000..34e9bf23a83
@@ -0,0 +1,14 @@
+if TARGET_IMX93_VAR_SOM
+
+config SYS_BOARD
+	default "imx93_var_som"
+
+config SYS_VENDOR
+	default "variscite"
+
+config SYS_CONFIG_NAME
+	default "imx93_var_som"
+
+source "board/variscite/common/Kconfig"
+
+endif
board/variscite/imx93_var_som/Makefile new file +18 -0
new file mode 100644
index 00000000000..bb2383c18da
@@ -0,0 +1,18 @@
+#
+# Copyright 2022 NXP
+# Copyright 2023 Variscite Ltd.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-y += imx93_var_som.o
+obj-$(CONFIG_TARGET_IMX93_VAR_SOM) += ../common/imx9_eeprom.o
+
+ifdef CONFIG_SPL_BUILD
+obj-y += spl.o
+obj-$(CONFIG_TARGET_IMX93_VAR_SOM) += lpddr4x_timing.o
+else
+obj-y += ../common/eth.o
+obj-y += ../common/mmc.o
+obj-$(CONFIG_EXTCON_PTN5150) += ../common/extcon-ptn5150.o
+endif
board/variscite/imx93_var_som/imx93_var_som.c new file +147 -0

147 lines not on this page · raw message

board/variscite/imx93_var_som/lpddr4x_timing.c new file +1489 -0

1,489 lines not on this page · raw message

board/variscite/imx93_var_som/spl.c new file +146 -0

146 lines not on this page · raw message

configs/imx93_var_som_defconfig new file +161 -0

3 lines not on this page · raw message

include/configs/imx93_var_som.h new file +175 -0

175 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

reviewer
#1 lore raw

Hi Mathieu,

Quoted 39 lines · Mathieu Othacehe

Add support for the Variscite VAR-SOM-IMX93 evaluation kit. The SoM consists of an NXP iMX93 dual A55 CPU. The SoM is mounted on a Variscite Symphony SBC.

---
 arch/arm/dts/Makefile                         |    3 +-
 .../dts/imx93-var-som-symphony-u-boot.dtsi    |  152 ++
 arch/arm/dts/imx93-var-som-symphony.dts       |  223 +++
 arch/arm/dts/imx93-var-som.dtsi               |  205 +++
 arch/arm/include/asm/arch-imx9/clock.h        |    1 +
 arch/arm/mach-imx/imx9/Kconfig                |    6 +
 board/variscite/common/Kconfig                |    6 +
 board/variscite/common/eth.c                  |   59 +
 board/variscite/common/eth.h                  |   12 +
 board/variscite/common/extcon-ptn5150.c       |  137 ++
 board/variscite/common/extcon-ptn5150.h       |   40 +
 board/variscite/common/imx9_eeprom.c          |  188 +++
 board/variscite/common/imx9_eeprom.h          |   83 +
 board/variscite/common/mmc.c                  |   47 +
 board/variscite/imx93_var_som/Kconfig         |   14 +
 board/variscite/imx93_var_som/Makefile        |   18 +
 board/variscite/imx93_var_som/imx93_var_som.c |  147 ++
 .../variscite/imx93_var_som/lpddr4x_timing.c  | 1489 +++++++++++++++++
 board/variscite/imx93_var_som/spl.c           |  146 ++
 configs/imx93_var_som_defconfig               |  161 ++
 include/configs/imx93_var_som.h               |  175 ++
 21 files changed, 3311 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx93-var-som-symphony-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx93-var-som-symphony.dts
 create mode 100644 arch/arm/dts/imx93-var-som.dtsi
 create mode 100644 board/variscite/common/Kconfig
 create mode 100644 board/variscite/common/eth.c
 create mode 100644 board/variscite/common/eth.h
 create mode 100644 board/variscite/common/extcon-ptn5150.c
 create mode 100644 board/variscite/common/extcon-ptn5150.h
 create mode 100644 board/variscite/common/imx9_eeprom.c
 create mode 100644 board/variscite/common/imx9_eeprom.h
Quoted 8 lines
 create mode 100644 board/variscite/common/mmc.c
 create mode 100644 board/variscite/imx93_var_som/Kconfig
 create mode 100644 board/variscite/imx93_var_som/Makefile
 create mode 100644 board/variscite/imx93_var_som/imx93_var_som.c
 create mode 100644 board/variscite/imx93_var_som/lpddr4x_timing.c
 create mode 100644 board/variscite/imx93_var_som/spl.c
 create mode 100644 configs/imx93_var_som_defconfig
 create mode 100644 include/configs/imx93_var_som.h

Please add a MAINTAINERS file for this board.

It would also be helpful to add doc/board/variscite/imx93_var_som.rst that explains
how to build U-Boot for this board, how to get the firmware, ATF, binaries, etc, and how to flash it to the boot medium.

arch/arm/dts/imx93-var-som-symphony.dts

Quoted 2 lines
arch/arm/dts/imx93-var-som-symphony.dts new file +0 -0

Please also submit the imx93-var-som-symphony.dts support to Linux so that it can get reviewed by the DT folks.

arch/arm/dts/imx93-var-som-symphony.dts line 2

Quoted 4 lines

+++ b/board/variscite/common/Kconfig

arch/arm/dts/imx93-var-som-symphony.dts new file +2 -0
@@ -0,0 +1,6 @@
+config EXTCON_PTN5150
+       bool "NXP PTN5150 CC LOGIC USB EXTCON support"

This should be converted to a proper driver.

To not block the board support, I suggest sending a v2 without PTN5150 support for now.

arch/arm/dts/imx93-var-som-symphony.dts line 3

Quoted 1 line
arch/arm/dts/imx93-var-som-symphony.dts new file +1 -0
+       default n

'default n' is already the default. Please drop it.

Quoted 6 lines
board/variscite/common/eth.c new file +3 -0
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2023 Variscite Ltd.

board/variscite/common/eth.c line 13

Quoted 10 lines
board/variscite/common/eth.c new file +10 -0
+ */
+#include <common.h>
+#include <net.h>
+#include <miiphy.h>
+#include <env.h>
+#include "../common/imx9_eeprom.h"
+
+#define CHAR_BIT 8
+       if (!is_valid_ethaddr(enetaddr))
+               return -1;

return -EINVAL;

board/variscite/common/eth.c line 19

Quoted 6 lines
board/variscite/common/eth.c new file +6 -0
+/* Returns carrier board revision string via 'rev' argument.
+ * For legacy carrier board revisions the "legacy" string is returned.
+ * For new carrier board revisions the actual carrier revision is returned.
+ * Symphony-Board 1.4 and below are legacy, 1.4a and above are new.
+ * DT8MCustomBoard 1.4 and below are legacy, 2.0 and above are new.
+ */

The correct style for multi-line comment is:

/*
* Line 1 bla bla
* line 2
*
*/

board/variscite/common/eth.c line 22

Quoted 3 lines
board/variscite/common/eth.c new file +3 -0
+
+               /* 0.9v
+                */

Same here. Either remove or provide a better comment.

board/variscite/common/eth.c line 26

Quoted 4 lines
board/variscite/common/eth.c new file +4 -0
+               pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS0, 0x18);
+               pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x18);
+
+               /* set standby voltage to 0.65v */

0.65V, not v.

Quoted 5 lines
board/variscite/common/eth.c new file +5 -0
+/* Initial environment variables */
+#define CFG_EXTRA_ENV_SETTINGS         \
+       BOOTENV \
+       AHAB_ENV \
+       "initrd_addr=0x83800000\0" \

board/variscite/common/eth.c line 41

Quoted 10 lines
board/variscite/common/eth.c new file +10 -0
+       "emmc_dev=0\0"\
+       "sd_dev=1\0" \
+       "scriptaddr=0x83500000\0" \
+       "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+       "image=Image.gz\0" \
+       "img_addr=0x82000000\0" \
+       "splashimage=0x90000000\0" \
+       "console=ttyLP0,115200 earlycon\0" \
+       "fdt_addr_r=0x83000000\0"                       \
+       "fdt_addr=0x83000000\0"                 \

...

The recommendation for the new boards is to add the environment to an env file. In this case, it would be board/variscite/imx93_var_som/imx93_var_som.env.

See board/cloos/imx8mm_phg/imx8mm_phg.env as reference.

board/variscite/common/eth.c line 43

Quoted 2 lines
board/variscite/common/eth.c new file +2 -0
+
+/* Link Definitions */

Maybe just drop this comment.

Quoted 6 lines
board/variscite/common/eth.c new file +6 -0
+#define CFG_SYS_INIT_RAM_ADDR        0x80000000
+#define CFG_SYS_INIT_RAM_SIZE        0x200000
+
+#define CFG_SYS_SDRAM_BASE           0x80000000
+#define PHYS_SDRAM                      0x80000000
+#define PHYS_SDRAM_SIZE                        0x80000000 /* 2GB DDR */

board/variscite/common/eth.c line 59

Quoted 10 lines
board/variscite/common/eth.c new file +10 -0
+
+#define DEFAULT_SDRAM_SIZE             (512 * SZ_1M) /* 512MB Minimum DDR4, see get_dram_size */
+#define VAR_EEPROM_DRAM_START           (PHYS_SDRAM + (DEFAULT_SDRAM_SIZE >> 1))
+#define VAR_SOM_EEPROM_I2C_NAME "i2c@42530000"
+#define VAR_CARRIER_EEPROM_I2C_NAME "i2c@44340000"
+
+#define CFG_SYS_FSL_USDHC_NUM  2
+
+/* Using ULP WDOG for reset */
+#define WDOG_BASE_ADDR          WDG3_BASE_ADDR

Is this needed now that we use DM?

board/variscite/common/eth.c

Quoted 4 lines
board/variscite/common/eth.c new file +4 -0
+
+#if defined(CONFIG_CMD_NET)
+#define CFG_FEC_XCV_TYPE             RGMII
+#define CFG_FEC_MXC_PHYADDR          5

Same here.

Quoted 1 line

+#define DWC_NET_PHYADDR 0

Is this needed?

#2 lore raw

Hello Fabio,

Thanks for the review!

Quoted 4 lines

It would also be helpful to add doc/board/variscite/imx93_var_som.rst that explains
how to build U-Boot for this board, how to get the firmware, ATF, binaries, etc, and how to flash it to the boot medium.

For now, I am testing the bootloaders I produce using those instructions:
https://variwiki.com/index.php?title=Yocto_Build_U-Boot&release=mx93-yocto-mickledore-6.1.36_2.1.0-v1.1

I understand that it would be nice to have u-boot do the image construction with the firmware, ATF and so on, like implemented on imx8.

Do you think that it could be done in a follow-up patch, once imx93-var-som support is merged?

Quoted 2 lines

Please also submit the imx93-var-som-symphony.dts support to Linux so that it can get reviewed by the DT folks.

Done here:
https://lore.kernel.org/linux-devicetree/[email protected]/T/#t

Quoted 2 lines

To not block the board support, I suggest sending a v2 without PTN5150 support for now.

OK.

Quoted 4 lines

include/configs/imx93_var_som.h line 163

Quoted 2 lines
include/configs/imx93_var_som.h new file +2 -0
+/* Using ULP WDOG for reset */
+#define WDOG_BASE_ADDR          WDG3_BASE_ADDR

Is this needed now that we use DM?

That specific define is needed as the ulp_wdog driver seems to require it. I removed all the other unneeded defines in v2.

Thanks,

Mathieu

reviewer
#3 lore raw

Hi Mathieu,

Quoted 7 lines · Mathieu Othacehe

For now, I am testing the bootloaders I produce using those instructions:
https://variwiki.com/index.php?title=Yocto_Build_U-Boot&release=mx93-yocto-mickledore-6.1.36_2.1.0-v1.1

I understand that it would be nice to have u-boot do the image construction with the firmware, ATF and so on, like implemented on imx8.

Please give it a try to add binman support to build the U-Boot binary for imx93.

I am adding Peng Fan here in case he could help.

Unfortunately, I don't have any imx93 board to help with this.

reviewer
#4 lore raw

[Adding Peng]

Quoted 18 lines · Fabio Estevam

Hi Mathieu,

Quoted 7 lines · Mathieu Othacehe

For now, I am testing the bootloaders I produce using those instructions:
https://variwiki.com/index.php?title=Yocto_Build_U-Boot&release=mx93-yocto-mickledore-6.1.36_2.1.0-v1.1

I understand that it would be nice to have u-boot do the image construction with the firmware, ATF and so on, like implemented on imx8.

Please give it a try to add binman support to build the U-Boot binary for imx93.

I am adding Peng Fan here in case he could help.

Unfortunately, I don't have any imx93 board to help with this.