blob: ab5b3b587686f0f5e3cd8aa7e2c74e88b02e5433 [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{
Mike Frysingerfe033ad2008-10-12 06:02:55 -040029 int i;
Mike Frysingercf675d32008-02-19 00:35:17 -050030 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",
Mike Frysingerfe033ad2008-10-12 06:02:55 -040033 i, (void *)*addr, *data,
Mike Frysingercf675d32008-02-19 00:35:17 -050034 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 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +020045int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Mike Frysingercf675d32008-02-19 00:35:17 -050046{
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
Frans Meulenbroeks388a29d2010-07-31 15:01:53 +020056U_BOOT_CMD(
57 cplbinfo, 1, 0, do_cplbinfo,
Peter Tyser2fb26042009-01-27 18:03:12 -060058 "display current CPLB tables",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020059 ""
60);