• Paul Boven's avatar
    userspace/libwr: Fixes to make shw_write_sfp() actually write SFP eeproms · 579646e4
    Paul Boven authored
    The SFP documentation "INF-8047.pdf" states:
    "The serial interface uses the 2-wire serial CMOS E2PROM protocol defined for
    the ATMEL AT24C01A/02/04 family of components."
    
    Upon reading that datasheet, some important details stand out:
    1) The eeprom can only write in pages, with pages being 8 or 16 bytes. Assuming
       the smallest device, you can only write 8 bytes at a time. To be safe, I'm
       assuming a pagesize of 8 bytes.
    
       This explains why we only saw stuff change in the first 8 bytes, I guess.
    
    2) A write needs to be preceded by the byte address which is a single byte for
       these devices, and then up to 8 (or 16) data bytes to be written at that
       location. If there are more bytes, or if the data wraps around the page
       binary, it will still only end up on the page belonging to that first
       address.
    
    3) After writing, you need to poll the eeprom to see if it has finished writing
       the byte. At the moment, I'm not doing that yet, instead I'm doing a 10ms
       wait which seems sufficient.
    Signed-off-by: Paul Boven's avatarPaul Boven <boven@jive.eu>
    Acked-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
    579646e4
i2c_sfp.c 18.5 KB