summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/lua
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/tools/lua')
-rw-r--r--utils/hwstub/tools/lua/atj.lua5
-rw-r--r--utils/hwstub/tools/lua/help.lua60
-rw-r--r--utils/hwstub/tools/lua/jz.lua26
-rw-r--r--utils/hwstub/tools/lua/load.lua32
-rw-r--r--utils/hwstub/tools/lua/pp.lua25
-rw-r--r--utils/hwstub/tools/lua/rk27xx.lua7
-rw-r--r--utils/hwstub/tools/lua/stmp.lua42
7 files changed, 150 insertions, 47 deletions
diff --git a/utils/hwstub/tools/lua/atj.lua b/utils/hwstub/tools/lua/atj.lua
index a1ad0c7505..16d2639f3a 100644
--- a/utils/hwstub/tools/lua/atj.lua
+++ b/utils/hwstub/tools/lua/atj.lua
@@ -4,7 +4,10 @@
4 4
5ATJ = {} 5ATJ = {}
6 6
7hwstub.soc:select("atj213x") 7function ATJ.init()
8 hwstub.soc:select("atj213x")
9end
10
8require "atj/gpio" 11require "atj/gpio"
9require "atj/lcm" 12require "atj/lcm"
10require "atj/dsp" 13require "atj/dsp"
diff --git a/utils/hwstub/tools/lua/help.lua b/utils/hwstub/tools/lua/help.lua
new file mode 100644
index 0000000000..280382eb61
--- /dev/null
+++ b/utils/hwstub/tools/lua/help.lua
@@ -0,0 +1,60 @@
1--
2-- HELP
3--
4HELP = hwstub.help
5
6function HELP:create_topic(name)
7 self[name] = { create_topic = HELP.create_topic, add = HELP.add, get_topic = HELP.get_topic }
8 return self[name]
9end
10
11function HELP:get_topic(name)
12 return self[name]
13end
14
15function HELP:add(text)
16 table.insert(self, text)
17end
18
19do
20 local h = HELP:create_topic("hwstub")
21 h:add("This tool uses a number of well-defined namespaces (tables) to organise its features.")
22 h:add("The hwstub table contains a number of information and functions related to the tool itself.")
23 h:add("Of particular interest are")
24 h:add("* hwstub.host which holds host specific information.")
25 h:add("* hwstub.dev which holds device specific information. See DEV")
26 h:add("* hwstub.help (aka HELP) which holds the help. See HELP.");
27 h:add("* hwstub.soc which holds soc specific information. See HW");
28
29 h = HELP:create_topic("HELP");
30 h:add("This variable redirects to hwstub.help and provides access to the help system.");
31 h:add("You can enhance the help using the following methods on any topic (including HELP itself).");
32 h:add("* t:create_topic(s) to create a new subtopic named s under topic t");
33 h:add("* t:add(s) to add a help line to topic t");
34 h:add("* t:get_topic(s) to get the subtopic s under topic t");
35
36 h = HELP:create_topic("DEV");
37 h:add("This variable redirects to hwstub.dev and provides direct access to the device.");
38 h:add("It contains some information about the device and the following methods.");
39 h:add("* read8/16/32(a) reads a 8/16/32-bit integer at address a atomically");
40 h:add("* write8/16/32(a, v) writes the 8/16/32-bit integer v at address a atomically");
41 h:add("* jump(a) jump to specified address");
42 h:add("* call(a) call function at specified address and return to hwstub");
43 h:add("* print_log() prints the device log");
44
45 h = HELP:create_topic("HW");
46 h:add("This variable redirects to the current soc under hwstub.soc and should be changed by calling hwstub:soc:select only.");
47 h:add("The complete register tree can be found under HW in a well organised fashion.");
48 h:add("* HW.dev points to device dev");
49 h:add("* HW.dev[i] points to device devi if there are several copies of the device at different addresses.");
50 h:add("* HW.dev.reg points to the register reg under dev");
51 h:add("* HW.dev.reg[i] points to the register regi if there are several copies.");
52 h:add("* HW.dev.reg.f points to the field f under register reg.");
53 h:add("* HW.dev.reg.f.v gives the value of named value v of field f.");
54 h:add("* All registers can be read using HW.dev.reg.read() and written using HW.dev.reg.write(v).");
55 h:add("* Register with a SCT variant also implement HW.dev.reg.set/clr/tog(v).");
56 h:add("* All register field can be read using HW.dev.reg.f.read() and written using HW.dev.reg.f.write(v).");
57 h:add("* Field writes can either give a integer or a named value to write(v).");
58 h:add("* Register with a SCT variant also implement HW.dev.reg.f.set/clr/tog(v) with the same properties.");
59 h:add("* All devices, registers and fields also have descriptions available such as addresses.");
60end
diff --git a/utils/hwstub/tools/lua/jz.lua b/utils/hwstub/tools/lua/jz.lua
new file mode 100644
index 0000000000..ab2cb8658f
--- /dev/null
+++ b/utils/hwstub/tools/lua/jz.lua
@@ -0,0 +1,26 @@
1---
2--- Chip Identification
3---
4JZ = { info = {} }
5
6local h = HELP:create_topic("JZ")
7h:add("This table contains the abstraction of the different device blocks for the JZ.")
8h:add("It allows one to use higher-level primitives rather than poking at register directly.")
9
10hh = h:create_topic("debug")
11hh:add("STMP.debug(...) prints some debug output if JZ.debug_on is true and does nothing otherwise.")
12
13JZ.debug_on = false
14
15function STMP.debug(...)
16 if STMP.debug_on then print(...) end
17end
18
19-- init
20function JZ.init()
21 local desc = string.format("jz%04x%c", hwstub.dev.jz.chipid, hwstub.dev.jz.rev)
22 desc = desc:lower()
23 if not hwstub.soc:select(desc) then
24 print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.")
25 end
26end
diff --git a/utils/hwstub/tools/lua/load.lua b/utils/hwstub/tools/lua/load.lua
index f636360c4c..cafa82751e 100644
--- a/utils/hwstub/tools/lua/load.lua
+++ b/utils/hwstub/tools/lua/load.lua
@@ -1,14 +1,24 @@
1package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lua"),2) .. ";" .. package.path 1package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lua"),2) .. ";" .. package.path
2 2require "stmp"
3if hwstub.dev.target.id == hwstub.dev.target.STMP then 3require "pp"
4 require "stmp" 4require "rk27xx"
5elseif hwstub.dev.target.id == hwstub.dev.target.PP then 5require "atj"
6 require "pp" 6require "jz"
7elseif hwstub.dev.target.id == hwstub.dev.target.RK27 then
8 require "rk27xx"
9elseif hwstub.dev.target.id == hwstub.dev.target.ATJ then
10 require "atj"
11end
12
13require "hwlib" 7require "hwlib"
14require "dumper" 8require "dumper"
9
10LOAD = {}
11
12function LOAD.init()
13 if hwstub.dev.target.id == hwstub.dev.target.STMP then
14 STMP.init()
15 elseif hwstub.dev.target.id == hwstub.dev.target.PP then
16 PP.init()
17 elseif hwstub.dev.target.id == hwstub.dev.target.RK27 then
18 RK27XX.init()
19 elseif hwstub.dev.target.id == hwstub.dev.target.ATJ then
20 ATJ.init()
21 elseif hwstub.dev.target.id == hwstub.dev.target.JZ then
22 JZ.init()
23 end
24end \ No newline at end of file
diff --git a/utils/hwstub/tools/lua/pp.lua b/utils/hwstub/tools/lua/pp.lua
index f9234780e5..38a4c1d0a2 100644
--- a/utils/hwstub/tools/lua/pp.lua
+++ b/utils/hwstub/tools/lua/pp.lua
@@ -42,16 +42,6 @@ function PP.is_pp500x()
42 return hwstub.dev.pp.chipid >= 0x5000 and hwstub.dev.pp.chipid < 0x5010 42 return hwstub.dev.pp.chipid >= 0x5000 and hwstub.dev.pp.chipid < 0x5010
43end 43end
44 44
45if PP.is_pp611x() then
46 identify("PP611x (aka GoForce6110)", "pp6110", "pp6110")
47elseif PP.is_pp502x() then
48 identify("PP502x", "pp502x", "pp502x")
49elseif PP.is_pp500x() then
50 identify("PP500x", "pp500x", "pp500x")
51else
52 print(string.format("Unable to identify this chip as a PP: chipid=0x%x", hwstub.dev.pp.chipid));
53end
54
55hh = h:create_topic("debug") 45hh = h:create_topic("debug")
56hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does nothing otherwise.") 46hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does nothing otherwise.")
57 47
@@ -66,6 +56,17 @@ hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does n
66 56
67PP.debug_on = false 57PP.debug_on = false
68 58
69if PP.info.chip ~= nil then 59-- init
70 require "pp/gpio" 60function PP.init()
61 if PP.is_pp611x() then
62 identify("PP611x (aka GoForce6110)", "pp6110", "pp6110")
63 elseif PP.is_pp502x() then
64 identify("PP502x", "pp502x", "pp502x")
65 elseif PP.is_pp500x() then
66 identify("PP500x", "pp500x", "pp500x")
67 else
68 print(string.format("Unable to identify this chip as a PP: chipid=0x%x", hwstub.dev.pp.chipid));
69 end
71end 70end
71
72require "pp/gpio"
diff --git a/utils/hwstub/tools/lua/rk27xx.lua b/utils/hwstub/tools/lua/rk27xx.lua
index 2a5bb9287c..f7f1f7a60f 100644
--- a/utils/hwstub/tools/lua/rk27xx.lua
+++ b/utils/hwstub/tools/lua/rk27xx.lua
@@ -4,5 +4,8 @@
4 4
5RK27XX = {} 5RK27XX = {}
6 6
7hwstub.soc:select("rk27xx") 7function RK27XX.init()
8require 'rk27xx/lcdif' 8 hwstub.soc:select("rk27xx")
9end
10
11require 'rk27xx/lradc'
diff --git a/utils/hwstub/tools/lua/stmp.lua b/utils/hwstub/tools/lua/stmp.lua
index 807c18df8d..ea1cde9c6d 100644
--- a/utils/hwstub/tools/lua/stmp.lua
+++ b/utils/hwstub/tools/lua/stmp.lua
@@ -1,7 +1,6 @@
1--- 1---
2--- Chip Identification 2--- Chip Identification
3--- 3---
4
5STMP = { info = {} } 4STMP = { info = {} }
6 5
7local h = HELP:create_topic("STMP") 6local h = HELP:create_topic("STMP")
@@ -49,18 +48,6 @@ function STMP.is_stmp3600()
49 return hwstub.dev.stmp.chipid >= 0x3600 and hwstub.dev.stmp.chipid < 0x3700 48 return hwstub.dev.stmp.chipid >= 0x3600 and hwstub.dev.stmp.chipid < 0x3700
50end 49end
51 50
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") 51hh = h:create_topic("debug")
65hh:add("STMP.debug(...) prints some debug output if STMP.debug_on is true and does nothing otherwise.") 52hh:add("STMP.debug(...) prints some debug output if STMP.debug_on is true and does nothing otherwise.")
66 53
@@ -70,11 +57,24 @@ function STMP.debug(...)
70 if STMP.debug_on then print(...) end 57 if STMP.debug_on then print(...) end
71end 58end
72 59
73if STMP.info.chip ~= nil then 60-- init
74 require "stmp/digctl" 61function STMP.init()
75 require "stmp/pinctrl" 62 if STMP.is_imx233() then
76 require "stmp/lcdif" 63 identify("STMP3780 (aka i.MX233)", "imx233", "imx233")
77 require "stmp/pwm" 64 elseif STMP.is_stmp3700() then
78 require "stmp/clkctrl" 65 identify("STMP3700", "stmp3700", "stmp3700")
79 require "stmp/i2c" 66 elseif STMP.is_stmp3770() then
80end \ No newline at end of file 67 identify("STMP3770", "stmp3770", "stmp3700")
68 elseif STMP.is_stmp3600() then
69 identify("STMP3600", "stmp3600", "stmp3600")
70 else
71 print(string.format("Unable to identify this chip as a STMP: chipid=0x%x", hwstub.dev.stmp.chipid));
72 end
73end
74
75require "stmp/digctl"
76require "stmp/pinctrl"
77require "stmp/lcdif"
78require "stmp/pwm"
79require "stmp/clkctrl"
80require "stmp/i2c" \ No newline at end of file