17ac6653aSJeff Kirsher /******************************************************************************* 27ac6653aSJeff Kirsher Copyright (C) 2007-2009 STMicroelectronics Ltd 37ac6653aSJeff Kirsher 47ac6653aSJeff Kirsher This program is free software; you can redistribute it and/or modify it 57ac6653aSJeff Kirsher under the terms and conditions of the GNU General Public License, 67ac6653aSJeff Kirsher version 2, as published by the Free Software Foundation. 77ac6653aSJeff Kirsher 87ac6653aSJeff Kirsher This program is distributed in the hope it will be useful, but WITHOUT 97ac6653aSJeff Kirsher ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 107ac6653aSJeff Kirsher FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 117ac6653aSJeff Kirsher more details. 127ac6653aSJeff Kirsher 137ac6653aSJeff Kirsher You should have received a copy of the GNU General Public License along with 147ac6653aSJeff Kirsher this program; if not, write to the Free Software Foundation, Inc., 157ac6653aSJeff Kirsher 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 167ac6653aSJeff Kirsher 177ac6653aSJeff Kirsher The full GNU General Public License is included in this distribution in 187ac6653aSJeff Kirsher the file called "COPYING". 197ac6653aSJeff Kirsher 207ac6653aSJeff Kirsher Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> 217ac6653aSJeff Kirsher *******************************************************************************/ 227ac6653aSJeff Kirsher 23bd4242dfSRayagond Kokatanur #ifndef __STMMAC_H__ 24bd4242dfSRayagond Kokatanur #define __STMMAC_H__ 25bd4242dfSRayagond Kokatanur 26bfab27a1SGiuseppe CAVALLARO #define STMMAC_RESOURCE_NAME "stmmaceth" 2794fbbbf8SGiuseppe CAVALLARO #define DRV_MODULE_VERSION "March_2013" 28ba1377ffSGiuseppe CAVALLARO 29ba1377ffSGiuseppe CAVALLARO #include <linux/clk.h> 307ac6653aSJeff Kirsher #include <linux/stmmac.h> 31286a8372SGiuseppe CAVALLARO #include <linux/phy.h> 3233d5e332SGiuseppe CAVALLARO #include <linux/pci.h> 337ac6653aSJeff Kirsher #include "common.h" 3492ba6888SRayagond Kokatanur #include <linux/ptp_clock_kernel.h> 35c5e4ddbdSChen-Yu Tsai #include <linux/reset.h> 367ac6653aSJeff Kirsher 37362b37beSGiuseppe CAVALLARO struct stmmac_tx_info { 38362b37beSGiuseppe CAVALLARO dma_addr_t buf; 39362b37beSGiuseppe CAVALLARO bool map_as_page; 40362b37beSGiuseppe CAVALLARO }; 41362b37beSGiuseppe CAVALLARO 427ac6653aSJeff Kirsher struct stmmac_priv { 437ac6653aSJeff Kirsher /* Frequently used values are kept adjacent for cache effect */ 441bb6dea8SGiuseppe CAVALLARO struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp; 451bb6dea8SGiuseppe CAVALLARO struct dma_desc *dma_tx; 467ac6653aSJeff Kirsher struct sk_buff **tx_skbuff; 477ac6653aSJeff Kirsher unsigned int cur_tx; 487ac6653aSJeff Kirsher unsigned int dirty_tx; 497ac6653aSJeff Kirsher unsigned int dma_tx_size; 501bb6dea8SGiuseppe CAVALLARO u32 tx_count_frames; 511bb6dea8SGiuseppe CAVALLARO u32 tx_coal_frames; 521bb6dea8SGiuseppe CAVALLARO u32 tx_coal_timer; 53362b37beSGiuseppe CAVALLARO struct stmmac_tx_info *tx_skbuff_dma; 541bb6dea8SGiuseppe CAVALLARO dma_addr_t dma_tx_phy; 557ac6653aSJeff Kirsher int tx_coalesce; 561bb6dea8SGiuseppe CAVALLARO int hwts_tx_en; 571bb6dea8SGiuseppe CAVALLARO spinlock_t tx_lock; 581bb6dea8SGiuseppe CAVALLARO bool tx_path_in_lpi_mode; 591bb6dea8SGiuseppe CAVALLARO struct timer_list txtimer; 607ac6653aSJeff Kirsher 611bb6dea8SGiuseppe CAVALLARO struct dma_desc *dma_rx ____cacheline_aligned_in_smp; 621bb6dea8SGiuseppe CAVALLARO struct dma_extended_desc *dma_erx; 631bb6dea8SGiuseppe CAVALLARO struct sk_buff **rx_skbuff; 647ac6653aSJeff Kirsher unsigned int cur_rx; 657ac6653aSJeff Kirsher unsigned int dirty_rx; 667ac6653aSJeff Kirsher unsigned int dma_rx_size; 677ac6653aSJeff Kirsher unsigned int dma_buf_sz; 681bb6dea8SGiuseppe CAVALLARO u32 rx_riwt; 691bb6dea8SGiuseppe CAVALLARO int hwts_rx_en; 701bb6dea8SGiuseppe CAVALLARO dma_addr_t *rx_skbuff_dma; 711bb6dea8SGiuseppe CAVALLARO dma_addr_t dma_rx_phy; 721bb6dea8SGiuseppe CAVALLARO 731bb6dea8SGiuseppe CAVALLARO struct napi_struct napi ____cacheline_aligned_in_smp; 741bb6dea8SGiuseppe CAVALLARO 751bb6dea8SGiuseppe CAVALLARO void __iomem *ioaddr; 761bb6dea8SGiuseppe CAVALLARO struct net_device *dev; 777ac6653aSJeff Kirsher struct device *device; 787ac6653aSJeff Kirsher struct mac_device_info *hw; 791bb6dea8SGiuseppe CAVALLARO spinlock_t lock; 807ac6653aSJeff Kirsher 811bb6dea8SGiuseppe CAVALLARO struct phy_device *phydev ____cacheline_aligned_in_smp; 827ac6653aSJeff Kirsher int oldlink; 837ac6653aSJeff Kirsher int speed; 847ac6653aSJeff Kirsher int oldduplex; 857ac6653aSJeff Kirsher unsigned int flow_ctrl; 867ac6653aSJeff Kirsher unsigned int pause; 877ac6653aSJeff Kirsher struct mii_bus *mii; 887ac6653aSJeff Kirsher int mii_irq[PHY_MAX_ADDR]; 897ac6653aSJeff Kirsher 901bb6dea8SGiuseppe CAVALLARO struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp; 911bb6dea8SGiuseppe CAVALLARO struct plat_stmmacenet_data *plat; 921bb6dea8SGiuseppe CAVALLARO struct dma_features dma_cap; 931bb6dea8SGiuseppe CAVALLARO struct stmmac_counters mmc; 941bb6dea8SGiuseppe CAVALLARO int hw_cap_support; 951bb6dea8SGiuseppe CAVALLARO int synopsys_id; 967ac6653aSJeff Kirsher u32 msg_enable; 977ac6653aSJeff Kirsher int wolopts; 983172d3afSDeepak Sikri int wol_irq; 99ba1377ffSGiuseppe CAVALLARO struct clk *stmmac_clk; 100c5e4ddbdSChen-Yu Tsai struct reset_control *stmmac_rst; 101cd7201f4SGiuseppe CAVALLARO int clk_csr; 102d765955dSGiuseppe CAVALLARO struct timer_list eee_ctrl_timer; 103d765955dSGiuseppe CAVALLARO int lpi_irq; 104d765955dSGiuseppe CAVALLARO int eee_enabled; 105d765955dSGiuseppe CAVALLARO int eee_active; 106d765955dSGiuseppe CAVALLARO int tx_lpi_timer; 1071bb6dea8SGiuseppe CAVALLARO int pcs; 1084a7d666aSGiuseppe CAVALLARO unsigned int mode; 109c24602efSGiuseppe CAVALLARO int extend_desc; 11092ba6888SRayagond Kokatanur struct ptp_clock *ptp_clock; 11192ba6888SRayagond Kokatanur struct ptp_clock_info ptp_clock_ops; 1121bb6dea8SGiuseppe CAVALLARO unsigned int default_addend; 1135566401fSGiuseppe CAVALLARO struct clk *clk_ptp_ref; 1145566401fSGiuseppe CAVALLARO unsigned int clk_ptp_rate; 1151bb6dea8SGiuseppe CAVALLARO u32 adv_ts; 1161bb6dea8SGiuseppe CAVALLARO int use_riwt; 11789f7f2cfSSrinivas Kandagatla int irq_wake; 11892ba6888SRayagond Kokatanur spinlock_t ptp_lock; 1197ac6653aSJeff Kirsher }; 1207ac6653aSJeff Kirsher 121d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev); 122d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev); 123073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii); 124d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev); 125*915af656SAndy Shevchenko 126d6cc64efSJoe Perches int stmmac_ptp_register(struct stmmac_priv *priv); 127d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv); 128bfab27a1SGiuseppe CAVALLARO int stmmac_resume(struct net_device *ndev); 129bfab27a1SGiuseppe CAVALLARO int stmmac_suspend(struct net_device *ndev); 130bfab27a1SGiuseppe CAVALLARO int stmmac_dvr_remove(struct net_device *ndev); 131bfab27a1SGiuseppe CAVALLARO struct stmmac_priv *stmmac_dvr_probe(struct device *device, 132cf3f047bSGiuseppe CAVALLARO struct plat_stmmacenet_data *plat_dat, 133cf3f047bSGiuseppe CAVALLARO void __iomem *addr); 134d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv); 135d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv); 136ba1377ffSGiuseppe CAVALLARO 13733d5e332SGiuseppe CAVALLARO #ifdef CONFIG_STMMAC_PLATFORM 1380ad5adcdSBeniamino Galvani extern const struct stmmac_of_data meson6_dwmac_data; 139af0bd4e9SChen-Yu Tsai extern const struct stmmac_of_data sun7i_gmac_data; 14071ae8f52SGiuseppe CAVALLARO extern const struct stmmac_of_data stih4xx_dwmac_data; 14171ae8f52SGiuseppe CAVALLARO extern const struct stmmac_of_data stid127_dwmac_data; 142801d233bSDinh Nguyen extern const struct stmmac_of_data socfpga_gmac_data; 14333d5e332SGiuseppe CAVALLARO extern struct platform_driver stmmac_pltfr_driver; 144c0d54066SGiuseppe CAVALLARO 14533d5e332SGiuseppe CAVALLARO static inline int stmmac_register_platform(void) 14633d5e332SGiuseppe CAVALLARO { 14733d5e332SGiuseppe CAVALLARO int err; 14833d5e332SGiuseppe CAVALLARO 14933d5e332SGiuseppe CAVALLARO err = platform_driver_register(&stmmac_pltfr_driver); 15033d5e332SGiuseppe CAVALLARO if (err) 15133d5e332SGiuseppe CAVALLARO pr_err("stmmac: failed to register the platform driver\n"); 15233d5e332SGiuseppe CAVALLARO 15333d5e332SGiuseppe CAVALLARO return err; 15433d5e332SGiuseppe CAVALLARO } 155ceb69499SGiuseppe CAVALLARO 15633d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_platform(void) 15733d5e332SGiuseppe CAVALLARO { 158493682b8SKonstantin Khlebnikov platform_driver_unregister(&stmmac_pltfr_driver); 15933d5e332SGiuseppe CAVALLARO } 16033d5e332SGiuseppe CAVALLARO #else 16133d5e332SGiuseppe CAVALLARO static inline int stmmac_register_platform(void) 16233d5e332SGiuseppe CAVALLARO { 16333d5e332SGiuseppe CAVALLARO pr_debug("stmmac: do not register the platf driver\n"); 16433d5e332SGiuseppe CAVALLARO 165493682b8SKonstantin Khlebnikov return 0; 16633d5e332SGiuseppe CAVALLARO } 167ceb69499SGiuseppe CAVALLARO 16833d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_platform(void) 16933d5e332SGiuseppe CAVALLARO { 17033d5e332SGiuseppe CAVALLARO } 17133d5e332SGiuseppe CAVALLARO #endif /* CONFIG_STMMAC_PLATFORM */ 17233d5e332SGiuseppe CAVALLARO 17333d5e332SGiuseppe CAVALLARO #ifdef CONFIG_STMMAC_PCI 17433d5e332SGiuseppe CAVALLARO extern struct pci_driver stmmac_pci_driver; 17533d5e332SGiuseppe CAVALLARO static inline int stmmac_register_pci(void) 17633d5e332SGiuseppe CAVALLARO { 17733d5e332SGiuseppe CAVALLARO int err; 17833d5e332SGiuseppe CAVALLARO 17933d5e332SGiuseppe CAVALLARO err = pci_register_driver(&stmmac_pci_driver); 18033d5e332SGiuseppe CAVALLARO if (err) 18133d5e332SGiuseppe CAVALLARO pr_err("stmmac: failed to register the PCI driver\n"); 18233d5e332SGiuseppe CAVALLARO 18333d5e332SGiuseppe CAVALLARO return err; 18433d5e332SGiuseppe CAVALLARO } 185ceb69499SGiuseppe CAVALLARO 18633d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_pci(void) 18733d5e332SGiuseppe CAVALLARO { 18833d5e332SGiuseppe CAVALLARO pci_unregister_driver(&stmmac_pci_driver); 18933d5e332SGiuseppe CAVALLARO } 19033d5e332SGiuseppe CAVALLARO #else 19133d5e332SGiuseppe CAVALLARO static inline int stmmac_register_pci(void) 19233d5e332SGiuseppe CAVALLARO { 19333d5e332SGiuseppe CAVALLARO pr_debug("stmmac: do not register the PCI driver\n"); 19433d5e332SGiuseppe CAVALLARO 195493682b8SKonstantin Khlebnikov return 0; 19633d5e332SGiuseppe CAVALLARO } 197ceb69499SGiuseppe CAVALLARO 19833d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_pci(void) 19933d5e332SGiuseppe CAVALLARO { 20033d5e332SGiuseppe CAVALLARO } 20133d5e332SGiuseppe CAVALLARO #endif /* CONFIG_STMMAC_PCI */ 202bd4242dfSRayagond Kokatanur 203bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */ 204