1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007-2008 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 <linux/rtnetlink.h>
12 #include "net_driver.h"
17 #include "falcon_hwdefs.h"
18 #include "falcon_io.h"
19 #include "workarounds.h"
21 /* Macros for unpacking the board revision */
22 /* The revision info is in host byte order. */
23 #define FALCON_BOARD_TYPE(_rev) (_rev >> 8)
24 #define FALCON_BOARD_MAJOR(_rev) ((_rev >> 4) & 0xf)
25 #define FALCON_BOARD_MINOR(_rev) (_rev & 0xf)
28 #define FALCON_BOARD_SFE4001 0x01
29 #define FALCON_BOARD_SFE4002 0x02
30 #define FALCON_BOARD_SFN4111T 0x51
31 #define FALCON_BOARD_SFN4112F 0x52
33 /* Blink support. If the PHY has no auto-blink mode so we hang it off a timer */
34 #define BLINK_INTERVAL (HZ/2)
36 static void blink_led_timer(unsigned long context
)
38 struct efx_nic
*efx
= (struct efx_nic
*)context
;
39 struct efx_blinker
*bl
= &efx
->board_info
.blinker
;
40 efx
->board_info
.set_id_led(efx
, bl
->state
);
41 bl
->state
= !bl
->state
;
43 mod_timer(&bl
->timer
, jiffies
+ BLINK_INTERVAL
);
46 static void board_blink(struct efx_nic
*efx
, bool blink
)
48 struct efx_blinker
*blinker
= &efx
->board_info
.blinker
;
50 /* The rtnl mutex serialises all ethtool ioctls, so
51 * nothing special needs doing here. */
53 blinker
->resubmit
= true;
54 blinker
->state
= false;
55 setup_timer(&blinker
->timer
, blink_led_timer
,
57 mod_timer(&blinker
->timer
, jiffies
+ BLINK_INTERVAL
);
59 blinker
->resubmit
= false;
60 if (blinker
->timer
.function
)
61 del_timer_sync(&blinker
->timer
);
62 efx
->board_info
.init_leds(efx
);
66 /*****************************************************************************
67 * Support for LM87 sensor chip used on several boards
69 #define LM87_REG_ALARMS1 0x41
70 #define LM87_REG_ALARMS2 0x42
71 #define LM87_IN_LIMITS(nr, _min, _max) \
72 0x2B + (nr) * 2, _max, 0x2C + (nr) * 2, _min
73 #define LM87_AIN_LIMITS(nr, _min, _max) \
74 0x3B + (nr), _max, 0x1A + (nr), _min
75 #define LM87_TEMP_INT_LIMITS(_min, _max) \
76 0x39, _max, 0x3A, _min
77 #define LM87_TEMP_EXT1_LIMITS(_min, _max) \
78 0x37, _max, 0x38, _min
80 #define LM87_ALARM_TEMP_INT 0x10
81 #define LM87_ALARM_TEMP_EXT1 0x20
83 #if defined(CONFIG_SENSORS_LM87) || defined(CONFIG_SENSORS_LM87_MODULE)
85 static int efx_init_lm87(struct efx_nic
*efx
, struct i2c_board_info
*info
,
88 struct i2c_client
*client
= i2c_new_device(&efx
->i2c_adap
, info
);
95 u8 reg
= *reg_values
++;
96 u8 value
= *reg_values
++;
97 rc
= i2c_smbus_write_byte_data(client
, reg
, value
);
102 efx
->board_info
.hwmon_client
= client
;
106 i2c_unregister_device(client
);
110 static void efx_fini_lm87(struct efx_nic
*efx
)
112 i2c_unregister_device(efx
->board_info
.hwmon_client
);
115 static int efx_check_lm87(struct efx_nic
*efx
, unsigned mask
)
117 struct i2c_client
*client
= efx
->board_info
.hwmon_client
;
118 s32 alarms1
, alarms2
;
120 /* If link is up then do not monitor temperature */
121 if (EFX_WORKAROUND_7884(efx
) && efx
->link_up
)
124 alarms1
= i2c_smbus_read_byte_data(client
, LM87_REG_ALARMS1
);
125 alarms2
= i2c_smbus_read_byte_data(client
, LM87_REG_ALARMS2
);
131 alarms2
&= mask
>> 8;
132 if (alarms1
|| alarms2
) {
134 "LM87 detected a hardware failure (status %02x:%02x)"
137 (alarms1
& LM87_ALARM_TEMP_INT
) ? " INTERNAL" : "",
138 (alarms1
& LM87_ALARM_TEMP_EXT1
) ? " EXTERNAL" : "");
145 #else /* !CONFIG_SENSORS_LM87 */
148 efx_init_lm87(struct efx_nic
*efx
, struct i2c_board_info
*info
,
149 const u8
*reg_values
)
153 static inline void efx_fini_lm87(struct efx_nic
*efx
)
156 static inline int efx_check_lm87(struct efx_nic
*efx
, unsigned mask
)
161 #endif /* CONFIG_SENSORS_LM87 */
163 /*****************************************************************************
164 * Support for the SFE4001 and SFN4111T NICs.
166 * The SFE4001 does not power-up fully at reset due to its high power
167 * consumption. We control its power via a PCA9539 I/O expander.
168 * Both boards have a MAX6647 temperature monitor which we expose to
171 * This also provides minimal support for reflashing the PHY, which is
172 * initiated by resetting it with the FLASH_CFG_1 pin pulled down.
173 * On SFE4001 rev A2 and later this is connected to the 3V3X output of
174 * the IO-expander; on the SFN4111T it is connected to Falcon's GPIO3.
175 * We represent reflash mode as PHY_MODE_SPECIAL and make it mutually
176 * exclusive with the network device being open.
179 /**************************************************************************
180 * Support for I2C IO Expander device on SFE40001
186 #define P0_INVERT 0x04
187 #define P0_CONFIG 0x06
189 #define P0_EN_1V0X_LBN 0
190 #define P0_EN_1V0X_WIDTH 1
191 #define P0_EN_1V2_LBN 1
192 #define P0_EN_1V2_WIDTH 1
193 #define P0_EN_2V5_LBN 2
194 #define P0_EN_2V5_WIDTH 1
195 #define P0_EN_3V3X_LBN 3
196 #define P0_EN_3V3X_WIDTH 1
197 #define P0_EN_5V_LBN 4
198 #define P0_EN_5V_WIDTH 1
199 #define P0_SHORTEN_JTAG_LBN 5
200 #define P0_SHORTEN_JTAG_WIDTH 1
201 #define P0_X_TRST_LBN 6
202 #define P0_X_TRST_WIDTH 1
203 #define P0_DSP_RESET_LBN 7
204 #define P0_DSP_RESET_WIDTH 1
208 #define P1_INVERT 0x05
209 #define P1_CONFIG 0x07
211 #define P1_AFE_PWD_LBN 0
212 #define P1_AFE_PWD_WIDTH 1
213 #define P1_DSP_PWD25_LBN 1
214 #define P1_DSP_PWD25_WIDTH 1
215 #define P1_RESERVED_LBN 2
216 #define P1_RESERVED_WIDTH 2
217 #define P1_SPARE_LBN 4
218 #define P1_SPARE_WIDTH 4
220 /* Temperature Sensor */
221 #define MAX664X_REG_RSL 0x02
222 #define MAX664X_REG_WLHO 0x0B
224 static void sfe4001_poweroff(struct efx_nic
*efx
)
226 struct i2c_client
*ioexp_client
= efx
->board_info
.ioexp_client
;
227 struct i2c_client
*hwmon_client
= efx
->board_info
.hwmon_client
;
229 /* Turn off all power rails and disable outputs */
230 i2c_smbus_write_byte_data(ioexp_client
, P0_OUT
, 0xff);
231 i2c_smbus_write_byte_data(ioexp_client
, P1_CONFIG
, 0xff);
232 i2c_smbus_write_byte_data(ioexp_client
, P0_CONFIG
, 0xff);
234 /* Clear any over-temperature alert */
235 i2c_smbus_read_byte_data(hwmon_client
, MAX664X_REG_RSL
);
238 static int sfe4001_poweron(struct efx_nic
*efx
)
240 struct i2c_client
*hwmon_client
= efx
->board_info
.hwmon_client
;
241 struct i2c_client
*ioexp_client
= efx
->board_info
.ioexp_client
;
246 /* Clear any previous over-temperature alert */
247 rc
= i2c_smbus_read_byte_data(hwmon_client
, MAX664X_REG_RSL
);
251 /* Enable port 0 and port 1 outputs on IO expander */
252 rc
= i2c_smbus_write_byte_data(ioexp_client
, P0_CONFIG
, 0x00);
255 rc
= i2c_smbus_write_byte_data(ioexp_client
, P1_CONFIG
,
256 0xff & ~(1 << P1_SPARE_LBN
));
260 /* If PHY power is on, turn it all off and wait 1 second to
261 * ensure a full reset.
263 rc
= i2c_smbus_read_byte_data(ioexp_client
, P0_OUT
);
266 out
= 0xff & ~((0 << P0_EN_1V2_LBN
) | (0 << P0_EN_2V5_LBN
) |
267 (0 << P0_EN_3V3X_LBN
) | (0 << P0_EN_5V_LBN
) |
268 (0 << P0_EN_1V0X_LBN
));
270 EFX_INFO(efx
, "power-cycling PHY\n");
271 rc
= i2c_smbus_write_byte_data(ioexp_client
, P0_OUT
, out
);
274 schedule_timeout_uninterruptible(HZ
);
277 for (i
= 0; i
< 20; ++i
) {
278 /* Turn on 1.2V, 2.5V, 3.3V and 5V power rails */
279 out
= 0xff & ~((1 << P0_EN_1V2_LBN
) | (1 << P0_EN_2V5_LBN
) |
280 (1 << P0_EN_3V3X_LBN
) | (1 << P0_EN_5V_LBN
) |
281 (1 << P0_X_TRST_LBN
));
282 if (efx
->phy_mode
& PHY_MODE_SPECIAL
)
283 out
|= 1 << P0_EN_3V3X_LBN
;
285 rc
= i2c_smbus_write_byte_data(ioexp_client
, P0_OUT
, out
);
290 /* Turn on 1V power rail */
291 out
&= ~(1 << P0_EN_1V0X_LBN
);
292 rc
= i2c_smbus_write_byte_data(ioexp_client
, P0_OUT
, out
);
296 EFX_INFO(efx
, "waiting for DSP boot (attempt %d)...\n", i
);
298 /* In flash config mode, DSP does not turn on AFE, so
299 * just wait 1 second.
301 if (efx
->phy_mode
& PHY_MODE_SPECIAL
) {
302 schedule_timeout_uninterruptible(HZ
);
306 for (j
= 0; j
< 10; ++j
) {
309 /* Check DSP has asserted AFE power line */
310 rc
= i2c_smbus_read_byte_data(ioexp_client
, P1_IN
);
313 if (rc
& (1 << P1_AFE_PWD_LBN
))
318 EFX_INFO(efx
, "timed out waiting for DSP boot\n");
321 sfe4001_poweroff(efx
);
325 static int sfn4111t_reset(struct efx_nic
*efx
)
329 /* GPIO 3 and the GPIO register are shared with I2C, so block that */
330 mutex_lock(&efx
->i2c_adap
.bus_lock
);
332 /* Pull RST_N (GPIO 2) low then let it up again, setting the
333 * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the
334 * output enables; the output levels should always be 0 (low)
335 * and we rely on external pull-ups. */
336 falcon_read(efx
, ®
, GPIO_CTL_REG_KER
);
337 EFX_SET_OWORD_FIELD(reg
, GPIO2_OEN
, true);
338 falcon_write(efx
, ®
, GPIO_CTL_REG_KER
);
340 EFX_SET_OWORD_FIELD(reg
, GPIO2_OEN
, false);
341 EFX_SET_OWORD_FIELD(reg
, GPIO3_OEN
,
342 !!(efx
->phy_mode
& PHY_MODE_SPECIAL
));
343 falcon_write(efx
, ®
, GPIO_CTL_REG_KER
);
346 mutex_unlock(&efx
->i2c_adap
.bus_lock
);
352 static ssize_t
show_phy_flash_cfg(struct device
*dev
,
353 struct device_attribute
*attr
, char *buf
)
355 struct efx_nic
*efx
= pci_get_drvdata(to_pci_dev(dev
));
356 return sprintf(buf
, "%d\n", !!(efx
->phy_mode
& PHY_MODE_SPECIAL
));
359 static ssize_t
set_phy_flash_cfg(struct device
*dev
,
360 struct device_attribute
*attr
,
361 const char *buf
, size_t count
)
363 struct efx_nic
*efx
= pci_get_drvdata(to_pci_dev(dev
));
364 enum efx_phy_mode old_mode
, new_mode
;
368 old_mode
= efx
->phy_mode
;
369 if (count
== 0 || *buf
== '0')
370 new_mode
= old_mode
& ~PHY_MODE_SPECIAL
;
372 new_mode
= PHY_MODE_SPECIAL
;
373 if (old_mode
== new_mode
) {
375 } else if (efx
->state
!= STATE_RUNNING
|| netif_running(efx
->net_dev
)) {
378 /* Reset the PHY, reconfigure the MAC and enable/disable
379 * MAC stats accordingly. */
380 efx
->phy_mode
= new_mode
;
381 if (new_mode
& PHY_MODE_SPECIAL
)
382 efx_stats_disable(efx
);
383 if (efx
->board_info
.type
== FALCON_BOARD_SFE4001
)
384 err
= sfe4001_poweron(efx
);
386 err
= sfn4111t_reset(efx
);
387 efx_reconfigure_port(efx
);
388 if (!(new_mode
& PHY_MODE_SPECIAL
))
389 efx_stats_enable(efx
);
393 return err
? err
: count
;
396 static DEVICE_ATTR(phy_flash_cfg
, 0644, show_phy_flash_cfg
, set_phy_flash_cfg
);
398 static void sfe4001_fini(struct efx_nic
*efx
)
400 EFX_INFO(efx
, "%s\n", __func__
);
402 device_remove_file(&efx
->pci_dev
->dev
, &dev_attr_phy_flash_cfg
);
403 sfe4001_poweroff(efx
);
404 i2c_unregister_device(efx
->board_info
.ioexp_client
);
405 i2c_unregister_device(efx
->board_info
.hwmon_client
);
408 static int sfe4001_check_hw(struct efx_nic
*efx
)
412 /* If XAUI link is up then do not monitor */
413 if (EFX_WORKAROUND_7884(efx
) && efx
->mac_up
)
416 /* Check the powered status of the PHY. Lack of power implies that
417 * the MAX6647 has shut down power to it, probably due to a temp.
418 * alarm. Reading the power status rather than the MAX6647 status
419 * directly because the later is read-to-clear and would thus
420 * start to power up the PHY again when polled, causing us to blip
421 * the power undesirably.
422 * We know we can read from the IO expander because we did
423 * it during power-on. Assume failure now is bad news. */
424 status
= i2c_smbus_read_byte_data(efx
->board_info
.ioexp_client
, P1_IN
);
426 (status
& ((1 << P1_AFE_PWD_LBN
) | (1 << P1_DSP_PWD25_LBN
))) != 0)
429 /* Use board power control, not PHY power control */
430 sfe4001_poweroff(efx
);
431 efx
->phy_mode
= PHY_MODE_OFF
;
433 return (status
< 0) ? -EIO
: -ERANGE
;
436 static struct i2c_board_info sfe4001_hwmon_info
= {
437 I2C_BOARD_INFO("max6647", 0x4e),
440 /* This board uses an I2C expander to provider power to the PHY, which needs to
441 * be turned on before the PHY can be used.
442 * Context: Process context, rtnl lock held
444 static int sfe4001_init(struct efx_nic
*efx
)
448 #if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
449 efx
->board_info
.hwmon_client
=
450 i2c_new_device(&efx
->i2c_adap
, &sfe4001_hwmon_info
);
452 efx
->board_info
.hwmon_client
=
453 i2c_new_dummy(&efx
->i2c_adap
, sfe4001_hwmon_info
.addr
);
455 if (!efx
->board_info
.hwmon_client
)
458 /* Raise board/PHY high limit from 85 to 90 degrees Celsius */
459 rc
= i2c_smbus_write_byte_data(efx
->board_info
.hwmon_client
,
460 MAX664X_REG_WLHO
, 90);
464 efx
->board_info
.ioexp_client
= i2c_new_dummy(&efx
->i2c_adap
, PCA9539
);
465 if (!efx
->board_info
.ioexp_client
) {
470 /* 10Xpress has fixed-function LED pins, so there is no board-specific
472 efx
->board_info
.blink
= tenxpress_phy_blink
;
474 efx
->board_info
.monitor
= sfe4001_check_hw
;
475 efx
->board_info
.fini
= sfe4001_fini
;
477 if (efx
->phy_mode
& PHY_MODE_SPECIAL
) {
478 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch
480 efx_stats_disable(efx
);
482 rc
= sfe4001_poweron(efx
);
486 rc
= device_create_file(&efx
->pci_dev
->dev
, &dev_attr_phy_flash_cfg
);
490 EFX_INFO(efx
, "PHY is powered on\n");
494 sfe4001_poweroff(efx
);
496 i2c_unregister_device(efx
->board_info
.ioexp_client
);
498 i2c_unregister_device(efx
->board_info
.hwmon_client
);
502 static int sfn4111t_check_hw(struct efx_nic
*efx
)
506 /* If XAUI link is up then do not monitor */
507 if (EFX_WORKAROUND_7884(efx
) && efx
->mac_up
)
510 /* Test LHIGH, RHIGH, FAULT, EOT and IOT alarms */
511 status
= i2c_smbus_read_byte_data(efx
->board_info
.hwmon_client
,
520 static void sfn4111t_fini(struct efx_nic
*efx
)
522 EFX_INFO(efx
, "%s\n", __func__
);
524 device_remove_file(&efx
->pci_dev
->dev
, &dev_attr_phy_flash_cfg
);
525 i2c_unregister_device(efx
->board_info
.hwmon_client
);
528 static struct i2c_board_info sfn4111t_a0_hwmon_info
= {
529 I2C_BOARD_INFO("max6647", 0x4e),
532 static struct i2c_board_info sfn4111t_r5_hwmon_info
= {
533 I2C_BOARD_INFO("max6646", 0x4d),
536 static int sfn4111t_init(struct efx_nic
*efx
)
541 efx
->board_info
.hwmon_client
=
542 i2c_new_device(&efx
->i2c_adap
,
543 (efx
->board_info
.minor
< 5) ?
544 &sfn4111t_a0_hwmon_info
:
545 &sfn4111t_r5_hwmon_info
);
546 if (!efx
->board_info
.hwmon_client
)
549 efx
->board_info
.blink
= tenxpress_phy_blink
;
550 efx
->board_info
.monitor
= sfn4111t_check_hw
;
551 efx
->board_info
.fini
= sfn4111t_fini
;
553 rc
= device_create_file(&efx
->pci_dev
->dev
, &dev_attr_phy_flash_cfg
);
558 if (efx
->phy_mode
& PHY_MODE_SPECIAL
) {
559 /* PHY may not generate a 156.25 MHz clock and MAC
560 * stats fetch will fail. */
561 efx_stats_disable(efx
);
564 rc
= sft9001_wait_boot(efx
);
567 efx
->phy_mode
= PHY_MODE_SPECIAL
;
568 } while (rc
== -EINVAL
&& ++i
< 2);
570 device_remove_file(&efx
->pci_dev
->dev
, &dev_attr_phy_flash_cfg
);
572 i2c_unregister_device(efx
->board_info
.hwmon_client
);
576 /*****************************************************************************
577 * Support for the SFE4002
580 static u8 sfe4002_lm87_channel
= 0x03; /* use AIN not FAN inputs */
582 static const u8 sfe4002_lm87_regs
[] = {
583 LM87_IN_LIMITS(0, 0x83, 0x91), /* 2.5V: 1.8V +/- 5% */
584 LM87_IN_LIMITS(1, 0x51, 0x5a), /* Vccp1: 1.2V +/- 5% */
585 LM87_IN_LIMITS(2, 0xb6, 0xca), /* 3.3V: 3.3V +/- 5% */
586 LM87_IN_LIMITS(3, 0xb0, 0xc9), /* 5V: 4.6-5.2V */
587 LM87_IN_LIMITS(4, 0xb0, 0xe0), /* 12V: 11-14V */
588 LM87_IN_LIMITS(5, 0x44, 0x4b), /* Vccp2: 1.0V +/- 5% */
589 LM87_AIN_LIMITS(0, 0xa0, 0xb2), /* AIN1: 1.66V +/- 5% */
590 LM87_AIN_LIMITS(1, 0x91, 0xa1), /* AIN2: 1.5V +/- 5% */
591 LM87_TEMP_INT_LIMITS(10, 60), /* board */
592 LM87_TEMP_EXT1_LIMITS(10, 70), /* Falcon */
596 static struct i2c_board_info sfe4002_hwmon_info
= {
597 I2C_BOARD_INFO("lm87", 0x2e),
598 .platform_data
= &sfe4002_lm87_channel
,
601 /****************************************************************************/
602 /* LED allocations. Note that on rev A0 boards the schematic and the reality
603 * differ: red and green are swapped. Below is the fixed (A1) layout (there
604 * are only 3 A0 boards in existence, so no real reason to make this
607 #define SFE4002_FAULT_LED (2) /* Red */
608 #define SFE4002_RX_LED (0) /* Green */
609 #define SFE4002_TX_LED (1) /* Amber */
611 static void sfe4002_init_leds(struct efx_nic
*efx
)
613 /* Set the TX and RX LEDs to reflect status and activity, and the
615 xfp_set_led(efx
, SFE4002_TX_LED
,
616 QUAKE_LED_TXLINK
| QUAKE_LED_LINK_ACTSTAT
);
617 xfp_set_led(efx
, SFE4002_RX_LED
,
618 QUAKE_LED_RXLINK
| QUAKE_LED_LINK_ACTSTAT
);
619 xfp_set_led(efx
, SFE4002_FAULT_LED
, QUAKE_LED_OFF
);
622 static void sfe4002_set_id_led(struct efx_nic
*efx
, bool state
)
624 xfp_set_led(efx
, SFE4002_FAULT_LED
, state
? QUAKE_LED_ON
:
628 static int sfe4002_check_hw(struct efx_nic
*efx
)
630 /* A0 board rev. 4002s report a temperature fault the whole time
631 * (bad sensor) so we mask it out. */
632 unsigned alarm_mask
=
633 (efx
->board_info
.major
== 0 && efx
->board_info
.minor
== 0) ?
634 ~LM87_ALARM_TEMP_EXT1
: ~0;
636 return efx_check_lm87(efx
, alarm_mask
);
639 static int sfe4002_init(struct efx_nic
*efx
)
641 int rc
= efx_init_lm87(efx
, &sfe4002_hwmon_info
, sfe4002_lm87_regs
);
644 efx
->board_info
.monitor
= sfe4002_check_hw
;
645 efx
->board_info
.init_leds
= sfe4002_init_leds
;
646 efx
->board_info
.set_id_led
= sfe4002_set_id_led
;
647 efx
->board_info
.blink
= board_blink
;
648 efx
->board_info
.fini
= efx_fini_lm87
;
652 /*****************************************************************************
653 * Support for the SFN4112F
656 static u8 sfn4112f_lm87_channel
= 0x03; /* use AIN not FAN inputs */
658 static const u8 sfn4112f_lm87_regs
[] = {
659 LM87_IN_LIMITS(0, 0x83, 0x91), /* 2.5V: 1.8V +/- 5% */
660 LM87_IN_LIMITS(1, 0x51, 0x5a), /* Vccp1: 1.2V +/- 5% */
661 LM87_IN_LIMITS(2, 0xb6, 0xca), /* 3.3V: 3.3V +/- 5% */
662 LM87_IN_LIMITS(4, 0xb0, 0xe0), /* 12V: 11-14V */
663 LM87_IN_LIMITS(5, 0x44, 0x4b), /* Vccp2: 1.0V +/- 5% */
664 LM87_AIN_LIMITS(1, 0x91, 0xa1), /* AIN2: 1.5V +/- 5% */
665 LM87_TEMP_INT_LIMITS(10, 60), /* board */
666 LM87_TEMP_EXT1_LIMITS(10, 70), /* Falcon */
670 static struct i2c_board_info sfn4112f_hwmon_info
= {
671 I2C_BOARD_INFO("lm87", 0x2e),
672 .platform_data
= &sfn4112f_lm87_channel
,
675 #define SFN4112F_ACT_LED 0
676 #define SFN4112F_LINK_LED 1
678 static void sfn4112f_init_leds(struct efx_nic
*efx
)
680 xfp_set_led(efx
, SFN4112F_ACT_LED
,
681 QUAKE_LED_RXLINK
| QUAKE_LED_LINK_ACT
);
682 xfp_set_led(efx
, SFN4112F_LINK_LED
,
683 QUAKE_LED_RXLINK
| QUAKE_LED_LINK_STAT
);
686 static void sfn4112f_set_id_led(struct efx_nic
*efx
, bool state
)
688 xfp_set_led(efx
, SFN4112F_LINK_LED
,
689 state
? QUAKE_LED_ON
: QUAKE_LED_OFF
);
692 static int sfn4112f_check_hw(struct efx_nic
*efx
)
694 /* Mask out unused sensors */
695 return efx_check_lm87(efx
, ~0x48);
698 static int sfn4112f_init(struct efx_nic
*efx
)
700 int rc
= efx_init_lm87(efx
, &sfn4112f_hwmon_info
, sfn4112f_lm87_regs
);
703 efx
->board_info
.monitor
= sfn4112f_check_hw
;
704 efx
->board_info
.init_leds
= sfn4112f_init_leds
;
705 efx
->board_info
.set_id_led
= sfn4112f_set_id_led
;
706 efx
->board_info
.blink
= board_blink
;
707 efx
->board_info
.fini
= efx_fini_lm87
;
711 /* This will get expanded as board-specific details get moved out of the
713 struct falcon_board_data
{
715 const char *ref_model
;
716 const char *gen_type
;
717 int (*init
) (struct efx_nic
*nic
);
721 static struct falcon_board_data board_data
[] = {
722 { FALCON_BOARD_SFE4001
, "SFE4001", "10GBASE-T adapter", sfe4001_init
},
723 { FALCON_BOARD_SFE4002
, "SFE4002", "XFP adapter", sfe4002_init
},
724 { FALCON_BOARD_SFN4111T
, "SFN4111T", "100/1000/10GBASE-T adapter",
726 { FALCON_BOARD_SFN4112F
, "SFN4112F", "SFP+ adapter",
730 void falcon_probe_board(struct efx_nic
*efx
, u16 revision_info
)
732 struct falcon_board_data
*data
= NULL
;
735 efx
->board_info
.type
= FALCON_BOARD_TYPE(revision_info
);
736 efx
->board_info
.major
= FALCON_BOARD_MAJOR(revision_info
);
737 efx
->board_info
.minor
= FALCON_BOARD_MINOR(revision_info
);
739 for (i
= 0; i
< ARRAY_SIZE(board_data
); i
++)
740 if (board_data
[i
].type
== efx
->board_info
.type
)
741 data
= &board_data
[i
];
744 EFX_INFO(efx
, "board is %s rev %c%d\n",
745 (efx
->pci_dev
->subsystem_vendor
== EFX_VENDID_SFC
)
746 ? data
->ref_model
: data
->gen_type
,
747 'A' + efx
->board_info
.major
, efx
->board_info
.minor
);
748 efx
->board_info
.init
= data
->init
;
750 EFX_ERR(efx
, "unknown board type %d\n", efx
->board_info
.type
);