blob: 629e6a9389e1c4d3c7f248d41efed3e8b6da8486 [file] [log] [blame]
Mike Frysingercf675d32008-02-19 00:35:17 -05001/*
2 * cmd_cplbinfo.c - dump the instruction/data cplb tables
3 *
4 * Copyright (c) 2007-2008 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <common.h>
10#include <command.h>
11#include <asm/blackfin.h>
12#include <asm/cplb.h>
13#include <asm/mach-common/bits/mpu.h>
14
15/*
16 * Translate the PAGE_SIZE bits into a human string
17 */
18static const char *cplb_page_size(uint32_t data)
19{
20 static const char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" };
21 return page_size_string_table[(data & PAGE_SIZE_MASK) >> PAGE_SIZE_SHIFT];
22}
23
24/*
25 * show a hardware cplb table
26 */
27static void show_cplb_table(uint32_t *addr, uint32_t *data)
28{
29 size_t i;
30 printf(" Address Data Size Valid Locked\n");
31 for (i = 1; i <= 16; ++i) {
32 printf(" %2i 0x%p 0x%05X %s %c %c\n",
33 i, *addr, *data,
34 cplb_page_size(*data),
35 (*data & CPLB_VALID ? 'Y' : 'N'),
36 (*data & CPLB_LOCK ? 'Y' : 'N'));
37 ++addr;
38 ++data;
39 }
40}
41
42/*
43 * display current instruction and data cplb tables
44 */
45int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
46{
47 printf("%s CPLB table [%08x]:\n", "Instruction", *(uint32_t *)DMEM_CONTROL);
48 show_cplb_table((uint32_t *)ICPLB_ADDR0, (uint32_t *)ICPLB_DATA0);
49
50 printf("%s CPLB table [%08x]:\n", "Data", *(uint32_t *)IMEM_CONTROL);
51 show_cplb_table((uint32_t *)DCPLB_ADDR0, (uint32_t *)DCPLB_DATA0);
52
53 return 0;
54}
55
56U_BOOT_CMD(cplbinfo, 1, 0, do_cplbinfo,
Peter Tyser2fb26042009-01-27 18:03:12 -060057 "display current CPLB tables",
Mike Frysingercf675d32008-02-19 00:35:17 -050058 "\n"
59 " - display current CPLB tables\n");