Skip to contentSkip to conversation

Add Ethernet support for Poplar board

PATCH Superseded Shawn Guo 3 participants 15 messages Mar 20, 2019 – Apr 24, 2019

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

v4 cover Add Ethernet support for Poplar board

The series adds Ethernet support for Poplar board. It firstly creates a reset driver for HiSilicon platform, then introduces higmacv300 Ethernet driver, and finally enables Ethernet support for Poplar board.

Changes for v4:
- Add a polarity field into struct reset_ctl.
- Instead of defining custom macros for polarity, use generic ones in include/dt-bindings/reset/ti-syscon.h.
- Use .data field as register offset and .id field as bit shift.
Changes for v3:
- Add polarity support into reset driver, so that we can drop the hacking on gmac reset sequence from higmacv300 driver.
Changes for v2:
- Rename driver symbol to HIGMACV300_ETH.
- Remove the use of temp variable 'addr' in higmac_recv().
- Simplify the return of function higmac_ofdata_to_platdata() and higmac_probe().
- Combine delaration and initialization for phyintf in function higmac_ofdata_to_platdata().
- Eliminate the MDIO read/write macros.
- Use wait_for_bit_le32() for MDIO command completion polling.
- Set up RX packet buffers in RX_FQ descriptor at initialization time, so that we do not need to allocate/free packet buffers repeatedly.
- Inform GMAC that the RX descriptor is no longer in use in function higmac_free_pkt().
- Define BITS_DESC_ENA instead of using magic number 0xf.

Shawn Guo (4):
reset: add polarity field into struct reset_ctl
reset: add reset driver for HiSilicon platform
net: add higmacv300 Ethernet driver for HiSilicon platform
poplar: enable Ethernet driver support

 arch/arm/dts/hi3798cv200-u-boot.dtsi |  14 +
 configs/poplar_defconfig             |   3 +
 drivers/net/Kconfig                  |   9 +
 drivers/net/Makefile                 |   1 +
 drivers/net/higmacv300.c             | 597 +++++++++++++++++++++++++++
 drivers/reset/Kconfig                |   6 +
 drivers/reset/Makefile               |   1 +
 drivers/reset/reset-hisilicon.c      | 103 +++++
 include/reset.h                      |   3 +
 9 files changed, 737 insertions(+)
 create mode 100644 drivers/net/higmacv300.c
 create mode 100644 drivers/reset/reset-hisilicon.c
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v4 1/4 reset: add polarity field into struct reset_ctl

Some reset controllers support different polarities for reset operation, so let's add a polarity field into struct reset_ctl.

---
 include/reset.h | 3 +++
 1 file changed, 3 insertions(+)
include/reset.h +3 -0
index 65aa7a4ce5e9..a1a9ad5603db 100644
@@ -43,6 +43,8 @@ struct udevice;
  * @data: An optional data field for scenarios where a single integer ID is not
  *	  sufficient. If used, it can be populated through an .of_xlate op and
  *	  processed during the various reset ops.
+ * @polarity: An optional polarity field for drivers that support
+ *	  different reset polarities.
  *
  * Should additional information to identify and configure any reset signal
  * for any provider be required in the future, the struct could be expanded to
