summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-23 19:06:02 +0300
committerDavid S. Miller <davem@davemloft.net>2009-11-24 21:58:52 +0300
commite775fb93a880d218ce0b3fd405278dd78f86c405 (patch)
tree5f5c31161f7f11a9611481396de92964e2fdaaae
parent3759433db2f7340ddec3abd55ebb1178600d014e (diff)
downloadlinux-e775fb93a880d218ce0b3fd405278dd78f86c405.tar.xz
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>
-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)
int falcon_probe_nic(struct efx_nic *efx)
{
struct falcon_nic_data *nic_data;
+ struct falcon_board *board;
int rc;
/* Allocate storage for hardware specific data */
@@ -2856,13 +2857,15 @@ int falcon_probe_nic(struct efx_nic *efx)
goto fail5;
/* Initialise I2C adapter */
- efx->i2c_adap.owner = THIS_MODULE;
- nic_data->i2c_data = falcon_i2c_bit_operations;
- nic_data->i2c_data.data = efx;
- efx->i2c_adap.algo_data = &nic_data->i2c_data;
- efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
- strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
- rc = i2c_bit_add_bus(&efx->i2c_adap);
+ board = falcon_board(efx);
+ board->i2c_adap.owner = THIS_MODULE;
+ board->i2c_data = falcon_i2c_bit_operations;
+ board->i2c_data.data = efx;
+ board->i2c_adap.algo_data = &board->i2c_data;
+ board->i2c_adap.dev.parent = &efx->pci_dev->dev;
+ strlcpy(board->i2c_adap.name, "SFC4000 GPIO",
+ sizeof(board->i2c_adap.name));
+ rc = i2c_bit_add_bus(&board->i2c_adap);
if (rc)
goto fail5;
@@ -2875,8 +2878,8 @@ int falcon_probe_nic(struct efx_nic *efx)
return 0;
fail6:
- BUG_ON(i2c_del_adapter(&efx->i2c_adap));
- memset(&efx->i2c_adap, 0, sizeof(efx->i2c_adap));
+ BUG_ON(i2c_del_adapter(&board->i2c_adap));
+ memset(&board->i2c_adap, 0, sizeof(board->i2c_adap));
fail5:
falcon_remove_spi_devices(efx);
falcon_free_buffer(efx, &efx->irq_status);
@@ -3066,14 +3069,15 @@ int falcon_init_nic(struct efx_nic *efx)
void falcon_remove_nic(struct efx_nic *efx)
{
struct falcon_nic_data *nic_data = efx->nic_data;
+ struct falcon_board *board = falcon_board(efx);
int rc;
falcon_board(efx)->fini(efx);
/* Remove I2C adapter and clear it in preparation for a retry */
- rc = i2c_del_adapter(&efx->i2c_adap);
+ rc = i2c_del_adapter(&board->i2c_adap);
BUG_ON(rc);
- memset(&efx->i2c_adap, 0, sizeof(efx->i2c_adap));
+ memset(&board->i2c_adap, 0, sizeof(board->i2c_adap));
falcon_remove_spi_devices(efx);
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)
* @set_id_led: Set state of identifying LED or revert to automatic function
* @monitor: Board-specific health check function
* @fini: Shut down hardware and free resources
+ * @i2c_adap: I2C adapter for on-board peripherals
+ * @i2c_data: Data for bit-banging algorithm
* @hwmon_client: I2C client for hardware monitor
* @ioexp_client: I2C client for power/port control
*/
@@ -52,18 +54,18 @@ struct falcon_board {
void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
int (*monitor) (struct efx_nic *nic);
void (*fini) (struct efx_nic *nic);
+ struct i2c_adapter i2c_adap;
+ struct i2c_algo_bit_data i2c_data;
struct i2c_client *hwmon_client, *ioexp_client;
};
/**
* struct falcon_nic_data - Falcon NIC state
* @pci_dev2: The secondary PCI device if present
- * @i2c_data: Operations and state for I2C bit-bashing algorithm
* @board: Board state and functions
*/
struct falcon_nic_data {
struct pci_dev *pci_dev2;
- struct i2c_algo_bit_data i2c_data;
struct falcon_board board;
};
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 @@
static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
const u8 *reg_values)
{
- struct i2c_client *client = i2c_new_device(&efx->i2c_adap, info);
+ struct falcon_board *board = falcon_board(efx);
+ struct i2c_client *client = i2c_new_device(&board->i2c_adap, info);
int rc;
if (!client)
@@ -65,7 +66,7 @@ static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
goto err;
}
- falcon_board(efx)->hwmon_client = client;
+ board->hwmon_client = client;
return 0;
err:
@@ -290,10 +291,11 @@ fail_on:
static int sfn4111t_reset(struct efx_nic *efx)
{
+ struct falcon_board *board = falcon_board(efx);
efx_oword_t reg;
/* GPIO 3 and the GPIO register are shared with I2C, so block that */
- i2c_lock_adapter(&efx->i2c_adap);
+ i2c_lock_adapter(&board->i2c_adap);
/* Pull RST_N (GPIO 2) low then let it up again, setting the
* FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the
@@ -309,7 +311,7 @@ static int sfn4111t_reset(struct efx_nic *efx)
efx_writeo(efx, &reg, FR_AB_GPIO_CTL);
msleep(1);
- i2c_unlock_adapter(&efx->i2c_adap);
+ i2c_unlock_adapter(&board->i2c_adap);
ssleep(1);
return 0;
@@ -416,10 +418,10 @@ static int sfe4001_init(struct efx_nic *efx)
#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
board->hwmon_client =
- i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info);
+ i2c_new_device(&board->i2c_adap, &sfe4001_hwmon_info);
#else
board->hwmon_client =
- i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr);
+ i2c_new_dummy(&board->i2c_adap, sfe4001_hwmon_info.addr);
#endif
if (!board->hwmon_client)
return -EIO;
@@ -430,7 +432,7 @@ static int sfe4001_init(struct efx_nic *efx)
if (rc)
goto fail_hwmon;
- board->ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539);
+ board->ioexp_client = i2c_new_dummy(&board->i2c_adap, PCA9539);
if (!board->ioexp_client) {
rc = -EIO;
goto fail_hwmon;
@@ -522,7 +524,7 @@ static int sfn4111t_init(struct efx_nic *efx)
int rc;
board->hwmon_client =
- i2c_new_device(&efx->i2c_adap,
+ i2c_new_device(&board->i2c_adap,
(board->minor < 5) ?
&sfn4111t_a0_hwmon_info :
&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 {
* @interrupt_mode: Interrupt mode
* @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
* @irq_rx_moderation: IRQ moderation time for RX event queues
- * @i2c_adap: I2C adapter
* @state: Device state flag. Serialised by the rtnl_lock.
* @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
* @tx_queue: TX DMA queues
@@ -725,8 +724,6 @@ struct efx_nic {
bool irq_rx_adaptive;
unsigned int irq_rx_moderation;
- struct i2c_adapter i2c_adap;
-
enum nic_state state;
enum reset_type reset_pending;