Skip to contentSkip to conversation

MPFS Icicle Kit Cleanup

PATCH In review Jamie Gibbons 2 participants 13 messages Aug 1, 2025 – Aug 12, 2025

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

cover MPFS Icicle Kit Cleanup

Hi all,

The following patch series completes a series of cleanups for Microchip's MPFS Icicle Kit. This includes making use of the CONFIG_OF_BOARD_SETUP functionality to move the ethernet mac address setting to the ft_board_setup() function which allows replacing fdt set in boot scripts for Microchip's MPFS Icicle kit.

Additionally, the Icicle Kit board file is further cleaned up with the addition of two new drivers - mailbox and system controller - to move all functions which interact with the system controller and which can be reused in other areas out of the board file.

Regards,
Jamie Gibbons

Jamie Gibbons (6):
configs: microchip_mpfs_icicle: enable CONFIG_OF_BOARD_SETUP
board: microchip: mpfs_icicle: make use of ft_board_setup()
mailbox: add PolarFire SoC mailbox driver
misc: add PolarFire SoC system controller
board: microchip: mpfs_icicle: enable new driver configs
board: microchip: mpfs_icicle: update to use system controller

 board/microchip/mpfs_icicle/Kconfig       |   4 +
 board/microchip/mpfs_icicle/mpfs_icicle.c | 121 +++++++--------
 configs/microchip_mpfs_icicle_defconfig   |   4 +
 drivers/mailbox/Kconfig                   |   7 +
 drivers/mailbox/Makefile                  |   1 +
 drivers/mailbox/mpfs-mbox.c               | 177 ++++++++++++++++++++++
 drivers/misc/Kconfig                      |   9 ++
 drivers/misc/Makefile                     |   1 +
 drivers/misc/mpfs_syscontroller.c         | 157 +++++++++++++++++++
 include/mpfs-mailbox.h                    |  67 ++++++++
 10 files changed, 484 insertions(+), 64 deletions(-)
 create mode 100644 drivers/mailbox/mpfs-mbox.c
 create mode 100644 drivers/misc/mpfs_syscontroller.c
 create mode 100644 include/mpfs-mailbox.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 configs: microchip_mpfs_icicle: enable CONFIG_OF_BOARD_SETUP

Enable CONFIG_OF_BOARD_SETUP and other dependencies to allow the use of the ft_board_setup() function to replace fdt set in boot scripts for Microchip's MPFS Icicle kit.

---
 configs/microchip_mpfs_icicle_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
configs/microchip_mpfs_icicle_defconfig +4 -0
index 6937aa224a1..7aefcc5fa86 100644
@@ -5,6 +5,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000
 CONFIG_ENV_SIZE=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="microchip/mpfs-icicle-kit"
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x80200000
 CONFIG_SYS_MEM_TOP_HIDE=0x400000
 # CONFIG_DEBUG_UART is not set
@@ -12,14 +13,17 @@ CONFIG_TARGET_MICROCHIP_ICICLE=y
 CONFIG_ARCH_RV64I=y
 CONFIG_RISCV_SMODE=y
 CONFIG_FIT=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_DEFAULT_FDT_FILE="microchip/mpfs-icicle-kit.dtb"
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=282
+CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SYS_PROMPT="RISC-V # "
 CONFIG_OF_UPSTREAM=y
+CONFIG_OVERWRITE_ETHADDR_ONCE=y
 CONFIG_ENV_RELOC_GD_ENV_ADDR=y
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_DM_MTD=y
Signature · 1 line
2.43.0
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] configs: microchip_mpfs_icicle: enable CONFIG_OF_BOARD_SETUP

Quoted 8 lines · Jamie Gibbons

Enable CONFIG_OF_BOARD_SETUP and other dependencies to allow the use of the ft_board_setup() function to replace fdt set in boot scripts for Microchip's MPFS Icicle kit.

---
 configs/microchip_mpfs_icicle_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
#3 lore raw

PATCH 2/6 board: microchip: mpfs_icicle: make use of ft_board_setup()

In reply to Jamie Gibbons

Move ethernet mac address setting to ft_board_setup() to remove the need for fdt set in custom boot script.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 51 ++++++++++++-----------
 1 file changed, 26 insertions(+), 25 deletions(-)
board/microchip/mpfs_icicle/mpfs_icicle.c +26 -25
index ba622e38ee5..19acbbba42b 100644
@@ -22,6 +22,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SERVICE_CR_REQ			0x1u
 #define SERVICE_SR_BUSY			0x2u
 
