Skip to contentSkip to conversation

imx: add i.MX95 support

PATCH Superseded Alice Guo 5 participants 60 messages Jan 15, 2025 – Mar 21, 2025

Subsystems (8)

v4 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Alice Guo

author
#0 lore raw

v4 cover imx: add i.MX95 support

Changes in v4:
- split the SCMI pin controller driver and SCMI agent code
- update i.MX95 SoC and clock related code, board basic support code and so on according to comments
- move the function that loads ATF and tee.bin to spl_imx_container.c
- add document for i.MX95 image container format

---
Alice Guo (8):
pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol
firmware: scmi: add pin control protocol support to SCMI agent
clk: scmi: check the clock state/parent/rate control permissions
sandbox: add SCMI clock control permissions to sandbox
imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95
binman: add a new entry type for packing DDR PHY firmware images
tools: imx8image: add i.MX95 support
doc: imx: add document for i.MX95 Image Container Format

Peng Fan (6):
mailbox: add i.MX95 Messaging Unit (MU) driver
scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data
scmi_protocols: add SCMI Performance domain management protocol message IDs
clk: scmi: add the command CLOCK_PARENT_SET
scmi: add the macro SCMI_MSG
imx9: scmi: add i.MX95 SoC and clock related code

Teo Hall (1):
imx: add V2X container support on i.MX95

Viorel Suman (1):
firmware: scmi: smt: Interrupt communication enable

Ye Li (4):
scmi_protocols: update struct scmi_base_discover_list_protocols_out
spl: imx: use trampoline buffer to load images to secure region
imx9: add i.MX95 Kconfig and Makefile
imx95_evk: add i.MX95 19x19 EVK board basic support

 MAINTAINERS                                   |   1 +
 arch/arm/dts/imx95-19x19-evk-u-boot.dtsi      |  68 +++
 arch/arm/dts/imx95-u-boot.dtsi                | 157 +++++
 arch/arm/include/asm/arch-imx/cpu.h           |   2 +
 arch/arm/include/asm/arch-imx9/clock.h        |  10 +
 arch/arm/include/asm/arch-imx9/imx-regs.h     |   5 +
 arch/arm/include/asm/arch-imx9/sys_proto.h    |   1 +
 arch/arm/include/asm/mach-imx/sys_proto.h     |  39 ++
 arch/arm/mach-imx/Kconfig                     |   2 +-
 arch/arm/mach-imx/image-container.c           |  63 +-
 arch/arm/mach-imx/imx9/Kconfig                |  14 +
 arch/arm/mach-imx/imx9/Makefile               |   9 +-
 arch/arm/mach-imx/imx9/scmi/Makefile          |   6 +
 arch/arm/mach-imx/imx9/scmi/clock.c           | 105 ++++
 arch/arm/mach-imx/imx9/scmi/clock_scmi.c      | 135 +++++
 arch/arm/mach-imx/imx9/scmi/container.cfg     |  10 +
 arch/arm/mach-imx/imx9/scmi/imximage.cfg      |  15 +
 arch/arm/mach-imx/imx9/scmi/soc.c             | 827 ++++++++++++++++++++++++++
 arch/sandbox/include/asm/scmi_test.h          |   4 +-
 board/freescale/imx95_evk/Kconfig             |  12 +
 board/freescale/imx95_evk/MAINTAINERS         |   6 +
 board/freescale/imx95_evk/Makefile            |  11 +
 board/freescale/imx95_evk/imx95_19x19_evk.env |  90 +++
 board/freescale/imx95_evk/imx95_evk.c         |  54 ++
 board/freescale/imx95_evk/spl.c               |  72 +++
 common/spl/Kconfig                            |   6 +
 common/spl/spl_imx_container.c                |  41 +-
 configs/imx95_19x19_evk_defconfig             | 177 ++++++
 doc/board/nxp/imx95_evk.rst                   | 114 ++++
 doc/board/nxp/index.rst                       |   1 +
 doc/imx/imx95_container.txt                   | 136 +++++
 drivers/clk/clk_scmi.c                        | 191 +++++-
 drivers/firmware/scmi/Kconfig                 |   6 +
 drivers/firmware/scmi/sandbox-scmi_agent.c    |  56 +-
 drivers/firmware/scmi/scmi_agent-uclass.c     |  11 +
 drivers/firmware/scmi/smt.c                   |   3 +
 drivers/firmware/scmi/smt.h                   |  10 +
 drivers/mailbox/Kconfig                       |   7 +
 drivers/mailbox/Makefile                      |   1 +
 drivers/mailbox/imx-mailbox.c                 | 417 +++++++++++++
 drivers/pinctrl/nxp/Kconfig                   |  13 +
 drivers/pinctrl/nxp/Makefile                  |   1 +
 drivers/pinctrl/nxp/pinctrl-imx.c             |   7 +-
 drivers/pinctrl/nxp/pinctrl-imx.h             |  11 +
 drivers/pinctrl/nxp/pinctrl-scmi.c            | 136 +++++
 include/configs/imx95_evk.h                   |  27 +
 include/imx8image.h                           |  19 +-
 include/scmi_agent-uclass.h                   |   2 +
 include/scmi_agent.h                          |  11 +
 include/scmi_protocols.h                      | 105 +++-
 tools/binman/entries.rst                      |  10 +
 tools/binman/etype/nxp_header_ddrfw.py        |  32 +
 tools/binman/ftest.py                         |  11 +
 tools/binman/test/346_nxp_ddrfw_imx95.dts     |  24 +
 tools/imx8image.c                             | 143 ++++-
 tools/imx9_image.sh                           |   8 +
 56 files changed, 3390 insertions(+), 65 deletions(-)

---
base-commit: d6da3dbaef57fc1d319b6b552efa009e2489d7d9
change-id: 20250114-imx95-ac8bbccd71e5

Best regards,

Signature · 1 line
Alice Guo <[email protected]>
author
#1 lore raw

PATCH v4 1/20 mailbox: add i.MX95 Messaging Unit (MU) driver

From: Peng Fan <[email protected]>

i.MX95 Messaging Unit (MU) enables 2 processors on a chip to communicate and coordinate by passing messages (e.g. frame information, event notices and requests) through the MU interface. This patch provides a driver for i.MX95 MU using the common mailbox framework. Currently, SCMI exchanges on i.MX95 uses a mailbox transport with SMT format, and the hardware used is this MU.

This id ported from Linux (v6.12.8) driver
drivers/mailbox/imx-mailbox.c.

---
 MAINTAINERS                   |   1 +
 drivers/mailbox/Kconfig       |   7 +
 drivers/mailbox/Makefile      |   1 +
 drivers/mailbox/imx-mailbox.c | 417 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 426 insertions(+)
MAINTAINERS +1 -0
index ba31f86feb6da266cddd160a041d0594ac86d274..5ab2b72d0f93afaf70c4c2dcb8fc48210683b749 100644
@@ -313,6 +313,7 @@ F:	board/freescale/*mx*/
 F:	board/freescale/common/
 F:	common/spl/spl_imx_container.c
 F:	doc/imx/
+F:	drivers/mailbox/imx-mailbox.c
 F:	drivers/serial/serial_mxc.c
 F:	include/imx_container.h
 
drivers/mailbox/Kconfig +7 -0
index 67d5ac1a74228ccd82b2725c0bb745354d099948..4d9f004ebad7f57034a6cdae3bff9645fa0ee67d 100644
@@ -21,6 +21,13 @@ config APPLE_MBOX
 	  such as the System Management Controller (SMC) and NVMe and this
 	  driver is required to get that functionality up and running.
 
+config IMX_MU_MBOX
+	bool "Enable i.MX MU MBOX support"
+	depends on DM_MAILBOX
+	help
+	  Enable support for i.MX Messaging Unit for communication with other
+	  processors on the SoC using mailbox interface
+
 config SANDBOX_MBOX
 	bool "Enable the sandbox mailbox test driver"
 	depends on DM_MAILBOX && SANDBOX
drivers/mailbox/Makefile +1 -0
index 6072fa1956b793636c35aa0d1419c9dcaae27095..574add60005fe73d2beba715a12e0157fe4b0552 100644
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_$(XPL_)DM_MAILBOX) += mailbox-uclass.o
 obj-$(CONFIG_APPLE_MBOX) += apple-mbox.o
+obj-$(CONFIG_IMX_MU_MBOX) += imx-mailbox.o
 obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox.o
 obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox-test.o
 obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o
drivers/mailbox/imx-mailbox.c new file +417 -0

417 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v4 01/20] mailbox: add i.MX95 Messaging Unit (MU) driver

Quoted 2 lines · Alice Guo

This id ported from Linux (v6.12.8) driver
drivers/mailbox/imx-mailbox.c.

'id' -> 'is' typo .

It is better to include the commit SHA from which this was ported over too, so the follow up patches in Linux can be easily ported over as they appear. If the last commit SHA from which this was ported over is known, then it is possible to do e.g. the following to find out any new commits:

linux$ git log 39d7d6177f0c..origin/master -- drivers/mailbox/imx-mailbox.c

"$ git log v6.12.8 -- drivers/mailbox/imx-mailbox.c" indicates this is the latest imx-mailbox.c commit in Linux 6.12.8:

39d7d6177f0c ("mailbox: imx: use device name in interrupt name")

[...]

Quoted 15 lines
drivers/mailbox/imx-mailbox.c new file +15 -0
+#define IMX_MU_xSR_GIPn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(28 + (3 - (x))))
+#define IMX_MU_xSR_RFn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x))))
+#define IMX_MU_xSR_TEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(20 + (3 - (x))))
+
+/* General Purpose Interrupt Enable */
+#define IMX_MU_xCR_GIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(28 + (3 - (x))))
+/* Receive Interrupt Enable */
+#define IMX_MU_xCR_RIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x))))
+/* Transmit Interrupt Enable */
+#define IMX_MU_xCR_TIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(20 + (3 - (x))))
+/* General Purpose Interrupt Request */
+#define IMX_MU_xCR_GIRn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(16 + (3 - (x))))
+/* MU reset */
+#define IMX_MU_xCR_RST(type)	(type & IMX_MU_V2 ? BIT(0) : BIT(5))
+#define IMX_MU_xSR_RST(type)	(type & IMX_MU_V2 ? BIT(0) : BIT(7))

[...]

drivers/mailbox/imx-mailbox.c line 352

Quoted 11 lines
drivers/mailbox/imx-mailbox.c new file +11 -0
+static const struct imx_mu_dcfg imx_mu_cfg_imx95 = {
+	.tx	= imx_mu_generic_tx,
+	.rxdb	= imx_mu_generic_rxdb,
+	.init	= imx_mu_init_generic,
+	.of_xlate = imx_mu_generic_of_xlate,
+	.type	= IMX_MU_V2,
+	.xTR	= 0x200,
+	.xRR	= 0x280,
+	.xSR	= {0xC, 0x118, 0x124, 0x12C},
+	.xCR	= {0x8, 0x110, 0x114, 0x120, 0x128},
+};

[...]

I would suggest these changes:

- Add the remaining SoC support, the plumbing is already there, all the conditional bits are already there for MU v1/v2 , so fill in the data for at least the V1 MU SoCs.

- Split this patch into separate submission or series, so it can get reviewed separately and land faster, possibly before the MX95 support gets fully sorted out.

author
#3 lore raw

PATCH v4 2/20 firmware: scmi: smt: Interrupt communication enable

In reply to Alice Guo

From: Viorel Suman <[email protected]>

i.MX95 System Manager uses interrupt driven communication which requires the caller to set Bit[0] of channel flags to 1. When transmission completes and the previous general purpose interrupt has been processed by the other core, i.MX95 System Manager will set General Purpose Interrupt Control Register (GCR). U-Boot polls General-purpose Status (GSR) to check if the operation is finished.

---
 drivers/firmware/scmi/Kconfig |  6 ++++++
 drivers/firmware/scmi/smt.c   |  3 +++
 drivers/firmware/scmi/smt.h   | 10 ++++++++++
 3 files changed, 19 insertions(+)
drivers/firmware/scmi/Kconfig +6 -0
index 8cf85f0d7a12c9e58dc249539727081ec25dd7b3..eb62b88615b5cd95635571556e79ba40d1a387e9 100644
@@ -41,3 +41,9 @@ config SCMI_AGENT_OPTEE
 	help
 	  Enable the SCMI communication channel based on OP-TEE transport
 	  for compatible "linaro,scmi-optee".
+
+config SCMI_TRANSPORT_SMT_INTR
+	bool
+	depends on SCMI_FIRMWARE
+	help
+	  Enable interrupt communication of shared memory based transport.
drivers/firmware/scmi/smt.c +3 -0
index 67d2f45002490ab64a6bc997eda93a8f4681d99b..ee7ae5d50b226b92a3961c181de83c730a621401 100644
@@ -48,6 +48,9 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
 	if (!smt->buf)
 		return -ENOMEM;
 
+	if (IS_ENABLED(CONFIG_SCMI_TRANSPORT_SMT_INTR))
+		scmi_smt_enable_intr(smt, true);
+
 #ifdef CONFIG_ARM
 	if (dcache_status())
 		mmu_set_region_dcache_behaviour(ALIGN_DOWN((uintptr_t)smt->buf, MMU_SECTION_SIZE),
drivers/firmware/scmi/smt.h +10 -0
index 9d669a6c922666c48e7dce4c0affd7b47cb137e4..768b0f4c8a8d1cc7966530e724d278d72c2a167b 100644
@@ -84,6 +84,16 @@ static inline void scmi_smt_put_channel(struct scmi_smt *smt)
 	hdr->channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR;
 }
 
+static inline void scmi_smt_enable_intr(struct scmi_smt *smt, bool enable)
+{
+	struct scmi_smt_header *hdr = (void *)smt->buf;
+
+	if (enable)
+		hdr->flags |= SCMI_SHMEM_FLAG_INTR_ENABLED;
+	else
+		hdr->flags &= ~SCMI_SHMEM_FLAG_INTR_ENABLED;
+}
+
 int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt);
 
 /*
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v4 02/20] firmware: scmi: smt: Interrupt communication enable

Quoted 51 lines · Alice Guo

From: Viorel Suman <[email protected]>

i.MX95 System Manager uses interrupt driven communication which requires the caller to set Bit[0] of channel flags to 1. When transmission completes and the previous general purpose interrupt has been processed by the other core, i.MX95 System Manager will set General Purpose Interrupt Control Register (GCR). U-Boot polls General-purpose Status (GSR) to check if the operation is finished.

---
  drivers/firmware/scmi/Kconfig |  6 ++++++
  drivers/firmware/scmi/smt.c   |  3 +++
  drivers/firmware/scmi/smt.h   | 10 ++++++++++
  3 files changed, 19 insertions(+)
drivers/firmware/scmi/Kconfig +6 -0
index 8cf85f0d7a12c9e58dc249539727081ec25dd7b3..eb62b88615b5cd95635571556e79ba40d1a387e9 100644
@@ -41,3 +41,9 @@ config SCMI_AGENT_OPTEE
  	help
  	  Enable the SCMI communication channel based on OP-TEE transport
  	  for compatible "linaro,scmi-optee".
+
+config SCMI_TRANSPORT_SMT_INTR
+	bool
+	depends on SCMI_FIRMWARE
+	help
+	  Enable interrupt communication of shared memory based transport.
drivers/firmware/scmi/smt.c +3 -0
index 67d2f45002490ab64a6bc997eda93a8f4681d99b..ee7ae5d50b226b92a3961c181de83c730a621401 100644
@@ -48,6 +48,9 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
  	if (!smt->buf)
  		return -ENOMEM;
 
+	if (IS_ENABLED(CONFIG_SCMI_TRANSPORT_SMT_INTR))
+		scmi_smt_enable_intr(smt, true);
+
  #ifdef CONFIG_ARM
  	if (dcache_status())
  		mmu_set_region_dcache_behaviour(ALIGN_DOWN((uintptr_t)smt->buf, MMU_SECTION_SIZE),
drivers/firmware/scmi/smt.h +0 -0
index 9d669a6c922666c48e7dce4c0affd7b47cb137e4..768b0f4c8a8d1cc7966530e724d278d72c2a167b 100644

drivers/firmware/scmi/smt.h static inline void scmi_smt_put_channel(struct scmi_smt *smt) · line 87

Quoted 4 lines
drivers/firmware/scmi/smt.h +1 -0
@@ -84,6 +84,16 @@ static inline void scmi_smt_put_channel(struct scmi_smt *smt)
  	hdr->channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR;
  }
 
+static inline void scmi_smt_enable_intr(struct scmi_smt *smt, bool enable)

Is this expected to be called from somewhere else except drivers/firmware/scmi/smt.c ? If not, please move it into drivers/firmware/scmi/smt.c .

Drop the 'inline' , compiler can figure that out.

drivers/firmware/scmi/smt.h static inline void scmi_smt_put_channel(struct scmi_smt *smt) · line 89

Quoted 2 lines
drivers/firmware/scmi/smt.h +2 -0
+{
+	struct scmi_smt_header *hdr = (void *)smt->buf;

The cast should be (struct scmi_smt_header *) instead of (void *)

Quoted 7 lines
drivers/firmware/scmi/smt.h +6 -0
+	if (enable)
+		hdr->flags |= SCMI_SHMEM_FLAG_INTR_ENABLED;
+	else
+		hdr->flags &= ~SCMI_SHMEM_FLAG_INTR_ENABLED;
+}
+
  int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt);
author
#5 lore raw

PATCH v4 3/20 pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol

In reply to Alice Guo

From: Alice Guo <[email protected]>

This patch provides a pinctrl driver based on SCMI pin control protocol. Currently, only the PINCTRL_CONFIG_SET command is implemented.

---
 drivers/pinctrl/nxp/Kconfig        |  13 ++++
 drivers/pinctrl/nxp/Makefile       |   1 +
 drivers/pinctrl/nxp/pinctrl-imx.c  |   7 +-
 drivers/pinctrl/nxp/pinctrl-imx.h  |  11 +++
 drivers/pinctrl/nxp/pinctrl-scmi.c | 136 +++++++++++++++++++++++++++++++++++++
 include/scmi_protocols.h           |  34 ++++++++++
 6 files changed, 200 insertions(+), 2 deletions(-)
drivers/pinctrl/nxp/Kconfig +13 -0
index 06c26f156f6c8f63204604d6065485629cfd9b61..ec63ab595650d0dfab7e3a7dc01d4af7814b6773 100644
@@ -1,6 +1,19 @@
 config PINCTRL_IMX
 	bool
 
+config PINCTRL_IMX_SCMI
+	bool "IMX pinctrl SCMI driver"
+	depends on ARCH_IMX9 && PINCTRL_FULL
+	select PINCTRL_IMX
+	help
+	  Say Y here to enable the imx pinctrl SCMI driver
+
+	  This provides a simple pinctrl driver for i.MX SoC which supports
+	  SCMI. This feature depends on device tree configuration. This driver
+	  is different from the linux one, this is a simple implementation,
+	  only parses the 'fsl,pins' property and configure related
+	  registers.
+
 config PINCTRL_IMX_SCU
 	bool
 
drivers/pinctrl/nxp/Makefile +1 -0
index f10aa6ef188e37583b181bdf9d70ac191e506d75..3ec3e2a9c6fdb875da4ae9bf151df5666256883b 100644
@@ -4,6 +4,7 @@ obj-$(CONFIG_PINCTRL_IMX6)		+= pinctrl-imx6.o
 obj-$(CONFIG_PINCTRL_IMX7)		+= pinctrl-imx7.o
 obj-$(CONFIG_PINCTRL_IMX7ULP)		+= pinctrl-imx7ulp.o
 obj-$(CONFIG_PINCTRL_IMX8ULP)		+= pinctrl-imx8ulp.o
+obj-$(CONFIG_PINCTRL_IMX_SCMI)		+= pinctrl-scmi.o
 obj-$(CONFIG_PINCTRL_IMX_SCU)		+= pinctrl-scu.o
 obj-$(CONFIG_PINCTRL_IMX8)		+= pinctrl-imx8.o
 obj-$(CONFIG_PINCTRL_IMX8M)		+= pinctrl-imx8m.o
drivers/pinctrl/nxp/pinctrl-imx.c +5 -2
index b1960c56b512cc113a810304dc3ac3f99b237a7e..0026aae00afe2b0aff40c3288c231b3065ef656a 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Peng Fan <[email protected]>
+ * Copyright 2025 NXP
  */
 
 #include <malloc.h>
