summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/lua/stmp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/tools/lua/stmp.lua')
-rw-r--r--utils/hwstub/tools/lua/stmp.lua78
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/stmp.lua b/utils/hwstub/tools/lua/stmp.lua
new file mode 100644
index 0000000000..8f93b86c46
--- /dev/null
+++ b/utils/hwstub/tools/lua/stmp.lua
@@ -0,0 +1,78 @@
1---
2--- Chip Identification
3---
4
5STMP = { info = {} }
6
7local h = HELP:create_topic("STMP")
8h:add("This table contains the abstraction of the different device blocks for the STMP.")
9h:add("It allows one to use higher-level primitives rather than poking at register directly.")
10h:add("Furthermore, it tries as much as possible to hide the differences between the different STMP families.")
11
12local function identify(name, family, desc)
13 STMP.chipid = hwstub.dev.stmp.chipid
14 STMP.info.chip = name
15 STMP.info.revision = "TA" .. tostring(hwstub.dev.stmp.rev+1)
16 STMP.desc = desc
17 STMP.family = family
18 print("Chip identified as " .. name ..", ROM " .. STMP.info.revision)
19 if not hwstub.soc:select(desc) then
20 print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.")
21 end
22end
23
24local hh = h:create_topic("is_imx233")
25hh:add("STMP.is_imx233() returns true if the chip ID reports a i.MX233")
26
27function STMP.is_imx233()
28 return hwstub.dev.stmp.chipid == 0x3780
29end
30
31hh = h:create_topic("is_stmp3700")
32hh:add("STMP.is_stmp3700() returns true if the chip ID reports a STMP3700")
33
34function STMP.is_stmp3700()
35 return hwstub.dev.stmp.chipid == 0x3700
36end
37
38hh = h:create_topic("is_stmp3770")
39hh:add("STMP.is_stmp3770() returns true if the chip ID reports a STMP3770")
40
41function STMP.is_stmp3770()
42 return hwstub.dev.stmp.chipid == 0x37b0
43end
44
45hh = h:create_topic("is_stmp3600")
46hh:add("STMP.is_stmp3600() returns true if the chip ID reports a STMP36xx")
47
48function STMP.is_stmp3600()
49 return hwstub.dev.stmp.chipid >= 0x3600 and hwstub.dev.stmp.chipid < 0x3700
50end
51
52if STMP.is_imx233() then
53 identify("STMP3780 (aka i.MX233)", "imx233", "imx233")
54elseif STMP.is_stmp3700() then
55 identify("STMP3700", "stmp3700", "stmp3700")
56elseif STMP.is_stmp3770() then
57 identify("STMP3770", "stmp3770", "stmp3700")
58elseif STMP.is_stmp3600() then
59 identify("STMP3600", "stmp3600", "stmp3600")
60else
61 print(string.format("Unable to identify this chip as a STMP: chipid=0x%x", hwstub.dev.stmp.chipid));
62end
63
64hh = h:create_topic("debug")
65hh:add("STMP.debug(...) prints some debug output if STMP.debug_on is true and does nothing otherwise.")
66
67STMP.debug_on = false
68
69function STMP.debug(...)
70 if STMP.debug_on then print(...) end
71end
72
73if STMP.info.chip ~= nil then
74 require "stmp/digctl"
75 require "stmp/pinctrl"
76 require "stmp/lcdif"
77 require "stmp/pwm"
78end \ No newline at end of file