Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | * Driver for Solarflare Solarstorm network controllers and boards |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 3 | * Copyright 2007-2008 Solarflare Communications Inc. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 4 | * |
| 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. |
| 8 | */ |
| 9 | |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 10 | #include <linux/rtnetlink.h> |
| 11 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 12 | #include "net_driver.h" |
| 13 | #include "phy.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 14 | #include "efx.h" |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 15 | #include "falcon.h" |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 16 | #include "regs.h" |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 17 | #include "io.h" |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 18 | #include "workarounds.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 19 | |
| 20 | /* Macros for unpacking the board revision */ |
| 21 | /* The revision info is in host byte order. */ |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 22 | #define FALCON_BOARD_TYPE(_rev) (_rev >> 8) |
| 23 | #define FALCON_BOARD_MAJOR(_rev) ((_rev >> 4) & 0xf) |
| 24 | #define FALCON_BOARD_MINOR(_rev) (_rev & 0xf) |
| 25 | |
| 26 | /* Board types */ |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 27 | #define FALCON_BOARD_SFE4001 0x01 |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 28 | #define FALCON_BOARD_SFE4002 0x02 |
| 29 | #define FALCON_BOARD_SFN4111T 0x51 |
| 30 | #define FALCON_BOARD_SFN4112F 0x52 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 31 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 32 | /***************************************************************************** |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 33 | * Support for LM87 sensor chip used on several boards |
| 34 | */ |
| 35 | #define LM87_REG_ALARMS1 0x41 |
| 36 | #define LM87_REG_ALARMS2 0x42 |
| 37 | #define LM87_IN_LIMITS(nr, _min, _max) \ |
| 38 | 0x2B + (nr) * 2, _max, 0x2C + (nr) * 2, _min |
| 39 | #define LM87_AIN_LIMITS(nr, _min, _max) \ |
| 40 | 0x3B + (nr), _max, 0x1A + (nr), _min |
| 41 | #define LM87_TEMP_INT_LIMITS(_min, _max) \ |
| 42 | 0x39, _max, 0x3A, _min |
| 43 | #define LM87_TEMP_EXT1_LIMITS(_min, _max) \ |
| 44 | 0x37, _max, 0x38, _min |
| 45 | |
| 46 | #define LM87_ALARM_TEMP_INT 0x10 |
| 47 | #define LM87_ALARM_TEMP_EXT1 0x20 |
| 48 | |
| 49 | #if defined(CONFIG_SENSORS_LM87) || defined(CONFIG_SENSORS_LM87_MODULE) |
| 50 | |
| 51 | static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, |
| 52 | const u8 *reg_values) |
| 53 | { |
| 54 | struct i2c_client *client = i2c_new_device(&efx->i2c_adap, info); |
| 55 | int rc; |
| 56 | |
| 57 | if (!client) |
| 58 | return -EIO; |
| 59 | |
| 60 | while (*reg_values) { |
| 61 | u8 reg = *reg_values++; |
| 62 | u8 value = *reg_values++; |
| 63 | rc = i2c_smbus_write_byte_data(client, reg, value); |
| 64 | if (rc) |
| 65 | goto err; |
| 66 | } |
| 67 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 68 | falcon_board(efx)->hwmon_client = client; |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 69 | return 0; |
| 70 | |
| 71 | err: |
| 72 | i2c_unregister_device(client); |
| 73 | return rc; |
| 74 | } |
| 75 | |
| 76 | static void efx_fini_lm87(struct efx_nic *efx) |
| 77 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 78 | i2c_unregister_device(falcon_board(efx)->hwmon_client); |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static int efx_check_lm87(struct efx_nic *efx, unsigned mask) |
| 82 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 83 | struct i2c_client *client = falcon_board(efx)->hwmon_client; |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 84 | s32 alarms1, alarms2; |
| 85 | |
| 86 | /* If link is up then do not monitor temperature */ |
| 87 | if (EFX_WORKAROUND_7884(efx) && efx->link_up) |
| 88 | return 0; |
| 89 | |
| 90 | alarms1 = i2c_smbus_read_byte_data(client, LM87_REG_ALARMS1); |
| 91 | alarms2 = i2c_smbus_read_byte_data(client, LM87_REG_ALARMS2); |
| 92 | if (alarms1 < 0) |
| 93 | return alarms1; |
| 94 | if (alarms2 < 0) |
| 95 | return alarms2; |
| 96 | alarms1 &= mask; |
| 97 | alarms2 &= mask >> 8; |
| 98 | if (alarms1 || alarms2) { |
| 99 | EFX_ERR(efx, |
| 100 | "LM87 detected a hardware failure (status %02x:%02x)" |
| 101 | "%s%s\n", |
| 102 | alarms1, alarms2, |
| 103 | (alarms1 & LM87_ALARM_TEMP_INT) ? " INTERNAL" : "", |
| 104 | (alarms1 & LM87_ALARM_TEMP_EXT1) ? " EXTERNAL" : ""); |
| 105 | return -ERANGE; |
| 106 | } |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | #else /* !CONFIG_SENSORS_LM87 */ |
| 112 | |
| 113 | static inline int |
| 114 | efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, |
| 115 | const u8 *reg_values) |
| 116 | { |
| 117 | return 0; |
| 118 | } |
| 119 | static inline void efx_fini_lm87(struct efx_nic *efx) |
| 120 | { |
| 121 | } |
| 122 | static inline int efx_check_lm87(struct efx_nic *efx, unsigned mask) |
| 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | #endif /* CONFIG_SENSORS_LM87 */ |
| 128 | |
| 129 | /***************************************************************************** |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 130 | * Support for the SFE4001 and SFN4111T NICs. |
| 131 | * |
| 132 | * The SFE4001 does not power-up fully at reset due to its high power |
| 133 | * consumption. We control its power via a PCA9539 I/O expander. |
| 134 | * Both boards have a MAX6647 temperature monitor which we expose to |
| 135 | * the lm90 driver. |
| 136 | * |
| 137 | * This also provides minimal support for reflashing the PHY, which is |
| 138 | * initiated by resetting it with the FLASH_CFG_1 pin pulled down. |
| 139 | * On SFE4001 rev A2 and later this is connected to the 3V3X output of |
| 140 | * the IO-expander; on the SFN4111T it is connected to Falcon's GPIO3. |
| 141 | * We represent reflash mode as PHY_MODE_SPECIAL and make it mutually |
| 142 | * exclusive with the network device being open. |
| 143 | */ |
| 144 | |
| 145 | /************************************************************************** |
| 146 | * Support for I2C IO Expander device on SFE40001 |
| 147 | */ |
| 148 | #define PCA9539 0x74 |
| 149 | |
| 150 | #define P0_IN 0x00 |
| 151 | #define P0_OUT 0x02 |
| 152 | #define P0_INVERT 0x04 |
| 153 | #define P0_CONFIG 0x06 |
| 154 | |
| 155 | #define P0_EN_1V0X_LBN 0 |
| 156 | #define P0_EN_1V0X_WIDTH 1 |
| 157 | #define P0_EN_1V2_LBN 1 |
| 158 | #define P0_EN_1V2_WIDTH 1 |
| 159 | #define P0_EN_2V5_LBN 2 |
| 160 | #define P0_EN_2V5_WIDTH 1 |
| 161 | #define P0_EN_3V3X_LBN 3 |
| 162 | #define P0_EN_3V3X_WIDTH 1 |
| 163 | #define P0_EN_5V_LBN 4 |
| 164 | #define P0_EN_5V_WIDTH 1 |
| 165 | #define P0_SHORTEN_JTAG_LBN 5 |
| 166 | #define P0_SHORTEN_JTAG_WIDTH 1 |
| 167 | #define P0_X_TRST_LBN 6 |
| 168 | #define P0_X_TRST_WIDTH 1 |
| 169 | #define P0_DSP_RESET_LBN 7 |
| 170 | #define P0_DSP_RESET_WIDTH 1 |
| 171 | |
| 172 | #define P1_IN 0x01 |
| 173 | #define P1_OUT 0x03 |
| 174 | #define P1_INVERT 0x05 |
| 175 | #define P1_CONFIG 0x07 |
| 176 | |
| 177 | #define P1_AFE_PWD_LBN 0 |
| 178 | #define P1_AFE_PWD_WIDTH 1 |
| 179 | #define P1_DSP_PWD25_LBN 1 |
| 180 | #define P1_DSP_PWD25_WIDTH 1 |
| 181 | #define P1_RESERVED_LBN 2 |
| 182 | #define P1_RESERVED_WIDTH 2 |
| 183 | #define P1_SPARE_LBN 4 |
| 184 | #define P1_SPARE_WIDTH 4 |
| 185 | |
| 186 | /* Temperature Sensor */ |
| 187 | #define MAX664X_REG_RSL 0x02 |
| 188 | #define MAX664X_REG_WLHO 0x0B |
| 189 | |
| 190 | static void sfe4001_poweroff(struct efx_nic *efx) |
| 191 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 192 | struct i2c_client *ioexp_client = falcon_board(efx)->ioexp_client; |
| 193 | struct i2c_client *hwmon_client = falcon_board(efx)->hwmon_client; |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 194 | |
| 195 | /* Turn off all power rails and disable outputs */ |
| 196 | i2c_smbus_write_byte_data(ioexp_client, P0_OUT, 0xff); |
| 197 | i2c_smbus_write_byte_data(ioexp_client, P1_CONFIG, 0xff); |
| 198 | i2c_smbus_write_byte_data(ioexp_client, P0_CONFIG, 0xff); |
| 199 | |
| 200 | /* Clear any over-temperature alert */ |
| 201 | i2c_smbus_read_byte_data(hwmon_client, MAX664X_REG_RSL); |
| 202 | } |
| 203 | |
| 204 | static int sfe4001_poweron(struct efx_nic *efx) |
| 205 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 206 | struct i2c_client *ioexp_client = falcon_board(efx)->ioexp_client; |
| 207 | struct i2c_client *hwmon_client = falcon_board(efx)->hwmon_client; |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 208 | unsigned int i, j; |
| 209 | int rc; |
| 210 | u8 out; |
| 211 | |
| 212 | /* Clear any previous over-temperature alert */ |
| 213 | rc = i2c_smbus_read_byte_data(hwmon_client, MAX664X_REG_RSL); |
| 214 | if (rc < 0) |
| 215 | return rc; |
| 216 | |
| 217 | /* Enable port 0 and port 1 outputs on IO expander */ |
| 218 | rc = i2c_smbus_write_byte_data(ioexp_client, P0_CONFIG, 0x00); |
| 219 | if (rc) |
| 220 | return rc; |
| 221 | rc = i2c_smbus_write_byte_data(ioexp_client, P1_CONFIG, |
| 222 | 0xff & ~(1 << P1_SPARE_LBN)); |
| 223 | if (rc) |
| 224 | goto fail_on; |
| 225 | |
| 226 | /* If PHY power is on, turn it all off and wait 1 second to |
| 227 | * ensure a full reset. |
| 228 | */ |
| 229 | rc = i2c_smbus_read_byte_data(ioexp_client, P0_OUT); |
| 230 | if (rc < 0) |
| 231 | goto fail_on; |
| 232 | out = 0xff & ~((0 << P0_EN_1V2_LBN) | (0 << P0_EN_2V5_LBN) | |
| 233 | (0 << P0_EN_3V3X_LBN) | (0 << P0_EN_5V_LBN) | |
| 234 | (0 << P0_EN_1V0X_LBN)); |
| 235 | if (rc != out) { |
| 236 | EFX_INFO(efx, "power-cycling PHY\n"); |
| 237 | rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out); |
| 238 | if (rc) |
| 239 | goto fail_on; |
| 240 | schedule_timeout_uninterruptible(HZ); |
| 241 | } |
| 242 | |
| 243 | for (i = 0; i < 20; ++i) { |
| 244 | /* Turn on 1.2V, 2.5V, 3.3V and 5V power rails */ |
| 245 | out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) | |
| 246 | (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) | |
| 247 | (1 << P0_X_TRST_LBN)); |
| 248 | if (efx->phy_mode & PHY_MODE_SPECIAL) |
| 249 | out |= 1 << P0_EN_3V3X_LBN; |
| 250 | |
| 251 | rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out); |
| 252 | if (rc) |
| 253 | goto fail_on; |
| 254 | msleep(10); |
| 255 | |
| 256 | /* Turn on 1V power rail */ |
| 257 | out &= ~(1 << P0_EN_1V0X_LBN); |
| 258 | rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out); |
| 259 | if (rc) |
| 260 | goto fail_on; |
| 261 | |
| 262 | EFX_INFO(efx, "waiting for DSP boot (attempt %d)...\n", i); |
| 263 | |
| 264 | /* In flash config mode, DSP does not turn on AFE, so |
| 265 | * just wait 1 second. |
| 266 | */ |
| 267 | if (efx->phy_mode & PHY_MODE_SPECIAL) { |
| 268 | schedule_timeout_uninterruptible(HZ); |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | for (j = 0; j < 10; ++j) { |
| 273 | msleep(100); |
| 274 | |
| 275 | /* Check DSP has asserted AFE power line */ |
| 276 | rc = i2c_smbus_read_byte_data(ioexp_client, P1_IN); |
| 277 | if (rc < 0) |
| 278 | goto fail_on; |
| 279 | if (rc & (1 << P1_AFE_PWD_LBN)) |
| 280 | return 0; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | EFX_INFO(efx, "timed out waiting for DSP boot\n"); |
| 285 | rc = -ETIMEDOUT; |
| 286 | fail_on: |
| 287 | sfe4001_poweroff(efx); |
| 288 | return rc; |
| 289 | } |
| 290 | |
| 291 | static int sfn4111t_reset(struct efx_nic *efx) |
| 292 | { |
| 293 | efx_oword_t reg; |
| 294 | |
| 295 | /* GPIO 3 and the GPIO register are shared with I2C, so block that */ |
David S. Miller | 3505d1a | 2009-11-18 22:19:03 -0800 | [diff] [blame] | 296 | i2c_lock_adapter(&efx->i2c_adap); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 297 | |
| 298 | /* Pull RST_N (GPIO 2) low then let it up again, setting the |
| 299 | * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the |
| 300 | * output enables; the output levels should always be 0 (low) |
| 301 | * and we rely on external pull-ups. */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 302 | efx_reado(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 303 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GPIO2_OEN, true); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 304 | efx_writeo(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 305 | msleep(1000); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 306 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GPIO2_OEN, false); |
| 307 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GPIO3_OEN, |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 308 | !!(efx->phy_mode & PHY_MODE_SPECIAL)); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 309 | efx_writeo(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 310 | msleep(1); |
| 311 | |
David S. Miller | 3505d1a | 2009-11-18 22:19:03 -0800 | [diff] [blame] | 312 | i2c_unlock_adapter(&efx->i2c_adap); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 313 | |
| 314 | ssleep(1); |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | static ssize_t show_phy_flash_cfg(struct device *dev, |
| 319 | struct device_attribute *attr, char *buf) |
| 320 | { |
| 321 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); |
| 322 | return sprintf(buf, "%d\n", !!(efx->phy_mode & PHY_MODE_SPECIAL)); |
| 323 | } |
| 324 | |
| 325 | static ssize_t set_phy_flash_cfg(struct device *dev, |
| 326 | struct device_attribute *attr, |
| 327 | const char *buf, size_t count) |
| 328 | { |
| 329 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); |
| 330 | enum efx_phy_mode old_mode, new_mode; |
| 331 | int err; |
| 332 | |
| 333 | rtnl_lock(); |
| 334 | old_mode = efx->phy_mode; |
| 335 | if (count == 0 || *buf == '0') |
| 336 | new_mode = old_mode & ~PHY_MODE_SPECIAL; |
| 337 | else |
| 338 | new_mode = PHY_MODE_SPECIAL; |
| 339 | if (old_mode == new_mode) { |
| 340 | err = 0; |
| 341 | } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) { |
| 342 | err = -EBUSY; |
| 343 | } else { |
| 344 | /* Reset the PHY, reconfigure the MAC and enable/disable |
| 345 | * MAC stats accordingly. */ |
| 346 | efx->phy_mode = new_mode; |
| 347 | if (new_mode & PHY_MODE_SPECIAL) |
| 348 | efx_stats_disable(efx); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 349 | if (falcon_board(efx)->type == FALCON_BOARD_SFE4001) |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 350 | err = sfe4001_poweron(efx); |
| 351 | else |
| 352 | err = sfn4111t_reset(efx); |
| 353 | efx_reconfigure_port(efx); |
| 354 | if (!(new_mode & PHY_MODE_SPECIAL)) |
| 355 | efx_stats_enable(efx); |
| 356 | } |
| 357 | rtnl_unlock(); |
| 358 | |
| 359 | return err ? err : count; |
| 360 | } |
| 361 | |
| 362 | static DEVICE_ATTR(phy_flash_cfg, 0644, show_phy_flash_cfg, set_phy_flash_cfg); |
| 363 | |
| 364 | static void sfe4001_fini(struct efx_nic *efx) |
| 365 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 366 | struct falcon_board *board = falcon_board(efx); |
| 367 | |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 368 | EFX_INFO(efx, "%s\n", __func__); |
| 369 | |
| 370 | device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); |
| 371 | sfe4001_poweroff(efx); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 372 | i2c_unregister_device(board->ioexp_client); |
| 373 | i2c_unregister_device(board->hwmon_client); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | static int sfe4001_check_hw(struct efx_nic *efx) |
| 377 | { |
| 378 | s32 status; |
| 379 | |
| 380 | /* If XAUI link is up then do not monitor */ |
| 381 | if (EFX_WORKAROUND_7884(efx) && efx->mac_up) |
| 382 | return 0; |
| 383 | |
| 384 | /* Check the powered status of the PHY. Lack of power implies that |
| 385 | * the MAX6647 has shut down power to it, probably due to a temp. |
| 386 | * alarm. Reading the power status rather than the MAX6647 status |
| 387 | * directly because the later is read-to-clear and would thus |
| 388 | * start to power up the PHY again when polled, causing us to blip |
| 389 | * the power undesirably. |
| 390 | * We know we can read from the IO expander because we did |
| 391 | * it during power-on. Assume failure now is bad news. */ |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 392 | status = i2c_smbus_read_byte_data(falcon_board(efx)->ioexp_client, P1_IN); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 393 | if (status >= 0 && |
| 394 | (status & ((1 << P1_AFE_PWD_LBN) | (1 << P1_DSP_PWD25_LBN))) != 0) |
| 395 | return 0; |
| 396 | |
| 397 | /* Use board power control, not PHY power control */ |
| 398 | sfe4001_poweroff(efx); |
| 399 | efx->phy_mode = PHY_MODE_OFF; |
| 400 | |
| 401 | return (status < 0) ? -EIO : -ERANGE; |
| 402 | } |
| 403 | |
| 404 | static struct i2c_board_info sfe4001_hwmon_info = { |
| 405 | I2C_BOARD_INFO("max6647", 0x4e), |
| 406 | }; |
| 407 | |
| 408 | /* This board uses an I2C expander to provider power to the PHY, which needs to |
| 409 | * be turned on before the PHY can be used. |
| 410 | * Context: Process context, rtnl lock held |
| 411 | */ |
| 412 | static int sfe4001_init(struct efx_nic *efx) |
| 413 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 414 | struct falcon_board *board = falcon_board(efx); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 415 | int rc; |
| 416 | |
| 417 | #if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE) |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 418 | board->hwmon_client = |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 419 | i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info); |
| 420 | #else |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 421 | board->hwmon_client = |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 422 | i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr); |
| 423 | #endif |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 424 | if (!board->hwmon_client) |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 425 | return -EIO; |
| 426 | |
| 427 | /* Raise board/PHY high limit from 85 to 90 degrees Celsius */ |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 428 | rc = i2c_smbus_write_byte_data(board->hwmon_client, |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 429 | MAX664X_REG_WLHO, 90); |
| 430 | if (rc) |
| 431 | goto fail_hwmon; |
| 432 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 433 | board->ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539); |
| 434 | if (!board->ioexp_client) { |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 435 | rc = -EIO; |
| 436 | goto fail_hwmon; |
| 437 | } |
| 438 | |
| 439 | /* 10Xpress has fixed-function LED pins, so there is no board-specific |
| 440 | * blink code. */ |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 441 | board->set_id_led = tenxpress_set_id_led; |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 442 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 443 | board->monitor = sfe4001_check_hw; |
| 444 | board->fini = sfe4001_fini; |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 445 | |
| 446 | if (efx->phy_mode & PHY_MODE_SPECIAL) { |
| 447 | /* PHY won't generate a 156.25 MHz clock and MAC stats fetch |
| 448 | * will fail. */ |
| 449 | efx_stats_disable(efx); |
| 450 | } |
| 451 | rc = sfe4001_poweron(efx); |
| 452 | if (rc) |
| 453 | goto fail_ioexp; |
| 454 | |
| 455 | rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); |
| 456 | if (rc) |
| 457 | goto fail_on; |
| 458 | |
| 459 | EFX_INFO(efx, "PHY is powered on\n"); |
| 460 | return 0; |
| 461 | |
| 462 | fail_on: |
| 463 | sfe4001_poweroff(efx); |
| 464 | fail_ioexp: |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 465 | i2c_unregister_device(board->ioexp_client); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 466 | fail_hwmon: |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 467 | i2c_unregister_device(board->hwmon_client); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 468 | return rc; |
| 469 | } |
| 470 | |
| 471 | static int sfn4111t_check_hw(struct efx_nic *efx) |
| 472 | { |
| 473 | s32 status; |
| 474 | |
| 475 | /* If XAUI link is up then do not monitor */ |
| 476 | if (EFX_WORKAROUND_7884(efx) && efx->mac_up) |
| 477 | return 0; |
| 478 | |
| 479 | /* Test LHIGH, RHIGH, FAULT, EOT and IOT alarms */ |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 480 | status = i2c_smbus_read_byte_data(falcon_board(efx)->hwmon_client, |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 481 | MAX664X_REG_RSL); |
| 482 | if (status < 0) |
| 483 | return -EIO; |
| 484 | if (status & 0x57) |
| 485 | return -ERANGE; |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | static void sfn4111t_fini(struct efx_nic *efx) |
| 490 | { |
| 491 | EFX_INFO(efx, "%s\n", __func__); |
| 492 | |
| 493 | device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 494 | i2c_unregister_device(falcon_board(efx)->hwmon_client); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | static struct i2c_board_info sfn4111t_a0_hwmon_info = { |
| 498 | I2C_BOARD_INFO("max6647", 0x4e), |
| 499 | }; |
| 500 | |
| 501 | static struct i2c_board_info sfn4111t_r5_hwmon_info = { |
| 502 | I2C_BOARD_INFO("max6646", 0x4d), |
| 503 | }; |
| 504 | |
Ben Hutchings | 981fc1b4 | 2009-11-23 16:04:23 +0000 | [diff] [blame] | 505 | static void sfn4111t_init_phy(struct efx_nic *efx) |
| 506 | { |
| 507 | if (!(efx->phy_mode & PHY_MODE_SPECIAL)) { |
| 508 | if (sft9001_wait_boot(efx) != -EINVAL) |
| 509 | return; |
| 510 | |
| 511 | efx->phy_mode = PHY_MODE_SPECIAL; |
| 512 | efx_stats_disable(efx); |
| 513 | } |
| 514 | |
| 515 | sfn4111t_reset(efx); |
| 516 | sft9001_wait_boot(efx); |
| 517 | } |
| 518 | |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 519 | static int sfn4111t_init(struct efx_nic *efx) |
| 520 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 521 | struct falcon_board *board = falcon_board(efx); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 522 | int rc; |
| 523 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 524 | board->hwmon_client = |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 525 | i2c_new_device(&efx->i2c_adap, |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 526 | (board->minor < 5) ? |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 527 | &sfn4111t_a0_hwmon_info : |
| 528 | &sfn4111t_r5_hwmon_info); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 529 | if (!board->hwmon_client) |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 530 | return -EIO; |
| 531 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 532 | board->init_phy = sfn4111t_init_phy; |
| 533 | board->set_id_led = tenxpress_set_id_led; |
| 534 | board->monitor = sfn4111t_check_hw; |
| 535 | board->fini = sfn4111t_fini; |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 536 | |
| 537 | rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); |
| 538 | if (rc) |
| 539 | goto fail_hwmon; |
| 540 | |
Ben Hutchings | 981fc1b4 | 2009-11-23 16:04:23 +0000 | [diff] [blame] | 541 | if (efx->phy_mode & PHY_MODE_SPECIAL) |
| 542 | /* PHY may not generate a 156.25 MHz clock and MAC |
| 543 | * stats fetch will fail. */ |
| 544 | efx_stats_disable(efx); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 545 | |
Ben Hutchings | 981fc1b4 | 2009-11-23 16:04:23 +0000 | [diff] [blame] | 546 | return 0; |
| 547 | |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 548 | fail_hwmon: |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 549 | i2c_unregister_device(board->hwmon_client); |
Ben Hutchings | c9597d4 | 2009-10-23 08:29:33 +0000 | [diff] [blame] | 550 | return rc; |
| 551 | } |
| 552 | |
| 553 | /***************************************************************************** |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 554 | * Support for the SFE4002 |
| 555 | * |
| 556 | */ |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 557 | static u8 sfe4002_lm87_channel = 0x03; /* use AIN not FAN inputs */ |
| 558 | |
| 559 | static const u8 sfe4002_lm87_regs[] = { |
| 560 | LM87_IN_LIMITS(0, 0x83, 0x91), /* 2.5V: 1.8V +/- 5% */ |
| 561 | LM87_IN_LIMITS(1, 0x51, 0x5a), /* Vccp1: 1.2V +/- 5% */ |
| 562 | LM87_IN_LIMITS(2, 0xb6, 0xca), /* 3.3V: 3.3V +/- 5% */ |
| 563 | LM87_IN_LIMITS(3, 0xb0, 0xc9), /* 5V: 4.6-5.2V */ |
| 564 | LM87_IN_LIMITS(4, 0xb0, 0xe0), /* 12V: 11-14V */ |
| 565 | LM87_IN_LIMITS(5, 0x44, 0x4b), /* Vccp2: 1.0V +/- 5% */ |
| 566 | LM87_AIN_LIMITS(0, 0xa0, 0xb2), /* AIN1: 1.66V +/- 5% */ |
| 567 | LM87_AIN_LIMITS(1, 0x91, 0xa1), /* AIN2: 1.5V +/- 5% */ |
| 568 | LM87_TEMP_INT_LIMITS(10, 60), /* board */ |
| 569 | LM87_TEMP_EXT1_LIMITS(10, 70), /* Falcon */ |
| 570 | 0 |
| 571 | }; |
| 572 | |
| 573 | static struct i2c_board_info sfe4002_hwmon_info = { |
| 574 | I2C_BOARD_INFO("lm87", 0x2e), |
| 575 | .platform_data = &sfe4002_lm87_channel, |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 576 | }; |
| 577 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 578 | /****************************************************************************/ |
| 579 | /* LED allocations. Note that on rev A0 boards the schematic and the reality |
| 580 | * differ: red and green are swapped. Below is the fixed (A1) layout (there |
| 581 | * are only 3 A0 boards in existence, so no real reason to make this |
| 582 | * conditional). |
| 583 | */ |
| 584 | #define SFE4002_FAULT_LED (2) /* Red */ |
| 585 | #define SFE4002_RX_LED (0) /* Green */ |
| 586 | #define SFE4002_TX_LED (1) /* Amber */ |
| 587 | |
Ben Hutchings | 981fc1b4 | 2009-11-23 16:04:23 +0000 | [diff] [blame] | 588 | static void sfe4002_init_phy(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 589 | { |
| 590 | /* Set the TX and RX LEDs to reflect status and activity, and the |
| 591 | * fault LED off */ |
Ben Hutchings | b37b62f | 2009-10-23 08:33:42 +0000 | [diff] [blame] | 592 | falcon_qt202x_set_led(efx, SFE4002_TX_LED, |
| 593 | QUAKE_LED_TXLINK | QUAKE_LED_LINK_ACTSTAT); |
| 594 | falcon_qt202x_set_led(efx, SFE4002_RX_LED, |
| 595 | QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACTSTAT); |
| 596 | falcon_qt202x_set_led(efx, SFE4002_FAULT_LED, QUAKE_LED_OFF); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 597 | } |
| 598 | |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 599 | static void sfe4002_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 600 | { |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 601 | falcon_qt202x_set_led( |
| 602 | efx, SFE4002_FAULT_LED, |
| 603 | (mode == EFX_LED_ON) ? QUAKE_LED_ON : QUAKE_LED_OFF); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 604 | } |
| 605 | |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 606 | static int sfe4002_check_hw(struct efx_nic *efx) |
| 607 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 608 | struct falcon_board *board = falcon_board(efx); |
| 609 | |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 610 | /* A0 board rev. 4002s report a temperature fault the whole time |
| 611 | * (bad sensor) so we mask it out. */ |
| 612 | unsigned alarm_mask = |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 613 | (board->major == 0 && board->minor == 0) ? |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 614 | ~LM87_ALARM_TEMP_EXT1 : ~0; |
| 615 | |
| 616 | return efx_check_lm87(efx, alarm_mask); |
| 617 | } |
| 618 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 619 | static int sfe4002_init(struct efx_nic *efx) |
| 620 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 621 | struct falcon_board *board = falcon_board(efx); |
Ben Hutchings | 3e133c4 | 2008-11-04 20:34:56 +0000 | [diff] [blame] | 622 | int rc = efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs); |
| 623 | if (rc) |
| 624 | return rc; |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 625 | board->monitor = sfe4002_check_hw; |
| 626 | board->init_phy = sfe4002_init_phy; |
| 627 | board->set_id_led = sfe4002_set_id_led; |
| 628 | board->fini = efx_fini_lm87; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 629 | return 0; |
| 630 | } |
| 631 | |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 632 | /***************************************************************************** |
| 633 | * Support for the SFN4112F |
| 634 | * |
| 635 | */ |
| 636 | static u8 sfn4112f_lm87_channel = 0x03; /* use AIN not FAN inputs */ |
| 637 | |
| 638 | static const u8 sfn4112f_lm87_regs[] = { |
| 639 | LM87_IN_LIMITS(0, 0x83, 0x91), /* 2.5V: 1.8V +/- 5% */ |
| 640 | LM87_IN_LIMITS(1, 0x51, 0x5a), /* Vccp1: 1.2V +/- 5% */ |
| 641 | LM87_IN_LIMITS(2, 0xb6, 0xca), /* 3.3V: 3.3V +/- 5% */ |
| 642 | LM87_IN_LIMITS(4, 0xb0, 0xe0), /* 12V: 11-14V */ |
| 643 | LM87_IN_LIMITS(5, 0x44, 0x4b), /* Vccp2: 1.0V +/- 5% */ |
| 644 | LM87_AIN_LIMITS(1, 0x91, 0xa1), /* AIN2: 1.5V +/- 5% */ |
| 645 | LM87_TEMP_INT_LIMITS(10, 60), /* board */ |
| 646 | LM87_TEMP_EXT1_LIMITS(10, 70), /* Falcon */ |
| 647 | 0 |
| 648 | }; |
| 649 | |
| 650 | static struct i2c_board_info sfn4112f_hwmon_info = { |
| 651 | I2C_BOARD_INFO("lm87", 0x2e), |
| 652 | .platform_data = &sfn4112f_lm87_channel, |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 653 | }; |
| 654 | |
| 655 | #define SFN4112F_ACT_LED 0 |
| 656 | #define SFN4112F_LINK_LED 1 |
| 657 | |
Ben Hutchings | 981fc1b4 | 2009-11-23 16:04:23 +0000 | [diff] [blame] | 658 | static void sfn4112f_init_phy(struct efx_nic *efx) |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 659 | { |
Ben Hutchings | b37b62f | 2009-10-23 08:33:42 +0000 | [diff] [blame] | 660 | falcon_qt202x_set_led(efx, SFN4112F_ACT_LED, |
| 661 | QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACT); |
| 662 | falcon_qt202x_set_led(efx, SFN4112F_LINK_LED, |
| 663 | QUAKE_LED_RXLINK | QUAKE_LED_LINK_STAT); |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 666 | static void sfn4112f_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 667 | { |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 668 | int reg; |
| 669 | |
| 670 | switch (mode) { |
| 671 | case EFX_LED_OFF: |
| 672 | reg = QUAKE_LED_OFF; |
| 673 | break; |
| 674 | case EFX_LED_ON: |
| 675 | reg = QUAKE_LED_ON; |
| 676 | break; |
| 677 | default: |
| 678 | reg = QUAKE_LED_RXLINK | QUAKE_LED_LINK_STAT; |
| 679 | break; |
| 680 | } |
| 681 | |
| 682 | falcon_qt202x_set_led(efx, SFN4112F_LINK_LED, reg); |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | static int sfn4112f_check_hw(struct efx_nic *efx) |
| 686 | { |
| 687 | /* Mask out unused sensors */ |
| 688 | return efx_check_lm87(efx, ~0x48); |
| 689 | } |
| 690 | |
| 691 | static int sfn4112f_init(struct efx_nic *efx) |
| 692 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 693 | struct falcon_board *board = falcon_board(efx); |
| 694 | |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 695 | int rc = efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs); |
| 696 | if (rc) |
| 697 | return rc; |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 698 | board->monitor = sfn4112f_check_hw; |
| 699 | board->init_phy = sfn4112f_init_phy; |
| 700 | board->set_id_led = sfn4112f_set_id_led; |
| 701 | board->fini = efx_fini_lm87; |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 702 | return 0; |
| 703 | } |
| 704 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 705 | /* This will get expanded as board-specific details get moved out of the |
| 706 | * PHY drivers. */ |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 707 | struct falcon_board_data { |
| 708 | u8 type; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 709 | const char *ref_model; |
| 710 | const char *gen_type; |
| 711 | int (*init) (struct efx_nic *nic); |
| 712 | }; |
| 713 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 714 | |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 715 | static struct falcon_board_data board_data[] = { |
| 716 | { FALCON_BOARD_SFE4001, "SFE4001", "10GBASE-T adapter", sfe4001_init }, |
| 717 | { FALCON_BOARD_SFE4002, "SFE4002", "XFP adapter", sfe4002_init }, |
| 718 | { FALCON_BOARD_SFN4111T, "SFN4111T", "100/1000/10GBASE-T adapter", |
Ben Hutchings | 6f158d5 | 2008-12-12 22:00:49 -0800 | [diff] [blame] | 719 | sfn4111t_init }, |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 720 | { FALCON_BOARD_SFN4112F, "SFN4112F", "SFP+ adapter", |
Ben Hutchings | 94f52cd | 2009-02-27 13:08:18 +0000 | [diff] [blame] | 721 | sfn4112f_init }, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 722 | }; |
| 723 | |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 724 | void falcon_probe_board(struct efx_nic *efx, u16 revision_info) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 725 | { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 726 | struct falcon_board *board = falcon_board(efx); |
Ben Hutchings | 3473a5b | 2009-10-23 08:29:16 +0000 | [diff] [blame] | 727 | struct falcon_board_data *data = NULL; |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 728 | int i; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 729 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 730 | board->type = FALCON_BOARD_TYPE(revision_info); |
| 731 | board->major = FALCON_BOARD_MAJOR(revision_info); |
| 732 | board->minor = FALCON_BOARD_MINOR(revision_info); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 733 | |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 734 | for (i = 0; i < ARRAY_SIZE(board_data); i++) |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 735 | if (board_data[i].type == board->type) |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 736 | data = &board_data[i]; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 737 | |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 738 | if (data) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 739 | EFX_INFO(efx, "board is %s rev %c%d\n", |
| 740 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) |
| 741 | ? data->ref_model : data->gen_type, |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 742 | 'A' + board->major, board->minor); |
| 743 | board->init = data->init; |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 744 | } else { |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 745 | EFX_ERR(efx, "unknown board type %d\n", board->type); |
Ben Hutchings | 04300d2 | 2008-12-12 21:48:09 -0800 | [diff] [blame] | 746 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 747 | } |