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/hardware/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
;
155 status
= pm3386_is_link_up(i
);
156 if (status
&& !netif_carrier_ok(dev
)) {
157 /* @@@ Should report autonegotiation status. */
158 printk(KERN_INFO
"%s: NIC Link is Up\n", dev
->name
);
162 netif_carrier_on(dev
);
163 } else if (!status
&& netif_carrier_ok(dev
)) {
164 printk(KERN_INFO
"%s: NIC Link is Down\n", dev
->name
);
166 netif_carrier_off(dev
);
168 pm3386_disable_tx(i
);
172 link_check_timer
.expires
= jiffies
+ HZ
/ 10;
173 add_timer(&link_check_timer
);
176 static void enp2611_set_port_admin_status(int port
, int up
)
179 caleb_enable_rx(port
);
181 pm3386_set_carrier(port
, 1);
182 pm3386_enable_rx(port
);
184 caleb_disable_tx(port
);
185 pm3386_disable_tx(port
);
186 /* @@@ Flush out pending packets. */
187 pm3386_set_carrier(port
, 0);
189 pm3386_disable_rx(port
);
190 caleb_disable_rx(port
);
194 static int __init
enp2611_init_module(void)
199 if (!machine_is_enp2611())
205 ports
= pm3386_port_count();
206 for (i
= 0; i
< ports
; i
++) {
207 nds
[i
] = ixpdev_alloc(i
, sizeof(struct enp2611_ixpdev_priv
));
208 if (nds
[i
] == NULL
) {
214 SET_MODULE_OWNER(nds
[i
]);
215 nds
[i
]->get_stats
= enp2611_get_stats
;
217 pm3386_get_mac(i
, nds
[i
]->dev_addr
);
220 ixp2400_msf_init(&enp2611_msf_parameters
);
222 if (ixpdev_init(ports
, nds
, enp2611_set_port_admin_status
)) {
223 for (i
= 0; i
< ports
; i
++)
229 init_timer(&link_check_timer
);
230 link_check_timer
.function
= enp2611_check_link_status
;
231 link_check_timer
.expires
= jiffies
;
232 add_timer(&link_check_timer
);
237 static void __exit
enp2611_cleanup_module(void)
241 del_timer_sync(&link_check_timer
);
244 for (i
= 0; i
< 3; i
++)
248 module_init(enp2611_init_module
);
249 module_exit(enp2611_cleanup_module
);
250 MODULE_LICENSE("GPL");