Skip to contentSkip to conversation

ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

PATCH Superseded Marek Vasut 4 participants 11 messages Mar 26, 2020 – Apr 14, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Add DT entries, Kconfig entries and board-specific entries to configure FMC2 bus and make KS8851-16MLL on that bus accessible to U-Boot.

Cc Patrick Delaunay <[email protected]>
Cc Patrice Chotard <[email protected]>

---
V2: Configure FMC2 nCS4 for SRAM as well
V3: Adjust the register macros

---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 68 ++++++++++++++++++++++
 board/dhelectronics/dh_stm32mp1/board.c    | 28 +++++++++
 configs/stm32mp15_dhcom_basic_defconfig    |  1 +
 3 files changed, 97 insertions(+)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +68 -0
index 6c952a57ee..eba3588540 100644
@@ -37,6 +37,12 @@
 			default-state = "on";
 		};
 	};
+
+	/* This is actually on FMC2, but we do not have bus driver for that */
+	ksz8851: ks8851mll at 64000000 {
+		compatible = "micrel,ks8851-mll";
+		reg = <0x64000000 0x20000>;
+	};
 };
 
 &i2c4 {
@@ -50,6 +56,68 @@
 	};
 };
 
+&pinctrl {
+	/* These should bound to FMC2 bus driver, but we do not have one */
+	pinctrl-0 = <&fmc_pins_b>;
+	pinctrl-1 = <&fmc_sleep_pins_b>;
+	pinctrl-names = "default", "sleep";
+
+	fmc_pins_b: fmc-0 {
+		pins1 {
+			pinmux = <STM32_PINMUX('D', 4, AF12)>, /* FMC_NOE */
+				 <STM32_PINMUX('D', 5, AF12)>, /* FMC_NWE */
+				 <STM32_PINMUX('B', 7, AF12)>, /* FMC_NL */
+				 <STM32_PINMUX('D', 14, AF12)>, /* FMC_D0 */
+				 <STM32_PINMUX('D', 15, AF12)>, /* FMC_D1 */
+				 <STM32_PINMUX('D', 0, AF12)>, /* FMC_D2 */
+				 <STM32_PINMUX('D', 1, AF12)>, /* FMC_D3 */
+				 <STM32_PINMUX('E', 7, AF12)>, /* FMC_D4 */
+				 <STM32_PINMUX('E', 8, AF12)>, /* FMC_D5 */
+				 <STM32_PINMUX('E', 9, AF12)>, /* FMC_D6 */
+				 <STM32_PINMUX('E', 10, AF12)>, /* FMC_D7 */
+				 <STM32_PINMUX('E', 11, AF12)>, /* FMC_D8 */
+				 <STM32_PINMUX('E', 12, AF12)>, /* FMC_D9 */
+				 <STM32_PINMUX('E', 13, AF12)>, /* FMC_D10 */
+				 <STM32_PINMUX('E', 14, AF12)>, /* FMC_D11 */
+				 <STM32_PINMUX('E', 15, AF12)>, /* FMC_D12 */
+				 <STM32_PINMUX('D', 8, AF12)>, /* FMC_D13 */
+				 <STM32_PINMUX('D', 9, AF12)>, /* FMC_D14 */
+				 <STM32_PINMUX('D', 10, AF12)>, /* FMC_D15 */
+				 <STM32_PINMUX('G', 9, AF12)>, /* FMC_NE2_FMC_NCE */
+				 <STM32_PINMUX('G', 12, AF12)>; /* FMC_NE4 */
+			bias-disable;
+			drive-push-pull;
+			slew-rate = <3>;
+		};
+	};
+
+	fmc_sleep_pins_b: fmc-sleep-0 {
+		pins {
+			pinmux = <STM32_PINMUX('D', 4, ANALOG)>, /* FMC_NOE */
+				 <STM32_PINMUX('D', 5, ANALOG)>, /* FMC_NWE */
+				 <STM32_PINMUX('B', 7, ANALOG)>, /* FMC_NL */
+				 <STM32_PINMUX('D', 14, ANALOG)>, /* FMC_D0 */
+				 <STM32_PINMUX('D', 15, ANALOG)>, /* FMC_D1 */
+				 <STM32_PINMUX('D', 0, ANALOG)>, /* FMC_D2 */
+				 <STM32_PINMUX('D', 1, ANALOG)>, /* FMC_D3 */
+				 <STM32_PINMUX('E', 7, ANALOG)>, /* FMC_D4 */
+				 <STM32_PINMUX('E', 8, ANALOG)>, /* FMC_D5 */
+				 <STM32_PINMUX('E', 9, ANALOG)>, /* FMC_D6 */
+				 <STM32_PINMUX('E', 10, ANALOG)>, /* FMC_D7 */
+				 <STM32_PINMUX('E', 11, ANALOG)>, /* FMC_D8 */
+				 <STM32_PINMUX('E', 12, ANALOG)>, /* FMC_D9 */
+				 <STM32_PINMUX('E', 13, ANALOG)>, /* FMC_D10 */
+				 <STM32_PINMUX('E', 14, ANALOG)>, /* FMC_D11 */
+				 <STM32_PINMUX('E', 15, ANALOG)>, /* FMC_D12 */
+				 <STM32_PINMUX('D', 8, ANALOG)>, /* FMC_D13 */
+				 <STM32_PINMUX('D', 9, ANALOG)>, /* FMC_D14 */
+				 <STM32_PINMUX('D', 10, ANALOG)>, /* FMC_D15 */
+				 <STM32_PINMUX('G', 9, ANALOG)>, /* FMC_NE2_FMC_NCE */
+				 <STM32_PINMUX('G', 12, ANALOG)>; /* FMC_NE4 */
+		};
+	};
+};
+
 &pmic {
 	u-boot,dm-pre-reloc;
 };
