xref: /netbsd/usr.bin/scmdctl/scmdctlconst.h (revision 32757b83)
1 /*	$NetBSD: scmdctlconst.h,v 1.1 2021/12/07 17:39:55 brad Exp $	*/
2 
3 /*
4  * Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _SCMDCTLCONST_H_
20 #define _SCMDCTLCONST_H_
21 
22 static const struct scmdcmd scmdcmds[] = {
23 	{
24 		.cmd = "identify",
25 		.id = SCMD_IDENTIFY,
26 		.helpargs = "[module]"
27 	},
28 	{
29 		.cmd = "diagnostics",
30 		.id = SCMD_DIAG,
31 		.helpargs = "[module]"
32 	},
33 	{
34 		.cmd = "motor",
35 		.id = SCMD_MOTOR,
36 		.helpargs = "get|set|invert|bridge|enable|disable module([get]|set|invert|bridge) A|B(set|invert) value(set)"
37 	},
38 	{
39 		.cmd = "read_register",
40 		.id = SCMD_READ,
41 		.helpargs = "module register [register_end]"
42 	},
43 	{
44 		.cmd = "write_register",
45 		.id = SCMD_WRITE,
46 		.helpargs = "module register value"
47 	},
48 	{
49 		.cmd = "restart",
50 		.id = SCMD_RESTART,
51 		.helpargs = ""
52 	},
53 	{
54 		.cmd = "re-enumerate",
55 		.id = SCMD_ENUMERATE,
56 		.helpargs = ""
57 	},
58 	{
59 		.cmd = "update_rate",
60 		.id = SCMD_UPDATERATE,
61 		.helpargs = "get|set|force rate(set)"
62 	},
63 	{
64 		.cmd = "expansion_bus",
65 		.id = SCMD_EBUS,
66 		.helpargs = "get|set 50kHz|100kHz|400kHz(set)"
67 	},
68 	{
69 		.cmd = "lock",
70 		.id = SCMD_LOCK,
71 		.helpargs = "get|lock|unlock local_user|local_master|global_user|global_master"
72 	},
73 	{
74 		.cmd = "spi_read_one",
75 		.id = SCMD_SPIREADONE,
76 		.helpargs = ""
77 	}
78 };
79 
80 static const struct scmdcmd motorsubcmds[] = {
81 	{
82 		.cmd = "get",
83 		.id = SCMD_SUBMOTORGET,
84 		.helpargs = ""
85 	},
86 	{
87 		.cmd = "set",
88 		.id = SCMD_SUBMOTORSET,
89 		.helpargs = ""
90 	},
91 	{
92 		.cmd = "invert",
93 		.id = SCMD_SUBMOTORINVERT,
94 		.helpargs = ""
95 	},
96 	{
97 		.cmd = "bridge",
98 		.id = SCMD_SUBMOTORBRIDGE,
99 		.helpargs = ""
100 	},
101 	{
102 		.cmd = "disable",
103 		.id = SCMD_SUBMOTORDISABLE,
104 		.helpargs = ""
105 	},
106 	{
107 		.cmd = "enable",
108 		.id = SCMD_SUBMOTORENABLE,
109 		.helpargs = ""
110 	}
111 };
112 
113 static const struct scmdcmd updateratesubcmds[] = {
114 	{
115 		.cmd = "get",
116 		.id = SCMD_SUBURGET,
117 		.helpargs = ""
118 	},
119 	{
120 		.cmd = "set",
121 		.id = SCMD_SUBURSET,
122 		.helpargs = ""
123 	},
124 	{
125 		.cmd = "force",
126 		.id = SCMD_SUBURFORCE,
127 		.helpargs = ""
128 	}
129 };
130 
131 static const struct scmdcmd ebussubcmds[] = {
132 	{
133 		.cmd = "get",
134 		.id = SCMD_SUBEBUSGET,
135 		.helpargs = ""
136 	},
137 	{
138 		.cmd = "set",
139 		.id = SCMD_SUBEBUSSET,
140 		.helpargs = ""
141 	}
142 };
143 
144 static const struct scmdcmd locksubcmds[] = {
145 	{
146 		.cmd = "get",
147 		.id = SCMD_SUBLOCKGET,
148 		.helpargs = ""
149 	},
150 	{
151 		.cmd = "lock",
152 		.id = SCMD_SUBLOCKLOCK,
153 		.helpargs = ""
154 	},
155 	{
156 		.cmd = "unlock",
157 		.id = SCMD_SUBLOCKUNLOCK,
158 		.helpargs = ""
159 	}
160 };
161 
162 static const struct scmdcmd lockcmdtypes[] = {
163 	{
164 		.cmd = "local_user",
165 		.id = SCMD_LOCAL_USER_LOCK,
166 		.helpargs = ""
167 	},
168 	{
169 		.cmd = "local_master",
170 		.id = SCMD_LOCAL_MASTER_LOCK,
171 		.helpargs = ""
172 	},
173 	{
174 		.cmd = "global_user",
175 		.id = SCMD_GLOBAL_USER_LOCK,
176 		.helpargs = ""
177 	},
178 	{
179 		.cmd = "global_master",
180 		.id = SCMD_GLOBAL_MASTER_LOCK,
181 		.helpargs = ""
182 	}
183 };
184 
185 static const char *ebus_speeds[] = {
186 	"50kHz","100kHz","400kHz"
187 };
188 
189 static const char *scmdregisternames[] = {
190 	"FID",
191 	"ID",
192 	"SLAVE_ADDR",
193 	"CONFIG_BITS",
194 	"U_I2C_RD_ERR",
195 	"U_I2C_WR_ERR",
196 	"U_BUF_DUMPED",
197 	"E_I2C_RD_ERR",
198 	"E_I2C_WR_ERR",
199 	"LOOP_TIME",
200 	"SLV_POLL_CNT",
201 	"SLV_TOP_ADDR",
202 	"MST_E_ERR",
203 	"MST_E_STATUS",
204 	"FSAFE_FAULTS",
205 	"REG_OOR_CNT",
206 	"REG_RO_WRITE_CNT",
207 	"GEN_TEST_WORD",
208 	"MOTOR_A_INVERT",
209 	"MOTOR_B_INVERT",
210 	"BRIDGE",
211 	"LOCAL_MASTER_LOCK",
212 	"LOCAL_USER_LOCK",
213 	"MST_E_IN_FN",
214 	"U_PORT_CLKDIV_U",
215 	"U_PORT_CLKDIV_L",
216 	"U_PORT_CLKDIV_CTRL",
217 	"E_PORT_CLKDIV_U",
218 	"E_PORT_CLKDIV_L",
219 	"E_PORT_CLKDIV_CTRL",
220 	"U_BUS_UART_BAUD",
221 	"FSAFE_CTRL",
222 	"MA_DRIVE",
223 	"MB_DRIVE",
224 	"S1A_DRIVE",
225 	"S1B_DRIVE",
226 	"S2A_DRIVE",
227 	"S2B_DRIVE",
228 	"S3A_DRIVE",
229 	"S3B_DRIVE",
230 	"S4A_DRIVE",
231 	"S4B_DRIVE",
232 	"S5A_DRIVE",
233 	"S5B_DRIVE",
234 	"S6A_DRIVE",
235 	"S6B_DRIVE",
236 	"S7A_DRIVE",
237 	"S7B_DRIVE",
238 	"S8A_DRIVE",
239 	"S8B_DRIVE",
240 	"S9A_DRIVE",
241 	"S9B_DRIVE",
242 	"S10A_DRIVE",
243 	"S10B_DRIVE",
244 	"S11A_DRIVE",
245 	"S11B_DRIVE",
246 	"S12A_DRIVE",
247 	"S12B_DRIVE",
248 	"S13A_DRIVE",
249 	"S13B_DRIVE",
250 	"S14A_DRIVE",
251 	"S14B_DRIVE",
252 	"S15A_DRIVE",
253 	"S15B_DRIVE",
254 	"S16A_DRIVE",
255 	"S16B_DRIVE",
256 	"HOLE_1_42",
257 	"HOLE_1_43",
258 	"HOLE_1_44",
259 	"HOLE_1_45",
260 	"HOLE_1_46",
261 	"HOLE_1_47",
262 	"HOLE_1_48",
263 	"HOLE_1_49",
264 	"HOLE_1_4A",
265 	"HOLE_1_4B",
266 	"HOLE_1_4C",
267 	"HOLE_1_4D",
268 	"HOLE_1_4E",
269 	"HOLE_1_4F",
270 	"INV_2_9",
271 	"INV_10_17",
272 	"INV_18_25",
273 	"INV_26_33",
274 	"BRIDGE_SLV_L",
275 	"BRIDGE_SLV_H",
276 	"HOLE_2_56",
277 	"HOLE_2_57",
278 	"HOLE_2_58",
279 	"HOLE_2_59",
280 	"HOLE_2_5A",
281 	"HOLE_2_5B",
282 	"HOLE_2_5C",
283 	"HOLE_2_5D",
284 	"HOLE_2_5E",
285 	"HOLE_2_5F",
286 	"HOLE_2_60",
287 	"HOLE_2_61",
288 	"HOLE_2_62",
289 	"HOLE_2_63",
290 	"HOLE_2_64",
291 	"HOLE_2_65",
292 	"HOLE_2_66",
293 	"HOLE_2_67",
294 	"HOLE_2_68",
295 	"HOLE_2_69",
296 	"HOLE_2_6A",
297 	"HOLE_2_6B",
298 	"HOLE_2_6C",
299 	"HOLE_2_6D",
300 	"HOLE_2_6E",
301 	"PAGE_SELECT",
302 	"DRIVER_ENABLE",
303 	"UPDATE_RATE",
304 	"FORCE_UPDATE",
305 	"E_BUS_SPEED",
306 	"MASTER_LOCK",
307 	"USER_LOCK",
308 	"FSAFE_TIME",
309 	"STATUS_1",
310 	"CONTROL_1",
311 	"REM_ADDR",
312 	"REM_OFFSET",
313 	"REM_DATA_WR",
314 	"REM_DATA_RD",
315 	"REM_WRITE",
316 	"REM_READ"
317 };
318 
319 #endif
320