aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-23 11:06:02 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-24 13:58:52 -0500
commite775fb93a880d218ce0b3fd405278dd78f86c405 (patch)
tree5f5c31161f7f11a9611481396de92964e2fdaaae /drivers/net/sfc
parent3759433db2f7340ddec3abd55ebb1178600d014e (diff)
sfc: Move all I2C stuff into struct falcon_board
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/falcon.c26
-rw-r--r--drivers/net/sfc/falcon.h6
-rw-r--r--drivers/net/sfc/falcon_boards.c18
-rw-r--r--drivers/net/sfc/net_driver.h3
4 files changed, 29 insertions, 24 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 490bda0d010e..ff15b9dd3618 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -2799,6 +2799,7 @@ static void falcon_probe_spi_devices(struct efx_nic *efx)
2799int falcon_probe_nic(struct efx_nic *efx) 2799int falcon_probe_nic(struct efx_nic *efx)
2800{ 2800{
2801 struct falcon_nic_data *nic_data; 2801 struct falcon_nic_data *nic_data;
2802 struct falcon_board *board;
2802 int rc; 2803 int rc;
2803 2804
2804 /* Allocate storage for hardware specific data */ 2805 /* Allocate storage for hardware specific data */
@@ -2856,13 +2857,15 @@ int falcon_probe_nic(struct efx_nic *efx)
2856 goto fail5; 2857 goto fail5;
2857 2858
2858 /* Initialise I2C adapter */ 2859 /* Initialise I2C adapter */
2859 efx->i2c_adap.owner = THIS_MODULE; 2860 board = falcon_board(efx);
2860 nic_data->i2c_data = falcon_i2c_bit_operations; 2861 board->i2c_adap.owner = THIS_MODULE;
2861 nic_data->i2c_data.data = efx; 2862 board->i2c_data = falcon_i2c_bit_operations;
2862 efx->i2c_adap.algo_data = &nic_data->i2c_data; 2863 board->i2c_data.data = efx;
2863 efx->i2c_adap.dev.parent = &efx->pci_dev->dev; 2864 board->i2c_adap.algo_data = &board->i2c_data;
2864 strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name)); 2865 board->i2c_adap.dev.parent = &efx->pci_dev->dev;
2865 rc = i2c_bit_add_bus(&efx->i2c_adap); 2866 strlcpy(board->i2c_adap.name, "SFC4000 GPIO",
2867 sizeof(board->i2c_adap.name));
2868 rc = i2c_bit_add_bus(&board->i2c_adap);
2866 if (rc) 2869 if (rc)
2867 goto fail5; 2870 goto fail5;
2868 2871
@@ -2875,8 +2878,8 @@ int falcon_probe_nic(struct efx_nic *efx)
2875 return 0; 2878 return 0;
2876 2879
2877 fail6: 2880 fail6:
2878 BUG_ON(i2c_del_adapter(&efx->i2c_adap)); 2881 BUG_ON(i2c_del_adapter(&board->i2c_adap));
2879 memset(&efx->i2c_adap, 0, sizeof(efx->i2c_adap)); 2882 memset(&board->i2c_adap, 0, sizeof(board->i2c_adap));
2880 fail5: 2883 fail5:
2881 falcon_remove_spi_devices(efx); 2884 falcon_remove_spi_devices(efx);
2882 falcon_free_buffer(efx, &efx->irq_status); 2885 falcon_free_buffer(efx, &efx->irq_status);
@@ -3066,14 +3069,15 @@ int falcon_init_nic(struct efx_nic *efx)
3066void falcon_remove_nic(struct efx_nic *efx) 3069void falcon_remove_nic(struct efx_nic *efx)
3067{ 3070{
3068 struct falcon_nic_data *nic_data = efx->nic_data; 3071 struct falcon_nic_data *nic_data = efx->nic_data;
3072 struct falcon_board *board = falcon_board(efx);
3069 int rc; 3073 int rc;
3070 3074
3071 falcon_board(efx)->fini(efx); 3075 falcon_board(efx)->fini(efx);
3072 3076
3073 /* Remove I2C adapter and clear it in preparation for a retry */ 3077 /* Remove I2C adapter and clear it in preparation for a retry */
3074 rc = i2c_del_adapter(&efx->i2c_adap); 3078 rc = i2c_del_adapter(&board->i2c_adap);
3075 BUG_ON(rc); 3079 BUG_ON(rc);
3076 memset(&efx->i2c_adap, 0, sizeof(efx->i2c_adap)); 3080 memset(&board->i2c_adap, 0, sizeof(board->i2c_adap));
3077 3081
3078 falcon_remove_spi_devices(efx); 3082 falcon_remove_spi_devices(efx);
3079 falcon_free_buffer(efx, &efx->irq_status); 3083 falcon_free_buffer(efx, &efx->irq_status);
diff --git a/drivers/net/sfc/falcon.h b/drivers/net/sfc/falcon.h
index 3e9696c12caa..0da5ea7908b0 100644
--- a/drivers/net/sfc/falcon.h
+++ b/drivers/net/sfc/falcon.h
@@ -40,6 +40,8 @@ static inline int falcon_rev(struct efx_nic *efx)
40 * @set_id_led: Set state of identifying LED or revert to automatic function 40 * @set_id_led: Set state of identifying LED or revert to automatic function
41 * @monitor: Board-specific health check function 41 * @monitor: Board-specific health check function
42 * @fini: Shut down hardware and free resources 42 * @fini: Shut down hardware and free resources
43 * @i2c_adap: I2C adapter for on-board peripherals
44 * @i2c_data: Data for bit-banging algorithm
43 * @hwmon_client: I2C client for hardware monitor 45 * @hwmon_client: I2C client for hardware monitor
44 * @ioexp_client: I2C client for power/port control 46 * @ioexp_client: I2C client for power/port control
45 */ 47 */
@@ -52,18 +54,18 @@ struct falcon_board {
52 void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); 54 void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
53 int (*monitor) (struct efx_nic *nic); 55 int (*monitor) (struct efx_nic *nic);
54 void (*fini) (struct efx_nic *nic); 56 void (*fini) (struct efx_nic *nic);
57 struct i2c_adapter i2c_adap;
58 struct i2c_algo_bit_data i2c_data;
55 struct i2c_client *hwmon_client, *ioexp_client; 59 struct i2c_client *hwmon_client, *ioexp_client;
56}; 60};
57 61
58/** 62/**
59 * struct falcon_nic_data - Falcon NIC state 63 * struct falcon_nic_data - Falcon NIC state
60 * @pci_dev2: The secondary PCI device if present 64 * @pci_dev2: The secondary PCI device if present
61 * @i2c_data: Operations and state for I2C bit-bashing algorithm
62 * @board: Board state and functions 65 * @board: Board state and functions
63 */ 66 */
64struct falcon_nic_data { 67struct falcon_nic_data {
65 struct pci_dev *pci_dev2; 68 struct pci_dev *pci_dev2;
66 struct i2c_algo_bit_data i2c_data;
67 struct falcon_board board; 69 struct falcon_board board;
68}; 70};
69 71
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index 20aebe07fdf2..cdf7a0d6e386 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -51,7 +51,8 @@
51static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, 51static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
52 const u8 *reg_values) 52 const u8 *reg_values)
53{ 53{
54 struct i2c_client *client = i2c_new_device(&efx->i2c_adap, info); 54 struct falcon_board *board = falcon_board(efx);
55 struct i2c_client *client = i2c_new_device(&board->i2c_adap, info);
55 int rc; 56 int rc;
56 57
57 if (!client) 58 if (!client)
@@ -65,7 +66,7 @@ static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
65 goto err; 66 goto err;
66 } 67 }
67 68
68 falcon_board(efx)->hwmon_client = client; 69 board->hwmon_client = client;
69 return 0; 70 return 0;
70 71
71err: 72err:
@@ -290,10 +291,11 @@ fail_on:
290 291
291static int sfn4111t_reset(struct efx_nic *efx) 292static int sfn4111t_reset(struct efx_nic *efx)
292{ 293{
294 struct falcon_board *board = falcon_board(efx);
293 efx_oword_t reg; 295 efx_oword_t reg;
294 296
295 /* GPIO 3 and the GPIO register are shared with I2C, so block that */ 297 /* GPIO 3 and the GPIO register are shared with I2C, so block that */
296 i2c_lock_adapter(&efx->i2c_adap); 298 i2c_lock_adapter(&board->i2c_adap);
297 299
298 /* Pull RST_N (GPIO 2) low then let it up again, setting the 300 /* Pull RST_N (GPIO 2) low then let it up again, setting the
299 * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the 301 * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the
@@ -309,7 +311,7 @@ static int sfn4111t_reset(struct efx_nic *efx)
309 efx_writeo(efx, &reg, FR_AB_GPIO_CTL); 311 efx_writeo(efx, &reg, FR_AB_GPIO_CTL);
310 msleep(1); 312 msleep(1);
311 313
312 i2c_unlock_adapter(&efx->i2c_adap); 314 i2c_unlock_adapter(&board->i2c_adap);
313 315
314 ssleep(1); 316 ssleep(1);
315 return 0; 317 return 0;
@@ -416,10 +418,10 @@ static int sfe4001_init(struct efx_nic *efx)
416 418
417#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE) 419#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
418 board->hwmon_client = 420 board->hwmon_client =
419 i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info); 421 i2c_new_device(&board->i2c_adap, &sfe4001_hwmon_info);
420#else 422#else
421 board->hwmon_client = 423 board->hwmon_client =
422 i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr); 424 i2c_new_dummy(&board->i2c_adap, sfe4001_hwmon_info.addr);
423#endif 425#endif
424 if (!board->hwmon_client) 426 if (!board->hwmon_client)
425 return -EIO; 427 return -EIO;
@@ -430,7 +432,7 @@ static int sfe4001_init(struct efx_nic *efx)
430 if (rc) 432 if (rc)
431 goto fail_hwmon; 433 goto fail_hwmon;
432 434
433 board->ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539); 435 board->ioexp_client = i2c_new_dummy(&board->i2c_adap, PCA9539);
434 if (!board->ioexp_client) { 436 if (!board->ioexp_client) {
435 rc = -EIO; 437 rc = -EIO;
436 goto fail_hwmon; 438 goto fail_hwmon;
@@ -522,7 +524,7 @@ static int sfn4111t_init(struct efx_nic *efx)
522 int rc; 524 int rc;
523 525
524 board->hwmon_client = 526 board->hwmon_client =
525 i2c_new_device(&efx->i2c_adap, 527 i2c_new_device(&board->i2c_adap,
526 (board->minor < 5) ? 528 (board->minor < 5) ?
527 &sfn4111t_a0_hwmon_info : 529 &sfn4111t_a0_hwmon_info :
528 &sfn4111t_r5_hwmon_info); 530 &sfn4111t_r5_hwmon_info);
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index fdc9e157e513..55d45a77a107 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -639,7 +639,6 @@ union efx_multicast_hash {
639 * @interrupt_mode: Interrupt mode 639 * @interrupt_mode: Interrupt mode
640 * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues 640 * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
641 * @irq_rx_moderation: IRQ moderation time for RX event queues 641 * @irq_rx_moderation: IRQ moderation time for RX event queues
642 * @i2c_adap: I2C adapter
643 * @state: Device state flag. Serialised by the rtnl_lock. 642 * @state: Device state flag. Serialised by the rtnl_lock.
644 * @reset_pending: Pending reset method (normally RESET_TYPE_NONE) 643 * @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
645 * @tx_queue: TX DMA queues 644 * @tx_queue: TX DMA queues
@@ -725,8 +724,6 @@ struct efx_nic {
725 bool irq_rx_adaptive; 724 bool irq_rx_adaptive;
726 unsigned int irq_rx_moderation; 725 unsigned int irq_rx_moderation;
727 726
728 struct i2c_adapter i2c_adap;
729
730 enum nic_state state; 727 enum nic_state state;
731 enum reset_type reset_pending; 728 enum reset_type reset_pending;
732 729