board/dhelectronics/dh_stm32mp1/board.c +28 -0
index b663696983..be55242799 100644
@@ -376,6 +376,32 @@ static void sysconf_init(void)
 #endif
 }
 
+static void board_init_fmc2(void)
+{
+#define STM32_FMC2_BCR1		0x0
+#define STM32_FMC2_BTR1		0x4
+#define STM32_FMC2_BWTR1	0x104
+#define STM32_FMC2_BCR(x)	((x) * 0x8 + STM32_FMC2_BCR1)
+#define STM32_FMC2_BTR(x)	((x) * 0x8 + STM32_FMC2_BTR1)
+#define STM32_FMC2_BWTR(x)	((x) * 0x8 + STM32_FMC2_BWTR1)
+
+#define RCC_MP_AHB6RSTCLRR	0x218
+#define RCC_MP_AHB6ENSETR	0x19c
+
+	/* Set up FMC2 bus for KS8851-16MLL and X11 SRAM */
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6RSTCLRR);
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6ENSETR);
+
+	/* KS8851-16MLL */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(1));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(1));
+	/* AS7C34098 SRAM on X11 */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(3));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(3));
+
+	setbits_le32(STM32_FMC2_BASE + STM32_FMC2_BCR1, BIT(31));
+}
+
 /* board dependent setup after realloc */
 int board_init(void)
 {
@@ -399,6 +425,8 @@ int board_init(void)
 
 	sysconf_init();
 
+	board_init_fmc2();
+
 	if (CONFIG_IS_ENABLED(CONFIG_LED))
 		led_default_state();
 
configs/stm32mp15_dhcom_basic_defconfig +1 -0
index 921dea242a..683f15e7d5 100644
@@ -93,6 +93,7 @@ CONFIG_SPI_FLASH_MTD=y
 CONFIG_SPL_SPI_FLASH_MTD=y
 CONFIG_DM_ETH=y
 CONFIG_DWC_ETH_QOS=y
+CONFIG_KS8851_MLL=y
 CONFIG_PHY=y
 CONFIG_PHY_STM32_USBPHYC=y
 CONFIG_PINCONF=y
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Hi Marek

You have forgotten to take into account some of my previous remarks on V2

Quoted 107 lines · Marek Vasut

Add DT entries, Kconfig entries and board-specific entries to configure FMC2 bus and make KS8851-16MLL on that bus accessible to U-Boot.

Cc Patrick Delaunay <[email protected]>
Cc Patrice Chotard <[email protected]>

---
V2: Configure FMC2 nCS4 for SRAM as well
V3: Adjust the register macros

---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 68 ++++++++++++++++++++++
 board/dhelectronics/dh_stm32mp1/board.c    | 28 +++++++++
 configs/stm32mp15_dhcom_basic_defconfig    |  1 +
 3 files changed, 97 insertions(+)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +68 -0
index 6c952a57ee..eba3588540 100644
@@ -37,6 +37,12 @@
 			default-state = "on";
 		};
 	};
