Skip to contentSkip to conversation

Add Ethernet support for Poplar board

PATCH Superseded Shawn Guo 2 participants 10 messages Mar 10, 2019 – Mar 20, 2019

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

v3 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 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 (3):
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      | 111 +++++
 8 files changed, 742 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 v3 1/3 reset: add reset driver for HiSilicon platform

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 | 111 ++++++++++++++++++++++++++++++++
 3 files changed, 118 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 +111 -0

111 lines not on this page · raw message

Signature · 1 line
2.18.0
#2 lore raw

PATCH v3 1/3 reset: add reset driver for HiSilicon platform

Hi Shawn,

Quoted 44 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.

---
 drivers/reset/Kconfig           |   6 ++
 drivers/reset/Makefile          |   1 +
 drivers/reset/reset-hisilicon.c | 111 ++++++++++++++++++++++++++++++++
 3 files changed, 118 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 +0 -0
new file mode 100644
index 000000000000..7b0c11fbc82e

drivers/reset/reset-hisilicon.c line 9

Quoted 9 lines
drivers/reset/reset-hisilicon.c new file +9 -0
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019, Linaro Limited
+ */
+
+#include <asm/io.h>
+#include <common.h>
+#include <dm.h>
+#include <dt-bindings/reset/hisi-reset.h>

Where does this file come from?

Quoted 54 lines
drivers/reset/reset-hisilicon.c new file +54 -0
+#include <reset-uclass.h>
+
+struct hisi_reset_priv {
+       void __iomem *base;
+};
+
+static int hisi_reset_deassert(struct reset_ctl *rst)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
+       u32 offset = rst->data & 0xffff;
+       u32 shift = rst->data >> 16;
+       int polarity = rst->id;
+       u32 val;
+
+       val = readl(priv->base + offset);
+       if (polarity == HISI_RESET_ACTIVE_HIGH)
+               val &= ~BIT(shift);
+       else
+               val |= BIT(shift);
+       writel(val, priv->base + offset);
+
+       return 0;
+}
+
+static int hisi_reset_assert(struct reset_ctl *rst)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
+       u32 offset = rst->data & 0xffff;
+       u32 shift = rst->data >> 16;
+       int polarity = rst->id;
+       u32 val;
+
+       val = readl(priv->base + offset);
+       if (polarity == HISI_RESET_ACTIVE_HIGH)
+               val |= BIT(shift);
+       else
+               val &= ~BIT(shift);
+       writel(val, priv->base + offset);
+
+       return 0;
+}
+
+static int hisi_reset_free(struct reset_ctl *rst)
+{
+       return 0;
+}
+
+static int hisi_reset_request(struct reset_ctl *rst)
+{
+       return 0;
+}
+
+static int hisi_reset_of_xlate(struct reset_ctl *rst,
+                              struct ofnode_phandle_args *args)

drivers/reset/reset-hisilicon.c line 73

