cplbinfo.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <common.h>
  9. #include <command.h>
  10. #include <asm/blackfin.h>
  11. #include <asm/cplb.h>
  12. #include <asm/mach-common/bits/mpu.h>
  13. /*
  14. * Translate the PAGE_SIZE bits into a human string
  15. */
  16. static const char *cplb_page_size(uint32_t data)
  17. {
  18. static const char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" };
  19. return page_size_string_table[(data & PAGE_SIZE_MASK) >> PAGE_SIZE_SHIFT];
  20. }
  21. /*
  22. * show a hardware cplb table
  23. */
  24. static void show_cplb_table(uint32_t *addr, uint32_t *data)
  25. {
  26. int i;
  27. printf(" Address Data Size Valid Locked\n");
  28. for (i = 1; i <= 16; ++i) {
  29. printf(" %2i 0x%p 0x%05X %s %c %c\n",
  30. i, (void *)*addr, *data,
  31. cplb_page_size(*data),
  32. (*data & CPLB_VALID ? 'Y' : 'N'),
  33. (*data & CPLB_LOCK ? 'Y' : 'N'));
  34. ++addr;
  35. ++data;
  36. }
  37. }
  38. /*
  39. * display current instruction and data cplb tables
  40. */
  41. int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  42. {
  43. printf("%s CPLB table [%08x]:\n", "Instruction", *(uint32_t *)DMEM_CONTROL);
  44. show_cplb_table((uint32_t *)ICPLB_ADDR0, (uint32_t *)ICPLB_DATA0);
  45. printf("%s CPLB table [%08x]:\n", "Data", *(uint32_t *)IMEM_CONTROL);
  46. show_cplb_table((uint32_t *)DCPLB_ADDR0, (uint32_t *)DCPLB_DATA0);
  47. return 0;
  48. }
  49. U_BOOT_CMD(
  50. cplbinfo, 1, 0, do_cplbinfo,
  51. "display current CPLB tables",
  52. ""
  53. );