diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:24:32 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:34:44 +0200 |
commit | 9ed980785429db35f51f8d324cc75c23f2e5fb20 (patch) | |
tree | aa5362c4eea139c22b606b685e2ab29a19908d0d | |
parent | bfb67f41a9e9df3b730d34041be6b4f4a4983c5b (diff) | |
download | rockbox-9ed980785429db35f51f8d324cc75c23f2e5fb20.tar.gz rockbox-9ed980785429db35f51f8d324cc75c23f2e5fb20.zip |
hwstub: rework i2c completely
Change-Id: I1e5f87f15f0ca9586d8185316ffcaeef6d9d4d38
-rw-r--r-- | utils/hwstub/tools/lua/i2c_scan.lua | 11 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/sonynwze360.lua | 7 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp/i2c.lua | 13 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp/pinctrl.lua | 34 |
4 files changed, 52 insertions, 13 deletions
diff --git a/utils/hwstub/tools/lua/i2c_scan.lua b/utils/hwstub/tools/lua/i2c_scan.lua new file mode 100644 index 0000000000..def7b5d84c --- /dev/null +++ b/utils/hwstub/tools/lua/i2c_scan.lua @@ -0,0 +1,11 @@ +I2CSCAN = {} + +function I2CSCAN.scan() + STMP.i2c.init() + STMP.i2c.set_speed(true) + for i = 2, 254, 2 do + if STMP.i2c.transmit(i, {}, true) then + print(string.format("%#x OK", i)) + end + end + end
\ No newline at end of file diff --git a/utils/hwstub/tools/lua/sonynwze360.lua b/utils/hwstub/tools/lua/sonynwze360.lua index 669e899f0d..4fabdfd27c 100644 --- a/utils/hwstub/tools/lua/sonynwze360.lua +++ b/utils/hwstub/tools/lua/sonynwze360.lua @@ -150,13 +150,6 @@ end function NWZE360.init() NWZE360.lcd_init() NWZE360.set_backlight(100) - STMP.i2c.init() - STMP.i2c.set_speed(true) - for i = 2, 254, 2 do - if STMP.i2c.transmit(i, {}, true) then - print(string.format("%#x OK", i)) - end - end --[[ HW.LRADC.CTRL0.SFTRST.clr() HW.LRADC.CTRL0.CLKGATE.clr() 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 diff --git a/utils/hwstub/tools/lua/stmp/pinctrl.lua b/utils/hwstub/tools/lua/stmp/pinctrl.lua index 5346c75b35..013b29701e 100644 --- a/utils/hwstub/tools/lua/stmp/pinctrl.lua +++ b/utils/hwstub/tools/lua/stmp/pinctrl.lua @@ -86,6 +86,7 @@ hh:add("* pin: pin number (mandatory) ") hh:add("* muxsel: same values as STMP.pinctrl.pin().muxsel (optional)") hh:add("* enable: enable/disable output (optional)") hh:add("* output: set/clear output (optional)") +hh:add("* pull: enable/disable pullup (optional)") hh:add("All non-subtable entries are ignored") hh:add("All unknown parameters in subtablkes are ignored") hh:add("") @@ -112,6 +113,10 @@ function STMP.pinctrl.configure(tbl) if v.output then pin.set() else pin.clr() end end + if v.pull ~= nil then + STMP.debug(string.format("cfg B%dP%02d pull %s", v.bank, v.pin, v.pull)) + pin.pull(v.pull) + end end end end @@ -291,3 +296,32 @@ function STMP.pinctrl.lcdif.setup_system(bus_width, busy) STMP.pinctrl.configure_ex(busy_pin) end end + +STMP.pinctrl.i2c = {} + +local hhh = hh:create_topic("setup") +hhh:add("The STMP.pinctrl.i2c.setup() functions configure the I2C pins.") + +function STMP.pinctrl.i2c.setup() + local pins = + { + stmp3700 = + { + all = + { + i2c_scl = { bank = 2, pin = 5, muxsel = "MAIN", pull = true}, + i2c_sda = { bank = 2, pin = 6, muxsel = "MAIN", pull = true} + } + }, + imx233 = + { + all = + { + i2c_scl = { bank = 0, pin = 30, muxsel = "MAIN", pull = true}, + i2c_sda = { bank = 0, pin = 31, muxsel = "MAIN", pull = true} + } + } + } + + STMP.pinctrl.configure_ex(pins) +end |