+
+	/* This is actually on FMC2, but we do not have bus driver for that */
+	ksz8851: ks8851mll at 64000000 {
+		compatible = "micrel,ks8851-mll";
+		reg = <0x64000000 0x20000>;
+	};
 };
 
 &i2c4 {
@@ -50,6 +56,68 @@
 	};
 };
 
+&pinctrl {
+	/* These should bound to FMC2 bus driver, but we do not have one */
+	pinctrl-0 = <&fmc_pins_b>;
+	pinctrl-1 = <&fmc_sleep_pins_b>;
+	pinctrl-names = "default", "sleep";
+
+	fmc_pins_b: fmc-0 {
+		pins1 {
+			pinmux = <STM32_PINMUX('D', 4, AF12)>, /* FMC_NOE */
+				 <STM32_PINMUX('D', 5, AF12)>, /* FMC_NWE */
+				 <STM32_PINMUX('B', 7, AF12)>, /* FMC_NL */
+				 <STM32_PINMUX('D', 14, AF12)>, /* FMC_D0 */
+				 <STM32_PINMUX('D', 15, AF12)>, /* FMC_D1 */
+				 <STM32_PINMUX('D', 0, AF12)>, /* FMC_D2 */
+				 <STM32_PINMUX('D', 1, AF12)>, /* FMC_D3 */
+				 <STM32_PINMUX('E', 7, AF12)>, /* FMC_D4 */
+				 <STM32_PINMUX('E', 8, AF12)>, /* FMC_D5 */
+				 <STM32_PINMUX('E', 9, AF12)>, /* FMC_D6 */
+				 <STM32_PINMUX('E', 10, AF12)>, /* FMC_D7 */
+				 <STM32_PINMUX('E', 11, AF12)>, /* FMC_D8 */
+				 <STM32_PINMUX('E', 12, AF12)>, /* FMC_D9 */
+				 <STM32_PINMUX('E', 13, AF12)>, /* FMC_D10 */
+				 <STM32_PINMUX('E', 14, AF12)>, /* FMC_D11 */
+				 <STM32_PINMUX('E', 15, AF12)>, /* FMC_D12 */
+				 <STM32_PINMUX('D', 8, AF12)>, /* FMC_D13 */
+				 <STM32_PINMUX('D', 9, AF12)>, /* FMC_D14 */
+				 <STM32_PINMUX('D', 10, AF12)>, /* FMC_D15 */
+				 <STM32_PINMUX('G', 9, AF12)>, /* FMC_NE2_FMC_NCE */
+				 <STM32_PINMUX('G', 12, AF12)>; /* FMC_NE4 */
+			bias-disable;
+			drive-push-pull;
+			slew-rate = <3>;
+		};
+	};
+
+	fmc_sleep_pins_b: fmc-sleep-0 {
+		pins {
+			pinmux = <STM32_PINMUX('D', 4, ANALOG)>, /* FMC_NOE */
+				 <STM32_PINMUX('D', 5, ANALOG)>, /* FMC_NWE */
+				 <STM32_PINMUX('B', 7, ANALOG)>, /* FMC_NL */
+				 <STM32_PINMUX('D', 14, ANALOG)>, /* FMC_D0 */
+				 <STM32_PINMUX('D', 15, ANALOG)>, /* FMC_D1 */
+				 <STM32_PINMUX('D', 0, ANALOG)>, /* FMC_D2 */
+				 <STM32_PINMUX('D', 1, ANALOG)>, /* FMC_D3 */
+				 <STM32_PINMUX('E', 7, ANALOG)>, /* FMC_D4 */
+				 <STM32_PINMUX('E', 8, ANALOG)>, /* FMC_D5 */
+				 <STM32_PINMUX('E', 9, ANALOG)>, /* FMC_D6 */
+				 <STM32_PINMUX('E', 10, ANALOG)>, /* FMC_D7 */
+				 <STM32_PINMUX('E', 11, ANALOG)>, /* FMC_D8 */
+				 <STM32_PINMUX('E', 12, ANALOG)>, /* FMC_D9 */
+				 <STM32_PINMUX('E', 13, ANALOG)>, /* FMC_D10 */
+				 <STM32_PINMUX('E', 14, ANALOG)>, /* FMC_D11 */
+				 <STM32_PINMUX('E', 15, ANALOG)>, /* FMC_D12 */
+				 <STM32_PINMUX('D', 8, ANALOG)>, /* FMC_D13 */
+				 <STM32_PINMUX('D', 9, ANALOG)>, /* FMC_D14 */
+				 <STM32_PINMUX('D', 10, ANALOG)>, /* FMC_D15 */
+				 <STM32_PINMUX('G', 9, ANALOG)>, /* FMC_NE2_FMC_NCE */
+				 <STM32_PINMUX('G', 12, ANALOG)>; /* FMC_NE4 */
+		};
+	};
+};
+
 &pmic {
 	u-boot,dm-pre-reloc;
 };
