xref: /openbmc/entity-manager/docs/address_size_detection_modes.md (revision dac2dfc3a64063b062fabd9c4d6e2857c1185eaf)
1*dac2dfc3SVu Pham# EEPROM address size detection modes
2*dac2dfc3SVu Pham
3*dac2dfc3SVu PhamThis document introduces and discusses the different modes to detect how many
4*dac2dfc3SVu Phamaddress byte(s) needed for a given EEPROM device.
5*dac2dfc3SVu Pham
6*dac2dfc3SVu Pham## MODE-1
7*dac2dfc3SVu Pham
8*dac2dfc3SVu PhamThe existing upstream function isDevice16Bit() bases on sending 1-byte write
9*dac2dfc3SVu Phamoperation (with a STOP condition) and 8 subsequent 1-byte read operations with
10*dac2dfc3SVu PhamSINGLE byte address.
11*dac2dfc3SVu Pham
12*dac2dfc3SVu Pham### This MODE-1 expects the following logic
13*dac2dfc3SVu Pham
14*dac2dfc3SVu Pham- If the device requires 1 address byte, it EXPECTS that the data will be read
15*dac2dfc3SVu Pham  from a single location so 8 bytes read will be the same.
16*dac2dfc3SVu Pham- If the device requires 2 address bytes, it EXPECTS that the data will be read
17*dac2dfc3SVu Pham  from 8 DIFFERENT LOCATIONS and at least one byte read is different than 7
18*dac2dfc3SVu Pham  other reads.
19*dac2dfc3SVu Pham
20*dac2dfc3SVu Pham### Issue and potential issue with this MODE-1
21*dac2dfc3SVu Pham
22*dac2dfc3SVu Pham- If any "2 address bytes" EEPROM from any vendor has the same data in all
23*dac2dfc3SVu Pham  memory locations (0-7) the existing upstream function read, this device will
24*dac2dfc3SVu Pham  be identified as "1 address byte" device.
25*dac2dfc3SVu Pham
26*dac2dfc3SVu Pham- ONSEMI EEPROM (a 2 address bytes device) return the same data from the same
27*dac2dfc3SVu Pham  single byte address read --> therefore, existing function wrongly identifies
28*dac2dfc3SVu Pham  it as 1 byte address device.
29*dac2dfc3SVu Pham
30*dac2dfc3SVu Pham## MODE-2
31*dac2dfc3SVu Pham
32*dac2dfc3SVu PhamThe proposal MODE-2 changes to isDevice16Bit() sends 8 instructions of 2-bytes
33*dac2dfc3SVu Phamwrite operation (WITHOUT a STOP condition ie. prohibited STOP) followed by a
34*dac2dfc3SVu Pham1-byte read operation. The proposed solution fully complies with IIC standard
35*dac2dfc3SVu Phamand should be applicable to any IIC EEPROM manufacturer.
36*dac2dfc3SVu Pham
37*dac2dfc3SVu Pham```text
38*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x00 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
39*dac2dfc3SVu Pham`|-------|---------------|------|------|----------------------|-------| --------------|-----------|------|
40*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x01 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
41*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x02 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
42*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x03 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
43*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x04 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
44*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x05 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
45*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x06 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
46*dac2dfc3SVu Pham`| Start | SlaveAddr + W | 0x00 | 0x07 | STOP PROHIBITED HERE | Start | SlaveAddr + R | data byte | Stop |
47*dac2dfc3SVu Pham```
48*dac2dfc3SVu Pham
49*dac2dfc3SVu Pham- If the device requires a single data byte, then it will always load address
50*dac2dfc3SVu Pham  0x00, the subsequent read byte will be the same for all 8 instructions. The
51*dac2dfc3SVu Pham  second byte on the write would be interpreted as data byte, thus not modifying
52*dac2dfc3SVu Pham  the address pointer.
53*dac2dfc3SVu Pham
54*dac2dfc3SVu Pham- If two address bytes are required, then the device will interpret both bytes
55*dac2dfc3SVu Pham  as addresses, thus reading from different addresses every time, similar with
56*dac2dfc3SVu Pham  what the existing function is using now.
57*dac2dfc3SVu Pham
58*dac2dfc3SVu Pham### Notes & reasons
59*dac2dfc3SVu Pham
60*dac2dfc3SVu PhamThere is no STOP condition after the second (potential) address byte. A START
61*dac2dfc3SVu Phamcondition must be sent after the second byte. If STOP condition is sent, then
62*dac2dfc3SVu Phamthe 1-byte address devices will start internal write cycle, altering the EEPROM
63*dac2dfc3SVu Phamcontent which is not good.
64*dac2dfc3SVu Pham
65*dac2dfc3SVu PhamThis proposal MODE-2 suffers the same 1st issue as MODE-1 ie. what if the EEPROM
66*dac2dfc3SVu Phamhas the same data at all those addresses. However, this proposal MODE-2
67*dac2dfc3SVu Phamaddresses the 2nd issue of MODE-1 which expects that the data will be read from
68*dac2dfc3SVu Pham8 DIFFERENT LOCATIONS if the device requires 2 address bytes. This expectation
69*dac2dfc3SVu Phamis the ambiguity (not standard defined) in the IIC specification.
70*dac2dfc3SVu Pham
71*dac2dfc3SVu PhamIn [IIC specification:](https://www.nxp.com/docs/en/user-guide/UM10204.pdf)
72*dac2dfc3SVu Pham
73*dac2dfc3SVu Pham- Section 3.1.10, Note 2 ->
74*dac2dfc3SVu Pham  `All decisions on auto-increment or decrement of previously accessed memory locations, etc., are taken by the designer of the device.`
75*dac2dfc3SVu Pham
76*dac2dfc3SVu Pham  Based on this note, the designer of every EEPROM has the "freedom" to use
77*dac2dfc3SVu Pham  whatever architecture considers appropriate and suitable to process everyone
78*dac2dfc3SVu Pham  of the two address bytes. There are no restrictions on this.
79*dac2dfc3SVu Pham
80*dac2dfc3SVu Pham  Based on this, the others EEPROM (not ONSEMI EEPROM) auto-increment - observed
81*dac2dfc3SVu Pham  with one address byte sent instead of two - is a manufacturer-specific
82*dac2dfc3SVu Pham  behavior, and not standard defined.
83*dac2dfc3SVu Pham
84*dac2dfc3SVu Pham- Section 3.1.10, Note 1 ->
85*dac2dfc3SVu Pham  `Combined formats can be used, for example, to control a serial memory. The internal memory location must be written during the first data byte. After the START condition and slave address is repeated, data can be transferred.`
86*dac2dfc3SVu Pham
87*dac2dfc3SVu Pham  This proposal MODE-2 implements this note. The memory location referred herein
88*dac2dfc3SVu Pham  is the address pointer, as being the first data byte in IIC communication.
89*dac2dfc3SVu Pham  Based on this note, EEPROM must update this pointer immediately following this
90*dac2dfc3SVu Pham  first address byte.
91