cmd_mfsl.c 7.6 KB

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