Skip to content

Commit

Permalink
enable i2c pins when controlling bmc i2c controller from host.
Browse files Browse the repository at this point in the history
Don't assume i2c pin are left enabled by BMC when taking control.
Adjust SCU register if required.
  • Loading branch information
lprylli committed Mar 19, 2020
1 parent 5effc70 commit 47f167e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ast/i2c.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ func (a *AstHandle) I2cDev(busno, slave int) i2c.Dev {
bus.m.Write32(bus.base+0, 0)
time.Sleep(100 * time.Millisecond)
}
if busno >= 2 && busno <= 13 {
scuBit := uint32(1) << uint(busno+16-2)
if a.scu.Read32(0x90)&scuBit == 0 {
a.scu.Write32(0x90, a.scu.Read32(0x90)|scuBit)
log.Printf("i2c %d pins were disabled, enabling...\n", busno)
}
}
if bus.m.Read32(bus.base+0x14) != 0x0a060000 {
log.Fatalf("Cannot initialize i2c, cmd = 0x%08x\n", bus.m.Read32(bus.base+0x14))
}
bus.m.Write32(bus.base, 1) // enable master func
return i2c.Dev{Bus: bus, Addr: uint16(slave)}
}
Expand Down
2 changes: 1 addition & 1 deletion cmds/asti2c/asti2c.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func idt_eeread(dev i2c.Dev, addr uint32) byte {
tx := []byte{0x47, 4, 1, 0, byte(addr % 256), byte(addr / 256)}
err := dev.Tx(tx, nil)
if err != nil {
log.Fatalf("idt_eeread:query-phase:%d\n", err)
log.Fatalf("idt_eeread:query-phase:%s\n", err)
}
var rbuf [8]byte
err = dev.Tx([]byte{0x47}, rbuf[:])
Expand Down

0 comments on commit 47f167e

Please sign in to comment.