Skip to content
Joel Stanley edited this page Oct 6, 2017 · 2 revisions

The I2C slave support an be tested with the slave EEPROM driver present in the upstream kernel.

Grab a recent Linux kernel with ASPEED i2c support. I used 4.14 with my in-progress clock driver applied, but dev-4.10 should work too.

Connect I2C1 and I2C2 SCL and SDA lines

The pins are on the south edge of the board, towards the south-west corner when reading the ASPEED Technolgoy Inc silkscreen up the correct way. A jumper should be able to reach between them.

Apply the patch to your tree

$ cd linux-aspeed
$ wget http://ozlabs.org/~joel/0001-ARM-dts-aspeed-evb-Enable-EEPROM-i2c-slave.patch
$ patch -p1 < 0001-ARM-dts-aspeed-evb-Enable-EEPROM-i2c-slave.patch

Build the kernel and fit image

Use your favourite FIT and initrd or root file system.

$ cd linux-aspeed
$ make aspeed_g5_defconfig
$ make
$ mkimage -f evb.fit evb

Boot the 'evb' fit image on your evb

Bind the drivers

# echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new-device
# i2cdetect -y 1                                                                                          
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                                                      
00:          -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
60: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --                                                      
70: -- -- -- -- -- -- -- --  
# echo 24c02 0x64 > /sys/bus/i2c/devices/i2c-2/new_device
# i2cdetect -y 2                                                                                          
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                                                      
00:          -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                      
60: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --                                                      
70: -- -- -- -- -- -- -- --

Find the eeprom sysfs files

# find /sys/devices/ -name slave-eeprom
/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a0c0.i2c-bus/i2c-2/2-0064/slave-eeprom

And the 'host' side of the eeprom is here. The one on bus i2c-3 is the real EEPROM; ignore it.

# find /sys/devices -name eeprom                                                                                
/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a0c0.i2c-bus/i2c-2/2-0064/eeprom              
/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a100.i2c-bus/i2c-3/3-0050/eeprom

Create some environment variables

# HOST=/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a0c0.i2c-bus/i2c-2/2-0064/eeprom
# SLAVE=/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a0c0.i2c-bus/i2c-2/2-0064/slave-eeprom

Write to one, and see it appear in the other

# echo "How about a nice game of chess?" > $SLAVE
# cat $HOST
How about a nice game of chess?
# hexdump -C $HOST
00000000  48 6f 77 20 61 62 6f 75  74 20 61 20 6e 69 63 65  |How about a nice|
00000010  20 67 61 6d 65 20 6f 66  20 63 68 65 73 73 3f 0a  | game of chess?.|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
# echo "You have no chance to survive make your time" > $HOST
# hexdump -C $SLAVE
00000000  59 6f 75 20 68 61 76 65  20 6e 6f 20 63 68 61 6e  |You have no chan|
00000010  63 65 20 74 6f 20 73 75  72 76 69 76 65 20 6d 61  |ce to survive ma|
00000020  6b 65 20 79 6f 75 72 20  74 69 6d 65 0a 00 00 00  |ke your time....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|