@@ -65,7 +66,9 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 
 	npins = size / pin_size;
 
-	if (info->flags & IMX8_USE_SCU) {
+	if (info->flags & IMX_USE_SCMI) {
+		return imx_pinctrl_scmi_conf_pins(dev, pin_data, npins);
+	} else if (info->flags & IMX8_USE_SCU) {
 		imx_pinctrl_scu_conf_pins(info, pin_data, npins);
 	} else {
 		/*
@@ -216,7 +219,7 @@ int imx_pinctrl_probe(struct udevice *dev,
 	priv->dev = dev;
 	priv->info = info;
 
-	if (info->flags & IMX8_USE_SCU)
+	if (info->flags & (IMX8_USE_SCU | IMX_USE_SCMI))
 		return 0;
 
 	addr = ofnode_get_addr_size_index(dev_ofnode(dev), 0, &size);
drivers/pinctrl/nxp/pinctrl-imx.h +11 -0
index fa4c084e2fc067fcb4e92c33312d4f430081fffd..f120e32d9da678d6e9ce583f0ba3c6c17d050f36 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (C) 2016 Peng Fan <[email protected]>
+ * Copyright 2025 NXP
  */
 
 #ifndef __DRIVERS_PINCTRL_IMX_H
@@ -47,6 +48,7 @@ extern const struct pinctrl_ops imx_pinctrl_ops;
 #define ZERO_OFFSET_VALID	0x2
 #define CFG_IBE_OBE		0x4
 #define IMX8_USE_SCU		0x8
+#define IMX_USE_SCMI		0x10
 
 #define IOMUXC_CONFIG_SION	(0x1 << 4)
 
@@ -65,4 +67,13 @@ static inline int imx_pinctrl_scu_conf_pins(struct imx_pinctrl_soc_info *info,
 }
 #endif
 
+#if IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI)
+int imx_pinctrl_scmi_conf_pins(struct udevice *dev, u32 *pin_data, int npins);
+#else
+static inline int imx_pinctrl_scmi_conf_pins(struct udevice *dev, u32 *pin_data, int npins)
+{
+	return 0;
+}
+#endif
+
 #endif /* __DRIVERS_PINCTRL_IMX_H */
drivers/pinctrl/nxp/pinctrl-scmi.c new file +136 -0

136 lines not on this page · raw message

include/scmi_protocols.h +34 -0
index 7abb2a6f36ba53223bd9103fcc02f58506fbfc8d..2367467512a6b65253317e51bea71de396aa96f9 100644
@@ -24,6 +24,7 @@ enum scmi_std_protocol {
 	SCMI_PROTOCOL_ID_SENSOR = 0x15,
 	SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
 	SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
+	SCMI_PROTOCOL_ID_PINCTRL = 0x19,
 };
 
 enum scmi_status_code {
@@ -1005,4 +1006,37 @@ struct scmi_voltd_level_get_out {
 	s32 voltage_level;
 };
 
+/* SCMI Pinctrl Protocol */
+enum scmi_pinctrl_message_id {
+	SCMI_MSG_PINCTRL_CONFIG_SET = 0x6
+};
+
+struct scmi_pin_config {
+	u32 type;
+	u32 val;
+};
+
+/**
+ * struct scmi_pad_config_set_in - Message payload for PAD_CONFIG_SET command
+ * @identifier:	Identifier for the pin or group.
+ * @function_id:	Identifier for the function selected to be enabled for the
+ * 					selected pin or group. This field is set to 0xFFFFFFFF if no
+ * 					function should be enabled by the pin or group.
+ * @attributes:	Bits[31:11] Reserved, must be zero.
+ * 				Bit[10] Function valid.
+ * 				Bits[9:2] Number of configurations to set.
+ * 				Bits[1:0] Selector: Whether the identifier field refers to a pin or a group.
+ * @configs:	Array of configurations.
+ */
+struct scmi_pinctrl_config_set_in {
+	u32 identifier;
+	u32 function_id;
+	u32 attributes;
+	struct scmi_pin_config configs[4];
+};
+
+struct scmi_pinctrl_config_set_out {
+	s32 status;
+};
+
 #endif /* _SCMI_PROTOCOLS_H */
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH v4 03/20] pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol

Quoted 23 lines · Alice Guo

From: Alice Guo <[email protected]>

This patch provides a pinctrl driver based on SCMI pin control protocol. Currently, only the PINCTRL_CONFIG_SET command is implemented.

---
  drivers/pinctrl/nxp/Kconfig        |  13 ++++
  drivers/pinctrl/nxp/Makefile       |   1 +
  drivers/pinctrl/nxp/pinctrl-imx.c  |   7 +-
  drivers/pinctrl/nxp/pinctrl-imx.h  |  11 +++
  drivers/pinctrl/nxp/pinctrl-scmi.c | 136 +++++++++++++++++++++++++++++++++++++
  include/scmi_protocols.h           |  34 ++++++++++
  6 files changed, 200 insertions(+), 2 deletions(-)
drivers/pinctrl/nxp/Kconfig +0 -0
index 06c26f156f6c8f63204604d6065485629cfd9b61..ec63ab595650d0dfab7e3a7dc01d4af7814b6773 100644

drivers/pinctrl/nxp/Kconfig line 5

Quoted 5 lines
drivers/pinctrl/nxp/Kconfig +2 -0
@@ -1,6 +1,19 @@
  config PINCTRL_IMX
  	bool
 
+config PINCTRL_IMX_SCMI
+	bool "IMX pinctrl SCMI driver"

i.MX instead of IMX ? Please be sure to use the branding consistently across Kconfig entries and various text fields.

drivers/pinctrl/nxp/Kconfig line 6

Quoted 1 line
drivers/pinctrl/nxp/Kconfig +1 -0
+	depends on ARCH_IMX9 && PINCTRL_FULL

Is this really supposed to be available for all iMX9* or is this limited to iMX95 ?

drivers/pinctrl/nxp/Kconfig line 9

Quoted 3 lines
drivers/pinctrl/nxp/Kconfig +3 -0
+	select PINCTRL_IMX
+	help
+	  Say Y here to enable the imx pinctrl SCMI driver

This Say Y stuff goes ...

drivers/pinctrl/nxp/Kconfig line 15

Quoted 5 lines
drivers/pinctrl/nxp/Kconfig +5 -0
+	  This provides a simple pinctrl driver for i.MX SoC which supports
+	  SCMI. This feature depends on device tree configuration. This driver
+	  is different from the linux one, this is a simple implementation,
+	  only parses the 'fsl,pins' property and configure related
+	  registers.

... here, at the end.

drivers/pinctrl/nxp/Kconfig line 18

Quoted 2 lines
drivers/pinctrl/nxp/Kconfig +0 -0
  config PINCTRL_IMX_SCU
  	bool

I have posted a couple of pinctrl patches to [1] , that should simplify this pinctrl implementation. The entire series is also available in [2] , the updated mx95 pinctrl patch on top of it is [3] .

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://source.denx.de/u-boot/custodians/u-boot-usb/-/commits/test-pinctrl
[3] https://source.denx.de/u-boot/custodians/u-boot-usb/-/commit/3191ef0497c629017da4d88bf6a14ff0ad7c0032

author
#7 lore raw

PATCH v4 4/20 firmware: scmi: add pin control protocol support to SCMI agent

In reply to Alice Guo

From: Alice Guo <[email protected]>

This patch adds SCMI pin control protocol support so that the pin controller driver based on SCMI, such as drivers/pinctrl/nxp/pinctrl-scmi.c, can be bound to the SCMI agent device whose protocol id is 0x19.

---
 drivers/firmware/scmi/scmi_agent-uclass.c | 11 +++++++++++
 include/scmi_agent-uclass.h               |  2 ++
 2 files changed, 13 insertions(+)
drivers/firmware/scmi/scmi_agent-uclass.c +11 -0
index 8c907c3b0328095c4b35ba089ed608fcda48b567..5f101f4ede8b585f8c562a42886ea7be4ef09953 100644
@@ -97,6 +97,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
 	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
 		proto = priv->voltagedom_dev;
 		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		proto = priv->pinctrl_dev;
+		break;
 	default:
 		dev_err(dev, "Protocol not supported\n");
 		proto = NULL;
@@ -147,6 +150,9 @@ static int scmi_add_protocol(struct udevice *dev,
 	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
 		priv->voltagedom_dev = proto;
 		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		priv->pinctrl_dev = proto;
+		break;
 	default:
 		dev_err(dev, "Protocol not supported\n");
 		return -EPROTO;
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice *dev)
 				drv = DM_DRIVER_GET(scmi_voltage_domain);
 			}
 			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&
+			    scmi_protocol_is_supported(dev, protocol_id))
+				drv = DM_DRIVER_GET(scmi_pinctrl_imx);
+			break;
 		default:
 			break;
 		}
include/scmi_agent-uclass.h +2 -0
index 33e0e18c30d4ae4ddaaa2cb3830c03cd7a559cc0..4beec43cb080b14a777cac1cb0f18ef53433596c 100644
@@ -27,6 +27,7 @@ struct scmi_channel;
  * @clock_dev:		SCMI clock protocol device
  * @resetdom_dev:	SCMI reset domain protocol device
  * @voltagedom_dev:	SCMI voltage domain protocol device
+ * @pinctrl_dev:	SCMI pin control protocol device
  */
 struct scmi_agent_priv {
 	u32 version;
@@ -43,6 +44,7 @@ struct scmi_agent_priv {
 	struct udevice *clock_dev;
 	struct udevice *resetdom_dev;
 	struct udevice *voltagedom_dev;
+	struct udevice *pinctrl_dev;
 };
 
 static inline u32 scmi_version(struct udevice *dev)
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 38 lines · Alice Guo

From: Alice Guo <[email protected]>

This patch adds SCMI pin control protocol support so that the pin controller driver based on SCMI, such as drivers/pinctrl/nxp/pinctrl-scmi.c, can be bound to the SCMI agent device whose protocol id is 0x19.

---
  drivers/firmware/scmi/scmi_agent-uclass.c | 11 +++++++++++
  include/scmi_agent-uclass.h               |  2 ++
  2 files changed, 13 insertions(+)
drivers/firmware/scmi/scmi_agent-uclass.c +6 -0
index 8c907c3b0328095c4b35ba089ed608fcda48b567..5f101f4ede8b585f8c562a42886ea7be4ef09953 100644
@@ -97,6 +97,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
  	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
  		proto = priv->voltagedom_dev;
  		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		proto = priv->pinctrl_dev;
+		break;
  	default:
  		dev_err(dev, "Protocol not supported\n");
  		proto = NULL;
@@ -147,6 +150,9 @@ static int scmi_add_protocol(struct udevice *dev,
  	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
  		priv->voltagedom_dev = proto;
  		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		priv->pinctrl_dev = proto;
+		break;
  	default:
  		dev_err(dev, "Protocol not supported\n");
  		return -EPROTO;

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 5 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice *dev)
  				drv = DM_DRIVER_GET(scmi_voltage_domain);
  			}
  			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

If not, this needs to use some other config option to gate access to it.

#9 lore raw

回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 65 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年1月24日 21:55
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 15 lines · Alice Guo

From: Alice Guo <[email protected]>

This patch adds SCMI pin control protocol support so that the pin controller driver based on SCMI, such as drivers/pinctrl/nxp/pinctrl-scmi.c, can be bound to the SCMI agent device whose protocol id is 0x19.

---
  drivers/firmware/scmi/scmi_agent-uclass.c | 11 +++++++++++
  include/scmi_agent-uclass.h               |  2 ++
  2 files changed, 13 insertions(+)
drivers/firmware/scmi/scmi_agent-uclass.c +0 -0
Quoted 2 lines

index

8c907c3b0328095c4b35ba089ed608fcda48b567..5f101f4ede8b585f8c562a428 86e

Quoted 24 lines

a7be4ef09953 100644

drivers/firmware/scmi/scmi_agent-uclass.c +6 -0
@@ -97,6 +97,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
  	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
  		proto = priv->voltagedom_dev;
  		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		proto = priv->pinctrl_dev;
+		break;
  	default:
  		dev_err(dev, "Protocol not supported\n");
  		proto = NULL;
@@ -147,6 +150,9 @@ static int scmi_add_protocol(struct udevice *dev,
  	case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
  		priv->voltagedom_dev = proto;
  		break;
+	case SCMI_PROTOCOL_ID_PINCTRL:
+		priv->pinctrl_dev = proto;
+		break;
  	default:
  		dev_err(dev, "Protocol not supported\n");
  		return -EPROTO;

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 5 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice *dev)
  				drv = DM_DRIVER_GET(scmi_voltage_domain);
  			}
  			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

Quoted 1 line

If not, this needs to use some other config option to gate access to it.

Currently, it is used for some product families of the i.MX9 series products.

Best Regards,
Alice Guo

#10 lore raw

Re: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/18/25 12:53 PM, Alice Guo (OSS) wrote:

[...]

Quoted 9 lines
Quoted 9 lines

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 6 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice *dev)
   				drv = DM_DRIVER_GET(scmi_voltage_domain);
   			}
   			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

Quoted 3 lines
Quoted 1 line

If not, this needs to use some other config option to gate access to it.

Currently, it is used for some product families of the i.MX9 series products.

Is the protocol iMX specific or is it generic protocol ?

#11 lore raw

回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 27 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年2月21日 6:35
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/18/25 12:53 PM, Alice Guo (OSS) wrote:

[...]

Quoted 1 line
Quoted 1 line

Review static int scmi_bind_protocols(struct udevice

Quoted 1 line
(quoted diff) +0 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice

*dev)

Quoted 8 lines
Quoted 8 lines

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 5 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
   				drv = DM_DRIVER_GET(scmi_voltage_domain);
   			}
   			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

If not, this needs to use some other config option to gate access to it.

Currently, it is used for some product families of the i.MX9 series products.

Is the protocol iMX specific or is it generic protocol ?

SCMI_PROTOCOL_ID_PINCTRL is not unique to iMX, but drivers/pinctrl/nxp/pinctrl-scmi.c (drv = DM_DRIVER_GET(scmi_pinctrl_imx)) is only for iMX.

#12 lore raw

Re: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 27 lines · Alice Guo (OSS)
Quoted 27 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年2月21日 6:35
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/18/25 12:53 PM, Alice Guo (OSS) wrote:

[...]

Quoted 1 line
Quoted 1 line

Review static int scmi_bind_protocols(struct udevice

Quoted 1 line
(quoted diff) +0 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice

*dev)

Quoted 8 lines
Quoted 8 lines

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 5 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
    				drv = DM_DRIVER_GET(scmi_voltage_domain);
    			}
    			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

If not, this needs to use some other config option to gate access to it.

Currently, it is used for some product families of the i.MX9 series products.

Is the protocol iMX specific or is it generic protocol ?

SCMI_PROTOCOL_ID_PINCTRL is not unique to iMX, but drivers/pinctrl/nxp/pinctrl-scmi.c (drv = DM_DRIVER_GET(scmi_pinctrl_imx)) is only for iMX.

This patch is changing common code, it shouldn't be littered with vendor-specific ifdeffery or if(IS_ENABLED(...))ery . Can this be made fully generic, similar to e.g. regulator protocol ?

#13 lore raw

Re: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 30 lines · Marek Vasut
Quoted 29 lines · Alice Guo (OSS)
Quoted 29 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年2月21日 6:35
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/18/25 12:53 PM, Alice Guo (OSS) wrote:

[...]

Quoted 1 line
Quoted 1 line

Review static int scmi_bind_protocols(struct udevice

Quoted 1 line
(quoted diff) +0 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice

*dev)

Quoted 10 lines
Quoted 9 lines

drivers/firmware/scmi/scmi_agent-uclass.c static int scmi_bind_protocols(struct udevice *dev) · line 446

Quoted 5 lines
drivers/firmware/scmi/scmi_agent-uclass.c +2 -0
    				drv = DM_DRIVER_GET(scmi_voltage_domain);
    			}
    			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

If not, this needs to use some other config option to gate access to it.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Currently, it is used for some product families of the i.MX9 series products.

Is the protocol iMX specific or is it generic protocol ?

SCMI_PROTOCOL_ID_PINCTRL is not unique to iMX, but drivers/pinctrl/nxp/pinctrl-scmi.c (drv = DM_DRIVER_GET(scmi_pinctrl_imx)) is only for iMX.

This patch is changing common code, it shouldn't be littered with vendor-specific ifdeffery or if(IS_ENABLED(...))ery . Can this be made fully generic, similar to e.g. regulator protocol ?

In Linux Kernel, there are two drivers, pinctrl-scmi.c and pinctrl-imx-scmi.c. Both follows ARM SCMI 3.2, but pinctrl-imx-scmi has some special settings to align with i.mx iomuxc array based settings, mux,input,pad and etc.

In gerneral, imx part could be merged with pinctrl-scmi.c but that will make code not clean.

Regards,
Peng

#14 lore raw

Re: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/24/25 3:45 AM, Peng Fan wrote:

[...]

Quoted 20 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
Quoted 1 line

Review static int scmi_bind_protocols(struct udevice

Quoted 1 line
(quoted diff) +0 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice

*dev)

Quoted 10 lines
Quoted 9 lines

Review static int scmi_bind_protocols(struct udevice · line 446

Quoted 5 lines
(quoted diff) +2 -0
     				drv = DM_DRIVER_GET(scmi_voltage_domain);
     			}
     			break;
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

If not, this needs to use some other config option to gate access to it.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Currently, it is used for some product families of the i.MX9 series products.

Is the protocol iMX specific or is it generic protocol ?

