cmd_fpgad.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * (C) Copyright 2013
  3. * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
  4. *
  5. * based on cmd_mem.c
  6. * (C) Copyright 2000
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <command.h>
  13. #include <gdsys_fpga.h>
  14. static uint dp_last_fpga;
  15. static uint dp_last_addr;
  16. static uint dp_last_length = 0x40;
  17. /*
  18. * FPGA Memory Display
  19. *
  20. * Syntax:
  21. * fpgad {fpga} {addr} {len}
  22. */
  23. #define DISP_LINE_LEN 16
  24. int do_fpga_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  25. {
  26. unsigned int k;
  27. unsigned int fpga;
  28. ulong addr, length;
  29. int rc = 0;
  30. u16 linebuf[DISP_LINE_LEN/sizeof(u16)];
  31. /*
  32. * We use the last specified parameters, unless new ones are
  33. * entered.
  34. */
  35. fpga = dp_last_fpga;
  36. addr = dp_last_addr;
  37. length = dp_last_length;
  38. if (argc < 3)
  39. return CMD_RET_USAGE;
  40. if ((flag & CMD_FLAG_REPEAT) == 0) {
  41. /*
  42. * FPGA is specified since argc > 2
  43. */
  44. fpga = simple_strtoul(argv[1], NULL, 16);
  45. /*
  46. * Address is specified since argc > 2
  47. */
  48. addr = simple_strtoul(argv[2], NULL, 16);
  49. /*
  50. * If another parameter, it is the length to display.
  51. * Length is the number of objects, not number of bytes.
  52. */
  53. if (argc > 3)
  54. length = simple_strtoul(argv[3], NULL, 16);
  55. }
  56. /* Print the lines. */
  57. for (k = 0; k < DISP_LINE_LEN / sizeof(u16); ++k)
  58. fpga_get_reg(fpga, (u16 *)fpga_ptr[fpga] + k, k * sizeof(u16),
  59. &linebuf[k]);
  60. print_buffer(addr, (void *)linebuf, sizeof(u16),
  61. length, DISP_LINE_LEN / sizeof(u16));
  62. addr += sizeof(u16)*length;
  63. dp_last_fpga = fpga;
  64. dp_last_addr = addr;
  65. dp_last_length = length;
  66. return rc;
  67. }
  68. U_BOOT_CMD(
  69. fpgad, 4, 1, do_fpga_md,
  70. "fpga register display",
  71. "fpga address [# of objects]"
  72. );