diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2010-12-02 08:47:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-03 12:08:07 -0500 |
commit | 4de92180258ac661bbce0f0065c9c81633ac862b (patch) | |
tree | bb58aecb8e7e52dd2f95daa53ab263ccd98b9374 | |
parent | 90b7a4ee610bf1d14120f5e0618ae2a3568394a5 (diff) |
sfc: Move SPI state to struct falcon_nic_data
We only have direct access to SPI on Falcon, so move all this state
out of struct efx_nic.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/sfc/efx.c | 4 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.c | 91 | ||||
-rw-r--r-- | drivers/net/sfc/mtd.c | 29 | ||||
-rw-r--r-- | drivers/net/sfc/net_driver.h | 8 | ||||
-rw-r--r-- | drivers/net/sfc/nic.h | 7 | ||||
-rw-r--r-- | drivers/net/sfc/spi.h | 5 |
6 files changed, 69 insertions, 75 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index b4580c4ea7e..6aed6acdd2d 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -1961,7 +1961,6 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method) | |||
1961 | 1961 | ||
1962 | efx_stop_all(efx); | 1962 | efx_stop_all(efx); |
1963 | mutex_lock(&efx->mac_lock); | 1963 | mutex_lock(&efx->mac_lock); |
1964 | mutex_lock(&efx->spi_lock); | ||
1965 | 1964 | ||
1966 | efx_fini_channels(efx); | 1965 | efx_fini_channels(efx); |
1967 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) | 1966 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) |
@@ -2003,7 +2002,6 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) | |||
2003 | efx_init_channels(efx); | 2002 | efx_init_channels(efx); |
2004 | efx_restore_filters(efx); | 2003 | efx_restore_filters(efx); |
2005 | 2004 | ||
2006 | mutex_unlock(&efx->spi_lock); | ||
2007 | mutex_unlock(&efx->mac_lock); | 2005 | mutex_unlock(&efx->mac_lock); |
2008 | 2006 | ||
2009 | efx_start_all(efx); | 2007 | efx_start_all(efx); |
@@ -2013,7 +2011,6 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) | |||
2013 | fail: | 2011 | fail: |
2014 | efx->port_initialized = false; | 2012 | efx->port_initialized = false; |
2015 | 2013 | ||
2016 | mutex_unlock(&efx->spi_lock); | ||
2017 | mutex_unlock(&efx->mac_lock); | 2014 | mutex_unlock(&efx->mac_lock); |
2018 | 2015 | ||
2019 | return rc; | 2016 | return rc; |
@@ -2202,7 +2199,6 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, | |||
2202 | memset(efx, 0, sizeof(*efx)); | 2199 | memset(efx, 0, sizeof(*efx)); |
2203 | spin_lock_init(&efx->biu_lock); | 2200 | spin_lock_init(&efx->biu_lock); |
2204 | mutex_init(&efx->mdio_lock); | 2201 | mutex_init(&efx->mdio_lock); |
2205 | mutex_init(&efx->spi_lock); | ||
2206 | #ifdef CONFIG_SFC_MTD | 2202 | #ifdef CONFIG_SFC_MTD |
2207 | INIT_LIST_HEAD(&efx->mtd_list); | 2203 | INIT_LIST_HEAD(&efx->mtd_list); |
2208 | #endif | 2204 | #endif |
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index fe150842d82..ca59f7e02df 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -254,7 +254,6 @@ int falcon_spi_cmd(struct efx_nic *efx, const struct efx_spi_device *spi, | |||
254 | /* Input validation */ | 254 | /* Input validation */ |
255 | if (len > FALCON_SPI_MAX_LEN) | 255 | if (len > FALCON_SPI_MAX_LEN) |
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | BUG_ON(!mutex_is_locked(&efx->spi_lock)); | ||
258 | 257 | ||
259 | /* Check that previous command is not still running */ | 258 | /* Check that previous command is not still running */ |
260 | rc = falcon_spi_poll(efx); | 259 | rc = falcon_spi_poll(efx); |
@@ -888,6 +887,7 @@ static void falcon_remove_port(struct efx_nic *efx) | |||
888 | static int | 887 | static int |
889 | falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | 888 | falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) |
890 | { | 889 | { |
890 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
891 | struct falcon_nvconfig *nvconfig; | 891 | struct falcon_nvconfig *nvconfig; |
892 | struct efx_spi_device *spi; | 892 | struct efx_spi_device *spi; |
893 | void *region; | 893 | void *region; |
@@ -895,8 +895,11 @@ falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | |||
895 | __le16 *word, *limit; | 895 | __le16 *word, *limit; |
896 | u32 csum; | 896 | u32 csum; |
897 | 897 | ||
898 | spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; | 898 | if (efx_spi_present(&nic_data->spi_flash)) |
899 | if (!spi) | 899 | spi = &nic_data->spi_flash; |
900 | else if (efx_spi_present(&nic_data->spi_eeprom)) | ||
901 | spi = &nic_data->spi_eeprom; | ||
902 | else | ||
900 | return -EINVAL; | 903 | return -EINVAL; |
901 | 904 | ||
902 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); | 905 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); |
@@ -904,12 +907,13 @@ falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | |||
904 | return -ENOMEM; | 907 | return -ENOMEM; |
905 | nvconfig = region + FALCON_NVCONFIG_OFFSET; | 908 | nvconfig = region + FALCON_NVCONFIG_OFFSET; |
906 | 909 | ||
907 | mutex_lock(&efx->spi_lock); | 910 | mutex_lock(&nic_data->spi_lock); |
908 | rc = falcon_spi_read(efx, spi, 0, FALCON_NVCONFIG_END, NULL, region); | 911 | rc = falcon_spi_read(efx, spi, 0, FALCON_NVCONFIG_END, NULL, region); |
909 | mutex_unlock(&efx->spi_lock); | 912 | mutex_unlock(&nic_data->spi_lock); |
910 | if (rc) { | 913 | if (rc) { |
911 | netif_err(efx, hw, efx->net_dev, "Failed to read %s\n", | 914 | netif_err(efx, hw, efx->net_dev, "Failed to read %s\n", |
912 | efx->spi_flash ? "flash" : "EEPROM"); | 915 | efx_spi_present(&nic_data->spi_flash) ? |
916 | "flash" : "EEPROM"); | ||
913 | rc = -EIO; | 917 | rc = -EIO; |
914 | goto out; | 918 | goto out; |
915 | } | 919 | } |
@@ -1011,7 +1015,7 @@ static int falcon_b0_test_registers(struct efx_nic *efx) | |||
1011 | 1015 | ||
1012 | /* Resets NIC to known state. This routine must be called in process | 1016 | /* Resets NIC to known state. This routine must be called in process |
1013 | * context and is allowed to sleep. */ | 1017 | * context and is allowed to sleep. */ |
1014 | static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method) | 1018 | static int __falcon_reset_hw(struct efx_nic *efx, enum reset_type method) |
1015 | { | 1019 | { |
1016 | struct falcon_nic_data *nic_data = efx->nic_data; | 1020 | struct falcon_nic_data *nic_data = efx->nic_data; |
1017 | efx_oword_t glb_ctl_reg_ker; | 1021 | efx_oword_t glb_ctl_reg_ker; |
@@ -1107,6 +1111,18 @@ fail5: | |||
1107 | return rc; | 1111 | return rc; |
1108 | } | 1112 | } |
1109 | 1113 | ||
1114 | static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method) | ||
1115 | { | ||
1116 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
1117 | int rc; | ||
1118 | |||
1119 | mutex_lock(&nic_data->spi_lock); | ||
1120 | rc = __falcon_reset_hw(efx, method); | ||
1121 | mutex_unlock(&nic_data->spi_lock); | ||
1122 | |||
1123 | return rc; | ||
1124 | } | ||
1125 | |||
1110 | static void falcon_monitor(struct efx_nic *efx) | 1126 | static void falcon_monitor(struct efx_nic *efx) |
1111 | { | 1127 | { |
1112 | bool link_changed; | 1128 | bool link_changed; |
@@ -1188,16 +1204,11 @@ static int falcon_reset_sram(struct efx_nic *efx) | |||
1188 | return -ETIMEDOUT; | 1204 | return -ETIMEDOUT; |
1189 | } | 1205 | } |
1190 | 1206 | ||
1191 | static int falcon_spi_device_init(struct efx_nic *efx, | 1207 | static void falcon_spi_device_init(struct efx_nic *efx, |
1192 | struct efx_spi_device **spi_device_ret, | 1208 | struct efx_spi_device *spi_device, |
1193 | unsigned int device_id, u32 device_type) | 1209 | unsigned int device_id, u32 device_type) |
1194 | { | 1210 | { |
1195 | struct efx_spi_device *spi_device; | ||
1196 | |||
1197 | if (device_type != 0) { | 1211 | if (device_type != 0) { |
1198 | spi_device = kzalloc(sizeof(*spi_device), GFP_KERNEL); | ||
1199 | if (!spi_device) | ||
1200 | return -ENOMEM; | ||
1201 | spi_device->device_id = device_id; | 1212 | spi_device->device_id = device_id; |
1202 | spi_device->size = | 1213 | spi_device->size = |
1203 | 1 << SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_SIZE); | 1214 | 1 << SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_SIZE); |
@@ -1214,25 +1225,14 @@ static int falcon_spi_device_init(struct efx_nic *efx, | |||
1214 | 1 << SPI_DEV_TYPE_FIELD(device_type, | 1225 | 1 << SPI_DEV_TYPE_FIELD(device_type, |
1215 | SPI_DEV_TYPE_BLOCK_SIZE); | 1226 | SPI_DEV_TYPE_BLOCK_SIZE); |
1216 | } else { | 1227 | } else { |
1217 | spi_device = NULL; | 1228 | spi_device->size = 0; |
1218 | } | 1229 | } |
1219 | |||
1220 | kfree(*spi_device_ret); | ||
1221 | *spi_device_ret = spi_device; | ||
1222 | return 0; | ||
1223 | } | ||
1224 | |||
1225 | static void falcon_remove_spi_devices(struct efx_nic *efx) | ||
1226 | { | ||
1227 | kfree(efx->spi_eeprom); | ||
1228 | efx->spi_eeprom = NULL; | ||
1229 | kfree(efx->spi_flash); | ||
1230 | efx->spi_flash = NULL; | ||
1231 | } | 1230 | } |
1232 | 1231 | ||
1233 | /* Extract non-volatile configuration */ | 1232 | /* Extract non-volatile configuration */ |
1234 | static int falcon_probe_nvconfig(struct efx_nic *efx) | 1233 | static int falcon_probe_nvconfig(struct efx_nic *efx) |
1235 | { | 1234 | { |
1235 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
1236 | struct falcon_nvconfig *nvconfig; | 1236 | struct falcon_nvconfig *nvconfig; |
1237 | int rc; | 1237 | int rc; |
1238 | 1238 | ||
@@ -1242,24 +1242,20 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) | |||
1242 | 1242 | ||
1243 | rc = falcon_read_nvram(efx, nvconfig); | 1243 | rc = falcon_read_nvram(efx, nvconfig); |
1244 | if (rc) | 1244 | if (rc) |
1245 | goto fail1; | 1245 | goto out; |
1246 | 1246 | ||
1247 | efx->phy_type = nvconfig->board_v2.port0_phy_type; | 1247 | efx->phy_type = nvconfig->board_v2.port0_phy_type; |
1248 | efx->mdio.prtad = nvconfig->board_v2.port0_phy_addr; | 1248 | efx->mdio.prtad = nvconfig->board_v2.port0_phy_addr; |
1249 | 1249 | ||
1250 | if (le16_to_cpu(nvconfig->board_struct_ver) >= 3) { | 1250 | if (le16_to_cpu(nvconfig->board_struct_ver) >= 3) { |
1251 | rc = falcon_spi_device_init( | 1251 | falcon_spi_device_init( |
1252 | efx, &efx->spi_flash, FFE_AB_SPI_DEVICE_FLASH, | 1252 | efx, &nic_data->spi_flash, FFE_AB_SPI_DEVICE_FLASH, |
1253 | le32_to_cpu(nvconfig->board_v3 | 1253 | le32_to_cpu(nvconfig->board_v3 |
1254 | .spi_device_type[FFE_AB_SPI_DEVICE_FLASH])); | 1254 | .spi_device_type[FFE_AB_SPI_DEVICE_FLASH])); |
1255 | if (rc) | 1255 | falcon_spi_device_init( |
1256 | goto fail2; | 1256 | efx, &nic_data->spi_eeprom, FFE_AB_SPI_DEVICE_EEPROM, |
1257 | rc = falcon_spi_device_init( | ||
1258 | efx, &efx->spi_eeprom, FFE_AB_SPI_DEVICE_EEPROM, | ||
1259 | le32_to_cpu(nvconfig->board_v3 | 1257 | le32_to_cpu(nvconfig->board_v3 |
1260 | .spi_device_type[FFE_AB_SPI_DEVICE_EEPROM])); | 1258 | .spi_device_type[FFE_AB_SPI_DEVICE_EEPROM])); |
1261 | if (rc) | ||
1262 | goto fail2; | ||
1263 | } | 1259 | } |
1264 | 1260 | ||
1265 | /* Read the MAC addresses */ | 1261 | /* Read the MAC addresses */ |
@@ -1270,15 +1266,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) | |||
1270 | 1266 | ||
1271 | rc = falcon_probe_board(efx, | 1267 | rc = falcon_probe_board(efx, |
1272 | le16_to_cpu(nvconfig->board_v2.board_revision)); | 1268 | le16_to_cpu(nvconfig->board_v2.board_revision)); |
1273 | if (rc) | 1269 | out: |
1274 | goto fail2; | ||
1275 | |||
1276 | kfree(nvconfig); | ||
1277 | return 0; | ||
1278 | |||
1279 | fail2: | ||
1280 | falcon_remove_spi_devices(efx); | ||
1281 | fail1: | ||
1282 | kfree(nvconfig); | 1270 | kfree(nvconfig); |
1283 | return rc; | 1271 | return rc; |
1284 | } | 1272 | } |
@@ -1286,6 +1274,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) | |||
1286 | /* Probe all SPI devices on the NIC */ | 1274 | /* Probe all SPI devices on the NIC */ |
1287 | static void falcon_probe_spi_devices(struct efx_nic *efx) | 1275 | static void falcon_probe_spi_devices(struct efx_nic *efx) |
1288 | { | 1276 | { |
1277 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
1289 | efx_oword_t nic_stat, gpio_ctl, ee_vpd_cfg; | 1278 | efx_oword_t nic_stat, gpio_ctl, ee_vpd_cfg; |
1290 | int boot_dev; | 1279 | int boot_dev; |
1291 | 1280 | ||
@@ -1314,12 +1303,14 @@ static void falcon_probe_spi_devices(struct efx_nic *efx) | |||
1314 | efx_writeo(efx, &ee_vpd_cfg, FR_AB_EE_VPD_CFG0); | 1303 | efx_writeo(efx, &ee_vpd_cfg, FR_AB_EE_VPD_CFG0); |
1315 | } | 1304 | } |
1316 | 1305 | ||
1306 | mutex_init(&nic_data->spi_lock); | ||
1307 | |||
1317 | if (boot_dev == FFE_AB_SPI_DEVICE_FLASH) | 1308 | if (boot_dev == FFE_AB_SPI_DEVICE_FLASH) |
1318 | falcon_spi_device_init(efx, &efx->spi_flash, | 1309 | falcon_spi_device_init(efx, &nic_data->spi_flash, |
1319 | FFE_AB_SPI_DEVICE_FLASH, | 1310 | FFE_AB_SPI_DEVICE_FLASH, |
1320 | default_flash_type); | 1311 | default_flash_type); |
1321 | if (boot_dev == FFE_AB_SPI_DEVICE_EEPROM) | 1312 | if (boot_dev == FFE_AB_SPI_DEVICE_EEPROM) |
1322 | falcon_spi_device_init(efx, &efx->spi_eeprom, | 1313 | falcon_spi_device_init(efx, &nic_data->spi_eeprom, |
1323 | FFE_AB_SPI_DEVICE_EEPROM, | 1314 | FFE_AB_SPI_DEVICE_EEPROM, |
1324 | large_eeprom_type); | 1315 | large_eeprom_type); |
1325 | } | 1316 | } |
@@ -1384,7 +1375,7 @@ static int falcon_probe_nic(struct efx_nic *efx) | |||
1384 | } | 1375 | } |
1385 | 1376 | ||
1386 | /* Now we can reset the NIC */ | 1377 | /* Now we can reset the NIC */ |
1387 | rc = falcon_reset_hw(efx, RESET_TYPE_ALL); | 1378 | rc = __falcon_reset_hw(efx, RESET_TYPE_ALL); |
1388 | if (rc) { | 1379 | if (rc) { |
1389 | netif_err(efx, probe, efx->net_dev, "failed to reset NIC\n"); | 1380 | netif_err(efx, probe, efx->net_dev, "failed to reset NIC\n"); |
1390 | goto fail3; | 1381 | goto fail3; |
@@ -1442,7 +1433,6 @@ static int falcon_probe_nic(struct efx_nic *efx) | |||
1442 | BUG_ON(i2c_del_adapter(&board->i2c_adap)); | 1433 | BUG_ON(i2c_del_adapter(&board->i2c_adap)); |
1443 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); | 1434 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); |
1444 | fail5: | 1435 | fail5: |
1445 | falcon_remove_spi_devices(efx); | ||
1446 | efx_nic_free_buffer(efx, &efx->irq_status); | 1436 | efx_nic_free_buffer(efx, &efx->irq_status); |
1447 | fail4: | 1437 | fail4: |
1448 | fail3: | 1438 | fail3: |
@@ -1596,10 +1586,9 @@ static void falcon_remove_nic(struct efx_nic *efx) | |||
1596 | BUG_ON(rc); | 1586 | BUG_ON(rc); |
1597 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); | 1587 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); |
1598 | 1588 | ||
1599 | falcon_remove_spi_devices(efx); | ||
1600 | efx_nic_free_buffer(efx, &efx->irq_status); | 1589 | efx_nic_free_buffer(efx, &efx->irq_status); |
1601 | 1590 | ||
1602 | falcon_reset_hw(efx, RESET_TYPE_ALL); | 1591 | __falcon_reset_hw(efx, RESET_TYPE_ALL); |
1603 | 1592 | ||
1604 | /* Release the second function after the reset */ | 1593 | /* Release the second function after the reset */ |
1605 | if (nic_data->pci_dev2) { | 1594 | if (nic_data->pci_dev2) { |
diff --git a/drivers/net/sfc/mtd.c b/drivers/net/sfc/mtd.c index d44c74584e0..d38627448c2 100644 --- a/drivers/net/sfc/mtd.c +++ b/drivers/net/sfc/mtd.c | |||
@@ -321,14 +321,15 @@ static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, | |||
321 | struct efx_mtd *efx_mtd = mtd->priv; | 321 | struct efx_mtd *efx_mtd = mtd->priv; |
322 | const struct efx_spi_device *spi = efx_mtd->spi; | 322 | const struct efx_spi_device *spi = efx_mtd->spi; |
323 | struct efx_nic *efx = efx_mtd->efx; | 323 | struct efx_nic *efx = efx_mtd->efx; |
324 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
324 | int rc; | 325 | int rc; |
325 | 326 | ||
326 | rc = mutex_lock_interruptible(&efx->spi_lock); | 327 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
327 | if (rc) | 328 | if (rc) |
328 | return rc; | 329 | return rc; |
329 | rc = falcon_spi_read(efx, spi, part->offset + start, len, | 330 | rc = falcon_spi_read(efx, spi, part->offset + start, len, |
330 | retlen, buffer); | 331 | retlen, buffer); |
331 | mutex_unlock(&efx->spi_lock); | 332 | mutex_unlock(&nic_data->spi_lock); |
332 | return rc; | 333 | return rc; |
333 | } | 334 | } |
334 | 335 | ||
@@ -337,13 +338,14 @@ static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) | |||
337 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 338 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); |
338 | struct efx_mtd *efx_mtd = mtd->priv; | 339 | struct efx_mtd *efx_mtd = mtd->priv; |
339 | struct efx_nic *efx = efx_mtd->efx; | 340 | struct efx_nic *efx = efx_mtd->efx; |
341 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
340 | int rc; | 342 | int rc; |
341 | 343 | ||
342 | rc = mutex_lock_interruptible(&efx->spi_lock); | 344 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
343 | if (rc) | 345 | if (rc) |
344 | return rc; | 346 | return rc; |
345 | rc = efx_spi_erase(part, part->offset + start, len); | 347 | rc = efx_spi_erase(part, part->offset + start, len); |
346 | mutex_unlock(&efx->spi_lock); | 348 | mutex_unlock(&nic_data->spi_lock); |
347 | return rc; | 349 | return rc; |
348 | } | 350 | } |
349 | 351 | ||
@@ -354,14 +356,15 @@ static int falcon_mtd_write(struct mtd_info *mtd, loff_t start, | |||
354 | struct efx_mtd *efx_mtd = mtd->priv; | 356 | struct efx_mtd *efx_mtd = mtd->priv; |
355 | const struct efx_spi_device *spi = efx_mtd->spi; | 357 | const struct efx_spi_device *spi = efx_mtd->spi; |
356 | struct efx_nic *efx = efx_mtd->efx; | 358 | struct efx_nic *efx = efx_mtd->efx; |
359 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
357 | int rc; | 360 | int rc; |
358 | 361 | ||
359 | rc = mutex_lock_interruptible(&efx->spi_lock); | 362 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
360 | if (rc) | 363 | if (rc) |
361 | return rc; | 364 | return rc; |
362 | rc = falcon_spi_write(efx, spi, part->offset + start, len, | 365 | rc = falcon_spi_write(efx, spi, part->offset + start, len, |
363 | retlen, buffer); | 366 | retlen, buffer); |
364 | mutex_unlock(&efx->spi_lock); | 367 | mutex_unlock(&nic_data->spi_lock); |
365 | return rc; | 368 | return rc; |
366 | } | 369 | } |
367 | 370 | ||
@@ -370,11 +373,12 @@ static int falcon_mtd_sync(struct mtd_info *mtd) | |||
370 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 373 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); |
371 | struct efx_mtd *efx_mtd = mtd->priv; | 374 | struct efx_mtd *efx_mtd = mtd->priv; |
372 | struct efx_nic *efx = efx_mtd->efx; | 375 | struct efx_nic *efx = efx_mtd->efx; |
376 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
373 | int rc; | 377 | int rc; |
374 | 378 | ||
375 | mutex_lock(&efx->spi_lock); | 379 | mutex_lock(&nic_data->spi_lock); |
376 | rc = efx_spi_slow_wait(part, true); | 380 | rc = efx_spi_slow_wait(part, true); |
377 | mutex_unlock(&efx->spi_lock); | 381 | mutex_unlock(&nic_data->spi_lock); |
378 | return rc; | 382 | return rc; |
379 | } | 383 | } |
380 | 384 | ||
@@ -387,14 +391,15 @@ static struct efx_mtd_ops falcon_mtd_ops = { | |||
387 | 391 | ||
388 | static int falcon_mtd_probe(struct efx_nic *efx) | 392 | static int falcon_mtd_probe(struct efx_nic *efx) |
389 | { | 393 | { |
394 | struct falcon_nic_data *nic_data = efx->nic_data; | ||
390 | struct efx_spi_device *spi; | 395 | struct efx_spi_device *spi; |
391 | struct efx_mtd *efx_mtd; | 396 | struct efx_mtd *efx_mtd; |
392 | int rc = -ENODEV; | 397 | int rc = -ENODEV; |
393 | 398 | ||
394 | ASSERT_RTNL(); | 399 | ASSERT_RTNL(); |
395 | 400 | ||
396 | spi = efx->spi_flash; | 401 | spi = &nic_data->spi_flash; |
397 | if (spi && spi->size > FALCON_FLASH_BOOTCODE_START) { | 402 | if (efx_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) { |
398 | efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]), | 403 | efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]), |
399 | GFP_KERNEL); | 404 | GFP_KERNEL); |
400 | if (!efx_mtd) | 405 | if (!efx_mtd) |
@@ -419,8 +424,8 @@ static int falcon_mtd_probe(struct efx_nic *efx) | |||
419 | } | 424 | } |
420 | } | 425 | } |
421 | 426 | ||
422 | spi = efx->spi_eeprom; | 427 | spi = &nic_data->spi_eeprom; |
423 | if (spi && spi->size > EFX_EEPROM_BOOTCONFIG_START) { | 428 | if (efx_spi_present(spi) && spi->size > EFX_EEPROM_BOOTCONFIG_START) { |
424 | efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]), | 429 | efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]), |
425 | GFP_KERNEL); | 430 | GFP_KERNEL); |
426 | if (!efx_mtd) | 431 | if (!efx_mtd) |
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h index 0a7e26d73b5..e5ee2d53750 100644 --- a/drivers/net/sfc/net_driver.h +++ b/drivers/net/sfc/net_driver.h | |||
@@ -657,11 +657,6 @@ struct efx_filter_state; | |||
657 | * to verify that an interrupt has occurred. | 657 | * to verify that an interrupt has occurred. |
658 | * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0 | 658 | * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0 |
659 | * @fatal_irq_level: IRQ level (bit number) used for serious errors | 659 | * @fatal_irq_level: IRQ level (bit number) used for serious errors |
660 | * @spi_flash: SPI flash device | ||
661 | * This field will be %NULL if no flash device is present (or for Siena). | ||
662 | * @spi_eeprom: SPI EEPROM device | ||
663 | * This field will be %NULL if no EEPROM device is present (or for Siena). | ||
664 | * @spi_lock: SPI bus lock | ||
665 | * @mtd_list: List of MTDs attached to the NIC | 660 | * @mtd_list: List of MTDs attached to the NIC |
666 | * @n_rx_nodesc_drop_cnt: RX no descriptor drop count | 661 | * @n_rx_nodesc_drop_cnt: RX no descriptor drop count |
667 | * @nic_data: Hardware dependant state | 662 | * @nic_data: Hardware dependant state |
@@ -746,9 +741,6 @@ struct efx_nic { | |||
746 | unsigned irq_zero_count; | 741 | unsigned irq_zero_count; |
747 | unsigned fatal_irq_level; | 742 | unsigned fatal_irq_level; |
748 | 743 | ||
749 | struct efx_spi_device *spi_flash; | ||
750 | struct efx_spi_device *spi_eeprom; | ||
751 | struct mutex spi_lock; | ||
752 | #ifdef CONFIG_SFC_MTD | 744 | #ifdef CONFIG_SFC_MTD |
753 | struct list_head mtd_list; | 745 | struct list_head mtd_list; |
754 | #endif | 746 | #endif |
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h index 0438dc98722..2a0fff324f1 100644 --- a/drivers/net/sfc/nic.h +++ b/drivers/net/sfc/nic.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "net_driver.h" | 15 | #include "net_driver.h" |
16 | #include "efx.h" | 16 | #include "efx.h" |
17 | #include "mcdi.h" | 17 | #include "mcdi.h" |
18 | #include "spi.h" | ||
18 | 19 | ||
19 | /* | 20 | /* |
20 | * Falcon hardware control | 21 | * Falcon hardware control |
@@ -113,6 +114,9 @@ struct falcon_board { | |||
113 | * @stats_pending: Is there a pending DMA of MAC statistics. | 114 | * @stats_pending: Is there a pending DMA of MAC statistics. |
114 | * @stats_timer: A timer for regularly fetching MAC statistics. | 115 | * @stats_timer: A timer for regularly fetching MAC statistics. |
115 | * @stats_dma_done: Pointer to the flag which indicates DMA completion. | 116 | * @stats_dma_done: Pointer to the flag which indicates DMA completion. |
117 | * @spi_flash: SPI flash device | ||
118 | * @spi_eeprom: SPI EEPROM device | ||
119 | * @spi_lock: SPI bus lock | ||
116 | */ | 120 | */ |
117 | struct falcon_nic_data { | 121 | struct falcon_nic_data { |
118 | struct pci_dev *pci_dev2; | 122 | struct pci_dev *pci_dev2; |
@@ -121,6 +125,9 @@ struct falcon_nic_data { | |||
121 | bool stats_pending; | 125 | bool stats_pending; |
122 | struct timer_list stats_timer; | 126 | struct timer_list stats_timer; |
123 | u32 *stats_dma_done; | 127 | u32 *stats_dma_done; |
128 | struct efx_spi_device spi_flash; | ||
129 | struct efx_spi_device spi_eeprom; | ||
130 | struct mutex spi_lock; | ||
124 | }; | 131 | }; |
125 | 132 | ||
126 | static inline struct falcon_board *falcon_board(struct efx_nic *efx) | 133 | static inline struct falcon_board *falcon_board(struct efx_nic *efx) |
diff --git a/drivers/net/sfc/spi.h b/drivers/net/sfc/spi.h index 8bf4fce0813..879b7f6bde3 100644 --- a/drivers/net/sfc/spi.h +++ b/drivers/net/sfc/spi.h | |||
@@ -61,6 +61,11 @@ struct efx_spi_device { | |||
61 | unsigned int block_size; | 61 | unsigned int block_size; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | static inline bool efx_spi_present(const struct efx_spi_device *spi) | ||
65 | { | ||
66 | return spi->size != 0; | ||
67 | } | ||
68 | |||
64 | int falcon_spi_cmd(struct efx_nic *efx, | 69 | int falcon_spi_cmd(struct efx_nic *efx, |
65 | const struct efx_spi_device *spi, unsigned int command, | 70 | const struct efx_spi_device *spi, unsigned int command, |
66 | int address, const void* in, void *out, size_t len); | 71 | int address, const void* in, void *out, size_t len); |