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