blob: d1217db70db49cba45e3815e779c6ab94cda7698 [file] [log] [blame]
Bryan Wue190d6b2007-07-17 14:43:44 +08001/*
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08002 * Blackfin On-Chip MAC Driver
Bryan Wue190d6b2007-07-17 14:43:44 +08003 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08004 * Copyright 2004-2007 Analog Devices Inc.
Bryan Wue190d6b2007-07-17 14:43:44 +08005 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08006 * Enter bugs at http://blackfin.uclinux.org/
Bryan Wue190d6b2007-07-17 14:43:44 +08007 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08008 * Licensed under the GPL-2 or later.
Bryan Wue190d6b2007-07-17 14:43:44 +08009 */
Barry Songfe92afe2010-05-17 17:19:40 -070010#ifndef _BFIN_MAC_H_
11#define _BFIN_MAC_H_
12
13#include <linux/net_tstamp.h>
Richard Cochrandd87b222012-10-31 06:27:24 +000014#include <linux/ptp_clock_kernel.h>
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080015#include <linux/timer.h>
Sonic Zhang02460d02010-06-11 10:44:22 +000016#include <linux/etherdevice.h>
17#include <linux/bfin_mac.h>
Bryan Wue190d6b2007-07-17 14:43:44 +080018
Sonic Zhang2d70a3d2011-01-10 02:54:33 +000019/*
20 * Disable hardware checksum for bug #5600 if writeback cache is
21 * enabled. Otherwize, corrupted RX packet will be sent up stack
22 * without error mark.
23 */
24#ifndef CONFIG_BFIN_EXTMEM_WRITEBACK
Bryan Wue190d6b2007-07-17 14:43:44 +080025#define BFIN_MAC_CSUM_OFFLOAD
Sonic Zhang2d70a3d2011-01-10 02:54:33 +000026#endif
Bryan Wue190d6b2007-07-17 14:43:44 +080027
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080028#define TX_RECLAIM_JIFFIES (HZ / 5)
Sonic Zhang159945a2014-07-24 17:52:59 +080029#define BFIN_MAC_RX_IRQ_DISABLED 1
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080030
Bryan Wue190d6b2007-07-17 14:43:44 +080031struct dma_descriptor {
32 struct dma_descriptor *next_dma_desc;
33 unsigned long start_addr;
34 unsigned short config;
35 unsigned short x_count;
36};
37
38struct status_area_rx {
39#if defined(BFIN_MAC_CSUM_OFFLOAD)
40 unsigned short ip_hdr_csum; /* ip header checksum */
41 /* ip payload(udp or tcp or others) checksum */
42 unsigned short ip_payload_csum;
43#endif
44 unsigned long status_word; /* the frame status word */
45};
46
47struct status_area_tx {
48 unsigned long status_word; /* the frame status word */
49};
50
51/* use two descriptors for a packet */
52struct net_dma_desc_rx {
53 struct net_dma_desc_rx *next;
54 struct sk_buff *skb;
55 struct dma_descriptor desc_a;
56 struct dma_descriptor desc_b;
57 struct status_area_rx status;
58};
59
60/* use two descriptors for a packet */
61struct net_dma_desc_tx {
62 struct net_dma_desc_tx *next;
63 struct sk_buff *skb;
64 struct dma_descriptor desc_a;
65 struct dma_descriptor desc_b;
66 unsigned char packet[1560];
67 struct status_area_tx status;
68};
69
Bryan Wu7ef0a7e2008-04-25 11:53:10 +080070struct bfin_mac_local {
Bryan Wue190d6b2007-07-17 14:43:44 +080071 /*
72 * these are things that the kernel wants me to keep, so users
73 * can find out semi-useless statistics of how well the card is
74 * performing
75 */
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080076 struct net_device_stats stats;
Bryan Wue190d6b2007-07-17 14:43:44 +080077
Bryan Wue190d6b2007-07-17 14:43:44 +080078 spinlock_t lock;
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080079
Michael Hennerich53fd3f22010-05-10 05:39:11 +000080 int wol; /* Wake On Lan */
81 int irq_wake_requested;
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080082 struct timer_list tx_reclaim_timer;
83 struct net_device *ndev;
Sonic Zhang159945a2014-07-24 17:52:59 +080084 struct napi_struct napi;
85 unsigned long flags;
Michael Hennerich53fd3f22010-05-10 05:39:11 +000086
Mike Frysingerc599bd62011-01-10 02:54:32 +000087 /* Data for EMAC_VLAN1 regs */
88 u16 vlan1_mask, vlan2_mask;
89
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080090 /* MII and PHY stuffs */
91 int old_link; /* used by bf537_adjust_link */
92 int old_speed;
93 int old_duplex;
94
95 struct phy_device *phydev;
Lennert Buytenhek298cf9b2008-10-08 16:29:57 -070096 struct mii_bus *mii_bus;
Barry Songfe92afe2010-05-17 17:19:40 -070097
98#if defined(CONFIG_BFIN_MAC_USE_HWSTAMP)
Richard Cochranbc3c5f62012-10-31 06:27:23 +000099 u32 addend;
100 unsigned int shift;
Richard Cochrandd87b222012-10-31 06:27:24 +0000101 s32 max_ppb;
Barry Songfe92afe2010-05-17 17:19:40 -0700102 struct hwtstamp_config stamp_cfg;
Richard Cochrandd87b222012-10-31 06:27:24 +0000103 struct ptp_clock_info caps;
104 struct ptp_clock *clock;
105 int phc_index;
106 spinlock_t phc_lock; /* protects time lo/hi registers */
Barry Songfe92afe2010-05-17 17:19:40 -0700107#endif
Bryan Wue190d6b2007-07-17 14:43:44 +0800108};
109
Joe Perches33980322013-09-23 15:11:30 -0700110int bfin_get_ether_addr(char *addr);
Barry Songfe92afe2010-05-17 17:19:40 -0700111
112#endif