board/dhelectronics/dh_stm32mp1/board.c +0 -0
index b663696983..be55242799 100644
@@ -376,6 +376,32 @@ static void sysconf_init(void)
 #endif

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 386

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +8 -0
 }
 
+static void board_init_fmc2(void)
+{
+#define STM32_FMC2_BCR1		0x0
+#define STM32_FMC2_BTR1		0x4
+#define STM32_FMC2_BWTR1	0x104
+#define STM32_FMC2_BCR(x)	((x) * 0x8 + STM32_FMC2_BCR1)
+#define STM32_FMC2_BTR(x)	((x) * 0x8 + STM32_FMC2_BTR1)
+#define STM32_FMC2_BWTR(x)	((x) * 0x8 + STM32_FMC2_BWTR1)

All these defines can be put in ./arch/arm/mach-stm32mp/include/mach/stm32.h

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 394

Quoted 8 lines
board/dhelectronics/dh_stm32mp1/board.c +8 -0
+
+#define RCC_MP_AHB6RSTCLRR	0x218
+#define RCC_MP_AHB6ENSETR	0x19c
+
+	/* Set up FMC2 bus for KS8851-16MLL and X11 SRAM */
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6RSTCLRR);
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6ENSETR);
+

Add a define for AHB6RSTCLRR and AHB6ENSETR BIT(12)

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 401

Quoted 7 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+	/* KS8851-16MLL */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(1));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(1));
+	/* AS7C34098 SRAM on X11 */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(3));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(3));
+

Avoid to put hardcoded value, it difficult to see what is done, add defines.

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 402

Quoted 1 line
board/dhelectronics/dh_stm32mp1/board.c +1 -0
+	setbits_le32(STM32_FMC2_BASE + STM32_FMC2_BCR1, BIT(31));

Add a define for FMC2_BCR1 BIT(31) , it will be easier to understand what is done

thanks

Patrice

Quoted 26 lines
board/dhelectronics/dh_stm32mp1/board.c +4 -0
+}
+
 /* board dependent setup after realloc */
 int board_init(void)
 {
@@ -399,6 +425,8 @@ int board_init(void)
 
 	sysconf_init();
 
+	board_init_fmc2();
+
 	if (CONFIG_IS_ENABLED(CONFIG_LED))
 		led_default_state();
 
configs/stm32mp15_dhcom_basic_defconfig +1 -0
index 921dea242a..683f15e7d5 100644
@@ -93,6 +93,7 @@ CONFIG_SPI_FLASH_MTD=y
 CONFIG_SPL_SPI_FLASH_MTD=y
 CONFIG_DM_ETH=y
 CONFIG_DWC_ETH_QOS=y
+CONFIG_KS8851_MLL=y
 CONFIG_PHY=y
 CONFIG_PHY_STM32_USBPHYC=y
 CONFIG_PINCONF=y
#2 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

[...]

Quoted 8 lines
Quoted 8 lines
board/dhelectronics/dh_stm32mp1/board.c +0 -0
index b663696983..be55242799 100644
@@ -376,6 +376,32 @@ static void sysconf_init(void)
 #endif
 }
 
Quoted 11 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 386

Quoted 8 lines
board/dhelectronics/dh_stm32mp1/board.c +8 -0
+static void board_init_fmc2(void)
+{
+#define STM32_FMC2_BCR1		0x0
+#define STM32_FMC2_BTR1		0x4
+#define STM32_FMC2_BWTR1	0x104
+#define STM32_FMC2_BCR(x)	((x) * 0x8 + STM32_FMC2_BCR1)
+#define STM32_FMC2_BTR(x)	((x) * 0x8 + STM32_FMC2_BTR1)
+#define STM32_FMC2_BWTR(x)	((x) * 0x8 + STM32_FMC2_BWTR1)

All these defines can be put in ./arch/arm/mach-stm32mp/include/mach/stm32.h

No, we need a driver for FMC2, that's where they should go. This is a stopgap solution.

Quoted 9 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 394

Quoted 7 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+#define RCC_MP_AHB6RSTCLRR	0x218
+#define RCC_MP_AHB6ENSETR	0x19c
+
+	/* Set up FMC2 bus for KS8851-16MLL and X11 SRAM */
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6RSTCLRR);
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6ENSETR);
+

