comphy_rx_training.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2017 Marvell International Ltd.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <console.h>
  10. #include <dm.h>
  11. #include <fdtdec.h>
  12. #include <dm/device-internal.h>
  13. #include <mvebu/comphy.h>
  14. int mvebu_comphy_rx_training_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
  15. char * const argv[])
  16. {
  17. struct udevice *dev;
  18. struct uclass *uc;
  19. int ret, cp_index, comphy_index, i = 0;
  20. if (argc != 3) {
  21. printf("missing arguments\n");
  22. return -1;
  23. }
  24. cp_index = hextoul(argv[1], NULL);
  25. comphy_index = hextoul(argv[2], NULL);
  26. ret = uclass_get(UCLASS_MISC, &uc);
  27. if (ret) {
  28. printf("Couldn't find UCLASS_MISC\n");
  29. return ret;
  30. }
  31. uclass_foreach_dev(dev, uc) {
  32. if (!(memcmp(dev->name, "comphy", 5))) {
  33. if (i == cp_index) {
  34. comphy_rx_training(dev, comphy_index);
  35. return 0;
  36. }
  37. i++;
  38. }
  39. }
  40. printf("Coudn't find comphy %d\n", cp_index);
  41. return 0;
  42. }
  43. U_BOOT_CMD(
  44. mvebu_comphy_rx_training, 3, 0, mvebu_comphy_rx_training_cmd,
  45. "mvebu_comphy_rx_training <cp id> <comphy id>\n",
  46. "\n\tRun COMPHY RX training sequence, the user must state CP index (0/1) and comphy ID (0/5)"
  47. );