1/* ********************************************************************* 2 * Broadcom Common Firmware Environment (CFE) 3 * 4 * BCM91480B-specific commands File: ui_bcm91480b.c 5 * 6 * A temporary sandbox for misc test routines and commands. 7 * 8 * Author: Mitch Lichtenberg 9 * 10 ********************************************************************* 11 * 12 * Copyright 2000,2001,2002,2003 13 * Broadcom Corporation. All rights reserved. 14 * 15 * This software is furnished under license and may be used and 16 * copied only in accordance with the following terms and 17 * conditions. Subject to these conditions, you may download, 18 * copy, install, use, modify and distribute modified or unmodified 19 * copies of this software in source and/or binary form. No title 20 * or ownership is transferred hereby. 21 * 22 * 1) Any source code used, modified or distributed must reproduce 23 * and retain this copyright notice and list of conditions 24 * as they appear in the source file. 25 * 26 * 2) No right is granted to use any trade name, trademark, or 27 * logo of Broadcom Corporation. The "Broadcom Corporation" 28 * name may not be used to endorse or promote products derived 29 * from this software without the prior written permission of 30 * Broadcom Corporation. 31 * 32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 44 * THE POSSIBILITY OF SUCH DAMAGE. 45 ********************************************************************* */ 46 47 48#include "cfe.h" 49#include "ui_command.h" 50 51#include "bcm91480b.h" 52#include "lib_hssubr.h" 53#include "lib_try.h" 54#include "lib_memfuncs.h" 55#include "sb1250_defs.h" 56#include "bcm1480_regs.h" 57#include "bcm1480_scd.h" 58 59/* ********************************************************************* 60 * Configuration 61 ********************************************************************* */ 62 63 64/* ********************************************************************* 65 * prototypes 66 ********************************************************************* */ 67 68int ui_init_bcm91480bcmds(void); 69 70 71/* ********************************************************************* 72 * Data 73 ********************************************************************* */ 74 75static int ui_cmd_uacwrite(ui_cmdline_t *cmd,int argc,char *argv[]) 76{ 77 uint32_t addr = 0; 78 hsaddr_t haddr; 79 uint64_t data0 = 0; 80 uint64_t data1 = 0; 81 uint64_t data2 = 0; 82 uint64_t data3 = 0; 83 int loops = 1; 84 int idx; 85 char *x; 86 87 if (((x = cmd_getarg(cmd,0)))) addr = lib_xtoi(x); 88 else ui_showusage(cmd); 89 90 haddr = PHYS_TO_XKPHYS(K_CALG_UNCACHED_ACCEL, (hsaddr_t)addr); 91 92 if (((x = cmd_getarg(cmd,1)))) data0 = lib_xtoq(x); 93 else ui_showusage(cmd); 94 if (((x = cmd_getarg(cmd,2)))) data1 = lib_xtoq(x); 95 else ui_showusage(cmd); 96 if (((x = cmd_getarg(cmd,3)))) data2 = lib_xtoq(x); 97 else ui_showusage(cmd); 98 if (((x = cmd_getarg(cmd,4)))) data3 = lib_xtoq(x); 99 else ui_showusage(cmd); 100 101 if (cmd_sw_value(cmd,"-loops",&x)) loops = atoi(x); 102 103 for (idx = 0; idx < loops; idx++) { 104 __asm __volatile ( " sd %0,0(%4) ; " 105 " sd %1,8(%4) ; " 106 " sd %2,16(%4) ; " 107 " sd %3,24(%4) ; " 108 " sync ; " 109 " sync " 110 : : "r"(data0),"r"(data1),"r"(data2),"r"(data3),"r"(haddr)); 111 } 112 113 return 0; 114 115} 116 117static int ui_cmd_memmargin(ui_cmdline_t *cmd,int argc,char *argv[]) 118{ 119 hsaddr_t uacbase = PHYS_TO_XKPHYS(K_CALG_UNCACHED_ACCEL, (hsaddr_t)0x500); 120 hsaddr_t ucbase = PHYS_TO_XKPHYS(K_CALG_UNCACHED, (hsaddr_t)0x500); 121 int nblks=1024*1024; 122 uint64_t offset = 0; 123 uint64_t d0,d1,d2,d3; 124 uint64_t pattern; 125 int passnum = 0; 126 int idx; 127 int errors = 0; 128 int wo,ro; 129 130 ro = cmd_sw_isset(cmd,"-ro"); 131 wo = cmd_sw_isset(cmd,"-wo"); 132 133 if (ro && wo) return -1; 134 135 for (;;) { 136 errors = 0; 137 if (!ro) { 138 offset = 0; 139 pattern = 0x5555555555555555ULL; 140 if (passnum&1) pattern = ~pattern; 141 for (idx = 0; idx < nblks; idx++,offset += 32) { 142 __asm __volatile ( " sd %0,0(%1) ; " 143 " sd %0,8(%1) ; " 144 " sd %0,16(%1) ; " 145 " sd %0,24(%1) ; " 146 " sync ; " 147 " sync " 148 : : "r"(pattern),"r"(uacbase+offset)); 149 pattern = ~pattern; 150 } 151 } 152 153 if (!wo) { 154 errors = 0; 155 pattern = 0x5555555555555555ULL; 156 offset = 0; 157 if (passnum&1) pattern = ~pattern; 158 for (idx = 0; idx < nblks; idx++,offset += 32) { 159 __asm __volatile ( " ld %1,0(%0) ; " 160 " ld %2,8(%0) ; " 161 " ld %3,16(%0) ; " 162 " ld %4,24(%0) ; " 163 " sync ; " 164 " sync " 165 : "=r"(d0),"=r"(d1),"=r"(d2),"=r"(d3) :"r"(ucbase+offset)); 166 if ((d0 != pattern) || (d1 != pattern) || (d2 !=pattern) || (d3 != pattern)) errors++; 167 pattern = ~pattern; 168 } 169 } 170 if (console_status()) break; 171 printf("%5d Errors: %d\n",passnum,errors); 172 errors = 0; 173 passnum++; 174 } 175 176 return 0; 177 178} 179 180 181#if CFG_LDT 182/* ********************************************************************* 183 * ui_cmd_node_enable(cmd,argc,argv) 184 * 185 * Set up node-based routing (board specific) 186 * 187 * Return value: 188 * -1 if error occurred. 189 ********************************************************************* */ 190 191extern int _pci_enumerated; 192extern void ht_node_route(int port, int source_node, int dest_node); 193 194static int ui_cmd_node_enable(ui_cmdline_t *cmd,int argc,char *argv[]) 195{ 196 unsigned int board_config; 197 unsigned int node_id; 198 unsigned int port; 199 char *x; 200 201 /* In a multinode system, the slave side of each link must 202 complete PCI/HT initialization before the master side is 203 configured. Currently, PCI/HT is delayed on both ends of 204 the link and must be initiated manually in the proper sequence. 205 If it hasn't been done already, force it now. */ 206 if (!_pci_enumerated) 207 ui_docommands("show pci -init"); 208 209 board_config = board_get_config(); 210 node_id = (board_config & BOARD_CFG_NODE_ID ? 5 : 4); 211 212 port = 0; /* default */ 213 if (cmd_sw_value(cmd, "-port", &x)) port = atoi(x); 214 if (port != 0 && port != 1) { 215 xprintf("port %d not available for internode links\n", port); 216 return CFE_ERR; 217 } 218 219 /* XXX Routing currently the nodes on each end have node ids that 220 differ only in the least significant bit. */ 221 ht_node_route(port, node_id, node_id ^ 1); 222 223 return 0; 224} 225#endif 226 227 228/* ********************************************************************* 229 * ui_init_bcm91480bcmds() 230 * 231 * Add BCM91480B-specific commands to the command table 232 * 233 * Input parameters: 234 * nothing 235 * 236 * Return value: 237 * 0 238 ********************************************************************* */ 239 240 241int ui_init_bcm91480bcmds(void) 242{ 243 cmd_addcmd("uacwrite", 244 ui_cmd_uacwrite, 245 NULL, 246 "Do an uncached write", 247 "uacwrite addr data0 data1 data2 data3", 248 "-loops=*;Number of iterations"); 249 250 cmd_addcmd("memmargin", 251 ui_cmd_memmargin, 252 NULL, 253 "Read/write memory continuously, count errors", 254 "memmargin", 255 "-ro;only do reads|" 256 "-wo;only do writes"); 257 258#if CFG_LDT 259 cmd_addcmd("node enable", 260 ui_cmd_node_enable, 261 NULL, 262 "Enable HT node routing", 263 "node enable", 264 "-port=*;Port to use, 0 (default) or 1"); 265#endif 266 267 return 0; 268} 269 270 271 272 273