15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/types.h>
18 #include <linux/string.h>
19 #include <linux/ptrace.h>
20 #include <linux/errno.h>
25 #include <linux/netdevice.h>
29 #include <linux/mii.h>
30 #include <linux/ethtool.h>
31 #include <linux/bitops.h>
37 #include <asm/uaccess.h>
41 #include <asm/pgtable.h>
49 #if defined(CONFIG_CPM1)
51 #define __fs_out32(addr, x) __raw_writel(x, addr)
52 #define __fs_out16(addr, x) __raw_writew(x, addr)
53 #define __fs_out8(addr, x) __raw_writeb(x, addr)
54 #define __fs_in32(addr) __raw_readl(addr)
55 #define __fs_in16(addr) __raw_readw(addr)
56 #define __fs_in8(addr) __raw_readb(addr)
59 #define __fs_out32(addr, x) out_be32(addr, x)
60 #define __fs_out16(addr, x) out_be16(addr, x)
61 #define __fs_in32(addr) in_be32(addr)
62 #define __fs_in16(addr) in_be16(addr)
63 #define __fs_out8(addr, x) out_8(addr, x)
64 #define __fs_in8(addr) in_8(addr)
68 #define W32(_p, _m, _v) __fs_out32(&(_p)->_m, (_v))
69 #define R32(_p, _m) __fs_in32(&(_p)->_m)
70 #define S32(_p, _m, _v) W32(_p, _m, R32(_p, _m) | (_v))
71 #define C32(_p, _m, _v) W32(_p, _m, R32(_p, _m) & ~(_v))
73 #define W16(_p, _m, _v) __fs_out16(&(_p)->_m, (_v))
74 #define R16(_p, _m) __fs_in16(&(_p)->_m)
75 #define S16(_p, _m, _v) W16(_p, _m, R16(_p, _m) | (_v))
76 #define C16(_p, _m, _v) W16(_p, _m, R16(_p, _m) & ~(_v))
78 #define W8(_p, _m, _v) __fs_out8(&(_p)->_m, (_v))
79 #define R8(_p, _m) __fs_in8(&(_p)->_m)
80 #define S8(_p, _m, _v) W8(_p, _m, R8(_p, _m) | (_v))
81 #define C8(_p, _m, _v) W8(_p, _m, R8(_p, _m) & ~(_v))
83 #define SCC_MAX_MULTICAST_ADDRS 64
88 #define SCC_RESET_DELAY 50
118 #define SCC_NAPI_RX_EVENT_MSK (SCCE_ENET_RXF | SCCE_ENET_RXB)
119 #define SCC_RX_EVENT (SCCE_ENET_RXF)
120 #define SCC_TX_EVENT (SCCE_ENET_TXB)
121 #define SCC_ERR_EVENT_MSK (SCCE_ENET_TXE | SCCE_ENET_BSY)
164 static void cleanup_data(
struct net_device *dev)
169 static void set_promiscuous_mode(
struct net_device *dev)
177 static void set_multicast_start(
struct net_device *dev)
182 W16(ep, sen_gaddr1, 0);
183 W16(ep, sen_gaddr2, 0);
184 W16(ep, sen_gaddr3, 0);
185 W16(ep, sen_gaddr4, 0);
192 u16 taddrh, taddrm, taddrl;
194 taddrh = ((
u16) mac[5] << 8) | mac[4];
195 taddrm = ((
u16) mac[3] << 8) | mac[2];
196 taddrl = ((
u16) mac[1] << 8) | mac[0];
198 W16(ep, sen_taddrh, taddrh);
199 W16(ep, sen_taddrm, taddrm);
200 W16(ep, sen_taddrl, taddrl);
204 static void set_multicast_finish(
struct net_device *dev)
217 W16(ep, sen_gaddr1, 0xffff);
218 W16(ep, sen_gaddr2, 0xffff);
219 W16(ep, sen_gaddr3, 0xffff);
220 W16(ep, sen_gaddr4, 0xffff);
224 static void set_multicast_list(
struct net_device *dev)
229 set_multicast_start(dev);
231 set_multicast_one(dev, ha->
addr);
232 set_multicast_finish(dev);
234 set_promiscuous_mode(dev);
248 u16 paddrh, paddrm, paddrl;
249 const unsigned char *
mac;
255 for (i = 0; i <
sizeof(*ep); i++)
260 W16(ep, sen_genscc.scc_tbase,
265 #ifndef CONFIG_NOT_COHERENT_CACHE
266 W8(ep, sen_genscc.scc_rfcr,
SCC_EB | SCC_GBL);
267 W8(ep, sen_genscc.scc_tfcr,
SCC_EB | SCC_GBL);
269 W8(ep, sen_genscc.scc_rfcr,
SCC_EB);
270 W8(ep, sen_genscc.scc_tfcr,
SCC_EB);
277 W16(ep, sen_genscc.scc_mrblr, 0x5f0);
281 W32(ep, sen_cpres, 0xffffffff);
282 W32(ep, sen_cmask, 0xdebb20e3);
284 W32(ep, sen_crcec, 0);
285 W32(ep, sen_alec, 0);
286 W32(ep, sen_disfc, 0);
288 W16(ep, sen_pads, 0x8888);
289 W16(ep, sen_retlim, 15);
291 W16(ep, sen_maxflr, 0x5ee);
295 W16(ep, sen_maxd1, 0x000005f0);
296 W16(ep, sen_maxd2, 0x000005f0);
300 W16(ep, sen_gaddr1, 0);
301 W16(ep, sen_gaddr2, 0);
302 W16(ep, sen_gaddr3, 0);
303 W16(ep, sen_gaddr4, 0);
304 W16(ep, sen_iaddr1, 0);
305 W16(ep, sen_iaddr2, 0);
306 W16(ep, sen_iaddr3, 0);
307 W16(ep, sen_iaddr4, 0);
312 paddrh = ((
u16) mac[5] << 8) | mac[4];
313 paddrm = ((
u16) mac[3] << 8) | mac[2];
314 paddrl = ((
u16) mac[1] << 8) | mac[0];
316 W16(ep, sen_paddrh, paddrh);
317 W16(ep, sen_paddrm, paddrm);
318 W16(ep, sen_paddrl, paddrl);
320 W16(ep, sen_pper, 0);
321 W16(ep, sen_taddrl, 0);
322 W16(ep, sen_taddrm, 0);
323 W16(ep, sen_taddrh, 0);
329 W16(sccp, scc_scce, 0xffff);
338 W32(sccp, scc_gsmrh, 0);
345 W16(sccp, scc_dsr, 0xd555);
369 dev_warn(fep->
dev,
"SCC timeout on graceful transmit stop\n");
371 W16(sccp, scc_sccm, 0);
377 static void napi_clear_rx_event(
struct net_device *dev)
385 static void napi_enable_rx(
struct net_device *dev)
393 static void napi_disable_rx(
struct net_device *dev)
401 static void rx_bd_done(
struct net_device *dev)
406 static void tx_kickstart(
struct net_device *dev)
416 return (
u32)
R16(sccp, scc_scce);
419 static void clear_int_events(
struct net_device *dev,
u32 int_events)
424 W16(sccp, scc_scce, int_events & 0xffff);
431 dev_warn(fep->
dev,
"SCC ERROR(s) 0x%x\n", int_events);
434 static int get_regs(
struct net_device *dev,
void *
p,
int *sizep)
442 p = (
char *)p +
sizeof(scc_t);
449 static int get_regs_len(
struct net_device *dev)
454 static void tx_restart(
struct net_device *dev)