Skip to contentSkip to conversation

net: ethernet: Add TSE PCS support to dwmac-socfpga

PATCH Superseded [email protected] 2 participants 2 messages Jun 3, 2016 – Jun 6, 2016

Subsystems (6)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ethernet: Add TSE PCS support to dwmac-socfpga

From: Tien Hock Loh <[email protected]>

This adds support for TSE PCS that uses SGMII adapter when the phy-mode of the dwmac is set to sgmii

---
v2:
- Refactored the TSE PCS out from the dwmac-socfpga.c file
- Added binding documentation for TSE PCS sgmii adapter

---
 .../devicetree/bindings/net/socfpga-dwmac.txt      |   4 +
 drivers/net/ethernet/stmicro/stmmac/Makefile       |   2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 141 ++++++++++--
 drivers/net/ethernet/stmicro/stmmac/tse_pcs.c      | 245 +++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/tse_pcs.h      |  11 +
 5 files changed, 379 insertions(+), 24 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/tse_pcs.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/tse_pcs.h
Documentation/devicetree/bindings/net/socfpga-dwmac.txt +4 -0
index 3a9d679..2bc39f1 100644
@@ -15,6 +15,8 @@ Required properties:
 Optional properties:
 altr,emac-splitter: Should be the phandle to the emac splitter soft IP node if
 		DWMAC controller is connected emac splitter.
+phy-mode: The phy mode the ethernet operates in
+altr,sgmii_to_sgmii_converter: phandle to the TSE SGMII converter
 
 Example:
 
@@ -28,4 +30,6 @@ gmac0: ethernet@ff700000 {
 	mac-address = [00 00 00 00 00 00];/* Filled in by U-Boot */
 	clocks = <&emac_0_clk>;
 	clock-names = "stmmaceth";
+	phy-mode = "sgmii";
+	altr,gmii_to_sgmii_converter = <&sgmii_1_gmii_to_sgmii_converter_0>;
 };
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index 73c2715..29c1dee 100644
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 
 obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o	\
-		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o
+		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o tse_pcs.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +118 -23

202 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/tse_pcs.c new file +245 -0

245 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/tse_pcs.h new file +11 -0
new file mode 100644
index 0000000..3faa714
@@ -0,0 +1,11 @@
+struct tse_pcs {
+	struct device *dev;
+	void __iomem *tse_pcs_base;
+	void __iomem *sgmii_adapter_base;
+	struct timer_list an_timer;
+	struct timer_list link_timer;
+};
+
+void tse_pcs_init(void __iomem *base, struct tse_pcs *pcs);
+void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
+			   unsigned int speed);
Signature · 1 line
1.7.11.GIT
maintainer
#1 lore raw

From: <[email protected]>
Date: Fri, 3 Jun 2016 02:07:15 -0700

Quoted 6 lines

From: Tien Hock Loh <[email protected]>

This adds support for TSE PCS that uses SGMII adapter when the phy-mode of the dwmac is set to sgmii

Please at least make an effort to use consistent coding style.

You rework this function to do this:

drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c struct socfpga_dwmac { · line 66

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +1 -2
-	if (!splitter_base)
-		return;
+	if (splitter_base) {

And then you add something like this:

drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c struct socfpga_dwmac { · line 88

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +3 -0
+	if ((tse_pcs_base) && (sgmii_adapter_base)) {
+		tse_pcs_fix_mac_speed(&dwmac->pcs, phy_dev, speed);
+	}

Excessive parenthesis in the if() condition, and single statement basic blocks do not get curly braces.