Browse Source

Adjust EEPROM/flash detection to fit expected manufacturing practice.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
4c3e0fede5
1 changed files with 31 additions and 8 deletions
  1. 31
    8
      src/drivers/net/etherfabric.c

+ 31
- 8
src/drivers/net/etherfabric.c View File

@@ -1545,6 +1545,11 @@ static struct efab_mac_operations ef1002_mac_operations = {
1545 1545
 #define FCN_EE_SPI_HDATA0_LBN 0
1546 1546
 #define FCN_EE_SPI_HDATA0_WIDTH 32
1547 1547
 
1548
+/* VPI configuration register */
1549
+#define FCN_VPD_CONFIG_REG_KER 0x0140
1550
+#define FCN_VPD_9BIT_LBN 1
1551
+#define FCN_VPD_9BIT_WIDTH 1
1552
+
1548 1553
 /* NIC status register */
1549 1554
 #define FCN_NIC_STAT_REG 0x0200
1550 1555
 #define ONCHIP_SRAM_LBN 16
@@ -2285,6 +2290,9 @@ static int falcon_spi_rw ( struct spi_bus *bus, struct spi_device *device,
2285 2290
  *
2286 2291
  */
2287 2292
 static void falcon_init_spi ( struct efab_nic *efab ) {
2293
+	efab_oword_t reg;
2294
+	int eeprom_9bit;
2295
+
2288 2296
 	/* Initialise SPI bus */
2289 2297
 	efab->spi.rw = falcon_spi_rw;
2290 2298
 	efab->falcon_eeprom.bus = &efab->spi;
@@ -2292,16 +2300,31 @@ static void falcon_init_spi ( struct efab_nic *efab ) {
2292 2300
 	efab->falcon_flash.bus = &efab->spi;
2293 2301
 	efab->falcon_flash.slave = FCN_EE_SPI_FLASH;
2294 2302
 
2295
-	/* Initialise EEPROM, if present */
2303
+	/* Initialise flash if present */
2296 2304
 	if ( efab->has_flash ) {
2305
+		DBG ( "Flash is present\n" );
2297 2306
 		init_at25f1024 ( &efab->falcon_flash );
2298
-		init_at25040 ( &efab->falcon_eeprom );
2299
-	} else {
2300
-		init_mc25xx640 ( &efab->falcon_eeprom );
2301
-		/* Falcon's SPI interface cannot support a block size
2302
-		 * larger than 16, so forcibly reduce it
2303
-		 */
2304
-		efab->falcon_eeprom.nvs.block_size = 16;
2307
+	}
2308
+
2309
+	/* Initialise EEPROM if present */
2310
+	if ( efab->has_eeprom ) {
2311
+		if ( efab->is_asic ) {
2312
+			falcon_read ( efab, &reg, FCN_VPD_CONFIG_REG_KER );
2313
+			eeprom_9bit = EFAB_OWORD_FIELD ( reg, FCN_VPD_9BIT );
2314
+		} else {
2315
+			eeprom_9bit = 1;
2316
+		}
2317
+		if ( eeprom_9bit ) {
2318
+			DBG ( "Small EEPROM is present\n" );
2319
+			init_at25040 ( &efab->falcon_eeprom );
2320
+		} else {
2321
+			DBG ( "Large EEPROM is present\n" );
2322
+			init_mc25xx640 ( &efab->falcon_eeprom );
2323
+			/* Falcon's SPI interface cannot support a block
2324
+			   size larger than 16, so forcibly reduce it
2325
+			 */
2326
+			efab->falcon_eeprom.nvs.block_size = 16;
2327
+		}
2305 2328
 	}
2306 2329
 }
2307 2330
 

Loading…
Cancel
Save