net: ethernet: Add TSE PCS support to dwmac-socfpga
Subsystems (6)
PATCH v7 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 - v6:
- Fixed a problem where driver build broken if driver is set as module v7:
- Fixed code style (don't break variable declaration with empty lines)
- Removed unnecessary parenthesis
--- .../devicetree/bindings/net/socfpga-dwmac.txt | 19 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +- drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | 274 +++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h | 36 +++ .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 140 +++++++++-- 5 files changed, 450 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 +2 -1
@@ -11,11 +11,12 @@ 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-altr-socfpga.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o stmmac-platform-objs:= stmmac_platform.o +dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c new file +274 -0
274 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 +119 -21
193 lines not on this page · raw message
Signature · 1 line
1.7.11.GIT
From: <[email protected]>
Date: Thu, 7 Jul 2016 20:23:30 -0700
Quoted 7 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.