Quoted 10 lines
drivers/reset/reset-hisilicon.c new file +10 -0
+{
+       if (args->args_count != 3) {
+               debug("Invalid args_count: %d\n", args->args_count);
+               return -EINVAL;
+       }
+
+       /*
+        * Encode register offset in .data[15..0] and bit shift in
+        * .data[31..16], and use .id field as polarity.
+        */

I don't like going through these contortions to avoid changing the struct in reset.h

I think you should add a "polarity" field to that struct and instead of defining a specific constant for HISI_RESET_ACTIVE_HIGH, instead make a generic one that everyone can use, such as the ASSERT_CLEAR and friends in Linux.

I also hope you can get rid of the register offset and either include it in the DT base address if it is something that needs to be selected or simply make a #define for the 0xCC for what the register is called and go from there. If both are not acceptable, I think it makes sense to use "data" as the register.

drivers/reset/reset-hisilicon.c line 75

Quoted 2 lines
drivers/reset/reset-hisilicon.c new file +2 -0
+       rst->data = (args->args[1] << 16) | (args->args[0] & 0xffff);
+       rst->id = args->args[2];

I think "id" should be used to hold the "shift" or bit number of the reset.

Quoted 43 lines
drivers/reset/reset-hisilicon.c new file +36 -1
+
+       return 0;
+}
+
+static const struct reset_ops hisi_reset_reset_ops = {
+       .of_xlate = hisi_reset_of_xlate,
+       .request = hisi_reset_request,
+       .free = hisi_reset_free,
+       .rst_assert = hisi_reset_assert,
+       .rst_deassert = hisi_reset_deassert,
+};
+
+static const struct udevice_id hisi_reset_ids[] = {
+       { .compatible = "hisilicon,hi3798cv200-reset" },
+       { }
+};
+
+static int hisi_reset_probe(struct udevice *dev)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(dev);
+
+       priv->base = dev_remap_addr(dev);
+       if (!priv->base)
+               return -ENOMEM;
+
+       return 0;
+}
+
+U_BOOT_DRIVER(hisi_reset) = {
+       .name = "hisilicon_reset",
+       .id = UCLASS_RESET,
+       .of_match = hisi_reset_ids,
+       .ops = &hisi_reset_reset_ops,
+       .probe = hisi_reset_probe,
+       .priv_auto_alloc_size = sizeof(struct hisi_reset_priv),
+};
--

2.18.0

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

author
#3 lore raw

PATCH v3 1/3 reset: add reset driver for HiSilicon platform

Hi Joe,

Thanks for the comments.

Quoted 50 lines · Joe Hershberger

Hi Shawn,

Quoted 47 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.

---
 drivers/reset/Kconfig           |   6 ++
 drivers/reset/Makefile          |   1 +
 drivers/reset/reset-hisilicon.c | 111 ++++++++++++++++++++++++++++++++
 3 files changed, 118 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 +3 -0
new file mode 100644
index 000000000000..7b0c11fbc82e
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019, Linaro Limited
Quoted 8 lines

drivers/reset/reset-hisilicon.c line 9

Quoted 6 lines
drivers/reset/reset-hisilicon.c new file +6 -0
+ */
+
+#include <asm/io.h>
+#include <common.h>
+#include <dm.h>
+#include <dt-bindings/reset/hisi-reset.h>

Where does this file come from?

Sorry, my bad. It's a new file in my working tree, and I forgot to add it. It becomes unneeded in the next version though.

Quoted 70 lines
Quoted 56 lines
drivers/reset/reset-hisilicon.c new file +54 -0
+#include <reset-uclass.h>
+
+struct hisi_reset_priv {
+       void __iomem *base;
+};
+
+static int hisi_reset_deassert(struct reset_ctl *rst)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
+       u32 offset = rst->data & 0xffff;
+       u32 shift = rst->data >> 16;
+       int polarity = rst->id;
+       u32 val;
+
+       val = readl(priv->base + offset);
+       if (polarity == HISI_RESET_ACTIVE_HIGH)
+               val &= ~BIT(shift);
+       else
+               val |= BIT(shift);
+       writel(val, priv->base + offset);
+
+       return 0;
+}
+
+static int hisi_reset_assert(struct reset_ctl *rst)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
+       u32 offset = rst->data & 0xffff;
+       u32 shift = rst->data >> 16;
+       int polarity = rst->id;
+       u32 val;
+
+       val = readl(priv->base + offset);
+       if (polarity == HISI_RESET_ACTIVE_HIGH)
+               val |= BIT(shift);
+       else
+               val &= ~BIT(shift);
+       writel(val, priv->base + offset);
+
+       return 0;
+}
+
+static int hisi_reset_free(struct reset_ctl *rst)
+{
+       return 0;
+}
+
+static int hisi_reset_request(struct reset_ctl *rst)
+{
+       return 0;
+}
+
+static int hisi_reset_of_xlate(struct reset_ctl *rst,
+                              struct ofnode_phandle_args *args)

drivers/reset/reset-hisilicon.c line 73

