Purpose:
The article will guides how to achieve software control by i2c commands.
On FWA-2012 BMC sku, left and mid LEDs are defined as alarm and locate purpose, managed by BMC. On non BMC sku, both LED are software defined, managed by user's OS.
Target Audience:
FWA-2012 systems in non BMC sku.
Guiding Steps:
1. Make sure i2c driver loaded.
# modprobe i2c_i801
Use "lsmod" to check if driver loaded.
# sudo lsmod | grep i2c
2: Install i2c-tools package.
(I2c tools could be installed from Ubuntu’s repository simply)
# sudo apt-get install i2c-tools
- Or built from source package in website. Please check README in package.
https://www.kernel.org/pub/software/utils/i2c-tools/
3: Scan smbus in system by i2cdetect.
# i2cdetect -l
i2c-0 smbus SMBus I801 adapter at e000 SMBus adapter
- Here shows system smbus adapter located at bus 0. Please note the bus number could be
different due to different hardware configuration, kernel version and driver of other devices.
4. Find i2c switch 0x71.
# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- 1a -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- 2d -- --
30: 30 31 -- -- 34 35 UU UU -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: UU -- 52 -- -- -- 56 -- 58 -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- 71 -- -- -- -- -- --
5. Enable 8th bit of i2c switch for accessing 0x23 IO expander.
# i2cset -y 0 0x71 0x80
6. Find 0x23 IO expander device appears on the smbus.
# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- 1a -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- 2d -- --
30: 30 31 -- -- 34 35 UU UU -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: UU -- 52 -- -- -- 56 -- 58 -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- 71 -- -- -- -- -- --
7. Set pins to output mode. (required to be done every time Linux boots)
# i2cset -y 0 0x23 0x03 0x00
- Here “0” is smbus number and “0x23” is device address. “0x03” is offset and “0x00” is value,
combined to set GPIO pin 0 to pin 7 to output mode. “0x00” is hex of binary “0000 0000”,
which means pin 0 to 7 is set to bit “0” (output mode). Please note pin number could be
different due to hardware configuration, product SKU, please contact Advantech FAE if you
have problem with this pin mapping. - Both left and mid LEDs will be on after enable it
8. Refer definition of both LEDs.
PIN | LED location | Usage |
6 |
left LED |
color amber, 1=on, 0=off |
7 | middle LED |
color blue, 1=on, 0=off |
9. Control LEDs via i2c commands.
# i2cset -y 0 0x23 0x01 0x00 (all off)
# i2cset -y 0 0x23 0x01 0xc0 (both on)
# i2cset -y 0 0x23 0x01 0x40 (LED 6 on)
# i2cset -y 0 0x23 0x01 0x80 (LED 7 on)
- "0x00" is hex of binary "0000 0000", which means all bit set to "0" (all off)
"0xc0" is hex of binary "1100 0000", which means bit 6 and 7 set to "1" (both on)
"0x40" is hex of binary "0100 0000", which means bit 6 set to "1" (LED 6 on)
"0x80" is hex of binary "1000 0000", which means bit 7 set to "1" (LED 7 on)
Comments
0 comments
Please sign in to leave a comment.