aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-12-02 08:47:10 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-03 12:08:06 -0500
commit6a8872c54d177abd900a0cf165b76ecb4803f052 (patch)
treebefd3690b9c73a7ae6342345c2a205a345d78028 /drivers
parent6c88b0b6dc886e49c0e6ee21d677c2e380bde688 (diff)
sfc: Expose Falcon BootROM config through MTD, not ethtool
The ethtool EEPROM interface is really meant for exposing chip configuration, not BootROM configuration. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sfc/ethtool.c59
-rw-r--r--drivers/net/sfc/mtd.c77
2 files changed, 54 insertions, 82 deletions
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index edb9d16b8b47..00fb6743c8a6 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -17,7 +17,6 @@
17#include "efx.h" 17#include "efx.h"
18#include "filter.h" 18#include "filter.h"
19#include "nic.h" 19#include "nic.h"
20#include "spi.h"
21#include "mdio_10g.h" 20#include "mdio_10g.h"
22 21
23struct ethtool_string { 22struct ethtool_string {
@@ -629,61 +628,6 @@ static u32 efx_ethtool_get_link(struct net_device *net_dev)
629 return efx->link_state.up; 628 return efx->link_state.up;
630} 629}
631 630
632static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
633{
634 struct efx_nic *efx = netdev_priv(net_dev);
635 struct efx_spi_device *spi = efx->spi_eeprom;
636
637 if (!spi)
638 return 0;
639 return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
640 min(spi->size, EFX_EEPROM_BOOTCONFIG_START);
641}
642
643static int efx_ethtool_get_eeprom(struct net_device *net_dev,
644 struct ethtool_eeprom *eeprom, u8 *buf)
645{
646 struct efx_nic *efx = netdev_priv(net_dev);
647 struct efx_spi_device *spi = efx->spi_eeprom;
648 size_t len;
649 int rc;
650
651 rc = mutex_lock_interruptible(&efx->spi_lock);
652 if (rc)
653 return rc;
654 rc = falcon_spi_read(efx, spi,
655 eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
656 eeprom->len, &len, buf);
657 mutex_unlock(&efx->spi_lock);
658
659 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
660 eeprom->len = len;
661 return rc;
662}
663
664static int efx_ethtool_set_eeprom(struct net_device *net_dev,
665 struct ethtool_eeprom *eeprom, u8 *buf)
666{
667 struct efx_nic *efx = netdev_priv(net_dev);
668 struct efx_spi_device *spi = efx->spi_eeprom;
669 size_t len;
670 int rc;
671
672 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
673 return -EINVAL;
674
675 rc = mutex_lock_interruptible(&efx->spi_lock);
676 if (rc)
677 return rc;
678 rc = falcon_spi_write(efx, spi,
679 eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
680 eeprom->len, &len, buf);
681 mutex_unlock(&efx->spi_lock);
682
683 eeprom->len = len;
684 return rc;
685}
686
687static int efx_ethtool_get_coalesce(struct net_device *net_dev, 631static int efx_ethtool_get_coalesce(struct net_device *net_dev,
688 struct ethtool_coalesce *coalesce) 632 struct ethtool_coalesce *coalesce)
689{ 633{
@@ -1116,9 +1060,6 @@ const struct ethtool_ops efx_ethtool_ops = {
1116 .set_msglevel = efx_ethtool_set_msglevel, 1060 .set_msglevel = efx_ethtool_set_msglevel,
1117 .nway_reset = efx_ethtool_nway_reset, 1061 .nway_reset = efx_ethtool_nway_reset,
1118 .get_link = efx_ethtool_get_link, 1062 .get_link = efx_ethtool_get_link,
1119 .get_eeprom_len = efx_ethtool_get_eeprom_len,
1120 .get_eeprom = efx_ethtool_get_eeprom,
1121 .set_eeprom = efx_ethtool_set_eeprom,
1122 .get_coalesce = efx_ethtool_get_coalesce, 1063 .get_coalesce = efx_ethtool_get_coalesce,
1123 .set_coalesce = efx_ethtool_set_coalesce, 1064 .set_coalesce = efx_ethtool_set_coalesce,
1124 .get_ringparam = efx_ethtool_get_ringparam, 1065 .get_ringparam = efx_ethtool_get_ringparam,
diff --git a/drivers/net/sfc/mtd.c b/drivers/net/sfc/mtd.c
index 02e54b4f701f..d44c74584e0f 100644
--- a/drivers/net/sfc/mtd.c
+++ b/drivers/net/sfc/mtd.c
@@ -387,35 +387,66 @@ static struct efx_mtd_ops falcon_mtd_ops = {
387 387
388static int falcon_mtd_probe(struct efx_nic *efx) 388static int falcon_mtd_probe(struct efx_nic *efx)
389{ 389{
390 struct efx_spi_device *spi = efx->spi_flash; 390 struct efx_spi_device *spi;
391 struct efx_mtd *efx_mtd; 391 struct efx_mtd *efx_mtd;
392 int rc; 392 int rc = -ENODEV;
393 393
394 ASSERT_RTNL(); 394 ASSERT_RTNL();
395 395
396 if (!spi || spi->size <= FALCON_FLASH_BOOTCODE_START) 396 spi = efx->spi_flash;
397 return -ENODEV; 397 if (spi && spi->size > FALCON_FLASH_BOOTCODE_START) {
398 398 efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
399 efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]), 399 GFP_KERNEL);
400 GFP_KERNEL); 400 if (!efx_mtd)
401 if (!efx_mtd) 401 return -ENOMEM;
402 return -ENOMEM; 402
403 403 efx_mtd->spi = spi;
404 efx_mtd->spi = spi; 404 efx_mtd->name = "flash";
405 efx_mtd->name = "flash"; 405 efx_mtd->ops = &falcon_mtd_ops;
406 efx_mtd->ops = &falcon_mtd_ops; 406
407 efx_mtd->n_parts = 1;
408 efx_mtd->part[0].mtd.type = MTD_NORFLASH;
409 efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
410 efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
411 efx_mtd->part[0].mtd.erasesize = spi->erase_size;
412 efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
413 efx_mtd->part[0].type_name = "sfc_flash_bootrom";
414
415 rc = efx_mtd_probe_device(efx, efx_mtd);
416 if (rc) {
417 kfree(efx_mtd);
418 return rc;
419 }
420 }
407 421
408 efx_mtd->n_parts = 1; 422 spi = efx->spi_eeprom;
409 efx_mtd->part[0].mtd.type = MTD_NORFLASH; 423 if (spi && spi->size > EFX_EEPROM_BOOTCONFIG_START) {
410 efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH; 424 efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
411 efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START; 425 GFP_KERNEL);
412 efx_mtd->part[0].mtd.erasesize = spi->erase_size; 426 if (!efx_mtd)
413 efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START; 427 return -ENOMEM;
414 efx_mtd->part[0].type_name = "sfc_flash_bootrom"; 428
429 efx_mtd->spi = spi;
430 efx_mtd->name = "EEPROM";
431 efx_mtd->ops = &falcon_mtd_ops;
432
433 efx_mtd->n_parts = 1;
434 efx_mtd->part[0].mtd.type = MTD_RAM;
435 efx_mtd->part[0].mtd.flags = MTD_CAP_RAM;
436 efx_mtd->part[0].mtd.size =
437 min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
438 EFX_EEPROM_BOOTCONFIG_START;
439 efx_mtd->part[0].mtd.erasesize = spi->erase_size;
440 efx_mtd->part[0].offset = EFX_EEPROM_BOOTCONFIG_START;
441 efx_mtd->part[0].type_name = "sfc_bootconfig";
442
443 rc = efx_mtd_probe_device(efx, efx_mtd);
444 if (rc) {
445 kfree(efx_mtd);
446 return rc;
447 }
448 }
415 449
416 rc = efx_mtd_probe_device(efx, efx_mtd);
417 if (rc)
418 kfree(efx_mtd);
419 return rc; 450 return rc;
420} 451}
421 452