aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale/fec.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/freescale/fec.h')
-rw-r--r--drivers/net/ethernet/freescale/fec.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 8408c627b195..c5a3bc1475c7 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -13,6 +13,12 @@
13#define FEC_H 13#define FEC_H
14/****************************************************************************/ 14/****************************************************************************/
15 15
16#ifdef CONFIG_FEC_PTP
17#include <linux/clocksource.h>
18#include <linux/net_tstamp.h>
19#include <linux/ptp_clock_kernel.h>
20#endif
21
16#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 22#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
17 defined(CONFIG_M520x) || defined(CONFIG_M532x) || \ 23 defined(CONFIG_M520x) || defined(CONFIG_M532x) || \
18 defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28) 24 defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28)
@@ -88,6 +94,13 @@ struct bufdesc {
88 unsigned short cbd_datlen; /* Data length */ 94 unsigned short cbd_datlen; /* Data length */
89 unsigned short cbd_sc; /* Control and status info */ 95 unsigned short cbd_sc; /* Control and status info */
90 unsigned long cbd_bufaddr; /* Buffer address */ 96 unsigned long cbd_bufaddr; /* Buffer address */
97#ifdef CONFIG_FEC_PTP
98 unsigned long cbd_esc;
99 unsigned long cbd_prot;
100 unsigned long cbd_bdu;
101 unsigned long ts;
102 unsigned short res0[4];
103#endif
91}; 104};
92#else 105#else
93struct bufdesc { 106struct bufdesc {
@@ -147,6 +160,112 @@ struct bufdesc {
147#define BD_ENET_TX_CSL ((ushort)0x0001) 160#define BD_ENET_TX_CSL ((ushort)0x0001)
148#define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */ 161#define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
149 162
163/*enhanced buffer desciptor control/status used by Ethernet transmit*/
164#define BD_ENET_TX_INT 0x40000000
165#define BD_ENET_TX_TS 0x20000000
166
167
168/* This device has up to three irqs on some platforms */
169#define FEC_IRQ_NUM 3
170
171/* The number of Tx and Rx buffers. These are allocated from the page
172 * pool. The code may assume these are power of two, so it it best
173 * to keep them that size.
174 * We don't need to allocate pages for the transmitter. We just use
175 * the skbuffer directly.
176 */
177
178#define FEC_ENET_RX_PAGES 8
179#define FEC_ENET_RX_FRSIZE 2048
180#define FEC_ENET_RX_FRPPG (PAGE_SIZE / FEC_ENET_RX_FRSIZE)
181#define RX_RING_SIZE (FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES)
182#define FEC_ENET_TX_FRSIZE 2048
183#define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE)
184#define TX_RING_SIZE 16 /* Must be power of two */
185#define TX_RING_MOD_MASK 15 /* for this to work */
186
187#define BD_ENET_RX_INT 0x00800000
188#define BD_ENET_RX_PTP ((ushort)0x0400)
189
190/* The FEC buffer descriptors track the ring buffers. The rx_bd_base and
191 * tx_bd_base always point to the base of the buffer descriptors. The
192 * cur_rx and cur_tx point to the currently available buffer.
193 * The dirty_tx tracks the current buffer that is being sent by the
194 * controller. The cur_tx and dirty_tx are equal under both completely
195 * empty and completely full conditions. The empty/ready indicator in
196 * the buffer descriptor determines the actual condition.
197 */
198struct fec_enet_private {
199 /* Hardware registers of the FEC device */
200 void __iomem *hwp;
201
202 struct net_device *netdev;
203
204 struct clk *clk_ipg;
205 struct clk *clk_ahb;
206#ifdef CONFIG_FEC_PTP
207 struct clk *clk_ptp;
208#endif
209
210 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
211 unsigned char *tx_bounce[TX_RING_SIZE];
212 struct sk_buff *tx_skbuff[TX_RING_SIZE];
213 struct sk_buff *rx_skbuff[RX_RING_SIZE];
214 ushort skb_cur;
215 ushort skb_dirty;
216
217 /* CPM dual port RAM relative addresses */
218 dma_addr_t bd_dma;
219 /* Address of Rx and Tx buffers */
220 struct bufdesc *rx_bd_base;
221 struct bufdesc *tx_bd_base;
222 /* The next free ring entry */
223 struct bufdesc *cur_rx, *cur_tx;
224 /* The ring entries to be free()ed */
225 struct bufdesc *dirty_tx;
226
227 uint tx_full;
228 /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
229 spinlock_t hw_lock;
230
231 struct platform_device *pdev;
232
233 int opened;
234 int dev_id;
235
236 /* Phylib and MDIO interface */
237 struct mii_bus *mii_bus;
238 struct phy_device *phy_dev;
239 int mii_timeout;
240 uint phy_speed;
241 phy_interface_t phy_interface;
242 int link;
243 int full_duplex;
244 struct completion mdio_done;
245 int irq[FEC_IRQ_NUM];
246
247#ifdef CONFIG_FEC_PTP
248 struct ptp_clock *ptp_clock;
249 struct ptp_clock_info ptp_caps;
250 unsigned long last_overflow_check;
251 spinlock_t tmreg_lock;
252 struct cyclecounter cc;
253 struct timecounter tc;
254 int rx_hwtstamp_filter;
255 u32 base_incval;
256 u32 cycle_speed;
257 int hwts_rx_en;
258 int hwts_tx_en;
259 struct timer_list time_keep;
260#endif
261
262};
263
264#ifdef CONFIG_FEC_PTP
265void fec_ptp_init(struct net_device *ndev, struct platform_device *pdev);
266void fec_ptp_start_cyclecounter(struct net_device *ndev);
267int fec_ptp_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd);
268#endif
150 269
151/****************************************************************************/ 270/****************************************************************************/
152#endif /* FEC_H */ 271#endif /* FEC_H */