diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2008-12-13 00:48:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-13 00:58:00 -0500 |
commit | 04300d248bd5166c00a59fa18efc1f7d041e9b32 (patch) | |
tree | e2ca573f576e5af3dbbd74e3ca6a8bdb2f9f0c2a /drivers/net/sfc/boards.c | |
parent | 06d5e19318e59f6f139b5171f4dfc5f3eb4dd897 (diff) |
sfc: Clean up board identification
Remove kluge for development boards with unspecified board type.
Remove assumption of contiguous board type code assignments.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/boards.c')
-rw-r--r-- | drivers/net/sfc/boards.c | 68 |
1 files changed, 18 insertions, 50 deletions
diff --git a/drivers/net/sfc/boards.c b/drivers/net/sfc/boards.c index edf026280bec..08fa4e35742b 100644 --- a/drivers/net/sfc/boards.c +++ b/drivers/net/sfc/boards.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * Driver for Solarflare Solarstorm network controllers and boards | 2 | * Driver for Solarflare Solarstorm network controllers and boards |
3 | * Copyright 2007 Solarflare Communications Inc. | 3 | * Copyright 2007-2008 Solarflare Communications Inc. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 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 | 6 | * under the terms of the GNU General Public License version 2 as published |
@@ -231,70 +231,38 @@ static int sfe4002_init(struct efx_nic *efx) | |||
231 | /* This will get expanded as board-specific details get moved out of the | 231 | /* This will get expanded as board-specific details get moved out of the |
232 | * PHY drivers. */ | 232 | * PHY drivers. */ |
233 | struct efx_board_data { | 233 | struct efx_board_data { |
234 | enum efx_board_type type; | ||
234 | const char *ref_model; | 235 | const char *ref_model; |
235 | const char *gen_type; | 236 | const char *gen_type; |
236 | int (*init) (struct efx_nic *nic); | 237 | int (*init) (struct efx_nic *nic); |
237 | }; | 238 | }; |
238 | 239 | ||
239 | static int dummy_init(struct efx_nic *nic) | ||
240 | { | ||
241 | return 0; | ||
242 | } | ||
243 | 240 | ||
244 | static struct efx_board_data board_data[] = { | 241 | static struct efx_board_data board_data[] = { |
245 | [EFX_BOARD_INVALID] = | 242 | { EFX_BOARD_SFE4001, "SFE4001", "10GBASE-T adapter", sfe4001_init }, |
246 | {NULL, NULL, dummy_init}, | 243 | { EFX_BOARD_SFE4002, "SFE4002", "XFP adapter", sfe4002_init }, |
247 | [EFX_BOARD_SFE4001] = | ||
248 | {"SFE4001", "10GBASE-T adapter", sfe4001_init}, | ||
249 | [EFX_BOARD_SFE4002] = | ||
250 | {"SFE4002", "XFP adapter", sfe4002_init}, | ||
251 | }; | 244 | }; |
252 | 245 | ||
253 | int efx_set_board_info(struct efx_nic *efx, u16 revision_info) | 246 | void efx_set_board_info(struct efx_nic *efx, u16 revision_info) |
254 | { | 247 | { |
255 | int rc = 0; | 248 | struct efx_board_data *data = NULL; |
256 | struct efx_board_data *data; | 249 | int i; |
257 | 250 | ||
258 | if (BOARD_TYPE(revision_info) >= EFX_BOARD_MAX) { | 251 | efx->board_info.type = BOARD_TYPE(revision_info); |
259 | EFX_ERR(efx, "squashing unknown board type %d\n", | 252 | efx->board_info.major = BOARD_MAJOR(revision_info); |
260 | BOARD_TYPE(revision_info)); | 253 | efx->board_info.minor = BOARD_MINOR(revision_info); |
261 | revision_info = 0; | ||
262 | } | ||
263 | |||
264 | if (BOARD_TYPE(revision_info) == 0) { | ||
265 | efx->board_info.major = 0; | ||
266 | efx->board_info.minor = 0; | ||
267 | /* For early boards that don't have revision info. there is | ||
268 | * only 1 board for each PHY type, so we can work it out, with | ||
269 | * the exception of the PHY-less boards. */ | ||
270 | switch (efx->phy_type) { | ||
271 | case PHY_TYPE_10XPRESS: | ||
272 | efx->board_info.type = EFX_BOARD_SFE4001; | ||
273 | break; | ||
274 | case PHY_TYPE_XFP: | ||
275 | efx->board_info.type = EFX_BOARD_SFE4002; | ||
276 | break; | ||
277 | default: | ||
278 | efx->board_info.type = 0; | ||
279 | break; | ||
280 | } | ||
281 | } else { | ||
282 | efx->board_info.type = BOARD_TYPE(revision_info); | ||
283 | efx->board_info.major = BOARD_MAJOR(revision_info); | ||
284 | efx->board_info.minor = BOARD_MINOR(revision_info); | ||
285 | } | ||
286 | 254 | ||
287 | data = &board_data[efx->board_info.type]; | 255 | for (i = 0; i < ARRAY_SIZE(board_data); i++) |
256 | if (board_data[i].type == efx->board_info.type) | ||
257 | data = &board_data[i]; | ||
288 | 258 | ||
289 | /* Report the board model number or generic type for recognisable | 259 | if (data) { |
290 | * boards. */ | ||
291 | if (efx->board_info.type != 0) | ||
292 | EFX_INFO(efx, "board is %s rev %c%d\n", | 260 | EFX_INFO(efx, "board is %s rev %c%d\n", |
293 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) | 261 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) |
294 | ? data->ref_model : data->gen_type, | 262 | ? data->ref_model : data->gen_type, |
295 | 'A' + efx->board_info.major, efx->board_info.minor); | 263 | 'A' + efx->board_info.major, efx->board_info.minor); |
296 | 264 | efx->board_info.init = data->init; | |
297 | efx->board_info.init = data->init; | 265 | } else { |
298 | 266 | EFX_ERR(efx, "unknown board type %d\n", efx->board_info.type); | |
299 | return rc; | 267 | } |
300 | } | 268 | } |