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