blob: 165b471b289ab011ac162d16f65ba3d7737d3278 [file] [log] [blame]
mushtaq khan66d9dbe2007-04-20 14:23:02 +05301
2#if (DEBUG_SATA)
3#define PRINTF(fmt,args...) printf (fmt ,##args)
4#else
5#define PRINTF(fmt,args...)
6#endif
7
8struct 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
26struct sata_port {
Wolfgang Denk3162eb82007-05-15 23:38:05 +020027 unsigned char port_no; /* primary=0, secondary=1 */
28 struct sata_ioports ioaddr; /* ATA cmd/ctl/dma reg blks */
mushtaq khan66d9dbe2007-04-20 14:23:02 +053029 unsigned char ctl_reg;
30 unsigned char last_ctl;
Mushtaq Khan1f2a0582007-06-30 18:50:48 +020031 unsigned char port_state; /* 1-port is available and */
32 /* 0-port is not available */
mushtaq khan66d9dbe2007-04-20 14:23:02 +053033 unsigned char dev_mask;
34};
35
36/***********SATA LIBRARY SPECIFIC DEFINITIONS AND DECLARATIONS**************/
37#ifdef SATA_DECL /*SATA library specific declarations */
38#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
39#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
40#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
41#define ata_id_u32(id,n) \
42 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
43#define ata_id_u64(id,n) \
44 (((u64) (id)[(n) + 3] << 48) | \
45 ((u64) (id)[(n) + 2] << 32) | \
46 ((u64) (id)[(n) + 1] << 16) | \
47 ((u64) (id)[(n) + 0]) )
48#endif
49
50#ifdef SATA_DECL /*SATA library specific declarations */
51static inline void
52ata_dump_id (u16 * id)
53{
54 PRINTF ("49==0x%04x "
55 "53==0x%04x "
56 "63==0x%04x "
57 "64==0x%04x "
58 "75==0x%04x \n", id[49], id[53], id[63], id[64], id[75]);
59 PRINTF ("80==0x%04x "
60 "81==0x%04x "
61 "82==0x%04x "
62 "83==0x%04x "
63 "84==0x%04x \n", id[80], id[81], id[82], id[83], id[84]);
64 PRINTF ("88==0x%04x " "93==0x%04x\n", id[88], id[93]);
65}
66#endif
67
68#ifdef SATA_DECL /*SATA library specific declarations */
69int sata_bus_softreset (int num);
70void sata_identify (int num, int dev);
71void sata_port (struct sata_ioports *ioport);
72void set_Feature_cmd (int num, int dev);
73int sata_devchk (struct sata_ioports *ioaddr, int dev);
74void dev_select (struct sata_ioports *ioaddr, int dev);
75u8 sata_busy_wait (struct sata_ioports *ioaddr, int bits, unsigned int max);
76u8 sata_chk_status (struct sata_ioports *ioaddr);
Mushtaq Khan1f2a0582007-06-30 18:50:48 +020077ulong sata_read (int device, ulong blknr,lbaint_t blkcnt, void * buffer);
78ulong sata_write (int device,ulong blknr, lbaint_t blkcnt, void * buffer);
mushtaq khan66d9dbe2007-04-20 14:23:02 +053079void msleep (int count);
80#else
81extern int sata_bus_softreset (int num);
82extern void sata_identify (int num, int dev);
83extern void sata_port (struct sata_ioports *ioport);
84extern void set_Feature_cmd (int num, int dev);
Mushtaq Khan1f2a0582007-06-30 18:50:48 +020085extern ulong sata_read (int device, ulong blknr,
86 lbaint_t blkcnt, void * buffer);
87extern ulong sata_write (int device, ulong blknr,
88 lbaint_t blkcnt, void * buffer);
mushtaq khan66d9dbe2007-04-20 14:23:02 +053089extern void msleep (int count);
90#endif
91
92/************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/
93
94#ifdef DRV_DECL /*Driver specific declaration */
95int init_sata (void);
96#else
97extern int init_sata (void);
98#endif
99
100#ifdef DRV_DECL /*Defines Driver Specific variables */
101struct sata_port port[CFG_SATA_MAXBUS];
102block_dev_desc_t sata_dev_desc[CFG_SATA_MAXDEVICES];
103int curr_dev = -1;
104#else
105extern struct sata_port port[CFG_SATA_MAXBUS];
106extern block_dev_desc_t sata_dev_desc[CFG_SATA_MAXDEVICES];
107extern int curr_dev;
108#endif