+static unsigned char mac_addr[6];
+
 static void read_device_serial_number(u8 *response, u8 response_size)
 {
 	u8 idx;
@@ -145,10 +147,7 @@ int board_late_init(void)
 {
 	u32 ret;
 	int node;
-	u8 idx;
-	u8 device_serial_number[16] = { 0 };
-	unsigned char mac_addr[6];
-	char icicle_mac_addr[20];
+	u8 device_serial_number[16] = {0};
 	void *blob = (void *)gd->fdt_blob;
 
 	read_device_serial_number(device_serial_number, 16);
@@ -170,19 +169,6 @@ int board_late_init(void)
 		}
 	}
 
-	icicle_mac_addr[0] = '[';
-
-	sprintf(&icicle_mac_addr[1], "%pM", mac_addr);
-
-	icicle_mac_addr[18] = ']';
-	icicle_mac_addr[19] = '\0';
-
-	for (idx = 0; idx < 20; idx++) {
-		if (icicle_mac_addr[idx] == ':')
-			icicle_mac_addr[idx] = ' ';
-	}
-	env_set("icicle_mac_addr0", icicle_mac_addr);
-
 	mac_addr[5] = device_serial_number[0] + 1;
 
 	node = fdt_path_offset(blob, "/soc/ethernet@20110000");
@@ -194,18 +180,33 @@ int board_late_init(void)
 		}
 	}
 
-	icicle_mac_addr[0] = '[';
+	return 0;
+}
 
-	sprintf(&icicle_mac_addr[1], "%pM", mac_addr);
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	u32 ret;
+	int node;
+
+	node = fdt_path_offset(blob, "/soc/ethernet@20110000");
+	if (node >= 0) {
+		ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
+		if (ret) {
+			printf("Error setting local-mac-address property for ethernet@20110000\n");
+			return -ENODEV;
+		}
+	}
 
-	icicle_mac_addr[18] = ']';
-	icicle_mac_addr[19] = '\0';
+	mac_addr[5] -= 1;
 
-	for (idx = 0; idx < 20; idx++) {
-		if (icicle_mac_addr[idx] == ':')
-			icicle_mac_addr[idx] = ' ';
+	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
+	if (node >= 0) {
+		ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
+		if (ret) {
+			printf("Error setting local-mac-address property for ethernet@20112000\n");
+			return -ENODEV;
+		}
 	}
-	env_set("icicle_mac_addr1", icicle_mac_addr);
 
 	return 0;
 }
Signature · 1 line
2.43.0
Acked-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] board: microchip: mpfs_icicle: make use of ft_board_setup()

Quoted 7 lines · Jamie Gibbons

Move ethernet mac address setting to ft_board_setup() to remove the need for fdt set in custom boot script.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 51 ++++++++++++-----------
 1 file changed, 26 insertions(+), 25 deletions(-)
#5 lore raw

PATCH 3/6 mailbox: add PolarFire SoC mailbox driver

In reply to Jamie Gibbons

This driver adds support for the single mailbox channel of the MSS system controller on the Microchip PolarFire SoC.

---
 drivers/mailbox/Kconfig     |   7 ++
 drivers/mailbox/Makefile    |   1 +
 drivers/mailbox/mpfs-mbox.c | 177 ++++++++++++++++++++++++++++++++++++
 include/mpfs-mailbox.h      |  67 ++++++++++++++
 4 files changed, 252 insertions(+)
 create mode 100644 drivers/mailbox/mpfs-mbox.c
 create mode 100644 include/mpfs-mailbox.h
drivers/mailbox/Kconfig +7 -0
index 4d9f004ebad..5a31ac707dc 100644
@@ -28,6 +28,13 @@ config IMX_MU_MBOX
 	  Enable support for i.MX Messaging Unit for communication with other
 	  processors on the SoC using mailbox interface
 
+config MPFS_MBOX
+	bool "Enable MPFS system controler support"
+	depends on DM_MAILBOX && ARCH_RV64I
+	help
+	  Enable support for the mailboxes that provide a comminucation
+	  channel with the system controller integrated on PolarFire SoC.
+
 config SANDBOX_MBOX
 	bool "Enable the sandbox mailbox test driver"
 	depends on DM_MAILBOX && SANDBOX
drivers/mailbox/Makefile +1 -0
index e8c745f7d79..b54fbdfff15 100644
@@ -6,6 +6,7 @@
 obj-$(CONFIG_$(PHASE_)DM_MAILBOX) += mailbox-uclass.o
 obj-$(CONFIG_APPLE_MBOX) += apple-mbox.o
 obj-$(CONFIG_IMX_MU_MBOX) += imx-mailbox.o
+obj-$(CONFIG_MPFS_MBOX) += mpfs-mbox.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/mpfs-mbox.c new file +177 -0

