Commit e10d4071 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

sdb-storage: scan through 128 possible i2c EEPROMs

parent 1c028e8e
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#define SDB_DEV_SFP 0x7366702d /* sfp- (database) */ #define SDB_DEV_SFP 0x7366702d /* sfp- (database) */
#define SDB_DEV_CALIB 0x63616c69 /* cali (bration) */ #define SDB_DEV_CALIB 0x63616c69 /* cali (bration) */
/* constants for scanning I2C EEPROMs */
#define EEPROM_START_ADR 0
#define EEPROM_STOP_ADR 127
/* Functions for Flash access */ /* Functions for Flash access */
static int sdb_flash_read(struct sdbfs *fs, int offset, void *buf, int count) static int sdb_flash_read(struct sdbfs *fs, int offset, void *buf, int count)
{ {
...@@ -252,28 +256,35 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr) ...@@ -252,28 +256,35 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr)
* 3. If w1 failed, look for i2c: start from low offsets. * 3. If w1 failed, look for i2c: start from low offsets.
*/ */
i2c_params.ifnum = chosen_i2cif; i2c_params.ifnum = chosen_i2cif;
i2c_params.addr = chosen_i2c_addr; i2c_params.addr = EEPROM_START_ADR;
if (!mi2c_devprobe(i2c_params.ifnum, i2c_params.addr)) while (i2c_params.addr <= EEPROM_STOP_ADR) {
return; /* First, we check if I2C EEPROM is there */
if (!mi2c_devprobe(i2c_params.ifnum, i2c_params.addr)) {
/* While looking for the magic number, use sdb-based read function */ i2c_params.addr++;
for (i = 0; i < ARRAY_SIZE(entry_points_eeprom); i++) { continue;
sdb_i2c_read(&wrc_sdb, entry_points_eeprom[i], (void *)&magic, }
sizeof(magic)); /* While looking for the magic number, use sdb-based read function */
if (magic == SDB_MAGIC) for (i = 0; i < ARRAY_SIZE(entry_points_eeprom); i++) {
break; sdb_i2c_read(&wrc_sdb, entry_points_eeprom[i], (void *)&magic,
} sizeof(magic));
if (magic == SDB_MAGIC) { if (magic == SDB_MAGIC)
pp_printf("sdbfs: found at %i in I2C\n", entry_points_eeprom[i]); break;
wrc_sdb.drvdata = &i2c_params; }
wrc_sdb.blocksize = 1; if (magic == SDB_MAGIC) {
wrc_sdb.entrypoint = entry_points_eeprom[i]; pp_printf("sdbfs: found at %i in I2C(0x%2X)\n",
wrc_sdb.read = sdb_i2c_read; entry_points_eeprom[i], i2c_params.addr);
wrc_sdb.write = sdb_i2c_write; wrc_sdb.drvdata = &i2c_params;
wrc_sdb.erase = sdb_i2c_erase; wrc_sdb.blocksize = 1;
goto found_exit; wrc_sdb.entrypoint = entry_points_eeprom[i];
wrc_sdb.read = sdb_i2c_read;
wrc_sdb.write = sdb_i2c_write;
wrc_sdb.erase = sdb_i2c_erase;
goto found_exit;
}
i2c_params.addr++;
} }
if (i == ARRAY_SIZE(entry_points_eeprom)) {
if (i2c_params.addr == EEPROM_STOP_ADR) {
pp_printf("No SDB filesystem in i2c eeprom\n"); pp_printf("No SDB filesystem in i2c eeprom\n");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment