cmd_mfsl.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 *argv[])
  32. {
  33. unsigned int fslnum;
  34. unsigned int num;
  35. unsigned int blocking;
  36. if (argc < 2) {
  37. cmd_usage(cmdtp);
  38. return 1;
  39. }
  40. fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  41. blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  42. if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
  43. puts ("Bad number of FSL\n");
  44. cmd_usage(cmdtp);
  45. return 1;
  46. }
  47. switch (fslnum) {
  48. #if (XILINX_FSL_NUMBER > 0)
  49. case 0:
  50. switch (blocking) {
  51. case 0: NGET (num, 0);
  52. break;
  53. case 1: NCGET (num, 0);
  54. break;
  55. case 2: GET (num, 0);
  56. break;
  57. case 3: CGET (num, 0);
  58. break;
  59. default:
  60. return 2;
  61. }
  62. break;
  63. #endif
  64. #if (XILINX_FSL_NUMBER > 1)
  65. case 1:
  66. switch (blocking) {
  67. case 0: NGET (num, 1);
  68. break;
  69. case 1: NCGET (num, 1);
  70. break;
  71. case 2: GET (num, 1);
  72. break;
  73. case 3: CGET (num, 1);
  74. break;
  75. default:
  76. return 2;
  77. }
  78. break;
  79. #endif
  80. #if (XILINX_FSL_NUMBER > 2)
  81. case 2:
  82. switch (blocking) {
  83. case 0: NGET (num, 2);
  84. break;
  85. case 1: NCGET (num, 2);
  86. break;
  87. case 2: GET (num, 2);
  88. break;
  89. case 3: CGET (num, 2);
  90. break;
  91. default:
  92. return 2;
  93. }
  94. break;
  95. #endif
  96. #if (XILINX_FSL_NUMBER > 3)
  97. case 3:
  98. switch (blocking) {
  99. case 0: NGET (num, 3);
  100. break;
  101. case 1: NCGET (num, 3);
  102. break;
  103. case 2: GET (num, 3);
  104. break;
  105. case 3: CGET (num, 3);
  106. break;
  107. default:
  108. return 2;
  109. }
  110. break;
  111. #endif
  112. #if (XILINX_FSL_NUMBER > 4)
  113. case 4:
  114. switch (blocking) {
  115. case 0: NGET (num, 4);
  116. break;
  117. case 1: NCGET (num, 4);
  118. break;
  119. case 2: GET (num, 4);
  120. break;
  121. case 3: CGET (num, 4);
  122. break;
  123. default:
  124. return 2;
  125. }
  126. break;
  127. #endif
  128. #if (XILINX_FSL_NUMBER > 5)
  129. case 5:
  130. switch (blocking) {
  131. case 0: NGET (num, 5);
  132. break;
  133. case 1: NCGET (num, 5);
  134. break;
  135. case 2: GET (num, 5);
  136. break;
  137. case 3: CGET (num, 5);
  138. break;
  139. default:
  140. return 2;
  141. }
  142. break;
  143. #endif
  144. #if (XILINX_FSL_NUMBER > 6)
  145. case 6:
  146. switch (blocking) {
  147. case 0: NGET (num, 6);
  148. break;
  149. case 1: NCGET (num, 6);
  150. break;
  151. case 2: GET (num, 6);
  152. break;
  153. case 3: CGET (num, 6);
  154. break;
  155. default:
  156. return 2;
  157. }
  158. break;
  159. #endif
  160. #if (XILINX_FSL_NUMBER > 7)
  161. case 7:
  162. switch (blocking) {
  163. case 0: NGET (num, 7);
  164. break;
  165. case 1: NCGET (num, 7);
  166. break;
  167. case 2: GET (num, 7);
  168. break;
  169. case 3: CGET (num, 7);
  170. break;
  171. default:
  172. return 2;
  173. }
  174. break;
  175. #endif
  176. default:
  177. return 1;
  178. }
  179. printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
  180. blocking < 2 ? "non blocking" : "blocking",
  181. ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
  182. return 0;
  183. }
  184. int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  185. {
  186. unsigned int fslnum;
  187. unsigned int num;
  188. unsigned int blocking;
  189. if (argc < 3) {
  190. cmd_usage(cmdtp);
  191. return 1;
  192. }
  193. fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  194. num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  195. blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
  196. if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
  197. cmd_usage(cmdtp);
  198. return 1;
  199. }
  200. switch (fslnum) {
  201. #if (XILINX_FSL_NUMBER > 0)
  202. case 0:
  203. switch (blocking) {
  204. case 0: NPUT (num, 0);
  205. break;
  206. case 1: NCPUT (num, 0);
  207. break;
  208. case 2: PUT (num, 0);
  209. break;
  210. case 3: CPUT (num, 0);
  211. break;
  212. default:
  213. return 2;
  214. }
  215. break;
  216. #endif
  217. #if (XILINX_FSL_NUMBER > 1)
  218. case 1:
  219. switch (blocking) {
  220. case 0: NPUT (num, 1);
  221. break;
  222. case 1: NCPUT (num, 1);
  223. break;
  224. case 2: PUT (num, 1);
  225. break;
  226. case 3: CPUT (num, 1);
  227. break;
  228. default:
  229. return 2;
  230. }
  231. break;
  232. #endif
  233. #if (XILINX_FSL_NUMBER > 2)
  234. case 2:
  235. switch (blocking) {
  236. case 0: NPUT (num, 2);
  237. break;
  238. case 1: NCPUT (num, 2);
  239. break;
  240. case 2: PUT (num, 2);
  241. break;
  242. case 3: CPUT (num, 2);
  243. break;
  244. default:
  245. return 2;
  246. }
  247. break;
  248. #endif
  249. #if (XILINX_FSL_NUMBER > 3)
  250. case 3:
  251. switch (blocking) {
  252. case 0: NPUT (num, 3);
  253. break;
  254. case 1: NCPUT (num, 3);
  255. break;
  256. case 2: PUT (num, 3);
  257. break;
  258. case 3: CPUT (num, 3);
  259. break;
  260. default:
  261. return 2;
  262. }
  263. break;
  264. #endif
  265. #if (XILINX_FSL_NUMBER > 4)
  266. case 4:
  267. switch (blocking) {
  268. case 0: NPUT (num, 4);
  269. break;
  270. case 1: NCPUT (num, 4);
  271. break;
  272. case 2: PUT (num, 4);
  273. break;
  274. case 3: CPUT (num, 4);
  275. break;
  276. default:
  277. return 2;
  278. }
  279. break;
  280. #endif
  281. #if (XILINX_FSL_NUMBER > 5)
  282. case 5:
  283. switch (blocking) {
  284. case 0: NPUT (num, 5);
  285. break;
  286. case 1: NCPUT (num, 5);
  287. break;
  288. case 2: PUT (num, 5);
  289. break;
  290. case 3: CPUT (num, 5);
  291. break;
  292. default:
  293. return 2;
  294. }
  295. break;
  296. #endif
  297. #if (XILINX_FSL_NUMBER > 6)
  298. case 6:
  299. switch (blocking) {
  300. case 0: NPUT (num, 6);
  301. break;
  302. case 1: NCPUT (num, 6);
  303. break;
  304. case 2: PUT (num, 6);
  305. break;
  306. case 3: CPUT (num, 6);
  307. break;
  308. default:
  309. return 2;
  310. }
  311. break;
  312. #endif
  313. #if (XILINX_FSL_NUMBER > 7)
  314. case 7:
  315. switch (blocking) {
  316. case 0: NPUT (num, 7);
  317. break;
  318. case 1: NCPUT (num, 7);
  319. break;
  320. case 2: PUT (num, 7);
  321. break;
  322. case 3: CPUT (num, 7);
  323. break;
  324. default:
  325. return 2;
  326. }
  327. break;
  328. #endif
  329. default:
  330. return 1;
  331. }
  332. printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
  333. blocking < 2 ? "non blocking" : "blocking",
  334. ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
  335. return 0;
  336. }
  337. int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  338. {
  339. unsigned int reg = 0;
  340. unsigned int val = 0;
  341. if (argc < 2) {
  342. cmd_usage(cmdtp);
  343. return 1;
  344. }
  345. reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  346. val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  347. switch (reg) {
  348. case 0x1:
  349. if (argc > 2) {
  350. MTS (val, rmsr);
  351. NOP;
  352. MFS (val, rmsr);
  353. } else {
  354. MFS (val, rmsr);
  355. }
  356. puts ("MSR");
  357. break;
  358. case 0x3:
  359. MFS (val, rear);
  360. puts ("EAR");
  361. break;
  362. case 0x5:
  363. MFS (val, resr);
  364. puts ("ESR");
  365. break;
  366. default:
  367. puts ("Unsupported register\n");
  368. return 1;
  369. }
  370. printf (": 0x%08x\n", val);
  371. return 0;
  372. }
  373. /***************************************************/
  374. U_BOOT_CMD (frd, 3, 1, do_frd,
  375. "frd - read data from FSL\n",
  376. "- [fslnum [0|1|2|3]]\n"
  377. " 0 - non blocking data read\n"
  378. " 1 - non blocking control read\n"
  379. " 2 - blocking data read\n"
  380. " 3 - blocking control read\n");
  381. U_BOOT_CMD (fwr, 4, 1, do_fwr,
  382. "fwr - write data to FSL\n",
  383. "- [fslnum [0|1|2|3]]\n"
  384. " 0 - non blocking data write\n"
  385. " 1 - non blocking control write\n"
  386. " 2 - blocking data write\n"
  387. " 3 - blocking control write\n");
  388. U_BOOT_CMD (rspr, 3, 1, do_rspr,
  389. "rspr - read/write special purpose register\n",
  390. "- reg_num [write value] read/write special purpose register\n"
  391. " 1 - MSR - Machine status register\n"
  392. " 3 - EAR - Exception address register\n"
  393. " 5 - ESR - Exception status register\n");