123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- /*
- * (C) Copyright 2007 Michal Simek
- *
- * Michal SIMEK <monstr@monstr.eu>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
- /*
- * Microblaze FSL support
- */
- #include <common.h>
- #include <config.h>
- #include <command.h>
- #include <asm/asm.h>
- int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
- {
- unsigned int fslnum;
- unsigned int num;
- unsigned int blocking;
- if (argc < 2) {
- cmd_usage(cmdtp);
- return 1;
- }
- fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
- if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
- puts ("Bad number of FSL\n");
- cmd_usage(cmdtp);
- return 1;
- }
- switch (fslnum) {
- #if (XILINX_FSL_NUMBER > 0)
- case 0:
- switch (blocking) {
- case 0: NGET (num, 0);
- break;
- case 1: NCGET (num, 0);
- break;
- case 2: GET (num, 0);
- break;
- case 3: CGET (num, 0);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 1)
- case 1:
- switch (blocking) {
- case 0: NGET (num, 1);
- break;
- case 1: NCGET (num, 1);
- break;
- case 2: GET (num, 1);
- break;
- case 3: CGET (num, 1);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 2)
- case 2:
- switch (blocking) {
- case 0: NGET (num, 2);
- break;
- case 1: NCGET (num, 2);
- break;
- case 2: GET (num, 2);
- break;
- case 3: CGET (num, 2);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 3)
- case 3:
- switch (blocking) {
- case 0: NGET (num, 3);
- break;
- case 1: NCGET (num, 3);
- break;
- case 2: GET (num, 3);
- break;
- case 3: CGET (num, 3);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 4)
- case 4:
- switch (blocking) {
- case 0: NGET (num, 4);
- break;
- case 1: NCGET (num, 4);
- break;
- case 2: GET (num, 4);
- break;
- case 3: CGET (num, 4);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 5)
- case 5:
- switch (blocking) {
- case 0: NGET (num, 5);
- break;
- case 1: NCGET (num, 5);
- break;
- case 2: GET (num, 5);
- break;
- case 3: CGET (num, 5);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 6)
- case 6:
- switch (blocking) {
- case 0: NGET (num, 6);
- break;
- case 1: NCGET (num, 6);
- break;
- case 2: GET (num, 6);
- break;
- case 3: CGET (num, 6);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 7)
- case 7:
- switch (blocking) {
- case 0: NGET (num, 7);
- break;
- case 1: NCGET (num, 7);
- break;
- case 2: GET (num, 7);
- break;
- case 3: CGET (num, 7);
- break;
- default:
- return 2;
- }
- break;
- #endif
- default:
- return 1;
- }
- printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
- blocking < 2 ? "non blocking" : "blocking",
- ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
- return 0;
- }
- int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
- {
- unsigned int fslnum;
- unsigned int num;
- unsigned int blocking;
- if (argc < 3) {
- cmd_usage(cmdtp);
- return 1;
- }
- fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
- blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
- if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
- cmd_usage(cmdtp);
- return 1;
- }
- switch (fslnum) {
- #if (XILINX_FSL_NUMBER > 0)
- case 0:
- switch (blocking) {
- case 0: NPUT (num, 0);
- break;
- case 1: NCPUT (num, 0);
- break;
- case 2: PUT (num, 0);
- break;
- case 3: CPUT (num, 0);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 1)
- case 1:
- switch (blocking) {
- case 0: NPUT (num, 1);
- break;
- case 1: NCPUT (num, 1);
- break;
- case 2: PUT (num, 1);
- break;
- case 3: CPUT (num, 1);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 2)
- case 2:
- switch (blocking) {
- case 0: NPUT (num, 2);
- break;
- case 1: NCPUT (num, 2);
- break;
- case 2: PUT (num, 2);
- break;
- case 3: CPUT (num, 2);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 3)
- case 3:
- switch (blocking) {
- case 0: NPUT (num, 3);
- break;
- case 1: NCPUT (num, 3);
- break;
- case 2: PUT (num, 3);
- break;
- case 3: CPUT (num, 3);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 4)
- case 4:
- switch (blocking) {
- case 0: NPUT (num, 4);
- break;
- case 1: NCPUT (num, 4);
- break;
- case 2: PUT (num, 4);
- break;
- case 3: CPUT (num, 4);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 5)
- case 5:
- switch (blocking) {
- case 0: NPUT (num, 5);
- break;
- case 1: NCPUT (num, 5);
- break;
- case 2: PUT (num, 5);
- break;
- case 3: CPUT (num, 5);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 6)
- case 6:
- switch (blocking) {
- case 0: NPUT (num, 6);
- break;
- case 1: NCPUT (num, 6);
- break;
- case 2: PUT (num, 6);
- break;
- case 3: CPUT (num, 6);
- break;
- default:
- return 2;
- }
- break;
- #endif
- #if (XILINX_FSL_NUMBER > 7)
- case 7:
- switch (blocking) {
- case 0: NPUT (num, 7);
- break;
- case 1: NCPUT (num, 7);
- break;
- case 2: PUT (num, 7);
- break;
- case 3: CPUT (num, 7);
- break;
- default:
- return 2;
- }
- break;
- #endif
- default:
- return 1;
- }
- printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
- blocking < 2 ? "non blocking" : "blocking",
- ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
- return 0;
- }
- int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
- {
- unsigned int reg = 0;
- unsigned int val = 0;
- if (argc < 2) {
- cmd_usage(cmdtp);
- return 1;
- }
- reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
- switch (reg) {
- case 0x1:
- if (argc > 2) {
- MTS (val, rmsr);
- NOP;
- MFS (val, rmsr);
- } else {
- MFS (val, rmsr);
- }
- puts ("MSR");
- break;
- case 0x3:
- MFS (val, rear);
- puts ("EAR");
- break;
- case 0x5:
- MFS (val, resr);
- puts ("ESR");
- break;
- default:
- puts ("Unsupported register\n");
- return 1;
- }
- printf (": 0x%08x\n", val);
- return 0;
- }
- /***************************************************/
- U_BOOT_CMD (frd, 3, 1, do_frd,
- "read data from FSL",
- "- [fslnum [0|1|2|3]]\n"
- " 0 - non blocking data read\n"
- " 1 - non blocking control read\n"
- " 2 - blocking data read\n"
- " 3 - blocking control read");
- U_BOOT_CMD (fwr, 4, 1, do_fwr,
- "write data to FSL",
- "- [fslnum [0|1|2|3]]\n"
- " 0 - non blocking data write\n"
- " 1 - non blocking control write\n"
- " 2 - blocking data write\n"
- " 3 - blocking control write");
- U_BOOT_CMD (rspr, 3, 1, do_rspr,
- "read/write special purpose register",
- "- reg_num [write value] read/write special purpose register\n"
- " 1 - MSR - Machine status register\n"
- " 3 - EAR - Exception address register\n"
- " 5 - ESR - Exception status register");
|