10 #include <linux/rtnetlink.h>
20 #define FALCON_BOARD_TYPE(_rev) (_rev >> 8)
21 #define FALCON_BOARD_MAJOR(_rev) ((_rev >> 4) & 0xf)
22 #define FALCON_BOARD_MINOR(_rev) (_rev & 0xf)
25 #define FALCON_BOARD_SFE4001 0x01
26 #define FALCON_BOARD_SFE4002 0x02
27 #define FALCON_BOARD_SFE4003 0x03
28 #define FALCON_BOARD_SFN4112F 0x52
34 #define FALCON_BOARD_TEMP_BIAS 15
35 #define FALCON_BOARD_TEMP_CRIT (80 + FALCON_BOARD_TEMP_BIAS)
40 #define FALCON_JUNC_TEMP_MIN 0
41 #define FALCON_JUNC_TEMP_MAX 90
42 #define FALCON_JUNC_TEMP_CRIT 125
47 #define LM87_REG_TEMP_HW_INT_LOCK 0x13
48 #define LM87_REG_TEMP_HW_EXT_LOCK 0x14
49 #define LM87_REG_TEMP_HW_INT 0x17
50 #define LM87_REG_TEMP_HW_EXT 0x18
51 #define LM87_REG_TEMP_EXT1 0x26
52 #define LM87_REG_TEMP_INT 0x27
53 #define LM87_REG_ALARMS1 0x41
54 #define LM87_REG_ALARMS2 0x42
55 #define LM87_IN_LIMITS(nr, _min, _max) \
56 0x2B + (nr) * 2, _max, 0x2C + (nr) * 2, _min
57 #define LM87_AIN_LIMITS(nr, _min, _max) \
58 0x3B + (nr), _max, 0x1A + (nr), _min
59 #define LM87_TEMP_INT_LIMITS(_min, _max) \
60 0x39, _max, 0x3A, _min
61 #define LM87_TEMP_EXT1_LIMITS(_min, _max) \
62 0x37, _max, 0x38, _min
64 #define LM87_ALARM_TEMP_INT 0x10
65 #define LM87_ALARM_TEMP_EXT1 0x20
67 #if defined(CONFIG_SENSORS_LM87) || defined(CONFIG_SENSORS_LM87_MODULE)
72 u8 reg = *reg_values++;
81 static const u8 falcon_lm87_common_regs[] = {
104 rc = efx_poke_lm87(client, reg_values);
107 rc = efx_poke_lm87(client, falcon_lm87_common_regs);
119 static void efx_fini_lm87(
struct efx_nic *efx)
124 static int efx_check_lm87(
struct efx_nic *efx,
unsigned mask)
127 bool temp_crit, elec_fault, is_failure;
161 is_failure = temp_crit || elec_fault;
165 "LM87 detected a hardware %s (status %02x:%02x)"
167 is_failure ?
"failure" :
"problem",
168 alarms & 0xff, alarms >> 8,
169 (alarms & LM87_ALARM_TEMP_INT) ?
170 "; board is overheating" :
"",
171 (alarms & LM87_ALARM_TEMP_EXT1) ?
172 "; controller is overheating" :
"",
173 temp_crit ?
"; reached critical temperature" :
"",
174 elec_fault ?
"; electrical fault" :
"");
176 return is_failure ? -
ERANGE : 0;
183 const u8 *reg_values)
187 static inline void efx_fini_lm87(
struct efx_nic *efx)
190 static inline int efx_check_lm87(
struct efx_nic *efx,
unsigned mask)
220 #define P0_INVERT 0x04
221 #define P0_CONFIG 0x06
223 #define P0_EN_1V0X_LBN 0
224 #define P0_EN_1V0X_WIDTH 1
225 #define P0_EN_1V2_LBN 1
226 #define P0_EN_1V2_WIDTH 1
227 #define P0_EN_2V5_LBN 2
228 #define P0_EN_2V5_WIDTH 1
229 #define P0_EN_3V3X_LBN 3
230 #define P0_EN_3V3X_WIDTH 1
231 #define P0_EN_5V_LBN 4
232 #define P0_EN_5V_WIDTH 1
233 #define P0_SHORTEN_JTAG_LBN 5
234 #define P0_SHORTEN_JTAG_WIDTH 1
235 #define P0_X_TRST_LBN 6
236 #define P0_X_TRST_WIDTH 1
237 #define P0_DSP_RESET_LBN 7
238 #define P0_DSP_RESET_WIDTH 1
242 #define P1_INVERT 0x05
243 #define P1_CONFIG 0x07
245 #define P1_AFE_PWD_LBN 0
246 #define P1_AFE_PWD_WIDTH 1
247 #define P1_DSP_PWD25_LBN 1
248 #define P1_DSP_PWD25_WIDTH 1
249 #define P1_RESERVED_LBN 2
250 #define P1_RESERVED_WIDTH 2
251 #define P1_SPARE_LBN 4
252 #define P1_SPARE_WIDTH 4
255 #define MAX664X_REG_RSL 0x02
256 #define MAX664X_REG_WLHO 0x0B
258 static void sfe4001_poweroff(
struct efx_nic *efx)
272 static int sfe4001_poweron(
struct efx_nic *efx)
311 for (i = 0; i < 20; ++
i) {
331 "waiting for DSP boot (attempt %d)...\n", i);
341 for (j = 0; j < 10; ++
j) {
356 sfe4001_poweroff(efx);
369 const char *buf,
size_t count)
377 if (count == 0 || *buf ==
'0')
389 if (new_mode & PHY_MODE_SPECIAL)
391 err = sfe4001_poweron(efx);
394 if (!(new_mode & PHY_MODE_SPECIAL))
399 return err ? err :
count;
402 static DEVICE_ATTR(phy_flash_cfg, 0644, show_phy_flash_cfg, set_phy_flash_cfg);
404 static void sfe4001_fini(
struct efx_nic *efx)
411 sfe4001_poweroff(efx);
416 static int sfe4001_check_hw(
struct efx_nic *efx)
439 sfe4001_poweroff(efx);
453 static int sfe4001_init(
struct efx_nic *efx)
458 #if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
480 if (efx->
phy_mode & PHY_MODE_SPECIAL) {
485 rc = sfe4001_poweron(efx);
497 sfe4001_poweroff(efx);
509 static u8 sfe4002_lm87_channel = 0x03;
511 static const u8 sfe4002_lm87_regs[] = {
527 .platform_data = &sfe4002_lm87_channel,
536 #define SFE4002_FAULT_LED (2)
537 #define SFE4002_RX_LED (0)
538 #define SFE4002_TX_LED (1)
540 static void sfe4002_init_phy(
struct efx_nic *efx)
558 static int sfe4002_check_hw(
struct efx_nic *efx)
564 unsigned alarm_mask =
566 ~LM87_ALARM_TEMP_EXT1 : ~0;
568 return efx_check_lm87(efx, alarm_mask);
571 static int sfe4002_init(
struct efx_nic *efx)
573 return efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs);
580 static u8 sfn4112f_lm87_channel = 0x03;
582 static const u8 sfn4112f_lm87_regs[] = {
596 .platform_data = &sfn4112f_lm87_channel,
599 #define SFN4112F_ACT_LED 0
600 #define SFN4112F_LINK_LED 1
602 static void sfn4112f_init_phy(
struct efx_nic *efx)
629 static int sfn4112f_check_hw(
struct efx_nic *efx)
632 return efx_check_lm87(efx, ~0x48);
635 static int sfn4112f_init(
struct efx_nic *efx)
637 return efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs);
644 static u8 sfe4003_lm87_channel = 0x03;
646 static const u8 sfe4003_lm87_regs[] = {
658 .platform_data = &sfe4003_lm87_channel,
662 #define SFE4003_RED_LED_GPIO 11
663 #define SFE4003_LED_ON 1
664 #define SFE4003_LED_OFF 0
679 static void sfe4003_init_phy(
struct efx_nic *efx)
691 static int sfe4003_check_hw(
struct efx_nic *efx)
697 unsigned alarm_mask =
699 ~LM87_ALARM_TEMP_EXT1 : ~0;
701 return efx_check_lm87(efx, alarm_mask);
704 static int sfe4003_init(
struct efx_nic *efx)
706 return efx_init_lm87(efx, &sfe4003_hwmon_info, sfe4003_lm87_regs);
712 .init = sfe4001_init,
714 .fini = sfe4001_fini,
716 .monitor = sfe4001_check_hw,
720 .init = sfe4002_init,
721 .init_phy = sfe4002_init_phy,
722 .fini = efx_fini_lm87,
723 .set_id_led = sfe4002_set_id_led,
724 .monitor = sfe4002_check_hw,
728 .init = sfe4003_init,
729 .init_phy = sfe4003_init_phy,
730 .fini = efx_fini_lm87,
731 .set_id_led = sfe4003_set_id_led,
732 .monitor = sfe4003_check_hw,
736 .init = sfn4112f_init,
737 .init_phy = sfn4112f_init_phy,
738 .fini = efx_fini_lm87,
739 .set_id_led = sfn4112f_set_id_led,
740 .monitor = sfn4112f_check_hw,
754 if (board_types[i].
id == type_id)
755 board->
type = &board_types[
i];