net: ethernet: Add TSE PCS support to dwmac-socfpga
Subsystems (6)
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
@@ -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
@@ -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
@@ -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
David Miller
maintainerFrom: <[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.
Signed-off-by Tien Hock Loh <[email protected]>Acked-by Rob Herring <[email protected]>
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
David Miller
maintainerFrom: 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 -0700Quoted 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.
Signed-off-by Tien Hock Loh <[email protected]>Acked-by Rob Herring <[email protected]>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!
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 -0700Quoted 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.
Signed-off-by Tien Hock Loh <[email protected]>Acked-by Rob Herring <[email protected]>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!