Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4150724 authored by Ben Hutchings's avatar Ben Hutchings Committed by Jeff Garzik
Browse files

sfc: Expose flash region storing boot code as MTD



The boot code that appears as a PCI expansion ROM on the SFC4000 is
stored in flash.  Expose this as a standard MTD device to allow for
in-place upgrades.

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 0a95f563
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -12,3 +12,11 @@ config SFC

	  To compile this driver as a module, choose M here.  The module
	  will be called sfc.
config SFC_MTD
	bool "Solarflare Solarstorm SFC4000 flash MTD support"
	depends on SFC && MTD
	default y
	help
	  This exposes the on-board flash memory as an MTD device (e.g.
          /dev/mtd1).  This makes it possible to upload new boot code
          to the NIC.
+1 −0
Original line number Diff line number Diff line
sfc-y			+= efx.o falcon.o tx.o rx.o falcon_xmac.o \
			   selftest.o ethtool.o xfp_phy.o \
			   mdio_10g.o tenxpress.o boards.o sfe4001.o
sfc-$(CONFIG_SFC_MTD)	+= mtd.o

obj-$(CONFIG_SFC)	+= sfc.o
+7 −0
Original line number Diff line number Diff line
@@ -1459,6 +1459,7 @@ static int efx_netdev_event(struct notifier_block *this,
		struct efx_nic *efx = netdev_priv(net_dev);

		strcpy(efx->name, net_dev->name);
		efx_mtd_rename(efx);
	}

	return NOTIFY_DONE;
@@ -1550,6 +1551,7 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)

	efx_stop_all(efx);
	mutex_lock(&efx->mac_lock);
	mutex_lock(&efx->spi_lock);

	rc = falcon_xmac_get_settings(efx, ecmd);
	if (rc)
@@ -1582,6 +1584,7 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok)
			EFX_ERR(efx, "could not restore PHY settings\n");
	}

	mutex_unlock(&efx->spi_lock);
	mutex_unlock(&efx->mac_lock);

	if (ok) {
@@ -1777,6 +1780,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
	memset(efx, 0, sizeof(*efx));
	spin_lock_init(&efx->biu_lock);
	spin_lock_init(&efx->phy_lock);
	mutex_init(&efx->spi_lock);
	INIT_WORK(&efx->reset_work, efx_reset_work);
	INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor);
	efx->pci_dev = pci_dev;
@@ -1911,6 +1915,8 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
	if (!efx)
		return;

	efx_mtd_remove(efx);

	/* Mark the NIC as fini, then stop the interface */
	rtnl_lock();
	efx->state = STATE_FINI;
@@ -2077,6 +2083,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,

	EFX_LOG(efx, "initialisation successful\n");

	efx_mtd_probe(efx); /* allowed to fail */
	return 0;

 fail5:
+10 −0
Original line number Diff line number Diff line
@@ -58,6 +58,16 @@ extern int efx_port_dummy_op_int(struct efx_nic *efx);
extern void efx_port_dummy_op_void(struct efx_nic *efx);
extern void efx_port_dummy_op_blink(struct efx_nic *efx, bool blink);

/* MTD */
#ifdef CONFIG_SFC_MTD
extern int efx_mtd_probe(struct efx_nic *efx);
extern void efx_mtd_rename(struct efx_nic *efx);
extern void efx_mtd_remove(struct efx_nic *efx);
#else
static inline int efx_mtd_probe(struct efx_nic *efx) { return 0; }
static inline void efx_mtd_rename(struct efx_nic *efx) {}
static inline void efx_mtd_remove(struct efx_nic *efx) {}
#endif

extern unsigned int efx_monitor_interval;

+4 −0
Original line number Diff line number Diff line
@@ -554,8 +554,10 @@ static int efx_ethtool_get_eeprom(struct net_device *net_dev,
	size_t len;
	int rc;

	mutex_lock(&efx->spi_lock);
	rc = falcon_spi_read(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
			     eeprom->len, &len, buf);
	mutex_unlock(&efx->spi_lock);
	eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
	eeprom->len = len;
	return rc;
@@ -572,8 +574,10 @@ static int efx_ethtool_set_eeprom(struct net_device *net_dev,
	if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
		return -EINVAL;

	mutex_lock(&efx->spi_lock);
	rc = falcon_spi_write(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
			      eeprom->len, &len, buf);
	mutex_unlock(&efx->spi_lock);
	eeprom->len = len;
	return rc;
}
Loading