cmd_mfsl.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /*
  2. * (C) Copyright 2007 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /*
  25. * Microblaze FSL support
  26. */
  27. #include <common.h>
  28. #include <config.h>
  29. #include <command.h>
  30. #include <asm/asm.h>
  31. int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  32. {
  33. unsigned int fslnum;
  34. unsigned int num;
  35. unsigned int blocking;
  36. if (argc < 2)
  37. return cmd_usage(cmdtp);
  38. fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  39. blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  40. if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
  41. puts ("Bad number of FSL\n");
  42. return cmd_usage(cmdtp);
  43. }
  44. switch (fslnum) {
  45. #if (XILINX_FSL_NUMBER > 0)
  46. case 0:
  47. switch (blocking) {
  48. case 0: NGET (num, 0);
  49. break;
  50. case 1: NCGET (num, 0);
  51. break;
  52. case 2: GET (num, 0);
  53. break;
  54. case 3: CGET (num, 0);
  55. break;
  56. default:
  57. return 2;
  58. }
  59. break;
  60. #endif
  61. #if (XILINX_FSL_NUMBER > 1)
  62. case 1:
  63. switch (blocking) {
  64. case 0: NGET (num, 1);
  65. break;
  66. case 1: NCGET (num, 1);
  67. break;
  68. case 2: GET (num, 1);
  69. break;
  70. case 3: CGET (num, 1);
  71. break;
  72. default:
  73. return 2;
  74. }
  75. break;
  76. #endif
  77. #if (XILINX_FSL_NUMBER > 2)
  78. case 2:
  79. switch (blocking) {
  80. case 0: NGET (num, 2);
  81. break;
  82. case 1: NCGET (num, 2);
  83. break;
  84. case 2: GET (num, 2);
  85. break;
  86. case 3: CGET (num, 2);
  87. break;
  88. default:
  89. return 2;
  90. }
  91. break;
  92. #endif
  93. #if (XILINX_FSL_NUMBER > 3)
  94. case 3:
  95. switch (blocking) {
  96. case 0: NGET (num, 3);
  97. break;
  98. case 1: NCGET (num, 3);
  99. break;
  100. case 2: GET (num, 3);
  101. break;
  102. case 3: CGET (num, 3);
  103. break;
  104. default:
  105. return 2;
  106. }
  107. break;
  108. #endif
  109. #if (XILINX_FSL_NUMBER > 4)
  110. case 4:
  111. switch (blocking) {
  112. case 0: NGET (num, 4);
  113. break;
  114. case 1: NCGET (num, 4);
  115. break;
  116. case 2: GET (num, 4);
  117. break;
  118. case 3: CGET (num, 4);
  119. break;
  120. default:
  121. return 2;
  122. }
  123. break;
  124. #endif
  125. #if (XILINX_FSL_NUMBER > 5)
  126. case 5:
  127. switch (blocking) {
  128. case 0: NGET (num, 5);
  129. break;
  130. case 1: NCGET (num, 5);
  131. break;
  132. case 2: GET (num, 5);
  133. break;
  134. case 3: CGET (num, 5);
  135. break;
  136. default:
  137. return 2;
  138. }
  139. break;
  140. #endif
  141. #if (XILINX_FSL_NUMBER > 6)
  142. case 6:
  143. switch (blocking) {
  144. case 0: NGET (num, 6);
  145. break;
  146. case 1: NCGET (num, 6);
  147. break;
  148. case 2: GET (num, 6);
  149. break;
  150. case 3: CGET (num, 6);
  151. break;
  152. default:
  153. return 2;
  154. }
  155. break;
  156. #endif
  157. #if (XILINX_FSL_NUMBER > 7)
  158. case 7:
  159. switch (blocking) {
  160. case 0: NGET (num, 7);
  161. break;
  162. case 1: NCGET (num, 7);
  163. break;
  164. case 2: GET (num, 7);
  165. break;
  166. case 3: CGET (num, 7);
  167. break;
  168. default:
  169. return 2;
  170. }
  171. break;
  172. #endif
  173. default:
  174. return 1;
  175. }
  176. printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
  177. blocking < 2 ? "non blocking" : "blocking",
  178. ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
  179. return 0;
  180. }
  181. int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  182. {
  183. unsigned int fslnum;
  184. unsigned int num;
  185. unsigned int blocking;
  186. if (argc < 3)
  187. return cmd_usage(cmdtp);
  188. fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  189. num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  190. blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
  191. if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
  192. return cmd_usage(cmdtp);
  193. switch (fslnum) {
  194. #if (XILINX_FSL_NUMBER > 0)
  195. case 0:
  196. switch (blocking) {
  197. case 0: NPUT (num, 0);
  198. break;
  199. case 1: NCPUT (num, 0);
  200. break;
  201. case 2: PUT (num, 0);
  202. break;
  203. case 3: CPUT (num, 0);
  204. break;
  205. default:
  206. return 2;
  207. }
  208. break;
  209. #endif
  210. #if (XILINX_FSL_NUMBER > 1)
  211. case 1:
  212. switch (blocking) {
  213. case 0: NPUT (num, 1);
  214. break;
  215. case 1: NCPUT (num, 1);
  216. break;
  217. case 2: PUT (num, 1);
  218. break;
  219. case 3: CPUT (num, 1);
  220. break;
  221. default:
  222. return 2;
  223. }
  224. break;
  225. #endif
  226. #if (XILINX_FSL_NUMBER > 2)
  227. case 2:
  228. switch (blocking) {
  229. case 0: NPUT (num, 2);
  230. break;
  231. case 1: NCPUT (num, 2);
  232. break;
  233. case 2: PUT (num, 2);
  234. break;
  235. case 3: CPUT (num, 2);
  236. break;
  237. default:
  238. return 2;
  239. }
  240. break;
  241. #endif
  242. #if (XILINX_FSL_NUMBER > 3)
  243. case 3:
  244. switch (blocking) {
  245. case 0: NPUT (num, 3);
  246. break;
  247. case 1: NCPUT (num, 3);
  248. break;
  249. case 2: PUT (num, 3);
  250. break;
  251. case 3: CPUT (num, 3);
  252. break;
  253. default:
  254. return 2;
  255. }
  256. break;
  257. #endif
  258. #if (XILINX_FSL_NUMBER > 4)
  259. case 4:
  260. switch (blocking) {
  261. case 0: NPUT (num, 4);
  262. break;
  263. case 1: NCPUT (num, 4);
  264. break;
  265. case 2: PUT (num, 4);
  266. break;
  267. case 3: CPUT (num, 4);
  268. break;
  269. default:
  270. return 2;
  271. }
  272. break;
  273. #endif
  274. #if (XILINX_FSL_NUMBER > 5)
  275. case 5:
  276. switch (blocking) {
  277. case 0: NPUT (num, 5);
  278. break;
  279. case 1: NCPUT (num, 5);
  280. break;
  281. case 2: PUT (num, 5);
  282. break;
  283. case 3: CPUT (num, 5);
  284. break;
  285. default:
  286. return 2;
  287. }
  288. break;
  289. #endif
  290. #if (XILINX_FSL_NUMBER > 6)
  291. case 6:
  292. switch (blocking) {
  293. case 0: NPUT (num, 6);
  294. break;
  295. case 1: NCPUT (num, 6);
  296. break;
  297. case 2: PUT (num, 6);
  298. break;
  299. case 3: CPUT (num, 6);
  300. break;
  301. default:
  302. return 2;
  303. }
  304. break;
  305. #endif
  306. #if (XILINX_FSL_NUMBER > 7)
  307. case 7:
  308. switch (blocking) {
  309. case 0: NPUT (num, 7);
  310. break;
  311. case 1: NCPUT (num, 7);
  312. break;
  313. case 2: PUT (num, 7);
  314. break;
  315. case 3: CPUT (num, 7);
  316. break;
  317. default:
  318. return 2;
  319. }
  320. break;
  321. #endif
  322. default:
  323. return 1;
  324. }
  325. printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
  326. blocking < 2 ? "non blocking" : "blocking",
  327. ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
  328. return 0;
  329. }
  330. int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  331. {
  332. unsigned int reg = 0;
  333. unsigned int val = 0;
  334. if (argc < 2)
  335. return cmd_usage(cmdtp);
  336. reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  337. val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  338. switch (reg) {
  339. case 0x1:
  340. if (argc > 2) {
  341. MTS (val, rmsr);
  342. NOP;
  343. MFS (val, rmsr);
  344. } else {
  345. MFS (val, rmsr);
  346. }
  347. puts ("MSR");
  348. break;
  349. case 0x3:
  350. MFS (val, rear);
  351. puts ("EAR");
  352. break;
  353. case 0x5:
  354. MFS (val, resr);
  355. puts ("ESR");
  356. break;
  357. default:
  358. puts ("Unsupported register\n");
  359. return 1;
  360. }
  361. printf (": 0x%08x\n", val);
  362. return 0;
  363. }
  364. /***************************************************/
  365. U_BOOT_CMD (frd, 3, 1, do_frd,
  366. "read data from FSL",
  367. "- [fslnum [0|1|2|3]]\n"
  368. " 0 - non blocking data read\n"
  369. " 1 - non blocking control read\n"
  370. " 2 - blocking data read\n"
  371. " 3 - blocking control read");
  372. U_BOOT_CMD (fwr, 4, 1, do_fwr,
  373. "write data to FSL",
  374. "- [fslnum [0|1|2|3]]\n"
  375. " 0 - non blocking data write\n"
  376. " 1 - non blocking control write\n"
  377. " 2 - blocking data write\n"
  378. " 3 - blocking control write");
  379. U_BOOT_CMD (rspr, 3, 1, do_rspr,
  380. "read/write special purpose register",
  381. "- reg_num [write value] read/write special purpose register\n"
  382. " 1 - MSR - Machine status register\n"
  383. " 3 - EAR - Exception address register\n"
  384. " 5 - ESR - Exception status register");