2 * IXP2400 MSF network device driver for the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/config.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <linux/init.h>
18 #include <linux/moduleparam.h>
19 #include <asm/arch/uengine.h>
20 #include <asm/mach-types.h>
24 #include "ixp2400-msf.h"
27 /***********************************************************************
28 * The Radisys ENP2611 is a PCI form factor board with three SFP GBIC
29 * slots, connected via two PMC/Sierra 3386s and an SPI-3 bridge FPGA
33 * SFP GBIC #0 ---+ | +---------+
34 * | PM3386 #0 +-------+ |
35 * SFP GBIC #1 ---+ | | "Caleb" | +---------+
36 * +-------------+ | | | |
37 * | SPI-3 +---------+ IXP2400 |
38 * +-------------+ | bridge | | |
39 * SFP GBIC #2 ---+ | | FPGA | +---------+
40 * | PM3386 #1 +-------+ |
44 * | 1.25Gbaud | 104MHz | 104MHz
45 * | SERDES ea. | SPI-3 ea. | SPI-3
47 ***********************************************************************/
48 static struct ixp2400_msf_parameters enp2611_msf_parameters =
50 .rx_mode = IXP2400_RX_MODE_UTOPIA_POS |
51 IXP2400_RX_MODE_1x32 |
52 IXP2400_RX_MODE_MPHY |
53 IXP2400_RX_MODE_MPHY_32 |
54 IXP2400_RX_MODE_MPHY_POLLED_STATUS |
55 IXP2400_RX_MODE_MPHY_LEVEL3 |
56 IXP2400_RX_MODE_RBUF_SIZE_64,
58 .rxclk01_multiplier = IXP2400_PLL_MULTIPLIER_16,
63 IXP2400_PORT_RX_MODE_MASTER |
64 IXP2400_PORT_RX_MODE_POS_PHY |
65 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
66 IXP2400_PORT_RX_MODE_ODD_PARITY |
67 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
69 IXP2400_PORT_RX_MODE_MASTER |
70 IXP2400_PORT_RX_MODE_POS_PHY |
71 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
72 IXP2400_PORT_RX_MODE_ODD_PARITY |
73 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
75 IXP2400_PORT_RX_MODE_MASTER |
76 IXP2400_PORT_RX_MODE_POS_PHY |
77 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
78 IXP2400_PORT_RX_MODE_ODD_PARITY |
79 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
81 IXP2400_PORT_RX_MODE_MASTER |
82 IXP2400_PORT_RX_MODE_POS_PHY |
83 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
84 IXP2400_PORT_RX_MODE_ODD_PARITY |
85 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE
88 .tx_mode = IXP2400_TX_MODE_UTOPIA_POS |
89 IXP2400_TX_MODE_1x32 |
90 IXP2400_TX_MODE_MPHY |
91 IXP2400_TX_MODE_MPHY_32 |
92 IXP2400_TX_MODE_MPHY_POLLED_STATUS |
93 IXP2400_TX_MODE_MPHY_LEVEL3 |
94 IXP2400_TX_MODE_TBUF_SIZE_64,
96 .txclk01_multiplier = IXP2400_PLL_MULTIPLIER_16,
101 IXP2400_PORT_TX_MODE_MASTER |
102 IXP2400_PORT_TX_MODE_POS_PHY |
103 IXP2400_PORT_TX_MODE_ODD_PARITY |
104 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
106 IXP2400_PORT_TX_MODE_MASTER |
107 IXP2400_PORT_TX_MODE_POS_PHY |
108 IXP2400_PORT_TX_MODE_ODD_PARITY |
109 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
111 IXP2400_PORT_TX_MODE_MASTER |
112 IXP2400_PORT_TX_MODE_POS_PHY |
113 IXP2400_PORT_TX_MODE_ODD_PARITY |
114 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
116 IXP2400_PORT_TX_MODE_MASTER |
117 IXP2400_PORT_TX_MODE_POS_PHY |
118 IXP2400_PORT_TX_MODE_ODD_PARITY |
119 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE
123 struct enp2611_ixpdev_priv
125 struct ixpdev_priv ixpdev_priv;
126 struct net_device_stats stats;
129 static struct net_device *nds[3];
130 static struct timer_list link_check_timer;
132 static struct net_device_stats *enp2611_get_stats(struct net_device *dev)
134 struct enp2611_ixpdev_priv *ip = netdev_priv(dev);
136 pm3386_get_stats(ip->ixpdev_priv.channel, &(ip->stats));
141 /* @@@ Poll the SFP moddef0 line too. */
142 /* @@@ Try to use the pm3386 DOOL interrupt as well. */
143 static void enp2611_check_link_status(unsigned long __dummy)
147 for (i = 0; i < 3; i++) {
148 struct net_device *dev;
153 status = pm3386_is_link_up(i);
154 if (status && !netif_carrier_ok(dev)) {
155 /* @@@ Should report autonegotiation status. */
156 printk(KERN_INFO "%s: NIC Link is Up\n", dev->name);
160 netif_carrier_on(dev);
161 } else if (!status && netif_carrier_ok(dev)) {
162 printk(KERN_INFO "%s: NIC Link is Down\n", dev->name);
164 netif_carrier_off(dev);
166 pm3386_disable_tx(i);
170 link_check_timer.expires = jiffies + HZ / 10;
171 add_timer(&link_check_timer);
174 static void enp2611_set_port_admin_status(int port, int up)
177 caleb_enable_rx(port);
179 pm3386_set_carrier(port, 1);
180 pm3386_enable_rx(port);
182 caleb_disable_tx(port);
183 pm3386_disable_tx(port);
184 /* @@@ Flush out pending packets. */
185 pm3386_set_carrier(port, 0);
187 pm3386_disable_rx(port);
188 caleb_disable_rx(port);
192 static int __init enp2611_init_module(void)
196 if (!machine_is_enp2611())
202 for (i = 0; i < 3; i++) {
203 nds[i] = ixpdev_alloc(i, sizeof(struct enp2611_ixpdev_priv));
204 if (nds[i] == NULL) {
210 SET_MODULE_OWNER(nds[i]);
211 nds[i]->get_stats = enp2611_get_stats;
213 pm3386_get_mac(i, nds[i]->dev_addr);
216 ixp2400_msf_init(&enp2611_msf_parameters);
218 if (ixpdev_init(3, nds, enp2611_set_port_admin_status)) {
219 for (i = 0; i < 3; i++)
224 init_timer(&link_check_timer);
225 link_check_timer.function = enp2611_check_link_status;
226 link_check_timer.expires = jiffies;
227 add_timer(&link_check_timer);
232 static void __exit enp2611_cleanup_module(void)
236 del_timer_sync(&link_check_timer);
239 for (i = 0; i < 3; i++)
243 module_init(enp2611_init_module);
244 module_exit(enp2611_cleanup_module);
245 MODULE_LICENSE("GPL");