22 #include <linux/module.h>
23 #include <linux/kernel.h>
26 #include <linux/netdevice.h>
30 #include <linux/mii.h>
33 #include <mach/hardware.h>
40 #define EMPTY_PTR_FIFO(xcno) (0 + ((xcno) << 3))
41 #define IND_FIFO_PORT_HI(xcno) (1 + ((xcno) << 3))
43 #define IND_FIFO_PORT_LO(xcno) (2 + ((xcno) << 3))
45 #define REQ_FIFO_PORT_HI(xcno) (3 + ((xcno) << 3))
48 #define REQ_FIFO_PORT_LO(xcno) (4 + ((xcno) << 3))
51 #define CON_FIFO_PORT_HI(xcno) (5 + ((xcno) << 3))
53 #define CON_FIFO_PORT_LO(xcno) (6 + ((xcno) << 3))
55 #define PFIFO_MASK(xcno) (0x7f << (xcno*8))
57 #define FIFO_PTR_FRAMELEN_SHIFT 0
58 #define FIFO_PTR_FRAMELEN_MASK (0x7ff << 0)
59 #define FIFO_PTR_FRAMELEN(len) (((len) << 0) & FIFO_PTR_FRAMELEN_MASK)
60 #define FIFO_PTR_TIMETRIG (1<<11)
61 #define FIFO_PTR_MULTI_REQ
62 #define FIFO_PTR_ORIGIN (1<<14)
63 #define FIFO_PTR_VLAN (1<<15)
64 #define FIFO_PTR_FRAMENO_SHIFT 16
65 #define FIFO_PTR_FRAMENO_MASK (0x3f << 16)
66 #define FIFO_PTR_FRAMENO(no) (((no) << 16) & FIFO_PTR_FRAMENO_MASK)
67 #define FIFO_PTR_SEGMENT_SHIFT 22
68 #define FIFO_PTR_SEGMENT_MASK (0xf << 22)
69 #define FIFO_PTR_SEGMENT(seg) (((seg) & 0xf) << 22)
70 #define FIFO_PTR_ERROR_SHIFT 28
71 #define FIFO_PTR_ERROR_MASK (0xf << 28)
73 #define ISR_LINK_STATUS_CHANGE (1<<4)
74 #define ISR_IND_LO (1<<3)
75 #define ISR_CON_LO (1<<2)
76 #define ISR_IND_HI (1<<1)
77 #define ISR_CON_HI (1<<0)
79 #define ETH_MAC_LOCAL_CONFIG 0x1560
80 #define ETH_MAC_4321 0x1564
81 #define ETH_MAC_65 0x1568
83 #define MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT 16
84 #define MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK (0xf<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT)
85 #define MAC_TRAFFIC_CLASS_ARRANGEMENT(x) (((x)<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT) & MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK)
86 #define LOCAL_CONFIG_LINK_STATUS_IRQ_EN (1<<24)
87 #define LOCAL_CONFIG_CON_LO_IRQ_EN (1<<23)
88 #define LOCAL_CONFIG_CON_HI_IRQ_EN (1<<22)
89 #define LOCAL_CONFIG_IND_LO_IRQ_EN (1<<21)
90 #define LOCAL_CONFIG_IND_HI_IRQ_EN (1<<20)
92 #define CARDNAME "netx-eth"
95 #define INTERNAL_PHY_ADR 0x1c
115 unsigned char *
buf = skb->
data;
116 unsigned int len = skb->
len;
118 spin_lock_irq(&priv->
lock);
130 ndev->
stats.tx_packets++;
133 netif_stop_queue(ndev);
134 spin_unlock_irq(&priv->
lock);
140 static void netx_eth_receive(
struct net_device *ndev)
143 unsigned int val, frameno,
seg, len;
153 skb = netdev_alloc_skb(ndev, len);
157 ndev->
stats.rx_dropped++;
170 ndev->
stats.rx_packets++;
175 netx_eth_interrupt(
int irq,
void *
dev_id)
190 printk(
"%s: unexpected status: 0x%08x\n",
196 netx_eth_receive(ndev);
199 netif_wake_queue(ndev);
206 spin_unlock_irqrestore(&priv->
lock, flags);
210 static int netx_eth_open(
struct net_device *ndev)
236 netif_start_queue(ndev);
241 static int netx_eth_close(
struct net_device *ndev)
245 netif_stop_queue(ndev);
255 static void netx_eth_timeout(
struct net_device *ndev)
262 spin_lock_irq(&priv->
lock);
267 for (i=2; i<=18; i++)
271 spin_unlock_irq(&priv->
lock);
273 netif_wake_queue(ndev);
292 netx_eth_phy_write(
struct net_device *ndev,
int phy_id,
int reg,
int value)
305 .ndo_open = netx_eth_open,
306 .ndo_stop = netx_eth_close,
307 .ndo_start_xmit = netx_eth_hard_start_xmit,
308 .ndo_tx_timeout = netx_eth_timeout,
309 .ndo_set_rx_mode = netx_eth_set_multicast_list,
315 static int netx_eth_enable(
struct net_device *ndev)
318 unsigned int mac4321, mac65;
327 priv->
mii.phy_id_mask = 0x1f;
328 priv->
mii.reg_num_mask = 0x1f;
329 priv->
mii.force_media = 0;
330 priv->
mii.full_duplex = 0;
332 priv->
mii.mdio_read = netx_eth_phy_read;
333 priv->
mii.mdio_write = netx_eth_phy_write;
350 ndev->
dev_addr[1] = (mac4321 >> 8) & 0xff;
351 ndev->
dev_addr[2] = (mac4321 >> 16) & 0xff;
352 ndev->
dev_addr[3] = (mac4321 >> 24) & 0xff;
354 ndev->
dev_addr[5] = (mac65 >> 8) & 0xff;
365 if (!is_valid_ether_addr(ndev->
dev_addr))
366 printk(
"%s: Invalid ethernet MAC address. Please "
367 "set using ifconfig\n", ndev->
name);
369 for (i=2; i<=18; i++)
391 platform_set_drvdata(pdev, ndev);
393 priv = netdev_priv(ndev);
398 dev_err(&pdev->
dev,
"unable to request xc engine\n");
400 goto exit_free_netdev;
403 ndev->
irq = priv->
xc->irq;
413 printk(
"unable to request PFIFO\n");
417 ret = netx_eth_enable(ndev);
419 goto exit_free_pfifo;
427 platform_set_drvdata(pdev,
NULL);
438 platform_set_drvdata(pdev,
NULL);
451 dev_err(&pdev->
dev,
"suspend not implemented\n");
457 dev_err(&pdev->
dev,
"resume not implemented\n");
462 .probe = netx_eth_drv_probe,
463 .remove = netx_eth_drv_remove,
464 .suspend = netx_eth_drv_suspend,
465 .resume = netx_eth_drv_resume,
472 static int __init netx_eth_init(
void)
474 unsigned int phy_control,
val;
476 printk(
"NetX Ethernet driver\n");
501 static void __exit netx_eth_cleanup(
void)