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 The full GNU General Public License is included in this distribution in 147ac6653aSJeff Kirsher the file called "COPYING". 157ac6653aSJeff Kirsher 167ac6653aSJeff Kirsher Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> 177ac6653aSJeff Kirsher *******************************************************************************/ 187ac6653aSJeff Kirsher 19bd4242dfSRayagond Kokatanur #ifndef __STMMAC_H__ 20bd4242dfSRayagond Kokatanur #define __STMMAC_H__ 21bd4242dfSRayagond Kokatanur 22bfab27a1SGiuseppe CAVALLARO #define STMMAC_RESOURCE_NAME "stmmaceth" 2306bce7ddSAlexandre TORGUE #define DRV_MODULE_VERSION "Jan_2016" 24ba1377ffSGiuseppe CAVALLARO 25ba1377ffSGiuseppe CAVALLARO #include <linux/clk.h> 267ac6653aSJeff Kirsher #include <linux/stmmac.h> 27286a8372SGiuseppe CAVALLARO #include <linux/phy.h> 2833d5e332SGiuseppe CAVALLARO #include <linux/pci.h> 297ac6653aSJeff Kirsher #include "common.h" 3092ba6888SRayagond Kokatanur #include <linux/ptp_clock_kernel.h> 31c5e4ddbdSChen-Yu Tsai #include <linux/reset.h> 327ac6653aSJeff Kirsher 33e56788cfSJoachim Eastwood struct stmmac_resources { 34e56788cfSJoachim Eastwood void __iomem *addr; 35e56788cfSJoachim Eastwood const char *mac; 36e56788cfSJoachim Eastwood int wol_irq; 37e56788cfSJoachim Eastwood int lpi_irq; 38e56788cfSJoachim Eastwood int irq; 39e56788cfSJoachim Eastwood }; 40e56788cfSJoachim Eastwood 41362b37beSGiuseppe CAVALLARO struct stmmac_tx_info { 42362b37beSGiuseppe CAVALLARO dma_addr_t buf; 43362b37beSGiuseppe CAVALLARO bool map_as_page; 44553e2ab3SGiuseppe Cavallaro unsigned len; 452a6d8e17SGiuseppe Cavallaro bool last_segment; 4696951366SGiuseppe Cavallaro bool is_jumbo; 47362b37beSGiuseppe CAVALLARO }; 48362b37beSGiuseppe CAVALLARO 497ac6653aSJeff Kirsher struct stmmac_priv { 507ac6653aSJeff Kirsher /* Frequently used values are kept adjacent for cache effect */ 511bb6dea8SGiuseppe CAVALLARO struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp; 521bb6dea8SGiuseppe CAVALLARO struct dma_desc *dma_tx; 537ac6653aSJeff Kirsher struct sk_buff **tx_skbuff; 547ac6653aSJeff Kirsher unsigned int cur_tx; 557ac6653aSJeff Kirsher unsigned int dirty_tx; 561bb6dea8SGiuseppe CAVALLARO u32 tx_count_frames; 571bb6dea8SGiuseppe CAVALLARO u32 tx_coal_frames; 581bb6dea8SGiuseppe CAVALLARO u32 tx_coal_timer; 59*5bacd778SLABBE Corentin struct stmmac_tx_info *tx_skbuff_dma; 60*5bacd778SLABBE Corentin dma_addr_t dma_tx_phy; 617ac6653aSJeff Kirsher int tx_coalesce; 621bb6dea8SGiuseppe CAVALLARO int hwts_tx_en; 631bb6dea8SGiuseppe CAVALLARO bool tx_path_in_lpi_mode; 641bb6dea8SGiuseppe CAVALLARO struct timer_list txtimer; 65f748be53SAlexandre TORGUE bool tso; 667ac6653aSJeff Kirsher 67*5bacd778SLABBE Corentin struct dma_desc *dma_rx ____cacheline_aligned_in_smp; 68*5bacd778SLABBE Corentin struct dma_extended_desc *dma_erx; 69*5bacd778SLABBE Corentin struct sk_buff **rx_skbuff; 70*5bacd778SLABBE Corentin unsigned int cur_rx; 71*5bacd778SLABBE Corentin unsigned int dirty_rx; 727ac6653aSJeff Kirsher unsigned int dma_buf_sz; 7322ad3838SGiuseppe Cavallaro unsigned int rx_copybreak; 74*5bacd778SLABBE Corentin unsigned int rx_zeroc_thresh; 751bb6dea8SGiuseppe CAVALLARO u32 rx_riwt; 761bb6dea8SGiuseppe CAVALLARO int hwts_rx_en; 77*5bacd778SLABBE Corentin dma_addr_t *rx_skbuff_dma; 78*5bacd778SLABBE Corentin dma_addr_t dma_rx_phy; 79*5bacd778SLABBE Corentin 80*5bacd778SLABBE Corentin struct napi_struct napi ____cacheline_aligned_in_smp; 811bb6dea8SGiuseppe CAVALLARO 821bb6dea8SGiuseppe CAVALLARO void __iomem *ioaddr; 831bb6dea8SGiuseppe CAVALLARO struct net_device *dev; 847ac6653aSJeff Kirsher struct device *device; 857ac6653aSJeff Kirsher struct mac_device_info *hw; 861bb6dea8SGiuseppe CAVALLARO spinlock_t lock; 877ac6653aSJeff Kirsher 887ac6653aSJeff Kirsher int oldlink; 897ac6653aSJeff Kirsher int speed; 907ac6653aSJeff Kirsher int oldduplex; 917ac6653aSJeff Kirsher unsigned int flow_ctrl; 927ac6653aSJeff Kirsher unsigned int pause; 937ac6653aSJeff Kirsher struct mii_bus *mii; 947ac6653aSJeff Kirsher int mii_irq[PHY_MAX_ADDR]; 957ac6653aSJeff Kirsher 961bb6dea8SGiuseppe CAVALLARO struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp; 971bb6dea8SGiuseppe CAVALLARO struct plat_stmmacenet_data *plat; 981bb6dea8SGiuseppe CAVALLARO struct dma_features dma_cap; 991bb6dea8SGiuseppe CAVALLARO struct stmmac_counters mmc; 1001bb6dea8SGiuseppe CAVALLARO int hw_cap_support; 1011bb6dea8SGiuseppe CAVALLARO int synopsys_id; 1027ac6653aSJeff Kirsher u32 msg_enable; 1037ac6653aSJeff Kirsher int wolopts; 1043172d3afSDeepak Sikri int wol_irq; 105cd7201f4SGiuseppe CAVALLARO int clk_csr; 106d765955dSGiuseppe CAVALLARO struct timer_list eee_ctrl_timer; 107d765955dSGiuseppe CAVALLARO int lpi_irq; 108d765955dSGiuseppe CAVALLARO int eee_enabled; 109d765955dSGiuseppe CAVALLARO int eee_active; 110d765955dSGiuseppe CAVALLARO int tx_lpi_timer; 1114a7d666aSGiuseppe CAVALLARO unsigned int mode; 112c24602efSGiuseppe CAVALLARO int extend_desc; 11392ba6888SRayagond Kokatanur struct ptp_clock *ptp_clock; 11492ba6888SRayagond Kokatanur struct ptp_clock_info ptp_clock_ops; 1151bb6dea8SGiuseppe CAVALLARO unsigned int default_addend; 1161bb6dea8SGiuseppe CAVALLARO u32 adv_ts; 1171bb6dea8SGiuseppe CAVALLARO int use_riwt; 11889f7f2cfSSrinivas Kandagatla int irq_wake; 11992ba6888SRayagond Kokatanur spinlock_t ptp_lock; 12036ff7c1eSAlexandre TORGUE void __iomem *mmcaddr; 121ba1ffd74SGiuseppe CAVALLARO void __iomem *ptpaddr; 122*5bacd778SLABBE Corentin u32 rx_tail_addr; 123*5bacd778SLABBE Corentin u32 tx_tail_addr; 124f748be53SAlexandre TORGUE u32 mss; 125466c5ac8SMathieu Olivari 126466c5ac8SMathieu Olivari #ifdef CONFIG_DEBUG_FS 127466c5ac8SMathieu Olivari struct dentry *dbgfs_dir; 128466c5ac8SMathieu Olivari struct dentry *dbgfs_rings_status; 129466c5ac8SMathieu Olivari struct dentry *dbgfs_dma_cap; 130466c5ac8SMathieu Olivari #endif 1317ac6653aSJeff Kirsher }; 1327ac6653aSJeff Kirsher 133d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev); 134d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev); 135073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii); 136d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev); 137915af656SAndy Shevchenko 138c30a70d3SGiuseppe CAVALLARO void stmmac_ptp_register(struct stmmac_priv *priv); 139d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv); 140f4e7bd81SJoachim Eastwood int stmmac_resume(struct device *dev); 141f4e7bd81SJoachim Eastwood int stmmac_suspend(struct device *dev); 142f4e7bd81SJoachim Eastwood int stmmac_dvr_remove(struct device *dev); 14315ffac73SJoachim Eastwood int stmmac_dvr_probe(struct device *device, 144cf3f047bSGiuseppe CAVALLARO struct plat_stmmacenet_data *plat_dat, 145e56788cfSJoachim Eastwood struct stmmac_resources *res); 146d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv); 147d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv); 148ba1377ffSGiuseppe CAVALLARO 149bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */ 150