177 lines not on this page · raw message

include/mpfs-mailbox.h new file +67 -0

68 lines not on this page · raw message

Signature · 1 line
2.43.0
Acked-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] mailbox: add PolarFire SoC mailbox driver

Quoted 4 lines · Jamie Gibbons

This driver adds support for the single mailbox channel of the MSS system controller on the Microchip PolarFire SoC.

Quoted 8 lines
---
 drivers/mailbox/Kconfig     |   7 ++
 drivers/mailbox/Makefile    |   1 +
 drivers/mailbox/mpfs-mbox.c | 177 ++++++++++++++++++++++++++++++++++++
 include/mpfs-mailbox.h      |  67 ++++++++++++++
 4 files changed, 252 insertions(+)
 create mode 100644 drivers/mailbox/mpfs-mbox.c
 create mode 100644 include/mpfs-mailbox.h
#7 lore raw

PATCH 4/6 misc: add PolarFire SoC system controller

In reply to Jamie Gibbons

This driver provides an interface to access the functions of the system controller on the Microchip PolarFire SoC.
This driver includes functions to use the system controller to read the device serial number.

---
 drivers/misc/Kconfig              |   9 ++
 drivers/misc/Makefile             |   1 +
 drivers/misc/mpfs_syscontroller.c | 157 ++++++++++++++++++++++++++++++
 3 files changed, 167 insertions(+)
 create mode 100644 drivers/misc/mpfs_syscontroller.c
drivers/misc/Kconfig +9 -0
index 0f753b9dbb9..c1843b6e4f1 100644
@@ -658,6 +658,15 @@ config MICROCHIP_FLEXCOM
 	  Only one function can be used at a time and is chosen at boot time
 	  according to the device tree.
 
+config MPFS_SYSCONTROLLER
+	bool "Enable Microchip PolarFire SoC (MPFS) System Services support"
+	depends on MISC
+	depends on MPFS_MBOX
+	help
+	  This driver adds support for the PolarFire SoC (MPFS) system controller.
+	  
+	  If unsure, say N.
+
 config K3_AVS0
 	depends on ARCH_K3 && SPL_DM_REGULATOR
 	bool "AVS class 0 support for K3 devices"
drivers/misc/Makefile +1 -0
index f7422c8e95a..dc5eb3af19c 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
 obj-$(CONFIG_JZ4780_EFUSE) += jz4780_efuse.o
 obj-$(CONFIG_MICROCHIP_FLEXCOM) += microchip_flexcom.o
+obj-$(CONFIG_MPFS_SYSCONTROLLER) += mpfs_syscontroller.o
 obj-$(CONFIG_K3_AVS0) += k3_avs.o
 obj-$(CONFIG_ESM_K3) += k3_esm.o
 obj-$(CONFIG_K3_BIST) += k3_bist.o
drivers/misc/mpfs_syscontroller.c new file +157 -0

157 lines not on this page · raw message

Signature · 1 line
2.43.0
Acked-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] misc: add PolarFire SoC system controller

Quoted 5 lines · Jamie Gibbons

This driver provides an interface to access the functions of the system controller on the Microchip PolarFire SoC.
This driver includes functions to use the system controller to read the device serial number.

Quoted 7 lines
---
 drivers/misc/Kconfig              |   9 ++
 drivers/misc/Makefile             |   1 +
 drivers/misc/mpfs_syscontroller.c | 157 ++++++++++++++++++++++++++++++
 3 files changed, 167 insertions(+)
 create mode 100644 drivers/misc/mpfs_syscontroller.c
#9 lore raw

PATCH 5/6 board: microchip: mpfs_icicle: enable new driver configs

In reply to Jamie Gibbons

Enable the MPFS mailbox and system controller drivers for use with the Icicle kit. These functions are crucial for the board setup functions that run in the Icicle board file - mpfs_icicle.c.

---
 board/microchip/mpfs_icicle/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
board/microchip/mpfs_icicle/Kconfig +4 -0
index 6e8c479e955..760dffc488b 100644
@@ -59,5 +59,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply MTD_SPI_NAND
 	imply CMD_MTD
 	imply CMD_MTDPARTS
+	imply DM_MAILBOX
+	imply MPFS_MBOX
+	imply MISC
+	imply MPFS_SYSCONTROLLER
 
 endif
Signature · 1 line
2.43.0
Acked-by on v1 5/6
#10 lore raw

Re: [PATCH 5/6] board: microchip: mpfs_icicle: enable new driver configs

Quoted 8 lines · Jamie Gibbons

