xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/stmmac.h (revision 96951366ce8546662de56f58a3885b94326f9670)
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 
37e56788cfSJoachim Eastwood struct stmmac_resources {
38e56788cfSJoachim Eastwood 	void __iomem *addr;
39e56788cfSJoachim Eastwood 	const char *mac;
40e56788cfSJoachim Eastwood 	int wol_irq;
41e56788cfSJoachim Eastwood 	int lpi_irq;
42e56788cfSJoachim Eastwood 	int irq;
43e56788cfSJoachim Eastwood };
44e56788cfSJoachim Eastwood 
45362b37beSGiuseppe CAVALLARO struct stmmac_tx_info {
46362b37beSGiuseppe CAVALLARO 	dma_addr_t buf;
47362b37beSGiuseppe CAVALLARO 	bool map_as_page;
48553e2ab3SGiuseppe Cavallaro 	unsigned len;
492a6d8e17SGiuseppe Cavallaro 	bool last_segment;
50*96951366SGiuseppe Cavallaro 	bool is_jumbo;
51362b37beSGiuseppe CAVALLARO };
52362b37beSGiuseppe CAVALLARO 
537ac6653aSJeff Kirsher struct stmmac_priv {
547ac6653aSJeff Kirsher 	/* Frequently used values are kept adjacent for cache effect */
551bb6dea8SGiuseppe CAVALLARO 	struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
561bb6dea8SGiuseppe CAVALLARO 	struct dma_desc *dma_tx;
577ac6653aSJeff Kirsher 	struct sk_buff **tx_skbuff;
587ac6653aSJeff Kirsher 	unsigned int cur_tx;
597ac6653aSJeff Kirsher 	unsigned int dirty_tx;
601bb6dea8SGiuseppe CAVALLARO 	u32 tx_count_frames;
611bb6dea8SGiuseppe CAVALLARO 	u32 tx_coal_frames;
621bb6dea8SGiuseppe CAVALLARO 	u32 tx_coal_timer;
63362b37beSGiuseppe CAVALLARO 	struct stmmac_tx_info *tx_skbuff_dma;
641bb6dea8SGiuseppe CAVALLARO 	dma_addr_t dma_tx_phy;
657ac6653aSJeff Kirsher 	int tx_coalesce;
661bb6dea8SGiuseppe CAVALLARO 	int hwts_tx_en;
671bb6dea8SGiuseppe CAVALLARO 	spinlock_t tx_lock;
681bb6dea8SGiuseppe CAVALLARO 	bool tx_path_in_lpi_mode;
691bb6dea8SGiuseppe CAVALLARO 	struct timer_list txtimer;
707ac6653aSJeff Kirsher 
711bb6dea8SGiuseppe CAVALLARO 	struct dma_desc *dma_rx	____cacheline_aligned_in_smp;
721bb6dea8SGiuseppe CAVALLARO 	struct dma_extended_desc *dma_erx;
731bb6dea8SGiuseppe CAVALLARO 	struct sk_buff **rx_skbuff;
747ac6653aSJeff Kirsher 	unsigned int cur_rx;
757ac6653aSJeff Kirsher 	unsigned int dirty_rx;
767ac6653aSJeff Kirsher 	unsigned int dma_buf_sz;
771bb6dea8SGiuseppe CAVALLARO 	u32 rx_riwt;
781bb6dea8SGiuseppe CAVALLARO 	int hwts_rx_en;
791bb6dea8SGiuseppe CAVALLARO 	dma_addr_t *rx_skbuff_dma;
801bb6dea8SGiuseppe CAVALLARO 	dma_addr_t dma_rx_phy;
811bb6dea8SGiuseppe CAVALLARO 
821bb6dea8SGiuseppe CAVALLARO 	struct napi_struct napi ____cacheline_aligned_in_smp;
831bb6dea8SGiuseppe CAVALLARO 
841bb6dea8SGiuseppe CAVALLARO 	void __iomem *ioaddr;
851bb6dea8SGiuseppe CAVALLARO 	struct net_device *dev;
867ac6653aSJeff Kirsher 	struct device *device;
877ac6653aSJeff Kirsher 	struct mac_device_info *hw;
881bb6dea8SGiuseppe CAVALLARO 	spinlock_t lock;
897ac6653aSJeff Kirsher 
901bb6dea8SGiuseppe CAVALLARO 	struct phy_device *phydev ____cacheline_aligned_in_smp;
917ac6653aSJeff Kirsher 	int oldlink;
927ac6653aSJeff Kirsher 	int speed;
937ac6653aSJeff Kirsher 	int oldduplex;
947ac6653aSJeff Kirsher 	unsigned int flow_ctrl;
957ac6653aSJeff Kirsher 	unsigned int pause;
967ac6653aSJeff Kirsher 	struct mii_bus *mii;
977ac6653aSJeff Kirsher 	int mii_irq[PHY_MAX_ADDR];
987ac6653aSJeff Kirsher 
991bb6dea8SGiuseppe CAVALLARO 	struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
1001bb6dea8SGiuseppe CAVALLARO 	struct plat_stmmacenet_data *plat;
1011bb6dea8SGiuseppe CAVALLARO 	struct dma_features dma_cap;
1021bb6dea8SGiuseppe CAVALLARO 	struct stmmac_counters mmc;
1031bb6dea8SGiuseppe CAVALLARO 	int hw_cap_support;
1041bb6dea8SGiuseppe CAVALLARO 	int synopsys_id;
1057ac6653aSJeff Kirsher 	u32 msg_enable;
1067ac6653aSJeff Kirsher 	int wolopts;
1073172d3afSDeepak Sikri 	int wol_irq;
108ba1377ffSGiuseppe CAVALLARO 	struct clk *stmmac_clk;
1095f9755d2SAndrew Bresticker 	struct clk *pclk;
110c5e4ddbdSChen-Yu Tsai 	struct reset_control *stmmac_rst;
111cd7201f4SGiuseppe CAVALLARO 	int clk_csr;
112d765955dSGiuseppe CAVALLARO 	struct timer_list eee_ctrl_timer;
113d765955dSGiuseppe CAVALLARO 	int lpi_irq;
114d765955dSGiuseppe CAVALLARO 	int eee_enabled;
115d765955dSGiuseppe CAVALLARO 	int eee_active;
116d765955dSGiuseppe CAVALLARO 	int tx_lpi_timer;
1171bb6dea8SGiuseppe CAVALLARO 	int pcs;
1184a7d666aSGiuseppe CAVALLARO 	unsigned int mode;
119c24602efSGiuseppe CAVALLARO 	int extend_desc;
12092ba6888SRayagond Kokatanur 	struct ptp_clock *ptp_clock;
12192ba6888SRayagond Kokatanur 	struct ptp_clock_info ptp_clock_ops;
1221bb6dea8SGiuseppe CAVALLARO 	unsigned int default_addend;
1235566401fSGiuseppe CAVALLARO 	struct clk *clk_ptp_ref;
1245566401fSGiuseppe CAVALLARO 	unsigned int clk_ptp_rate;
1251bb6dea8SGiuseppe CAVALLARO 	u32 adv_ts;
1261bb6dea8SGiuseppe CAVALLARO 	int use_riwt;
12789f7f2cfSSrinivas Kandagatla 	int irq_wake;
12892ba6888SRayagond Kokatanur 	spinlock_t ptp_lock;
129466c5ac8SMathieu Olivari 
130466c5ac8SMathieu Olivari #ifdef CONFIG_DEBUG_FS
131466c5ac8SMathieu Olivari 	struct dentry *dbgfs_dir;
132466c5ac8SMathieu Olivari 	struct dentry *dbgfs_rings_status;
133466c5ac8SMathieu Olivari 	struct dentry *dbgfs_dma_cap;
134466c5ac8SMathieu Olivari #endif
1357ac6653aSJeff Kirsher };
1367ac6653aSJeff Kirsher 
137d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev);
138d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev);
139073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii);
140d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev);
141915af656SAndy Shevchenko 
142d6cc64efSJoe Perches int stmmac_ptp_register(struct stmmac_priv *priv);
143d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv);
144bfab27a1SGiuseppe CAVALLARO int stmmac_resume(struct net_device *ndev);
145bfab27a1SGiuseppe CAVALLARO int stmmac_suspend(struct net_device *ndev);
146bfab27a1SGiuseppe CAVALLARO int stmmac_dvr_remove(struct net_device *ndev);
14715ffac73SJoachim Eastwood int stmmac_dvr_probe(struct device *device,
148cf3f047bSGiuseppe CAVALLARO 		     struct plat_stmmacenet_data *plat_dat,
149e56788cfSJoachim Eastwood 		     struct stmmac_resources *res);
150d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv);
151d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv);
152ba1377ffSGiuseppe CAVALLARO 
153bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */
154