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> |
| 32 | #include <asm/asm.h> |
| 33 | |
| 34 | #if (CONFIG_COMMANDS & CFG_CMD_MFSL) |
| 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: |
| 58 | if (blocking) { |
| 59 | GET (num, 0); |
| 60 | } else { |
| 61 | NGET (num, 0); |
| 62 | } |
| 63 | break; |
| 64 | #endif |
| 65 | #if (XILINX_FSL_NUMBER > 1) |
| 66 | case 1: |
| 67 | if (blocking) { |
| 68 | GET (num, 1); |
| 69 | } else { |
| 70 | NGET (num, 1); |
| 71 | } |
| 72 | break; |
| 73 | #endif |
| 74 | #if (XILINX_FSL_NUMBER > 2) |
| 75 | case 2: |
| 76 | if (blocking) { |
| 77 | GET (num, 2); |
| 78 | } else { |
| 79 | NGET (num, 2); |
| 80 | } |
| 81 | break; |
| 82 | #endif |
| 83 | #if (XILINX_FSL_NUMBER > 3) |
| 84 | case 3: |
| 85 | if (blocking) { |
| 86 | GET (num, 3); |
| 87 | } else { |
| 88 | NGET (num, 3); |
| 89 | } |
| 90 | break; |
| 91 | #endif |
| 92 | #if (XILINX_FSL_NUMBER > 4) |
| 93 | case 4: |
| 94 | if (blocking) { |
| 95 | GET (num, 4); |
| 96 | } else { |
| 97 | NGET (num, 4); |
| 98 | } |
| 99 | break; |
| 100 | #endif |
| 101 | #if (XILINX_FSL_NUMBER > 5) |
| 102 | case 5: |
| 103 | if (blocking) { |
| 104 | GET (num, 5); |
| 105 | } else { |
| 106 | NGET (num, 5); |
| 107 | } |
| 108 | break; |
| 109 | #endif |
| 110 | #if (XILINX_FSL_NUMBER > 6) |
| 111 | case 6: |
| 112 | if (blocking) { |
| 113 | GET (num, 6); |
| 114 | } else { |
| 115 | NGET (num, 6); |
| 116 | } |
| 117 | break; |
| 118 | #endif |
| 119 | #if (XILINX_FSL_NUMBER > 7) |
| 120 | case 7: |
| 121 | if (blocking) { |
| 122 | GET (num, 7); |
| 123 | } else { |
| 124 | NGET (num, 7); |
| 125 | } |
| 126 | break; |
| 127 | #endif |
| 128 | default: |
| 129 | return 1; |
| 130 | } |
| 131 | |
| 132 | printf ("%01x: 0x%08lx - %s read\n", fslnum, num, |
| 133 | blocking ? "blocking" : "non blocking"); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 138 | { |
| 139 | unsigned int fslnum; |
| 140 | unsigned int num; |
| 141 | unsigned int blocking; |
| 142 | |
| 143 | if (argc < 3) { |
| 144 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 145 | return 1; |
| 146 | } |
| 147 | |
| 148 | fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16); |
| 149 | num = (unsigned int)simple_strtoul (argv[2], NULL, 16); |
| 150 | blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16); |
| 151 | if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { |
| 152 | printf ("Bad number of FSL\nUsage:\n%s\n", cmdtp->usage); |
| 153 | return 1; |
| 154 | } |
| 155 | |
| 156 | switch (fslnum) { |
| 157 | #if (XILINX_FSL_NUMBER > 0) |
| 158 | case 0: |
| 159 | if (blocking) { |
| 160 | PUT (num, 0); |
| 161 | } else { |
| 162 | NPUT (num, 0); |
| 163 | } |
| 164 | break; |
| 165 | #endif |
| 166 | #if (XILINX_FSL_NUMBER > 1) |
| 167 | case 1: |
| 168 | if (blocking) { |
| 169 | PUT (num, 1); |
| 170 | } else { |
| 171 | NPUT (num, 1); |
| 172 | } |
| 173 | break; |
| 174 | #endif |
| 175 | #if (XILINX_FSL_NUMBER > 2) |
| 176 | case 2: |
| 177 | if (blocking) { |
| 178 | PUT (num, 2); |
| 179 | } else { |
| 180 | NPUT (num, 2); |
| 181 | } |
| 182 | break; |
| 183 | #endif |
| 184 | #if (XILINX_FSL_NUMBER > 3) |
| 185 | case 3: |
| 186 | if (blocking) { |
| 187 | PUT (num, 3); |
| 188 | } else { |
| 189 | NPUT (num, 3); |
| 190 | } |
| 191 | break; |
| 192 | #endif |
| 193 | #if (XILINX_FSL_NUMBER > 4) |
| 194 | case 4: |
| 195 | if (blocking) { |
| 196 | PUT (num, 4); |
| 197 | } else { |
| 198 | NPUT (num, 4); |
| 199 | } |
| 200 | break; |
| 201 | #endif |
| 202 | #if (XILINX_FSL_NUMBER > 5) |
| 203 | case 5: |
| 204 | if (blocking) { |
| 205 | PUT (num, 5); |
| 206 | } else { |
| 207 | NPUT (num, 5); |
| 208 | } |
| 209 | break; |
| 210 | #endif |
| 211 | #if (XILINX_FSL_NUMBER > 6) |
| 212 | case 6: |
| 213 | if (blocking) { |
| 214 | PUT (num, 6); |
| 215 | } else { |
| 216 | NPUT (num, 6); |
| 217 | } |
| 218 | break; |
| 219 | #endif |
| 220 | #if (XILINX_FSL_NUMBER > 7) |
| 221 | case 7: |
| 222 | if (blocking) { |
| 223 | PUT (num, 7); |
| 224 | } else { |
| 225 | NPUT (num, 7); |
| 226 | } |
| 227 | break; |
| 228 | #endif |
| 229 | default: |
| 230 | return 1; |
| 231 | } |
| 232 | |
| 233 | printf ("%01x: 0x%08lx - %s write\n", fslnum, num, |
| 234 | blocking ? "blocking" : "non blocking"); |
| 235 | return 0; |
| 236 | |
| 237 | } |
| 238 | |
| 239 | int do_rmsr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 240 | { |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame^] | 241 | unsigned int val = 0; |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 242 | |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame^] | 243 | val = (unsigned int)simple_strtoul (argv[1], NULL, 16); |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 244 | if (argc < 1) { |
| 245 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 246 | return 1; |
| 247 | } |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame^] | 248 | if (argc > 1) { |
| 249 | MTS (val); |
| 250 | MFS (val); |
| 251 | } else { |
| 252 | MFS (val); |
| 253 | } |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 254 | printf ("rmsr: 0x%08lx\n", val); |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | /***************************************************/ |
| 259 | |
| 260 | U_BOOT_CMD (frd, 3, 1, do_frd, |
| 261 | "frd - read data from FSL\n", |
| 262 | "- [fslnum [0|x]], (0 - non blocking|x - blocking).\n"); |
| 263 | |
| 264 | U_BOOT_CMD (fwr, 4, 1, do_fwr, |
| 265 | "fwr - write data to FSL\n", |
| 266 | "- [fslnum data [0|x]], (0 - non blocking|x - blocking).\n"); |
| 267 | |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame^] | 268 | U_BOOT_CMD (rmsr, 3, 1, do_rmsr, |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 269 | "rmsr - read MSR register\n", "- read MSR register.\n"); |
| 270 | |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame^] | 271 | #endif /* CONFIG_MICROBLAZE & CFG_CMD_MFSL */ |