Quoted 10 lines
drivers/reset/reset-hisilicon.c new file +10 -0
+{
+       if (args->args_count != 3) {
+               debug("Invalid args_count: %d\n", args->args_count);
+               return -EINVAL;
+       }
+
+       /*
+        * Encode register offset in .data[15..0] and bit shift in
+        * .data[31..16], and use .id field as polarity.
+        */

I don't like going through these contortions to avoid changing the struct in reset.h

Quoted 4 lines

I think you should add a "polarity" field to that struct and instead of defining a specific constant for HISI_RESET_ACTIVE_HIGH, instead make a generic one that everyone can use, such as the ASSERT_CLEAR and friends in Linux.

Okay, will do in the next version. As the ASSERT_CLEAR and friends are defined in include/dt-bindings/reset/ti-syscon.h (already copied into U-Boot from Linux), I will just use this header.

Quoted 5 lines

I also hope you can get rid of the register offset and either include it in the DT base address if it is something that needs to be selected or simply make a #define for the 0xCC for what the register is called and go from there.

Although the resets we need for GMAC happen to be in a single register, the controller includes resets for other modules, that spread in different registers. I would like to get the driver ready for other clients to use in the future.

Quoted 7 lines

If both are not acceptable, I think it makes sense to use "data" as the register.

drivers/reset/reset-hisilicon.c line 75

Quoted 2 lines
drivers/reset/reset-hisilicon.c new file +2 -0
+       rst->data = (args->args[1] << 16) | (args->args[0] & 0xffff);
+       rst->id = args->args[2];

I think "id" should be used to hold the "shift" or bit number of the reset.

Yes. This is exactly what v2 does - use 'data' as register offset and 'id' as shift. Will go back to this in the next version.

Shawn

Quoted 47 lines
Quoted 47 lines
drivers/reset/reset-hisilicon.c new file +36 -1
+
+       return 0;
+}
+
+static const struct reset_ops hisi_reset_reset_ops = {
+       .of_xlate = hisi_reset_of_xlate,
+       .request = hisi_reset_request,
+       .free = hisi_reset_free,
+       .rst_assert = hisi_reset_assert,
+       .rst_deassert = hisi_reset_deassert,
+};
+
+static const struct udevice_id hisi_reset_ids[] = {
+       { .compatible = "hisilicon,hi3798cv200-reset" },
+       { }
+};
+
+static int hisi_reset_probe(struct udevice *dev)
+{
+       struct hisi_reset_priv *priv = dev_get_priv(dev);
+
+       priv->base = dev_remap_addr(dev);
+       if (!priv->base)
+               return -ENOMEM;
+
+       return 0;
+}
+
+U_BOOT_DRIVER(hisi_reset) = {
+       .name = "hisilicon_reset",
+       .id = UCLASS_RESET,
+       .of_match = hisi_reset_ids,
+       .ops = &hisi_reset_reset_ops,
+       .probe = hisi_reset_probe,
+       .priv_auto_alloc_size = sizeof(struct hisi_reset_priv),
+};
--

2.18.0

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

author
#4 lore raw

PATCH v3 2/3 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
#5 lore raw

PATCH v3 2/3 net: add higmacv300 Ethernet driver for HiSilicon platform

Quoted 8 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.

---

author
#6 lore raw

PATCH v3 3/3 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..2ca943f64e59 100644
@@ -8,7 +8,15 @@
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  */
 
+#include <dt-bindings/reset/hisi-reset.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  HISI_RESET_ACTIVE_HIGH>,
+		 <&rst 0xcc 11 HISI_RESET_ACTIVE_HIGH>,
+		 <&rst 0xcc 13 HISI_RESET_ACTIVE_LOW>;
+};
+
 &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
#7 lore raw

PATCH v3 3/3 poplar: enable Ethernet driver support

Quoted 18 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.

---
 arch/arm/dts/hi3798cv200-u-boot.dtsi | 14 ++++++++++++++
 configs/poplar_defconfig             |  3 +++
 2 files changed, 17 insertions(+)
arch/arm/dts/hi3798cv200-u-boot.dtsi +0 -0
index 7844c5208c5d..2ca943f64e59 100644