SCMI_PROTOCOL_ID_PINCTRL is not unique to iMX, but drivers/pinctrl/nxp/pinctrl-scmi.c (drv = DM_DRIVER_GET(scmi_pinctrl_imx)) is only for iMX.

This patch is changing common code, it shouldn't be littered with vendor-specific ifdeffery or if(IS_ENABLED(...))ery . Can this be made fully generic, similar to e.g. regulator protocol ?

Quoted 6 lines

In Linux Kernel, there are two drivers, pinctrl-scmi.c and pinctrl-imx-scmi.c. Both follows ARM SCMI 3.2, but pinctrl-imx-scmi has some special settings to align with i.mx iomuxc array based settings, mux,input,pad and etc.

In gerneral, imx part could be merged with pinctrl-scmi.c but that will make code not clean.

In that case, why does U-Boot not have pinctrl-imx-scmi.c to contain the iMX customization too ? If this protocol is IMX specific, it shouldn't be ifdeffed in common code.

#15 lore raw

回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 47 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月1日 2:58
收件人: Peng Fan (OSS) <[email protected]>
抄送: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]>; [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 2/24/25 3:45 AM, Peng Fan wrote:

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +0 -0
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct

udevice

*dev)

Quoted 1 line
Quoted 1 line
Quoted 1 line

drv =

DM_DRIVER_GET(scmi_voltage_domain);

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

Review

Quoted 4 lines
     			}
     			break;
(quoted diff) +2 -0
+		case SCMI_PROTOCOL_ID_PINCTRL:
+			if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&

Is this pinctrl protocol really imx specific ?

If not, this needs to use some other config option to gate access to it.

Currently, it is used for some product families of the i.MX9 series

products.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Is the protocol iMX specific or is it generic protocol ?

SCMI_PROTOCOL_ID_PINCTRL is not unique to iMX, but

drivers/pinctrl/nxp/pinctrl-scmi.c (drv = DM_DRIVER_GET(scmi_pinctrl_imx)) is only for iMX.

Quoted 8 lines
Quoted 3 lines

This patch is changing common code, it shouldn't be littered with vendor-specific ifdeffery or if(IS_ENABLED(...))ery . Can this be made fully generic, similar to e.g. regulator protocol ?

In Linux Kernel, there are two drivers, pinctrl-scmi.c and pinctrl-imx-scmi.c. Both follows ARM SCMI 3.2, but pinctrl-imx-scmi has some special settings to align with i.mx iomuxc array based settings, mux,input,pad and etc.

Quoted 5 lines
Quoted 2 lines

In gerneral, imx part could be merged with pinctrl-scmi.c but that will make code not clean.

In that case, why does U-Boot not have pinctrl-imx-scmi.c to contain the iMX customization too ? If this protocol is IMX specific, it shouldn't be ifdeffed in common code.

Is it acceptable to rename " drivers/pinctrl/nxp/pinctrl-scmi.c" to "drivers/pinctrl/nxp/ pinctrl-imx-scmi.c"? SCMI_PROTOCOL_ID_PINCTRL = 0x19 is not i.MX specific.

#16 lore raw

Re: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 3/3/25 9:04 AM, Alice Guo (OSS) wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

In Linux Kernel, there are two drivers, pinctrl-scmi.c and pinctrl-imx-scmi.c. Both follows ARM SCMI 3.2, but pinctrl-imx-scmi has some special settings to align with i.mx iomuxc array based settings, mux,input,pad and etc.

In gerneral, imx part could be merged with pinctrl-scmi.c but that will make code not clean.

In that case, why does U-Boot not have pinctrl-imx-scmi.c to contain the iMX customization too ? If this protocol is IMX specific, it shouldn't be ifdeffed in common code.

Is it acceptable to rename " drivers/pinctrl/nxp/pinctrl-scmi.c" to "drivers/pinctrl/nxp/ pinctrl-imx-scmi.c"? SCMI_PROTOCOL_ID_PINCTRL = 0x19 is not i.MX specific.

Look at this commit, which allows drivers placed in some driver.c file insert their driver entry into a linker list, and then some common code can iterate over this linker list and match drivers against some properties.

In this case, it is a PHY driver which does list supported PHY IDs in each U_BOOT_PHY_DRIVER, and the common code checks whether the PHY IDs match when a new PHY gets registered:

7940a93eb977 ("net: phy: Iterate over both registered PHYs and struct phy_driver linker list")

This is the driver side conversion example:

20bd8e4fcbb5 ("net: phy: gen10g: Convert to U_BOOT_PHY_DRIVER()")

What you could do is the same:

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy: Iterate over both registered PHYs and struct phy_driver linker list"), call it e.g. U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c rpc_spi_bind() for example of doing this.

I hope this helps untangle the SCMI implementation.

#17 lore raw

回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 57 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月4日 4:53
收件人: Alice Guo (OSS) <[email protected]>; Peng Fan (OSS) <[email protected]>
抄送: Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]>; [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 3/3/25 9:04 AM, Alice Guo (OSS) wrote:

[...]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

In Linux Kernel, there are two drivers, pinctrl-scmi.c and pinctrl-imx-scmi.c. Both follows ARM SCMI 3.2, but pinctrl-imx-scmi has some special settings to align with i.mx iomuxc array based settings, mux,input,pad and

etc.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

In gerneral, imx part could be merged with pinctrl-scmi.c but that will make code not clean.

In that case, why does U-Boot not have pinctrl-imx-scmi.c to contain the iMX customization too ? If this protocol is IMX specific, it shouldn't be ifdeffed in common code.

Is it acceptable to rename " drivers/pinctrl/nxp/pinctrl-scmi.c" to

"drivers/pinctrl/nxp/ pinctrl-imx-scmi.c"? SCMI_PROTOCOL_ID_PINCTRL = 0x19 is not i.MX specific.

Look at this commit, which allows drivers placed in some driver.c file insert their driver entry into a linker list, and then some common code can iterate over this linker list and match drivers against some properties.

In this case, it is a PHY driver which does list supported PHY IDs in each U_BOOT_PHY_DRIVER, and the common code checks whether the PHY IDs match when a new PHY gets registered:

7940a93eb977 ("net: phy: Iterate over both registered PHYs and struct phy_driver linker list")

This is the driver side conversion example:

20bd8e4fcbb5 ("net: phy: gen10g: Convert to U_BOOT_PHY_DRIVER()")

What you could do is the same:

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy: Iterate over both registered PHYs and struct phy_driver linker list"), call it e.g. U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

Quoted 7 lines

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c rpc_spi_bind() for example of doing this.

I hope this helps untangle the SCMI implementation.

Thank you for providing the example. Please review my patch set.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#18 lore raw

Re: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 3/5/25 2:36 PM, Alice Guo (OSS) wrote:

Hello Alice,

Quoted 13 lines
Quoted 13 lines

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy: Iterate over both registered PHYs and struct phy_driver linker list"), call it e.g. U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c rpc_spi_bind() for example of doing this.

Quoted 5 lines
Quoted 1 line

I hope this helps untangle the SCMI implementation.

Thank you for providing the example. Please review my patch set.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

I will try to review this this week, I apologize for the delayed replies.

#19 lore raw

回复: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 35 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月10日 8:10
收件人: Alice Guo (OSS) <[email protected]>; Peng Fan (OSS) <[email protected]>
抄送: Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]>; [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 3/5/25 2:36 PM, Alice Guo (OSS) wrote:

Hello Alice,

Quoted 2 lines
Quoted 2 lines

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy:
Iterate over both registered PHYs and struct phy_driver linker list"), call it

e.g.

Quoted 14 lines
Quoted 13 lines

U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c
rpc_spi_bind() for example of doing this.

I hope this helps untangle the SCMI implementation.

Quoted 7 lines
Quoted 5 lines

Thank you for providing the example. Please review my patch set.
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-2-2
[email protected]/
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-3-2
[email protected]/

I will try to review this this week, I apologize for the delayed replies.

Hi Marek,

Are you available this week to review? 😊

Best Regards,
Alice Guo

#20 lore raw

Re: 回复: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

On 3/20/25 3:28 AM, Alice Guo (OSS) wrote:

Hello Alice,

Quoted 23 lines
Quoted 23 lines
Quoted 2 lines
Quoted 2 lines

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy:
Iterate over both registered PHYs and struct phy_driver linker list"), call it

e.g.

Quoted 19 lines
Quoted 5 lines

U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

Quoted 8 lines

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c
rpc_spi_bind() for example of doing this.

I hope this helps untangle the SCMI implementation.

Thank you for providing the example. Please review my patch set.
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-2-2
[email protected]/
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-3-2
[email protected]/

Quoted 5 lines
Quoted 1 line

I will try to review this this week, I apologize for the delayed replies.

Hi Marek,

Are you available this week to review? 😊

Ugh, sorry, I am working toward it. I apologize for the abysmal delay.

Thank you for the reminder.

#21 lore raw

回复: 回复: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

Quoted 44 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月20日 12:04
收件人: Alice Guo (OSS) <[email protected]>; Peng Fan (OSS) <[email protected]>
抄送: Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]>; [email protected]; [email protected]; Alice Guo <[email protected]>
主题: Re: 回复: 回复: 回复: 回复: 回复: [PATCH v4 04/20] firmware: scmi:
add pin control protocol support to SCMI agent

On 3/20/25 3:28 AM, Alice Guo (OSS) wrote:

Hello Alice,

Quoted 26 lines
Quoted 26 lines
Quoted 3 lines
Quoted 3 lines

- Basically duplicate the mechanism in 7940a93eb977 ("net: phy:
Iterate over both registered PHYs and struct phy_driver linker list"), call it

e.g.

Quoted 21 lines
Quoted 5 lines

U_BOOT_SCMI_DRIVER()
- Switch SCMI drivers to use U_BOOT_SCMI_DRIVER , have each one list a protocol ID (instead of the PHY IDs), and then use the scmi_agent-uclass.c to iterate over all the linker lists

Quoted 8 lines

About the MX95 specifics and handling those, it is possible to have two drivers which support the same hardware compiled into U-Boot and have them decide at bind time which driver should bind and which not, look at drivers/mtd/renesas_rpc_hf.c rpc_hf_probe() and drivers/spi/renesas_rpc_spi.c
rpc_spi_bind() for example of doing this.

I hope this helps untangle the SCMI implementation.

Thank you for providing the example. Please review my patch set.
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-2
-2
[email protected]/
https://patchwork.ozlabs.org/project/uboot/patch/20250305-imx95-v1-3
-2
[email protected]/

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I will try to review this this week, I apologize for the delayed replies.

Hi Marek,

Are you available this week to review? 😊

Ugh, sorry, I am working toward it. I apologize for the abysmal delay.

Thank you for the reminder.

Hi Marek,

I have sent v8. Please review this patch set. The main changes of v7 and v8 are included in cover-letter so that you can know what modifications I have made. Thanks!

Best Regards
Alice Guo

author
#22 lore raw

PATCH v4 5/20 scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

In reply to Alice Guo

From: Peng Fan <[email protected]>

SCMI misc protocol is intended for miscellaneous functions which are device specific and are usually defined to access bit fields. This patch adds SCMI misc protocol protocol_id and message_id for getting the ROM passover data.

---
 include/scmi_protocols.h | 5 +++++
 1 file changed, 5 insertions(+)
include/scmi_protocols.h +5 -0
index 2367467512a6b65253317e51bea71de396aa96f9..6cda1f00df1f6baf6db65a28b4cab114f8540a4b 100644
@@ -25,6 +25,7 @@ enum scmi_std_protocol {
 	SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
 	SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
 	SCMI_PROTOCOL_ID_PINCTRL = 0x19,
+	SCMI_PROTOCOL_ID_IMX_MISC = 0x84,
 };
 
 enum scmi_status_code {
@@ -50,6 +51,10 @@ enum scmi_discovery_id {
 	SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
 };
 
+enum scmi_imx_misc_message_id {
+	SCMI_MISC_ROM_PASSOVER_GET = 0x7
+};
+
 /*
  * SCMI Base Protocol
  */
Signature · 1 line
2.34.1
#23 lore raw

Re: [PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

Quoted 6 lines · Alice Guo

From: Peng Fan <[email protected]>

SCMI misc protocol is intended for miscellaneous functions which are device specific and are usually defined to access bit fields. This patch adds SCMI misc protocol protocol_id and message_id for getting the ROM passover data.

Is this iMX specific or is this generic protocol ?

If generic , then the symbol SCMI_PROTOCOL_ID_IMX_MISC should not contain _IMX substring .

#24 lore raw

回复: [EXT] Re: [PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

Quoted 21 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年1月24日 21:57
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>; Peng Fan <[email protected]>; Ye Li <[email protected]> 主题: [EXT] Re: [PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 2 lines · Alice Guo

From: Peng Fan <[email protected]>

Quoted 8 lines
Quoted 4 lines

SCMI misc protocol is intended for miscellaneous functions which are device specific and are usually defined to access bit fields. This patch adds SCMI misc protocol protocol_id and message_id for getting the ROM passover data.

Is this iMX specific or is this generic protocol ?

If generic , then the symbol SCMI_PROTOCOL_ID_IMX_MISC should not contain _IMX substring .

SCMI_PROTOCOL_ID_IMX_MISC is IMX specific protocol.

#25 lore raw

Re: 回复: [EXT] Re: [PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

Quoted 25 lines · Alice Guo (OSS)
Quoted 25 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年1月24日 21:57
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>; Peng Fan <[email protected]>; Ye Li <[email protected]> 主题: [EXT] Re: [PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 6 lines · Alice Guo

From: Peng Fan <[email protected]>

SCMI misc protocol is intended for miscellaneous functions which are device specific and are usually defined to access bit fields. This patch adds SCMI misc protocol protocol_id and message_id for getting the ROM passover data.

Quoted 6 lines
Quoted 4 lines

Is this iMX specific or is this generic protocol ?

If generic , then the symbol SCMI_PROTOCOL_ID_IMX_MISC should not contain _IMX substring .

SCMI_PROTOCOL_ID_IMX_MISC is IMX specific protocol.

It would be good to explicitly spell this out in the commit message , that this is some non-generic vendor-specific extension.

author
#26 lore raw

PATCH v4 6/20 scmi_protocols: add SCMI Performance domain management protocol message IDs

In reply to Alice Guo

From: Peng Fan <[email protected]>

SCMI Performance domain management protocol is intended for performance management of groups of devices or APs that run in the same performance domain. The functionality provided by the callee-side can be used by passing the corresponding message_id.

---
 include/scmi_protocols.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/scmi_protocols.h +18 -0
index 6cda1f00df1f6baf6db65a28b4cab114f8540a4b..08c86a642844570424dddbfcf9670d1e6757d8d1 100644
@@ -1044,4 +1044,22 @@ struct scmi_pinctrl_config_set_out {
 	s32 status;
 };
 
+/* SCMI Perf Protocol */
+enum scmi_perf_message_id {
+	SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3,
+	SCMI_PERF_DESCRIBE_LEVELS = 0x4,
+	SCMI_PERF_LIMITS_SET = 0x5,
+	SCMI_PERF_LIMITS_GET = 0x6,
+	SCMI_PERF_LEVEL_SET = 0x7,
+	SCMI_PERF_LEVEL_GET = 0x8
+};
+
+struct scmi_perf_in {
+	u32 domain_id;
+	u32 perf_level;
+};
+
+struct scmi_perf_out {
+	s32 status;
+};
 #endif /* _SCMI_PROTOCOLS_H */
Signature · 1 line
2.34.1
author
#27 lore raw

PATCH v4 7/20 clk: scmi: add the command CLOCK_PARENT_SET

In reply to Alice Guo

From: Peng Fan <[email protected]>

This patch adds the command CLOCK_PARENT_SET that can be used to set the parent of a clock. ARM SCMI Version 3.2 supports to change the parent of a clock device.

---
 drivers/clk/clk_scmi.c   | 20 ++++++++++++++++++++
 include/scmi_protocols.h | 19 +++++++++++++++++++
 2 files changed, 39 insertions(+)
drivers/clk/clk_scmi.c +20 -0
index e42d2032d45e011b751c19b395b6f99d5c54e78e..84333cdd0ccfe566c269f776f39725c69883c25c 100644
@@ -178,11 +178,31 @@ static int scmi_clk_probe(struct udevice *dev)
 	return 0;
 }
 
+static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
+{
+	struct scmi_clk_parent_set_in in = {
+		.clock_id = clk->id,
+		.parent_clk = parent->id,
+	};
+	struct scmi_clk_parent_set_out out;
+	struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
+					  SCMI_CLOCK_PARENT_SET,
+					  in, out);
+	int ret;
+
+	ret = devm_scmi_process_msg(clk->dev, &msg);
+	if (ret < 0)
+		return ret;
+
+	return scmi_to_linux_errno(out.status);
+}
+
 static const struct clk_ops scmi_clk_ops = {
 	.enable = scmi_clk_enable,
 	.disable = scmi_clk_disable,
 	.get_rate = scmi_clk_get_rate,
 	.set_rate = scmi_clk_set_rate,
+	.set_parent = scmi_clk_set_parent,
 };
 
 U_BOOT_DRIVER(scmi_clock) = {
include/scmi_protocols.h +19 -0
index 08c86a642844570424dddbfcf9670d1e6757d8d1..d529f8e2697472e60d0cb9c275f34ef0ecaed3ca 100644
@@ -737,6 +737,7 @@ enum scmi_clock_message_id {
 	SCMI_CLOCK_RATE_SET = 0x5,
 	SCMI_CLOCK_RATE_GET = 0x6,
 	SCMI_CLOCK_CONFIG_SET = 0x7,
+	SCMI_CLOCK_PARENT_SET = 0xD
 };
 
 #define SCMI_CLK_PROTO_ATTR_COUNT_MASK	GENMASK(15, 0)
@@ -839,6 +840,24 @@ struct scmi_clk_rate_set_out {
 	s32 status;
 };
 
+/**
+ * struct scmi_clk_parent_state_in - Message payload for CLOCK_PARENT_SET command
+ * @clock_id:		SCMI clock ID
+ * @parent_clk:		SCMI clock ID
+ */
+struct scmi_clk_parent_set_in {
+	u32 clock_id;
+	u32 parent_clk;
+};
+
+/**
+ * struct scmi_clk_parent_set_out - Response payload for CLOCK_PARENT_SET command
+ * @status:	SCMI command status
+ */
+struct scmi_clk_parent_set_out {
+	s32 status;
+};
+
 /*
  * SCMI Reset Domain Protocol
  */
Signature · 1 line
2.34.1
author
#28 lore raw

PATCH v4 8/20 clk: scmi: check the clock state/parent/rate control permissions

In reply to Alice Guo

From: Alice Guo <[email protected]>

Clock driver based on SCMI clock management protocol in Linux checks clock state, parent and rate control permissions. To be consistent with the kernel driver, add this check here.

When using common clock framework (CCF), use the clock signal ID to get the clock registered by clk_register() in scmi_clk_probe(), and then obatin the struct clk_scmi variable with container_of().

---
 drivers/clk/clk_scmi.c   | 173 ++++++++++++++++++++++++++++++++++++++++++++---
 include/scmi_protocols.h |  26 ++++++-
 2 files changed, 188 insertions(+), 11 deletions(-)
drivers/clk/clk_scmi.c +163 -10
index 84333cdd0ccfe566c269f776f39725c69883c25c..0654f0cbf5fcca9c82b840c2fabd057ce1907979 100644
@@ -12,6 +12,56 @@
 #include <asm/types.h>
 #include <linux/clk-provider.h>
 
+struct clk_scmi {
+	struct clk clk;
+	u32 ctrl_flags;
+};
+
+static int scmi_clk_get_permissions(struct udevice *dev, int clkid, u32 *perm)
+{
+	u32 version;
+	int ret;
+
+	ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK, &version);
+	if (ret) {
+		debug("get SCMI clock management protocol version failed\n");
+		return ret;
+	}
+
+	if (version >= CLOCK_PROTOCOL_VERSION_3_0) {
+		struct scmi_clk_get_permissions_in in = {
+			.clock_id = clkid,
+		};
+		struct scmi_clk_get_permissions_out out;
+		struct scmi_msg msg = {
+			.protocol_id = SCMI_PROTOCOL_ID_CLOCK,
+			.message_id = SCMI_CLOCK_GET_PERMISSIONS,
+			.in_msg = (u8 *)&in,
+			.in_msg_sz = sizeof(in),
+			.out_msg = (u8 *)&out,
+			.out_msg_sz = sizeof(out),
+		};
+
+		ret = devm_scmi_process_msg(dev, &msg);
+		if (ret) {
+			debug("get SCMI clock management protocol permissions failed\n");
+			return ret;
+		}
+
+		ret = scmi_to_linux_errno(out.status);
+		if (ret < 0) {
+			debug("the status code of getting permissions: %d\n", ret);
+			return ret;
+		}
+
+		*perm = out.permissions;
+		return 0;
+	}
+
+	debug("SCMI clock management protocol version is less than 3.0.\n");
+	return -EINVAL;
+}
+
 static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks)
 {
 	struct scmi_clk_protocol_attr_out out;
@@ -32,7 +82,8 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks)
 	return 0;
 }
 
-static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name)
+static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name,
+				 u32 *attr)
 {
 	struct scmi_clk_attribute_in in = {
 		.clock_id = clkid,
@@ -53,6 +104,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name)
 		return ret;
 
 	*name = strdup(out.clock_name);
+	*attr = out.attributes;
 
 	return 0;
 }
@@ -78,11 +130,49 @@ static int scmi_clk_gate(struct clk *clk, int enable)
 
 static int scmi_clk_enable(struct clk *clk)
 {
+	struct clk_scmi *clkscmi;
+	struct clk *c;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {
+		ret = clk_get_by_id(clk->id, &c);
+		if (ret)
+			return ret;
+
+		clkscmi = container_of(c, struct clk_scmi, clk);
+
+		if (clkscmi->ctrl_flags & SUPPORT_CLK_STAT_CONTROL)
+			return scmi_clk_gate(clk, 1);
+
+		/* Following Linux drivers/clk/clk-scmi.c, directly return 0 if agent has no permission. */
+		debug("SCMI CLOCK: the clock cannot be enabled by the agent.\n");
+		return 0;
+	}
+
 	return scmi_clk_gate(clk, 1);
 }
 
 static int scmi_clk_disable(struct clk *clk)
 {
+	struct clk_scmi *clkscmi;
+	struct clk *c;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {
+		ret = clk_get_by_id(clk->id, &c);
+		if (ret)
+			return ret;
+
+		clkscmi = container_of(c, struct clk_scmi, clk);
+
+		if (clkscmi->ctrl_flags & SUPPORT_CLK_STAT_CONTROL)
+			return scmi_clk_gate(clk, 0);
+
+		/* Following Linux drivers/clk/clk-scmi.c, directly return 0 if agent has no permission. */
+		debug("SCMI CLOCK: the clock cannot be disabled by the agent.\n");
+		return 0;
+	}
+
 	return scmi_clk_gate(clk, 0);
 }
 
@@ -108,7 +198,7 @@ static ulong scmi_clk_get_rate(struct clk *clk)
 	return (ulong)(((u64)out.rate_msb << 32) | out.rate_lsb);
 }
 
