Mike Frysinger | cf675d3 | 2008-02-19 00:35:17 -0500 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 18 | static 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 | */ |
| 27 | static void show_cplb_table(uint32_t *addr, uint32_t *data) |
| 28 | { |
Mike Frysinger | fe033ad | 2008-10-12 06:02:55 -0400 | [diff] [blame] | 29 | int i; |
Mike Frysinger | cf675d3 | 2008-02-19 00:35:17 -0500 | [diff] [blame] | 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", |
Mike Frysinger | fe033ad | 2008-10-12 06:02:55 -0400 | [diff] [blame] | 33 | i, (void *)*addr, *data, |
Mike Frysinger | cf675d3 | 2008-02-19 00:35:17 -0500 | [diff] [blame] | 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 | */ |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 45 | int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Mike Frysinger | cf675d3 | 2008-02-19 00:35:17 -0500 | [diff] [blame] | 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 | |
Frans Meulenbroeks | 388a29d | 2010-07-31 15:01:53 +0200 | [diff] [blame] | 56 | U_BOOT_CMD( |
| 57 | cplbinfo, 1, 0, do_cplbinfo, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 58 | "display current CPLB tables", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 59 | "" |
| 60 | ); |