Skip to contentSkip to conversation

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

PATCH Superseded [email protected] 2 participants 4 messages Jun 24, 2016 – Jun 28, 2016

Subsystems (6)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 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 v3:
- Added missing license header for new source files
- Updated tse_pcs.h include headers
- Standardize if statements
v4:
- Reset SGMII adapter on speed change
- Do not enable SGMII adapter if speed is not supported
- On init, if PCS reset fails, do not enable adapter v5:
- Fixed devicetree binding property name using _ instead of -

---
 .../devicetree/bindings/net/socfpga-dwmac.txt      |  19 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |   2 +-
 drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | 276 +++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h |  36 +++
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 149 +++++++++--
 5 files changed, 460 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h
Documentation/devicetree/bindings/net/socfpga-dwmac.txt +19 -0
index 72d82d6..2e68a3c 100644
@@ -17,9 +17,26 @@ 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
+
+This device node has additional phandle dependency, the sgmii converter:
+
+Required properties:
+ - compatible	: Should be altr,gmii-to-sgmii-2.0
+ - reg-names	: Should be "eth_tse_control_port"
 
 Example:
 
+gmii_to_sgmii_converter: phy@0x100000240 {
+	compatible = "altr,gmii-to-sgmii-2.0";
+	reg = <0x00000001 0x00000240 0x00000008>,
+		<0x00000001 0x00000200 0x00000040>;
+	reg-names = "eth_tse_control_port";
+	clocks = <&sgmii_1_clk_0 &emac1 1 &sgmii_clk_125 &sgmii_clk_125>;
+	clock-names = "tse_pcs_ref_clk_clock_connection", "tse_rx_cdr_refclk";
+};
+
 gmac0: ethernet@ff700000 {
 	compatible = "altr,socfpga-stmmac", "snps,dwmac-3.70a", "snps,dwmac";
 	altr,sysmgr-syscon = <&sysmgr 0x60 0>;
@@ -30,4 +47,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 = <&gmii_to_sgmii_converter>;
 };
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index 0fb362d..0ff76e8 100644
@@ -11,7 +11,7 @@ obj-$(CONFIG_DWMAC_IPQ806X)	+= dwmac-ipq806x.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
-obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o
+obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o altr_tse_pcs.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
 obj-$(CONFIG_DWMAC_SUNXI)	+= dwmac-sunxi.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c new file +276 -0

276 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h new file +36 -0
new file mode 100644
index 0000000..2f58824
@@ -0,0 +1,36 @@
+/* Copyright Altera Corporation (C) 2016. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Tien Hock Loh <[email protected]>
+ */
+
+#ifndef __TSE_PCS_H__
+#define __TSE_PCS_H__
+
+#include <linux/phy.h>
+#include <linux/timer.h>
+
+struct tse_pcs {
+	struct device *dev;
+	void __iomem *tse_pcs_base;
+	void __iomem *sgmii_adapter_base;
+	struct timer_list aneg_link_timer;
+	int autoneg;
+};
+
+int 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);
+
+#endif /* __TSE_PCS_H__ */
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +128 -21

196 lines not on this page · raw message

Signature · 1 line
1.7.11.GIT
maintainer
#1 lore raw

From: <[email protected]>
Date: Fri, 24 Jun 2016 02:13:23 -0700

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

Applied to net-next, thanks.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Tue, 28 Jun 2016 05:34:50 -0400 (EDT)

Quoted 5 lines

From: <[email protected]>
Date: Fri, 24 Jun 2016 02:13:23 -0700

Quoted 2 lines

From: Tien Hock Loh <[email protected]>

Quoted 8 lines
Quoted 6 lines

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

Applied to net-next, thanks.

I had to revert, this breaks the build:

ERROR: "tse_pcs_fix_mac_speed" [drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.ko] undefined!
ERROR: "tse_pcs_init" [drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.ko] undefined!

#3 lore raw

My fault, I wasn't testing against building as module, was always building as part of the kernel. I'll get it fixed and put another patch for review.

Thanks
Tien Hock

Quoted 21 lines · David Miller

From: David Miller <[email protected]>
Date: Tue, 28 Jun 2016 05:34:50 -0400 (EDT)

Quoted 5 lines

From: <[email protected]>
Date: Fri, 24 Jun 2016 02:13:23 -0700

Quoted 2 lines

From: Tien Hock Loh <[email protected]>

Quoted 8 lines
Quoted 6 lines

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

Applied to net-next, thanks.

I had to revert, this breaks the build:

ERROR: "tse_pcs_fix_mac_speed" [drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.ko] undefined!
ERROR: "tse_pcs_init" [drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.ko] undefined!