diff options
Diffstat (limited to 'utils/hwstub/tools/lua')
-rw-r--r-- | utils/hwstub/tools/lua/atj.lua | 5 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/help.lua | 60 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/jz.lua | 26 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/load.lua | 32 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/pp.lua | 25 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/rk27xx.lua | 7 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp.lua | 42 |
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 | ||
5 | ATJ = {} | 5 | ATJ = {} |
6 | 6 | ||
7 | hwstub.soc:select("atj213x") | 7 | function ATJ.init() |
8 | hwstub.soc:select("atj213x") | ||
9 | end | ||
10 | |||
8 | require "atj/gpio" | 11 | require "atj/gpio" |
9 | require "atj/lcm" | 12 | require "atj/lcm" |
10 | require "atj/dsp" | 13 | require "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 | -- | ||
4 | HELP = hwstub.help | ||
5 | |||
6 | function HELP:create_topic(name) | ||
7 | self[name] = { create_topic = HELP.create_topic, add = HELP.add, get_topic = HELP.get_topic } | ||
8 | return self[name] | ||
9 | end | ||
10 | |||
11 | function HELP:get_topic(name) | ||
12 | return self[name] | ||
13 | end | ||
14 | |||
15 | function HELP:add(text) | ||
16 | table.insert(self, text) | ||
17 | end | ||
18 | |||
19 | do | ||
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."); | ||
60 | end | ||
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 | --- | ||
4 | JZ = { info = {} } | ||
5 | |||
6 | local h = HELP:create_topic("JZ") | ||
7 | h:add("This table contains the abstraction of the different device blocks for the JZ.") | ||
8 | h:add("It allows one to use higher-level primitives rather than poking at register directly.") | ||
9 | |||
10 | hh = h:create_topic("debug") | ||
11 | hh:add("STMP.debug(...) prints some debug output if JZ.debug_on is true and does nothing otherwise.") | ||
12 | |||
13 | JZ.debug_on = false | ||
14 | |||
15 | function STMP.debug(...) | ||
16 | if STMP.debug_on then print(...) end | ||
17 | end | ||
18 | |||
19 | -- init | ||
20 | function 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 | ||
26 | end | ||
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 @@ | |||
1 | package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lua"),2) .. ";" .. package.path | 1 | package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lua"),2) .. ";" .. package.path |
2 | 2 | require "stmp" | |
3 | if hwstub.dev.target.id == hwstub.dev.target.STMP then | 3 | require "pp" |
4 | require "stmp" | 4 | require "rk27xx" |
5 | elseif hwstub.dev.target.id == hwstub.dev.target.PP then | 5 | require "atj" |
6 | require "pp" | 6 | require "jz" |
7 | elseif hwstub.dev.target.id == hwstub.dev.target.RK27 then | ||
8 | require "rk27xx" | ||
9 | elseif hwstub.dev.target.id == hwstub.dev.target.ATJ then | ||
10 | require "atj" | ||
11 | end | ||
12 | |||
13 | require "hwlib" | 7 | require "hwlib" |
14 | require "dumper" | 8 | require "dumper" |
9 | |||
10 | LOAD = {} | ||
11 | |||
12 | function 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 | ||
24 | end \ 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 |
43 | end | 43 | end |
44 | 44 | ||
45 | if PP.is_pp611x() then | ||
46 | identify("PP611x (aka GoForce6110)", "pp6110", "pp6110") | ||
47 | elseif PP.is_pp502x() then | ||
48 | identify("PP502x", "pp502x", "pp502x") | ||
49 | elseif PP.is_pp500x() then | ||
50 | identify("PP500x", "pp500x", "pp500x") | ||
51 | else | ||
52 | print(string.format("Unable to identify this chip as a PP: chipid=0x%x", hwstub.dev.pp.chipid)); | ||
53 | end | ||
54 | |||
55 | hh = h:create_topic("debug") | 45 | hh = h:create_topic("debug") |
56 | hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does nothing otherwise.") | 46 | hh: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 | ||
67 | PP.debug_on = false | 57 | PP.debug_on = false |
68 | 58 | ||
69 | if PP.info.chip ~= nil then | 59 | -- init |
70 | require "pp/gpio" | 60 | function 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 | ||
71 | end | 70 | end |
71 | |||
72 | require "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 | ||
5 | RK27XX = {} | 5 | RK27XX = {} |
6 | 6 | ||
7 | hwstub.soc:select("rk27xx") | 7 | function RK27XX.init() |
8 | require 'rk27xx/lcdif' | 8 | hwstub.soc:select("rk27xx") |
9 | end | ||
10 | |||
11 | require '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 | |||
5 | STMP = { info = {} } | 4 | STMP = { info = {} } |
6 | 5 | ||
7 | local h = HELP:create_topic("STMP") | 6 | local 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 |
50 | end | 49 | end |
51 | 50 | ||
52 | if STMP.is_imx233() then | ||
53 | identify("STMP3780 (aka i.MX233)", "imx233", "imx233") | ||
54 | elseif STMP.is_stmp3700() then | ||
55 | identify("STMP3700", "stmp3700", "stmp3700") | ||
56 | elseif STMP.is_stmp3770() then | ||
57 | identify("STMP3770", "stmp3770", "stmp3700") | ||
58 | elseif STMP.is_stmp3600() then | ||
59 | identify("STMP3600", "stmp3600", "stmp3600") | ||
60 | else | ||
61 | print(string.format("Unable to identify this chip as a STMP: chipid=0x%x", hwstub.dev.stmp.chipid)); | ||
62 | end | ||
63 | |||
64 | hh = h:create_topic("debug") | 51 | hh = h:create_topic("debug") |
65 | hh:add("STMP.debug(...) prints some debug output if STMP.debug_on is true and does nothing otherwise.") | 52 | hh: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 |
71 | end | 58 | end |
72 | 59 | ||
73 | if STMP.info.chip ~= nil then | 60 | -- init |
74 | require "stmp/digctl" | 61 | function 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 |
80 | end \ 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 | ||
73 | end | ||
74 | |||
75 | require "stmp/digctl" | ||
76 | require "stmp/pinctrl" | ||
77 | require "stmp/lcdif" | ||
78 | require "stmp/pwm" | ||
79 | require "stmp/clkctrl" | ||
80 | require "stmp/i2c" \ No newline at end of file | ||