Add a define for AHB6RSTCLRR and AHB6ENSETR BIT(12)

Maybe you should fix board/stm32mp1 and arch/arm/mach-stm32mp to do the same ? :)

Quoted 10 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 401

Quoted 7 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+	/* KS8851-16MLL */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(1));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(1));
+	/* AS7C34098 SRAM on X11 */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(3));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(3));
+

Avoid to put hardcoded value, it difficult to see what is done, add defines.

Quoted 3 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 402

Quoted 1 line
board/dhelectronics/dh_stm32mp1/board.c +1 -0
+	setbits_le32(STM32_FMC2_BASE + STM32_FMC2_BCR1, BIT(31));

Add a define for FMC2_BCR1 BIT(31) , it will be easier to understand what is done

OK

#3 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

In reply to Marek Vasut

Hi Marek,

Quoted 37 lines

From: Marek Vasut <[email protected]>
Sent: jeudi 26 mars 2020 16:58

Add DT entries, Kconfig entries and board-specific entries to configure FMC2 bus and make KS8851-16MLL on that bus accessible to U-Boot.

Cc Patrick Delaunay <[email protected]>
Cc Patrice Chotard <[email protected]>

---
V2: Configure FMC2 nCS4 for SRAM as well
V3: Adjust the register macros

---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 68 ++++++++++++++++++++++
 board/dhelectronics/dh_stm32mp1/board.c    | 28 +++++++++
 configs/stm32mp15_dhcom_basic_defconfig    |  1 +
 3 files changed, 97 insertions(+)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +6 -0
index 6c952a57ee..eba3588540 100644
@@ -37,6 +37,12 @@
 			default-state = "on";
 		};
 	};
+
+	/* This is actually on FMC2, but we do not have bus driver for that */
+	ksz8851: ks8851mll at 64000000 {
+		compatible = "micrel,ks8851-mll";
+		reg = <0x64000000 0x20000>;
+	};
 };
 
 &i2c4 {

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 60

Quoted 5 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +2 -0
@@ -50,6 +56,68 @@
 	};
 };
 
+&pinctrl {
+	/* These should bound to FMC2 bus driver, but we do not have one */

As temporarily solution (waiting final solution and real FMC2 bus driver) can you define a NO_OP in board device associated to existing compatible = "st,stm32mp15-fmc2"

Quoted 6 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +6 -0
+	pinctrl-0 = <&fmc_pins_b>;
+	pinctrl-1 = <&fmc_sleep_pins_b>;
+	pinctrl-names = "default", "sleep";
+
+	fmc_pins_b: fmc-0 {
+		pins1 {

[...]

Quoted 5 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +5 -0
+		};
+	};
+
+	fmc_sleep_pins_b: fmc-sleep-0 {
+		pins {

[...]

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 123

Quoted 7 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +4 -0
+		};
+	};
+};
+
 &pmic {
 	u-boot,dm-pre-reloc;
 };

For example

&fmc {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <& fmc_pins_b>;
	pinctrl-1 = <& fmc_sleep_pins_b>;
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
};
static const struct udevice_id stm32_fmc2_bus_ids[] = {
	{.compatible = "st,stm32mp15-fmc2},
	{ }
};
U_BOOT_DRIVER(stm32_fmc2_bus) = {
	.name		= "stm32mp15-fmc2-ids",
	.id		= UCLASS_NOP,
	.of_match	= stm32_fmc2_bus_ids,
	.bind		= stm32_fmc2_bus,
};

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) #endif } · line 378

Quoted 9 lines
board/dhelectronics/dh_stm32mp1/board.c +2 -0
index b663696983..be55242799 100644
@@ -376,6 +376,32 @@ static void sysconf_init(void)  #endif  }
 