Enable the MPFS mailbox and system controller drivers for use with the Icicle kit. These functions are crucial for the board setup functions that run in the Icicle board file - mpfs_icicle.c.

---
 board/microchip/mpfs_icicle/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
#11 lore raw

PATCH 6/6 board: microchip: mpfs_icicle: update to use system controller

In reply to Jamie Gibbons

A new system controller driver has been created to make code modular and improve and clean code. Update and remove functions to account for these additional drivers.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 72 ++++++++++-------------
 1 file changed, 32 insertions(+), 40 deletions(-)
board/microchip/mpfs_icicle/mpfs_icicle.c +32 -40
index 19acbbba42b..739a9b6cd76 100644
@@ -4,55 +4,22 @@
  * Padmarao Begari <[email protected]>
  */
 
-#include <dm.h>
-#include <env.h>
-#include <init.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/sections.h>
+#include <dm.h>
+#include <dm/devres.h>
+#include <env.h>
+#include <linux/compat.h>
+#include <mpfs-mailbox.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define MPFS_SYSREG_SOFT_RESET		((unsigned int *)0x20002088)
-#define MPFS_SYS_SERVICE_CR		((unsigned int *)0x37020050)
-#define MPFS_SYS_SERVICE_SR		((unsigned int *)0x37020054)
-#define MPFS_SYS_SERVICE_MAILBOX	((unsigned char *)0x37020800)
-
+#define MPFS_SYSREG_SOFT_RESET	((unsigned int *)0x20002088)
 #define PERIPH_RESET_VALUE		0x1e8u
-#define SERVICE_CR_REQ			0x1u
-#define SERVICE_SR_BUSY			0x2u
 
 static unsigned char mac_addr[6];
 
-static void read_device_serial_number(u8 *response, u8 response_size)
-{
-	u8 idx;
-	u8 *response_buf;
-	unsigned int val;
-
-	response_buf = (u8 *)response;
-
-	writel(SERVICE_CR_REQ, MPFS_SYS_SERVICE_CR);
-	/*
-	 * REQ bit will remain set till the system controller starts
-	 * processing.
-	 */
-	do {
-		val = readl(MPFS_SYS_SERVICE_CR);
-	} while (SERVICE_CR_REQ == (val & SERVICE_CR_REQ));
-
-	/*
-	 * Once system controller starts processing the busy bit will
-	 * go high and service is completed when busy bit is gone low
-	 */
-	do {
-		val = readl(MPFS_SYS_SERVICE_SR);
-	} while (SERVICE_SR_BUSY == (val & SERVICE_SR_BUSY));
-
-	for (idx = 0; idx < response_size; idx++)
-		response_buf[idx] = readb(MPFS_SYS_SERVICE_MAILBOX + idx);
-}
-
 #if defined(CONFIG_MULTI_DTB_FIT)
 int board_fit_config_name_match(const char *name)
 {
@@ -149,8 +116,33 @@ int board_late_init(void)
 	int node;
 	u8 device_serial_number[16] = {0};
 	void *blob = (void *)gd->fdt_blob;
+	struct udevice *dev;
+	struct mpfs_sys_serv *sys_serv_priv;
+
+	ret = uclass_get_device_by_name(UCLASS_MISC, "syscontroller", &dev);
+	if (ret) {
+		debug("%s: system controller setup failed\n", __func__);
+		return ret;
+	}
 
-	read_device_serial_number(device_serial_number, 16);
+	sys_serv_priv = kzalloc(sizeof(*sys_serv_priv), GFP_KERNEL);
+	if (!sys_serv_priv)
+		return -ENOMEM;
+
+	sys_serv_priv->dev = dev;
+
+	sys_serv_priv->sys_controller = mpfs_syscontroller_get(dev);
+	ret = IS_ERR(sys_serv_priv->sys_controller);
+	if (ret) {
+		debug("%s:  Failed to register system controller sub device ret=%d\n", __func__, ret);
+		return -ENODEV;
+	}
+
+	ret = mpfs_syscontroller_read_sernum(sys_serv_priv, device_serial_number);
+	if (ret) {
+		printf("Cannot read device serial number\n");
+		return -EINVAL;
+	}
 
 	/* Update MAC address with device serial number */
 	mac_addr[0] = 0x00;
Signature · 1 line
2.43.0
Reviewed-by on v1 6/6
#12 lore raw

Re: [PATCH 6/6] board: microchip: mpfs_icicle: update to use system controller

Quoted 8 lines · Jamie Gibbons

A new system controller driver has been created to make code modular and improve and clean code. Update and remove functions to account for these additional drivers.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 72 ++++++++++-------------
 1 file changed, 32 insertions(+), 40 deletions(-)