xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/stmmac.h (revision 493682b8b8a9bf130a544d983c63f1b35df688b9)
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"
27cfd1979eSGiuseppe CAVALLARO #define DRV_MODULE_VERSION	"Nov_2012"
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"
347ac6653aSJeff Kirsher 
357ac6653aSJeff Kirsher struct stmmac_priv {
367ac6653aSJeff Kirsher 	/* Frequently used values are kept adjacent for cache effect */
377ac6653aSJeff Kirsher 	struct dma_desc *dma_tx ____cacheline_aligned;
387ac6653aSJeff Kirsher 	dma_addr_t dma_tx_phy;
397ac6653aSJeff Kirsher 	struct sk_buff **tx_skbuff;
407ac6653aSJeff Kirsher 	unsigned int cur_tx;
417ac6653aSJeff Kirsher 	unsigned int dirty_tx;
427ac6653aSJeff Kirsher 	unsigned int dma_tx_size;
437ac6653aSJeff Kirsher 	int tx_coalesce;
447ac6653aSJeff Kirsher 
457ac6653aSJeff Kirsher 	struct dma_desc *dma_rx ;
467ac6653aSJeff Kirsher 	unsigned int cur_rx;
477ac6653aSJeff Kirsher 	unsigned int dirty_rx;
487ac6653aSJeff Kirsher 	struct sk_buff **rx_skbuff;
497ac6653aSJeff Kirsher 	dma_addr_t *rx_skbuff_dma;
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 	struct plat_stmmacenet_data *plat;
781c901a46SGiuseppe CAVALLARO 	struct stmmac_counters mmc;
79e7434821SGiuseppe CAVALLARO 	struct dma_features dma_cap;
8019e30c14SGiuseppe CAVALLARO 	int hw_cap_support;
81ba1377ffSGiuseppe CAVALLARO 	struct clk *stmmac_clk;
82cd7201f4SGiuseppe CAVALLARO 	int clk_csr;
83cffb13f4SGiuseppe CAVALLARO 	int synopsys_id;
84d765955dSGiuseppe CAVALLARO 	struct timer_list eee_ctrl_timer;
85d765955dSGiuseppe CAVALLARO 	bool tx_path_in_lpi_mode;
86d765955dSGiuseppe CAVALLARO 	int lpi_irq;
87d765955dSGiuseppe CAVALLARO 	int eee_enabled;
88d765955dSGiuseppe CAVALLARO 	int eee_active;
89d765955dSGiuseppe CAVALLARO 	int tx_lpi_timer;
909125cdd1SGiuseppe CAVALLARO 	struct timer_list txtimer;
919125cdd1SGiuseppe CAVALLARO 	u32 tx_count_frames;
929125cdd1SGiuseppe CAVALLARO 	u32 tx_coal_frames;
939125cdd1SGiuseppe CAVALLARO 	u32 tx_coal_timer;
9462a2ab93SGiuseppe CAVALLARO 	int use_riwt;
9562a2ab93SGiuseppe CAVALLARO 	u32 rx_riwt;
967ac6653aSJeff Kirsher };
977ac6653aSJeff Kirsher 
98bfab27a1SGiuseppe CAVALLARO extern int phyaddr;
99bfab27a1SGiuseppe CAVALLARO 
1007ac6653aSJeff Kirsher extern int stmmac_mdio_unregister(struct net_device *ndev);
1017ac6653aSJeff Kirsher extern int stmmac_mdio_register(struct net_device *ndev);
1027ac6653aSJeff Kirsher extern void stmmac_set_ethtool_ops(struct net_device *netdev);
1037ac6653aSJeff Kirsher extern const struct stmmac_desc_ops enh_desc_ops;
1047ac6653aSJeff Kirsher extern const struct stmmac_desc_ops ndesc_ops;
105bfab27a1SGiuseppe CAVALLARO int stmmac_freeze(struct net_device *ndev);
106bfab27a1SGiuseppe CAVALLARO int stmmac_restore(struct net_device *ndev);
107bfab27a1SGiuseppe CAVALLARO int stmmac_resume(struct net_device *ndev);
108bfab27a1SGiuseppe CAVALLARO int stmmac_suspend(struct net_device *ndev);
109bfab27a1SGiuseppe CAVALLARO int stmmac_dvr_remove(struct net_device *ndev);
110bfab27a1SGiuseppe CAVALLARO struct stmmac_priv *stmmac_dvr_probe(struct device *device,
111cf3f047bSGiuseppe CAVALLARO 				     struct plat_stmmacenet_data *plat_dat,
112cf3f047bSGiuseppe CAVALLARO 				     void __iomem *addr);
113d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv);
114d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv);
115ba1377ffSGiuseppe CAVALLARO 
11633d5e332SGiuseppe CAVALLARO #ifdef CONFIG_STMMAC_PLATFORM
11733d5e332SGiuseppe CAVALLARO extern struct platform_driver stmmac_pltfr_driver;
11833d5e332SGiuseppe CAVALLARO static inline int stmmac_register_platform(void)
11933d5e332SGiuseppe CAVALLARO {
12033d5e332SGiuseppe CAVALLARO 	int err;
12133d5e332SGiuseppe CAVALLARO 
12233d5e332SGiuseppe CAVALLARO 	err = platform_driver_register(&stmmac_pltfr_driver);
12333d5e332SGiuseppe CAVALLARO 	if (err)
12433d5e332SGiuseppe CAVALLARO 		pr_err("stmmac: failed to register the platform driver\n");
12533d5e332SGiuseppe CAVALLARO 
12633d5e332SGiuseppe CAVALLARO 	return err;
12733d5e332SGiuseppe CAVALLARO }
12833d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_platform(void)
12933d5e332SGiuseppe CAVALLARO {
130*493682b8SKonstantin Khlebnikov 	platform_driver_unregister(&stmmac_pltfr_driver);
13133d5e332SGiuseppe CAVALLARO }
13233d5e332SGiuseppe CAVALLARO #else
13333d5e332SGiuseppe CAVALLARO static inline int stmmac_register_platform(void)
13433d5e332SGiuseppe CAVALLARO {
13533d5e332SGiuseppe CAVALLARO 	pr_debug("stmmac: do not register the platf driver\n");
13633d5e332SGiuseppe CAVALLARO 
137*493682b8SKonstantin Khlebnikov 	return 0;
13833d5e332SGiuseppe CAVALLARO }
13933d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_platform(void)
14033d5e332SGiuseppe CAVALLARO {
14133d5e332SGiuseppe CAVALLARO }
14233d5e332SGiuseppe CAVALLARO #endif /* CONFIG_STMMAC_PLATFORM */
14333d5e332SGiuseppe CAVALLARO 
14433d5e332SGiuseppe CAVALLARO #ifdef CONFIG_STMMAC_PCI
14533d5e332SGiuseppe CAVALLARO extern struct pci_driver stmmac_pci_driver;
14633d5e332SGiuseppe CAVALLARO static inline int stmmac_register_pci(void)
14733d5e332SGiuseppe CAVALLARO {
14833d5e332SGiuseppe CAVALLARO 	int err;
14933d5e332SGiuseppe CAVALLARO 
15033d5e332SGiuseppe CAVALLARO 	err = pci_register_driver(&stmmac_pci_driver);
15133d5e332SGiuseppe CAVALLARO 	if (err)
15233d5e332SGiuseppe CAVALLARO 		pr_err("stmmac: failed to register the PCI driver\n");
15333d5e332SGiuseppe CAVALLARO 
15433d5e332SGiuseppe CAVALLARO 	return err;
15533d5e332SGiuseppe CAVALLARO }
15633d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_pci(void)
15733d5e332SGiuseppe CAVALLARO {
15833d5e332SGiuseppe CAVALLARO 	pci_unregister_driver(&stmmac_pci_driver);
15933d5e332SGiuseppe CAVALLARO }
16033d5e332SGiuseppe CAVALLARO #else
16133d5e332SGiuseppe CAVALLARO static inline int stmmac_register_pci(void)
16233d5e332SGiuseppe CAVALLARO {
16333d5e332SGiuseppe CAVALLARO 	pr_debug("stmmac: do not register the PCI driver\n");
16433d5e332SGiuseppe CAVALLARO 
165*493682b8SKonstantin Khlebnikov 	return 0;
16633d5e332SGiuseppe CAVALLARO }
16733d5e332SGiuseppe CAVALLARO static inline void stmmac_unregister_pci(void)
16833d5e332SGiuseppe CAVALLARO {
16933d5e332SGiuseppe CAVALLARO }
17033d5e332SGiuseppe CAVALLARO #endif /* CONFIG_STMMAC_PCI */
171bd4242dfSRayagond Kokatanur 
172bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */
173