Skip to contentSkip to conversation

x86: Add Intel Topcliff PCH Gigabit Ethernet support

PATCH New Bin Meng 3 participants 19 messages Mar 20, 2015 – Mar 25, 2015

Subsystems (2)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

cover x86: Add Intel Topcliff PCH Gigabit Ethernet support

This series adds a new ethernet driver for the GMAC found on Intel Topcliff Platform Controller Hub and enable its support on Intel Crown Bay board.

The series also did some clean up work below:
- Introduce ETH_FCS_LEN macro as it is often used by some ethernet drivers
- Remove any local version of ETH_FCS_LEN from various places
- Update README.drivers.eth for up-to-date mdio APIs

Bin Meng (4):
net: Add ethernet FCS length macro in net.h
net: Update README.drivers.eth to mention latest APIs
net: Add Intel Topcliff GMAC driver
x86: crownbay: Enable Intel Topcliff GMAC support

 doc/README.drivers.eth     |  51 +++--
 drivers/net/Makefile       |   1 +
 drivers/net/e1000.h        |   7 +-
 drivers/net/pch_gbe.c      | 466 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/pch_gbe.h      | 300 +++++++++++++++++++++++++++++
 drivers/usb/gadget/ether.c |   1 -
 drivers/usb/gadget/rndis.c |   1 -
 include/configs/crownbay.h |   4 +
 include/net.h              |   2 +
 include/netdev.h           |   4 +
 include/usb_ether.h        |   1 -
 11 files changed, 815 insertions(+), 23 deletions(-)
 create mode 100644 drivers/net/pch_gbe.c
 create mode 100644 drivers/net/pch_gbe.h
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH 1/4 net: Add ethernet FCS length macro in net.h

Some ethernet drivers use their own version of ethernet FCS length macro which is really common. We define ETH_FCS_LEN in net.h and replace those custom versions in various places.

---

 drivers/net/e1000.h        | 7 +++----
 drivers/usb/gadget/ether.c | 1 -
 drivers/usb/gadget/rndis.c | 1 -
 include/net.h              | 2 ++
 include/usb_ether.h        | 1 -
 5 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/e1000.h +3 -4
