ata_piix.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __ATA_PIIX_H__
  2. #define __ATA_PIIX_H__
  3. #if (DEBUG_SATA)
  4. #define PRINTF(fmt,args...) printf (fmt ,##args)
  5. #else
  6. #define PRINTF(fmt,args...)
  7. #endif
  8. struct sata_ioports {
  9. unsigned long cmd_addr;
  10. unsigned long data_addr;
  11. unsigned long error_addr;
  12. unsigned long feature_addr;
  13. unsigned long nsect_addr;
  14. unsigned long lbal_addr;
  15. unsigned long lbam_addr;
  16. unsigned long lbah_addr;
  17. unsigned long device_addr;
  18. unsigned long status_addr;
  19. unsigned long command_addr;
  20. unsigned long altstatus_addr;
  21. unsigned long ctl_addr;
  22. unsigned long bmdma_addr;
  23. unsigned long scr_addr;
  24. };
  25. struct sata_port {
  26. unsigned char port_no; /* primary=0, secondary=1 */
  27. struct sata_ioports ioaddr; /* ATA cmd/ctl/dma reg blks */
  28. unsigned char ctl_reg;
  29. unsigned char last_ctl;
  30. unsigned char port_state; /* 1-port is available and */
  31. /* 0-port is not available */
  32. unsigned char dev_mask;
  33. };
  34. /***********SATA LIBRARY SPECIFIC DEFINITIONS AND DECLARATIONS**************/
  35. #ifdef SATA_DECL /*SATA library specific declarations */
  36. #define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
  37. #define ata_id_has_lba(id) ((id)[49] & (1 << 9))
  38. #define ata_id_has_dma(id) ((id)[49] & (1 << 8))
  39. #define ata_id_u32(id,n) \
  40. (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
  41. #define ata_id_u64(id,n) \
  42. (((u64) (id)[(n) + 3] << 48) | \
  43. ((u64) (id)[(n) + 2] << 32) | \
  44. ((u64) (id)[(n) + 1] << 16) | \
  45. ((u64) (id)[(n) + 0]) )
  46. #endif
  47. #ifdef SATA_DECL /*SATA library specific declarations */
  48. static inline void
  49. ata_dump_id (u16 * id)
  50. {
  51. PRINTF ("49 = 0x%04x "
  52. "53 = 0x%04x "
  53. "63 = 0x%04x "
  54. "64 = 0x%04x "
  55. "75 = 0x%04x \n", id[49], id[53], id[63], id[64], id[75]);
  56. PRINTF ("80 = 0x%04x "
  57. "81 = 0x%04x "
  58. "82 = 0x%04x "
  59. "83 = 0x%04x "
  60. "84 = 0x%04x \n", id[80], id[81], id[82], id[83], id[84]);
  61. PRINTF ("88 = 0x%04x " "93 = 0x%04x\n", id[88], id[93]);
  62. }
  63. #endif
  64. #ifdef SATA_DECL /*SATA library specific declarations */
  65. int sata_bus_softreset (int num);
  66. void sata_identify (int num, int dev);
  67. void sata_port (struct sata_ioports *ioport);
  68. void set_Feature_cmd (int num, int dev);
  69. int sata_devchk (struct sata_ioports *ioaddr, int dev);
  70. void dev_select (struct sata_ioports *ioaddr, int dev);
  71. u8 sata_busy_wait (struct sata_ioports *ioaddr, int bits, unsigned int max);
  72. u8 sata_chk_status (struct sata_ioports *ioaddr);
  73. ulong sata_read (int device, ulong blknr,lbaint_t blkcnt, void * buffer);
  74. ulong sata_write (int device,ulong blknr, lbaint_t blkcnt, void * buffer);
  75. void msleep (int count);
  76. #endif
  77. /************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/
  78. #ifdef DRV_DECL /*Driver specific declaration */
  79. int init_sata (int dev);
  80. #endif
  81. #ifdef DRV_DECL /*Defines Driver Specific variables */
  82. struct sata_port port[CONFIG_SYS_SATA_MAXBUS];
  83. #endif
  84. #endif /* __ATA_PIIX_H__ */