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 23bfab27a1SGiuseppe CAVALLARO #define STMMAC_RESOURCE_NAME "stmmaceth" 2478a5249fSGiuseppe CAVALLARO #define DRV_MODULE_VERSION "Feb_2012" 25*ba1377ffSGiuseppe CAVALLARO 26*ba1377ffSGiuseppe CAVALLARO #include <linux/clk.h> 277ac6653aSJeff Kirsher #include <linux/stmmac.h> 28286a8372SGiuseppe CAVALLARO #include <linux/phy.h> 297ac6653aSJeff Kirsher #include "common.h" 307ac6653aSJeff Kirsher #ifdef CONFIG_STMMAC_TIMER 317ac6653aSJeff Kirsher #include "stmmac_timer.h" 327ac6653aSJeff Kirsher #endif 337ac6653aSJeff Kirsher 347ac6653aSJeff Kirsher struct stmmac_priv { 357ac6653aSJeff Kirsher /* Frequently used values are kept adjacent for cache effect */ 367ac6653aSJeff Kirsher struct dma_desc *dma_tx ____cacheline_aligned; 377ac6653aSJeff Kirsher dma_addr_t dma_tx_phy; 387ac6653aSJeff Kirsher struct sk_buff **tx_skbuff; 397ac6653aSJeff Kirsher unsigned int cur_tx; 407ac6653aSJeff Kirsher unsigned int dirty_tx; 417ac6653aSJeff Kirsher unsigned int dma_tx_size; 427ac6653aSJeff Kirsher int tx_coalesce; 437ac6653aSJeff Kirsher 447ac6653aSJeff Kirsher struct dma_desc *dma_rx ; 457ac6653aSJeff Kirsher unsigned int cur_rx; 467ac6653aSJeff Kirsher unsigned int dirty_rx; 477ac6653aSJeff Kirsher struct sk_buff **rx_skbuff; 487ac6653aSJeff Kirsher dma_addr_t *rx_skbuff_dma; 497ac6653aSJeff Kirsher struct sk_buff_head rx_recycle; 507ac6653aSJeff Kirsher 517ac6653aSJeff Kirsher struct net_device *dev; 527ac6653aSJeff Kirsher dma_addr_t dma_rx_phy; 537ac6653aSJeff Kirsher unsigned int dma_rx_size; 547ac6653aSJeff Kirsher unsigned int dma_buf_sz; 557ac6653aSJeff Kirsher struct device *device; 567ac6653aSJeff Kirsher struct mac_device_info *hw; 577ac6653aSJeff Kirsher void __iomem *ioaddr; 587ac6653aSJeff Kirsher 597ac6653aSJeff Kirsher struct stmmac_extra_stats xstats; 607ac6653aSJeff Kirsher struct napi_struct napi; 617ac6653aSJeff Kirsher int no_csum_insertion; 627ac6653aSJeff Kirsher 637ac6653aSJeff Kirsher struct phy_device *phydev; 647ac6653aSJeff Kirsher int oldlink; 657ac6653aSJeff Kirsher int speed; 667ac6653aSJeff Kirsher int oldduplex; 677ac6653aSJeff Kirsher unsigned int flow_ctrl; 687ac6653aSJeff Kirsher unsigned int pause; 697ac6653aSJeff Kirsher struct mii_bus *mii; 707ac6653aSJeff Kirsher int mii_irq[PHY_MAX_ADDR]; 717ac6653aSJeff Kirsher 727ac6653aSJeff Kirsher u32 msg_enable; 737ac6653aSJeff Kirsher spinlock_t lock; 74a9097a96SGiuseppe CAVALLARO spinlock_t tx_lock; 757ac6653aSJeff Kirsher int wolopts; 763172d3afSDeepak Sikri int wol_irq; 777ac6653aSJeff Kirsher #ifdef CONFIG_STMMAC_TIMER 787ac6653aSJeff Kirsher struct stmmac_timer *tm; 797ac6653aSJeff Kirsher #endif 807ac6653aSJeff Kirsher struct plat_stmmacenet_data *plat; 811c901a46SGiuseppe CAVALLARO struct stmmac_counters mmc; 82e7434821SGiuseppe CAVALLARO struct dma_features dma_cap; 8319e30c14SGiuseppe CAVALLARO int hw_cap_support; 84*ba1377ffSGiuseppe CAVALLARO #ifdef CONFIG_HAVE_CLK 85*ba1377ffSGiuseppe CAVALLARO struct clk *stmmac_clk; 86*ba1377ffSGiuseppe CAVALLARO #endif 877ac6653aSJeff Kirsher }; 887ac6653aSJeff Kirsher 89bfab27a1SGiuseppe CAVALLARO extern int phyaddr; 90bfab27a1SGiuseppe CAVALLARO 917ac6653aSJeff Kirsher extern int stmmac_mdio_unregister(struct net_device *ndev); 927ac6653aSJeff Kirsher extern int stmmac_mdio_register(struct net_device *ndev); 937ac6653aSJeff Kirsher extern void stmmac_set_ethtool_ops(struct net_device *netdev); 947ac6653aSJeff Kirsher extern const struct stmmac_desc_ops enh_desc_ops; 957ac6653aSJeff Kirsher extern const struct stmmac_desc_ops ndesc_ops; 96bfab27a1SGiuseppe CAVALLARO 97bfab27a1SGiuseppe CAVALLARO int stmmac_freeze(struct net_device *ndev); 98bfab27a1SGiuseppe CAVALLARO int stmmac_restore(struct net_device *ndev); 99bfab27a1SGiuseppe CAVALLARO int stmmac_resume(struct net_device *ndev); 100bfab27a1SGiuseppe CAVALLARO int stmmac_suspend(struct net_device *ndev); 101bfab27a1SGiuseppe CAVALLARO int stmmac_dvr_remove(struct net_device *ndev); 102bfab27a1SGiuseppe CAVALLARO struct stmmac_priv *stmmac_dvr_probe(struct device *device, 103cf3f047bSGiuseppe CAVALLARO struct plat_stmmacenet_data *plat_dat, 104cf3f047bSGiuseppe CAVALLARO void __iomem *addr); 105*ba1377ffSGiuseppe CAVALLARO 106*ba1377ffSGiuseppe CAVALLARO #ifdef CONFIG_HAVE_CLK 107*ba1377ffSGiuseppe CAVALLARO static inline int stmmac_clk_enable(struct stmmac_priv *priv) 108*ba1377ffSGiuseppe CAVALLARO { 109*ba1377ffSGiuseppe CAVALLARO if (priv->stmmac_clk) 110*ba1377ffSGiuseppe CAVALLARO return clk_enable(priv->stmmac_clk); 111*ba1377ffSGiuseppe CAVALLARO 112*ba1377ffSGiuseppe CAVALLARO return 0; 113*ba1377ffSGiuseppe CAVALLARO } 114*ba1377ffSGiuseppe CAVALLARO 115*ba1377ffSGiuseppe CAVALLARO static inline void stmmac_clk_disable(struct stmmac_priv *priv) 116*ba1377ffSGiuseppe CAVALLARO { 117*ba1377ffSGiuseppe CAVALLARO if (priv->stmmac_clk) 118*ba1377ffSGiuseppe CAVALLARO clk_disable(priv->stmmac_clk); 119*ba1377ffSGiuseppe CAVALLARO } 120*ba1377ffSGiuseppe CAVALLARO static inline int stmmac_clk_get(struct stmmac_priv *priv) 121*ba1377ffSGiuseppe CAVALLARO { 122*ba1377ffSGiuseppe CAVALLARO priv->stmmac_clk = clk_get(priv->device, NULL); 123*ba1377ffSGiuseppe CAVALLARO 124*ba1377ffSGiuseppe CAVALLARO if (IS_ERR(priv->stmmac_clk)) { 125*ba1377ffSGiuseppe CAVALLARO pr_err("%s: ERROR clk_get failed\n", __func__); 126*ba1377ffSGiuseppe CAVALLARO return PTR_ERR(priv->stmmac_clk); 127*ba1377ffSGiuseppe CAVALLARO } 128*ba1377ffSGiuseppe CAVALLARO return 0; 129*ba1377ffSGiuseppe CAVALLARO } 130*ba1377ffSGiuseppe CAVALLARO #else 131*ba1377ffSGiuseppe CAVALLARO static inline int stmmac_clk_enable(struct stmmac_priv *priv) 132*ba1377ffSGiuseppe CAVALLARO { 133*ba1377ffSGiuseppe CAVALLARO return 0; 134*ba1377ffSGiuseppe CAVALLARO } 135*ba1377ffSGiuseppe CAVALLARO static inline void stmmac_clk_disable(struct stmmac_priv *priv) 136*ba1377ffSGiuseppe CAVALLARO { 137*ba1377ffSGiuseppe CAVALLARO } 138*ba1377ffSGiuseppe CAVALLARO static inline int stmmac_clk_get(struct stmmac_priv *priv) 139*ba1377ffSGiuseppe CAVALLARO { 140*ba1377ffSGiuseppe CAVALLARO return 0; 141*ba1377ffSGiuseppe CAVALLARO } 142*ba1377ffSGiuseppe CAVALLARO #endif /* CONFIG_HAVE_CLK */ 143