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