sata.h 3.3 KB

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