Skip to contentSkip to conversation

Sync PolarFire SoC dts with Linux

PATCH In review Conor Dooley 2 participants 5 messages Jun 15, 2023 – Jun 21, 2023 1 message not in the archive

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

v2 cover Sync PolarFire SoC dts with Linux

Hey,

Couple of patches here that do a long-overdue sync of the Linux devicetree for PolarFire SoC & the Icicle kit with Linux. This wasn't possible for a while due to an incorrect dts & clock driver that were based on a pre-upstream version of the dt-binding. That's fixed now, so a complete re-sync is possible.

To elide complaints about the mac address not being set for the second ethernet, the code which set it for ethernet0 has been changed to set it for whichever (or both) of the macbs that are enabled.

Hopefully I'll have a follow-on bit of work soonTM that will rework the mac address setting code as it'll be needed to support another board.

Cheers,
Conor.

Changes in v2:
- Fix address in error print in 3/3

Conor Dooley (3):
riscv: dts: drop microchip from dts filenames
riscv: dts: sync mpfs-icicle devicetree with linux
board: microchip: set mac address for ethernet1 on icicle

 arch/riscv/dts/Makefile                       |   2 +-
 arch/riscv/dts/microchip-mpfs-icicle-kit.dts  | 136 ------
 arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi    |  71 +++
 ...-boot.dtsi => mpfs-icicle-kit-u-boot.dtsi} |   0
 arch/riscv/dts/mpfs-icicle-kit.dts            | 208 +++++++++
 .../dts/{microchip-mpfs.dtsi => mpfs.dtsi}    | 442 ++++++++----------
 board/microchip/mpfs_icicle/mpfs_icicle.c     |  15 +-
 configs/microchip_mpfs_icicle_defconfig       |   2 +-
 doc/board/microchip/mpfs_icicle.rst           |   6 +-
 .../dt-bindings/clock/microchip-mpfs-clock.h  |  29 +-
 .../microchip-mpfs-plic.h                     | 196 --------
 .../interrupt-controller/riscv-hart.h         |  17 -
 12 files changed, 514 insertions(+), 610 deletions(-)
 delete mode 100644 arch/riscv/dts/microchip-mpfs-icicle-kit.dts
 create mode 100644 arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi
 rename arch/riscv/dts/{microchip-mpfs-icicle-kit-u-boot.dtsi => mpfs-icicle-kit-u-boot.dtsi} (100%)
 create mode 100644 arch/riscv/dts/mpfs-icicle-kit.dts
 rename arch/riscv/dts/{microchip-mpfs.dtsi => mpfs.dtsi} (57%)
 delete mode 100644 include/dt-bindings/interrupt-controller/microchip-mpfs-plic.h
 delete mode 100644 include/dt-bindings/interrupt-controller/riscv-hart.h
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/3 riscv: dts: drop microchip from dts filenames

The original names picked for the DT doesn't match Linux's naming scheme and it was renamed there a while ago. Rename it in U-Boot to allow easily syncing dts between the two projects.

---
 arch/riscv/dts/Makefile                                     | 2 +-
 ...s-icicle-kit-u-boot.dtsi => mpfs-icicle-kit-u-boot.dtsi} | 0
 .../{microchip-mpfs-icicle-kit.dts => mpfs-icicle-kit.dts}  | 2 +-
 arch/riscv/dts/{microchip-mpfs.dtsi => mpfs.dtsi}           | 0
 configs/microchip_mpfs_icicle_defconfig                     | 2 +-
 doc/board/microchip/mpfs_icicle.rst                         | 6 +++---
 6 files changed, 6 insertions(+), 6 deletions(-)
 rename arch/riscv/dts/{microchip-mpfs-icicle-kit-u-boot.dtsi => mpfs-icicle-kit-u-boot.dtsi} (100%)
 rename arch/riscv/dts/{microchip-mpfs-icicle-kit.dts => mpfs-icicle-kit.dts} (98%)
 rename arch/riscv/dts/{microchip-mpfs.dtsi => mpfs.dtsi} (100%)
arch/riscv/dts/Makefile +1 -1
index 79a58694f5..1d61eb8020 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 dtb-$(CONFIG_TARGET_AE350) += ae350_32.dtb ae350_64.dtb
-dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += microchip-mpfs-icicle-kit.dtb
+dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
 dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
 dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
 dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb
arch/riscv/dts/mpfs-icicle-kit-u-boot.dtsi renamed from arch/riscv/dts/microchip-mpfs-icicle-kit-u-boot.dtsi +0 -0
similarity index 100%
rename from arch/riscv/dts/microchip-mpfs-icicle-kit-u-boot.dtsi
rename to arch/riscv/dts/mpfs-icicle-kit-u-boot.dtsi
arch/riscv/dts/mpfs-icicle-kit.dts renamed from arch/riscv/dts/microchip-mpfs-icicle-kit.dts +1 -1
similarity index 98%
rename from arch/riscv/dts/microchip-mpfs-icicle-kit.dts
rename to arch/riscv/dts/mpfs-icicle-kit.dts
index c3f58e2d56..3c56400b92 100644
@@ -6,7 +6,7 @@
 
 /dts-v1/;
 
-#include "microchip-mpfs.dtsi"
+#include "mpfs.dtsi"
 
 /* Clock frequency (in Hz) of the rtcclk */
 #define RTCCLK_FREQ		1000000
arch/riscv/dts/mpfs.dtsi renamed from arch/riscv/dts/microchip-mpfs.dtsi +0 -0
similarity index 100%
rename from arch/riscv/dts/microchip-mpfs.dtsi
rename to arch/riscv/dts/mpfs.dtsi
configs/microchip_mpfs_icicle_defconfig +1 -1
index c03c8ec6ec..fa49d3865f 100644
@@ -4,7 +4,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x2000
 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_DEFAULT_DEVICE_TREE="mpfs-icicle-kit"
 CONFIG_SYS_PROMPT="RISC-V # "
 CONFIG_SYS_MEM_TOP_HIDE=0x400000
 CONFIG_SYS_LOAD_ADDR=0x80200000
doc/board/microchip/mpfs_icicle.rst +3 -3
index 09c2c6a9c1..1464e536e9 100644
@@ -134,7 +134,7 @@ Build OpenSBI
 .. code-block:: none
 
    make PLATFORM=generic FW_PAYLOAD_PATH=<u-boot-directory>/u-boot.bin
-   FW_FDT_PATH=<u-boot-directory>/arch/riscv/dts/microchip-mpfs-icicle-kit-.dtb
+   FW_FDT_PATH=<u-boot-directory>/arch/riscv/dts/mpfs-icicle-kit-.dtb
 
 3. Output "fw_payload.bin" file available at
    "<opensbi-directory>/build/platform/generic/firmware/fw_payload.bin"
@@ -277,14 +277,14 @@ load uImage (with initramfs).
    done
    Bytes transferred = 14482480 (dcfc30 hex)
 
-   RISC-V # tftpboot ${fdt_addr_r} microchip-mpfs-icicle-kit.dtb
+   RISC-V # tftpboot ${fdt_addr_r} mpfs-icicle-kit.dtb
    ethernet@20112000: PHY present at 9
    ethernet@20112000: Starting autonegotiation...
    ethernet@20112000: Autonegotiation complete
    ethernet@20112000: link up, 1000Mbps full-duplex (lpa: 0x7800)
    Using ethernet@20112000 device
    TFTP from server 192.168.1.3; our IP address is 192.168.1.5
-   Filename 'microchip-mpfs-icicle-kit.dtb'.
+   Filename 'mpfs-icicle-kit.dtb'.
    Load address: 0x82200000
    Loading: #
 			2.5 MiB/s
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/3 riscv: dts: sync mpfs-icicle devicetree with linux

In reply to Conor Dooley

The "notable" disappearances are:
- the pac193x stanza - there's nothing in mainline linux w.r.t. bindings for this & what is going to appear in mainline linux is going to be incompatible with what is currently in U-Boot.
- operating points - these operating points should not be set at the soc.dtsi level as they may not be possible depending on the design programmed to the FPGA
- clock output names - there are defines for the clock indices, these should not be needed
- the dt maintainers in linux NAKed using defines for IRQ numbers
- the qspi nand, which is not part of the icicle's default configuration is removed.

---
 arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi    |  71 +++
 arch/riscv/dts/mpfs-icicle-kit.dts            | 190 +++++---
 arch/riscv/dts/mpfs.dtsi                      | 442 ++++++++----------
 .../dt-bindings/clock/microchip-mpfs-clock.h  |  29 +-
 .../microchip-mpfs-plic.h                     | 196 --------
 .../interrupt-controller/riscv-hart.h         |  17 -
 6 files changed, 420 insertions(+), 525 deletions(-)
 create mode 100644 arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi
 delete mode 100644 include/dt-bindings/interrupt-controller/microchip-mpfs-plic.h
 delete mode 100644 include/dt-bindings/interrupt-controller/riscv-hart.h
arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi new file +71 -0
new file mode 100644
index 0000000000..1069134f2e
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Copyright (c) 2020-2021 Microchip Technology Inc */
+
+/ {
+	compatible = "microchip,mpfs-icicle-reference-rtlv2210", "microchip,mpfs-icicle-kit",
+		     "microchip,mpfs";
+
+	core_pwm0: pwm@40000000 {
+		compatible = "microchip,corepwm-rtl-v4";
+		reg = <0x0 0x40000000 0x0 0xF0>;
+		microchip,sync-update-mask = /bits/ 32 <0>;
+		#pwm-cells = <3>;
+		clocks = <&ccc_nw CLK_CCC_PLL0_OUT3>;
+		status = "disabled";
+	};
+
+	i2c2: i2c@40000200 {
+		compatible = "microchip,corei2c-rtl-v7";
+		reg = <0x0 0x40000200 0x0 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clocks = <&ccc_nw CLK_CCC_PLL0_OUT3>;
+		interrupt-parent = <&plic>;
+		interrupts = <122>;
+		clock-frequency = <100000>;
+		status = "disabled";
+	};
+
+	pcie: pcie@3000000000 {
+		compatible = "microchip,pcie-host-1.0";
+		#address-cells = <0x3>;
+		#interrupt-cells = <0x1>;
+		#size-cells = <0x2>;
+		device_type = "pci";
+		reg = <0x30 0x0 0x0 0x8000000>, <0x0 0x43000000 0x0 0x10000>;
+		reg-names = "cfg", "apb";
+		bus-range = <0x0 0x7f>;
+		interrupt-parent = <&plic>;
+		interrupts = <119>;
+		interrupt-map = <0 0 0 1 &pcie_intc 0>,
+				<0 0 0 2 &pcie_intc 1>,
+				<0 0 0 3 &pcie_intc 2>,
+				<0 0 0 4 &pcie_intc 3>;
+		interrupt-map-mask = <0 0 0 7>;
+		clocks = <&ccc_nw CLK_CCC_PLL0_OUT1>, <&ccc_nw CLK_CCC_PLL0_OUT3>;
+		clock-names = "fic1", "fic3";
+		ranges = <0x3000000 0x0 0x8000000 0x30 0x8000000 0x0 0x80000000>;
+		dma-ranges = <0x02000000 0x0 0x00000000 0x0 0x00000000 0x1 0x00000000>;
+		msi-parent = <&pcie>;
+		msi-controller;
+		status = "disabled";
+		pcie_intc: interrupt-controller {
+			#address-cells = <0>;
+			#interrupt-cells = <1>;
+			interrupt-controller;
+		};
+	};
+
+	refclk_ccc: cccrefclk {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+	};
+};
+
+&ccc_nw {
+	clocks = <&refclk_ccc>, <&refclk_ccc>, <&refclk_ccc>, <&refclk_ccc>,
+		 <&refclk_ccc>, <&refclk_ccc>;
+	clock-names = "pll0_ref0", "pll0_ref1", "pll1_ref0", "pll1_ref1",
+		      "dll0_ref", "dll1_ref";
+	status = "okay";
+};
arch/riscv/dts/mpfs-icicle-kit.dts +131 -59

243 lines not on this page · raw message

arch/riscv/dts/mpfs.dtsi +192 -250

670 lines not on this page · raw message

include/dt-bindings/clock/microchip-mpfs-clock.h +26 -3
index c7ed0a8db7..79775a5134 100644
@@ -1,7 +1,7 @@
-/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
 /*
- * Copyright (C) 2020 Microchip Technology Inc.
- * Padmarao Begari <[email protected]>
+ * Daire McNamara,<[email protected]>
+ * Copyright (C) 2020-2022 Microchip Technology Inc.  All rights reserved.
  */
 
 #ifndef _DT_BINDINGS_CLK_MICROCHIP_MPFS_H_
@@ -45,4 +45,27 @@
 #define CLK_RTCREF	33
 #define CLK_MSSPLL	34
 
+/* Clock Conditioning Circuitry Clock IDs */
+
+#define CLK_CCC_PLL0		0
+#define CLK_CCC_PLL1		1
+#define CLK_CCC_DLL0		2
+#define CLK_CCC_DLL1		3
+
+#define CLK_CCC_PLL0_OUT0	4
+#define CLK_CCC_PLL0_OUT1	5
+#define CLK_CCC_PLL0_OUT2	6
+#define CLK_CCC_PLL0_OUT3	7
+
+#define CLK_CCC_PLL1_OUT0	8
+#define CLK_CCC_PLL1_OUT1	9
+#define CLK_CCC_PLL1_OUT2	10
+#define CLK_CCC_PLL1_OUT3	11
+
+#define CLK_CCC_DLL0_OUT0	12
+#define CLK_CCC_DLL0_OUT1	13
+
+#define CLK_CCC_DLL1_OUT0	14
+#define CLK_CCC_DLL1_OUT1	15
+
 #endif	/* _DT_BINDINGS_CLK_MICROCHIP_MPFS_H_ */