@@ -59,6 +61,7 @@ struct reset_ctl {
 	 */
 	unsigned long id;
 	unsigned long data;
+	unsigned long polarity;
 };
 
 /**
Signature · 1 line
2.18.0
#3 lore raw

PATCH v4 1/4 reset: add polarity field into struct reset_ctl

In reply to Shawn Guo
Quoted 5 lines · Shawn Guo

Some reset controllers support different polarities for reset operation, so let's add a polarity field into struct reset_ctl.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/957cdc5a/attachment.sig>
author
#4 lore raw

PATCH v4 2/4 reset: add reset driver for HiSilicon platform

In reply to Shawn Guo

It adds a Driver Model compatible reset driver for HiSlicon platform. The driver implements a custom .of_xlate function, and uses .data field as reset register offset and .id field as bit shift.

---
 drivers/reset/Kconfig           |   6 ++
 drivers/reset/Makefile          |   1 +
 drivers/reset/reset-hisilicon.c | 103 ++++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 drivers/reset/reset-hisilicon.c
drivers/reset/Kconfig +6 -0
index a81e76769604..6ec6f39c85f0 100644
@@ -121,4 +121,10 @@ config RESET_SUNXI
 	  This enables support for common reset driver for
 	  Allwinner SoCs.
 
+config RESET_HISILICON
+	bool "Reset controller driver for HiSilicon SoCs"
+	depends on DM_RESET
+	help
+	  Support for reset controller on HiSilicon SoCs.
+
 endmenu
drivers/reset/Makefile +1 -0
index 4fad7d412985..7fec75bb4923 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
+obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o
drivers/reset/reset-hisilicon.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.18.0
#6 lore raw

PATCH v4 2/4 reset: add reset driver for HiSilicon platform

In reply to Shawn Guo
Quoted 6 lines · Shawn Guo

It adds a Driver Model compatible reset driver for HiSlicon platform. The driver implements a custom .of_xlate function, and uses .data field as reset register offset and .id field as bit shift.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/a49cd3cd/attachment.sig>
author
#7 lore raw

PATCH v4 3/4 net: add higmacv300 Ethernet driver for HiSilicon platform

In reply to Shawn Guo

It adds the driver for HIGMACV300 Ethernet controller found on HiSilicon SoCs like Hi3798CV200. It's based on a downstream U-Boot driver, but quite a lot of code gets rewritten and cleaned up to adopt driver model and PHY API.

---
 drivers/net/Kconfig      |   9 +
 drivers/net/Makefile     |   1 +
 drivers/net/higmacv300.c | 597 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 607 insertions(+)
 create mode 100644 drivers/net/higmacv300.c
drivers/net/Kconfig +9 -0
index 6a570285aac5..ad1e50c0e8ca 100644
@@ -525,4 +525,13 @@ config MEDIATEK_ETH
 	  This Driver support MediaTek Ethernet GMAC
 	  Say Y to enable support for the MediaTek Ethernet GMAC.
 
+config HIGMACV300_ETH
+	bool "HiSilicon Gigabit Ethernet Controller"
+	depends on DM_ETH
+	select DM_RESET
+	select PHYLIB
+	help
+	  This driver supports HIGMACV300 Ethernet controller found on
+	  HiSilicon SoCs.
+
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 51be72b0aa86..8d02a378964b 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_SNI_AVE) += sni_ave.o
 obj-y += ti/
 obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
 obj-y += mscc_eswitch/
+obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o
drivers/net/higmacv300.c new file +597 -0

597 lines not on this page · raw message

Signature · 1 line
2.18.0
#8 lore raw

PATCH v4 3/4 net: add higmacv300 Ethernet driver for HiSilicon platform

Quoted 7 lines · Shawn Guo

It adds the driver for HIGMACV300 Ethernet controller found on HiSilicon SoCs like Hi3798CV200. It's based on a downstream U-Boot driver, but quite a lot of code gets rewritten and cleaned up to adopt driver model and PHY API.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/5e882f16/attachment.sig>
author
#9 lore raw

PATCH v4 4/4 poplar: enable Ethernet driver support

In reply to Shawn Guo

The 'phy' reset of gmac device in kernel device tree is not generic enough for u-boot to use, so we need to overwrite the 'resets' property as needed. With this device tree fixup and poplar_defconfig changes, Ethernet starts working on Poplar board.

---
 arch/arm/dts/hi3798cv200-u-boot.dtsi | 14 ++++++++++++++
 configs/poplar_defconfig             |  3 +++
 2 files changed, 17 insertions(+)
arch/arm/dts/hi3798cv200-u-boot.dtsi +14 -0
index 7844c5208c5d..2de06d952914 100644
@@ -8,7 +8,15 @@
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  */
 