index 6d110eb..f3b77b1 100644
@@ -430,12 +430,11 @@ struct e1000_phy_stats {
 #define ENET_HEADER_SIZE	     14
 #define MAXIMUM_ETHERNET_FRAME_SIZE  1518	/* With FCS */
 #define MINIMUM_ETHERNET_FRAME_SIZE  64	/* With FCS */
-#define ETHERNET_FCS_SIZE	     4
 #define MAXIMUM_ETHERNET_PACKET_SIZE \
-    (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
+	(MAXIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN)
 #define MINIMUM_ETHERNET_PACKET_SIZE \
-    (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
-#define CRC_LENGTH		     ETHERNET_FCS_SIZE
+	(MINIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN)
+#define CRC_LENGTH		     ETH_FCS_LEN
 #define MAX_JUMBO_FRAME_SIZE	     0x3F00
 
 /* 802.1q VLAN Packet Sizes */
drivers/usb/gadget/ether.c +0 -1
index ba442d5..8f03a6b 100644
@@ -68,7 +68,6 @@ unsigned packet_received, packet_sent;
 #define ETH_ZLEN	60		/* Min. octets in frame sans FCS */
 #define ETH_DATA_LEN	1500		/* Max. octets in payload	 */
 #define ETH_FRAME_LEN	PKTSIZE_ALIGN	/* Max. octets in frame sans FCS */
-#define ETH_FCS_LEN	4		/* Octets in the FCS		 */
 
 #define DRIVER_DESC		"Ethernet Gadget"
 /* Based on linux 2.6.27 version */
drivers/usb/gadget/rndis.c +0 -1
index 404a7b9..62c9b2e 100644
@@ -43,7 +43,6 @@
 #define ETH_ZLEN	60		/* Min. octets in frame sans FCS */
 #define ETH_DATA_LEN	1500		/* Max. octets in payload	 */
 #define ETH_FRAME_LEN	PKTSIZE_ALIGN	/* Max. octets in frame sans FCS */
-#define ETH_FCS_LEN	4		/* Octets in the FCS		 */
 #define ENOTSUPP        524     /* Operation is not supported */
 
 
include/net.h +2 -0
index 73ea88b..b9a5c41 100644
@@ -191,6 +191,8 @@ struct ethernet_hdr {
 /* Ethernet header size */
 #define ETHER_HDR_SIZE	(sizeof(struct ethernet_hdr))
 
+#define ETH_FCS_LEN	4		/* Octets in the FCS		*/
+
 struct e802_hdr {
 	uchar		et_dest[6];	/* Destination node		*/
 	uchar		et_src[6];	/* Source node			*/
include/usb_ether.h +0 -1
index b38d037..23507e1 100644
@@ -18,7 +18,6 @@
 #define ETH_ZLEN	60		/* Min. octets in frame sans FCS */
 #define ETH_DATA_LEN	1500		/* Max. octets in payload	 */
 #define ETH_FRAME_LEN	PKTSIZE_ALIGN	/* Max. octets in frame sans FCS */
-#define ETH_FCS_LEN	4		/* Octets in the FCS		 */
 
 struct ueth_data {
 	/* eth info */
Signature · 1 line
1.8.2.1
#3 lore raw

PATCH 1/4 net: Add ethernet FCS length macro in net.h

Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Bin Meng

Some ethernet drivers use their own version of ethernet FCS length macro which is really common. We define ETH_FCS_LEN in net.h and replace those custom versions in various places.

---

I'll pick this up to get this board into better shape.

Applied to u-boot-x86, thanks!

author
#4 lore raw

PATCH 2/4 net: Update README.drivers.eth to mention latest APIs

In reply to Bin Meng

README.drivers.eth still refers to the deprecated miiphy_register(). Update the doc to mention new APIs mdio_alloc() and mdio_register().

---

 doc/README.drivers.eth | 51 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 16 deletions(-)
doc/README.drivers.eth +35 -16
index eb83038..42af442 100644
@@ -43,15 +43,16 @@ int ape_register(bd_t *bis, int iobase)
 {
 	struct ape_priv *priv;
 	struct eth_device *dev;
+	struct mii_dev *bus;
 
 	priv = malloc(sizeof(*priv));
 	if (priv == NULL)
-		return 1;
+		return -ENOMEM;
 
 	dev = malloc(sizeof(*dev));
 	if (dev == NULL) {
 		free(priv);
-		return 1;
+		return -ENOMEM;
 	}
 
 	/* setup whatever private state you need */
@@ -59,7 +60,8 @@ int ape_register(bd_t *bis, int iobase)
 	memset(dev, 0, sizeof(*dev));
 	sprintf(dev->name, "APE");
 
-	/* if your device has dedicated hardware storage for the
+	/*
+	 * if your device has dedicated hardware storage for the
 	 * MAC, read it and initialize dev->enetaddr with it
 	 */
 	ape_mac_read(dev->enetaddr);
@@ -74,8 +76,17 @@ int ape_register(bd_t *bis, int iobase)
 
 	eth_register(dev);
 
-#ifdef CONFIG_CMD_MII)
-	miiphy_register(dev->name, ape_mii_read, ape_mii_write);
+#ifdef CONFIG_PHYLIB
+	bus = mdio_alloc();
+	if (!bus) {
+		free(priv);
+		free(dev);
+		return -ENOMEM;
+	}
+
+	bus->read = ape_mii_read;
+	bus->write = ape_mii_write;
+	mdio_register(bus);
 #endif
 
 	return 1;
@@ -166,25 +177,33 @@ some net operation (ping / tftp / whatever...)
 	eth_halt()
 		dev->halt()
 
------------------------------
- CONFIG_MII / CONFIG_CMD_MII
------------------------------
+--------------------------------
+ CONFIG_PHYLIB / CONFIG_CMD_MII
+--------------------------------
 
 If your device supports banging arbitrary values on the MII bus (pretty much
 every device does), you should add support for the mii command.  Doing so is
 fairly trivial and makes debugging mii issues a lot easier at runtime.
 
 After you have called eth_register() in your driver's register function, add
-a call to miiphy_register() like so:
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-	miiphy_register(dev->name, mii_read, mii_write);
-#endif
+a call to mdio_alloc() and mdio_register() like so:
+	bus = mdio_alloc();
+	if (!bus) {
+		free(priv);
+		free(dev);
+		return -ENOMEM;
+	}
+
+	bus->read = ape_mii_read;
+	bus->write = ape_mii_write;
+	mdio_register(bus);
 
 And then define the mii_read and mii_write functions if you haven't already.
 Their syntax is straightforward:
-	int mii_read(char *devname, uchar addr, uchar reg, ushort *val);
-	int mii_write(char *devname, uchar addr, uchar reg, ushort val);
+	int mii_read(struct mii_dev *bus, int addr, int devad, int reg);
+	int mii_write(struct mii_dev *bus, int addr, int devad, int reg,
+		      u16 val);
 
 The read function should read the register 'reg' from the phy at address 'addr'
-and store the result in the pointer 'val'.  The implementation for the write
-function should logically follow.
+and return the result to its caller.  The implementation for the write function
+should logically follow.
Signature · 1 line
1.8.2.1
#6 lore raw

PATCH 2/4 net: Update README.drivers.eth to mention latest APIs

Quoted 9 lines · Joe Hershberger
Quoted 6 lines · Bin Meng

README.drivers.eth still refers to the deprecated miiphy_register(). Update the doc to mention new APIs mdio_alloc() and mdio_register().

---

Applied to u-boot-x86, thanks!

author
#7 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

In reply to Bin Meng

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

 drivers/net/Makefile  |   1 +
 drivers/net/pch_gbe.c | 466 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/pch_gbe.h | 300 ++++++++++++++++++++++++++++++++
 include/netdev.h      |   4 +
 4 files changed, 771 insertions(+)
 create mode 100644 drivers/net/pch_gbe.c
 create mode 100644 drivers/net/pch_gbe.h
drivers/net/Makefile +1 -0
index 46c4ac6..66c35fa 100644
@@ -47,6 +47,7 @@ obj-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 obj-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_NS8382X) += ns8382x.o
+obj-$(CONFIG_PCH_GBE) += pch_gbe.o
 obj-$(CONFIG_PCNET) += pcnet.o
 obj-$(CONFIG_RTL8139) += rtl8139.o
 obj-$(CONFIG_RTL8169) += rtl8169.o
drivers/net/pch_gbe.c new file +466 -0

466 lines not on this page · raw message

drivers/net/pch_gbe.h new file +300 -0

300 lines not on this page · raw message

include/netdev.h +4 -0
index daffc12..4cbf055 100644
@@ -70,6 +70,7 @@ int natsemi_initialize(bd_t *bis);
 int ne2k_register(void);
 int npe_initialize(bd_t *bis);
 int ns8382x_initialize(bd_t *bis);
+int pch_gbe_register(bd_t *bis);
 int pcnet_initialize(bd_t *bis);
 int ppc_4xx_eth_initialize (bd_t *bis);
 int rtl8139_initialize(bd_t *bis);
@@ -124,6 +125,9 @@ static inline int pci_eth_init(bd_t *bis)
 #ifdef CONFIG_E1000
 	num += e1000_initialize(bis);
 #endif
+#ifdef CONFIG_PCH_GBE
+	num += pch_gbe_register(bis);
+#endif
 #ifdef CONFIG_PCNET
 	num += pcnet_initialize(bis);
 #endif
Signature · 1 line
1.8.2.1
#9 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

Hi Bin,

Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Bin Meng

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

Do you think this could be converted to driver model?

E.g., see this:

http://patchwork.ozlabs.org/patch/444846/

Regards,
Simon

author
#10 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

Hi Simon,

Quoted 12 lines · Simon Glass

Hi Bin,

Quoted 9 lines · Joe Hershberger
Quoted 7 lines · Bin Meng

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

Quoted 7 lines
Quoted 1 line

Do you think this could be converted to driver model?

E.g., see this:

http://patchwork.ozlabs.org/patch/444846/

Yes, I plan to do the conversion in the future as a separate patch. If possible to catch up the train for the v2015.04 release, are you going to apply this series now?

Regards,
Bin

#11 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

Hi Bin,

Quoted 7 lines · Bin Meng

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Bin,

On 20 March 2015 at 13:18, Joe Hershberger <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 10 lines · Bin Meng
Quoted 7 lines

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

Do you think this could be converted to driver model?

Quoted 7 lines
Quoted 3 lines

E.g., see this:

http://patchwork.ozlabs.org/patch/444846/

Yes, I plan to do the conversion in the future as a separate patch. If possible to catch up the train for the v2015.04 release, are you going to apply this series now?

I was planning to do this later. Do you want it in this release? I suppose that would be ok because it is a new board.

Regards,
Simon

author
#12 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Bin,

Quoted 23 lines · Bin Meng

Hi Simon,

Quoted 19 lines · Simon Glass

Hi Bin,

Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Bin Meng

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

Do you think this could be converted to driver model?

E.g., see this:

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

http://patchwork.ozlabs.org/patch/444846/

Yes, I plan to do the conversion in the future as a separate patch. If possible to catch up the train for the v2015.04 release, are you going to apply this series now?

I was planning to do this later. Do you want it in this release? I suppose that would be ok because it is a new board.

Yep, given the series look OK and no rework will be needed, I would like to add it to this release if time permits. And maybe along with my other patches before (quark)?

Regards,
Bin

#13 lore raw

PATCH 3/4 net: Add Intel Topcliff GMAC driver

Quoted 39 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Bin,

Quoted 23 lines · Bin Meng

Hi Simon,

Quoted 19 lines · Simon Glass

Hi Bin,

Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Bin Meng

Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands.

---

Do you think this could be converted to driver model?

E.g., see this:

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

http://patchwork.ozlabs.org/patch/444846/

Yes, I plan to do the conversion in the future as a separate patch. If possible to catch up the train for the v2015.04 release, are you going to apply this series now?

I was planning to do this later. Do you want it in this release? I suppose that would be ok because it is a new board.

Quoted 6 lines

Yep, given the series look OK and no rework will be needed, I would like to add it to this release if time permits. And maybe along with my other patches before (quark)?

Regards,
Bin

Applied to u-boot-x86, thanks!

author
#14 lore raw

PATCH 4/4 x86: crownbay: Enable Intel Topcliff GMAC support

In reply to Bin Meng

Intel Crown Bay board has one ethernet port connected from Intel Topcliff PCH. Enable it in the board configuration.

---

 include/configs/crownbay.h | 4 ++++
 1 file changed, 4 insertions(+)
include/configs/crownbay.h +4 -0
index 4a74f82..df32f2a 100644
@@ -52,6 +52,10 @@
 #define CONFIG_MMC_SDMA
 #define CONFIG_CMD_MMC
 
+/* Topcliff Gigabit Ethernet */
+#define CONFIG_PCH_GBE
+#define CONFIG_PHYLIB
+
 /* Video is not supported */
 #undef CONFIG_VIDEO
 #undef CONFIG_CFB_CONSOLE
Signature · 1 line
1.8.2.1
#17 lore raw

cover x86: Add Intel Topcliff PCH Gigabit Ethernet support

In reply to Bin Meng

Hi Simon,

Quoted 2 lines · Bin Meng

This series adds a new ethernet driver for the GMAC found on Intel

Topcliff

Quoted 8 lines

Platform Controller Hub and enable its support on Intel Crown Bay board.

The series also did some clean up work below:
- Introduce ETH_FCS_LEN macro as it is often used by some ethernet drivers
- Remove any local version of ETH_FCS_LEN from various places
- Update README.drivers.eth for up-to-date mdio APIs

Quoted 5 lines

Bin Meng (4):
net: Add ethernet FCS length macro in net.h
net: Update README.drivers.eth to mention latest APIs
net: Add Intel Topcliff GMAC driver
x86: crownbay: Enable Intel Topcliff GMAC support

I assume it is preferable to pull this through the x86 tree. Let me know either way.

-Joe

#18 lore raw

cover x86: Add Intel Topcliff PCH Gigabit Ethernet support

Hi Joe,

Quoted 14 lines · Joe Hershberger

Hi Simon,

Quoted 11 lines · Bin Meng

This series adds a new ethernet driver for the GMAC found on Intel Topcliff
Platform Controller Hub and enable its support on Intel Crown Bay board.

The series also did some clean up work below:
- Introduce ETH_FCS_LEN macro as it is often used by some ethernet drivers
- Remove any local version of ETH_FCS_LEN from various places
- Update README.drivers.eth for up-to-date mdio APIs

Quoted 8 lines
Quoted 5 lines

Bin Meng (4):
net: Add ethernet FCS length macro in net.h
net: Update README.drivers.eth to mention latest APIs
net: Add Intel Topcliff GMAC driver
x86: crownbay: Enable Intel Topcliff GMAC support

I assume it is preferable to pull this through the x86 tree. Let me know either way.

Yes, will do. But I suspect it should be converted to driver model. Let's see.

Regards,
Simon