net: dsa: mv88e6xxx: rework EEPROM access
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Wed, 20 Jul 2016 22:18:35 +0000 (18:18 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jul 2016 04:10:54 +0000 (21:10 -0700)
commit855b193290e6a07b343ee3c059ea6b4bd6cdc2bf
treec5b5d862b18d9660b75fc74477935db70a00873e
parentd4673339ce22f1d65ebe05bbdaadabf4efb13d18
net: dsa: mv88e6xxx: rework EEPROM access

The 6352 family of switches and compatibles provide a 8-bit address and
16-bit data access to an optional EEPROM.

Newer chip such as the 6390 family slightly changed the access to 16-bit
address and 8-bit data.

This commit cleans up the EEPROM access code for 16-bit access and makes
it easy to eventually introduce future support for 8-bit access.

Here's a list of notable changes brought by this patch:

  - provide Global2 unlocked helpers for EEPROM commands
  - remove eeprom_mutex, only reg_lock is necessary for driver functions
  - eeprom_len is 0 for chip without EEPROM, so return it directly
  - the Running bit must be 0 before r/w, so wait for Busy *and* Running
  - remove now unused mv88e6xxx_wait and mv88e6xxx_reg_write
  - other than that, the logic (in _{get,set}_eeprom16) didn't change

Chips with an 8-bit EEPROM access will require to implement the
8-suffixed variant of G2 helpers and the related flag:

    #define MV88E6XXX_FLAGS_EEPROM8 \
     (MV88E6XXX_FLAG_G2_EEPROM_CMD | \
      MV88E6XXX_FLAG_G2_EEPROM_ADDR)

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/mv88e6xxx.h