Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

eeprom: at25: Add DT support for EEPROMs with odd address bits

Certain EEPROMS have a size that is larger than the number of address
bytes would allow, and store the MSB of the address in bit 3 of the
instruction byte.

This can be described in platform data using EE_INSTR_BIT3_IS_ADDR, or
in DT using the obsolete legacy "at25,addr-mode" property.
But currently there exists no non-deprecated way to describe this in DT.

Hence extend the existing "address-width" DT property to allow
specifying 9 address bits, and enable support for that in the driver.

This has been tested with a Microchip 25LC040A.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Geert Uytterhoeven and committed by
Greg Kroah-Hartman
f8d3bc10 eb90826b

+6 -1
+3 -1
Documentation/devicetree/bindings/eeprom/at25.txt
··· 11 11 - spi-max-frequency : max spi frequency to use 12 12 - pagesize : size of the eeprom page 13 13 - size : total eeprom size in bytes 14 - - address-width : number of address bits (one of 8, 16, or 24) 14 + - address-width : number of address bits (one of 8, 9, 16, or 24). 15 + For 9 bits, the MSB of the address is sent as bit 3 of the instruction 16 + byte, before the address byte. 15 17 16 18 Optional properties: 17 19 - spi-cpha : SPI shifted clock phase, as per spi-bus bindings.
+3
drivers/misc/eeprom/at25.c
··· 276 276 return -ENODEV; 277 277 } 278 278 switch (val) { 279 + case 9: 280 + chip->flags |= EE_INSTR_BIT3_IS_ADDR; 281 + /* fall through */ 279 282 case 8: 280 283 chip->flags |= EE_ADDR1; 281 284 break;