ide.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _IDE_H
  8. #define _IDE_H
  9. #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
  10. #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
  11. extern ulong ide_bus_offset[];
  12. #ifdef CONFIG_IDE_LED
  13. /*
  14. * LED Port
  15. */
  16. #define LED_PORT ((uchar *)(PER8_BASE + 0x3000))
  17. #define LED_IDE1 0x01
  18. #define LED_IDE2 0x02
  19. #define DEVICE_LED(d) ((d & 2) | ((d & 2) == 0)) /* depends on bit positions! */
  20. #endif /* CONFIG_IDE_LED */
  21. #ifdef CONFIG_SYS_64BIT_LBA
  22. typedef uint64_t lbaint_t;
  23. #define LBAF "%llx"
  24. #define LBAFU "%llu"
  25. #else
  26. typedef ulong lbaint_t;
  27. #define LBAF "%lx"
  28. #define LBAFU "%lu"
  29. #endif
  30. /*
  31. * Function Prototypes
  32. */
  33. void ide_init(void);
  34. ulong ide_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer);
  35. ulong ide_write(int device, lbaint_t blknr, lbaint_t blkcnt,
  36. const void *buffer);
  37. #ifdef CONFIG_IDE_PREINIT
  38. int ide_preinit(void);
  39. #endif
  40. #ifdef CONFIG_IDE_INIT_POSTRESET
  41. int ide_init_postreset(void);
  42. #endif
  43. #if defined(CONFIG_OF_IDE_FIXUP)
  44. int ide_device_present(int dev);
  45. #endif
  46. #if defined(CONFIG_IDE_AHB)
  47. unsigned char ide_read_register(int dev, unsigned int port);
  48. void ide_write_register(int dev, unsigned int port, unsigned char val);
  49. void ide_read_data(int dev, ulong *sect_buf, int words);
  50. void ide_write_data(int dev, const ulong *sect_buf, int words);
  51. #endif
  52. /*
  53. * I/O function overrides
  54. */
  55. void ide_input_swap_data(int dev, ulong *sect_buf, int words);
  56. void ide_input_data(int dev, ulong *sect_buf, int words);
  57. void ide_output_data(int dev, const ulong *sect_buf, int words);
  58. void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts);
  59. void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts);
  60. /**
  61. * board_start_ide() - Start up the board IDE interfac
  62. *
  63. * @return 0 if ok
  64. */
  65. int board_start_ide(void);
  66. #endif /* _IDE_H */