-static ulong scmi_clk_set_rate(struct clk *clk, ulong rate)
+static ulong __scmi_clk_set_rate(struct clk *clk, ulong rate)
 {
 	struct scmi_clk_rate_set_in in = {
 		.clock_id = clk->id,
@@ -133,9 +223,33 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate)
 	return scmi_clk_get_rate(clk);
 }
 
+static ulong scmi_clk_set_rate(struct clk *clk, ulong rate)
+{
+	struct clk_scmi *clkscmi;
+	struct clk *c;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {
+		ret = clk_get_by_id(clk->id, &c);
+		if (ret)
+			return ret;
+
+		clkscmi = container_of(c, struct clk_scmi, clk);
+
+		if (clkscmi->ctrl_flags & SUPPORT_CLK_RATE_CONTROL)
+			return __scmi_clk_set_rate(clk, rate);
+
+		/* Following Linux drivers/clk/clk-scmi.c, directly return 0 if agent has no permission. */
+		debug("SCMI CLOCK: the clock rate cannot be changed by the agent.\n");
+		return 0;
+	}
+
+	return __scmi_clk_set_rate(clk, rate);
+}
+
 static int scmi_clk_probe(struct udevice *dev)
 {
-	struct clk *clk;
+	struct clk_scmi *clk_scmi;
 	size_t num_clocks, i;
 	int ret;
 
@@ -156,29 +270,44 @@ static int scmi_clk_probe(struct udevice *dev)
 
 	for (i = 0; i < num_clocks; i++) {
 		char *clock_name;
+		u32 attributes;
 
-		if (!scmi_clk_get_attibute(dev, i, &clock_name)) {
-			clk = kzalloc(sizeof(*clk), GFP_KERNEL);
-			if (!clk || !clock_name)
+		if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {
+			clk_scmi = kzalloc(sizeof(*clk_scmi), GFP_KERNEL);
+			if (!clk_scmi || !clock_name)
 				ret = -ENOMEM;
 			else
-				ret = clk_register(clk, dev->driver->name,
+				ret = clk_register(&clk_scmi->clk, dev->driver->name,
 						   clock_name, dev->name);
 
 			if (ret) {
-				free(clk);
+				free(clk_scmi);
 				free(clock_name);
+				free(&attributes);
 				return ret;
 			}
 
-			clk_dm(i, clk);
+			clk_dm(i, &clk_scmi->clk);
+
+			if (CLK_HAS_RESTRICTIONS(attributes)) {
+				u32 perm;
+
+				ret = scmi_clk_get_permissions(dev, i, &perm);
+				if (ret < 0)
+					clk_scmi->ctrl_flags = 0;
+				else
+					clk_scmi->ctrl_flags = perm;
+			} else {
+				clk_scmi->ctrl_flags = SUPPORT_CLK_STAT_CONTROL | SUPPORT_CLK_PARENT_CONTROL |
+						       SUPPORT_CLK_RATE_CONTROL;
+			}
 		}
 	}
 
 	return 0;
 }
 
-static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
+static int __scmi_clk_set_parent(struct clk *clk, struct clk *parent)
 {
 	struct scmi_clk_parent_set_in in = {
 		.clock_id = clk->id,
@@ -197,6 +326,30 @@ static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
 	return scmi_to_linux_errno(out.status);
 }
 
+static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
+{
+	struct clk_scmi *clkscmi;
+	struct clk *c;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {
+		ret = clk_get_by_id(clk->id, &c);
+		if (ret)
+			return ret;
+
+		clkscmi = container_of(c, struct clk_scmi, clk);
+
+		if (clkscmi->ctrl_flags & SUPPORT_CLK_PARENT_CONTROL)
+			return __scmi_clk_set_parent(clk, parent);
+
+		/* Following Linux drivers/clk/clk-scmi.c, directly return 0 if agent has no permission. */
+		debug("SCMI CLOCK: the clock's parent cannot be changed by the agent.\n");
+		return 0;
+	}
+
+	return -ENOTSUPP;
+}
+
 static const struct clk_ops scmi_clk_ops = {
 	.enable = scmi_clk_enable,
 	.disable = scmi_clk_disable,
include/scmi_protocols.h +25 -1
index d529f8e2697472e60d0cb9c275f34ef0ecaed3ca..9607433c3276f9aa18044c414a5bde3143726cf4 100644
@@ -731,13 +731,15 @@ int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name);
 /*
  * SCMI Clock Protocol
  */
+#define CLOCK_PROTOCOL_VERSION_3_0	0x30000
 
 enum scmi_clock_message_id {
 	SCMI_CLOCK_ATTRIBUTES = 0x3,
 	SCMI_CLOCK_RATE_SET = 0x5,
 	SCMI_CLOCK_RATE_GET = 0x6,
 	SCMI_CLOCK_CONFIG_SET = 0x7,
-	SCMI_CLOCK_PARENT_SET = 0xD
+	SCMI_CLOCK_PARENT_SET = 0xD,
+	SCMI_CLOCK_GET_PERMISSIONS = 0xF
 };
 
 #define SCMI_CLK_PROTO_ATTR_COUNT_MASK	GENMASK(15, 0)
@@ -776,6 +778,7 @@ struct scmi_clk_attribute_in {
 struct scmi_clk_attribute_out {
 	s32 status;
 	u32 attributes;
+#define CLK_HAS_RESTRICTIONS(x)	((x) & BIT(1))
 	char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
 };
 
@@ -858,6 +861,27 @@ struct scmi_clk_parent_set_out {
 	s32 status;
 };
 
+/**
+ * @clock_id:	Identifier for the clock device.
+ */
+struct scmi_clk_get_permissions_in {
+	u32 clock_id;
+};
+
+/**
+ * @status:	Negative 32-bit integers are used to return error status codes.
+ * @permissions:	Bit[31] Clock state control, Bit[30] Clock parent control,
+ * 					Bit[29] Clock rate control, Bits[28:0] Reserved, must be zero
+ */
+struct scmi_clk_get_permissions_out {
+	s32 status;
+	u32 permissions;
+};
+
+#define SUPPORT_CLK_STAT_CONTROL	BIT(31)
+#define SUPPORT_CLK_PARENT_CONTROL	BIT(30)
+#define SUPPORT_CLK_RATE_CONTROL	BIT(29)
+
 /*
  * SCMI Reset Domain Protocol
  */
Signature · 1 line
2.34.1
#29 lore raw

Re: [PATCH v4 08/20] clk: scmi: check the clock state/parent/rate control permissions

On 1/15/25 2:28 PM, Alice Guo wrote:

[...]

drivers/clk/clk_scmi.c line 31

Quoted 12 lines
drivers/clk/clk_scmi.c +12 -0
+static int scmi_clk_get_permissions(struct udevice *dev, int clkid, u32 *perm)
+{
+	u32 version;
+	int ret;
+
+	ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK, &version);
+	if (ret) {
+		debug("get SCMI clock management protocol version failed\n");
+		return ret;
+	}
+
+	if (version >= CLOCK_PROTOCOL_VERSION_3_0) {

if (version < CLOCK_PROTOCOL_VERSION_3_0)
return -EINVAL;

Quoted 3 lines
drivers/clk/clk_scmi.c +3 -0
+		struct scmi_clk_get_permissions_in in = {
+			.clock_id = clkid,
+		};

[...]

drivers/clk/clk_scmi.c static int scmi_clk_set_parent(struct clk *clk, struct clk *parent) · line 335

Quoted 7 lines
drivers/clk/clk_scmi.c +7 -0
+static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
+{
+	struct clk_scmi *clkscmi;
+	struct clk *c;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {

Either do this to reduce indent:

if (!CONFIG_IS_ENABLED(CLK_CCF))
return -ENOTSUPP;

Or even better, introduce dedicated clock ops structure for the CCF variant with these extra callbacks .

Quoted 16 lines
drivers/clk/clk_scmi.c +16 -0
+		ret = clk_get_by_id(clk->id, &c);
+		if (ret)
+			return ret;
+
+		clkscmi = container_of(c, struct clk_scmi, clk);
+
+		if (clkscmi->ctrl_flags & SUPPORT_CLK_PARENT_CONTROL)
+			return __scmi_clk_set_parent(clk, parent);
+
+		/* Following Linux drivers/clk/clk-scmi.c, directly return 0 if agent has no permission. */
+		debug("SCMI CLOCK: the clock's parent cannot be changed by the agent.\n");
+		return 0;
+	}
+
+	return -ENOTSUPP;
+}

[...]

Quoted 5 lines
include/scmi_protocols.h +1 -0
@@ -858,6 +861,27 @@ struct scmi_clk_parent_set_out {
  	s32 status;
  };
 
+/**

include/scmi_protocols.h struct scmi_clk_parent_set_out { · line 874

Quoted 10 lines
include/scmi_protocols.h +10 -0
+ * @clock_id:	Identifier for the clock device.
+ */
+struct scmi_clk_get_permissions_in {
+	u32 clock_id;
+};
+
+/**
+ * @status:	Negative 32-bit integers are used to return error status codes.
+ * @permissions:	Bit[31] Clock state control, Bit[30] Clock parent control,
+ * 					Bit[29] Clock rate control, Bits[28:0] Reserved, must be zero

Please make sure the indent is consistent (it seems there are too many tabs here) and does not overflow 80 characters line length .

author
#30 lore raw

PATCH v4 9/20 sandbox: add SCMI clock control permissions to sandbox

In reply to Alice Guo

This patch is used to add SCMI clock control permissions to sandbox for testing.

---
 arch/sandbox/include/asm/scmi_test.h       |  2 ++
 drivers/firmware/scmi/sandbox-scmi_agent.c | 56 ++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 3 deletions(-)
arch/sandbox/include/asm/scmi_test.h +2 -0
index 619f8f5098cdd82ba2343897166c34c82c753422..b30e536a35771ec3e1439c1e64fd09de3728dc50 100644
@@ -27,10 +27,12 @@ struct sandbox_scmi_pwd {
  * @id:		Identifier of the clock used in the SCMI protocol
  * @enabled:	Clock state: true if enabled, false if disabled
  * @rate:	Clock rate in Hertz
+ * @perm:	Indicating state/parent/rate permission
  */
 struct sandbox_scmi_clk {
 	bool enabled;
 	ulong rate;
+	u32 perm;
 };
 
 /**
drivers/firmware/scmi/sandbox-scmi_agent.c +53 -3

92 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#31 lore raw

PATCH v4 10/20 scmi_protocols: update struct scmi_base_discover_list_protocols_out

In reply to Alice Guo

From: Ye Li <[email protected]>

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

---
 include/scmi_protocols.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/scmi_protocols.h +4 -1
index 9607433c3276f9aa18044c414a5bde3143726cf4..3c55d228cb641bc6c0e5ca7ac885efe84b41c66d 100644
@@ -141,11 +141,14 @@ struct scmi_base_discover_impl_version_out {
  * @status:		SCMI command status
  * @num_protocols:	Number of SCMI protocols in @protocol
  * @protocols:		Array of packed SCMI protocol ID's
+ *
+ * The number of elements of @protocols is specified by callee-side. Currently,
+ * set it to 4 is enough for i.MX95.
  */
 struct scmi_base_discover_list_protocols_out {
 	s32 status;
 	u32 num_protocols;
-	u32 protocols[3];
+	u32 protocols[4];
 };
 
 /**
Signature · 1 line
2.34.1
#32 lore raw

Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

Quoted 5 lines · Alice Guo

From: Ye Li <[email protected]>

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Can you please try something like this instead ? That should be future-proof:

drivers/firmware/scmi/base.c +14 -10
index f4e3974ff5b..92d278edfaf 100644
@@ -258,17 +258,16 @@ static int scmi_base_discover_impl_version_int(struct udevice *dev,
 static int scmi_base_discover_list_protocols_int(struct udevice *dev,
 						 u8 **protocols)
 {
-	struct scmi_base_discover_list_protocols_out out;
+	struct scmi_base_discover_list_protocols_out *out;
 	int cur;
 	struct scmi_msg msg = {
 		.protocol_id = SCMI_PROTOCOL_ID_BASE,
 		.message_id = SCMI_BASE_DISCOVER_LIST_PROTOCOLS,
 		.in_msg = (u8 *)&cur,
 		.in_msg_sz = sizeof(cur),
-		.out_msg = (u8 *)&out,
-		.out_msg_sz = sizeof(out),
 	};
 	u32 num_agents, num_protocols;
+	int size;
 	u8 *buf;
 	int i, ret;
 
@@ -276,29 +275,34 @@ static int scmi_base_discover_list_protocols_int(struct udevice *dev,
 	if (ret)
 		return ret;
 
-	buf = calloc(sizeof(u8), num_protocols);
-	if (!buf)
+	size = sizeof(*out) + sizeof(u8) * num_protocols;
+	out = calloc(1, size);
+	if (!out)
 		return -ENOMEM;
 
+	msg.out_msg = (u8 *)out;
+	msg.out_msg_sz = size;
+	buf = (u8 *)out->protocols;
+
 	cur = 0;
 	do {
 		ret = devm_scmi_process_msg(dev, &msg);
 		if (ret)
 			goto err;
-		if (out.status) {
-			ret = scmi_to_linux_errno(out.status);
+		if (out->status) {
+			ret = scmi_to_linux_errno(out->status);
 			goto err;
 		}
 
-		for (i = 0; i < out.num_protocols; i++, cur++)
-			buf[cur] = out.protocols[i / 4] >> ((i % 4) * 8);
+		for (i = 0; i < out->num_protocols; i++, cur++)
+			buf[cur] = out->protocols[i / 4] >> ((i % 4) * 8);
 	} while (cur < num_protocols);
 
 	*protocols = buf;
 
 	return num_protocols;
 err:
-	free(buf);
+	free(out);
 
 	return ret;
 }
include/scmi_protocols.h +1 -1
index a51234eda5c..29a7fd85cc0 100644
@@ -148,7 +148,7 @@ struct scmi_base_discover_impl_version_out {
 struct scmi_base_discover_list_protocols_out {
 	s32 status;
 	u32 num_protocols;
-	u32 protocols[4];
+	u32 protocols[];
 };
 
 /**
#33 lore raw

回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

Quoted 36 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年1月24日 22:38
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>; Ye Li <[email protected]>
主题: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 5 lines · Alice Guo

From: Ye Li <[email protected]>

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Can you please try something like this instead ? That should be future-proof:

drivers/firmware/scmi/base.c index renamed from drivers/firmware/scmi/base.c +0 -0

f4e3974ff5b..92d278edfaf 100644

drivers/firmware/scmi/base.c +0 -0
@@ -258,17 +258,16 @@ static int
 scmi_base_discover_impl_version_int(struct udevice *dev,
  static int scmi_base_discover_list_protocols_int(struct udevice *dev,
                                                 u8 **protocols)
  {

drivers/firmware/scmi/base.c static int · line 270

Quoted 10 lines
drivers/firmware/scmi/base.c +1 -3
-       struct scmi_base_discover_list_protocols_out out;
+       struct scmi_base_discover_list_protocols_out *out;
        int cur;
        struct scmi_msg msg = {
                .protocol_id = SCMI_PROTOCOL_ID_BASE,
                .message_id = SCMI_BASE_DISCOVER_LIST_PROTOCOLS,
                .in_msg = (u8 *)&cur,
                .in_msg_sz = sizeof(cur),
-               .out_msg = (u8 *)&out,
-               .out_msg_sz = sizeof(out),

The pointer and byte size of the buffer where the response message is stored should be provided before sending a BASE_DISCOVER_LIST PROTOCOLS message.

There is a more reasonable way. Number of protocols that are implemented, excluding the Base protocol, can be obtained by sending a PROTOCOL_ATTRIBUTES message. But now this command is not supported in U-Boot. In this patch, ec8727b7e1 ("firmware: scmi: implement SCMI base protocol"), "u32 protocols[3];" is used. So, I think setting the array of packed SCMI protocol ID's to a fixed size is acceptable.

Best Regards,
Alice Guo

Quoted 63 lines
drivers/firmware/scmi/base.c +14 -7
        };
        u32 num_agents, num_protocols;
+       int size;
        u8 *buf;
        int i, ret;
@@ -276,29 +275,34 @@ static int
 scmi_base_discover_list_protocols_int(struct udevice *dev,
        if (ret)
                return ret;
 
-       buf = calloc(sizeof(u8), num_protocols);
-       if (!buf)
+       size = sizeof(*out) + sizeof(u8) * num_protocols;
+       out = calloc(1, size);
+       if (!out)
                return -ENOMEM;
 
+       msg.out_msg = (u8 *)out;
+       msg.out_msg_sz = size;
+       buf = (u8 *)out->protocols;
+
        cur = 0;
        do {
                ret = devm_scmi_process_msg(dev, &msg);
                if (ret)
                        goto err;
-               if (out.status) {
-                       ret = scmi_to_linux_errno(out.status);
+               if (out->status) {
+                       ret = scmi_to_linux_errno(out->status);
                        goto err;
                }
 
-               for (i = 0; i < out.num_protocols; i++, cur++)
-                       buf[cur] = out.protocols[i / 4] >> ((i % 4) * 8);
+               for (i = 0; i < out->num_protocols; i++, cur++)
+                       buf[cur] = out->protocols[i / 4] >> ((i % 4) *
+ 8);
        } while (cur < num_protocols);
 
        *protocols = buf;
 
        return num_protocols;
  err:
-       free(buf);
+       free(out);
 
        return ret;
  }
include/scmi_protocols.h index renamed from include/scmi_protocols.h +0 -0

a51234eda5c..29a7fd85cc0 100644

include/scmi_protocols.h +1 -1
@@ -148,7 +148,7 @@ struct scmi_base_discover_impl_version_out {
  struct scmi_base_discover_list_protocols_out {
        s32 status;
        u32 num_protocols;
-       u32 protocols[4];
+       u32 protocols[];
  };
 
  /**
#34 lore raw

Re: 回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

On 3/3/25 11:37 AM, Alice Guo (OSS) wrote:

Hi,

Quoted 28 lines
Quoted 15 lines
Quoted 3 lines

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Can you please try something like this instead ? That should be future-proof:

drivers/firmware/scmi/base.c index renamed from drivers/firmware/scmi/base.c +0 -0

f4e3974ff5b..92d278edfaf 100644

drivers/firmware/scmi/base.c +0 -0
@@ -258,17 +258,16 @@ static int
 scmi_base_discover_impl_version_int(struct udevice *dev,
   static int scmi_base_discover_list_protocols_int(struct udevice *dev,
                                                  u8 **protocols)
   {

drivers/firmware/scmi/base.c static int · line 270

Quoted 10 lines
drivers/firmware/scmi/base.c +1 -3
-       struct scmi_base_discover_list_protocols_out out;
+       struct scmi_base_discover_list_protocols_out *out;
         int cur;
         struct scmi_msg msg = {
                 .protocol_id = SCMI_PROTOCOL_ID_BASE,
                 .message_id = SCMI_BASE_DISCOVER_LIST_PROTOCOLS,
                 .in_msg = (u8 *)&cur,
                 .in_msg_sz = sizeof(cur),
-               .out_msg = (u8 *)&out,
-               .out_msg_sz = sizeof(out),

The pointer and byte size of the buffer where the response message is stored should be provided before sending a BASE_DISCOVER_LIST PROTOCOLS message.

Quoted 1 line

There is a more reasonable way. Number of protocols that are implemented, excluding the Base protocol, can be obtained by sending a PROTOCOL_ATTRIBUTES message. But now this command is not supported in U-Boot. In this patch, ec8727b7e1 ("firmware: scmi: implement SCMI base protocol"), "u32 protocols[3];" is used. So, I think setting the array of packed SCMI protocol ID's to a fixed size is acceptable.

NAK, let's not perpetuate this suboptimal implementation, please implement PROTOCOL_ATTRIBUTES if that's the way to find out the amount of supported protocols dynamically.

#35 lore raw

回复: 回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

Quoted 50 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月4日 4:19
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>; Ye Li <[email protected]>
主题: Re: 回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

On 3/3/25 11:37 AM, Alice Guo (OSS) wrote:

Hi,

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Can you please try something like this instead ? That should be future-proof:

Quoted 8 lines

drivers/firmware/scmi/base.c static int · line 260

Quoted 8 lines
(quoted diff) +0 -0

b/drivers/firmware/scmi/base.c index f4e3974ff5b..92d278edfaf 100644

drivers/firmware/scmi/base.c +0 -0
@@ -258,17 +258,16 @@ static int
 scmi_base_discover_impl_version_int(struct udevice *dev,
   static int scmi_base_discover_list_protocols_int(struct udevice *dev,
                                                  u8

**protocols)

Quoted 7 lines

drivers/firmware/scmi/base.c static int scmi_base_discover_impl_version_int(struct udevice *dev,

Quoted 7 lines
drivers/firmware/scmi/base.c +1 -1
   {
-       struct scmi_base_discover_list_protocols_out out;
+       struct scmi_base_discover_list_protocols_out *out;
         int cur;
         struct scmi_msg msg = {
                 .protocol_id = SCMI_PROTOCOL_ID_BASE,
                 .message_id =

SCMI_BASE_DISCOVER_LIST_PROTOCOLS,

Quoted 6 lines

drivers/firmware/scmi/base.c static int scmi_base_discover_impl_version_int(struct udevice *dev, · line 269

Quoted 4 lines
drivers/firmware/scmi/base.c +0 -2
                 .in_msg = (u8 *)&cur,
                 .in_msg_sz = sizeof(cur),
-               .out_msg = (u8 *)&out,
-               .out_msg_sz = sizeof(out),

The pointer and byte size of the buffer where the response message is stored

should be provided before sending a BASE_DISCOVER_LIST PROTOCOLS message.

Quoted 2 lines

There is a more reasonable way. Number of protocols that are implemented,

Quoted 8 lines

excluding the Base protocol, can be obtained by sending a PROTOCOL_ATTRIBUTES message. But now this command is not supported in U-Boot. In this patch, ec8727b7e1 ("firmware: scmi: implement SCMI base protocol"), "u32 protocols[3];" is used. So, I think setting the array of packed SCMI protocol ID's to a fixed size is acceptable.
NAK, let's not perpetuate this suboptimal implementation, please implement PROTOCOL_ATTRIBUTES if that's the way to find out the amount of supported protocols dynamically.

OK. Will do it according to your comment.

#36 lore raw

Re: 回复: 回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

Quoted 59 lines · Alice Guo (OSS)
Quoted 50 lines

-----邮件原件-----
发件人: Marek Vasut <[email protected]>
发送时间: 2025年3月4日 4:19
收件人: Alice Guo (OSS) <[email protected]>; Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]> 抄送: [email protected]; [email protected]; Alice Guo <[email protected]>; Ye Li <[email protected]>
主题: Re: 回复: [EXT] Re: [PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

On 3/3/25 11:37 AM, Alice Guo (OSS) wrote:

Hi,

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

@protocols is an array of protocol identifiers that are implemented, excluding the Base protocol. The number of elements of @protocols is specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Can you please try something like this instead ? That should be future-proof:

Quoted 8 lines

drivers/firmware/scmi/base.c static int · line 260

Quoted 8 lines
(quoted diff) +0 -0

b/drivers/firmware/scmi/base.c index f4e3974ff5b..92d278edfaf 100644

drivers/firmware/scmi/base.c +0 -0
@@ -258,17 +258,16 @@ static int
 scmi_base_discover_impl_version_int(struct udevice *dev,
    static int scmi_base_discover_list_protocols_int(struct udevice *dev,
                                                   u8

**protocols)

Quoted 7 lines

drivers/firmware/scmi/base.c static int scmi_base_discover_impl_version_int(struct udevice *dev,

Quoted 7 lines
drivers/firmware/scmi/base.c +1 -1
    {
-       struct scmi_base_discover_list_protocols_out out;
+       struct scmi_base_discover_list_protocols_out *out;
          int cur;
          struct scmi_msg msg = {
                  .protocol_id = SCMI_PROTOCOL_ID_BASE,
                  .message_id =

SCMI_BASE_DISCOVER_LIST_PROTOCOLS,

Quoted 6 lines

drivers/firmware/scmi/base.c static int scmi_base_discover_impl_version_int(struct udevice *dev, · line 269

Quoted 4 lines
drivers/firmware/scmi/base.c +0 -2
                  .in_msg = (u8 *)&cur,
                  .in_msg_sz = sizeof(cur),
-               .out_msg = (u8 *)&out,
-               .out_msg_sz = sizeof(out),

The pointer and byte size of the buffer where the response message is stored

should be provided before sending a BASE_DISCOVER_LIST PROTOCOLS message.

Quoted 2 lines

There is a more reasonable way. Number of protocols that are implemented,

Quoted 8 lines

excluding the Base protocol, can be obtained by sending a PROTOCOL_ATTRIBUTES message. But now this command is not supported in U-Boot. In this patch, ec8727b7e1 ("firmware: scmi: implement SCMI base protocol"), "u32 protocols[3];" is used. So, I think setting the array of packed SCMI protocol ID's to a fixed size is acceptable.
NAK, let's not perpetuate this suboptimal implementation, please implement PROTOCOL_ATTRIBUTES if that's the way to find out the amount of supported protocols dynamically.

Quoted 1 line

OK. Will do it according to your comment.

Thank you !

author
#37 lore raw

PATCH v4 11/20 scmi: add the macro SCMI_MSG

In reply to Alice Guo

From: Peng Fan <[email protected]>

This patch adds the macro SCMI_MSG for protocols that do not need _in_array.

---
 include/scmi_agent.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/scmi_agent.h +11 -0
index 755986d6c424ccc881ac0943a88735cbcfacb001..5508a126a6dc504afa6d896c78c760b1af0d3deb 100644
@@ -54,6 +54,17 @@ struct scmi_msg {
 		.out_msg_sz = sizeof(_out_array),	\
 	}
 
+/* Helper macro to match a message on output array references */
+#define SCMI_MSG(_protocol, _message, _out_array)	\
+	(struct scmi_msg){				\
+		.protocol_id = (_protocol),		\
+		.message_id = (_message),		\
+		.in_msg = (uint8_t *)NULL,		\
+		.in_msg_sz = 0,				\
+		.out_msg = (uint8_t *)&(_out_array),	\
+		.out_msg_sz = sizeof(_out_array),	\
+	}
+
 /**
  * devm_scmi_of_get_channel() - Get SCMI channel handle from SCMI agent DT node
  *
Signature · 1 line
2.34.1
#38 lore raw

Re: [PATCH v4 11/20] scmi: add the macro SCMI_MSG

Quoted 17 lines · Alice Guo

From: Peng Fan <[email protected]>

This patch adds the macro SCMI_MSG for protocols that do not need _in_array.

---
  include/scmi_agent.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/scmi_agent.h +0 -0
index 755986d6c424ccc881ac0943a88735cbcfacb001..5508a126a6dc504afa6d896c78c760b1af0d3deb 100644

include/scmi_agent.h struct scmi_msg { · line 62

Quoted 9 lines
include/scmi_agent.h +6 -0
@@ -54,6 +54,17 @@ struct scmi_msg {
  		.out_msg_sz = sizeof(_out_array),	\
  	}
 
+/* Helper macro to match a message on output array references */
+#define SCMI_MSG(_protocol, _message, _out_array)	\
+	(struct scmi_msg){				\
+		.protocol_id = (_protocol),		\
+		.message_id = (_message),		\
+		.in_msg = (uint8_t *)NULL,		\

Is the cast needed ?

include/scmi_agent.h struct scmi_msg { · line 63

Quoted 1 line
include/scmi_agent.h +1 -0
+		.in_msg_sz = 0,				\

Is the explicit assignment of in_msg/in_msg_sz even needed at all ?

Quoted 3 lines
include/scmi_agent.h +3 -0
+		.out_msg = (uint8_t *)&(_out_array),	\
+		.out_msg_sz = sizeof(_out_array),	\
+	}

[...]

author
#39 lore raw

PATCH v4 12/20 imx9: scmi: add i.MX95 SoC and clock related code

In reply to Alice Guo

From: Peng Fan <[email protected]>

This patch adds i.MX95 SoC and clock related code. Because they are based on SCMI, put them in the scmi subfolder.

---
 arch/arm/include/asm/arch-imx/cpu.h        |   2 +
 arch/arm/include/asm/arch-imx9/clock.h     |  10 +
 arch/arm/include/asm/arch-imx9/imx-regs.h  |   5 +
 arch/arm/include/asm/arch-imx9/sys_proto.h |   1 +
 arch/arm/include/asm/mach-imx/sys_proto.h  |  39 ++
 arch/arm/mach-imx/imx9/scmi/Makefile       |   6 +
 arch/arm/mach-imx/imx9/scmi/clock.c        | 105 ++++
 arch/arm/mach-imx/imx9/scmi/clock_scmi.c   | 135 +++++
 arch/arm/mach-imx/imx9/scmi/soc.c          | 809 +++++++++++++++++++++++++++++
 arch/sandbox/include/asm/scmi_test.h       |   2 +-
 10 files changed, 1113 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-imx/cpu.h +2 -0
index 0d7a573461690046b27498c7174459110a73689c..1f669c72d00833f07ca7a2563ae24536af9dc418 100644
@@ -76,6 +76,8 @@
 #define MXC_CPU_IMX9111		0xCD /* dummy ID */
 #define MXC_CPU_IMX9101		0xCE /* dummy ID */
 
+#define MXC_CPU_IMX95		0x1C1 /* dummy ID */
+
 #define MXC_SOC_MX6		0x60
 #define MXC_SOC_MX7		0x70
 #define MXC_SOC_IMX8M		0x80
arch/arm/include/asm/arch-imx9/clock.h +10 -0
index 60d48b13b11f274c9e4c8caf20954de0431d9d6a..ffaf6b5f7d81d73af1702dff64cf9b15ea521ad9 100644
@@ -255,5 +255,15 @@ int ccm_shared_gpr_tz_access(u32 gpr, bool non_secure, bool user_mode, bool lock
 void enable_usboh3_clk(unsigned char enable);
 int set_clk_enet(enum enet_freq type);
 int set_clk_eqos(enum enet_freq type);
+
+int imx_clk_scmi_enable(u32 clock_id, bool enable);
+ulong imx_clk_scmi_set_rate(u32 clock_id, ulong rate);
+ulong imx_clk_scmi_get_rate(u32 clock_id);
+int imx_clk_scmi_set_parent(u32 clock_id, u32 parent_id);
 void set_arm_clk(ulong freq);
+
+int imx_clk_scmi_enable(u32 clock_id, bool enable);
+ulong imx_clk_scmi_set_rate(u32 clock_id, ulong rate);
+ulong imx_clk_scmi_get_rate(u32 clock_id);
+int imx_clk_scmi_set_parent(u32 clock_id, u32 parent_id);
 #endif
arch/arm/include/asm/arch-imx9/imx-regs.h +5 -0
index ef9538bd42e8b2972d7e6829a402bc4f661e3cbb..f7f9c706e13e63df7ff0a90b3964e04bc15959bf 100644
@@ -20,6 +20,11 @@
 #define WDG4_BASE_ADDR      0x424a0000UL
 #define WDG5_BASE_ADDR      0x424b0000UL
 
+#define GPIO2_BASE_ADDR	    0x43810000UL
+#define GPIO3_BASE_ADDR	    0x43820000UL
+#define GPIO4_BASE_ADDR	    0x43840000UL
+#define GPIO5_BASE_ADDR	    0x43850000UL
+
 #define FSB_BASE_ADDR       0x47510000UL
 
 #define ANATOP_BASE_ADDR    0x44480000UL
arch/arm/include/asm/arch-imx9/sys_proto.h +1 -0
index e4bf6a63424f7c54c1dcdf6b882a908940e5fdb1..df2148a53c7e43fcacad0798090df23e24347dbe 100644
@@ -12,6 +12,7 @@ enum imx9_soc_voltage_mode {
 	VOLT_LOW_DRIVE = 0,
 	VOLT_NOMINAL_DRIVE,
 	VOLT_OVER_DRIVE,
+	VOLT_SUPER_OVER_DRIVE,
 };
 
 void soc_power_init(void);
arch/arm/include/asm/mach-imx/sys_proto.h +39 -0
index 109a806852ab42d018ce45a4e96af5b57adb6a9c..0780f99b49a7768d77ed688157e3287195c857b1 100644
@@ -97,6 +97,8 @@ struct bd_info;
 #define is_imx9302() (is_cpu_type(MXC_CPU_IMX9302))
 #define is_imx9301() (is_cpu_type(MXC_CPU_IMX9301))
 
+#define is_imx95() (is_cpu_type(MXC_CPU_IMX95))
+
 #define is_imx9121() (is_cpu_type(MXC_CPU_IMX9121))
 #define is_imx9111() (is_cpu_type(MXC_CPU_IMX9111))
 #define is_imx9101() (is_cpu_type(MXC_CPU_IMX9101))
@@ -216,6 +218,43 @@ ulong spl_romapi_get_uboot_base(u32 image_offset, u32 rom_bt_dev);
 u32 rom_api_download_image(u8 *dest, u32 offset, u32 size);
 u32 rom_api_query_boot_infor(u32 info_type, u32 *info);
 
+#if IS_ENABLED(CONFIG_SCMI_FIRMWARE)
+typedef struct rom_passover {
+	u16 tag;                   // Tag
+	u8  len;                   // Fixed value of 0x80
+	u8  ver;                   // Version
+	u32 boot_mode;             // Boot mode
+	u32 card_addr_mode;        // SD card address mode
+	u32 bad_blks_of_img_set0;  // NAND bad block count skipped 1
+	u32 ap_mu_id;              // AP MU ID
+	u32 bad_blks_of_img_set1;  // NAND bad block count skipped 1
+	u8  boot_stage;            // Boot stage
+	u8  img_set_sel;           // Image set booted from
+	u8  rsv0[2];               // Reserved
+	u32 img_set_end;           // Offset of Image End
+	u32 rom_version;           // ROM version
+	u8  boot_dev_state;        // Boot device state
+	u8  boot_dev_inst;         // Boot device type
+	u8  boot_dev_type;         // Boot device instance
+	u8  rsv1;                  // Reserved
+	u32 dev_page_size;         // Boot device page size
+	u32 cnt_header_ofs;        // Container header offset
+	u32 img_ofs;               // Image offset
+}  __packed rom_passover_t;
+
+/**
+ * struct scmi_rom_passover_out - Response payload for ROM_PASSOVER_GET command
+ * @status:	SCMI clock ID
+ * @attributes:	Attributes of the targets clock state
+ */
+struct scmi_rom_passover_get_out {
+	u32 status;
+	u32 numPassover;
+	u32 passover[(sizeof(rom_passover_t) + 8) / 4];
+};
+
+#endif
+
 /* For i.MX ULP */
 #define BT0CFG_LPBOOT_MASK	0x1
 #define BT0CFG_DUALBOOT_MASK	0x2
arch/arm/mach-imx/imx9/scmi/Makefile new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4534db08d287899af5bb26283e4d20b942b421e4
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2025 NXP
+
+obj-y += soc.o
+obj-y += clock_scmi.o clock.o
arch/arm/mach-imx/imx9/scmi/clock.c new file +105 -0

105 lines not on this page · raw message

arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +135 -0

135 lines not on this page · raw message

arch/arm/mach-imx/imx9/scmi/soc.c new file +809 -0

809 lines not on this page · raw message

arch/sandbox/include/asm/scmi_test.h +1 -1
index b30e536a35771ec3e1439c1e64fd09de3728dc50..c9717118bcb90e7f26285ead30cff8612ed42956 100644
@@ -110,7 +110,7 @@ struct sandbox_scmi_devices {
 	size_t regul_count;
 };
 
-#ifdef CONFIG_SCMI_FIRMWARE
+#if IS_ENABLED(CONFIG_SCMI_FIRMWARE)
 /**
  * sandbox_scmi_channel_id - Get the channel id
  * @dev:	Reference to the SCMI protocol device
Signature · 1 line
2.34.1
#40 lore raw

Re: [PATCH v4 12/20] imx9: scmi: add i.MX95 SoC and clock related code

Quoted 14 lines · Alice Guo
arch/arm/mach-imx/imx9/scmi/clock.c new file +14 -0
+void init_uart_clk(u32 index)
+{
+	u32 clock_id;
+
+	switch (index) {
+	case 0:
+		clock_id = IMX95_CLK_LPUART1;
+		break;
+	case 1:
+		clock_id = IMX95_CLK_LPUART2;
+		break;
+	case 2:
+		clock_id = IMX95_CLK_LPUART3;
+		break;

arch/arm/mach-imx/imx9/scmi/clock.c line 79

Quoted 10 lines
arch/arm/mach-imx/imx9/scmi/clock.c new file +10 -0
+	default:
+		return;
+	}
+
+	/* 24MHz */
+	imx_clk_scmi_enable(clock_id, false);
+	imx_clk_scmi_set_parent(clock_id, IMX95_CLK_24M);
+	imx_clk_scmi_set_rate(clock_id, 24000000);
+	imx_clk_scmi_enable(clock_id, true);
+}

Is this ad-hoc clock management necessary even with DM_CLK ?

Quoted 15 lines
arch/arm/mach-imx/imx9/scmi/clock.c new file +15 -0
+unsigned int mxc_get_clock(enum mxc_clock clk)
+{
+	switch (clk) {
+	case MXC_ARM_CLK:
+		return get_arm_core_clk();
+	case MXC_IPG_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_BUSWAKEUP);
+	case MXC_CSPI_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_LPSPI1);
+	case MXC_ESDHC_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_USDHC1);
+	case MXC_ESDHC2_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_USDHC2);
+	case MXC_ESDHC3_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_USDHC3);

arch/arm/mach-imx/imx9/scmi/clock.c line 105

Quoted 10 lines
arch/arm/mach-imx/imx9/scmi/clock.c new file +10 -0
+	case MXC_UART_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_LPUART1);
+	case MXC_FLEXSPI_CLK:
+		return imx_clk_scmi_get_rate(IMX95_CLK_FLEXSPI1);
+	default:
+		return -1;
+	};
+
+	return -1;
+};