arch/arm/dts/hi3798cv200-u-boot.dtsi line 11

Quoted 4 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +1 -0
@@ -8,7 +8,15 @@
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  */
 
+#include <dt-bindings/reset/hisi-reset.h>

Where does this file come from?

arch/arm/dts/hi3798cv200-u-boot.dtsi line 16

Quoted 5 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +4 -0
+
 &soc {
+       rst: reset-controller at 8a22000 {
+               compatible = "hisilicon,hi3798cv200-reset";
+               reg = <0x8a22000 0x1000>;

Would it not be reasonable to include the "0xcc" from below in this address instead of adding them at runtime?

Quoted 40 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +9 -0
+               #reset-cells = <3>;
+       };
+
        usb2: ehci at 9890000 {
                compatible = "generic-ehci";
                reg = <0x9890000 0x100>;
@@ -16,6 +24,12 @@
        };
 };
 
+&gmac1 {
+       resets = <&rst 0xcc 9  HISI_RESET_ACTIVE_HIGH>,
+                <&rst 0xcc 11 HISI_RESET_ACTIVE_HIGH>,
+                <&rst 0xcc 13 HISI_RESET_ACTIVE_LOW>;
+};
+
 &uart0 {
        clock = <75000000>;
        status = "okay";
configs/poplar_defconfig +3 -1
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
--

2.18.0

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

author
#8 lore raw

PATCH v3 3/3 poplar: enable Ethernet driver support

Quoted 26 lines · Joe Hershberger
Quoted 18 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.

---
 arch/arm/dts/hi3798cv200-u-boot.dtsi | 14 ++++++++++++++
 configs/poplar_defconfig             |  3 +++
 2 files changed, 17 insertions(+)
arch/arm/dts/hi3798cv200-u-boot.dtsi +0 -0
index 7844c5208c5d..2ca943f64e59 100644

arch/arm/dts/hi3798cv200-u-boot.dtsi line 11

Quoted 4 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +1 -0
@@ -8,7 +8,15 @@
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  */
 
+#include <dt-bindings/reset/hisi-reset.h>

Where does this file come from?

Quoted 8 lines

arch/arm/dts/hi3798cv200-u-boot.dtsi line 16

Quoted 5 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +4 -0
+
 &soc {
+       rst: reset-controller at 8a22000 {
+               compatible = "hisilicon,hi3798cv200-reset";
+               reg = <0x8a22000 0x1000>;

Would it not be reasonable to include the "0xcc" from below in this address instead of adding them at runtime?

In that case, if we have new client devices using other registers in the reset controller, we will need to have multiple such nodes to be defined. This is less efficient and doesn't describe HW design well.

Shawn

Quoted 42 lines
Quoted 42 lines
arch/arm/dts/hi3798cv200-u-boot.dtsi +9 -0
+               #reset-cells = <3>;
+       };
+
        usb2: ehci at 9890000 {
                compatible = "generic-ehci";
                reg = <0x9890000 0x100>;
@@ -16,6 +24,12 @@
        };
 };
 
+&gmac1 {
+       resets = <&rst 0xcc 9  HISI_RESET_ACTIVE_HIGH>,
+                <&rst 0xcc 11 HISI_RESET_ACTIVE_HIGH>,
+                <&rst 0xcc 13 HISI_RESET_ACTIVE_LOW>;
+};
+
 &uart0 {
        clock = <75000000>;
        status = "okay";
configs/poplar_defconfig +3 -1
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
--

2.18.0

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

author
#9 lore raw

v3 cover Add Ethernet support for Poplar board

In reply to Shawn Guo

Hi Joe,

Quoted 7 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 v3:
- Add polarity support into reset driver, so that we can drop the hacking on gmac reset sequence from higmacv300 driver.

Does this version look good to you?

Shawn

Quoted 35 lines

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 (3):
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      | 111 +++++
 8 files changed, 742 insertions(+)
 create mode 100644 drivers/net/higmacv300.c
 create mode 100644 drivers/reset/reset-hisilicon.c
Signature · 1 line
2.18.0