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>
This commit is contained in:
parent
3759433db2
commit
e775fb93a8
@ -2799,6 +2799,7 @@ static void falcon_probe_spi_devices(struct efx_nic *efx)
|
|||||||
int falcon_probe_nic(struct efx_nic *efx)
|
int falcon_probe_nic(struct efx_nic *efx)
|
||||||
{
|
{
|
||||||
struct falcon_nic_data *nic_data;
|
struct falcon_nic_data *nic_data;
|
||||||
|
struct falcon_board *board;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Allocate storage for hardware specific data */
|
/* Allocate storage for hardware specific data */
|
||||||
@ -2856,13 +2857,15 @@ int falcon_probe_nic(struct efx_nic *efx)
|
|||||||
goto fail5;
|
goto fail5;
|
||||||
|
|
||||||
/* Initialise I2C adapter */
|
/* Initialise I2C adapter */
|
||||||
efx->i2c_adap.owner = THIS_MODULE;
|
board = falcon_board(efx);
|
||||||
nic_data->i2c_data = falcon_i2c_bit_operations;
|
board->i2c_adap.owner = THIS_MODULE;
|
||||||
nic_data->i2c_data.data = efx;
|
board->i2c_data = falcon_i2c_bit_operations;
|
||||||
efx->i2c_adap.algo_data = &nic_data->i2c_data;
|
board->i2c_data.data = efx;
|
||||||
efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
|
board->i2c_adap.algo_data = &board->i2c_data;
|
||||||
strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
|
board->i2c_adap.dev.parent = &efx->pci_dev->dev;
|
||||||
rc = i2c_bit_add_bus(&efx->i2c_adap);
|
strlcpy(board->i2c_adap.name, "SFC4000 GPIO",
|
||||||
|
sizeof(board->i2c_adap.name));
|
||||||
|
rc = i2c_bit_add_bus(&board->i2c_adap);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail5;
|
goto fail5;
|
||||||
|
|
||||||
@ -2875,8 +2878,8 @@ int falcon_probe_nic(struct efx_nic *efx)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail6:
|
fail6:
|
||||||
BUG_ON(i2c_del_adapter(&efx->i2c_adap));
|
BUG_ON(i2c_del_adapter(&board->i2c_adap));
|
||||||
memset(&efx->i2c_adap, 0, sizeof(efx->i2c_adap));
|
memset(&board->i2c_adap, 0, sizeof(board->i2c_adap));
|
||||||
fail5:
|
fail5:
|
||||||
falcon_remove_spi_devices(efx);
|
falcon_remove_spi_devices(efx);
|
||||||
falcon_free_buffer(efx, &efx->irq_status);
|
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)
|
void falcon_remove_nic(struct efx_nic *efx)
|
||||||
{
|
{
|
||||||
struct falcon_nic_data *nic_data = efx->nic_data;
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
||||||
|
struct falcon_board *board = falcon_board(efx);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
falcon_board(efx)->fini(efx);
|
falcon_board(efx)->fini(efx);
|
||||||
|
|
||||||
/* Remove I2C adapter and clear it in preparation for a retry */
|
/* 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);
|
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_remove_spi_devices(efx);
|
||||||
falcon_free_buffer(efx, &efx->irq_status);
|
falcon_free_buffer(efx, &efx->irq_status);
|
||||||
|
@ -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
|
* @set_id_led: Set state of identifying LED or revert to automatic function
|
||||||
* @monitor: Board-specific health check function
|
* @monitor: Board-specific health check function
|
||||||
* @fini: Shut down hardware and free resources
|
* @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
|
* @hwmon_client: I2C client for hardware monitor
|
||||||
* @ioexp_client: I2C client for power/port control
|
* @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);
|
void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
|
||||||
int (*monitor) (struct efx_nic *nic);
|
int (*monitor) (struct efx_nic *nic);
|
||||||
void (*fini) (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 i2c_client *hwmon_client, *ioexp_client;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct falcon_nic_data - Falcon NIC state
|
* struct falcon_nic_data - Falcon NIC state
|
||||||
* @pci_dev2: The secondary PCI device if present
|
* @pci_dev2: The secondary PCI device if present
|
||||||
* @i2c_data: Operations and state for I2C bit-bashing algorithm
|
|
||||||
* @board: Board state and functions
|
* @board: Board state and functions
|
||||||
*/
|
*/
|
||||||
struct falcon_nic_data {
|
struct falcon_nic_data {
|
||||||
struct pci_dev *pci_dev2;
|
struct pci_dev *pci_dev2;
|
||||||
struct i2c_algo_bit_data i2c_data;
|
|
||||||
struct falcon_board board;
|
struct falcon_board board;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +51,8 @@
|
|||||||
static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
|
static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
|
||||||
const u8 *reg_values)
|
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;
|
int rc;
|
||||||
|
|
||||||
if (!client)
|
if (!client)
|
||||||
@ -65,7 +66,7 @@ static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
falcon_board(efx)->hwmon_client = client;
|
board->hwmon_client = client;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -290,10 +291,11 @@ fail_on:
|
|||||||
|
|
||||||
static int sfn4111t_reset(struct efx_nic *efx)
|
static int sfn4111t_reset(struct efx_nic *efx)
|
||||||
{
|
{
|
||||||
|
struct falcon_board *board = falcon_board(efx);
|
||||||
efx_oword_t reg;
|
efx_oword_t reg;
|
||||||
|
|
||||||
/* GPIO 3 and the GPIO register are shared with I2C, so block that */
|
/* 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
|
/* Pull RST_N (GPIO 2) low then let it up again, setting the
|
||||||
* FLASH_CFG_1 strap (GPIO 3) appropriately. Only change 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, ®, FR_AB_GPIO_CTL);
|
efx_writeo(efx, ®, FR_AB_GPIO_CTL);
|
||||||
msleep(1);
|
msleep(1);
|
||||||
|
|
||||||
i2c_unlock_adapter(&efx->i2c_adap);
|
i2c_unlock_adapter(&board->i2c_adap);
|
||||||
|
|
||||||
ssleep(1);
|
ssleep(1);
|
||||||
return 0;
|
return 0;
|
||||||
@ -416,10 +418,10 @@ static int sfe4001_init(struct efx_nic *efx)
|
|||||||
|
|
||||||
#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
|
#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
|
||||||
board->hwmon_client =
|
board->hwmon_client =
|
||||||
i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info);
|
i2c_new_device(&board->i2c_adap, &sfe4001_hwmon_info);
|
||||||
#else
|
#else
|
||||||
board->hwmon_client =
|
board->hwmon_client =
|
||||||
i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr);
|
i2c_new_dummy(&board->i2c_adap, sfe4001_hwmon_info.addr);
|
||||||
#endif
|
#endif
|
||||||
if (!board->hwmon_client)
|
if (!board->hwmon_client)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@ -430,7 +432,7 @@ static int sfe4001_init(struct efx_nic *efx)
|
|||||||
if (rc)
|
if (rc)
|
||||||
goto fail_hwmon;
|
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) {
|
if (!board->ioexp_client) {
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
goto fail_hwmon;
|
goto fail_hwmon;
|
||||||
@ -522,7 +524,7 @@ static int sfn4111t_init(struct efx_nic *efx)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
board->hwmon_client =
|
board->hwmon_client =
|
||||||
i2c_new_device(&efx->i2c_adap,
|
i2c_new_device(&board->i2c_adap,
|
||||||
(board->minor < 5) ?
|
(board->minor < 5) ?
|
||||||
&sfn4111t_a0_hwmon_info :
|
&sfn4111t_a0_hwmon_info :
|
||||||
&sfn4111t_r5_hwmon_info);
|
&sfn4111t_r5_hwmon_info);
|
||||||
|
@ -639,7 +639,6 @@ union efx_multicast_hash {
|
|||||||
* @interrupt_mode: Interrupt mode
|
* @interrupt_mode: Interrupt mode
|
||||||
* @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
|
* @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
|
||||||
* @irq_rx_moderation: IRQ moderation time 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.
|
* @state: Device state flag. Serialised by the rtnl_lock.
|
||||||
* @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
|
* @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
|
||||||
* @tx_queue: TX DMA queues
|
* @tx_queue: TX DMA queues
|
||||||
@ -725,8 +724,6 @@ struct efx_nic {
|
|||||||
bool irq_rx_adaptive;
|
bool irq_rx_adaptive;
|
||||||
unsigned int irq_rx_moderation;
|
unsigned int irq_rx_moderation;
|
||||||
|
|
||||||
struct i2c_adapter i2c_adap;
|
|
||||||
|
|
||||||
enum nic_state state;
|
enum nic_state state;
|
||||||
enum reset_type reset_pending;
|
enum reset_type reset_pending;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user