allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / cfe / cfe / arch / mips / board / bcm947xx / src / ui_bcm947xx.c
blobbf7d4145489e66c0193475a55686181beb6fc7a9
1 /*
2 * Broadcom Common Firmware Environment (CFE)
3 * Board device initialization, File: ui_bcm947xx.c
5 * Copyright (C) 2011, Broadcom Corporation
6 * All Rights Reserved.
7 *
8 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
9 * the contents of this file may not be disclosed to third parties, copied
10 * or duplicated in any form, in whole or in part, without the prior
11 * written permission of Broadcom Corporation.
13 * $Id: ui_bcm947xx.c 323091 2012-03-22 23:32:36Z $
16 #include "lib_types.h"
17 #include "lib_string.h"
18 #include "lib_queue.h"
19 #include "lib_malloc.h"
20 #include "lib_printf.h"
21 #include "cfe.h"
22 #include "cfe_iocb.h"
23 #include "cfe_devfuncs.h"
24 #include "cfe_ioctl.h"
25 #include "cfe_error.h"
26 #include "cfe_fileops.h"
27 #include "cfe_loader.h"
28 #include "ui_command.h"
29 #include "bsp_config.h"
31 #include <typedefs.h>
32 #include <osl.h>
33 #include <bcmdevs.h>
34 #include <bcmutils.h>
35 #include <hndsoc.h>
36 #include <siutils.h>
37 #include <sbchipc.h>
38 #include <sbmemc.h>
39 #include <dmemc_core.h>
40 #include <bcmendian.h>
41 #include <bcmnvram.h>
42 #include <hndcpu.h>
43 #include <trxhdr.h>
44 #include "addrspace.h"
45 #include "initdata.h"
47 #include "bsp_priv.h"
49 #ifdef RESCUE_MODE
50 unsigned char DETECT(void);
51 bool mmode_set(void);
52 bool rmode_set(void);
53 extern void LEDON(void);
54 extern void LEDOFF(void);
55 extern void GPIO_INIT(void);
56 extern void FANON(void);
58 /* define GPIOs*/
59 #define FAN_GPIO (1 << 14) // GPIO 14
60 #define PWR_LED_GPIO (1 << 12) // GPIO 12
61 #define RST_BTN_GPIO (1 << 9) // GPIO 9
62 #define HAVE_FAN_GPIO (1 << 6) // GPIO 6
63 #define EZ_BTN_GPIO (1 << 4) // GPIO 4
64 #endif
66 static int
67 ui_cmd_reboot(ui_cmdline_t *cmd, int argc, char *argv[])
69 hnd_cpu_reset(sih);
70 return 0;
74 static int
75 ui_cmd_nvram(ui_cmdline_t *cmd, int argc, char *argv[])
77 char *command, *name, *value;
78 char *buf;
79 size_t size;
80 int ret;
82 if (!(command = cmd_getarg(cmd, 0)))
83 return CFE_ERR_INV_PARAM;
85 if (!strcmp(command, "get")) {
86 if ((name = cmd_getarg(cmd, 1)))
87 if ((value = nvram_get(name)))
88 printf("%s\n", value);
89 } else if (!strcmp(command, "set")) {
90 if ((name = cmd_getarg(cmd, 1))) {
91 if ((value = strchr(name, '=')))
92 *value++ = '\0';
93 else if ((value = cmd_getarg(cmd, 2))) {
94 if (*value == '=')
95 value = cmd_getarg(cmd, 3);
97 if (value)
98 nvram_set(name, value);
100 } else if (!strcmp(command, "unset")) {
101 if ((name = cmd_getarg(cmd, 1)))
102 nvram_unset(name);
103 } else if (!strcmp(command, "commit")) {
104 nvram_commit();
105 } else if (!strcmp(command, "erase")) {
106 extern char *flashdrv_nvram;
107 if ((ret = cfe_open(flashdrv_nvram)) < 0)
108 return ret;
109 if (!(buf = KMALLOC(NVRAM_SPACE, 0)))
110 return CFE_ERR_NOMEM;
111 memset(buf, 0xff, NVRAM_SPACE);
112 cfe_writeblk(ret, 0, (unsigned char *)buf, NVRAM_SPACE);
113 cfe_close(ret);
114 KFREE(buf);
115 } else if (!strcmp(command, "show") || !strcmp(command, "getall")) {
116 if (!(buf = KMALLOC(NVRAM_SPACE, 0)))
117 return CFE_ERR_NOMEM;
118 nvram_getall(buf, NVRAM_SPACE);
119 for (name = buf; *name; name += strlen(name) + 1)
120 printf("%s\n", name);
121 size = sizeof(struct nvram_header) + ((uintptr)name - (uintptr)buf);
122 printf("size: %d bytes (%d left)\n", size, NVRAM_SPACE - size);
123 KFREE(buf);
126 return 0;
129 static int
130 check_trx(char *trx_name)
132 int ret;
133 fileio_ctx_t *fsctx;
134 void *ref;
135 struct trx_header trx;
136 #ifdef CFG_NFLASH
137 uint32 crc;
138 static uint32 buf[16*1024];
139 #else
140 uint32 crc, buf[512];
141 #endif /* CFG_NFLASH */
142 int first_read = 1;
143 unsigned int len, count;
145 /* Open header */
146 ret = fs_init("raw", &fsctx, trx_name);
147 if (ret)
148 return ret;
150 ret = fs_open(fsctx, &ref, "", FILE_MODE_READ);
151 if (ret) {
152 fs_uninit(fsctx);
153 return ret;
156 /* Read header */
157 ret = fs_read(fsctx, ref, (unsigned char *) &trx, sizeof(struct trx_header));
158 if (ret != sizeof(struct trx_header)) {
159 ret = CFE_ERR_IOERR;
160 goto done;
163 /* Verify magic number */
164 if (ltoh32(trx.magic) != TRX_MAGIC) {
165 ret = CFE_ERR_INVBOOTBLOCK;
166 goto done;
169 /* Checksum over header */
170 crc = hndcrc32((uint8 *) &trx.flag_version,
171 sizeof(struct trx_header) - OFFSETOF(struct trx_header, flag_version),
172 CRC32_INIT_VALUE);
174 for (len = ltoh32(trx.len) - sizeof(struct trx_header); len; len -= count) {
175 if (first_read) {
176 count = MIN(len, sizeof(buf) - sizeof(struct trx_header));
177 first_read = 0;
178 } else
179 count = MIN(len, sizeof(buf));
181 /* Read data */
182 ret = fs_read(fsctx, ref, (unsigned char *) &buf, count);
183 if (ret != count) {
184 ret = CFE_ERR_IOERR;
185 goto done;
188 /* Checksum over data */
189 crc = hndcrc32((uint8 *) &buf, count, crc);
192 /* Verify checksum */
193 if (ltoh32(trx.crc32) != crc) {
194 ret = CFE_ERR_BOOTPROGCHKSUM;
195 goto done;
198 ret = 0;
200 done:
201 fs_close(fsctx, ref);
202 fs_uninit(fsctx);
203 if (ret)
204 xprintf("%s\n", cfe_errortext(ret));
205 return ret;
208 #ifdef RESCUE_MODE
209 bool mmode_set(void)
211 unsigned long gpioin;
213 sih = si_kattach(SI_OSH);
214 ASSERT(sih);
215 gpioin = si_gpioin(sih);
217 si_detach(sih);
218 return gpioin & RST_BTN_GPIO ? FALSE : TRUE;
221 bool rmode_set(void) /* reset mode */
223 unsigned long gpioin;
225 sih = si_kattach(SI_OSH);
226 ASSERT(sih);
227 gpioin = si_gpioin(sih);
229 si_detach(sih);
230 return gpioin & EZ_BTN_GPIO ? FALSE : TRUE;
233 extern void LEDON(void)
235 sih = si_kattach(SI_OSH);
236 ASSERT(sih);
237 si_gpioouten(sih, PWR_LED_GPIO, PWR_LED_GPIO, GPIO_DRV_PRIORITY);
239 /* led on */
240 /* negative logic and hence val==0 */
241 si_gpioout(sih, PWR_LED_GPIO, 0, GPIO_DRV_PRIORITY);
243 extern void GPIO_INIT(void)
245 sih = si_kattach(SI_OSH);
246 ASSERT(sih);
247 si_gpiocontrol(sih, PWR_LED_GPIO, 0, GPIO_DRV_PRIORITY);
248 si_gpioouten(sih, PWR_LED_GPIO, 0, GPIO_DRV_PRIORITY);
249 si_gpiocontrol(sih, FAN_GPIO, 0, GPIO_DRV_PRIORITY);
250 si_gpioouten(sih, FAN_GPIO, 0, GPIO_DRV_PRIORITY);
251 si_gpiocontrol(sih, HAVE_FAN_GPIO, 0, GPIO_DRV_PRIORITY);
252 si_gpioouten(sih, HAVE_FAN_GPIO, 0, GPIO_DRV_PRIORITY);
255 extern void LEDOFF(void)
257 sih = si_kattach(SI_OSH);
258 ASSERT(sih);
259 si_gpioouten(sih, PWR_LED_GPIO, PWR_LED_GPIO, GPIO_DRV_PRIORITY);
260 si_gpioout(sih, PWR_LED_GPIO, PWR_LED_GPIO, GPIO_DRV_PRIORITY);
263 extern void FANON(void)
265 sih = si_kattach(SI_OSH);
266 ASSERT(sih);
267 si_gpioouten(sih, FAN_GPIO, FAN_GPIO, GPIO_DRV_PRIORITY);
268 si_gpioout(sih, FAN_GPIO, 0, GPIO_DRV_PRIORITY);
269 si_gpioouten(sih, HAVE_FAN_GPIO, HAVE_FAN_GPIO, GPIO_DRV_PRIORITY);
270 si_gpioout(sih, HAVE_FAN_GPIO, 0, GPIO_DRV_PRIORITY);
272 unsigned char DETECT(void)
274 unsigned char d = 0;
275 char *rescueflag;
277 if ((rescueflag = nvram_get("rescueflag")) != NULL) {
278 if (!nvram_invmatch("rescueflag", "enable")) {
279 xprintf("Rescue Flag enable.\n");
280 d = 1;
282 else {
283 xprintf("Rescue Flag disable.\n");
284 if (mmode_set())
285 d = 1;
286 else
287 d = 0;
289 nvram_set("rescueflag", "disable");
290 nvram_commit();
292 else {
293 xprintf("Null Rescue Flag.\n");
294 if (mmode_set())
295 d = 1;
296 else
297 d = 0;
300 /* Set 1 to be high active and 0 to be low active */
301 if (d==1)
302 return 1;
303 else
304 return 0;
306 #endif // RESCUE_MODE
309 * ui_get_loadbuf(bufptr, bufsize)
311 * Figure out the location and size of the staging buffer.
313 * Input parameters:
314 * bufptr - address to return buffer location
315 * bufsize - address to return buffer size
317 static void ui_get_loadbuf(uint8_t **bufptr, int *bufsize)
319 int size = CFG_FLASH_STAGING_BUFFER_SIZE;
322 * Get the address of the staging buffer. We can't
323 * allocate the space from the heap to store the
324 * new flash image, because the heap may not be big
325 * enough. So, if FLASH_STAGING_BUFFER_SIZE is non-zero
326 * then just use it and FLASH_STAGING_BUFFER; else
327 * use the larger of (mem_bottomofmem - FLASH_STAGING_BUFFER)
328 * and (mem_totalsize - mem_topofmem).
331 if (size > 0) {
332 *bufptr = (uint8_t *) KERNADDR(CFG_FLASH_STAGING_BUFFER_ADDR);
333 *bufsize = size;
334 } else {
335 int below, above;
336 int reserved = CFG_FLASH_STAGING_BUFFER_ADDR;
338 /* For small memory size (8MB), we tend to use the below region.
339 * The buffer address may conflict with the os running address,
340 * so we reserve 3MB for the os.
342 if ((mem_totalsize == (8*1024)) && (PHYSADDR(mem_bottomofmem) > 0x300000))
343 reserved = 0x300000;
345 below = PHYSADDR(mem_bottomofmem) - reserved;
346 above = (mem_totalsize << 10) - PHYSADDR(mem_topofmem);
348 if (below > above) {
349 *bufptr = (uint8_t *) KERNADDR(reserved);
350 *bufsize = below;
351 } else {
352 *bufptr = (uint8_t *) KERNADDR(mem_topofmem);
353 *bufsize = above;
358 #if defined(DUAL_IMAGE) || defined(FAILSAFE_UPGRADE)
359 static
360 int check_image_prepare_cmd(int the_image, char *buf, uint32 osaddr, int bufsize)
362 int ret = -1;
363 char trx_name[16], os_name[16];
364 char trx2_name[16], os2_name[16];
366 #ifdef CFG_NFLASH
367 ui_get_trx_flashdev(trx_name);
368 ui_get_os_flashdev(os_name);
369 #else
370 strcpy(trx_name, "flash1.trx");
371 strcpy(os_name, "flash0.os");
372 #endif
374 strncpy (trx2_name,trx_name,sizeof(trx2_name));
375 strncpy (os2_name,os_name,sizeof(os2_name));
376 strcat (trx2_name, "2");
377 strcat (os2_name, "2");
379 if (the_image == 0) {
380 if ((ret = check_trx(trx_name)) == 0) {
381 sprintf(buf, "boot -raw -z -addr=0x%x -max=0x%x %s:", osaddr, bufsize,
382 os_name);
383 } else {
384 printf("%s CRC check failed!\n", trx_name);
386 } else if (the_image == 1) {
387 if ((ret = check_trx(trx2_name)) == 0) {
388 sprintf(buf, "boot -raw -z -addr=0x%x -max=0x%x %s:", osaddr, bufsize,
389 os2_name);
390 } else {
391 printf("%s CRC check failed!\n", trx2_name);
393 } else {
394 printf("Image partition %d does not exist\n", the_image);
396 return ret;
398 #endif /* DUAL_IMAGE || FAILSAFE_UPGRADE */
400 #ifdef CFG_NFLASH
401 static int ui_get_bootflags(void)
403 int bootflags = 0;
404 char *val;
406 /* Only support chipcommon revision == 38 and BCM4706 for now */
407 if (((CHIPID(sih->chip) == BCM4706_CHIP_ID) || sih->ccrev == 38) &&
408 (sih->cccaps & CC_CAP_NFLASH)) {
409 if ((val = nvram_get("bootflags")))
410 bootflags = atoi(val);
411 else if ((sih->chipst & (1 << 4)) != 0) {
412 /* This is NANDBOOT */
413 bootflags = FLASH_KERNEL_NFLASH | FLASH_BOOT_NFLASH;
416 return bootflags;
419 void ui_get_boot_flashdev(char *flashdev)
421 if (!flashdev)
422 return;
423 if ((ui_get_bootflags() & FLASH_BOOT_NFLASH) == FLASH_BOOT_NFLASH)
424 strcpy(flashdev, "nflash1.boot");
425 else
426 strcpy(flashdev, "flash1.boot");
428 return;
431 void ui_get_os_flashdev(char *flashdev)
433 if (!flashdev)
434 return;
435 if ((ui_get_bootflags() & FLASH_KERNEL_NFLASH) == FLASH_KERNEL_NFLASH)
436 strcpy(flashdev, "nflash0.os");
437 else
438 strcpy(flashdev, "flash0.os");
440 return;
443 void ui_get_trx_flashdev(char *flashdev)
445 if (!flashdev)
446 return;
447 if ((ui_get_bootflags() & FLASH_KERNEL_NFLASH) == FLASH_KERNEL_NFLASH)
448 strcpy(flashdev, "nflash1.trx");
449 else
450 strcpy(flashdev, "flash1.trx");
451 return;
453 #endif /* CFG_NFLASH */
455 static int
456 ui_cmd_go(ui_cmdline_t *cmd, int argc, char *argv[])
458 int ret = 0;
459 char buf[512];
460 struct trx_header *file_buf;
461 uint8_t *ptr;
462 char *val;
463 uint32 osaddr;
464 int bufsize = 0;
465 #ifndef RESCUE_MODE
466 int retry = 0;
467 int trx_failed;
468 #else
469 int i = 0;
470 GPIO_INIT();
471 LEDON();
472 #endif
473 #ifdef FAILSAFE_UPGRADE
474 char *bootpartition = nvram_get(BOOTPARTITION);
475 char *partialboots = nvram_get(PARTIALBOOTS);
476 char *maxpartialboots = nvram_get(MAXPARTIALBOOTS);
477 #endif
478 #ifdef DUAL_IMAGE
479 char *bootpartition = nvram_get(IMAGE_BOOT);
480 #endif
481 #ifdef CFG_NFLASH
482 char trx_name[16], os_name[16];
483 #else
484 char *trx_name = "flash1.trx";
485 char *os_name = "flash0.os";
486 #endif /* CFG_NFLASH */
488 val = nvram_get("os_ram_addr");
489 if (val)
490 osaddr = bcm_strtoul(val, NULL, 16);
491 else
492 osaddr = 0x80001000;
494 #ifdef RESCUE_MODE
495 //trx_name = "nflash1.trx";
496 strcpy(trx_name, "nflash1.trx");
497 strcpy(os_name, "nflash0.os");
499 if (DETECT()) {
500 xprintf("Hello!! Enter Rescue Mode: (by Force)\n\n");
501 /* Wait forever for an image */
502 while ((ret = ui_docommand("flash -noheader : nflash1.trx")) == CFE_ERR_TIMEOUT) {
503 if (i%2 == 0)
504 LEDOFF();
505 else
506 LEDON();
507 i++;
508 if (i==0xffffff)
509 i = 0;
513 else if (rmode_set()) {
514 xprintf("Wait until reset button released...\n");
515 while(rmode_set() == 1) {
516 if ((i%100000) < 50000) {
517 LEDON();
519 else {
520 LEDOFF();
522 i++;
524 if (i==0xffffff) {
525 i = 0;
528 ui_docommand ("nvram erase");
529 ui_docommand ("reboot");
531 else {
532 xprintf("boot the image...\n"); // tmp test
534 if (check_trx(trx_name)) {
535 xprintf("Hello!! Enter Rescue Mode: (Check error)\n\n");
536 /* Wait forever for an image */
537 while ((ret = ui_docommand("flash -noheader : nflash1.trx")) == CFE_ERR_TIMEOUT) {
538 if (i%2 == 0)
539 LEDOFF();
540 else
541 LEDON();
542 i++;
543 if (i==0xffffff)
544 i = 0;
546 } else if (!nvram_invmatch("boot_wait", "on")) {
547 xprintf("go load\n"); // tmp test
548 ui_get_loadbuf(&ptr, &bufsize);
549 /* Load the image */
550 sprintf(buf, "load -raw -addr=0x%x -max=0x%x :", (unsigned int)ptr, (unsigned int)TRX_MAX_LEN);
551 ret = ui_docommand(buf);
553 /* Load was successful. Check for the TRX magic.
554 * If it's a TRX image, then proceed to flash it, else try to boot
555 * Note: To boot a TRX image directly from the memory, address will need to be
556 * load address + trx header length.
558 if (ret == 0) {
559 file_buf = (struct trx_header *)ptr;
560 /* If it's a TRX, then proceed to writing to flash else,
561 * try to boot from memory
563 if (file_buf->magic != TRX_MAGIC) {
564 sprintf(buf, "boot -raw -z -addr=0x%x -max=0x%x -fs=memory :0x%x",
565 osaddr, (unsigned int)bufsize, (unsigned int)ptr);
566 return ui_docommand(buf);
568 /* Flash the image from memory directly */
569 sprintf(buf, "flash -noheader -mem -size=0x%x 0x%x nflash1.trx",
570 (unsigned int)file_buf->len, (unsigned int)ptr);
571 ret = ui_docommand(buf);
576 #else // RESCUE_MODE
578 #if defined(FAILSAFE_UPGRADE) || defined(DUAL_IMAGE)
579 if (bootpartition != NULL) {
580 #ifdef CFG_NFLASH
581 ui_get_trx_flashdev(trx_name);
582 #endif
583 trx_failed = check_trx(trx_name);
584 #ifdef CFG_NFLASH
585 strcat(trx_name,"2");
586 #endif
587 trx_failed &= check_trx(trx_name);
588 } else
589 #endif /* FAILSAFE_UPGRADE || DUAL_IMAGE*/
591 #ifdef CFG_NFLASH
592 ui_get_trx_flashdev(trx_name);
593 ui_get_os_flashdev(os_name);
594 #endif
595 trx_failed = check_trx(trx_name);
598 if (trx_failed) {
599 /* Wait for CFE_ERR_TIMEOUT_LIMIT for an image */
600 while (1) {
601 sprintf(buf, "flash -noheader :%s", trx_name);
602 if ((ret = ui_docommand(buf)) != CFE_ERR_TIMEOUT)
603 break;
604 if (++retry == CFE_ERR_TIMEOUT_LIMIT) {
605 ret = CFE_ERR_INTR;
606 break;
609 } else if (!nvram_invmatch("boot_wait", "on")) {
610 ui_get_loadbuf(&ptr, &bufsize);
611 /* Load the image */
612 sprintf(buf, "load -raw -addr=0x%p -max=0x%x :", ptr, bufsize);
613 ret = ui_docommand(buf);
615 /* Load was successful. Check for the TRX magic.
616 * If it's a TRX image, then proceed to flash it, else try to boot
617 * Note: To boot a TRX image directly from the memory, address will need to be
618 * load address + trx header length.
620 if (ret == 0) {
621 file_buf = (struct trx_header *)ptr;
622 /* If it's a TRX, then proceed to writing to flash else,
623 * try to boot from memory
625 if (file_buf->magic != TRX_MAGIC) {
626 sprintf(buf, "boot -raw -z -addr=0x%x -max=0x%x -fs=memory :0x%p",
627 osaddr, bufsize, ptr);
628 return ui_docommand(buf);
630 /* Flash the image from memory directly */
631 sprintf(buf, "flash -noheader -mem -size=0x%x 0x%p %s",
632 file_buf->len, ptr, trx_name);
633 ret = ui_docommand(buf);
636 #endif // RESCUE_MODE
638 if (ret == CFE_ERR_INTR)
639 return ret;
640 /* Boot the image */
641 bufsize = PHYSADDR(mem_bottomofmem) - PHYSADDR(osaddr);
643 #if defined(FAILSAFE_UPGRADE) || defined(DUAL_IMAGE)
644 /* Get linux_boot variable to see what is current image */
645 if (bootpartition != NULL) {
646 char temp[20];
647 int i = atoi(bootpartition);
648 #ifdef FAILSAFE_UPGRADE
649 if (maxpartialboots && (atoi(maxpartialboots) > 0)) {
650 if (partialboots && (atoi(partialboots) > atoi(maxpartialboots))) {
651 i = 1-i;
652 printf("Changed to the other image %d (maxpartialboots exceeded)\n", i);
653 /* reset to new image */
654 sprintf(temp, "%d", i);
655 nvram_set(PARTIALBOOTS, "1");
656 nvram_set(BOOTPARTITION, temp);
657 nvram_commit();
658 } else {
659 /* Increment the counter */
660 sprintf(temp,"%d",partialboots ? atoi(partialboots)+1:1);
661 nvram_set(PARTIALBOOTS, temp);
662 nvram_commit();
665 #endif
666 if (i > 1)
667 i = 0;
669 /* We try the specified one, if it is failed, we try the other one */
670 if (check_image_prepare_cmd(i, buf, osaddr, bufsize) == 0) {
671 printf("Booting(%d): %s\n",i,buf);
672 } else if (check_image_prepare_cmd(1-i, buf, osaddr, bufsize) == 0) {
673 printf("Changed to the other image %d\n", 1 - i);
674 sprintf(temp, "%d", 1-i);
675 nvram_set(BOOTPARTITION, temp);
676 #ifdef FAILSAFE_UPGRADE
677 nvram_set(PARTIALBOOTS, "1");
678 #endif
679 nvram_commit();
680 } else {
681 printf ("Both images bad!!!\n");
682 buf[0] = 0;
685 else
686 #endif /* FAILSAFE_UPGRADE || DUAL_IMAGE */
687 sprintf(buf, "boot -raw -z -addr=0x%x -max=0x%x %s:", osaddr, bufsize, os_name);
689 return ui_docommand(buf);
692 static int
693 ui_cmd_clocks(ui_cmdline_t *cmd, int argc, char *argv[])
695 chipcregs_t *cc = (chipcregs_t *)si_setcoreidx(sih, SI_CC_IDX);
696 uint32 ccc = R_REG(NULL, &cc->capabilities);
697 uint32 pll = ccc & CC_CAP_PLL_MASK;
699 if (pll != PLL_NONE) {
700 uint32 n = R_REG(NULL, &cc->clockcontrol_n);
701 printf("Current clocks for pll=0x%x:\n", pll);
702 printf(" mips: %d\n", si_clock_rate(pll, n, R_REG(NULL, &cc->clockcontrol_m3)));
703 printf(" sb: %d\n", si_clock_rate(pll, n, R_REG(NULL, &cc->clockcontrol_sb)));
704 printf(" pci: %d\n", si_clock_rate(pll, n, R_REG(NULL, &cc->clockcontrol_pci)));
705 printf(" mipsref: %d\n", si_clock_rate(pll, n,
706 R_REG(NULL, &cc->clockcontrol_m2)));
707 } else {
708 printf("Current clocks: %d/%d/%d/%d Mhz.\n",
709 si_cpu_clock(sih) / 1000000,
710 si_mem_clock(sih) / 1000000,
711 si_clock(sih) / 1000000,
712 si_alp_clock(sih) / 1000000);
714 return 0;
718 extern int ui_init_devcmds(void); // J++
721 ui_init_bcm947xxcmds(void)
723 cmd_addcmd("reboot",
724 ui_cmd_reboot,
725 NULL,
726 "Reboot.",
727 "reboot\n\n"
728 "Reboots.",
729 "");
730 cmd_addcmd("nvram",
731 ui_cmd_nvram,
732 NULL,
733 "NVRAM utility.",
734 "nvram [command] [args..]\n\n"
735 "Access NVRAM.",
736 "get [name];Gets the value of the specified variable|"
737 "set [name=value];Sets the value of the specified variable|"
738 "unset [name];Deletes the specified variable|"
739 "commit;Commit variables to flash|"
740 "erase;Erase all nvram|"
741 "show;Shows all variables|");
742 cmd_addcmd("go",
743 ui_cmd_go,
744 NULL,
745 "Verify and boot OS image.",
746 "go\n\n"
747 "Boots OS image if valid. Waits for a new OS image if image is invalid\n"
748 "or boot_wait is unset or not on.",
749 "");
750 cmd_addcmd("show clocks",
751 ui_cmd_clocks,
752 NULL,
753 "Show current values of the clocks.",
754 "show clocks\n\n"
755 "Shows the current values of the clocks.",
756 "");
758 ui_init_devcmds(); // J++
760 #if CFG_WLU
761 wl_addcmd();
762 #endif
764 return 0;