net: ethernet: Add TSE PCS support to dwmac-socfpga
Subsystems (6)
PATCH v6 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
--- .../devicetree/bindings/net/socfpga-dwmac.txt | 19 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +- 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 | 141 +++++++++-- 5 files changed, 453 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 +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 +120 -21
194 lines not on this page · raw message
Signature · 6 lines
1.7.11.GIT -- 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: <[email protected]>
Date: Wed, 29 Jun 2016 02:10:13 -0700
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c line 146
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c new file +9
-0+static void auto_nego_timer_callback (unsigned long data) +{ +u16 val =0 ; +u16 speed =0 ; +u16 duplex =0 ; + +struct tse_pcs *pcs = (struct tse_pcs *)data; +void __iomem *tse_pcs_base = pcs->tse_pcs_base; +void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
Please do not break up a set of local variable declarations with an empty line.
Review
Quoted 1 line
(quoted diff) +1
-0+ if ((tse_pcs_base) && (sgmii_adapter_base))
Unnecessary parenthesis.
Review
Quoted 1 line
(quoted diff) +1
-0+ if ((tse_pcs_base) && (sgmii_adapter_base))
Likewise.
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * · line 113
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +6
-2@@ -88,9 +104,13 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *struct device_node *np = dev->of_node;struct regmap *sys_mgr_base_addr;u32 reg_offset, reg_shift; -int ret; -struct device_node *np_splitter; +int ret, index; +struct device_node *np_splitter =NULL ; +struct device_node *np_sgmii_adapter =NULL ; +struct resource res_splitter; +struct resource res_tse_pcs; +struct resource res_sgmii_adapter;
Again, do not break up local variable declarations with an empty line like this.
--
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
Quoted 23 lines · On Wed, Jun 29, 2016 at 02:10:13AM -0700…
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]>---
v2:
- Refactored the TSE PCS out from thedwmac-socfpga.cfile
- Added binding documentation for TSE PCS sgmii adapter
v3:
- Added missing license header for new source files
- Updatedtse_pcs.hinclude 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
Quoted 2 lines
--- .../devicetree/bindings/net/socfpga-dwmac.txt | 19 ++
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +- 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 | 141 +++++++++-- 5 files changed, 453 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
--
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