aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-11-04 15:33:11 -0500
committerJeff Garzik <jgarzik@redhat.com>2008-11-06 00:49:56 -0500
commit0a95f56323ce93dac354c1b2d54bf959a985cf7d (patch)
treefbf11f9284c25fc5c0520fda649c3850d180da3b /drivers
parent2883f552f2c6c6ccb2021643652c6d930f205f6f (diff)
sfc: Clean up non-volatile memory partitioning
Move flash and EEPROM partition boundary constants into spi.h and rename them to be consistent. Add a comment on the partitioning. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sfc/ethtool.c11
-rw-r--r--drivers/net/sfc/falcon.c6
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h1
-rw-r--r--drivers/net/sfc/spi.h17
4 files changed, 24 insertions, 11 deletions
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index cd0d0873d978..df0579e386f7 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -172,10 +172,7 @@ static struct efx_ethtool_stat efx_ethtool_stats[] = {
172/* Number of ethtool statistics */ 172/* Number of ethtool statistics */
173#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats) 173#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
174 174
175/* EEPROM range with gPXE configuration */
176#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB 175#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
177#define EFX_ETHTOOL_EEPROM_MIN 0x800U
178#define EFX_ETHTOOL_EEPROM_MAX 0x1800U
179 176
180/************************************************************************** 177/**************************************************************************
181 * 178 *
@@ -545,8 +542,8 @@ static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
545 542
546 if (!spi) 543 if (!spi)
547 return 0; 544 return 0;
548 return min(spi->size, EFX_ETHTOOL_EEPROM_MAX) - 545 return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
549 min(spi->size, EFX_ETHTOOL_EEPROM_MIN); 546 min(spi->size, EFX_EEPROM_BOOTCONFIG_START);
550} 547}
551 548
552static int efx_ethtool_get_eeprom(struct net_device *net_dev, 549static int efx_ethtool_get_eeprom(struct net_device *net_dev,
@@ -557,7 +554,7 @@ static int efx_ethtool_get_eeprom(struct net_device *net_dev,
557 size_t len; 554 size_t len;
558 int rc; 555 int rc;
559 556
560 rc = falcon_spi_read(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN, 557 rc = falcon_spi_read(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
561 eeprom->len, &len, buf); 558 eeprom->len, &len, buf);
562 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC; 559 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
563 eeprom->len = len; 560 eeprom->len = len;
@@ -575,7 +572,7 @@ static int efx_ethtool_set_eeprom(struct net_device *net_dev,
575 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC) 572 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
576 return -EINVAL; 573 return -EINVAL;
577 574
578 rc = falcon_spi_write(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN, 575 rc = falcon_spi_write(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
579 eeprom->len, &len, buf); 576 eeprom->len, &len, buf);
580 eeprom->len = len; 577 eeprom->len = len;
581 return rc; 578 return rc;
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 31ed1f49de00..3f74ceff6a2e 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -2253,13 +2253,13 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
2253 __le16 *word, *limit; 2253 __le16 *word, *limit;
2254 u32 csum; 2254 u32 csum;
2255 2255
2256 region = kmalloc(NVCONFIG_END, GFP_KERNEL); 2256 region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL);
2257 if (!region) 2257 if (!region)
2258 return -ENOMEM; 2258 return -ENOMEM;
2259 nvconfig = region + NVCONFIG_OFFSET; 2259 nvconfig = region + NVCONFIG_OFFSET;
2260 2260
2261 spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; 2261 spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom;
2262 rc = falcon_spi_read(spi, 0, NVCONFIG_END, NULL, region); 2262 rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region);
2263 if (rc) { 2263 if (rc) {
2264 EFX_ERR(efx, "Failed to read %s\n", 2264 EFX_ERR(efx, "Failed to read %s\n",
2265 efx->spi_flash ? "flash" : "EEPROM"); 2265 efx->spi_flash ? "flash" : "EEPROM");
@@ -2283,7 +2283,7 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
2283 limit = (__le16 *) (nvconfig + 1); 2283 limit = (__le16 *) (nvconfig + 1);
2284 } else { 2284 } else {
2285 word = region; 2285 word = region;
2286 limit = region + NVCONFIG_END; 2286 limit = region + FALCON_NVCONFIG_END;
2287 } 2287 }
2288 for (csum = 0; word < limit; ++word) 2288 for (csum = 0; word < limit; ++word)
2289 csum += le16_to_cpu(*word); 2289 csum += le16_to_cpu(*word);
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index 5d584b0dbb51..040e70ed4ec7 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -1150,7 +1150,6 @@ struct falcon_nvconfig_board_v3 {
1150 (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field))) 1150 (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
1151 1151
1152#define NVCONFIG_OFFSET 0x300 1152#define NVCONFIG_OFFSET 0x300
1153#define NVCONFIG_END 0x400
1154 1153
1155#define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C 1154#define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
1156struct falcon_nvconfig { 1155struct falcon_nvconfig {
diff --git a/drivers/net/sfc/spi.h b/drivers/net/sfc/spi.h
index feef61942377..b73f86cf5fa2 100644
--- a/drivers/net/sfc/spi.h
+++ b/drivers/net/sfc/spi.h
@@ -63,4 +63,21 @@ int falcon_spi_read(const struct efx_spi_device *spi, loff_t start,
63int falcon_spi_write(const struct efx_spi_device *spi, loff_t start, 63int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
64 size_t len, size_t *retlen, const u8 *buffer); 64 size_t len, size_t *retlen, const u8 *buffer);
65 65
66/*
67 * SFC4000 flash is partitioned into:
68 * 0-0x400 chip and board config (see falcon_hwdefs.h)
69 * 0x400-0x8000 unused (or may contain VPD if EEPROM not present)
70 * 0x8000-end boot code (mapped to PCI expansion ROM)
71 * SFC4000 small EEPROM (size < 0x400) is used for VPD only.
72 * SFC4000 large EEPROM (size >= 0x400) is partitioned into:
73 * 0-0x400 chip and board config
74 * configurable VPD
75 * 0x800-0x1800 boot config
76 * Aside from the chip and board config, all of these are optional and may
77 * be absent or truncated depending on the devices used.
78 */
79#define FALCON_NVCONFIG_END 0x400U
80#define EFX_EEPROM_BOOTCONFIG_START 0x800U
81#define EFX_EEPROM_BOOTCONFIG_END 0x1800U
82
66#endif /* EFX_SPI_H */ 83#endif /* EFX_SPI_H */