From 9ed980785429db35f51f8d324cc75c23f2e5fb20 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 22 Oct 2013 00:24:32 +0200 Subject: hwstub: rework i2c completely Change-Id: I1e5f87f15f0ca9586d8185316ffcaeef6d9d4d38 --- utils/hwstub/tools/lua/stmp/i2c.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'utils/hwstub/tools/lua/stmp/i2c.lua') diff --git a/utils/hwstub/tools/lua/stmp/i2c.lua b/utils/hwstub/tools/lua/stmp/i2c.lua index 54d860e0df..209f1df4e2 100644 --- a/utils/hwstub/tools/lua/stmp/i2c.lua +++ b/utils/hwstub/tools/lua/stmp/i2c.lua @@ -8,10 +8,7 @@ h:add("The STMP.clkctrl table handles the i2c device for all STMPs.") function STMP.i2c.init() HW.I2C.CTRL0.SFTRST.set() - STMP.pinctrl.pin(0, 30).muxsel("MAIN") - STMP.pinctrl.pin(0, 30).pull(true) - STMP.pinctrl.pin(0, 31).muxsel("MAIN") - STMP.pinctrl.pin(0, 31).pull(true) + STMP.pinctrl.i2c.setup() STMP.i2c.reset() STMP.i2c.set_speed(true) end @@ -21,7 +18,9 @@ function STMP.i2c.reset() HW.I2C.CTRL0.SFTRST.clr() HW.I2C.CTRL0.CLKGATE.clr() -- errata for IMX233 - HW.I2C.CTRL1.ACK_MODE.set(); + if STMP.is_imx233() then + HW.I2C.CTRL1.ACK_MODE.set(); + end end function STMP.i2c.set_speed(fast) @@ -63,7 +62,9 @@ function STMP.i2c.transmit(slave_addr, buffer, send_stop) while HW.I2C.CTRL0.RUN.read() == 1 do end if HW.I2C.CTRL1.NO_SLAVE_ACK_IRQ.read() == 1 then - HW.I2C.CTRL1.CLR_GOT_A_NAK.set() + if STMP.is_imx233() then + HW.I2C.CTRL1.CLR_GOT_A_NAK.set() + end STMP.i2c.reset() return false end -- cgit v1.2.3