Is this ad-hoc clock management necessary even with DM_CLK ?

Quoted 9 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..23ffe0eed695b67977d441f7ee8830af9c4aabfe
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP

arch/arm/mach-imx/imx9/scmi/clock_scmi.c line 13

Quoted 10 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +10 -0
+ *
+ * Peng Fan <[email protected]>
+ */
+
+#include <dm/uclass.h>
+#include <scmi_agent.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int imx_clk_scmi_enable(u32 clock_id, bool enable)

Is this ad-hoc clock management necessary even with DM_CLK ?

[...]

Quoted 30 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +30 -0
+int print_cpuinfo(void)
+{
+	u32 cpurev, max_freq;
+	int minc, maxc;
+
+	cpurev = get_cpu_rev();
+
+	printf("CPU:   i.MX%s rev%d.%d",
+		get_imx_type((cpurev & 0x1FF000) >> 12),
+		(cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0);
+
+	max_freq = get_cpu_speed_grade_hz();
+	if (!max_freq || max_freq == mxc_get_clock(MXC_ARM_CLK)) {
+		printf(" at %dMHz\n", mxc_get_clock(MXC_ARM_CLK) / 1000000);
+	} else {
+		printf(" %d MHz (running at %d MHz)\n", max_freq / 1000000,
+		       mxc_get_clock(MXC_ARM_CLK) / 1000000);
+	}
+
+	puts("CPU:   ");
+	switch (get_cpu_temp_grade(&minc, &maxc)) {
+	case TEMP_AUTOMOTIVE:
+		puts("Automotive temperature grade ");
+		break;
+	case TEMP_INDUSTRIAL:
+		puts("Industrial temperature grade ");
+		break;
+	case TEMP_EXTCOMMERCIAL:
+		if (is_imx93())
+			puts("Extended Industrial temperature grade ");

arch/arm/mach-imx/imx9/scmi/clock_scmi.c line 53

Quoted 10 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +10 -0
+		else
+			puts("Extended Consumer temperature grade ");
+		break;
+	default:
+		puts("Consumer temperature grade ");
+		break;
+	}
+	printf("(%dC to %dC)", minc, maxc);
+
+#if defined(CONFIG_DM_THERMAL)

Use "if (CONFIG_IS_ENABLED(...))" instead of preprocessor "#if ..." where possible so compiler can detect bitrot.

[...]

arch/arm/mach-imx/imx9/scmi/clock_scmi.c line 61

Quoted 8 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +8 -0
+int arch_misc_init(void)
+{
+	build_info();
+	return 0;
+}
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+#ifndef CONFIG_SPL_BUILD

Can this ifdeffery be cleaned up ?

arch/arm/mach-imx/imx9/scmi/clock_scmi.c line 74

Quoted 13 lines
arch/arm/mach-imx/imx9/scmi/clock_scmi.c new file +13 -0
+int board_fix_fdt(void *fdt)
+{
+	return 0;
+}
+#endif
+#endif
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	return 0;
+}
+
+#if defined(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)

Use if (CONFIG_IS_ENABLED()) or if (IS_ENABLED()) and please fix globally.

author
#41 lore raw

PATCH v4 13/20 spl: imx: use trampoline buffer to load images to secure region

In reply to Alice Guo

From: Ye Li <[email protected]>

When SPL loading image to secure region, for example, ATF and tee to DDR secure region. Because the USDHC controller is non-secure master, it can't access this region and will cause loading issue.

So use a trampoline buffer in non-secure region, then use CPU to copy the image from trampoline buffer to destination secure region.

---
 arch/arm/mach-imx/imx9/scmi/soc.c | 18 +++++++++++++++++
 common/spl/Kconfig                |  6 ++++++
 common/spl/spl_imx_container.c    | 41 +++++++++++++++++++++++++++++++++------
 3 files changed, 59 insertions(+), 6 deletions(-)
arch/arm/mach-imx/imx9/scmi/soc.c +18 -0
index f1683b0484b84bf18b8612abc4daacf2f69d5e0b..f3840761e1bb1f5f6b4ebbced26d8a8f41eb4867 100644
@@ -807,3 +807,21 @@ enum boot_device get_boot_device(void)
 	return boot_dev;
 }
 #endif
