ide.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2011
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. /*
  7. * IDE support
  8. */
  9. #include <common.h>
  10. #include <blk.h>
  11. #include <dm.h>
  12. #include <config.h>
  13. #include <watchdog.h>
  14. #include <command.h>
  15. #include <image.h>
  16. #include <asm/byteorder.h>
  17. #include <asm/io.h>
  18. #include <dm/device-internal.h>
  19. #include <dm/uclass-internal.h>
  20. #include <ide.h>
  21. #include <ata.h>
  22. #ifdef CONFIG_LED_STATUS
  23. # include <status_led.h>
  24. #endif
  25. /* Current I/O Device */
  26. static int curr_device;
  27. int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  28. {
  29. if (argc == 2) {
  30. if (strncmp(argv[1], "res", 3) == 0) {
  31. struct udevice *dev;
  32. int ret;
  33. puts("\nReset IDE: ");
  34. ret = uclass_find_first_device(UCLASS_IDE, &dev);
  35. ret = device_remove(dev, DM_REMOVE_NORMAL);
  36. if (!ret)
  37. ret = device_chld_unbind(dev, NULL);
  38. if (ret) {
  39. printf("Cannot remove IDE (err=%dE)\n", ret);
  40. return CMD_RET_FAILURE;
  41. }
  42. ret = uclass_first_device_err(UCLASS_IDE, &dev);
  43. if (ret) {
  44. printf("Init failed (err=%dE)\n", ret);
  45. return CMD_RET_FAILURE;
  46. }
  47. return 0;
  48. }
  49. }
  50. return blk_common_cmd(argc, argv, UCLASS_IDE, &curr_device);
  51. }
  52. int do_diskboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  53. {
  54. return common_diskboot(cmdtp, "ide", argc, argv);
  55. }
  56. U_BOOT_CMD(ide, 5, 1, do_ide,
  57. "IDE sub-system",
  58. "reset - reset IDE controller\n"
  59. "ide info - show available IDE devices\n"
  60. "ide device [dev] - show or set current device\n"
  61. "ide part [dev] - print partition table of one or all IDE devices\n"
  62. "ide read addr blk# cnt\n"
  63. "ide write addr blk# cnt - read/write `cnt'"
  64. " blocks starting at block `blk#'\n"
  65. " to/from memory address `addr'");
  66. U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
  67. "boot from IDE device", "loadAddr dev:part");