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