+
+bool arch_check_dst_in_secure(void *start, ulong size)
+{
+	ulong ns_end = CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE;
+#ifdef PHYS_SDRAM_2_SIZE
+	ns_end += PHYS_SDRAM_2_SIZE;
+#endif
+
+	if ((ulong)start < CFG_SYS_SDRAM_BASE || (ulong)start + size > ns_end)
+		return true;
+
+	return false;
+}
+
+void *arch_get_container_trampoline(void)
+{
+	return (void *)((ulong)CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE - SZ_16M);
+}
common/spl/Kconfig +6 -0
index 4e56d9909c80f8e888034df4a5098d1bb288d9a0..fc8175c853af4b0855e1854f0bb5f9a5002bbbae 100644
@@ -362,6 +362,12 @@ config SPL_LOAD_IMX_CONTAINER
 	  Support booting U-Boot from an i.MX8 container image. If you are not
 	  using i.MX8, say 'n'.
 
+config SPL_IMX_CONTAINER_USE_TRAMPOLINE
+	bool
+	depends on SPL
+	help
+	  Enable SPL load reader to load data to a trampoline buffer.
+
 config IMX_CONTAINER_CFG
 	string "i.MX8 Container config file"
 	depends on SPL && SPL_LOAD_IMX_CONTAINER
common/spl/spl_imx_container.c +35 -6

59 lines not on this page · raw message

Signature · 1 line
2.34.1
#42 lore raw

Re: [PATCH v4 13/20] spl: imx: use trampoline buffer to load images to secure region

Quoted 8 lines · Alice Guo

From: Ye Li <[email protected]>

When SPL loading image to secure region, for example, ATF and tee to DDR secure region. Because the USDHC controller is non-secure master, it can't access this region and will cause loading issue.

So use a trampoline buffer in non-secure region, then use CPU to copy the image from trampoline buffer to destination secure region.

There is already common/bouncebuf.c , can you instead implement something similar, which would behave as a generic bounce buffer, except for the secure/nonsecure regions ?

The region configuration could come from DT or maybe from firmware ?

author
#43 lore raw

PATCH v4 14/20 imx9: add i.MX95 Kconfig and Makefile

In reply to Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 Kconfig and Makefile. i.MX95 uses SCMI.

---
 arch/arm/mach-imx/imx9/Kconfig  | 8 ++++++++
 arch/arm/mach-imx/imx9/Makefile | 9 +++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
arch/arm/mach-imx/imx9/Kconfig +8 -0
index 54c6b117fcff21be5c3800ebd1dc30f8ea12ac42..660529555e9b3d38a6fb70c77858bd9de7473461 100644
@@ -21,6 +21,14 @@ config IMX91
 	select IMX9
 	select ARMV8_SPL_EXCEPTION_VECTORS
 
+config IMX95
+	bool
+	select IMX9
+	select ARMV8_SPL_EXCEPTION_VECTORS
+	select SCMI_FIRMWARE
+	select DM_MAILBOX
+	select SCMI_TRANSPORT_SMT_INTR
+	select SPL_IMX_CONTAINER_USE_TRAMPOLINE
 
 config SYS_SOC
 	default "imx9"
arch/arm/mach-imx/imx9/Makefile +7 -2
index 45a9105a75a558dada3c328ed0878050da2a41e1..53cc97c6b471f1bdc3f55b198788ca42e4ad9558 100644
@@ -3,8 +3,13 @@
 # Copyright 2022 NXP
 
 obj-y += lowlevel_init.o
+
+ifeq ($(CONFIG_SCMI_FIRMWARE),y)
+obj-y += scmi/
+else
 obj-y += soc.o clock.o clock_root.o trdc.o
+endif
 
-#ifndef CONFIG_XPL_BUILD
+ifneq ($(CONFIG_SPL_BUILD),y)
 obj-y += imx_bootaux.o
-#endif
+endif
\ No newline at end of file
Signature · 1 line
2.34.1
#44 lore raw

Re: [PATCH v4 14/20] imx9: add i.MX95 Kconfig and Makefile

Quoted 18 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 Kconfig and Makefile. i.MX95 uses SCMI.

---
  arch/arm/mach-imx/imx9/Kconfig  | 8 ++++++++
  arch/arm/mach-imx/imx9/Makefile | 9 +++++++--
  2 files changed, 15 insertions(+), 2 deletions(-)
arch/arm/mach-imx/imx9/Kconfig +0 -0
index 54c6b117fcff21be5c3800ebd1dc30f8ea12ac42..660529555e9b3d38a6fb70c77858bd9de7473461 100644
@@ -21,6 +21,14 @@ config IMX91
  	select IMX9

arch/arm/mach-imx/imx9/Kconfig config IMX91 · line 31

Quoted 10 lines
arch/arm/mach-imx/imx9/Kconfig +8 -0
  	select ARMV8_SPL_EXCEPTION_VECTORS
 
+config IMX95
+	bool
+	select IMX9
+	select ARMV8_SPL_EXCEPTION_VECTORS
+	select SCMI_FIRMWARE
+	select DM_MAILBOX
+	select SCMI_TRANSPORT_SMT_INTR
+	select SPL_IMX_CONTAINER_USE_TRAMPOLINE

Keep the list sorted.

author
#45 lore raw

PATCH v4 15/20 imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95

In reply to Alice Guo

From: Alice Guo <[email protected]>

i.MX95 only supports low power boot, which means A55 is kicked by M33. There is no ROM runs on A55 in such case so that deselect IMX8_ROMAPI for i.MX95.

---
 arch/arm/mach-imx/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/Kconfig +1 -1
index 134e42028c3787d78e28af03d40c41a8b2b1981b..daf6443aa5b40b6410f2645937239a4ec785fa34 100644
@@ -180,7 +180,7 @@ config DDRMC_VF610_CALIBRATION
 
 config IMX8_ROMAPI
 	def_bool y
-	depends on IMX8MN || IMX8MP || IMX8ULP || IMX9
+	depends on IMX8MN || IMX8MP || IMX8ULP || (IMX9 && !IMX95)
 
 config SPL_IMX_ROMAPI_LOADADDR
 	hex "Default load address to load image through ROM API"
Signature · 1 line
2.34.1
#46 lore raw

Re: [PATCH v4 15/20] imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95

Quoted 16 lines · Alice Guo

From: Alice Guo <[email protected]>

i.MX95 only supports low power boot, which means A55 is kicked by M33. There is no ROM runs on A55 in such case so that deselect IMX8_ROMAPI for i.MX95.

---
  arch/arm/mach-imx/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/Kconfig +0 -0
index 134e42028c3787d78e28af03d40c41a8b2b1981b..daf6443aa5b40b6410f2645937239a4ec785fa34 100644

arch/arm/mach-imx/Kconfig config DDRMC_VF610_CALIBRATION · line 183

Quoted 5 lines
arch/arm/mach-imx/Kconfig +1 -1
@@ -180,7 +180,7 @@ config DDRMC_VF610_CALIBRATION
 
  config IMX8_ROMAPI
  	def_bool y
-	depends on IMX8MN || IMX8MP || IMX8ULP || IMX9
+	depends on IMX8MN || IMX8MP || IMX8ULP || (IMX9 && !IMX95)

Would it make sense to introduce IMX91 and IMX93 symbols instead and select those two instead of this negative match ?

author
#47 lore raw

PATCH v4 16/20 binman: add a new entry type for packing DDR PHY firmware images

In reply to Alice Guo

From: Alice Guo <[email protected]>

i.MX95 needs to combine DDR PHY firmware images and their byte counts together, so add a new entry type nxp-header-ddrfw for this requirement.

---
 tools/binman/entries.rst                  | 10 ++++++++++
 tools/binman/etype/nxp_header_ddrfw.py    | 32 +++++++++++++++++++++++++++++++
 tools/binman/ftest.py                     | 11 +++++++++++
 tools/binman/test/346_nxp_ddrfw_imx95.dts | 24 +++++++++++++++++++++++
 4 files changed, 77 insertions(+)
tools/binman/entries.rst +10 -0
index 780e9817fb6496b5f2a4aef6ed1c0b4c8d9a4ba2..6da3f0b904643360ca11da32e31129f5f54d279c 100644
@@ -1663,6 +1663,16 @@ Properties / Entry arguments:
 
 
 
+.. _etype_nxp_header_ddrfw:
+
+Entry: nxp-header-ddrfw: add a header to DDR PHY firmware images
+---------------------------------------------------
+
+This entry is used to combine DDR PHY firmware images and their byte counts
+together. See imx95_evk.rst for how to get DDR PHY Firmware Images.
+
+
+
 .. _etype_opensbi:
 
 Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
tools/binman/etype/nxp_header_ddrfw.py new file +32 -0
new file mode 100644
index 0000000000000000000000000000000000000000..80e0611df609107d6e092a5a6d8aec05b80a6347
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2025 NXP
+
+from binman.etype.section import Entry_section
+
+class Entry_nxp_header_ddrfw(Entry_section):
+    """Add a header to DDR PHY firmware images
+
+    This entry is used for i.MX95 to combine DDR PHY firmware images and their
+    byte counts together.
+
+    See imx95_evk.rst for how to get DDR PHY Firmware Images.
+    """
+
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+
+    def BuildSectionData(self, required):
+        section_data = bytearray()
+        header_data = bytearray()
+
+        for entry in self._entries.values():
+            entry_data = entry.GetData(required)
+
+            if not required and entry_data is None:
+                return None
+
+            section_data += entry_data
+            header_data += entry.contents_size.to_bytes(4, 'little')
+
+        return header_data + section_data
tools/binman/ftest.py +11 -0
index a553ca9e5642b685b908e817972b42bfba1d8a0a..62acc1d885cf6565999672d25584602929c3c4c3 100644
@@ -104,6 +104,8 @@ PRE_LOAD_VERSION      = 0x11223344.to_bytes(4, 'big')
 PRE_LOAD_HDR_SIZE     = 0x00001000.to_bytes(4, 'big')
 TI_BOARD_CONFIG_DATA  = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 TI_UNSECURE_DATA      = b'unsecuredata'
+IMX_LPDDR_IMEM_DATA   = b'qwertyuiop1234567890'
+IMX_LPDDR_DMEM_DATA   = b'asdfghjklzxcvbnm'
 
 # Subdirectory of the input dir to use to put test FDTs
 TEST_FDT_SUBDIR       = 'fdts'
@@ -202,6 +204,8 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('fsp_m.bin', FSP_M_DATA)
         TestFunctional._MakeInputFile('fsp_s.bin', FSP_S_DATA)
         TestFunctional._MakeInputFile('fsp_t.bin', FSP_T_DATA)
