1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
10 #include "net_driver.h"
15 /* Macros for unpacking the board revision */
16 /* The revision info is in host byte order. */
17 #define BOARD_TYPE(_rev) (_rev >> 8)
18 #define BOARD_MAJOR(_rev) ((_rev >> 4) & 0xf)
19 #define BOARD_MINOR(_rev) (_rev & 0xf)
21 /* Blink support. If the PHY has no auto-blink mode so we hang it off a timer */
22 #define BLINK_INTERVAL (HZ/2)
24 static void blink_led_timer(unsigned long context)
26 struct efx_nic *efx = (struct efx_nic *)context;
27 struct efx_blinker *bl = &efx->board_info.blinker;
28 efx->board_info.set_fault_led(efx, bl->state);
29 bl->state = !bl->state;
31 bl->timer.expires = jiffies + BLINK_INTERVAL;
32 add_timer(&bl->timer);
36 static void board_blink(struct efx_nic *efx, int blink)
38 struct efx_blinker *blinker = &efx->board_info.blinker;
40 /* The rtnl mutex serialises all ethtool ioctls, so
41 * nothing special needs doing here. */
43 blinker->resubmit = 1;
45 setup_timer(&blinker->timer, blink_led_timer,
47 blinker->timer.expires = jiffies + BLINK_INTERVAL;
48 add_timer(&blinker->timer);
50 blinker->resubmit = 0;
51 if (blinker->timer.function)
52 del_timer_sync(&blinker->timer);
53 efx->board_info.set_fault_led(efx, 0);
57 /*****************************************************************************
58 * Support for the SFE4002
61 /****************************************************************************/
62 /* LED allocations. Note that on rev A0 boards the schematic and the reality
63 * differ: red and green are swapped. Below is the fixed (A1) layout (there
64 * are only 3 A0 boards in existence, so no real reason to make this
67 #define SFE4002_FAULT_LED (2) /* Red */
68 #define SFE4002_RX_LED (0) /* Green */
69 #define SFE4002_TX_LED (1) /* Amber */
71 static int sfe4002_init_leds(struct efx_nic *efx)
73 /* Set the TX and RX LEDs to reflect status and activity, and the
75 xfp_set_led(efx, SFE4002_TX_LED,
76 QUAKE_LED_TXLINK | QUAKE_LED_LINK_ACTSTAT);
77 xfp_set_led(efx, SFE4002_RX_LED,
78 QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACTSTAT);
79 xfp_set_led(efx, SFE4002_FAULT_LED, QUAKE_LED_OFF);
80 efx->board_info.blinker.led_num = SFE4002_FAULT_LED;
84 static void sfe4002_fault_led(struct efx_nic *efx, int state)
86 xfp_set_led(efx, SFE4002_FAULT_LED, state ? QUAKE_LED_ON :
90 static int sfe4002_init(struct efx_nic *efx)
92 efx->board_info.init_leds = sfe4002_init_leds;
93 efx->board_info.set_fault_led = sfe4002_fault_led;
94 efx->board_info.blink = board_blink;
98 /* This will get expanded as board-specific details get moved out of the
100 struct efx_board_data {
101 const char *ref_model;
102 const char *gen_type;
103 int (*init) (struct efx_nic *nic);
106 static int dummy_init(struct efx_nic *nic)
111 static struct efx_board_data board_data[] = {
112 [EFX_BOARD_INVALID] =
113 {NULL, NULL, dummy_init},
114 [EFX_BOARD_SFE4001] =
115 {"SFE4001", "10GBASE-T adapter", sfe4001_poweron},
116 [EFX_BOARD_SFE4002] =
117 {"SFE4002", "XFP adapter", sfe4002_init},
120 int efx_set_board_info(struct efx_nic *efx, u16 revision_info)
123 struct efx_board_data *data;
125 if (BOARD_TYPE(revision_info) >= EFX_BOARD_MAX) {
126 EFX_ERR(efx, "squashing unknown board type %d\n",
127 BOARD_TYPE(revision_info));
131 if (BOARD_TYPE(revision_info) == 0) {
132 efx->board_info.major = 0;
133 efx->board_info.minor = 0;
134 /* For early boards that don't have revision info. there is
135 * only 1 board for each PHY type, so we can work it out, with
136 * the exception of the PHY-less boards. */
137 switch (efx->phy_type) {
138 case PHY_TYPE_10XPRESS:
139 efx->board_info.type = EFX_BOARD_SFE4001;
142 efx->board_info.type = EFX_BOARD_SFE4002;
145 efx->board_info.type = 0;
149 efx->board_info.type = BOARD_TYPE(revision_info);
150 efx->board_info.major = BOARD_MAJOR(revision_info);
151 efx->board_info.minor = BOARD_MINOR(revision_info);
154 data = &board_data[efx->board_info.type];
156 /* Report the board model number or generic type for recognisable
158 if (efx->board_info.type != 0)
159 EFX_INFO(efx, "board is %s rev %c%d\n",
160 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
161 ? data->ref_model : data->gen_type,
162 'A' + efx->board_info.major, efx->board_info.minor);
164 efx->board_info.init = data->init;