+#include <dt-bindings/reset/ti-syscon.h>
+
 &soc {
+	rst: reset-controller at 8a22000 {
+		compatible = "hisilicon,hi3798cv200-reset";
+		reg = <0x8a22000 0x1000>;
+		#reset-cells = <3>;
+	};
+
 	usb2: ehci at 9890000 {
 		compatible = "generic-ehci";
 		reg = <0x9890000 0x100>;
@@ -16,6 +24,12 @@
 	};
 };
 
+&gmac1 {
+	resets = <&rst 0xcc 9  ASSERT_SET>,
+		 <&rst 0xcc 11 ASSERT_SET>,
+		 <&rst 0xcc 13 DEASSERT_SET>;
+};
+
 &uart0 {
 	clock = <75000000>;
 	status = "okay";
configs/poplar_defconfig +3 -0
index 81bd3702e42a..76ab5eb70e7e 100644
@@ -19,6 +19,9 @@ CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_K3=y
+CONFIG_DM_ETH=y
+CONFIG_HIGMACV300_ETH=y
+CONFIG_RESET_HISILICON=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
Signature · 1 line
2.18.0
#10 lore raw

PATCH v4 4/4 poplar: enable Ethernet driver support

Quoted 7 lines · Shawn Guo

The 'phy' reset of gmac device in kernel device tree is not generic enough for u-boot to use, so we need to overwrite the 'resets' property as needed. With this device tree fixup and poplar_defconfig changes, Ethernet starts working on Poplar board.

#11 lore raw

PATCH v4 4/4 poplar: enable Ethernet driver support

In reply to Shawn Guo
Quoted 7 lines · Shawn Guo

The 'phy' reset of gmac device in kernel device tree is not generic enough for u-boot to use, so we need to overwrite the 'resets' property as needed. With this device tree fixup and poplar_defconfig changes, Ethernet starts working on Poplar board.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/66a99b7e/attachment.sig>
author
#12 lore raw

v4 cover Add Ethernet support for Poplar board

In reply to Shawn Guo

Hi Joe,

Quoted 9 lines · Shawn Guo

The series adds Ethernet support for Poplar board. It firstly creates a reset driver for HiSilicon platform, then introduces higmacv300 Ethernet driver, and finally enables Ethernet support for Poplar board.

Changes for v4:
- Add a polarity field into struct reset_ctl.
- Instead of defining custom macros for polarity, use generic ones in include/dt-bindings/reset/ti-syscon.h.
- Use .data field as register offset and .id field as bit shift.

How is this version? Any comments there?

Shawn

Quoted 40 lines

Changes for v3:
- Add polarity support into reset driver, so that we can drop the hacking on gmac reset sequence from higmacv300 driver.
Changes for v2:
- Rename driver symbol to HIGMACV300_ETH.
- Remove the use of temp variable 'addr' in higmac_recv().
- Simplify the return of function higmac_ofdata_to_platdata() and higmac_probe().
- Combine delaration and initialization for phyintf in function higmac_ofdata_to_platdata().
- Eliminate the MDIO read/write macros.
- Use wait_for_bit_le32() for MDIO command completion polling.
- Set up RX packet buffers in RX_FQ descriptor at initialization time, so that we do not need to allocate/free packet buffers repeatedly.
- Inform GMAC that the RX descriptor is no longer in use in function higmac_free_pkt().
- Define BITS_DESC_ENA instead of using magic number 0xf.

Shawn Guo (4):
reset: add polarity field into struct reset_ctl
reset: add reset driver for HiSilicon platform
net: add higmacv300 Ethernet driver for HiSilicon platform
poplar: enable Ethernet driver support

 arch/arm/dts/hi3798cv200-u-boot.dtsi |  14 +
 configs/poplar_defconfig             |   3 +
 drivers/net/Kconfig                  |   9 +
 drivers/net/Makefile                 |   1 +
 drivers/net/higmacv300.c             | 597 +++++++++++++++++++++++++++
 drivers/reset/Kconfig                |   6 +
 drivers/reset/Makefile               |   1 +
 drivers/reset/reset-hisilicon.c      | 103 +++++
 include/reset.h                      |   3 +
 9 files changed, 737 insertions(+)
 create mode 100644 drivers/net/higmacv300.c
 create mode 100644 drivers/reset/reset-hisilicon.c
Signature · 1 line
2.18.0
#13 lore raw

v4 cover Add Ethernet support for Poplar board

Quoted 8 lines · Shawn Guo

Hi Joe,

Quoted 4 lines · Shawn Guo

The series adds Ethernet support for Poplar board. It firstly creates a reset driver for HiSilicon platform, then introduces higmacv300 Ethernet driver, and finally enables Ethernet support for Poplar board.

Quoted 7 lines
Quoted 5 lines

Changes for v4:
- Add a polarity field into struct reset_ctl.
- Instead of defining custom macros for polarity, use generic ones in include/dt-bindings/reset/ti-syscon.h.
- Use .data field as register offset and .id field as bit shift.

How is this version? Any comments there?

Looks great! Thanks!

Quoted 47 lines

Shawn

Quoted 37 lines

Changes for v3:
- Add polarity support into reset driver, so that we can drop the hacking on gmac reset sequence from higmacv300 driver.
Changes for v2:
- Rename driver symbol to HIGMACV300_ETH.
- Remove the use of temp variable 'addr' in higmac_recv().
- Simplify the return of function higmac_ofdata_to_platdata() and higmac_probe().
- Combine delaration and initialization for phyintf in function higmac_ofdata_to_platdata().
- Eliminate the MDIO read/write macros.
- Use wait_for_bit_le32() for MDIO command completion polling.
- Set up RX packet buffers in RX_FQ descriptor at initialization time, so that we do not need to allocate/free packet buffers repeatedly.
- Inform GMAC that the RX descriptor is no longer in use in function higmac_free_pkt().
- Define BITS_DESC_ENA instead of using magic number 0xf.

Shawn Guo (4):
reset: add polarity field into struct reset_ctl
reset: add reset driver for HiSilicon platform
net: add higmacv300 Ethernet driver for HiSilicon platform
poplar: enable Ethernet driver support

 arch/arm/dts/hi3798cv200-u-boot.dtsi |  14 +
 configs/poplar_defconfig             |   3 +
 drivers/net/Kconfig                  |   9 +
 drivers/net/Makefile                 |   1 +
 drivers/net/higmacv300.c             | 597 +++++++++++++++++++++++++++
 drivers/reset/Kconfig                |   6 +
 drivers/reset/Makefile               |   1 +
 drivers/reset/reset-hisilicon.c      | 103 +++++
 include/reset.h                      |   3 +
 9 files changed, 737 insertions(+)
 create mode 100644 drivers/net/higmacv300.c
 create mode 100644 drivers/reset/reset-hisilicon.c
Quoted 3 lines

--
2.18.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

author
#14 lore raw

v4 cover Add Ethernet support for Poplar board

Quoted 15 lines · Joe Hershberger
Quoted 14 lines · Shawn Guo

Hi Joe,

Quoted 9 lines · Shawn Guo

The series adds Ethernet support for Poplar board. It firstly creates a reset driver for HiSilicon platform, then introduces higmacv300 Ethernet driver, and finally enables Ethernet support for Poplar board.

Changes for v4:
- Add a polarity field into struct reset_ctl.
- Instead of defining custom macros for polarity, use generic ones in include/dt-bindings/reset/ti-syscon.h.
- Use .data field as register offset and .id field as bit shift.

Quoted 3 lines
Quoted 1 line

How is this version? Any comments there?

Looks great! Thanks!

Hi Tom,

The series has been there for almost one month with no further comments. I guess it's ready to be picked up?

Thanks,
Shawn