include/dt-bindings/interrupt-controller/microchip-mpfs-plic.h deleted +0 -196

196 lines not on this page · raw message

include/dt-bindings/interrupt-controller/riscv-hart.h deleted +0 -17
deleted file mode 100644
index c4331b8521..0000000000
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
-/* Copyright (c) 2020-2021 Microchip Technology Inc */
-
-#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_RISCV_HART_H
-#define _DT_BINDINGS_INTERRUPT_CONTROLLER_RISCV_HART_H
-
-#define HART_INT_U_SOFT   0
-#define HART_INT_S_SOFT   1
-#define HART_INT_M_SOFT   3
-#define HART_INT_U_TIMER  4
-#define HART_INT_S_TIMER  5
-#define HART_INT_M_TIMER  7
-#define HART_INT_U_EXT    8
-#define HART_INT_S_EXT    9
-#define HART_INT_M_EXT    11
-
-#endif /* _DT_BINDINGS_INTERRUPT_CONTROLLER_RISCV_HART_H */
Signature · 1 line
2.40.1

A message that is not in the archive (sent off-list or not yet received): SEZPR03MB8064AAA5D3770CF05E3A0C82C15DA@SEZPR03MB8064.apcprd03.prod.outlook.com

Reviewed-by
#4 lore raw

Re: [PATCH v2 2/3] riscv: dts: sync mpfs-icicle devicetree with linux

Quoted 22 lines

From: Conor Dooley <[email protected]>
Sent: Thursday, June 15, 2023 6:13 PM
To: [email protected]
Cc: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; Padmarao Begari <[email protected]>; Conor Dooley <[email protected]>
Subject: [PATCH v2 2/3] riscv: dts: sync mpfs-icicle devicetree with linux

The "notable" disappearances are:
- the pac193x stanza - there's nothing in mainline linux w.r.t. bindings for this & what is going to appear in mainline linux is going to be incompatible with what is currently in U-Boot.
- operating points - these operating points should not be set at the soc.dtsi level as they may not be possible depending on the design programmed to the FPGA
- clock output names - there are defines for the clock indices, these should not be needed
- the dt maintainers in linux NAKed using defines for IRQ numbers
- the qspi nand, which is not part of the icicle's default configuration is removed.

Quoted 7 lines
---
 arch/riscv/dts/mpfs-icicle-kit-fabric.dtsi    |  71 +++
 arch/riscv/dts/mpfs-icicle-kit.dts            | 190 +++++---
 arch/riscv/dts/mpfs.dtsi                      | 442 ++++++++----------
 .../dt-bindings/clock/microchip-mpfs-clock.h  |  29 +-
 .../microchip-mpfs-plic.h                     | 196 --------
 .../interrupt-controller/riscv-hart.h         |  17 -
#5 lore raw

PATCH v2 3/3 board: microchip: set mac address for ethernet1 on icicle

In reply to Conor Dooley

The dts sync from Linux leaves mac0/ethernet1 enabled on icicle, but U-Boot does not currently set a mac address for it. Expand on the code which currently sets the mac for mac1/ethernet0 to optionally set the mac address for the second ethernet.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
board/microchip/mpfs_icicle/mpfs_icicle.c +12 -3
index e74c9fb03c..0f5f82924e 100644
@@ -80,7 +80,7 @@ int board_late_init(void)
 	char icicle_mac_addr[20];
 	void *blob = (void *)gd->fdt_blob;
 
-	node = fdt_path_offset(blob, "ethernet0");
+	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
 	if (node < 0) {
 		printf("No ethernet0 path offset\n");
 		return -ENODEV;
@@ -88,7 +88,7 @@ int board_late_init(void)
 
 	ret = fdtdec_get_byte_array(blob, node, "local-mac-address", mac_addr, 6);
 	if (ret) {
-		printf("No local-mac-address property\n");
+		printf("No local-mac-address property for ethernet@20112000\n");
 		return -EINVAL;
 	}
 
@@ -104,7 +104,7 @@ int board_late_init(void)
 
 	ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
 	if (ret) {
-		printf("Error setting local-mac-address property\n");
+		printf("Error setting local-mac-address property for ethernet@20112000\n");
 		return -ENODEV;
 	}
 
@@ -123,6 +123,15 @@ int board_late_init(void)
 
 	mac_addr[5] = device_serial_number[0] + 1;
 
+	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[0] = '[';
 
 	sprintf(&icicle_mac_addr[1], "%pM", mac_addr);
Signature · 1 line
2.40.1