+static void board_init_fmc2(void)
+{

Can you use device-tree information (to avoid hardcoded address STM32_FMC2_BASE).

For me, the address should be used only when the information are
not available in device tree or before the device tree availability (in pre-reloc phasis)

ofnode = ofnode_by_compatible(ofnode_null(), "st,stm32mp15-fmc2"); fmc2_addr = ofnode_get_addr(node);

or use NOP device as proposed previously.

PS: it is a preliminary step/temporarily solution, waiting FMC2 the bus driver availability.

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 393

Quoted 13 lines
board/dhelectronics/dh_stm32mp1/board.c +13 -0
+#define STM32_FMC2_BCR1		0x0
+#define STM32_FMC2_BTR1		0x4
+#define STM32_FMC2_BWTR1	0x104
+#define STM32_FMC2_BCR(x)	((x) * 0x8 + STM32_FMC2_BCR1)
+#define STM32_FMC2_BTR(x)	((x) * 0x8 + STM32_FMC2_BTR1)
+#define STM32_FMC2_BWTR(x)	((x) * 0x8 + STM32_FMC2_BWTR1)
+
+#define RCC_MP_AHB6RSTCLRR	0x218
+#define RCC_MP_AHB6ENSETR	0x19c
+
+	/* Set up FMC2 bus for KS8851-16MLL and X11 SRAM */
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6RSTCLRR);
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6ENSETR);

Use clk and reset driver model and DT, for example:

struct clk clk;
struct reset_ctl reset;