+        TestFunctional._MakeInputFile('lpddr5_imem.bin', IMX_LPDDR_IMEM_DATA)
+        TestFunctional._MakeInputFile('lpddr5_dmem.bin', IMX_LPDDR_DMEM_DATA)
 
         cls._elf_testdir = os.path.join(cls._indir, 'elftest')
         elf_test.BuildElfTestFiles(cls._elf_testdir)
@@ -7826,6 +7830,13 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         """Test that binman can produce an iMX8 image"""
         self._DoTestFile('339_nxp_imx8.dts')
 
+    def testNxpHeaderDdrfw(self):
+        """Test that binman can add a header to DDR PHY firmware images"""
+        data = self._DoReadFile('346_nxp_ddrfw_imx95.dts')
+        self.assertEqual(len(IMX_LPDDR_IMEM_DATA).to_bytes(4, 'little') +
+                         len(IMX_LPDDR_DMEM_DATA).to_bytes(4, 'little') +
+                         IMX_LPDDR_IMEM_DATA + IMX_LPDDR_DMEM_DATA, data)
+
     def testFitSignSimple(self):
         """Test that image with FIT and signature nodes can be signed"""
         if not elf.ELF_TOOLS:
tools/binman/test/346_nxp_ddrfw_imx95.dts new file +24 -0
new file mode 100644
index 0000000000000000000000000000000000000000..889f6f29860746c09a91aaad7658976559760d9c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		imx-lpddr {
+			type = "nxp-header-ddrfw";
+
+			imx-lpddr-imem {
+				filename = "lpddr5_imem.bin";
+				type = "blob-ext";
+			};
+
+			imx-lpddr-dmem {
+				filename = "lpddr5_dmem.bin";
+				type = "blob-ext";
+			};
+		};
+	};
+};
Signature · 1 line
2.34.1
author
#48 lore raw

PATCH v4 17/20 tools: imx8image: add i.MX95 support

In reply to Alice Guo

From: Alice Guo <[email protected]>

i.MX95 uses binman to invoke mkimage to create image container. 2 image containers are needed currently. The first one is composed of ahab-container.img, LPDDR firmware images, OEI images, System Manager image and u-boot-spl.bin. The second one is comsisted of ARM Trusted firmware and u-boot.bin.

Because DDR OEI image and LPDDR firmware images have to be packaged together and named as m33-oei-ddrfw.bin by binman, so imx9_image.sh does not check if m33-oei-ddrfw.bin exists.

When using "make imx95_19x19_evk_defconfig; make", imx9_image.sh will delete the line for u-boot.bin in container.cfg. In fact, binman is always called after the u-boot.bin is built, so imx9_image.sh does not check if u-boot.bin exists.

---
 include/imx8image.h |  19 +++++--
 tools/imx8image.c   | 143 +++++++++++++++++++++++++++++++++++++++++++++++-----
 tools/imx9_image.sh |   8 +++
 3 files changed, 153 insertions(+), 17 deletions(-)
