Skip to contentSkip to conversation

riscv: dts: spacemit: enable more devices on Milk-V Jupiter

PATCH Applied Aurelien Jarno 2 participants 9 messages Mar 26 – Mar 27

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

v2 cover riscv: dts: spacemit: enable more devices on Milk-V Jupiter

This patchset improves support of the Milk-V Jupiter board by enabling more devices. Most notably the NOR flash (useful for upgrading the bootloader), the USB 3 ports and the PCIe ports.

It was inspired by the Banana Pi F3 device tree file. It is based against the k1/dt-for-next branch and does not have any other dependency.

Changes between version 1 and version 2:
- Collect Reviewed-by:
- Remove bootph-pre-ram property from SPI NOR flash
- Mention that the fast read opcodes is marked as supported in the SPI NOR flash datasheet
- Fix typo in the description of patch 6

Version 1 of this series is available here:
https://lore.kernel.org/lkml/[email protected]

Aurelien Jarno (6):
riscv: dts: spacemit: add LEDs for Milk-V Jupiter board
riscv: dts: spacemit: add 24c04 eeprom on Milk-V Jupiter
riscv: dts: spacemit: add i2c aliases on Milk-V Jupiter
riscv: dts: spacemit: enable QSPI and add SPI NOR on Milk-V Jupiter
riscv: dts: spacemit: enable USB 3 ports on Milk-V Jupiter
riscv: dts: spacemit: enable PCIe ports on Milk-V Jupiter

 .../boot/dts/spacemit/k1-milkv-jupiter.dts    | 188 +++++++++++++++++-
 1 file changed, 187 insertions(+), 1 deletion(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/6 riscv: dts: spacemit: add LEDs for Milk-V Jupiter board

The Milk-V Jupiter board provides support for two LEDs through the front panel header. The "Power LED" indicates the system is running, and the "HDD LED" shows disk activity. Configure the corresponding LED triggers accordingly.

Caveats:
- The LEDs are driven through a 4.7k series resistor, making them quite faint.
- The disk activity trigger requires a storage controller on the M.2 or PCIe interface. That said, it matches the purpose and the vendor kernel.

---
 .../boot/dts/spacemit/k1-milkv-jupiter.dts      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

v2:
- Collect Reviewed-by:

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +17 -0
index 9959c8023ece0..3cd83c5924e4f 100644
@@ -21,6 +21,23 @@ chosen {
 		stdout-path = "serial0";
 	};
 
+	leds {
+		compatible = "gpio-leds";
+
+		led1 {
+			label = "pwr-led";
+			gpios = <&gpio K1_GPIO(96) GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "default-on";
+			default-state = "on";
+		};
+
+		led2 {
+			label = "hdd-led";
+			gpios = <&gpio K1_GPIO(92) GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "disk-activity";
+		};
+	};
+
 	reg_dc_in: regulator-dc-in-12v {
 		compatible = "regulator-fixed";
 		regulator-name = "dc_in_12v";
Signature · 1 line
2.51.0
#2 lore raw

PATCH v2 2/6 riscv: dts: spacemit: add 24c04 eeprom on Milk-V Jupiter

In reply to Aurelien Jarno

The Milk-V Jupiter board includes a 24c04 eeprom on the i2c2 bus. The eeprom contains an ONIE TLV table, which on the board I tested only provides a product-name entry. Expose it via an onie,tlv-layout nvmem layout.

The eeprom is marked as read-only since its contents are not supposed to be modified.

---
 .../boot/dts/spacemit/k1-milkv-jupiter.dts    | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

v2:
- Collect Reviewed-by:

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +22 -0
index 3cd83c5924e4f..bd48208a370cf 100644
@@ -108,6 +108,28 @@ &pdma {
 	status = "okay";
 };
 
+&i2c2 {
+	pinctrl-0 = <&i2c2_0_cfg>;
+	pinctrl-names = "default";
+	status = "okay";
+
+	eeprom@50 {
+		compatible = "atmel,24c04";
+		reg = <0x50>;
+		vcc-supply = <&buck3_1v8>; /* EEPROM_VCC18 */
+		pagesize = <16>;
+		read-only;
+		size = <512>;
+
+		nvmem-layout {
+			compatible = "onie,tlv-layout";
+
+			product-name {
+			};
+		};
+	};
+};
+
 &i2c8 {
 	pinctrl-0 = <&i2c8_cfg>;
 	pinctrl-names = "default";
Signature · 1 line
2.51.0
#3 lore raw

PATCH v2 3/6 riscv: dts: spacemit: add i2c aliases on Milk-V Jupiter

In reply to Aurelien Jarno

Add i2c aliases for i2c2 and i2c8 on Milk-V Jupiter. This is useful to keep a stable number for the /dev entries after loading the i2c-dev module.

---
 arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts | 2 ++
 1 file changed, 2 insertions(+)

v2:
- Collect Reviewed-by:

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +2 -0
index bd48208a370cf..836311c3f035c 100644
@@ -15,6 +15,8 @@ aliases {
 		ethernet0 = &eth0;
 		ethernet1 = &eth1;
 		serial0 = &uart0;
+		i2c2 = &i2c2;
+		i2c8 = &i2c8;
 	};
 
 	chosen {
Signature · 1 line
2.51.0
#4 lore raw

PATCH v2 4/6 riscv: dts: spacemit: enable QSPI and add SPI NOR on Milk-V Jupiter

In reply to Aurelien Jarno

Add the QSPI controller node for the Milk-V Jupiter board and describe the attached SPI NOR flash (GD25Q64E).

The flash supports a frequency up to 133MHz (80 MHz for reads), and the SoC supports a frequency up to 104 MHz. However tests have shown that the flash is not reliably detected above 26.5 MHz, consistent with frequency used in the vendor kernel. Therefore, use this frequency.

The m25p,fast-read properties is taken from the vendor kernel, and the GD25Q64E datasheet confirms tha the fast read opcodes are supported.

Add a corresponding flash partition layout, matching the layout and the names used in the vendor U-Boot.

---
 .../boot/dts/spacemit/k1-milkv-jupiter.dts    | 43 ++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

v2:
- Remove bootph-pre-ram property from SPI NOR flash and update the patch description accordingly
- Mention that the fast read opcodes is marked as supported in the datasheet
- Collect Reviewed-by:

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +42 -1
index 836311c3f035c..bac6438c67532 100644
@@ -173,7 +173,7 @@ buck3_1v8: buck3 {
 				regulator-always-on;
 			};
 
-			buck4 {
+			buck4_3v3: buck4 {
 				regulator-min-microvolt = <500000>;
 				regulator-max-microvolt = <3300000>;
 				regulator-ramp-delay = <5000>;
@@ -256,6 +256,47 @@ dldo7 {
 	};
 };
 
+&qspi {
+	pinctrl-names = "default";
+	pinctrl-0 = <&qspi_cfg>;
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <26500000>;
+		spi-rx-bus-width = <4>;
+		spi-tx-bus-width = <4>;
+		vcc-supply = <&buck4_3v3>; /* QSPI_VCC1833 */
+		m25p,fast-read;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			bootinfo@0 {
+				reg = <0x0 0x10000>;
+			};
+			private@10000 {
+				reg = <0x10000 0x10000>;
+			};
+			fsbl@20000 {
+				reg = <0x20000 0x40000>;
+			};
+			env@60000 {
+				reg = <0x60000 0x10000>;
+			};
+			opensbi@70000 {
+				reg = <0x70000 0x30000>;
+			};
+			uboot@a00000 {
+				reg = <0xa0000 0x760000>;
+			};
+		};
+	};
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_2_cfg>;
Signature · 1 line
2.51.0
#5 lore raw

PATCH v2 5/6 riscv: dts: spacemit: enable USB 3 ports on Milk-V Jupiter

In reply to Aurelien Jarno

Enable the DWC3 USB 3.0 controller (USB#2 port in the K1 datasheet) and its associated combo_phy (USB 3 PHY) and usbphy2 (USB 2 PHY) on the Milk-V Jupiter board.

The board uses a VLI VL817 hub, providing four ports. Two are routed to the 3.0 type-A connectors, and two to the F_USB3 front USB header. The hub requires two separate 5V power supplies: one for the hub itself and one for the USB connectors. Add an always-on regulator sourcing 5V from the DC-IN input, along with two GPIO-controlled fixed regulators to manage the hub and connectors power supplies.

Note that the board also provides four USB 2.0 ports (two via type-A connectors and two via the F_USB2 front USB header), but these are handled by a different controller (USB#1 port in the K1 datasheet).

---
 .../boot/dts/spacemit/k1-milkv-jupiter.dts    | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)

v2:
- Collect Reviewed-by:

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +62 -0
index bac6438c67532..8eeaf2631b719 100644
@@ -58,6 +58,41 @@ reg_vcc_4v: regulator-vcc-4v {
 		regulator-always-on;
 		vin-supply = <&reg_dc_in>;
 	};
+
+	reg_vcc_5v: regulator-vcc-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc_5v";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-boot-on;
+		regulator-always-on;
+		vin-supply = <&reg_dc_in>;
+	};
+
+	regulator-usb3-vbus-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "USB30_VBUS";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		vin-supply = <&reg_vcc_5v>;
+		gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+
+	usb3_hub_5v: regulator-usb3-hub-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "USB30_HUB";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		vin-supply = <&reg_vcc_5v>;
+		gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&combo_phy {
+	status = "okay";
 };
 
 &eth0 {
@@ -302,3 +337,30 @@ &uart0 {
 	pinctrl-0 = <&uart0_2_cfg>;
 	status = "okay";
 };
+
+&usbphy2 {
+	status = "okay";
+};
+
+&usb_dwc3 {
+	dr_mode = "host";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	status = "okay";
+
+	hub_2_0: hub@1 {
+		compatible = "usb2109,2817";
+		reg = <0x1>;
+		vdd-supply = <&usb3_hub_5v>;
+		peer-hub = <&hub_3_0>;
+		reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
+	};
+
+	hub_3_0: hub@2 {
+		compatible = "usb2109,817";
+		reg = <0x2>;
+		vdd-supply = <&usb3_hub_5v>;
+		peer-hub = <&hub_2_0>;
+		reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
+	};
+};
Signature · 1 line
2.51.0
#6 lore raw

PATCH v2 6/6 riscv: dts: spacemit: enable PCIe ports on Milk-V Jupiter

In reply to Aurelien Jarno

Enable the two PCIe controller along with and their associated PHY. They are routed to the M.2 M-key connector and to the PCIe x8 slot.

Add an always-on regulator sourcing 3.3V from the DC-IN input, to power the PCIe ports.

---
 .../boot/dts/spacemit/k1-milkv-jupiter.dts    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

v2:
- Collect Reviewed-by:
- Fix a typo in the description

arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +42 -0
index 8eeaf2631b719..afaad59e6bce2 100644
@@ -40,6 +40,16 @@ led2 {
 		};
 	};
 
+	pcie_vcc_3v3: regulator-pcie-vcc3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "pcie_vcc3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+		vin-supply = <&reg_dc_in>;
+	};
+
 	reg_dc_in: regulator-dc-in-12v {
 		compatible = "regulator-fixed";
 		regulator-name = "dc_in_12v";
@@ -291,6 +301,38 @@ dldo7 {
 	};
 };
 
+&pcie1_phy {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie1_3_cfg>;
+	status = "okay";
+};
+
+&pcie1_port {
+	phys = <&pcie1_phy>;
+	vpcie3v3-supply = <&pcie_vcc_3v3>;
+};
+
+&pcie1 {
+	vpcie3v3-supply = <&pcie_vcc_3v3>;
+	status = "okay";
+};
+
+&pcie2_phy {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie2_4_cfg>;
+	status = "okay";
+};
+
+&pcie2_port {
+	phys = <&pcie2_phy>;
+	vpcie3v3-supply = <&pcie_vcc_3v3>;
+};
+
+&pcie2 {
+	vpcie3v3-supply = <&pcie_vcc_3v3>;
+	status = "okay";
+};
+
 &qspi {
 	pinctrl-names = "default";
 	pinctrl-0 = <&qspi_cfg>;
Signature · 1 line
2.51.0
maintainer Reviewed-by on the v2 series
#7 lore raw
In reply to Aurelien Jarno

Hi Aurelien,

Quoted 19 lines · Aurelien Jarno

This patchset improves support of the Milk-V Jupiter board by enabling more devices. Most notably the NOR flash (useful for upgrading the bootloader), the USB 3 ports and the PCIe ports.

It was inspired by the Banana Pi F3 device tree file. It is based against the k1/dt-for-next branch and does not have any other dependency.

Changes between version 1 and version 2:
- Collect Reviewed-by:
- Remove bootph-pre-ram property from SPI NOR flash
- Mention that the fast read opcodes is marked as supported in the SPI NOR flash datasheet
- Fix typo in the description of patch 6

Version 1 of this series is available here:
https://lore.kernel.org/lkml/[email protected]

Quoted 7 lines

Aurelien Jarno (6):
riscv: dts: spacemit: add LEDs for Milk-V Jupiter board
riscv: dts: spacemit: add 24c04 eeprom on Milk-V Jupiter
riscv: dts: spacemit: add i2c aliases on Milk-V Jupiter
riscv: dts: spacemit: enable QSPI and add SPI NOR on Milk-V Jupiter
riscv: dts: spacemit: enable USB 3 ports on Milk-V Jupiter
riscv: dts: spacemit: enable PCIe ports on Milk-V Jupiter

For the series

Signature · 1 line
Yixun Lan (dlan)
maintainer Applied
#8 lore raw
In reply to Aurelien Jarno
Quoted 9 lines · Aurelien Jarno

This patchset improves support of the Milk-V Jupiter board by enabling more devices. Most notably the NOR flash (useful for upgrading the bootloader), the USB 3 ports and the PCIe ports.

It was inspired by the Banana Pi F3 device tree file. It is based against the k1/dt-for-next branch and does not have any other dependency.

[...]

Applied, thanks!

[1/6] riscv: dts: spacemit: add LEDs for Milk-V Jupiter board

      https://github.com/spacemit-com/linux/commit/334e64abacd3df4005de80b082d0dbf02b453c76
[2/6] riscv: dts: spacemit: add 24c04 eeprom on Milk-V Jupiter
      https://github.com/spacemit-com/linux/commit/77156216f1d0f57e1cfce3452410db20468edca4
[3/6] riscv: dts: spacemit: add i2c aliases on Milk-V Jupiter
      https://github.com/spacemit-com/linux/commit/7af5edec73d5d69618541f91600adeb6f35b7d17
[4/6] riscv: dts: spacemit: enable QSPI and add SPI NOR on Milk-V Jupiter
      https://github.com/spacemit-com/linux/commit/2829823956f0f590f5c6b4eafed2dab7a96f69b3
[5/6] riscv: dts: spacemit: enable USB 3 ports on Milk-V Jupiter
      https://github.com/spacemit-com/linux/commit/dce01d8585a22f708b5f1eb621cacd9878258ac8
[6/6] riscv: dts: spacemit: enable PCIe ports on Milk-V Jupiter
      https://github.com/spacemit-com/linux/commit/2b8bd26bbfcdeb1a06127dcd8f9101080133f2a1

Best regards,

Signature · 1 line
Yixun Lan <[email protected]>