clk_get_by_index_nodev(ofnode, 0, &clk ;
clk_get_by_index_nodev(ofnode, 0, &reset);

Quoted 25 lines
board/dhelectronics/dh_stm32mp1/board.c +11 -0
+	/* KS8851-16MLL */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(1));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(1));
+	/* AS7C34098 SRAM on X11 */
+	writel(0x000010db, STM32_FMC2_BASE + STM32_FMC2_BCR(3));
+	writel(0xc0022222, STM32_FMC2_BASE + STM32_FMC2_BTR(3));
+
+	setbits_le32(STM32_FMC2_BASE + STM32_FMC2_BCR1, BIT(31)); }
+
 /* board dependent setup after realloc */  int board_init(void)  { @@ -399,6 +425,8
 @@ int board_init(void)
 
 	sysconf_init();
 
+	board_init_fmc2();
+
board/dhelectronics/dh_stm32mp1/board.c +0 -0
 	if (CONFIG_IS_ENABLED(CONFIG_LED))
 		led_default_state();
configs/stm32mp15_dhcom_basic_defconfig +0 -0
index 921dea242a..683f15e7d5 100644
@@ -93,6 +93,7 @@ CONFIG_SPI_FLASH_MTD=y
Quoted 8 lines

CONFIG_SPL_SPI_FLASH_MTD=y CONFIG_DM_ETH=y
CONFIG_DWC_ETH_QOS=y
+CONFIG_KS8851_MLL=y
CONFIG_PHY=y
CONFIG_PHY_STM32_USBPHYC=y
CONFIG_PINCONF=y
--
2.25.1

Regards

Patrick

#4 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 1 line · Patrick DELAUNAY

Hi Marek,

Hi,

[...]

Quoted 6 lines

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 60

Quoted 2 lines

+&pinctrl {

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +1 -0
+	/* These should bound to FMC2 bus driver, but we do not have one */

As temporarily solution (waiting final solution and real FMC2 bus driver) can you define a NO_OP in board device associated to existing compatible = "st,stm32mp15-fmc2"

NO_OP ?

Quoted 37 lines
Quoted 6 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +6 -0
+	pinctrl-0 = <&fmc_pins_b>;
+	pinctrl-1 = <&fmc_sleep_pins_b>;
+	pinctrl-names = "default", "sleep";
+
+	fmc_pins_b: fmc-0 {
+		pins1 {

[...]

Quoted 5 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +5 -0
+		};
+	};
+
+	fmc_sleep_pins_b: fmc-sleep-0 {
+		pins {

[...]

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 123

Quoted 7 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +4 -0
+		};
+	};
+};
+
 &pmic {
 	u-boot,dm-pre-reloc;
 };

For example

&fmc {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <& fmc_pins_b>;
	pinctrl-1 = <& fmc_sleep_pins_b>;
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
};
static const struct udevice_id stm32_fmc2_bus_ids[] = {
	{.compatible = "st,stm32mp15-fmc2},
	{ }
};
Quoted 6 lines
U_BOOT_DRIVER(stm32_fmc2_bus) = {
	.name		= "stm32mp15-fmc2-ids",
	.id		= UCLASS_NOP,
	.of_match	= stm32_fmc2_bus_ids,
	.bind		= stm32_fmc2_bus,
};

That looks like a hack, it would collide with the actual FMC2 driver and it seems the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I am reluctant to do anything like depending on the FMC DT bindings thus far.

Quoted 15 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) #endif } · line 378

Quoted 9 lines
board/dhelectronics/dh_stm32mp1/board.c +2 -0
index b663696983..be55242799 100644
@@ -376,6 +376,32 @@ static void sysconf_init(void)  #endif  }
 
+static void board_init_fmc2(void)
+{

Can you use device-tree information (to avoid hardcoded address STM32_FMC2_BASE).

For me, the address should be used only when the information are
not available in device tree or before the device tree availability (in pre-reloc phasis)

Quoted 6 lines

ofnode = ofnode_by_compatible(ofnode_null(), "st,stm32mp15-fmc2"); fmc2_addr = ofnode_get_addr(node);

or use NOP device as proposed previously.

PS: it is a preliminary step/temporarily solution, waiting FMC2 the bus driver availability.

Or, I can just use the address directly, which means no DT traversal, so simpler code and faster boot time.

Quoted 16 lines

board/dhelectronics/dh_stm32mp1/board.c static void sysconf_init(void) · line 393

Quoted 13 lines
board/dhelectronics/dh_stm32mp1/board.c +13 -0
+#define STM32_FMC2_BCR1		0x0
+#define STM32_FMC2_BTR1		0x4
+#define STM32_FMC2_BWTR1	0x104
+#define STM32_FMC2_BCR(x)	((x) * 0x8 + STM32_FMC2_BCR1)
+#define STM32_FMC2_BTR(x)	((x) * 0x8 + STM32_FMC2_BTR1)
+#define STM32_FMC2_BWTR(x)	((x) * 0x8 + STM32_FMC2_BWTR1)
+
+#define RCC_MP_AHB6RSTCLRR	0x218
+#define RCC_MP_AHB6ENSETR	0x19c
+
+	/* Set up FMC2 bus for KS8851-16MLL and X11 SRAM */
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6RSTCLRR);
+	writel(BIT(12), STM32_RCC_BASE + RCC_MP_AHB6ENSETR);

Use clk and reset driver model and DT, for example:

Quoted 5 lines

struct clk clk;
struct reset_ctl reset;

clk_get_by_index_nodev(ofnode, 0, &clk ;
clk_get_by_index_nodev(ofnode, 0, &reset);

This very much looks like I can just write the entire bus driver by now, instead of just writing these few registers in a real simple way, until the bus driver exists.

But since the bindings aren't stable, I am not very inclined to do that.

[...]

#5 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Dear Marek,

Quoted 10 lines

From: Marek Vasut <[email protected]>
Sent: jeudi 9 avril 2020 13:27

Quoted 1 line · Patrick DELAUNAY

Hi Marek,

Hi,

[...]

Quoted 8 lines
Quoted 6 lines

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 60

Quoted 2 lines

+&pinctrl {

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +1 -0
+	/* These should bound to FMC2 bus driver, but we do not have one */

As temporarily solution (waiting final solution and real FMC2 bus driver) can you define a NO_OP in board device associated to existing compatible = "st,stm32mp15-fmc2"

NO_OP ?

Sorry, UCLASS_NOP

After debate with Christophe, I agree that i sis other complicated for temporarily solution.

Quoted 44 lines
Quoted 37 lines
Quoted 6 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +6 -0
+	pinctrl-0 = <&fmc_pins_b>;
+	pinctrl-1 = <&fmc_sleep_pins_b>;
+	pinctrl-names = "default", "sleep";
+
+	fmc_pins_b: fmc-0 {
+		pins1 {

[...]

Quoted 5 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +5 -0
+		};
+	};
+
+	fmc_sleep_pins_b: fmc-sleep-0 {
+		pins {

[...]

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi line 123

Quoted 7 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +4 -0
+		};
+	};
+};
+
 &pmic {
 	u-boot,dm-pre-reloc;
 };

For example

&fmc {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <& fmc_pins_b>;
	pinctrl-1 = <& fmc_sleep_pins_b>;
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
};
static const struct udevice_id stm32_fmc2_bus_ids[] = {
	{.compatible = "st,stm32mp15-fmc2},
	{ }
};
Quoted 6 lines
U_BOOT_DRIVER(stm32_fmc2_bus) = {
	.name		= "stm32mp15-fmc2-ids",
	.id		= UCLASS_NOP,
	.of_match	= stm32_fmc2_bus_ids,
	.bind		= stm32_fmc2_bus,
};
Quoted 3 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

[...]

Quoted 5 lines
Quoted 5 lines

Use clk and reset driver model and DT, for example:

struct clk clk;
struct reset_ctl reset;

Quoted 7 lines
Quoted 2 lines

clk_get_by_index_nodev(ofnode, 0, &clk ;
clk_get_by_index_nodev(ofnode, 0, &reset);

This very much looks like I can just write the entire bus driver by now, instead of just writing these few registers in a real simple way, until the bus driver exists.

But since the bindings aren't stable, I am not very inclined to do that.

I am convinced now (thanks to Christophe) to keep it simple as it is a temporarily solution.

Thanks

Patrick

Quoted 2 lines

[...]

#6 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

On 4/9/20 7:38 PM, Patrick DELAUNAY wrote:
Hi,

[...]

Quoted 5 lines
Quoted 3 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

Great, thanks.

I had a look into writing the bus driver in the meantime, but it's not as simple as I originally anticipated. So, I'll wait until the Linux DT bindings stabilize and revisit it then.

Thanks

#7 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 11 lines · Marek Vasut

On 4/9/20 7:38 PM, Patrick DELAUNAY wrote:
Hi,

[...]

Quoted 5 lines
Quoted 3 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

Quoted 8 lines

Great, thanks.

I had a look into writing the bus driver in the meantime, but it's not as simple as I originally anticipated. So, I'll wait until the Linux DT bindings stabilize and revisit it then.

Thanks

Hi Marek,

I have already prepared a set of patches to add the full FMC2 support in U-Boot based on kernel drivers. I am currently waiting for the bindings and the drivers being reviewed on kernel side.

Regards,
Christophe Kerello.

#8 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 24 lines · Christophe Kerello
Quoted 21 lines · Marek Vasut

On 4/9/20 7:38 PM, Patrick DELAUNAY wrote:
Hi,

[...]

Quoted 9 lines
Quoted 6 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems
the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I
am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

Great, thanks.

I had a look into writing the bus driver in the meantime, but it's not as simple as I originally anticipated. So, I'll wait until the Linux DT bindings stabilize and revisit it then.

Quoted 8 lines
Quoted 2 lines

Thanks

Hi Marek,

I have already prepared a set of patches to add the full FMC2 support in U-Boot based on kernel drivers. I am currently waiting for the bindings and the drivers being reviewed on kernel side.

Great, thanks.

I'll switch to that one once it's upstream, but I don't see a reason to block this patch until then.

#9 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 30 lines · Marek Vasut
Quoted 29 lines · Christophe Kerello
Quoted 15 lines · Marek Vasut

On 4/9/20 7:38 PM, Patrick DELAUNAY wrote:
Hi,

[...]

Quoted 9 lines
Quoted 6 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems
the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I
am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

Quoted 8 lines

Great, thanks.

I had a look into writing the bus driver in the meantime, but it's not as simple as I originally anticipated. So, I'll wait until the Linux DT bindings stabilize and revisit it then.

Thanks

Hi Marek,

Quoted 9 lines
Quoted 3 lines

I have already prepared a set of patches to add the full FMC2 support in U-Boot based on kernel drivers. I am currently waiting for the bindings and the drivers being reviewed on kernel side.

Great, thanks.

I'll switch to that one once it's upstream, but I don't see a reason to block this patch until then.

Hi Marek,

Yes, we are aligned. We are not going to block this patch.

Regards,
Christophe Kerello.

#10 lore raw

PATCH v3 1/1 ARM: dts: stm32: Add KS8851-16MLL ethernet on FMC2

Quoted 39 lines · Christophe Kerello
Quoted 36 lines · Marek Vasut
Quoted 24 lines · Christophe Kerello
Quoted 21 lines · Marek Vasut

On 4/9/20 7:38 PM, Patrick DELAUNAY wrote:
Hi,

[...]

Quoted 9 lines
Quoted 6 lines

That looks like a hack, it would collide with the actual FMC2 driver and it seems
the FMC2 DT compatible string is not even stable yet (cfr the Linux patches). So I
am reluctant to do anything like depending on the FMC DT bindings thus far.

You are aligned with Christophe, he push me to accept your temporarily solution.

Great, thanks.

I had a look into writing the bus driver in the meantime, but it's not as simple as I originally anticipated. So, I'll wait until the Linux DT bindings stabilize and revisit it then.

Quoted 8 lines
Quoted 2 lines

Thanks

Hi Marek,

I have already prepared a set of patches to add the full FMC2 support in U-Boot based on kernel drivers. I am currently waiting for the bindings and the drivers being reviewed on kernel side.

Great, thanks.

Quoted 7 lines
Quoted 3 lines

I'll switch to that one once it's upstream, but I don't see a reason to block this patch until then.

Hi Marek,

Yes, we are aligned. We are not going to block this patch.

Great, thanks.