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