include/imx8image.h +16 -3
index 6b95e93fb50980f9e86099b3103142dcbe38764a..b48e2b039698a225e152bddfe4b29be2fcbdc730 100644
@@ -157,7 +157,9 @@ enum imx8image_cmd {
 	CMD_SOC_TYPE,
 	CMD_CONTAINER,
 	CMD_IMAGE,
-	CMD_DATA
+	CMD_DATA,
+	CMD_DUMMY_V2X,
+	CMD_HOLD
 };
 
 enum imx8image_core_type {
@@ -169,7 +171,9 @@ enum imx8image_core_type {
 	CFG_A35,
 	CFG_A55,
 	CFG_A53,
-	CFG_A72
+	CFG_A72,
+	CFG_M33,
+	CFG_OEI
 };
 
 enum imx8image_fld_types {
@@ -208,7 +212,10 @@ typedef enum option_type {
 	FILEOFF,
 	MSG_BLOCK,
 	SENTINEL,
-	UPOWER
+	UPOWER,
+	OEI,
+	DUMMY_V2X,
+	HOLD
 } option_type_t;
 
 typedef struct {
@@ -227,12 +234,16 @@ typedef struct {
 #define CORE_CA35       4
 #define CORE_CA72       5
 #define CORE_SECO       6
+#define CORE_M33        7
 
 #define CORE_ULP_CM33		0x1
 #define CORE_ULP_CA35		0x2
 #define CORE_ULP_UPOWER 	0x4
 #define CORE_ULP_SENTINEL 	0x6
 
+#define CORE_IMX95_M33P		0
+#define CORE_IMX95_A55C0	2
+
 #define SC_R_OTP	357U
 #define SC_R_DEBUG	354U
 #define SC_R_ROM_0	236U
@@ -246,10 +257,12 @@ typedef struct {
 #define IMG_TYPE_EXEC    0x03   /* Executable image type */
 #define IMG_TYPE_DATA    0x04   /* Data image type */
 #define IMG_TYPE_DCD_DDR 0x05   /* DCD/DDR image type */
+#define IMG_TYPE_OEI     0x05   /* Optional Executable image type */
 #define IMG_TYPE_SECO    0x06   /* SECO image type */
 #define IMG_TYPE_SENTINEL 0x06	/* SENTINEL image type */
 #define IMG_TYPE_PROV    0x07   /* Provisioning image type */
 #define IMG_TYPE_DEK     0x08   /* DEK validation type */
+#define IMG_TYPE_V2X_DUMMY 0x0E /* V2X Dummy image */
 
 #define IMG_TYPE_SHIFT   0
 #define IMG_TYPE_MASK    0x1f
tools/imx8image.c +129 -14

298 lines not on this page · raw message

tools/imx9_image.sh +8 -0
index ca78a57a19a06ade4792da6d2435cbc4fa07de62..6523d1a0ad109db2da29bae122a20b084c2522ed 100755
@@ -18,6 +18,14 @@ for f in $blobs; do
 		continue
 	fi
 
+	if [ $f = "m33-oei-ddrfw.bin" ]; then
+		continue
+	fi
+
+	if [ $f = "u-boot.bin" ]; then
+		continue
+	fi
+
 	if [ ! -f $tmp ]; then
 		echo "WARNING '$tmp' not found, resulting binary may be not-functional" >&2
 
Signature · 1 line
2.34.1
#49 lore raw

Re: [PATCH v4 17/20] tools: imx8image: add i.MX95 support

Quoted 6 lines · Alice Guo

From: Alice Guo <[email protected]>

i.MX95 uses binman to invoke mkimage to create image container. 2 image containers are needed currently. The first one is composed of ahab-container.img, LPDDR firmware images, OEI images, System Manager image and u-boot-spl.bin. The second one is comsisted of ARM Trusted

comsisted -- typo.

[...]

tools/imx8image.c static void set_image_array_entry(flash_header_v3_t *container, · line 645

Quoted 9 lines
tools/imx8image.c +3 -1
@@ -586,8 +639,10 @@ static void set_image_array_entry(flash_header_v3_t *container,
  			meta = IMAGE_A53_DEFAULT_META(custom_partition);
  		} else if (soc == QM && core == CORE_CA72) {
  			meta = IMAGE_A72_DEFAULT_META(custom_partition);
-		} else if (((soc == ULP) || (soc == IMX9)) && core == CORE_CA35) {
+		} else if ((soc == ULP) && core == CORE_CA35) {
  			meta = 0;
+		} else if ((soc == IMX9) && core == CORE_CA35) {
+			meta = CORE_IMX95_A55C0;

Why is this core == CORE_CA35 and not core == CORE_CA55 here ?

author
#50 lore raw

PATCH v4 18/20 imx: add V2X container support on i.MX95

In reply to Alice Guo

From: Teo Hall <[email protected]>

This patch adds V2X container support on i.MX95.

---
 arch/arm/mach-imx/image-container.c | 63 +++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 23 deletions(-)
arch/arm/mach-imx/image-container.c +40 -23
index 2afe9d38a0681862098a6566a873873f24069b88..54ae7721888dbc93fdaba8e5aedc52c4506bb1c1 100644
@@ -231,45 +231,62 @@ static unsigned long get_boot_device_offset(void *dev, int dev_type)
 	return offset;
 }
 
-static int get_imageset_end(void *dev, int dev_type)
+static ulong get_imageset_end(void *dev, int dev_type)
 {
-	unsigned long offset1 = 0, offset2 = 0;
-	int value_container[2];
+	unsigned long offset[3] = {};
+	int value_container[3] = {};
 	u16 hdr_length;
 
-	offset1 = get_boot_device_offset(dev, dev_type);
-	offset2 = CONTAINER_HDR_ALIGNMENT + offset1;
+	offset[0] = get_boot_device_offset(dev, dev_type);
 
-	value_container[0] = get_dev_container_size(dev, dev_type, offset1, &hdr_length);
+	value_container[0] = get_dev_container_size(dev, dev_type, offset[0], &hdr_length);
 	if (value_container[0] < 0) {
 		printf("Parse seco container failed %d\n", value_container[0]);
-		return value_container[0];
+		return 0;
 	}
 
 	debug("seco container size 0x%x\n", value_container[0]);
 
-	value_container[1] = get_dev_container_size(dev, dev_type, offset2, &hdr_length);
-	if (value_container[1] < 0) {
-		debug("Parse scu container failed %d, only seco container\n",
-		      value_container[1]);
-		/* return seco container total size */
-		return value_container[0] + offset1;
+	if (is_imx95()) {
+		offset[1] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + offset[0];
+
+		value_container[1] = get_dev_container_size(dev, dev_type, offset[1], &hdr_length);
+		if (value_container[1] < 0) {
+			printf("Parse v2x container failed %d\n", value_container[1]);
+			return value_container[0] + offset[0]; /* return seco container total size */
+		}
+
+		debug("v2x container size 0x%x\n", value_container[1]);
+
+		offset[2] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + offset[1];
+	} else {
+		/* Skip offset[1] */
+		offset[2] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + offset[0];
 	}
 
-	debug("scu container size 0x%x\n", value_container[1]);
+	value_container[2] = get_dev_container_size(dev, dev_type, offset[2], &hdr_length);
+	if (value_container[2] < 0) {
+		debug("Parse scu container image failed %d, only seco container\n", value_container[2]);
+		if (is_imx95())
+			return value_container[1] + offset[1]; /* return seco + v2x container total size */
+		else
+			return value_container[0] + offset[0]; /* return seco container total size */
+	}
 
-	return value_container[1] + offset2;
+	debug("scu container size 0x%x\n", value_container[2]);
+
+	return value_container[2] + offset[2];
 }
 
 #ifdef CONFIG_SPL_SPI_LOAD
 unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash)
 {
-	int end;
+	ulong end;
 
 	end = get_imageset_end(flash, QSPI_DEV);
 	end = ROUND(end, SZ_1K);
 
-	printf("Load image from QSPI 0x%x\n", end);
+	printf("Load image from QSPI 0x%lx\n", end);
 
 	return end;
 }
@@ -279,12 +296,12 @@ unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash)
 unsigned long arch_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
 						unsigned long raw_sect)
 {
-	int end;
+	ulong end;
 
 	end = get_imageset_end(mmc, MMC_DEV);
 	end = ROUND(end, SZ_1K);
 
-	printf("Load image from MMC/SD 0x%x\n", end);
+	printf("Load image from MMC/SD 0x%lx\n", end);
 
 	return end / mmc->read_bl_len;
 }
@@ -312,12 +329,12 @@ int spl_mmc_emmc_boot_partition(struct mmc *mmc)
 #ifdef CONFIG_SPL_NAND_SUPPORT
 uint32_t spl_nand_get_uboot_raw_page(void)
 {
-	int end;
+	ulong end;
 
 	end = get_imageset_end((void *)NULL, NAND_DEV);
 	end = ROUND(end, SZ_16K);
 
-	printf("Load image from NAND 0x%x\n", end);
+	printf("Load image from NAND 0x%lx\n", end);
 
 	return end;
 }
@@ -326,7 +343,7 @@ uint32_t spl_nand_get_uboot_raw_page(void)
 #ifdef CONFIG_SPL_NOR_SUPPORT
 unsigned long spl_nor_get_uboot_base(void)
 {
-	int end;
+	ulong end;
 
 	/* Calculate the image set end,
 	 * if it is less than CFG_SYS_UBOOT_BASE(0x8281000),
@@ -339,7 +356,7 @@ unsigned long spl_nor_get_uboot_base(void)
 	else
 		end = ROUND(end, SZ_1K);
 
-	printf("Load image from NOR 0x%x\n", end);
+	printf("Load image from NOR 0x%lx\n", end);
 
 	return end;
 }
Signature · 1 line
2.34.1
author
#51 lore raw

PATCH v4 19/20 doc: imx: add document for i.MX95 Image Container Format

In reply to Alice Guo

From: Alice Guo <[email protected]>

This patch add a document for i.MX95 Image Container Format.

---
 doc/imx/imx95_container.txt | 136 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)
doc/imx/imx95_container.txt new file +136 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2ad573450697ae344d8703f43d050ddd1fef7a85
@@ -0,0 +1,136 @@
+i.MX95 Image Container Format
+-----------------------------
+
+The image container set consists of some image containers, and image container
+contains boot images. Each image container has its own container header which is
+defined in Figure 1. All container headers are placed together in a continuous
+8KB space at the beginning of the image container set - image container set header.
+
+ROM code addresses image containers in image container set one by one based on
+their headers’ order in image container set header.
+
+If ELE container exists, its container header must be the 1st one in the image
+container set header.
+
+If V2X container exists, its container header must be the 2nd one in the image
+container set header. V2X must be combined with ELE container.
+
+The information of boot images are recorded in image container header. System
+ROM code needs to retrieve the information from the image container header, like
+the offset on boot source, the target address in RAM, the length of boot image.
+The order of ROM code handling these boot images is based on the order of each
+boot image information present in image container header.
+
+Figure 1:
+------------------- +--------------+--------------+--------------+--------------+
+          ^         |Tag           |Length        |Length        |Version       |
+          |         +--------------+--------------+--------------+--------------+
+          |         |                           Flags                           |
+          |         +--------------+--------------+--------------+--------------+
+          |         |# of Images   |Fuse version  |SW version                   |
+Image     |         +--------------+--------------+--------------+--------------+
+Conatiner |         |Reserved                     |Signature Block Offset       |
+Header    | ------- +--------------+--------------+--------------+--------------+
+          |       ^ |Image0: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, IV|
+          |       | +--------------+--------------+--------------+--------------+
+          | Image | |Image1: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, IV|
+          | Array | +--------------+--------------+--------------+--------------+
+          |       | |                            ...                            |
+          |       | +--------------+--------------+--------------+--------------+
+          v       v |ImageN: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, IV|
+------------------- +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+        ----------- +--------------+--------------+--------------+--------------+ <-- SignOffset
+                  ^ |Tag           |Length        |Length        |Version       |
+                  | +--------------+--------------+--------------+--------------+
+                  | |SRK table offset             |Certificate Offset           |
+                  | +--------------+--------------+--------------+--------------+
+                  | |Blob Offset                  |Signature Offset             |
+                  | +--------------+--------------+--------------+--------------+
+        Signature | |                         SRK Table                         |
+        Block     | +--------------+--------------+--------------+--------------+
+                  | |                         Signature                         |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                   Certificate (optional)                  |
+                  | +--------------+--------------+--------------+--------------+
+                  v |                      Blob (optional)                      |
+        ----------- +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+ <-- Image0Offset
+                    |                           Image0                          |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+ <-- ImageNOffset
+                    |                           ImageN                          |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+
+i.MX95 Low Power Boot Image Sets Layout
+---------------------------------------
+
+    Image container sets are handled by M33 ROM.
+
+    --------------- +--------------+--------------+--------------+--------------+
+                  ^ |                    1st Container Header                   |
+                  | +--------------+--------------+--------------+--------------+
+    ELE +         | |                 Padding for 1KB alignment                 |
+    OEM           | +--------------+--------------+--------------+--------------+
+    Conatiner     | |                    2nd Container Header                   |
+    Set           | +--------------+--------------+--------------+--------------+
+    Header        | |                 Padding for 1KB alignment                 |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                    3rd Container Header                   |
+                  | +--------------+--------------+--------------+--------------+
+                  v |                 Padding for 1KB alignment                 |
+    --------------- +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                 mx95a0-ahab-container.img                 |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+------------------- +--------------+--------------+--------------+--------------+
+                  ^ |                      oei-m33-ddr.bin                      |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                      ddrfw-header.bin                     |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                  lpddr5_imem_v202311.bin                  |
+                  | +--------------+--------------+--------------+--------------+
+m33-oei-ddrfw.bin | |                  lpddr5_dmem_v202311.bin                  |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                     ddrfw-qb-header.bin                   |
+                  | +--------------+--------------+--------------+--------------+
+                  | |                 lpddr5_imem_qb_v202311.bin                |
+                  | +--------------+--------------+--------------+--------------+
+                  v |                 lpddr5_dmem_qb_v202311.bin                |
+------------------- +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                      oei-m33-tcm.bin                      |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                       m33_image.bin                       |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                      u-boot-spl.bin                       |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+
+    --------------- +--------------+--------------+--------------+--------------+
+    u-boot-atf    ^ |                    1st Container Header                   |
+    Container     | +--------------+--------------+--------------+--------------+
+    Header        v |                 Padding for 1KB alignment                 |
+    --------------- +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                          bl31.bin                         |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
+                    |                         u-boot.bin                        |
+                    +--------------+--------------+--------------+--------------+
+                    |                            ...                            |
+                    +--------------+--------------+--------------+--------------+
Signature · 1 line
2.34.1
author
#52 lore raw

PATCH v4 20/20 imx95_evk: add i.MX95 19x19 EVK board basic support

In reply to Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---
 arch/arm/dts/imx95-19x19-evk-u-boot.dtsi      |  68 ++++++++++
 arch/arm/dts/imx95-u-boot.dtsi                | 157 +++++++++++++++++++++++
 arch/arm/mach-imx/imx9/Kconfig                |   6 +
 arch/arm/mach-imx/imx9/scmi/container.cfg     |  10 ++
 arch/arm/mach-imx/imx9/scmi/imximage.cfg      |  15 +++
 board/freescale/imx95_evk/Kconfig             |  12 ++
 board/freescale/imx95_evk/MAINTAINERS         |   6 +
 board/freescale/imx95_evk/Makefile            |  11 ++
 board/freescale/imx95_evk/imx95_19x19_evk.env |  90 +++++++++++++
 board/freescale/imx95_evk/imx95_evk.c         |  54 ++++++++
 board/freescale/imx95_evk/spl.c               |  72 +++++++++++
 configs/imx95_19x19_evk_defconfig             | 177 ++++++++++++++++++++++++++
 doc/board/nxp/imx95_evk.rst                   | 114 +++++++++++++++++
 doc/board/nxp/index.rst                       |   1 +
 include/configs/imx95_evk.h                   |  27 ++++
 15 files changed, 820 insertions(+)
arch/arm/dts/imx95-19x19-evk-u-boot.dtsi new file +68 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2902e8f711c3ef705df27ca4fc7a89d1bd7ffc71
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include "imx95-u-boot.dtsi"
+
+&gpio1 {
+	reg = <0 0x47400000 0 0x1000>, <0 0x47400040 0 0x40>;
+};
+
+&lpuart1 {
+	clocks = <&scmi_clk IMX95_CLK_LPUART1>, <&scmi_clk IMX95_CLK_LPUART1>;
+	clock-names = "ipg", "per";
+	bootph-pre-ram;
+};
+
+&reg_usdhc2_vmmc {
+	bootph-pre-ram;
+};
+
+&usdhc1 {
+	bootph-pre-ram;
+};
+
+&usdhc2 {
+	bootph-pre-ram;
+};
+
+&wdog3 {
+	status = "disabled";
+};
+
+&pinctrl_uart1 {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc1 {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc1_100mhz {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc1_200mhz {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc2 {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_100mhz {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_200mhz {
+	bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_gpio {
+	bootph-pre-ram;
+};
+
+&pinctrl_reg_usdhc2_vmmc {
+	bootph-pre-ram;
+};
arch/arm/dts/imx95-u-boot.dtsi new file +157 -0

157 lines not on this page · raw message

arch/arm/mach-imx/imx9/Kconfig +6 -0
index 660529555e9b3d38a6fb70c77858bd9de7473461..4dd73f0a9e525ebbb8559639f914504ec53f15dd 100644
@@ -68,6 +68,11 @@ config TARGET_PHYCORE_IMX93
 	select OF_BOARD_FIXUP
 	select OF_BOARD_SETUP
 
+config TARGET_IMX95_19X19_EVK
+	bool "imx95_19x19_evk"
+	select IMX95
+	imply OF_UPSTREAM
+
 endchoice
 
 source "board/freescale/imx91_evk/Kconfig"
@@ -75,6 +80,7 @@ source "board/freescale/imx93_evk/Kconfig"
 source "board/freescale/imx93_qsb/Kconfig"
 source "board/phytec/phycore_imx93/Kconfig"
 source "board/variscite/imx93_var_som/Kconfig"
+source "board/freescale/imx95_evk/Kconfig"
 
 endif
 
arch/arm/mach-imx/imx9/scmi/container.cfg new file +10 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ac5a0a281812faf9edff53b49cc19ed769352d71
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2025 NXP
+ */
+
+BOOT_FROM SD
+SOC_TYPE IMX9
+CONTAINER
+IMAGE A55 bl31.bin 0x8a200000
+IMAGE A55 u-boot.bin CONFIG_TEXT_BASE
\ No newline at end of file
arch/arm/mach-imx/imx9/scmi/imximage.cfg new file +15 -0
new file mode 100644
index 0000000000000000000000000000000000000000..678d15c99be78598ff8dd7a4218530e43e9db2c0
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2025 NXP
+ */
+
+BOOT_FROM SD
+SOC_TYPE IMX9
+APPEND mx95a0-ahab-container.img
+CONTAINER
+IMAGE OEI m33-oei-ddrfw.bin 0x1ffc0000
+HOLD 0x10000
+IMAGE OEI oei-m33-tcm.bin 0x1ffc0000
+IMAGE M33 m33_image.bin 0x1ffc0000
+IMAGE A55 spl/u-boot-spl.bin 0x20480000
+DUMMY_V2X 0x8b000000
\ No newline at end of file
board/freescale/imx95_evk/Kconfig new file +12 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f9a67353e5db6d3ec94784cf091e45d8817d541c
@@ -0,0 +1,12 @@
+if TARGET_IMX95_19X19_EVK
+
+config SYS_BOARD
+	default "imx95_evk"
+
+config SYS_VENDOR
+	default "freescale"
+
+config SYS_CONFIG_NAME
+	default "imx95_evk"
+
+endif
board/freescale/imx95_evk/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5caf763e0cc390c46fc54ee627bc966b2b110958
@@ -0,0 +1,6 @@
+i.MX95 EVK BOARD
+M:	Alice Guo <[email protected]>
+S:	Maintained
+F:	board/freescale/imx95_evk/
+F:	include/configs/imx95_evk.h
+F:	configs/imx95_19x19_evk_defconfig
board/freescale/imx95_evk/Makefile new file +11 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0f5cec385c35059ac5bbcf31868855c10a6c2fe4
@@ -0,0 +1,11 @@
+#
+# Copyright 2025 NXP
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-y += imx95_evk.o
+
+ifdef CONFIG_SPL_BUILD
+obj-y += spl.o
+endif
board/freescale/imx95_evk/imx95_19x19_evk.env new file +90 -0

91 lines not on this page · raw message

board/freescale/imx95_evk/imx95_evk.c new file +54 -0

54 lines not on this page · raw message

board/freescale/imx95_evk/spl.c new file +72 -0

72 lines not on this page · raw message

configs/imx95_19x19_evk_defconfig new file +177 -0

177 lines not on this page · raw message

doc/board/nxp/imx95_evk.rst new file +114 -0

114 lines not on this page · raw message

doc/board/nxp/index.rst +1 -0
index 8ca4b5619863f616dbedc7eb0ff8a286a3fbbf48..e7ec725cc04e9755ba3dac37561c26ebc3f1c716 100644
@@ -15,6 +15,7 @@ NXP Semiconductors
    imx91_11x11_evk
    imx93_9x9_qsb
    imx93_11x11_evk
+   imx95_evk
    imxrt1020-evk
    imxrt1050-evk
    imxrt1170-evk
include/configs/imx95_evk.h new file +27 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b077fa7af7d1e56a00278d0f3feb9fd7b0c55f42
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2025 NXP
+ */
+
+#ifndef __IMX95_EVK_H
+#define __IMX95_EVK_H
+
+#include <linux/sizes.h>
+#include <linux/stringify.h>
+#include <asm/arch/imx-regs.h>
+
+#define CFG_SYS_UBOOT_BASE	\
+	(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+
+#define CFG_SYS_INIT_RAM_ADDR	0x90000000
+#define CFG_SYS_INIT_RAM_SIZE	0x200000
+
+#define CFG_SYS_SDRAM_BASE		0x90000000
+#define PHYS_SDRAM				0x90000000
+/* Totally 16GB */
+#define PHYS_SDRAM_SIZE			0x70000000 /* 2GB - 256MB DDR */
+#define PHYS_SDRAM_2_SIZE		0x380000000 /* 14GB */
+
+#define WDOG_BASE_ADDR			WDG3_BASE_ADDR
+
+#endif
Signature · 1 line
2.34.1
#53 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Quoted 12 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

<snip...>

Quoted 19 lines
board/freescale/imx95_evk/imx95_evk.c new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0b32101dc7f9899f4f
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_evk.c line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

board/freescale/imx95_evk/imx95_evk.c line 25

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

#54 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Quoted 54 lines · Tim Harvey
Quoted 12 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

<snip...>

Quoted 19 lines
board/freescale/imx95_evk/imx95_evk.c new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0b32101dc7f9899f4f
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_evk.c line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

Quoted 8 lines

board/freescale/imx95_evk/imx95_evk.c line 25

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

Hi Alic,

One more thing to do for next series. Refresh your imx95_19x19_evk_defconfig as its very out of sync:

make imx95_19x19_evk_defconfig
make savedefconfig
cp defconfig configs/imx95_19x19_evk_defconfig

Best Regards,

Tim

#55 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Quoted 64 lines · Tim Harvey
Quoted 54 lines · Tim Harvey
Quoted 12 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

<snip...>

Quoted 19 lines
board/freescale/imx95_evk/imx95_evk.c new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0b32101dc7f9899f4f
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_evk.c line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

Quoted 8 lines

board/freescale/imx95_evk/imx95_evk.c line 25

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

Quoted 8 lines

Hi Alic,

One more thing to do for next series. Refresh your imx95_19x19_evk_defconfig as its very out of sync:

make imx95_19x19_evk_defconfig
make savedefconfig
cp defconfig configs/imx95_19x19_evk_defconfig

And please enable CONFIG_FIT and CONFIG_FIT_VERBOSE .

#56 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Quoted 67 lines · Marek Vasut
Quoted 66 lines · Tim Harvey
Quoted 54 lines · Tim Harvey
Quoted 12 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

<snip...>

Quoted 19 lines
board/freescale/imx95_evk/imx95_evk.c new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0b32101dc7f9899f4f
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_evk.c line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

Quoted 8 lines

board/freescale/imx95_evk/imx95_evk.c line 25

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

Hi Alic,

Quoted 7 lines
Quoted 6 lines

One more thing to do for next series. Refresh your imx95_19x19_evk_defconfig as its very out of sync:

make imx95_19x19_evk_defconfig
make savedefconfig
cp defconfig configs/imx95_19x19_evk_defconfig

And please enable CONFIG_FIT and CONFIG_FIT_VERBOSE .

Which should already be there if using bootstd to boot and not distro boot scripts, another thing that should be done now and not later.

Signature · 1 line
Tom
#57 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

In reply to Tim Harvey
Quoted 65 lines · Tim Harvey
Quoted 54 lines · Tim Harvey
Quoted 12 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

<snip...>

Quoted 19 lines
board/freescale/imx95_evk/imx95_evk.c new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0b32101dc7f9899f4f
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_evk.c line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

Quoted 8 lines

board/freescale/imx95_evk/imx95_evk.c line 25

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

Quoted 9 lines

Hi Alic,

One more thing to do for next series. Refresh your imx95_19x19_evk_defconfig as its very out of sync:

make imx95_19x19_evk_defconfig
make savedefconfig
cp defconfig configs/imx95_19x19_evk_defconfig

Hi Alice,

I'm also seeing the following files left around after a build that are also not removed after a clean/distclean:
mkimage-out.imx-boot.spl mkimage-out.imx-boot.u-boot
mkimage.imx-boot.spl
mkimage.imx-boot.u-boot

Best Regards,

Tim

#58 lore raw

回复: [EXT] Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Quoted 104 lines

-----邮件原件-----
发件人: Tim Harvey <[email protected]>
发送时间: 2025年1月17日 6:48
收件人: Alice Guo (OSS) <[email protected]>
抄送: Tom Rini <[email protected]>; Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; dl-uboot-imx <[email protected]>; Lukasz Majewski <[email protected]>; Sean Anderson <[email protected]>; Simon Glass <[email protected]>; Alper Nebi Yasak <[email protected]>; [email protected]; [email protected]; Alice Guo <[email protected]>; Ye Li <[email protected]>; Peng Fan <[email protected]>
主题: [EXT] Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 2 lines · Tim Harvey

On Thu, Jan 16, 2025 at 11:38 AM Tim Harvey <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

On Wed, Jan 15, 2025 at 5:30 AM Alice Guo <[email protected]>

Quoted 12 lines · wrote:
Quoted 12 lines
Quoted 12 lines

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---

Quoted 6 lines
Quoted 6 lines

<snip...>

Quoted 5 lines
board/freescale/imx95_evk/imx95_evk.c new file +0 -0
new file mode 100644

index

0000000000000000000000000000000000000000..1ed15ca47b157067a7376b0 b

Quoted 39 lines
Quoted 30 lines
Quoted 10 lines

32101dc7f9899f4f

board/freescale/imx95_evk/imx95_evk.c new file +6 -0
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>

board/freescale/imx95_evk/imx95_evk.c line 16

Quoted 10 lines
board/freescale/imx95_evk/imx95_evk.c new file +10 -0
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h> #include <asm/arch/clock.h>
+#include <fdt_support.h> #include <asm/io.h> #include
+<linux/bitfield.h> #include <linux/bitops.h> #include
+<linux/delay.h> #include <miiphy.h> #include <netdev.h> #include
+<asm/gpio.h> #include <asm/mach-imx/sys_proto.h> #include
+<scmi_agent.h> #include <scmi_protocols.h> #include
+"../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Hi Alice,

Most of the above are not needed (and should be alphabetized anyway)

The only ones needed are:
#include <asm/arch/clock.h>
#include <asm/gpio.h>
#include <asm/mach-imx/sys_proto.h>

Quoted 8 lines

board/freescale/imx95_evk/imx95_evk.c line 18

Quoted 2 lines
board/freescale/imx95_evk/imx95_evk.c new file +2 -0
+
+DECLARE_GLOBAL_DATA_PTR;

not needed as you don't use gd

Best Regards,

Tim

Quoted 9 lines

Hi Alic,

One more thing to do for next series. Refresh your imx95_19x19_evk_defconfig as its very out of sync:

make imx95_19x19_evk_defconfig
make savedefconfig
cp defconfig configs/imx95_19x19_evk_defconfig

Hi Alice,

I'm also seeing the following files left around after a build that are also not removed after a clean/distclean:
mkimage-out.imx-boot.spl
mkimage-out.imx-boot.u-boot
mkimage.imx-boot.spl
mkimage.imx-boot.u-boot

Quoted 3 lines

Best Regards,

Tim

Will improve these in v5.

Best Regards,
Alice Guo

#59 lore raw

Re: [PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

In reply to Alice Guo
Quoted 34 lines · Alice Guo

From: Ye Li <[email protected]>

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System Manager, uSDHC for SD Card, gpio, lpuart are supported now.

---
  arch/arm/dts/imx95-19x19-evk-u-boot.dtsi      |  68 ++++++++++
  arch/arm/dts/imx95-u-boot.dtsi                | 157 +++++++++++++++++++++++
  arch/arm/mach-imx/imx9/Kconfig                |   6 +
  arch/arm/mach-imx/imx9/scmi/container.cfg     |  10 ++
  arch/arm/mach-imx/imx9/scmi/imximage.cfg      |  15 +++
  board/freescale/imx95_evk/Kconfig             |  12 ++
  board/freescale/imx95_evk/MAINTAINERS         |   6 +
  board/freescale/imx95_evk/Makefile            |  11 ++
  board/freescale/imx95_evk/imx95_19x19_evk.env |  90 +++++++++++++
  board/freescale/imx95_evk/imx95_evk.c         |  54 ++++++++
  board/freescale/imx95_evk/spl.c               |  72 +++++++++++
  configs/imx95_19x19_evk_defconfig             | 177 ++++++++++++++++++++++++++
  doc/board/nxp/imx95_evk.rst                   | 114 +++++++++++++++++
  doc/board/nxp/index.rst                       |   1 +
  include/configs/imx95_evk.h                   |  27 ++++
  15 files changed, 820 insertions(+)
arch/arm/dts/imx95-19x19-evk-u-boot.dtsi new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2902e8f711c3ef705df27ca4fc7a89d1bd7ffc71

arch/arm/dts/imx95-19x19-evk-u-boot.dtsi line 9

Quoted 9 lines
arch/arm/dts/imx95-19x19-evk-u-boot.dtsi new file +9 -0
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include "imx95-u-boot.dtsi"
+
+&gpio1 {
+	reg = <0 0x47400000 0 0x1000>, <0 0x47400040 0 0x40>;

Why is this override here ?

arch/arm/dts/imx95-19x19-evk-u-boot.dtsi line 14

Quoted 5 lines
arch/arm/dts/imx95-19x19-evk-u-boot.dtsi new file +5 -0
+};
+
+&lpuart1 {
+	clocks = <&scmi_clk IMX95_CLK_LPUART1>, <&scmi_clk IMX95_CLK_LPUART1>;
+	clock-names = "ipg", "per";

Are these overrides necessary ?

[...]

Quoted 22 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +16 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8d2b5dfcf07d251c77440bae44d62bff6253dfc7
@@ -0,0 +1,90 @@
+sec_boot=no
+initrd_addr=0x93800000
+emmc_dev=0
+sd_dev=1
+scriptaddr=0x93500000
+kernel_addr_r=CONFIG_SYS_LOAD_ADDR
+image=Image
+splashimage=0xA0000000
+console=ttyLP0,115200 earlycon
+fdt_addr_r=0x93000000
+fdt_addr=0x93000000
+cntr_addr=0xA8000000
+cntr_file=os_cntr_signed.bin
+boot_fit=no
+fdtfile=CONFIG_DEFAULT_FDT_FILE
+bootm_size=0x10000000

board/freescale/imx95_evk/imx95_19x19_evk.env line 26

Quoted 10 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +10 -0
+mmcautodetect=yes
+mmcargs=setenv bootargs console=${console} root=${mmcroot}
+loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
+bootscript=echo Running bootscript from mmc ...; source
+loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
+loadcntr=fatload mmc ${mmcdev}:${mmcpart} ${cntr_addr} ${cntr_file}
+auth_os=auth_cntr ${cntr_addr}
+boot_os=booti ${loadaddr} - ${fdt_addr_r};
+mmcboot=echo Booting from mmc ...;

Did you consider switching to modern "bootflow"/"bootmethod" ?

[...]

Quoted 15 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +14 -0
+++ b/board/freescale/imx95_evk/imx95_evk.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include <env.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm/arch-imx9/ccm_regs.h>
+#include <asm/arch/clock.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <linux/bitfield.h>

board/freescale/imx95_evk/imx95_19x19_evk.env line 23

Quoted 10 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +10 -0
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/gpio.h>
+#include <asm/mach-imx/sys_proto.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include "../../../dts/upstream/src/arm64/freescale/imx95-clock.h"
+#include "../../../dts/upstream/src/arm64/freescale/imx95-power.h"

Are all these headers really needed for this trivial C file ? I think not, so please remove all the unnecessary ones .

Quoted 9 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +9 -0
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_early_init_f(void)
+{
+	/* UART1: A55, UART2: M33, UART3: M7 */
+	init_uart_clk(0);
+
+	return 0;
+}

board/freescale/imx95_evk/imx95_19x19_evk.env line 42

Quoted 10 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +10 -0
+
+int board_init(void)
+{
+	return 0;
+}
+
+int board_late_init(void)
+{
+#ifdef CONFIG_ENV_IS_IN_MMC
+	board_late_mmc_env_init();

Use if (CONFIG_IS_ENABLED()) ... please fix globally .

[...]

Quoted 6 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +5 -0
+++ b/include/configs/imx95_evk.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2025 NXP
+ */

board/freescale/imx95_evk/imx95_19x19_evk.env line 14

Quoted 10 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +10 -0
+
+#ifndef __IMX95_EVK_H
+#define __IMX95_EVK_H
+
+#include <linux/sizes.h>
+#include <linux/stringify.h>
+#include <asm/arch/imx-regs.h>
+
+#define CFG_SYS_UBOOT_BASE	\
+	(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)

Is this option really necessary ?

Try and look at CONFIG_POSITION_INDEPENDENT .

board/freescale/imx95_evk/imx95_19x19_evk.env line 24

Quoted 10 lines
board/freescale/imx95_evk/imx95_19x19_evk.env new file +10 -0
+#define CFG_SYS_INIT_RAM_ADDR	0x90000000
+#define CFG_SYS_INIT_RAM_SIZE	0x200000
+
+#define CFG_SYS_SDRAM_BASE		0x90000000
+#define PHYS_SDRAM				0x90000000
+/* Totally 16GB */
+#define PHYS_SDRAM_SIZE			0x70000000 /* 2GB - 256MB DDR */
+#define PHYS_SDRAM_2_SIZE		0x380000000 /* 14GB */
+
+#define WDOG_BASE_ADDR			WDG3_BASE_ADDR

Is this watchdog config option needed ?