stmmac: remove specific SoC Koption from platform.
[linux-2.6-microblaze.git] / drivers / net / ethernet / stmicro / stmmac / stmmac.h
1 /*******************************************************************************
2   Copyright (C) 2007-2009  STMicroelectronics Ltd
3
4   This program is free software; you can redistribute it and/or modify it
5   under the terms and conditions of the GNU General Public License,
6   version 2, as published by the Free Software Foundation.
7
8   This program is distributed in the hope it will be useful, but WITHOUT
9   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11   more details.
12
13   You should have received a copy of the GNU General Public License along with
14   this program; if not, write to the Free Software Foundation, Inc.,
15   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16
17   The full GNU General Public License is included in this distribution in
18   the file called "COPYING".
19
20   Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
21 *******************************************************************************/
22
23 #ifndef __STMMAC_H__
24 #define __STMMAC_H__
25
26 #define STMMAC_RESOURCE_NAME   "stmmaceth"
27 #define DRV_MODULE_VERSION      "March_2013"
28
29 #include <linux/clk.h>
30 #include <linux/stmmac.h>
31 #include <linux/phy.h>
32 #include <linux/pci.h>
33 #include "common.h"
34 #include <linux/ptp_clock_kernel.h>
35 #include <linux/reset.h>
36
37 struct stmmac_tx_info {
38         dma_addr_t buf;
39         bool map_as_page;
40 };
41
42 struct stmmac_priv {
43         /* Frequently used values are kept adjacent for cache effect */
44         struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
45         struct dma_desc *dma_tx;
46         struct sk_buff **tx_skbuff;
47         unsigned int cur_tx;
48         unsigned int dirty_tx;
49         unsigned int dma_tx_size;
50         u32 tx_count_frames;
51         u32 tx_coal_frames;
52         u32 tx_coal_timer;
53         struct stmmac_tx_info *tx_skbuff_dma;
54         dma_addr_t dma_tx_phy;
55         int tx_coalesce;
56         int hwts_tx_en;
57         spinlock_t tx_lock;
58         bool tx_path_in_lpi_mode;
59         struct timer_list txtimer;
60
61         struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
62         struct dma_extended_desc *dma_erx;
63         struct sk_buff **rx_skbuff;
64         unsigned int cur_rx;
65         unsigned int dirty_rx;
66         unsigned int dma_rx_size;
67         unsigned int dma_buf_sz;
68         u32 rx_riwt;
69         int hwts_rx_en;
70         dma_addr_t *rx_skbuff_dma;
71         dma_addr_t dma_rx_phy;
72
73         struct napi_struct napi ____cacheline_aligned_in_smp;
74
75         void __iomem *ioaddr;
76         struct net_device *dev;
77         struct device *device;
78         struct mac_device_info *hw;
79         spinlock_t lock;
80
81         struct phy_device *phydev ____cacheline_aligned_in_smp;
82         int oldlink;
83         int speed;
84         int oldduplex;
85         unsigned int flow_ctrl;
86         unsigned int pause;
87         struct mii_bus *mii;
88         int mii_irq[PHY_MAX_ADDR];
89
90         struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
91         struct plat_stmmacenet_data *plat;
92         struct dma_features dma_cap;
93         struct stmmac_counters mmc;
94         int hw_cap_support;
95         int synopsys_id;
96         u32 msg_enable;
97         int wolopts;
98         int wol_irq;
99         struct clk *stmmac_clk;
100         struct reset_control *stmmac_rst;
101         int clk_csr;
102         struct timer_list eee_ctrl_timer;
103         int lpi_irq;
104         int eee_enabled;
105         int eee_active;
106         int tx_lpi_timer;
107         int pcs;
108         unsigned int mode;
109         int extend_desc;
110         struct ptp_clock *ptp_clock;
111         struct ptp_clock_info ptp_clock_ops;
112         unsigned int default_addend;
113         struct clk *clk_ptp_ref;
114         unsigned int clk_ptp_rate;
115         u32 adv_ts;
116         int use_riwt;
117         int irq_wake;
118         spinlock_t ptp_lock;
119 };
120
121 int stmmac_mdio_unregister(struct net_device *ndev);
122 int stmmac_mdio_register(struct net_device *ndev);
123 int stmmac_mdio_reset(struct mii_bus *mii);
124 void stmmac_set_ethtool_ops(struct net_device *netdev);
125 extern const struct stmmac_desc_ops enh_desc_ops;
126 extern const struct stmmac_desc_ops ndesc_ops;
127 extern const struct stmmac_hwtimestamp stmmac_ptp;
128 int stmmac_ptp_register(struct stmmac_priv *priv);
129 void stmmac_ptp_unregister(struct stmmac_priv *priv);
130 int stmmac_resume(struct net_device *ndev);
131 int stmmac_suspend(struct net_device *ndev);
132 int stmmac_dvr_remove(struct net_device *ndev);
133 struct stmmac_priv *stmmac_dvr_probe(struct device *device,
134                                      struct plat_stmmacenet_data *plat_dat,
135                                      void __iomem *addr);
136 void stmmac_disable_eee_mode(struct stmmac_priv *priv);
137 bool stmmac_eee_init(struct stmmac_priv *priv);
138
139 #ifdef CONFIG_STMMAC_PLATFORM
140 extern const struct stmmac_of_data meson6_dwmac_data;
141 extern const struct stmmac_of_data sun7i_gmac_data;
142 extern const struct stmmac_of_data stih4xx_dwmac_data;
143 extern const struct stmmac_of_data stid127_dwmac_data;
144 extern const struct stmmac_of_data socfpga_gmac_data;
145 extern struct platform_driver stmmac_pltfr_driver;
146
147 static inline int stmmac_register_platform(void)
148 {
149         int err;
150
151         err = platform_driver_register(&stmmac_pltfr_driver);
152         if (err)
153                 pr_err("stmmac: failed to register the platform driver\n");
154
155         return err;
156 }
157
158 static inline void stmmac_unregister_platform(void)
159 {
160         platform_driver_unregister(&stmmac_pltfr_driver);
161 }
162 #else
163 static inline int stmmac_register_platform(void)
164 {
165         pr_debug("stmmac: do not register the platf driver\n");
166
167         return 0;
168 }
169
170 static inline void stmmac_unregister_platform(void)
171 {
172 }
173 #endif /* CONFIG_STMMAC_PLATFORM */
174
175 #ifdef CONFIG_STMMAC_PCI
176 extern struct pci_driver stmmac_pci_driver;
177 static inline int stmmac_register_pci(void)
178 {
179         int err;
180
181         err = pci_register_driver(&stmmac_pci_driver);
182         if (err)
183                 pr_err("stmmac: failed to register the PCI driver\n");
184
185         return err;
186 }
187
188 static inline void stmmac_unregister_pci(void)
189 {
190         pci_unregister_driver(&stmmac_pci_driver);
191 }
192 #else
193 static inline int stmmac_register_pci(void)
194 {
195         pr_debug("stmmac: do not register the PCI driver\n");
196
197         return 0;
198 }
199
200 static inline void stmmac_unregister_pci(void)
201 {
202 }
203 #endif /* CONFIG_STMMAC_PCI */
204
205 #endif /* __STMMAC_H__ */