Blame view

include/linux/libata.h 66.6 KB
c82ee6d3b   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
af36d7f0d   Jeff Garzik   [libata] license ...
3
4
5
   *  Copyright 2003-2005 Red Hat, Inc.  All rights reserved.
   *  Copyright 2003-2005 Jeff Garzik
   *
af36d7f0d   Jeff Garzik   [libata] license ...
6
   *  libata documentation is available via 'make {ps|pdf}docs',
9bb9a39ce   Mauro Carvalho Chehab   ata: update refer...
7
   *  as Documentation/driver-api/libata.rst
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
12
13
   */
  
  #ifndef __LINUX_LIBATA_H__
  #define __LINUX_LIBATA_H__
  
  #include <linux/delay.h>
341c2c958   Tejun Heo   libata: consisten...
14
  #include <linux/jiffies.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
  #include <linux/interrupt.h>
1c72d8d90   Andrew Morton   [PATCH] libata.h ...
16
  #include <linux/dma-mapping.h>
872602162   Jens Axboe   libata: convert t...
17
  #include <linux/scatterlist.h>
f0d36efdc   Tejun Heo   libata: update li...
18
  #include <linux/io.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
  #include <linux/ata.h>
  #include <linux/workqueue.h>
35bb94b11   Jeff Garzik   libata: Add helpe...
21
  #include <scsi/scsi_host.h>
11ef697b3   Kristen Carlson Accardi   [PATCH] libata: A...
22
  #include <linux/acpi.h>
ceb0c6426   Tejun Heo   libata: add ATAPI...
23
  #include <linux/cdrom.h>
c0c362b60   Tejun Heo   libata: implement...
24
  #include <linux/sched.h>
b5292111d   Kai-Heng Feng   libata: Use per p...
25
  #include <linux/async.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26

a6d967a48   Jeff Garzik   [libata] No need ...
27
28
29
30
31
  /*
   * Define if arch has non-standard setup.  This is a _PCI_ standard
   * not a legacy or ISA standard.
   */
  #ifdef CONFIG_ATA_NONSTANDARD
2ec7df045   Alan Cox   [PATCH] libata: r...
32
  #include <asm/libata-portmap.h>
a6d967a48   Jeff Garzik   [libata] No need ...
33
  #else
dcd3ea81f   Christoph Hellwig   libata: remove <a...
34
35
  #define ATA_PRIMARY_IRQ(dev)	14
  #define ATA_SECONDARY_IRQ(dev)	15
a6d967a48   Jeff Garzik   [libata] No need ...
36
  #endif
2ec7df045   Alan Cox   [PATCH] libata: r...
37

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
  /*
bfd605795   Randy Dunlap   From: Borislav Pe...
39
40
   * compile-time options: to be removed as soon as all the drivers are
   * converted to the new debugging mechanism
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
42
43
44
45
   */
  #undef ATA_DEBUG		/* debugging output */
  #undef ATA_VERBOSE_DEBUG	/* yet more debugging output */
  #undef ATA_IRQ_TRAP		/* define to ack screaming irqs */
  #undef ATA_NDEBUG		/* define to disable quick runtime checks */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
  
  
  /* note: prints function name for you */
  #ifdef ATA_DEBUG
1f938d060   Alexander Beregalov   libata.h: replace...
50
  #define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  #ifdef ATA_VERBOSE_DEBUG
1f938d060   Alexander Beregalov   libata.h: replace...
52
  #define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
54
55
56
57
58
59
  #else
  #define VPRINTK(fmt, args...)
  #endif	/* ATA_VERBOSE_DEBUG */
  #else
  #define DPRINTK(fmt, args...)
  #define VPRINTK(fmt, args...)
  #endif	/* ATA_DEBUG */
06296a1e6   Joe Perches   ata: Add and use ...
60
61
62
63
64
65
66
67
68
  #define ata_print_version_once(dev, version)			\
  ({								\
  	static bool __print_once;				\
  								\
  	if (!__print_once) {					\
  		__print_once = true;				\
  		ata_print_version(dev, version);		\
  	}							\
  })
bfd605795   Randy Dunlap   From: Borislav Pe...
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  /* NEW: debug levels */
  #define HAVE_LIBATA_MSG 1
  
  enum {
  	ATA_MSG_DRV	= 0x0001,
  	ATA_MSG_INFO	= 0x0002,
  	ATA_MSG_PROBE	= 0x0004,
  	ATA_MSG_WARN	= 0x0008,
  	ATA_MSG_MALLOC	= 0x0010,
  	ATA_MSG_CTL	= 0x0020,
  	ATA_MSG_INTR	= 0x0040,
  	ATA_MSG_ERR	= 0x0080,
  };
  
  #define ata_msg_drv(p)    ((p)->msg_enable & ATA_MSG_DRV)
  #define ata_msg_info(p)   ((p)->msg_enable & ATA_MSG_INFO)
  #define ata_msg_probe(p)  ((p)->msg_enable & ATA_MSG_PROBE)
  #define ata_msg_warn(p)   ((p)->msg_enable & ATA_MSG_WARN)
  #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC)
  #define ata_msg_ctl(p)    ((p)->msg_enable & ATA_MSG_CTL)
  #define ata_msg_intr(p)   ((p)->msg_enable & ATA_MSG_INTR)
  #define ata_msg_err(p)    ((p)->msg_enable & ATA_MSG_ERR)
  
  static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
  {
  	if (dval < 0 || dval >= (sizeof(u32) * 8))
  		return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */
  	if (!dval)
  		return 0;
  	return (1 << dval) - 1;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
  /* defines only for the constants which don't work well as enums */
  #define ATA_TAG_POISON		0xfafbfcfdU
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
104
  enum {
  	/* various global constants */
  	LIBATA_MAX_PRD		= ATA_MAX_PRD / 2,
d26fc9551   Alan Cox   libata: Support c...
105
  	LIBATA_DUMB_MAX_PRD	= ATA_MAX_PRD / 4,	/* Worst case */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  	ATA_DEF_QUEUE		= 1,
a6e6ce8e8   Tejun Heo   [PATCH] libata-nc...
107
  	ATA_MAX_QUEUE		= 32,
28361c403   Jens Axboe   libata: add extra...
108
  	ATA_TAG_INTERNAL	= ATA_MAX_QUEUE,
341c2c958   Tejun Heo   libata: consisten...
109
  	ATA_SHORT_PAUSE		= 16,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110

140b5e591   Tejun Heo   libata: fix ATAPI...
111
  	ATAPI_MAX_DRAIN		= 16 << 10,
b558edddb   Tejun Heo   libata: kill ata_...
112
  	ATA_ALL_DEVICES		= (1 << ATA_MAX_DEVICES) - 1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  	ATA_SHT_EMULATED	= 1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
114
  	ATA_SHT_THIS_ID		= -1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
115

dc34e7e1a   Sergei Shtylyov   libata: move 'str...
116
117
118
119
120
121
122
123
  	/* struct ata_taskfile flags */
  	ATA_TFLAG_LBA48		= (1 << 0), /* enable 48-bit LBA and "HOB" */
  	ATA_TFLAG_ISADDR	= (1 << 1), /* enable r/w to nsect/lba regs */
  	ATA_TFLAG_DEVICE	= (1 << 2), /* enable r/w to device reg */
  	ATA_TFLAG_WRITE		= (1 << 3), /* data dir: host->dev==1 (write) */
  	ATA_TFLAG_LBA		= (1 << 4), /* enable LBA */
  	ATA_TFLAG_FUA		= (1 << 5), /* enable FUA */
  	ATA_TFLAG_POLLING	= (1 << 6), /* set nIEN to 1 and use polling */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  	/* struct ata_device stuff */
949b38af4   Tejun Heo   [PATCH] libata: c...
125
126
  	ATA_DFLAG_LBA		= (1 << 0), /* device supports LBA */
  	ATA_DFLAG_LBA48		= (1 << 1), /* device supports LBA48 */
029f5468b   Jeff Garzik   Merge branch 'ups...
127
  	ATA_DFLAG_CDB_INTR	= (1 << 2), /* device asserts INTRQ when ready for CDB */
88e490340   Tejun Heo   [PATCH] libata-nc...
128
  	ATA_DFLAG_NCQ		= (1 << 3), /* device supports NCQ */
6fc49adb9   Tejun Heo   [PATCH] libata: u...
129
  	ATA_DFLAG_FLUSH_EXT	= (1 << 4), /* do FLUSH_EXT instead of FLUSH */
6746544c3   Tejun Heo   libata: reimpleme...
130
131
  	ATA_DFLAG_ACPI_PENDING	= (1 << 5), /* ACPI resume action pending */
  	ATA_DFLAG_ACPI_FAILED	= (1 << 6), /* ACPI on devcfg has failed */
7d77b2470   Tejun Heo   libata-pmp-prep: ...
132
  	ATA_DFLAG_AN		= (1 << 7), /* AN configured */
818831c8b   Christoph Hellwig   libata: implement...
133
  	ATA_DFLAG_TRUSTED	= (1 << 8), /* device supports trusted send/recv */
911630063   Tejun Heo   libata: automatic...
134
  	ATA_DFLAG_DMADIR	= (1 << 10), /* device requires DMADIR */
2557164e0   Kristen Carlson Accardi   ata: increase all...
135
  	ATA_DFLAG_CFG_MASK	= (1 << 12) - 1,
949b38af4   Tejun Heo   [PATCH] libata: c...
136

2557164e0   Kristen Carlson Accardi   ata: increase all...
137
138
  	ATA_DFLAG_PIO		= (1 << 12), /* device limited to PIO mode */
  	ATA_DFLAG_NCQ_OFF	= (1 << 13), /* device limited to non-NCQ mode */
054a5fbac   Tejun Heo   libata: track SLE...
139
  	ATA_DFLAG_SLEEPING	= (1 << 15), /* device is sleeping */
00115e0f5   Tejun Heo   libata: implement...
140
  	ATA_DFLAG_DUBIOUS_XFER	= (1 << 16), /* data transfer not verified */
45fabbb77   Elias Oltmanns   libata: Implement...
141
  	ATA_DFLAG_NO_UNLOAD	= (1 << 17), /* device doesn't support unload */
445d211b0   Tejun Heo   libata: unlock HP...
142
  	ATA_DFLAG_UNLOCK_HPA	= (1 << 18), /* unlock HPA */
ed36911c7   Marc Carino   libata: Add suppo...
143
  	ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */
8e061784b   Adam Manzanares   ata: Enabling ATA...
144
  	ATA_DFLAG_NCQ_PRIO	= (1 << 20), /* device supports NCQ priority */
84f95243b   Adam Manzanares   ata: ATA Command ...
145
  	ATA_DFLAG_NCQ_PRIO_ENABLE = (1 << 21), /* Priority cmds sent to dev */
f20ded38a   Tejun Heo   libata: rearrange...
146
  	ATA_DFLAG_INIT_MASK	= (1 << 24) - 1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147

f20ded38a   Tejun Heo   libata: rearrange...
148
149
  	ATA_DFLAG_DETACH	= (1 << 24),
  	ATA_DFLAG_DETACHED	= (1 << 25),
abdda7331   Tejun Heo   [PATCH] libata-hp...
150

b1354cbb5   Lin Ming   libata: detect De...
151
  	ATA_DFLAG_DA		= (1 << 26), /* device supports Device Attention */
65fe1f0f6   Shane Huang   ahci: implement a...
152
  	ATA_DFLAG_DEVSLP	= (1 << 27), /* device supports Device Sleep */
0d0cdb028   Aaron Lu   libata: restore a...
153
  	ATA_DFLAG_ACPI_DISABLED = (1 << 28), /* ACPI for the device is disabled */
06dbde5f3   Hannes Reinecke   libata: Implement...
154
  	ATA_DFLAG_D_SENSE	= (1 << 29), /* Descriptor sense requested */
6d1003ae8   Hannes Reinecke   libata: support h...
155
  	ATA_DFLAG_ZAC		= (1 << 30), /* ZAC device */
b1354cbb5   Lin Ming   libata: detect De...
156

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
159
160
161
  	ATA_DEV_UNKNOWN		= 0,	/* unknown device */
  	ATA_DEV_ATA		= 1,	/* ATA device */
  	ATA_DEV_ATA_UNSUP	= 2,	/* ATA device (unsupported) */
  	ATA_DEV_ATAPI		= 3,	/* ATAPI device */
  	ATA_DEV_ATAPI_UNSUP	= 4,	/* ATAPI device (unsupported) */
e0a717526   Tejun Heo   libata-pmp-prep: ...
162
163
164
165
  	ATA_DEV_PMP		= 5,	/* SATA port multiplier */
  	ATA_DEV_PMP_UNSUP	= 6,	/* SATA port multiplier (unsupported) */
  	ATA_DEV_SEMB		= 7,	/* SEMB */
  	ATA_DEV_SEMB_UNSUP	= 8,	/* SEMB (unsupported) */
9162c6579   Hannes Reinecke   libata: Implement...
166
  	ATA_DEV_ZAC		= 9,	/* ZAC device */
3a92945b2   Hannes Reinecke   libata: fixup ZAC...
167
168
  	ATA_DEV_ZAC_UNSUP	= 10,	/* ZAC device (unsupported) */
  	ATA_DEV_NONE		= 11,	/* no device */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
169

0c88758b5   Tejun Heo   libata-link: make...
170
  	/* struct ata_link flags */
8ba5a45c9   Bartlomiej Zolnierkiewicz   ata: optimize str...
171
  	/* NOTE: struct ata_force_param currently stores lflags in u16 */
05944bdf6   Tejun Heo   libata: implement...
172
  	ATA_LFLAG_NO_HRST	= (1 << 1), /* avoid hardreset */
ae791c056   Tejun Heo   libata-pmp-prep: ...
173
174
175
176
  	ATA_LFLAG_NO_SRST	= (1 << 2), /* avoid softreset */
  	ATA_LFLAG_ASSUME_ATA	= (1 << 3), /* assume ATA class */
  	ATA_LFLAG_ASSUME_SEMB	= (1 << 4), /* assume SEMB class */
  	ATA_LFLAG_ASSUME_CLASS	= ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
fd995f703   Tejun Heo   libata-pmp-prep: ...
177
  	ATA_LFLAG_NO_RETRY	= (1 << 5), /* don't retry this link */
f9df58cb2   Tejun Heo   libata-pmp-prep: ...
178
  	ATA_LFLAG_DISABLED	= (1 << 6), /* link is disabled */
18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
179
  	ATA_LFLAG_SW_ACTIVITY	= (1 << 7), /* keep activity stats */
6b7ae9545   Tejun Heo   libata: reimpleme...
180
  	ATA_LFLAG_NO_LPM	= (1 << 8), /* disable LPM on this link */
ca6d43b05   Dan Williams   [SCSI] libata: re...
181
  	ATA_LFLAG_RST_ONCE	= (1 << 9), /* limit recovery to one reset */
09c5b4803   Gabriele Mazzotta   libata: Ignore sp...
182
  	ATA_LFLAG_CHANGED	= (1 << 10), /* LPM state changed on this link */
e39b2bb3b   Danesh Petigara   libata: skip debo...
183
  	ATA_LFLAG_NO_DB_DELAY	= (1 << 11), /* no debounce delay on link resume */
0c88758b5   Tejun Heo   libata-link: make...
184

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
185
  	/* struct ata_port flags */
949b38af4   Tejun Heo   [PATCH] libata: c...
186
  	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
  					    /* (doesn't imply presence) */
949b38af4   Tejun Heo   [PATCH] libata: c...
188
  	ATA_FLAG_SATA		= (1 << 1),
240630e61   Hans de Goede   ahci: Disable LPM...
189
  	ATA_FLAG_NO_LPM		= (1 << 2), /* host not happy with LPM */
ea013a9b2   Andreas Werner   libata-eh.c: Intr...
190
  	ATA_FLAG_NO_LOG_PAGE	= (1 << 5), /* do not issue log page read */
949b38af4   Tejun Heo   [PATCH] libata: c...
191
192
193
  	ATA_FLAG_NO_ATAPI	= (1 << 6), /* No ATAPI support */
  	ATA_FLAG_PIO_DMA	= (1 << 7), /* PIO cmds via DMA */
  	ATA_FLAG_PIO_LBA48	= (1 << 8), /* Host DMA engine is LBA28 only */
7395acb2c   Tejun Heo   [PATCH] libata: s...
194
195
196
  	ATA_FLAG_PIO_POLLING	= (1 << 9), /* use polling PIO if LLD
  					     * doesn't handle PIO interrupts */
  	ATA_FLAG_NCQ		= (1 << 10), /* host supports NCQ */
2a6e58d27   Rafael J. Wysocki   SATA: Blacklistin...
197
198
  	ATA_FLAG_NO_POWEROFF_SPINDOWN = (1 << 11), /* don't spindown before poweroff */
  	ATA_FLAG_NO_HIBERNATE_SPINDOWN = (1 << 12), /* don't spindown before hibernation */
7395acb2c   Tejun Heo   [PATCH] libata: s...
199
  	ATA_FLAG_DEBUGMSG	= (1 << 13),
388539f3f   Shaohua Li   [libata] add DMA ...
200
  	ATA_FLAG_FPDMA_AA		= (1 << 14), /* driver supports Auto-Activate */
b2a8bbe67   Tejun Heo   libata: implement...
201
  	ATA_FLAG_IGN_SIMPLEX	= (1 << 15), /* ignore SIMPLEX */
f834e49f1   Alan Cox   libata: Add a hos...
202
  	ATA_FLAG_NO_IORDY	= (1 << 16), /* controller lacks iordy */
3cadbcc09   Tejun Heo   libata-acpi: add ...
203
  	ATA_FLAG_ACPI_SATA	= (1 << 17), /* need native SATA ACPI layout */
9f45cbd3f   Kristen Carlson Accardi   [libata] check fo...
204
  	ATA_FLAG_AN		= (1 << 18), /* controller supports AN */
e0a717526   Tejun Heo   libata-pmp-prep: ...
205
  	ATA_FLAG_PMP		= (1 << 19), /* controller supports PMP */
40fb59e75   Marc Carino   libata: Add H2D F...
206
  	ATA_FLAG_FPDMA_AUX	= (1 << 20), /* controller supports H2DFIS aux field */
18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
207
208
209
210
  	ATA_FLAG_EM		= (1 << 21), /* driver supports enclosure
  					      * management */
  	ATA_FLAG_SW_ACTIVITY	= (1 << 22), /* driver supports sw activity
  					      * led */
ae01b2493   Tejun Heo   libata: Implement...
211
  	ATA_FLAG_NO_DIPM	= (1 << 23), /* host not happy with DIPM */
a1480a166   Linus Torvalds   Merge branch 'for...
212
  	ATA_FLAG_SAS_HOST	= (1 << 24), /* SAS host */
949b38af4   Tejun Heo   [PATCH] libata: c...
213

b51e9e5db   Tejun Heo   [PATCH] libata: a...
214
  	/* bits 24:31 of ap->flags are reserved for LLD specific flags */
9ec957f20   Tejun Heo   [PATCH] libata-eh...
215

e3cf95dd6   Alan Cox   ata: Report 16/32...
216

b51e9e5db   Tejun Heo   [PATCH] libata: a...
217
218
219
220
221
222
  	/* struct ata_port pflags */
  	ATA_PFLAG_EH_PENDING	= (1 << 0), /* EH pending */
  	ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */
  	ATA_PFLAG_FROZEN	= (1 << 2), /* port is frozen */
  	ATA_PFLAG_RECOVERED	= (1 << 3), /* recovery action performed */
  	ATA_PFLAG_LOADING	= (1 << 4), /* boot/loading probe */
b51e9e5db   Tejun Heo   [PATCH] libata: a...
223
  	ATA_PFLAG_SCSI_HOTPLUG	= (1 << 6), /* SCSI hotplug scheduled */
f4d6d0046   Tejun Heo   libata: ignore EH...
224
  	ATA_PFLAG_INITIALIZING	= (1 << 7), /* being initialized, don't touch */
afaa5c373   Tejun Heo   libata: implement...
225
  	ATA_PFLAG_RESETTING	= (1 << 8), /* reset in progress */
ece180d1c   Tejun Heo   libata: perform p...
226
227
  	ATA_PFLAG_UNLOADING	= (1 << 9), /* driver is being unloaded */
  	ATA_PFLAG_UNLOADED	= (1 << 10), /* driver is unloaded */
949b38af4   Tejun Heo   [PATCH] libata: c...
228

b51e9e5db   Tejun Heo   [PATCH] libata: a...
229
  	ATA_PFLAG_SUSPENDED	= (1 << 17), /* port is suspended (power) */
500530f65   Tejun Heo   [PATCH] libata: r...
230
  	ATA_PFLAG_PM_PENDING	= (1 << 18), /* PM operation pending */
c05e6ff03   Tejun Heo   libata-acpi: impl...
231
  	ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */
949b38af4   Tejun Heo   [PATCH] libata: c...
232

e3cf95dd6   Alan Cox   ata: Report 16/32...
233
234
  	ATA_PFLAG_PIO32		= (1 << 20),  /* 32bit PIO */
  	ATA_PFLAG_PIO32CHANGE	= (1 << 21),  /* 32bit PIO can be turned on/off */
8a3e33cf9   Manuel Lauss   ata: ahci: find e...
235
  	ATA_PFLAG_EXTERNAL	= (1 << 22),  /* eSATA/external port */
e3cf95dd6   Alan Cox   ata: Report 16/32...
236

949b38af4   Tejun Heo   [PATCH] libata: c...
237
238
  	/* struct ata_queued_cmd flags */
  	ATA_QCFLAG_ACTIVE	= (1 << 0), /* cmd not yet ack'd to scsi lyer */
001102d78   Tejun Heo   libata: kill non-...
239
  	ATA_QCFLAG_DMAMAP	= (1 << 1), /* SG table is DMA mapped */
271973677   Tejun Heo   [PATCH] libata: a...
240
  	ATA_QCFLAG_IO		= (1 << 3), /* standard IO command */
e61e06722   Tejun Heo   [PATCH] libata: i...
241
  	ATA_QCFLAG_RESULT_TF	= (1 << 4), /* result TF requested */
da917d69d   Tejun Heo   libata-pmp-prep: ...
242
  	ATA_QCFLAG_CLEAR_EXCL	= (1 << 5), /* clear excl_link on completion */
e027bd36c   Tejun Heo   libata: implement...
243
  	ATA_QCFLAG_QUIET	= (1 << 6), /* don't report device error */
03faab782   Tejun Heo   libata: implement...
244
  	ATA_QCFLAG_RETRY	= (1 << 7), /* retry after failure */
e61e06722   Tejun Heo   [PATCH] libata: i...
245

9ec957f20   Tejun Heo   [PATCH] libata-eh...
246
247
248
  	ATA_QCFLAG_FAILED	= (1 << 16), /* cmd failed and is owned by EH */
  	ATA_QCFLAG_SENSE_VALID	= (1 << 17), /* sense data valid */
  	ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
249

4e5ec5dba   Alan Cox   [PATCH] libata: B...
250
  	/* host set flags */
cca3974e4   Jeff Garzik   libata: Grand ren...
251
  	ATA_HOST_SIMPLEX	= (1 << 0),	/* Host is simplex, one DMA channel per host only */
ecef72532   Tejun Heo   libata: separate ...
252
  	ATA_HOST_STARTED	= (1 << 1),	/* Host started */
886ad09fc   Arjan van de Ven   libata: Add a per...
253
  	ATA_HOST_PARALLEL_SCAN	= (1 << 2),	/* Ports on this host can be scanned in parallel */
db63a4c81   Andy Whitcroft   libata: add a hos...
254
  	ATA_HOST_IGNORE_ATA	= (1 << 3),	/* Ignore ATA devices on this host. */
9bec2e385   Jeff Garzik   [libata] Trim tra...
255

b8b275efc   Tejun Heo   ata_piix: fix sus...
256
  	/* bits 24:31 of host->flags are reserved for LLD specific flags */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
257
  	/* various lengths of time */
341c2c958   Tejun Heo   libata: consisten...
258
259
  	ATA_TMOUT_BOOT		= 30000,	/* heuristic */
  	ATA_TMOUT_BOOT_QUICK	=  7000,	/* heuristic */
341c2c958   Tejun Heo   libata: consisten...
260
  	ATA_TMOUT_INTERNAL_QUICK = 5000,
45fabbb77   Elias Oltmanns   libata: Implement...
261
  	ATA_TMOUT_MAX_PARK	= 30000,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
262

b48d58f55   Tejun Heo   libata: use longe...
263
264
265
266
  	/*
  	 * GoVault needs 2s and iVDR disk HHD424020F7SV00 800ms.  2s
  	 * is too much without parallel probing.  Use 2s if parallel
  	 * probing is available, 800ms otherwise.
88ff6eafb   Tejun Heo   libata: implement...
267
  	 */
b48d58f55   Tejun Heo   libata: use longe...
268
269
  	ATA_TMOUT_FF_WAIT_LONG	=  2000,
  	ATA_TMOUT_FF_WAIT	=   800,
88ff6eafb   Tejun Heo   libata: implement...
270

705e76beb   Tejun Heo   libata: restructu...
271
272
273
274
275
276
277
278
279
280
  	/* Spec mandates to wait for ">= 2ms" before checking status
  	 * after reset.  We wait 150ms, because that was the magic
  	 * delay used for ATAPI devices in Hale Landis's ATADRVR, for
  	 * the period of time between when the ATA command register is
  	 * written, and then status is checked.  Because waiting for
  	 * "a while" before checking status is fine, post SRST, we
  	 * perform this magic delay here as well.
  	 *
  	 * Old drivers/ide uses the 2mS rule and then waits for ready.
  	 */
341c2c958   Tejun Heo   libata: consisten...
281
  	ATA_WAIT_AFTER_RESET	=  150,
705e76beb   Tejun Heo   libata: restructu...
282

9dadd45b2   Tejun Heo   libata: move gene...
283
284
285
286
287
  	/* If PMP is supported, we have to do follow-up SRST.  As some
  	 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
  	 * advised to wait only for the following duration before
  	 * doing SRST.
  	 */
e7d3ef13d   Stuart Hayes   libata: change dr...
288
  	ATA_TMOUT_PMP_SRST_WAIT	= 5000,
9dadd45b2   Tejun Heo   libata: move gene...
289

09c5b4803   Gabriele Mazzotta   libata: Ignore sp...
290
291
292
293
294
  	/* When the LPM policy is set to ATA_LPM_MAX_POWER, there might
  	 * be a spurious PHY event, so ignore the first PHY event that
  	 * occurs within 10s after the policy change.
  	 */
  	ATA_TMOUT_SPURIOUS_PHY	= 10000,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
  	/* ATA bus states */
  	BUS_UNKNOWN		= 0,
  	BUS_DMA			= 1,
  	BUS_IDLE		= 2,
  	BUS_NOINTR		= 3,
  	BUS_NODATA		= 4,
  	BUS_TIMER		= 5,
  	BUS_PIO			= 6,
  	BUS_EDD			= 7,
  	BUS_IDENTIFY		= 8,
  	BUS_PACKET		= 9,
  
  	/* SATA port states */
  	PORT_UNKNOWN		= 0,
  	PORT_ENABLED		= 1,
  	PORT_DISABLED		= 2,
  
  	/* encoding various smaller bitmaps into a single
7dc951aef   Tejun Heo   libata: xfer_mask...
313
  	 * unsigned long bitmap
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
  	 */
70cd071e4   Tejun Heo   libata: clean up ...
315
316
317
  	ATA_NR_PIO_MODES	= 7,
  	ATA_NR_MWDMA_MODES	= 5,
  	ATA_NR_UDMA_MODES	= 8,
1da7b0d01   Tejun Heo   [PATCH] libata: i...
318
319
  
  	ATA_SHIFT_PIO		= 0,
70cd071e4   Tejun Heo   libata: clean up ...
320
321
  	ATA_SHIFT_MWDMA		= ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
  	ATA_SHIFT_UDMA		= ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
8e061784b   Adam Manzanares   ata: Enabling ATA...
322
  	ATA_SHIFT_PRIO		= 6,
70cd071e4   Tejun Heo   libata: clean up ...
323

8e061784b   Adam Manzanares   ata: Enabling ATA...
324
  	ATA_PRIO_HIGH		= 2,
cedc9a478   Jeff Garzik   libata: fix ATAPI...
325
326
  	/* size of buffer to pad xfers ending on unaligned boundaries */
  	ATA_DMA_PAD_SZ		= 4,
949b38af4   Tejun Heo   [PATCH] libata: c...
327

0c247c559   Tejun Heo   [PATCH] libata-eh...
328
329
  	/* ering size */
  	ATA_ERING_SIZE		= 32,
31cc23b34   Tejun Heo   libata-pmp-prep: ...
330
331
332
  	/* return values for ->qc_defer */
  	ATA_DEFER_LINK		= 1,
  	ATA_DEFER_PORT		= 2,
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
333
334
  	/* desc_len for ata_eh_info and context */
  	ATA_EH_DESC_LEN		= 80,
9be1e979f   Tejun Heo   [PATCH] libata-eh...
335
336
  	/* reset / recovery action types */
  	ATA_EH_REVALIDATE	= (1 << 0),
cf4806265   Tejun Heo   libata: prefer ha...
337
338
339
  	ATA_EH_SOFTRESET	= (1 << 1), /* meaningful only in ->prereset */
  	ATA_EH_HARDRESET	= (1 << 2), /* meaningful only in ->prereset */
  	ATA_EH_RESET		= ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
f9df58cb2   Tejun Heo   libata-pmp-prep: ...
340
  	ATA_EH_ENABLE_LINK	= (1 << 3),
45fabbb77   Elias Oltmanns   libata: Implement...
341
  	ATA_EH_PARK		= (1 << 5), /* unload heads and stop I/O */
9be1e979f   Tejun Heo   [PATCH] libata-eh...
342

45fabbb77   Elias Oltmanns   libata: Implement...
343
  	ATA_EH_PERDEV_MASK	= ATA_EH_REVALIDATE | ATA_EH_PARK,
b5b3fa386   Tejun Heo   libata: misc upda...
344
  	ATA_EH_ALL_ACTIONS	= ATA_EH_REVALIDATE | ATA_EH_RESET |
6b7ae9545   Tejun Heo   libata: reimpleme...
345
  				  ATA_EH_ENABLE_LINK,
9be1e979f   Tejun Heo   [PATCH] libata-eh...
346

f3e81b19a   Tejun Heo   [PATCH] libata-eh...
347
  	/* ata_eh_info->flags */
abdda7331   Tejun Heo   [PATCH] libata-hp...
348
  	ATA_EHI_HOTPLUGGED	= (1 << 0),  /* could have been hotplugged */
1cdaf534f   Tejun Heo   [PATCH] libata: i...
349
350
  	ATA_EHI_NO_AUTOPSY	= (1 << 2),  /* no autopsy */
  	ATA_EHI_QUIET		= (1 << 3),  /* be quiet */
e2f3d75fc   Tejun Heo   libata: skip EH a...
351
  	ATA_EHI_NO_RECOVERY	= (1 << 4),  /* no recovery */
abdda7331   Tejun Heo   [PATCH] libata-hp...
352

0d64a233f   Tejun Heo   libata: separate ...
353
354
355
356
  	ATA_EHI_DID_SOFTRESET	= (1 << 16), /* already soft-reset this port */
  	ATA_EHI_DID_HARDRESET	= (1 << 17), /* already soft-reset this port */
  	ATA_EHI_PRINTINFO	= (1 << 18), /* print configuration info */
  	ATA_EHI_SETMODE		= (1 << 19), /* configure transfer mode */
89692c032   Andrea Gelmini   include/linux/lib...
357
  	ATA_EHI_POST_SETMODE	= (1 << 20), /* revalidating after setmode */
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
358

0d64a233f   Tejun Heo   libata: separate ...
359
  	ATA_EHI_DID_RESET	= ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
13abf50df   Tejun Heo   [PATCH] libata: i...
360

848e4c68c   Tejun Heo   libata: transfer ...
361
362
  	/* mask of flags to transfer *to* the slave link */
  	ATA_EHI_TO_SLAVE_MASK	= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET,
a1e10f7e6   Tejun Heo   libata: move EH r...
363
364
  	/* max tries if error condition is still set after ->error_handler */
  	ATA_EH_MAX_TRIES	= 5,
ad9e27624   Tejun Heo   [PATCH] libata-eh...
365

5040ab67a   Tejun Heo   libata: retry lin...
366
367
  	/* sometimes resuming a link requires several retries */
  	ATA_LINK_RESUME_TRIES	= 5,
14d2bac18   Tejun Heo   [PATCH] libata: i...
368
369
  	/* how hard are we gonna try to probe/recover devices */
  	ATA_PROBE_MAX_TRIES	= 3,
022bdb075   Tejun Heo   [PATCH] libata-eh...
370
  	ATA_EH_DEV_TRIES	= 3,
e0a717526   Tejun Heo   libata-pmp-prep: ...
371
372
  	ATA_EH_PMP_TRIES	= 5,
  	ATA_EH_PMP_LINK_TRIES	= 3,
bf1bff6fa   Tejun Heo   libata: increase ...
373
  	SATA_PMP_RW_TIMEOUT	= 3000,		/* PMP read/write timeout */
f5914a461   Tejun Heo   [PATCH] libata-hp...
374

87fbc5a06   Tejun Heo   libata: improve E...
375
376
377
  	/* This should match the actual table size of
  	 * ata_eh_cmd_timeout_table in libata-eh.c.
  	 */
6013efd88   Tejun Heo   libata: retry fai...
378
  	ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6,
87fbc5a06   Tejun Heo   libata: improve E...
379

935908598   Alan Cox   [PATCH] libata: i...
380
  	/* Horkage types. May be set by libata or controller on drives
25985edce   Lucas De Marchi   Fix common misspe...
381
  	   (some horkage may be drive/controller pair dependent */
935908598   Alan Cox   [PATCH] libata: i...
382
383
  
  	ATA_HORKAGE_DIAGNOSTIC	= (1 << 0),	/* Failed boot diag */
6919a0a6c   Alan Cox   [PATCH] libata: R...
384
385
  	ATA_HORKAGE_NODMA	= (1 << 1),	/* DMA problems */
  	ATA_HORKAGE_NONCQ	= (1 << 2),	/* Don't use NCQ */
18d6e9d51   Albert Lee   libata: Limit max...
386
  	ATA_HORKAGE_MAX_SEC_128	= (1 << 3),	/* Limit max sects to 128 */
16c55b038   Tejun Heo   libata: implement...
387
  	ATA_HORKAGE_BROKEN_HPA	= (1 << 4),	/* Broken HPA */
50af2fa1e   Tejun Heo   libata: ignore SI...
388
  	ATA_HORKAGE_DISABLE	= (1 << 5),	/* Disable it */
93328e114   Alan Cox   [PATCH] libata: F...
389
  	ATA_HORKAGE_HPA_SIZE	= (1 << 6),	/* native size off by one */
6bbfd53d4   Alan Cox   libata: handle br...
390
  	ATA_HORKAGE_IVB		= (1 << 8),	/* cbl det validity bit bugs */
2d3b8eea7   Albert Lee   libata: workaroun...
391
  	ATA_HORKAGE_STUCK_ERR	= (1 << 9),	/* stuck ERR on next PACKET */
9ce8e3073   Jens Axboe   libata: add white...
392
  	ATA_HORKAGE_BRIDGE_OK	= (1 << 10),	/* no bridge limits */
6a87e42e9   Tejun Heo   libata: implement...
393
394
  	ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands
  						    not multiple of 16 bytes */
877d03105   Nick Andrew   trivial: Fix miss...
395
  	ATA_HORKAGE_FIRMWARE_WARN = (1 << 12),	/* firmware update warning */
9062712fa   Tejun Heo   libata: implement...
396
  	ATA_HORKAGE_1_5_GBPS	= (1 << 13),	/* force 1.5 Gbps */
d0cb43b35   Tejun Heo   libata: implement...
397
  	ATA_HORKAGE_NOSETXFER	= (1 << 14),	/* skip SETXFER, SATA only */
388539f3f   Shaohua Li   [libata] add DMA ...
398
  	ATA_HORKAGE_BROKEN_FPDMA_AA	= (1 << 15),	/* skip AA */
43c9c5918   Tejun Heo   libata: implement...
399
  	ATA_HORKAGE_DUMP_ID	= (1 << 16),	/* dump IDENTIFY data */
a32450e12   Shan Hai   libata: Set max s...
400
  	ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17),	/* Set max sects to 65535 */
966fbe193   Vincent Pelletier   libata: Add atapi...
401
  	ATA_HORKAGE_ATAPI_DMADIR = (1 << 18),	/* device requires dmadir */
f78dea064   Marc Carino   libata: implement...
402
  	ATA_HORKAGE_NO_NCQ_TRIM	= (1 << 19),	/* don't use queued TRIM */
ecd75ad51   Tejun Heo   libata: disable L...
403
404
  	ATA_HORKAGE_NOLPM	= (1 << 20),	/* don't use LPM */
  	ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21),	/* some WDs have broken LPM */
e61f7d1c3   Martin K. Petersen   libata: Whitelist...
405
  	ATA_HORKAGE_ZERO_AFTER_TRIM = (1 << 22),/* guarantees zero after trim */
7cfdfdc82   Damien Le Moal   libata: Cleanup a...
406
  	ATA_HORKAGE_NO_DMA_LOG	= (1 << 23),	/* don't use DMA for log read */
71d126fd2   Arne Fitzenreiter   libata: add ATA_H...
407
  	ATA_HORKAGE_NOTRIM	= (1 << 24),	/* don't use TRIM */
af34d6376   David Milburn   libata: add ATA_H...
408
  	ATA_HORKAGE_MAX_SEC_1024 = (1 << 25),	/* Limit max sects to 1024 */
3b5455636   Tejun Heo   libata: implement...
409
  	ATA_HORKAGE_MAX_TRIM_128M = (1 << 26),	/* Limit max trim size to 128M */
b3a706014   Alan Cox   libata: Add a dri...
410

2dcb407e6   Jeff Garzik   [libata] checkpat...
411
  	 /* DMA mask for user DMA control: User visible values; DO NOT
b3a706014   Alan Cox   libata: Add a dri...
412
413
414
415
  	    renumber */
  	ATA_DMA_MASK_ATA	= (1 << 0),	/* DMA on ATA Disk */
  	ATA_DMA_MASK_ATAPI	= (1 << 1),	/* DMA on ATAPI */
  	ATA_DMA_MASK_CFA	= (1 << 2),	/* DMA on CF Card */
ceb0c6426   Tejun Heo   libata: add ATAPI...
416
417
418
419
420
  
  	/* ATAPI command types */
  	ATAPI_READ		= 0,		/* READs */
  	ATAPI_WRITE		= 1,		/* WRITEs */
  	ATAPI_READ_CD		= 2,		/* READ CD [MSF] */
e52dcc489   Tejun Heo   libata: ATA_12/16...
421
422
  	ATAPI_PASS_THRU		= 3,		/* SAT pass-thru */
  	ATAPI_MISC		= 4,		/* the rest */
624d5c514   Tejun Heo   libata: reorganiz...
423
424
425
426
427
428
429
430
431
432
  
  	/* Timing constants */
  	ATA_TIMING_SETUP	= (1 << 0),
  	ATA_TIMING_ACT8B	= (1 << 1),
  	ATA_TIMING_REC8B	= (1 << 2),
  	ATA_TIMING_CYC8B	= (1 << 3),
  	ATA_TIMING_8BIT		= ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
  				  ATA_TIMING_CYC8B,
  	ATA_TIMING_ACTIVE	= (1 << 4),
  	ATA_TIMING_RECOVER	= (1 << 5),
3ada9c126   David Daney   libata: Add anoth...
433
434
435
  	ATA_TIMING_DMACK_HOLD	= (1 << 6),
  	ATA_TIMING_CYCLE	= (1 << 7),
  	ATA_TIMING_UDMA		= (1 << 8),
624d5c514   Tejun Heo   libata: reorganiz...
436
437
438
  	ATA_TIMING_ALL		= ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
  				  ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
  				  ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
3ada9c126   David Daney   libata: Add anoth...
439
440
  				  ATA_TIMING_DMACK_HOLD | ATA_TIMING_CYCLE |
  				  ATA_TIMING_UDMA,
f1bce7f80   Tejun Heo   libata: cosmetic ...
441
442
443
444
445
  
  	/* ACPI constants */
  	ATA_ACPI_FILTER_SETXFER	= 1 << 0,
  	ATA_ACPI_FILTER_LOCK	= 1 << 1,
  	ATA_ACPI_FILTER_DIPM	= 1 << 2,
fa5b561c4   Tejun Heo   libata: implement...
446
447
  	ATA_ACPI_FILTER_FPDMA_OFFSET = 1 << 3,	/* FPDMA non-zero offset */
  	ATA_ACPI_FILTER_FPDMA_AA = 1 << 4,	/* FPDMA auto activate */
f1bce7f80   Tejun Heo   libata: cosmetic ...
448
449
450
451
  
  	ATA_ACPI_FILTER_DEFAULT	= ATA_ACPI_FILTER_SETXFER |
  				  ATA_ACPI_FILTER_LOCK |
  				  ATA_ACPI_FILTER_DIPM,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
452
  };
7dc951aef   Tejun Heo   libata: xfer_mask...
453
454
455
456
457
458
459
460
  enum ata_xfer_mask {
  	ATA_MASK_PIO		= ((1LU << ATA_NR_PIO_MODES) - 1)
  					<< ATA_SHIFT_PIO,
  	ATA_MASK_MWDMA		= ((1LU << ATA_NR_MWDMA_MODES) - 1)
  					<< ATA_SHIFT_MWDMA,
  	ATA_MASK_UDMA		= ((1LU << ATA_NR_UDMA_MODES) - 1)
  					<< ATA_SHIFT_UDMA,
  };
14be71f4c   Albert Lee   [PATCH] libata: r...
461
  enum hsm_task_states {
c56b14d2a   Albert Lee   [PATCH] libata ir...
462
  	HSM_ST_IDLE,		/* no command on going */
715276470   Albert Lee   libata: reorder H...
463
464
  	HSM_ST_FIRST,		/* (waiting the device to)
  				   write CDB or first data block */
c56b14d2a   Albert Lee   [PATCH] libata ir...
465
466
  	HSM_ST,			/* (waiting the device to) transfer data */
  	HSM_ST_LAST,		/* (waiting the device to) complete command */
c56b14d2a   Albert Lee   [PATCH] libata ir...
467
  	HSM_ST_ERR,		/* error */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
468
  };
a7dac447b   Jeff Garzik   [libata] change a...
469
  enum ata_completion_errors {
25937580a   Jiri Slaby   ata: define AC_ER...
470
  	AC_ERR_OK		= 0,	    /* no error */
11a56d243   Tejun Heo   [PATCH] libata: a...
471
472
473
474
475
476
477
478
479
  	AC_ERR_DEV		= (1 << 0), /* device reported error */
  	AC_ERR_HSM		= (1 << 1), /* host state machine violation */
  	AC_ERR_TIMEOUT		= (1 << 2), /* timeout */
  	AC_ERR_MEDIA		= (1 << 3), /* media error */
  	AC_ERR_ATA_BUS		= (1 << 4), /* ATA bus error */
  	AC_ERR_HOST_BUS		= (1 << 5), /* host bus error */
  	AC_ERR_SYSTEM		= (1 << 6), /* system error */
  	AC_ERR_INVALID		= (1 << 7), /* invalid argument */
  	AC_ERR_OTHER		= (1 << 8), /* unknown */
55a8e2c83   Tejun Heo   [PATCH] libata: i...
480
  	AC_ERR_NODEV_HINT	= (1 << 9), /* polling device detection hint */
5335b7290   Tejun Heo   libata: implement...
481
  	AC_ERR_NCQ		= (1 << 10), /* marker for offending NCQ qc */
a7dac447b   Jeff Garzik   [libata] change a...
482
  };
c93b263e0   Tejun Heo   libata: clean up ...
483
484
485
486
487
488
489
490
  /*
   * Link power management policy: If you alter this, you also need to
   * alter libata-scsi.c (for the ascii descriptions)
   */
  enum ata_lpm_policy {
  	ATA_LPM_UNKNOWN,
  	ATA_LPM_MAX_POWER,
  	ATA_LPM_MED_POWER,
f4ac64769   Hans de Goede   libata: Add new m...
491
  	ATA_LPM_MED_POWER_WITH_DIPM, /* Med power + DIPM as win IRST does */
a5ec5a7bf   Srinivas Pandruvada   ata: ahci: Suppor...
492
493
  	ATA_LPM_MIN_POWER_WITH_PARTIAL, /* Min Power + partial and slumber */
  	ATA_LPM_MIN_POWER, /* Min power + no partial (slumber only) */
c93b263e0   Tejun Heo   libata: clean up ...
494
  };
6b7ae9545   Tejun Heo   libata: reimpleme...
495
496
497
  enum ata_lpm_hints {
  	ATA_LPM_EMPTY		= (1 << 0), /* port empty/probing */
  	ATA_LPM_HIPM		= (1 << 1), /* may use HIPM */
fb3296335   Danesh Petigara   drivers: ata: wak...
498
  	ATA_LPM_WAKE_ONLY	= (1 << 2), /* only wake up link */
6b7ae9545   Tejun Heo   libata: reimpleme...
499
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
500
501
502
503
  /* forward declarations */
  struct scsi_device;
  struct ata_port_operations;
  struct ata_port;
cc0680a58   Tejun Heo   libata-link: link...
504
  struct ata_link;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
505
506
507
  struct ata_queued_cmd;
  
  /* typedefs */
77853bf2b   Tejun Heo   [PATCH] libata: m...
508
  typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
cc0680a58   Tejun Heo   libata-link: link...
509
510
  typedef int (*ata_prereset_fn_t)(struct ata_link *link, unsigned long deadline);
  typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
d4b2bab4f   Tejun Heo   libata: add deadl...
511
  			      unsigned long deadline);
cc0680a58   Tejun Heo   libata-link: link...
512
  typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
513

45fabbb77   Elias Oltmanns   libata: Implement...
514
  extern struct device_attribute dev_attr_unload_heads;
ec811a94c   Bartlomiej Zolnierkiewicz   ata: start separa...
515
516
  #ifdef CONFIG_SATA_HOST
  extern struct device_attribute dev_attr_link_power_management_policy;
84f95243b   Adam Manzanares   ata: ATA Command ...
517
  extern struct device_attribute dev_attr_ncq_prio_enable;
18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
518
519
520
  extern struct device_attribute dev_attr_em_message_type;
  extern struct device_attribute dev_attr_em_message;
  extern struct device_attribute dev_attr_sw_activity;
ec811a94c   Bartlomiej Zolnierkiewicz   ata: start separa...
521
  #endif
18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
522
523
524
525
526
527
  
  enum sw_activity {
  	OFF,
  	BLINK_ON,
  	BLINK_OFF,
  };
ca77329fb   Kristen Carlson Accardi   [libata] Link pow...
528

dc34e7e1a   Sergei Shtylyov   libata: move 'str...
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
  struct ata_taskfile {
  	unsigned long		flags;		/* ATA_TFLAG_xxx */
  	u8			protocol;	/* ATA_PROT_xxx */
  
  	u8			ctl;		/* control reg */
  
  	u8			hob_feature;	/* additional data */
  	u8			hob_nsect;	/* to support LBA48 */
  	u8			hob_lbal;
  	u8			hob_lbam;
  	u8			hob_lbah;
  
  	u8			feature;
  	u8			nsect;
  	u8			lbal;
  	u8			lbam;
  	u8			lbah;
  
  	u8			device;
  
  	u8			command;	/* IO operation */
8be5ad9ac   Marc Carino   libata: Populate ...
550
551
552
553
  
  	u32			auxiliary;	/* auxiliary field */
  						/* from SATA 3.1 and */
  						/* ATA-8 ACS-3 */
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
554
  };
127102aea   Tejun Heo   libata: make SFF ...
555
  #ifdef CONFIG_ATA_SFF
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
556
  struct ata_ioports {
0d5ff5667   Tejun Heo   libata: convert t...
557
558
559
560
561
562
563
564
565
566
567
568
569
  	void __iomem		*cmd_addr;
  	void __iomem		*data_addr;
  	void __iomem		*error_addr;
  	void __iomem		*feature_addr;
  	void __iomem		*nsect_addr;
  	void __iomem		*lbal_addr;
  	void __iomem		*lbam_addr;
  	void __iomem		*lbah_addr;
  	void __iomem		*device_addr;
  	void __iomem		*status_addr;
  	void __iomem		*command_addr;
  	void __iomem		*altstatus_addr;
  	void __iomem		*ctl_addr;
9a7780c9a   Tejun Heo   libata-sff: make ...
570
  #ifdef CONFIG_ATA_BMDMA
0d5ff5667   Tejun Heo   libata: convert t...
571
  	void __iomem		*bmdma_addr;
9a7780c9a   Tejun Heo   libata-sff: make ...
572
  #endif /* CONFIG_ATA_BMDMA */
0d5ff5667   Tejun Heo   libata: convert t...
573
  	void __iomem		*scr_addr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
574
  };
127102aea   Tejun Heo   libata: make SFF ...
575
  #endif /* CONFIG_ATA_SFF */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
576

cca3974e4   Jeff Garzik   libata: Grand ren...
577
  struct ata_host {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
578
579
  	spinlock_t		lock;
  	struct device 		*dev;
0d5ff5667   Tejun Heo   libata: convert t...
580
  	void __iomem * const	*iomap;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
581
  	unsigned int		n_ports;
1a112d10f   Tejun Heo   libata: introduce...
582
  	unsigned int		n_tags;			/* nr of NCQ tags */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
583
  	void			*private_data;
029cfd6b7   Tejun Heo   libata: implement...
584
  	struct ata_port_operations *ops;
5444a6f40   Alan Cox   [PATCH] libata: S...
585
  	unsigned long		flags;
2623c7a5f   Taras Kondratiuk   libata: add refco...
586
  	struct kref		kref;
c0c362b60   Tejun Heo   libata: implement...
587
588
589
  
  	struct mutex		eh_mutex;
  	struct task_struct	*eh_owner;
032af1ce1   Alan Cox   libata-core: Fix ...
590
  	struct ata_port		*simplex_claimed;	/* channel owning the DMA */
9c5fbf05c   Gustavo A. R. Silva   libata: Replace z...
591
  	struct ata_port		*ports[];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
592
593
594
595
596
597
598
599
600
601
602
603
604
  };
  
  struct ata_queued_cmd {
  	struct ata_port		*ap;
  	struct ata_device	*dev;
  
  	struct scsi_cmnd	*scsicmd;
  	void			(*scsidone)(struct scsi_cmnd *);
  
  	struct ata_taskfile	tf;
  	u8			cdb[ATAPI_CDB_LEN];
  
  	unsigned long		flags;		/* ATA_QCFLAG_xxx */
5ac40790b   Jens Axboe   libata: introduce...
605
606
  	unsigned int		tag;		/* libata core tag */
  	unsigned int		hw_tag;		/* driver tag */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
607
  	unsigned int		n_elem;
5825627c9   FUJITA Tomonori   libata: fix dma_u...
608
  	unsigned int		orig_n_elem;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
609
610
  
  	int			dma_dir;
5a5dbd18a   Mark Lord   libata: add suppo...
611
  	unsigned int		sect_size;
cedc9a478   Jeff Garzik   libata: fix ATAPI...
612

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
613
  	unsigned int		nbytes;
aacda3753   Tejun Heo   libata: implement...
614
  	unsigned int		extrabytes;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
615
  	unsigned int		curbytes;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
616
  	struct scatterlist	sgent;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
617

ff2aeb1eb   Tejun Heo   libata: convert t...
618
  	struct scatterlist	*sg;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
619

b34e90429   Richard Kennedy   libata: reorder a...
620
621
  	struct scatterlist	*cursg;
  	unsigned int		cursg_ofs;
a22e2eb07   Albert Lee   [PATCH] libata: m...
622
  	unsigned int		err_mask;
e61e06722   Tejun Heo   [PATCH] libata: i...
623
  	struct ata_taskfile	result_tf;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
624
  	ata_qc_cb_t		complete_fn;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
625
  	void			*private_data;
1c50dc83f   Darrick J. Wong   [SCSI] sas_ata: a...
626
  	void			*lldd_task;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
627
  };
cca3974e4   Jeff Garzik   libata: Grand ren...
628
  struct ata_port_stats {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
629
630
631
632
  	unsigned long		unhandled_irq;
  	unsigned long		idle_irq;
  	unsigned long		rw_reqbuf;
  };
0c247c559   Tejun Heo   [PATCH] libata-eh...
633
  struct ata_ering_entry {
3884f7b0a   Tejun Heo   libata: clean up ...
634
  	unsigned int		eflags;
0c247c559   Tejun Heo   [PATCH] libata-eh...
635
636
637
638
639
640
641
642
  	unsigned int		err_mask;
  	u64			timestamp;
  };
  
  struct ata_ering {
  	int			cursor;
  	struct ata_ering_entry	ring[ATA_ERING_SIZE];
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
643
  struct ata_device {
9af5c9c97   Tejun Heo   libata-link: intr...
644
  	struct ata_link		*link;
72fa4b742   Tejun Heo   [PATCH] libata-hp...
645
  	unsigned int		devno;		/* 0 or 1 */
75683fe71   Tejun Heo   libata: clean up ...
646
  	unsigned int		horkage;	/* List of broken features */
6866e7bc8   Richard Kennedy   libata: reorder a...
647
  	unsigned long		flags;		/* ATA_DFLAG_xxx */
3edebac41   Tejun Heo   [PATCH] libata-hp...
648
  	struct scsi_device	*sdev;		/* attached SCSI device */
95514fd8f   Bartlomiej Zolnierkiewicz   libata: add priva...
649
  	void			*private_data;
fafbae87d   Tejun Heo   libata-acpi: impl...
650
  #ifdef CONFIG_ATA_ACPI
398e07826   Tejun Heo   libata-acpi: impl...
651
  	union acpi_object	*gtf_cache;
110f66d25   Tejun Heo   libata: make gtf_...
652
  	unsigned int		gtf_filter;
fafbae87d   Tejun Heo   libata-acpi: impl...
653
  #endif
afe759511   Aaron Lu   libata: identify ...
654
655
656
  #ifdef CONFIG_SATA_ZPODD
  	void			*zpodd;
  #endif
d9027470b   Gwendal Grignou   [libata] Add ATA ...
657
  	struct device		tdev;
99cf610aa   Tejun Heo   libata: clear dev...
658
  	/* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
72fa4b742   Tejun Heo   [PATCH] libata-hp...
659
  	u64			n_sectors;	/* size of device, if ATA */
5920dadfb   Tejun Heo   libata: accept la...
660
  	u64			n_native_sectors; /* native size, if ATA */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
661
  	unsigned int		class;		/* ATA_DEV_xxx */
45fabbb77   Elias Oltmanns   libata: Implement...
662
  	unsigned long		unpark_deadline;
e0a717526   Tejun Heo   libata-pmp-prep: ...
663

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
664
665
666
667
  	u8			pio_mode;
  	u8			dma_mode;
  	u8			xfer_mode;
  	unsigned int		xfer_shift;	/* ATA_SHIFT_xxx */
8cbd6df1f   Albert Lee   [PATCH] libata CH...
668
669
  	unsigned int		multi_count;	/* sectors count for
  						   READ/WRITE MULTIPLE */
b00eec1d5   Tejun Heo   [PATCH] libata: a...
670
  	unsigned int		max_sectors;	/* per-device max sectors */
6e7846e9c   Tejun Heo   [PATCH] libata: m...
671
  	unsigned int		cdb_len;
8bf62ecee   Albert Lee   [libata] C/H/S su...
672

acf356b12   Tejun Heo   [PATCH] libata: a...
673
  	/* per-dev xfer mask */
7dc951aef   Tejun Heo   libata: xfer_mask...
674
675
676
  	unsigned long		pio_mask;
  	unsigned long		mwdma_mask;
  	unsigned long		udma_mask;
acf356b12   Tejun Heo   [PATCH] libata: a...
677

8bf62ecee   Albert Lee   [libata] C/H/S su...
678
679
680
681
  	/* for CHS addressing */
  	u16			cylinders;	/* Number of cylinders */
  	u16			heads;		/* Number of heads */
  	u16			sectors;	/* Number of sectors per track */
0c247c559   Tejun Heo   [PATCH] libata-eh...
682

f7e989301   Jeff Garzik   [libata] linux/li...
683
684
685
  	union {
  		u16		id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
  		u32		gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
4ee34ea3a   Harvey Hunt   libata: Align ata...
686
  	} ____cacheline_aligned;
99cf610aa   Tejun Heo   libata: clear dev...
687

803739d25   Shane Huang   [libata] replace ...
688
689
  	/* DEVSLP Timing Variables from Identify Device Data Log */
  	u8			devslp_timing[ATA_LOG_DEVSLP_SIZE];
65fe1f0f6   Shane Huang   ahci: implement a...
690

ed36911c7   Marc Carino   libata: Add suppo...
691
692
  	/* NCQ send and receive log subcommand support */
  	u8			ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE];
284b3b77e   Hannes Reinecke   libata: NCQ encap...
693
  	u8			ncq_non_data_cmds[ATA_LOG_NCQ_NON_DATA_SIZE];
ed36911c7   Marc Carino   libata: Add suppo...
694

6d1003ae8   Hannes Reinecke   libata: support h...
695
696
697
698
699
  	/* ZAC zone configuration */
  	u32			zac_zoned_cap;
  	u32			zac_zones_optimal_open;
  	u32			zac_zones_optimal_nonseq;
  	u32			zac_zones_max_open;
99cf610aa   Tejun Heo   libata: clear dev...
700
701
702
703
  	/* error history */
  	int			spdn_cnt;
  	/* ering is CLEAR_END, read comment above CLEAR_END */
  	struct ata_ering	ering;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
704
  };
99cf610aa   Tejun Heo   libata: clear dev...
705
706
  /* Fields between ATA_DEVICE_CLEAR_BEGIN and ATA_DEVICE_CLEAR_END are
   * cleared to zero on ata_dev_init().
72fa4b742   Tejun Heo   [PATCH] libata-hp...
707
   */
99cf610aa   Tejun Heo   libata: clear dev...
708
709
  #define ATA_DEVICE_CLEAR_BEGIN		offsetof(struct ata_device, n_sectors)
  #define ATA_DEVICE_CLEAR_END		offsetof(struct ata_device, ering)
72fa4b742   Tejun Heo   [PATCH] libata-hp...
710

f3e81b19a   Tejun Heo   [PATCH] libata-eh...
711
712
713
714
715
  struct ata_eh_info {
  	struct ata_device	*dev;		/* offending device */
  	u32			serror;		/* SError from LLDD */
  	unsigned int		err_mask;	/* port-wide err_mask */
  	unsigned int		action;		/* ATA_EH_* action mask */
47005f255   Tejun Heo   [PATCH] libata: i...
716
  	unsigned int		dev_action[ATA_MAX_DEVICES]; /* dev EH action */
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
717
  	unsigned int		flags;		/* ATA_EHI_* flags */
abdda7331   Tejun Heo   [PATCH] libata-hp...
718

abdda7331   Tejun Heo   [PATCH] libata-hp...
719
  	unsigned int		probe_mask;
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
720
721
722
723
724
725
726
  	char			desc[ATA_EH_DESC_LEN];
  	int			desc_len;
  };
  
  struct ata_eh_context {
  	struct ata_eh_info	i;
  	int			tries[ATA_MAX_DEVICES];
87fbc5a06   Tejun Heo   libata: improve E...
727
728
  	int			cmd_timeout_idx[ATA_MAX_DEVICES]
  					       [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
abdda7331   Tejun Heo   [PATCH] libata-hp...
729
730
  	unsigned int		classes[ATA_MAX_DEVICES];
  	unsigned int		did_probe_mask;
45fabbb77   Elias Oltmanns   libata: Implement...
731
  	unsigned int		unloaded_mask;
00115e0f5   Tejun Heo   libata: implement...
732
733
  	unsigned int		saved_ncq_enabled;
  	u8			saved_xfer_mode[ATA_MAX_DEVICES];
0a2c0f561   Tejun Heo   libata: improve E...
734
735
  	/* timestamp for the last reset attempt or success */
  	unsigned long		last_reset;
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
736
  };
64578a3de   Tejun Heo   libata-acpi: impl...
737
738
739
740
741
742
743
744
745
746
  struct ata_acpi_drive
  {
  	u32 pio;
  	u32 dma;
  } __packed;
  
  struct ata_acpi_gtm {
  	struct ata_acpi_drive drive[2];
  	u32 flags;
  } __packed;
9af5c9c97   Tejun Heo   libata-link: intr...
747
748
  struct ata_link {
  	struct ata_port		*ap;
8989805d6   Tejun Heo   libata-link: add ...
749
  	int			pmp;		/* port multiplier port # */
9af5c9c97   Tejun Heo   libata-link: intr...
750

d9027470b   Gwendal Grignou   [libata] Add ATA ...
751
  	struct device		tdev;
9af5c9c97   Tejun Heo   libata-link: intr...
752
753
  	unsigned int		active_tag;	/* active tag on this link */
  	u32			sactive;	/* active NCQ commands */
0c88758b5   Tejun Heo   libata-link: make...
754
  	unsigned int		flags;		/* ATA_LFLAG_xxx */
d127ea7b8   Tejun Heo   libata: restore S...
755
  	u32			saved_scontrol;	/* SControl on probe */
9af5c9c97   Tejun Heo   libata-link: intr...
756
757
758
  	unsigned int		hw_sata_spd_limit;
  	unsigned int		sata_spd_limit;
  	unsigned int		sata_spd;	/* current SATA PHY speed */
6b7ae9545   Tejun Heo   libata: reimpleme...
759
  	enum ata_lpm_policy	lpm_policy;
9af5c9c97   Tejun Heo   libata-link: intr...
760
761
762
763
764
765
766
  
  	/* record runtime error info, protected by host_set lock */
  	struct ata_eh_info	eh_info;
  	/* EH context */
  	struct ata_eh_context	eh_context;
  
  	struct ata_device	device[ATA_MAX_DEVICES];
09c5b4803   Gabriele Mazzotta   libata: Ignore sp...
767
768
  
  	unsigned long		last_lpm_change; /* when last LPM change happened */
9af5c9c97   Tejun Heo   libata-link: intr...
769
  };
d9027470b   Gwendal Grignou   [libata] Add ATA ...
770
771
  #define ATA_LINK_CLEAR_BEGIN		offsetof(struct ata_link, active_tag)
  #define ATA_LINK_CLEAR_END		offsetof(struct ata_link, device[0])
9af5c9c97   Tejun Heo   libata-link: intr...
772

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
773
  struct ata_port {
cca3974e4   Jeff Garzik   libata: Grand ren...
774
  	struct Scsi_Host	*scsi_host; /* our co-allocated scsi host */
029cfd6b7   Tejun Heo   libata: implement...
775
  	struct ata_port_operations *ops;
ba6a13083   Jeff Garzik   [libata] Add host...
776
  	spinlock_t		*lock;
e3cf95dd6   Alan Cox   ata: Report 16/32...
777
778
  	/* Flags owned by the EH context. Only EH should touch these once the
  	   port is active */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
779
  	unsigned long		flags;	/* ATA_FLAG_xxx */
e3cf95dd6   Alan Cox   ata: Report 16/32...
780
  	/* Flags that change dynamically, protected by ap->lock */
b51e9e5db   Tejun Heo   [PATCH] libata: a...
781
  	unsigned int		pflags; /* ATA_PFLAG_xxx */
44877b4e2   Tejun Heo   libata: s/ap->id/...
782
  	unsigned int		print_id; /* user visible unique port ID */
e628dc999   David Milburn   libata: export at...
783
  	unsigned int            local_port_no; /* host local port num */
44877b4e2   Tejun Heo   libata: s/ap->id/...
784
  	unsigned int		port_no; /* 0 based port no. inside the host */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
785

127102aea   Tejun Heo   libata: make SFF ...
786
  #ifdef CONFIG_ATA_SFF
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
787
  	struct ata_ioports	ioaddr;	/* ATA cmd/ctl/dma register blocks */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
788
789
  	u8			ctl;	/* cache of ATA control register */
  	u8			last_ctl;	/* Cache last written value */
ea3c64506   Gwendal Grignou   libata-sff: Reena...
790
  	struct ata_link*	sff_pio_task_link; /* link currently used */
c429137a6   Tejun Heo   libata-sff: port_...
791
  	struct delayed_work	sff_pio_task;
9a7780c9a   Tejun Heo   libata-sff: make ...
792
  #ifdef CONFIG_ATA_BMDMA
f60d70113   Tejun Heo   libata-sff: prd i...
793
794
  	struct ata_bmdma_prd	*bmdma_prd;	/* BMDMA SG list */
  	dma_addr_t		bmdma_prd_dma;	/* and its DMA mapping */
9a7780c9a   Tejun Heo   libata-sff: make ...
795
  #endif /* CONFIG_ATA_BMDMA */
5fe7454aa   Tejun Heo   libata-sff: ap->[...
796
  #endif /* CONFIG_ATA_SFF */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
797
798
799
800
  	unsigned int		pio_mask;
  	unsigned int		mwdma_mask;
  	unsigned int		udma_mask;
  	unsigned int		cbl;	/* cable type; ATA_CBL_xxx */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
801

28361c403   Jens Axboe   libata: add extra...
802
  	struct ata_queued_cmd	qcmd[ATA_MAX_QUEUE + 1];
12cb5ce10   Shaohua Li   libata: use blk t...
803
  	unsigned long		sas_tag_allocated; /* for sas tag allocation only */
e3ed89396   Jens Axboe   libata: bump ->qc...
804
  	u64			qc_active;
da917d69d   Tejun Heo   libata-pmp-prep: ...
805
  	int			nr_active_links; /* #links with active qcs */
12cb5ce10   Shaohua Li   libata: use blk t...
806
  	unsigned int		sas_last_tag;	/* track next tag hw expects */
dedaf2b03   Tejun Heo   [PATCH] libata-nc...
807

b1c72916a   Tejun Heo   libata: implement...
808
809
  	struct ata_link		link;		/* host default link */
  	struct ata_link		*slave_link;	/* see ata_slave_link_init() */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
810

8989805d6   Tejun Heo   libata-link: add ...
811
812
  	int			nr_pmp_links;	/* nr of available PMP links */
  	struct ata_link		*pmp_link;	/* array of PMP links */
da917d69d   Tejun Heo   libata-pmp-prep: ...
813
  	struct ata_link		*excl_link;	/* for PMP qc exclusion */
8989805d6   Tejun Heo   libata-link: add ...
814

cca3974e4   Jeff Garzik   libata: Grand ren...
815
816
  	struct ata_port_stats	stats;
  	struct ata_host		*host;
2f1f610b6   Brian King   [PATCH] libata: R...
817
  	struct device 		*dev;
d9027470b   Gwendal Grignou   [libata] Add ATA ...
818
  	struct device		tdev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
819

ad72cf988   Tejun Heo   libata: take adva...
820
  	struct mutex		scsi_scan_mutex;
52bad64d9   David Howells   WorkStruct: Separ...
821
  	struct delayed_work	hotplug_task;
3b01b8af2   Jeff Garzik   libata: fix build...
822
  	struct work_struct	scsi_rescan_task;
86e45b6bd   Tejun Heo   [PATCH] libata: i...
823

14be71f4c   Albert Lee   [PATCH] libata: r...
824
  	unsigned int		hsm_task_state;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
825

bfd605795   Randy Dunlap   From: Borislav Pe...
826
  	u32			msg_enable;
a72ec4ce6   Tejun Heo   [PATCH] libata: i...
827
  	struct list_head	eh_done_q;
c6cf9e99d   Tejun Heo   [PATCH] libata: i...
828
  	wait_queue_head_t	eh_wait_q;
a1e10f7e6   Tejun Heo   libata: move EH r...
829
  	int			eh_tries;
45fabbb77   Elias Oltmanns   libata: Implement...
830
  	struct completion	park_req_pending;
bfd605795   Randy Dunlap   From: Borislav Pe...
831

500530f65   Tejun Heo   [PATCH] libata: r...
832
  	pm_message_t		pm_mesg;
6b7ae9545   Tejun Heo   libata: reimpleme...
833
  	enum ata_lpm_policy	target_lpm_policy;
500530f65   Tejun Heo   [PATCH] libata: r...
834

5ddf24c5e   Tejun Heo   libata: implement...
835
836
  	struct timer_list	fastdrain_timer;
  	unsigned long		fastdrain_cnt;
b5292111d   Kai-Heng Feng   libata: Use per p...
837
  	async_cookie_t		cookie;
18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
838
  	int			em_message_type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
839
  	void			*private_data;
fe635c7e9   Tejun Heo   [PATCH] libata: u...
840

fafbae87d   Tejun Heo   libata-acpi: impl...
841
  #ifdef CONFIG_ATA_ACPI
c05e6ff03   Tejun Heo   libata-acpi: impl...
842
  	struct ata_acpi_gtm	__acpi_init_gtm; /* use ata_acpi_init_gtm() */
fafbae87d   Tejun Heo   libata-acpi: impl...
843
  #endif
84bda12af   Tejun Heo   libata: align ap-...
844
845
  	/* owned by EH */
  	u8			sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
846
  };
029cfd6b7   Tejun Heo   libata: implement...
847
848
849
850
851
852
  /* The following initializer overrides a method to NULL whether one of
   * its parent has the method defined or not.  This is equivalent to
   * ERR_PTR(-ENOENT).  Unfortunately, ERR_PTR doesn't render a constant
   * expression and thus can't be used as an initializer.
   */
  #define ATA_OP_NULL		(void *)(unsigned long)(-ENOENT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
853
  struct ata_port_operations {
c1bc899f5   Tejun Heo   libata: reorganiz...
854
855
856
  	/*
  	 * Command execution
  	 */
95364f367   Jiri Slaby   ata: make qc_prep...
857
858
859
  	int (*qc_defer)(struct ata_queued_cmd *qc);
  	int (*check_atapi_dma)(struct ata_queued_cmd *qc);
  	enum ata_completion_errors (*qc_prep)(struct ata_queued_cmd *qc);
c1bc899f5   Tejun Heo   libata: reorganiz...
860
  	unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
22183bf56   Tejun Heo   libata: add qc_fi...
861
  	bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
862

c1bc899f5   Tejun Heo   libata: reorganiz...
863
864
865
866
867
868
869
870
  	/*
  	 * Configuration and exception handling
  	 */
  	int  (*cable_detect)(struct ata_port *ap);
  	unsigned long (*mode_filter)(struct ata_device *dev, unsigned long xfer_mask);
  	void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
  	void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
  	int  (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
963e4975c   Alan Cox   pata_it821x: Driv...
871
  	unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
872

c1bc899f5   Tejun Heo   libata: reorganiz...
873
  	void (*dev_config)(struct ata_device *dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
874

c1bc899f5   Tejun Heo   libata: reorganiz...
875
876
  	void (*freeze)(struct ata_port *ap);
  	void (*thaw)(struct ata_port *ap);
a1efdaba2   Tejun Heo   libata: make rese...
877
878
879
880
881
882
883
884
  	ata_prereset_fn_t	prereset;
  	ata_reset_fn_t		softreset;
  	ata_reset_fn_t		hardreset;
  	ata_postreset_fn_t	postreset;
  	ata_prereset_fn_t	pmp_prereset;
  	ata_reset_fn_t		pmp_softreset;
  	ata_reset_fn_t		pmp_hardreset;
  	ata_postreset_fn_t	pmp_postreset;
c1bc899f5   Tejun Heo   libata: reorganiz...
885
  	void (*error_handler)(struct ata_port *ap);
c96f1732e   Alan Cox   [libata] Improve ...
886
  	void (*lost_interrupt)(struct ata_port *ap);
c1bc899f5   Tejun Heo   libata: reorganiz...
887
  	void (*post_internal_cmd)(struct ata_queued_cmd *qc);
e4a9c3732   Dan Williams   [SCSI] libata, li...
888
889
  	void (*sched_eh)(struct ata_port *ap);
  	void (*end_eh)(struct ata_port *ap);
c1bc899f5   Tejun Heo   libata: reorganiz...
890
891
892
893
  
  	/*
  	 * Optional features
  	 */
82ef04fb4   Tejun Heo   libata: make SCR ...
894
895
  	int  (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
  	int  (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
c1bc899f5   Tejun Heo   libata: reorganiz...
896
897
  	void (*pmp_attach)(struct ata_port *ap);
  	void (*pmp_detach)(struct ata_port *ap);
6b7ae9545   Tejun Heo   libata: reimpleme...
898
899
  	int  (*set_lpm)(struct ata_link *link, enum ata_lpm_policy policy,
  			unsigned hints);
c1bc899f5   Tejun Heo   libata: reorganiz...
900
901
902
903
904
905
906
907
908
  
  	/*
  	 * Start, stop, suspend and resume
  	 */
  	int  (*port_suspend)(struct ata_port *ap, pm_message_t mesg);
  	int  (*port_resume)(struct ata_port *ap);
  	int  (*port_start)(struct ata_port *ap);
  	void (*port_stop)(struct ata_port *ap);
  	void (*host_stop)(struct ata_host *host);
127102aea   Tejun Heo   libata: make SFF ...
909
  #ifdef CONFIG_ATA_SFF
c1bc899f5   Tejun Heo   libata: reorganiz...
910
911
912
  	/*
  	 * SFF / taskfile oriented ops
  	 */
5682ed33a   Tejun Heo   libata: rename SF...
913
  	void (*sff_dev_select)(struct ata_port *ap, unsigned int device);
41dec29bc   Sergei Shtylyov   libata: introduce...
914
  	void (*sff_set_devctl)(struct ata_port *ap, u8 ctl);
5682ed33a   Tejun Heo   libata: rename SF...
915
916
917
918
919
920
  	u8   (*sff_check_status)(struct ata_port *ap);
  	u8   (*sff_check_altstatus)(struct ata_port *ap);
  	void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf);
  	void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf);
  	void (*sff_exec_command)(struct ata_port *ap,
  				 const struct ata_taskfile *tf);
989e0aac1   Bartlomiej Zolnierkiewicz   ata: pass queued ...
921
  	unsigned int (*sff_data_xfer)(struct ata_queued_cmd *qc,
5682ed33a   Tejun Heo   libata: rename SF...
922
  			unsigned char *buf, unsigned int buflen, int rw);
e42a542ba   Sergei Shtylyov   libata: make sff_...
923
  	void (*sff_irq_on)(struct ata_port *);
27943620c   Tejun Heo   libata: implement...
924
  	bool (*sff_irq_check)(struct ata_port *);
5682ed33a   Tejun Heo   libata: rename SF...
925
  	void (*sff_irq_clear)(struct ata_port *);
8244cd059   Tejun Heo   libata-sff: renam...
926
  	void (*sff_drain_fifo)(struct ata_queued_cmd *qc);
5682ed33a   Tejun Heo   libata: rename SF...
927

9a7780c9a   Tejun Heo   libata-sff: make ...
928
  #ifdef CONFIG_ATA_BMDMA
c1bc899f5   Tejun Heo   libata: reorganiz...
929
930
931
932
  	void (*bmdma_setup)(struct ata_queued_cmd *qc);
  	void (*bmdma_start)(struct ata_queued_cmd *qc);
  	void (*bmdma_stop)(struct ata_queued_cmd *qc);
  	u8   (*bmdma_status)(struct ata_port *ap);
9a7780c9a   Tejun Heo   libata-sff: make ...
933
  #endif /* CONFIG_ATA_BMDMA */
127102aea   Tejun Heo   libata: make SFF ...
934
  #endif /* CONFIG_ATA_SFF */
c1bc899f5   Tejun Heo   libata: reorganiz...
935

18f7ba4c2   Kristen Carlson Accardi   libata/ahci: encl...
936
937
938
939
940
941
  	ssize_t (*em_show)(struct ata_port *ap, char *buf);
  	ssize_t (*em_store)(struct ata_port *ap, const char *message,
  			    size_t size);
  	ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
  	ssize_t (*sw_activity_store)(struct ata_device *dev,
  				     enum sw_activity val);
439d7a358   Mark Langsdorf   ahci: make ahci_t...
942
943
  	ssize_t (*transmit_led_message)(struct ata_port *ap, u32 state,
  					ssize_t size);
c1bc899f5   Tejun Heo   libata: reorganiz...
944
945
  	/*
  	 * Obsolete
9ec957f20   Tejun Heo   [PATCH] libata-eh...
946
  	 */
c1bc899f5   Tejun Heo   libata: reorganiz...
947
948
  	void (*phy_reset)(struct ata_port *ap);
  	void (*eng_timeout)(struct ata_port *ap);
029cfd6b7   Tejun Heo   libata: implement...
949
950
951
952
953
954
  
  	/*
  	 * ->inherits must be the last field and all the preceding
  	 * fields must be pointers.
  	 */
  	const struct ata_port_operations	*inherits;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
955
956
957
  };
  
  struct ata_port_info {
cca3974e4   Jeff Garzik   libata: Grand ren...
958
  	unsigned long		flags;
0c88758b5   Tejun Heo   libata-link: make...
959
  	unsigned long		link_flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
960
961
962
  	unsigned long		pio_mask;
  	unsigned long		mwdma_mask;
  	unsigned long		udma_mask;
029cfd6b7   Tejun Heo   libata: implement...
963
  	struct ata_port_operations *port_ops;
e99f8b5ef   Alan Cox   [PATCH] libata: p...
964
  	void 			*private_data;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
965
  };
452503f99   Alan Cox   Add ide-timing fu...
966
967
968
969
970
971
972
973
  struct ata_timing {
  	unsigned short mode;		/* ATA mode */
  	unsigned short setup;		/* t1 */
  	unsigned short act8b;		/* t2 for 8-bit I/O */
  	unsigned short rec8b;		/* t2i for 8-bit I/O */
  	unsigned short cyc8b;		/* t0 for 8-bit I/O */
  	unsigned short active;		/* t2 or tD */
  	unsigned short recover;		/* t2i or tK */
3ada9c126   David Daney   libata: Add anoth...
974
  	unsigned short dmack_hold;	/* tj */
452503f99   Alan Cox   Add ide-timing fu...
975
976
977
  	unsigned short cycle;		/* t0 */
  	unsigned short udma;		/* t2CYCTYP/2 */
  };
624d5c514   Tejun Heo   libata: reorganiz...
978
979
980
  /*
   * Core layer - drivers/ata/libata-core.c
   */
029cfd6b7   Tejun Heo   libata: implement...
981
  extern struct ata_port_operations ata_dummy_port_ops;
21b0ad4fb   Tejun Heo   libata: add init ...
982
  extern const struct ata_port_info ata_dummy_port_info;
dd5b06c49   Tejun Heo   [PATCH] libata: i...
983

b1c04e80c   Christoph Hellwig   libata: return bo...
984
  static inline bool ata_is_atapi(u8 prot)
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
985
  {
37f92d77d   Christoph Hellwig   ata: define ATA_P...
986
  	return prot & ATA_PROT_FLAG_ATAPI;
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
987
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
988
  static inline bool ata_is_pio(u8 prot)
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
989
  {
37f92d77d   Christoph Hellwig   ata: define ATA_P...
990
  	return prot & ATA_PROT_FLAG_PIO;
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
991
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
992
  static inline bool ata_is_dma(u8 prot)
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
993
  {
37f92d77d   Christoph Hellwig   ata: define ATA_P...
994
  	return prot & ATA_PROT_FLAG_DMA;
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
995
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
996
  static inline bool ata_is_ncq(u8 prot)
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
997
  {
37f92d77d   Christoph Hellwig   ata: define ATA_P...
998
  	return prot & ATA_PROT_FLAG_NCQ;
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
999
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
1000
  static inline bool ata_is_data(u8 prot)
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
1001
  {
37f92d77d   Christoph Hellwig   ata: define ATA_P...
1002
  	return prot & (ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA);
dc34e7e1a   Sergei Shtylyov   libata: move 'str...
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
  }
  
  static inline int is_multi_taskfile(struct ata_taskfile *tf)
  {
  	return (tf->command == ATA_CMD_READ_MULTI) ||
  	       (tf->command == ATA_CMD_WRITE_MULTI) ||
  	       (tf->command == ATA_CMD_READ_MULTI_EXT) ||
  	       (tf->command == ATA_CMD_WRITE_MULTI_EXT) ||
  	       (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
  }
dd5b06c49   Tejun Heo   [PATCH] libata: i...
1013
1014
1015
1016
  static inline int ata_port_is_dummy(struct ata_port *ap)
  {
  	return ap->ops == &ata_dummy_port_ops;
  }
0aa1113d5   Tejun Heo   libata: separate ...
1017
  extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
aa2731ad9   Tejun Heo   libata: separate ...
1018
1019
  extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
  				int (*check_ready)(struct ata_link *link));
57c9efdfb   Tejun Heo   libata: implement...
1020
1021
  extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
  			      unsigned long deadline);
203c75b82   Tejun Heo   libata: separate ...
1022
  extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
2855568b1   Jeff Garzik   [libata] struct p...
1023

f31871951   Tejun Heo   libata: separate ...
1024
  extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
f5cda2572   Tejun Heo   libata: implement...
1025
1026
  extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
  			const struct ata_port_info * const * ppi, int n_ports);
2fa4a3261   Jason Yan   scsi: libsas: dyn...
1027
1028
  extern void ata_host_get(struct ata_host *host);
  extern void ata_host_put(struct ata_host *host);
ecef72532   Tejun Heo   libata: separate ...
1029
  extern int ata_host_start(struct ata_host *host);
f31871951   Tejun Heo   libata: separate ...
1030
1031
  extern int ata_host_register(struct ata_host *host,
  			     struct scsi_host_template *sht);
f5cda2572   Tejun Heo   libata: implement...
1032
1033
1034
  extern int ata_host_activate(struct ata_host *host, int irq,
  			     irq_handler_t irq_handler, unsigned long irq_flags,
  			     struct scsi_host_template *sht);
0529c159d   Tejun Heo   libata: implement...
1035
  extern void ata_host_detach(struct ata_host *host);
8d8e7d131   Dan Williams   [SCSI] libsas, ip...
1036
  extern void ata_host_init(struct ata_host *, struct device *, struct ata_port_operations *);
193515d51   Jeff Garzik   [libata] eliminat...
1037
  extern int ata_scsi_detect(struct scsi_host_template *sht);
6f4e626fb   Nathan Chancellor   scsi: ata: Use un...
1038
1039
  extern int ata_scsi_ioctl(struct scsi_device *dev, unsigned int cmd,
  			  void __user *arg);
75c0b0e11   Arnd Bergmann   compat_ioctl: scs...
1040
1041
1042
1043
1044
  #ifdef CONFIG_COMPAT
  #define ATA_SCSI_COMPAT_IOCTL .compat_ioctl = ata_scsi_ioctl,
  #else
  #define ATA_SCSI_COMPAT_IOCTL /* empty */
  #endif
f281233d3   Jeff Garzik   SCSI host lock pu...
1045
  extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd);
aad4b4d15   Christoph Hellwig   scsi: libata: Fix...
1046
  #if IS_REACHABLE(CONFIG_ATA)
cc97923a5   Christoph Hellwig   block: move dma d...
1047
  bool ata_scsi_dma_need_drain(struct request *rq);
7bb7ee870   Christoph Hellwig   scsi: libata: Pro...
1048
1049
1050
  #else
  #define ata_scsi_dma_need_drain NULL
  #endif
94be9a58d   Jeff Garzik   [libata] get-iden...
1051
  extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
6f4e626fb   Nathan Chancellor   scsi: ata: Use un...
1052
  			    unsigned int cmd, void __user *arg);
b5b3fa386   Tejun Heo   libata: misc upda...
1053
1054
  extern bool ata_link_online(struct ata_link *link);
  extern bool ata_link_offline(struct ata_link *link);
6ffa01d88   Tejun Heo   libata: add CONFI...
1055
  #ifdef CONFIG_PM
cca3974e4   Jeff Garzik   libata: Grand ren...
1056
1057
  extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
  extern void ata_host_resume(struct ata_host *host);
bc6e7c4b0   Dan Williams   libata, libsas: k...
1058
1059
  extern void ata_sas_port_suspend(struct ata_port *ap);
  extern void ata_sas_port_resume(struct ata_port *ap);
2fcbdcb4c   Dan Williams   [SCSI] libata: ex...
1060
  #else
bc6e7c4b0   Dan Williams   libata, libsas: k...
1061
  static inline void ata_sas_port_suspend(struct ata_port *ap)
2fcbdcb4c   Dan Williams   [SCSI] libata: ex...
1062
  {
2fcbdcb4c   Dan Williams   [SCSI] libata: ex...
1063
  }
a5a656995   Randy Dunlap   libata.h: add stu...
1064
1065
1066
  static inline void ata_sas_port_resume(struct ata_port *ap)
  {
  }
6ffa01d88   Tejun Heo   libata: add CONFI...
1067
  #endif
67846b301   Jeff Garzik   libata: add ata_r...
1068
  extern int ata_ratelimit(void);
97750cebb   Tejun Heo   libata: add @ap t...
1069
1070
1071
  extern void ata_msleep(struct ata_port *ap, unsigned int msecs);
  extern u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask,
  			u32 val, unsigned long interval, unsigned long timeout);
436d34b36   Tejun Heo   libata: uninline ...
1072
  extern int atapi_cmd_type(u8 opcode);
7dc951aef   Tejun Heo   libata: xfer_mask...
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
  extern unsigned long ata_pack_xfermask(unsigned long pio_mask,
  			unsigned long mwdma_mask, unsigned long udma_mask);
  extern void ata_unpack_xfermask(unsigned long xfer_mask,
  			unsigned long *pio_mask, unsigned long *mwdma_mask,
  			unsigned long *udma_mask);
  extern u8 ata_xfer_mask2mode(unsigned long xfer_mask);
  extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
  extern int ata_xfer_mode2shift(unsigned long xfer_mode);
  extern const char *ata_mode_string(unsigned long xfer_mask);
  extern unsigned long ata_id_xfermask(const u16 *id);
31cc23b34   Tejun Heo   libata-pmp-prep: ...
1083
  extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
95364f367   Jiri Slaby   ata: make qc_prep...
1084
  extern enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1085
1086
  extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
  		 unsigned int n_elem);
057ace5e7   Jeff Garzik   libata: const-ifi...
1087
  extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
10305f0f8   Alan Cox   Add id_to_dma_mod...
1088
  extern void ata_dev_disable(struct ata_device *adev);
6a62a04d4   Tejun Heo   [PATCH] libata: r...
1089
1090
1091
1092
  extern void ata_id_string(const u16 *id, unsigned char *s,
  			  unsigned int ofs, unsigned int len);
  extern void ata_id_c_string(const u16 *id, unsigned char *s,
  			    unsigned int ofs, unsigned int len);
963e4975c   Alan Cox   pata_it821x: Driv...
1093
1094
  extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
  					struct ata_taskfile *tf, u16 *id);
f686bcb80   Tejun Heo   [PATCH] libata-eh...
1095
  extern void ata_qc_complete(struct ata_queued_cmd *qc);
8385d756e   Sascha Hauer   libata: Fix retri...
1096
  extern u64 ata_qc_get_active(struct ata_port *ap);
b27dcfb06   Jeff Garzik   [libata] avoid ne...
1097
  extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1098
1099
1100
  extern int ata_std_bios_param(struct scsi_device *sdev,
  			      struct block_device *bdev,
  			      sector_t capacity, int geom[]);
d8d9129ea   Tejun Heo   libata: implement...
1101
  extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1102
  extern int ata_scsi_slave_config(struct scsi_device *sdev);
83c47bcb3   Tejun Heo   [PATCH] libata-hp...
1103
  extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
a6e6ce8e8   Tejun Heo   [PATCH] libata-nc...
1104
  extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
db5ed4dfd   Christoph Hellwig   scsi: drop reason...
1105
  				       int queue_depth);
f6e67035a   Dan Williams   [SCSI] libsas,lib...
1106
  extern int __ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev,
db5ed4dfd   Christoph Hellwig   scsi: drop reason...
1107
  				    int queue_depth);
3373efd89   Tejun Heo   [PATCH] libata: u...
1108
  extern struct ata_device *ata_dev_pair(struct ata_device *adev);
0260731f0   Tejun Heo   libata-link: link...
1109
  extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
0e0b494ca   James Bottomley   libata: separate ...
1110
1111
  extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
  extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q);
7fe183c77   Bartlomiej Zolnierkiewicz   ata: start separa...
1112
1113
1114
1115
  
  /*
   * SATA specific code - drivers/ata/libata-sata.c
   */
6eab1bc0e   Bartlomiej Zolnierkiewicz   ata: move sata_sc...
1116
  #ifdef CONFIG_SATA_HOST
2b384ede7   Bartlomiej Zolnierkiewicz   ata: move sata_de...
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
  extern const unsigned long sata_deb_timing_normal[];
  extern const unsigned long sata_deb_timing_hotplug[];
  extern const unsigned long sata_deb_timing_long[];
  
  static inline const unsigned long *
  sata_ehc_deb_timing(struct ata_eh_context *ehc)
  {
  	if (ehc->i.flags & ATA_EHI_HOTPLUGGED)
  		return sata_deb_timing_hotplug;
  	else
  		return sata_deb_timing_normal;
  }
6eab1bc0e   Bartlomiej Zolnierkiewicz   ata: move sata_sc...
1129
1130
1131
1132
  extern int sata_scr_valid(struct ata_link *link);
  extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
  extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
  extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
ab4117cf2   Bartlomiej Zolnierkiewicz   ata: move *sata_s...
1133
  extern int sata_set_spd(struct ata_link *link);
78c97c80d   Bartlomiej Zolnierkiewicz   ata: move sata_li...
1134
1135
1136
  extern int sata_link_hardreset(struct ata_link *link,
  			const unsigned long *timing, unsigned long deadline,
  			bool *online, int (*check_ready)(struct ata_link *));
9d3158f5c   Bartlomiej Zolnierkiewicz   ata: move sata_li...
1137
1138
  extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
  			    unsigned long deadline);
a0ccd2511   Bartlomiej Zolnierkiewicz   ata: move ata_eh_...
1139
  extern void ata_eh_analyze_ncq_error(struct ata_link *link);
6eab1bc0e   Bartlomiej Zolnierkiewicz   ata: move sata_sc...
1140
  #else
2b384ede7   Bartlomiej Zolnierkiewicz   ata: move sata_de...
1141
1142
1143
1144
1145
  static inline const unsigned long *
  sata_ehc_deb_timing(struct ata_eh_context *ehc)
  {
  	return NULL;
  }
6eab1bc0e   Bartlomiej Zolnierkiewicz   ata: move sata_sc...
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
  static inline int sata_scr_valid(struct ata_link *link) { return 0; }
  static inline int sata_scr_read(struct ata_link *link, int reg, u32 *val)
  {
  	return -EOPNOTSUPP;
  }
  static inline int sata_scr_write(struct ata_link *link, int reg, u32 val)
  {
  	return -EOPNOTSUPP;
  }
  static inline int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
  {
  	return -EOPNOTSUPP;
  }
ab4117cf2   Bartlomiej Zolnierkiewicz   ata: move *sata_s...
1159
  static inline int sata_set_spd(struct ata_link *link) { return -EOPNOTSUPP; }
78c97c80d   Bartlomiej Zolnierkiewicz   ata: move sata_li...
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
  static inline int sata_link_hardreset(struct ata_link *link,
  				      const unsigned long *timing,
  				      unsigned long deadline,
  				      bool *online,
  				      int (*check_ready)(struct ata_link *))
  {
  	if (online)
  		*online = false;
  	return -EOPNOTSUPP;
  }
9d3158f5c   Bartlomiej Zolnierkiewicz   ata: move sata_li...
1170
1171
1172
1173
1174
1175
  static inline int sata_link_resume(struct ata_link *link,
  				   const unsigned long *params,
  				   unsigned long deadline)
  {
  	return -EOPNOTSUPP;
  }
a0ccd2511   Bartlomiej Zolnierkiewicz   ata: move ata_eh_...
1176
  static inline void ata_eh_analyze_ncq_error(struct ata_link *link) { }
6eab1bc0e   Bartlomiej Zolnierkiewicz   ata: move sata_sc...
1177
  #endif
9d3158f5c   Bartlomiej Zolnierkiewicz   ata: move sata_li...
1178
1179
  extern int sata_link_debounce(struct ata_link *link,
  			const unsigned long *params, unsigned long deadline);
7fe183c77   Bartlomiej Zolnierkiewicz   ata: start separa...
1180
1181
1182
  extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
  			     bool spm_wakeup);
  extern int ata_slave_link_init(struct ata_port *ap);
15964ff72   Bartlomiej Zolnierkiewicz   ata: move ata_sas...
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
  extern void ata_sas_port_destroy(struct ata_port *);
  extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
  					   struct ata_port_info *, struct Scsi_Host *);
  extern void ata_sas_async_probe(struct ata_port *ap);
  extern int ata_sas_sync_probe(struct ata_port *ap);
  extern int ata_sas_port_init(struct ata_port *);
  extern int ata_sas_port_start(struct ata_port *ap);
  extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap);
  extern void ata_sas_tport_delete(struct ata_port *ap);
  extern void ata_sas_port_stop(struct ata_port *ap);
  extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
  extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);
7fe183c77   Bartlomiej Zolnierkiewicz   ata: start separa...
1195
1196
1197
  extern void ata_tf_to_fis(const struct ata_taskfile *tf,
  			  u8 pmp, int is_cmd, u8 *fis);
  extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
61a11986d   Bartlomiej Zolnierkiewicz   ata: move ata_qc_...
1198
  extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);
8393b811f   Gabriele Mazzotta   libata: Add helpe...
1199
  extern bool sata_lpm_ignore_phy_events(struct ata_link *link);
a695de27f   Bartlomiej Zolnierkiewicz   ata: start separa...
1200
  extern int sata_async_notification(struct ata_port *ap);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1201

be0d18dff   Alan Cox   libata: cable det...
1202
1203
1204
  extern int ata_cable_40wire(struct ata_port *ap);
  extern int ata_cable_80wire(struct ata_port *ap);
  extern int ata_cable_sata(struct ata_port *ap);
c88f90c37   Tejun Heo   libata: add ATA_C...
1205
  extern int ata_cable_ignore(struct ata_port *ap);
be0d18dff   Alan Cox   libata: cable det...
1206
  extern int ata_cable_unknown(struct ata_port *ap);
624d5c514   Tejun Heo   libata: reorganiz...
1207
  /* Timing helpers */
1bc4ccfff   Alan Cox   [PATCH] libata: a...
1208
  extern unsigned int ata_pio_need_iordy(const struct ata_device *);
a0f79b929   Tejun Heo   libata: implement...
1209
  extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
452503f99   Alan Cox   Add ide-timing fu...
1210

624d5c514   Tejun Heo   libata: reorganiz...
1211
1212
1213
1214
1215
1216
1217
1218
1219
  /* PCI */
  #ifdef CONFIG_PCI
  struct pci_dev;
  
  struct pci_bits {
  	unsigned int		reg;	/* PCI config register to read */
  	unsigned int		width;	/* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
  	unsigned long		mask;
  	unsigned long		val;
452503f99   Alan Cox   Add ide-timing fu...
1220
  };
624d5c514   Tejun Heo   libata: reorganiz...
1221
  extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
10a663a1b   Prabhakar Kushwaha   ata: ahci: Add sh...
1222
  extern void ata_pci_shutdown_one(struct pci_dev *pdev);
624d5c514   Tejun Heo   libata: reorganiz...
1223
1224
1225
1226
1227
1228
1229
1230
1231
  extern void ata_pci_remove_one(struct pci_dev *pdev);
  
  #ifdef CONFIG_PM
  extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
  extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
  extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
  extern int ata_pci_device_resume(struct pci_dev *pdev);
  #endif /* CONFIG_PM */
  #endif /* CONFIG_PCI */
b7db04d92   Brian Norris   libata: implement...
1232
1233
1234
  struct platform_device;
  
  extern int ata_platform_remove_one(struct platform_device *pdev);
624d5c514   Tejun Heo   libata: reorganiz...
1235
1236
1237
  /*
   * ACPI - drivers/ata/libata-acpi.c
   */
e1ddb4b6a   Alan Cox   [libata] add ACPI...
1238
  #ifdef CONFIG_ATA_ACPI
c05e6ff03   Tejun Heo   libata-acpi: impl...
1239
1240
1241
1242
1243
1244
  static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
  {
  	if (ap->pflags & ATA_PFLAG_INIT_GTM_VALID)
  		return &ap->__acpi_init_gtm;
  	return NULL;
  }
0d02f0b22   Tejun Heo   libata-acpi: adju...
1245
1246
  int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
  int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
7c77fa4d5   Tejun Heo   libata: separate ...
1247
1248
  unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
  				    const struct ata_acpi_gtm *gtm);
021ee9a6d   Tejun Heo   libata: reimpleme...
1249
  int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
e1ddb4b6a   Alan Cox   [libata] add ACPI...
1250
  #else
c05e6ff03   Tejun Heo   libata-acpi: impl...
1251
1252
1253
1254
  static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
  {
  	return NULL;
  }
7c77fa4d5   Tejun Heo   libata: separate ...
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
  
  static inline int ata_acpi_stm(const struct ata_port *ap,
  			       struct ata_acpi_gtm *stm)
  {
  	return -ENOSYS;
  }
  
  static inline int ata_acpi_gtm(const struct ata_port *ap,
  			       struct ata_acpi_gtm *stm)
  {
  	return -ENOSYS;
  }
  
  static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
  					const struct ata_acpi_gtm *gtm)
  {
  	return 0;
  }
021ee9a6d   Tejun Heo   libata: reimpleme...
1273
1274
1275
1276
1277
1278
  
  static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
  				      const struct ata_acpi_gtm *gtm)
  {
  	return 0;
  }
e1ddb4b6a   Alan Cox   [libata] add ACPI...
1279
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1280

ece1d6361   Tejun Heo   [PATCH] libata: s...
1281
  /*
624d5c514   Tejun Heo   libata: reorganiz...
1282
   * EH - drivers/ata/libata-eh.c
ece1d6361   Tejun Heo   [PATCH] libata: s...
1283
   */
7b70fc039   Tejun Heo   [PATCH] libata-eh...
1284
  extern void ata_port_schedule_eh(struct ata_port *ap);
81c757bc6   Dan Williams   [SCSI] libsas: ex...
1285
  extern void ata_port_wait_eh(struct ata_port *ap);
dbd826168   Tejun Heo   libata-link: impl...
1286
  extern int ata_link_abort(struct ata_link *link);
7b70fc039   Tejun Heo   [PATCH] libata-eh...
1287
  extern int ata_port_abort(struct ata_port *ap);
e31804994   Tejun Heo   [PATCH] libata-eh...
1288
1289
1290
1291
  extern int ata_port_freeze(struct ata_port *ap);
  
  extern void ata_eh_freeze_port(struct ata_port *ap);
  extern void ata_eh_thaw_port(struct ata_port *ap);
7b70fc039   Tejun Heo   [PATCH] libata-eh...
1292

ece1d6361   Tejun Heo   [PATCH] libata: s...
1293
1294
  extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
  extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
f5914a461   Tejun Heo   [PATCH] libata-hp...
1295
1296
1297
  extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
  		      ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
  		      ata_postreset_fn_t postreset);
a1efdaba2   Tejun Heo   libata: make rese...
1298
  extern void ata_std_error_handler(struct ata_port *ap);
e4a9c3732   Dan Williams   [SCSI] libata, li...
1299
1300
  extern void ata_std_sched_eh(struct ata_port *ap);
  extern void ata_std_end_eh(struct ata_port *ap);
8a745f1f3   Kristen Carlson Accardi   libata: Power off...
1301
  extern int ata_link_nr_enabled(struct ata_link *link);
022bdb075   Tejun Heo   [PATCH] libata-eh...
1302

61440db61   Tejun Heo   [PATCH] libata: i...
1303
  /*
68d1d07b5   Tejun Heo   libata: implement...
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
   * Base operations to inherit from and initializers for sht
   *
   * Operations
   *
   * base  : Common to all libata drivers.
   * sata  : SATA controllers w/ native interface.
   * pmp   : SATA controllers w/ PMP support.
   * sff   : SFF ATA controllers w/o BMDMA support.
   * bmdma : SFF ATA controllers w/ BMDMA support.
   *
   * sht initializers
   *
   * BASE  : Common to all libata drivers.  The user must set
   *	   sg_tablesize and dma_boundary.
   * PIO   : SFF ATA controllers w/ only PIO support.
   * BMDMA : SFF ATA controllers w/ BMDMA support.  sg_tablesize and
   *	   dma_boundary are set to BMDMA limits.
   * NCQ   : SATA controllers supporting NCQ.  The user must set
   *	   sg_tablesize, dma_boundary and can_queue.
   */
  extern const struct ata_port_operations ata_base_port_ops;
  extern const struct ata_port_operations sata_port_ops;
45fabbb77   Elias Oltmanns   libata: Implement...
1326
  extern struct device_attribute *ata_common_sdev_attrs[];
68d1d07b5   Tejun Heo   libata: implement...
1327

018d5ef20   Akinobu Mita   ata: ahci_platfor...
1328
1329
1330
1331
1332
1333
  /*
   * All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated
   * by the edge drivers.  Because the 'module' field of sht must be the
   * edge driver's module reference, otherwise the driver can be unloaded
   * even if the scsi_device is being accessed.
   */
6f09eae3b   Bartlomiej Zolnierkiewicz   ata: expose ncq_e...
1334
  #define __ATA_BASE_SHT(drv_name)				\
68d1d07b5   Tejun Heo   libata: implement...
1335
1336
1337
  	.module			= THIS_MODULE,			\
  	.name			= drv_name,			\
  	.ioctl			= ata_scsi_ioctl,		\
75c0b0e11   Arnd Bergmann   compat_ioctl: scs...
1338
  	ATA_SCSI_COMPAT_IOCTL					\
68d1d07b5   Tejun Heo   libata: implement...
1339
  	.queuecommand		= ata_scsi_queuecmd,		\
cc97923a5   Christoph Hellwig   block: move dma d...
1340
  	.dma_need_drain		= ata_scsi_dma_need_drain,	\
68d1d07b5   Tejun Heo   libata: implement...
1341
  	.can_queue		= ATA_DEF_QUEUE,		\
12cb5ce10   Shaohua Li   libata: use blk t...
1342
  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
68d1d07b5   Tejun Heo   libata: implement...
1343
  	.this_id		= ATA_SHT_THIS_ID,		\
68d1d07b5   Tejun Heo   libata: implement...
1344
  	.emulated		= ATA_SHT_EMULATED,		\
68d1d07b5   Tejun Heo   libata: implement...
1345
1346
1347
  	.proc_name		= drv_name,			\
  	.slave_configure	= ata_scsi_slave_config,	\
  	.slave_destroy		= ata_scsi_slave_destroy,	\
45fabbb77   Elias Oltmanns   libata: Implement...
1348
  	.bios_param		= ata_std_bios_param,		\
6f09eae3b   Bartlomiej Zolnierkiewicz   ata: expose ncq_e...
1349
1350
1351
1352
  	.unlock_native_capacity	= ata_scsi_unlock_native_capacity
  
  #define ATA_BASE_SHT(drv_name)					\
  	__ATA_BASE_SHT(drv_name),				\
45fabbb77   Elias Oltmanns   libata: Implement...
1353
  	.sdev_attrs		= ata_common_sdev_attrs
68d1d07b5   Tejun Heo   libata: implement...
1354

ec811a94c   Bartlomiej Zolnierkiewicz   ata: start separa...
1355
1356
  #ifdef CONFIG_SATA_HOST
  extern struct device_attribute *ata_ncq_sdev_attrs[];
68d1d07b5   Tejun Heo   libata: implement...
1357
  #define ATA_NCQ_SHT(drv_name)					\
6f09eae3b   Bartlomiej Zolnierkiewicz   ata: expose ncq_e...
1358
1359
  	__ATA_BASE_SHT(drv_name),				\
  	.sdev_attrs		= ata_ncq_sdev_attrs,		\
68d1d07b5   Tejun Heo   libata: implement...
1360
  	.change_queue_depth	= ata_scsi_change_queue_depth
ec811a94c   Bartlomiej Zolnierkiewicz   ata: start separa...
1361
  #endif
68d1d07b5   Tejun Heo   libata: implement...
1362
1363
  
  /*
071f44b1d   Tejun Heo   libata: implement...
1364
1365
   * PMP helpers
   */
88fcd5627   Tejun Heo   libata: make PMP ...
1366
  #ifdef CONFIG_SATA_PMP
071f44b1d   Tejun Heo   libata: implement...
1367
1368
1369
1370
1371
1372
1373
1374
1375
  static inline bool sata_pmp_supported(struct ata_port *ap)
  {
  	return ap->flags & ATA_FLAG_PMP;
  }
  
  static inline bool sata_pmp_attached(struct ata_port *ap)
  {
  	return ap->nr_pmp_links != 0;
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
1376
  static inline bool ata_is_host_link(const struct ata_link *link)
071f44b1d   Tejun Heo   libata: implement...
1377
  {
b1c72916a   Tejun Heo   libata: implement...
1378
  	return link == &link->ap->link || link == link->ap->slave_link;
071f44b1d   Tejun Heo   libata: implement...
1379
  }
88fcd5627   Tejun Heo   libata: make PMP ...
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
  #else /* CONFIG_SATA_PMP */
  static inline bool sata_pmp_supported(struct ata_port *ap)
  {
  	return false;
  }
  
  static inline bool sata_pmp_attached(struct ata_port *ap)
  {
  	return false;
  }
b1c04e80c   Christoph Hellwig   libata: return bo...
1390
  static inline bool ata_is_host_link(const struct ata_link *link)
88fcd5627   Tejun Heo   libata: make PMP ...
1391
1392
1393
1394
  {
  	return 1;
  }
  #endif /* CONFIG_SATA_PMP */
071f44b1d   Tejun Heo   libata: implement...
1395
1396
1397
1398
1399
1400
1401
1402
1403
  
  static inline int sata_srst_pmp(struct ata_link *link)
  {
  	if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
  		return SATA_PMP_CTRL_PORT;
  	return link->pmp;
  }
  
  /*
61440db61   Tejun Heo   [PATCH] libata: i...
1404
1405
   * printk helpers
   */
b9075fa96   Joe Perches   treewide: use __p...
1406
  __printf(3, 4)
d7bead1b8   Joe Perches   libata: change at...
1407
1408
  void ata_port_printk(const struct ata_port *ap, const char *level,
  		     const char *fmt, ...);
b9075fa96   Joe Perches   treewide: use __p...
1409
  __printf(3, 4)
d7bead1b8   Joe Perches   libata: change at...
1410
1411
  void ata_link_printk(const struct ata_link *link, const char *level,
  		     const char *fmt, ...);
b9075fa96   Joe Perches   treewide: use __p...
1412
  __printf(3, 4)
d7bead1b8   Joe Perches   libata: change at...
1413
1414
  void ata_dev_printk(const struct ata_device *dev, const char *level,
  		    const char *fmt, ...);
a9a79dfec   Joe Perches   ata: Convert ata_...
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
  
  #define ata_port_err(ap, fmt, ...)				\
  	ata_port_printk(ap, KERN_ERR, fmt, ##__VA_ARGS__)
  #define ata_port_warn(ap, fmt, ...)				\
  	ata_port_printk(ap, KERN_WARNING, fmt, ##__VA_ARGS__)
  #define ata_port_notice(ap, fmt, ...)				\
  	ata_port_printk(ap, KERN_NOTICE, fmt, ##__VA_ARGS__)
  #define ata_port_info(ap, fmt, ...)				\
  	ata_port_printk(ap, KERN_INFO, fmt, ##__VA_ARGS__)
  #define ata_port_dbg(ap, fmt, ...)				\
  	ata_port_printk(ap, KERN_DEBUG, fmt, ##__VA_ARGS__)
  
  #define ata_link_err(link, fmt, ...)				\
  	ata_link_printk(link, KERN_ERR, fmt, ##__VA_ARGS__)
  #define ata_link_warn(link, fmt, ...)				\
  	ata_link_printk(link, KERN_WARNING, fmt, ##__VA_ARGS__)
  #define ata_link_notice(link, fmt, ...)				\
  	ata_link_printk(link, KERN_NOTICE, fmt, ##__VA_ARGS__)
  #define ata_link_info(link, fmt, ...)				\
  	ata_link_printk(link, KERN_INFO, fmt, ##__VA_ARGS__)
  #define ata_link_dbg(link, fmt, ...)				\
  	ata_link_printk(link, KERN_DEBUG, fmt, ##__VA_ARGS__)
  
  #define ata_dev_err(dev, fmt, ...)				\
  	ata_dev_printk(dev, KERN_ERR, fmt, ##__VA_ARGS__)
  #define ata_dev_warn(dev, fmt, ...)				\
  	ata_dev_printk(dev, KERN_WARNING, fmt, ##__VA_ARGS__)
  #define ata_dev_notice(dev, fmt, ...)				\
  	ata_dev_printk(dev, KERN_NOTICE, fmt, ##__VA_ARGS__)
  #define ata_dev_info(dev, fmt, ...)				\
  	ata_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
  #define ata_dev_dbg(dev, fmt, ...)				\
  	ata_dev_printk(dev, KERN_DEBUG, fmt, ##__VA_ARGS__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1448

06296a1e6   Joe Perches   ata: Add and use ...
1449
  void ata_print_version(const struct device *dev, const char *version);
61440db61   Tejun Heo   [PATCH] libata: i...
1450
  /*
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
1451
1452
   * ata_eh_info helpers
   */
b9075fa96   Joe Perches   treewide: use __p...
1453
1454
1455
1456
  extern __printf(2, 3)
  void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
  extern __printf(2, 3)
  void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
b64bbc39f   Tejun Heo   libata: improve E...
1457
  extern void ata_ehi_clear_desc(struct ata_eh_info *ehi);
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
1458

c0b6c0377   Tejun Heo   [PATCH] libata: s...
1459
1460
  static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
  {
b558edddb   Tejun Heo   libata: kill ata_...
1461
  	ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
f8f1e1cc0   Tejun Heo   libata: reorganiz...
1462
  	ehi->flags |= ATA_EHI_HOTPLUGGED;
b558edddb   Tejun Heo   libata: kill ata_...
1463
  	ehi->action |= ATA_EH_RESET | ATA_EH_ENABLE_LINK;
c0b6c0377   Tejun Heo   [PATCH] libata: s...
1464
1465
  	ehi->err_mask |= AC_ERR_ATA_BUS;
  }
f3e81b19a   Tejun Heo   [PATCH] libata-eh...
1466
  /*
cbcdd8759   Tejun Heo   libata: implement...
1467
1468
   * port description helpers
   */
b9075fa96   Joe Perches   treewide: use __p...
1469
1470
  extern __printf(2, 3)
  void ata_port_desc(struct ata_port *ap, const char *fmt, ...);
cbcdd8759   Tejun Heo   libata: implement...
1471
1472
1473
1474
  #ifdef CONFIG_PCI
  extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
  			       const char *name);
  #endif
28361c403   Jens Axboe   libata: add extra...
1475
  static inline bool ata_tag_internal(unsigned int tag)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1476
  {
28361c403   Jens Axboe   libata: add extra...
1477
  	return tag == ATA_TAG_INTERNAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1478
  }
28361c403   Jens Axboe   libata: add extra...
1479
  static inline bool ata_tag_valid(unsigned int tag)
2ab7db1ff   Tejun Heo   [PATCH] libata-eh...
1480
  {
28361c403   Jens Axboe   libata: add extra...
1481
  	return tag < ATA_MAX_QUEUE || ata_tag_internal(tag);
2ab7db1ff   Tejun Heo   [PATCH] libata-eh...
1482
  }
6362f0a29   Jens Axboe   libata: add comma...
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
  #define __ata_qc_for_each(ap, qc, tag, max_tag, fn)		\
  	for ((tag) = 0; (tag) < (max_tag) &&			\
  	     ({ qc = fn((ap), (tag)); 1; }); (tag)++)		\
  
  /*
   * Internal use only, iterate commands ignoring error handling and
   * status of 'qc'.
   */
  #define ata_qc_for_each_raw(ap, qc, tag)					\
  	__ata_qc_for_each(ap, qc, tag, ATA_MAX_QUEUE, __ata_qc_from_tag)
  
  /*
   * Iterate all potential commands that can be queued
   */
  #define ata_qc_for_each(ap, qc, tag)					\
  	__ata_qc_for_each(ap, qc, tag, ATA_MAX_QUEUE, ata_qc_from_tag)
  
  /*
   * Like ata_qc_for_each, but with the internal tag included
   */
  #define ata_qc_for_each_with_internal(ap, qc, tag)			\
  	__ata_qc_for_each(ap, qc, tag, ATA_MAX_QUEUE + 1, ata_qc_from_tag)
5806db22c   Tejun Heo   [PATCH] libata: i...
1505
1506
1507
  /*
   * device helpers
   */
e1211e3fa   Tejun Heo   [PATCH] libata: i...
1508
  static inline unsigned int ata_class_enabled(unsigned int class)
597afd214   Tejun Heo   [PATCH] libata: s...
1509
  {
e0a717526   Tejun Heo   libata-pmp-prep: ...
1510
  	return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI ||
9162c6579   Hannes Reinecke   libata: Implement...
1511
1512
  		class == ATA_DEV_PMP || class == ATA_DEV_SEMB ||
  		class == ATA_DEV_ZAC;
597afd214   Tejun Heo   [PATCH] libata: s...
1513
  }
e1211e3fa   Tejun Heo   [PATCH] libata: i...
1514
  static inline unsigned int ata_class_disabled(unsigned int class)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1515
  {
e0a717526   Tejun Heo   libata-pmp-prep: ...
1516
  	return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP ||
3a92945b2   Hannes Reinecke   libata: fixup ZAC...
1517
1518
  		class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP ||
  		class == ATA_DEV_ZAC_UNSUP;
e1211e3fa   Tejun Heo   [PATCH] libata: i...
1519
  }
002c8054f   Tejun Heo   [PATCH] libata: i...
1520
1521
1522
1523
  static inline unsigned int ata_class_absent(unsigned int class)
  {
  	return !ata_class_enabled(class) && !ata_class_disabled(class);
  }
e1211e3fa   Tejun Heo   [PATCH] libata: i...
1524
1525
1526
1527
1528
1529
1530
1531
  static inline unsigned int ata_dev_enabled(const struct ata_device *dev)
  {
  	return ata_class_enabled(dev->class);
  }
  
  static inline unsigned int ata_dev_disabled(const struct ata_device *dev)
  {
  	return ata_class_disabled(dev->class);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1532
  }
002c8054f   Tejun Heo   [PATCH] libata: i...
1533
1534
1535
1536
  static inline unsigned int ata_dev_absent(const struct ata_device *dev)
  {
  	return ata_class_absent(dev->class);
  }
5806db22c   Tejun Heo   [PATCH] libata: i...
1537
  /*
f58229f80   Tejun Heo   libata-link: impl...
1538
   * link helpers
5806db22c   Tejun Heo   [PATCH] libata: i...
1539
   */
f58229f80   Tejun Heo   libata-link: impl...
1540
  static inline int ata_link_max_devices(const struct ata_link *link)
5806db22c   Tejun Heo   [PATCH] libata: i...
1541
  {
8989805d6   Tejun Heo   libata-link: add ...
1542
  	if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
5806db22c   Tejun Heo   [PATCH] libata: i...
1543
1544
1545
  		return 2;
  	return 1;
  }
da917d69d   Tejun Heo   libata-pmp-prep: ...
1546
1547
1548
1549
  static inline int ata_link_active(struct ata_link *link)
  {
  	return ata_tag_valid(link->active_tag) || link->sactive;
  }
1eca4365b   Tejun Heo   libata: beef up i...
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
  /*
   * Iterators
   *
   * ATA_LITER_* constants are used to select link iteration mode and
   * ATA_DITER_* device iteration mode.
   *
   * For a custom iteration directly using ata_{link|dev}_next(), if
   * @link or @dev, respectively, is NULL, the first element is
   * returned.  @dev and @link can be any valid device or link and the
   * next element according to the iteration mode will be returned.
   * After the last element, NULL is returned.
   */
  enum ata_link_iter_mode {
  	ATA_LITER_EDGE,		/* if present, PMP links only; otherwise,
  				 * host link.  no slave link */
  	ATA_LITER_HOST_FIRST,	/* host link followed by PMP or slave links */
  	ATA_LITER_PMP_FIRST,	/* PMP links followed by host link,
  				 * slave link still comes after host link */
  };
  
  enum ata_dev_iter_mode {
  	ATA_DITER_ENABLED,
  	ATA_DITER_ENABLED_REVERSE,
  	ATA_DITER_ALL,
  	ATA_DITER_ALL_REVERSE,
  };
  
  extern struct ata_link *ata_link_next(struct ata_link *link,
  				      struct ata_port *ap,
  				      enum ata_link_iter_mode mode);
  
  extern struct ata_device *ata_dev_next(struct ata_device *dev,
  				       struct ata_link *link,
  				       enum ata_dev_iter_mode mode);
  
  /*
   * Shortcut notation for iterations
   *
   * ata_for_each_link() iterates over each link of @ap according to
   * @mode.  @link points to the current link in the loop.  @link is
   * NULL after loop termination.  ata_for_each_dev() works the same way
   * except that it iterates over each device of @link.
   *
   * Note that the mode prefixes ATA_{L|D}ITER_ shouldn't need to be
   * specified when using the following shorthand notations.  Only the
   * mode itself (EDGE, HOST_FIRST, ENABLED, etc...) should be
   * specified.  This not only increases brevity but also makes it
   * impossible to use ATA_LITER_* for device iteration or vice-versa.
   */
  #define ata_for_each_link(link, ap, mode) \
  	for ((link) = ata_link_next(NULL, (ap), ATA_LITER_##mode); (link); \
  	     (link) = ata_link_next((link), (ap), ATA_LITER_##mode))
  
  #define ata_for_each_dev(dev, link, mode) \
  	for ((dev) = ata_dev_next(NULL, (link), ATA_DITER_##mode); (dev); \
  	     (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode))
5806db22c   Tejun Heo   [PATCH] libata: i...
1606

6d1245bf2   Tejun Heo   libata: separate ...
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
  /**
   *	ata_ncq_enabled - Test whether NCQ is enabled
   *	@dev: ATA device to test for
   *
   *	LOCKING:
   *	spin_lock_irqsave(host lock)
   *
   *	RETURNS:
   *	1 if NCQ is enabled for @dev, 0 otherwise.
   */
  static inline int ata_ncq_enabled(struct ata_device *dev)
  {
7caa30ea8   Bartlomiej Zolnierkiewicz   ata: add CONFIG_S...
1619
1620
  	if (!IS_ENABLED(CONFIG_SATA_HOST))
  		return 0;
6d1245bf2   Tejun Heo   libata: separate ...
1621
1622
1623
  	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
  			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
  }
0baab86b0   Edward Falk   libata: update in...
1624

87fb6c31b   Marc Carino   libata: Add suppo...
1625
1626
1627
1628
1629
1630
  static inline bool ata_fpdma_dsm_supported(struct ata_device *dev)
  {
  	return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&
  		(dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &
  		 ATA_LOG_NCQ_SEND_RECV_DSM_TRIM);
  }
5c65d8bb3   Hannes Reinecke   libata: Add comma...
1631
1632
1633
1634
1635
1636
  static inline bool ata_fpdma_read_log_supported(struct ata_device *dev)
  {
  	return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&
  		(dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET] &
  		 ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED);
  }
28a3fc229   Hannes Reinecke   libata: implement...
1637
1638
1639
1640
1641
1642
  static inline bool ata_fpdma_zac_mgmt_in_supported(struct ata_device *dev)
  {
  	return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&
  		(dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_ZAC_MGMT_OFFSET] &
  		ATA_LOG_NCQ_SEND_RECV_ZAC_MGMT_IN_SUPPORTED);
  }
284b3b77e   Hannes Reinecke   libata: NCQ encap...
1643
1644
1645
1646
1647
  static inline bool ata_fpdma_zac_mgmt_out_supported(struct ata_device *dev)
  {
  	return (dev->ncq_non_data_cmds[ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OFFSET] &
  		ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OUT);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1648
1649
1650
1651
  static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
  {
  	qc->tf.ctl |= ATA_NIEN;
  }
f69499f42   Tejun Heo   [PATCH] libata-eh...
1652
1653
  static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
  						       unsigned int tag)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1654
  {
28361c403   Jens Axboe   libata: add extra...
1655
  	if (ata_tag_valid(tag))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1656
1657
1658
  		return &ap->qcmd[tag];
  	return NULL;
  }
f69499f42   Tejun Heo   [PATCH] libata-eh...
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
  static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap,
  						     unsigned int tag)
  {
  	struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
  
  	if (unlikely(!qc) || !ap->ops->error_handler)
  		return qc;
  
  	if ((qc->flags & (ATA_QCFLAG_ACTIVE |
  			  ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE)
  		return qc;
  
  	return NULL;
  }
aacda3753   Tejun Heo   libata: implement...
1673
1674
1675
1676
  static inline unsigned int ata_qc_raw_nbytes(struct ata_queued_cmd *qc)
  {
  	return qc->nbytes - min(qc->extrabytes, qc->nbytes);
  }
3373efd89   Tejun Heo   [PATCH] libata: u...
1677
  static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1678
1679
  {
  	memset(tf, 0, sizeof(*tf));
5fe7454aa   Tejun Heo   libata-sff: ap->[...
1680
  #ifdef CONFIG_ATA_SFF
9af5c9c97   Tejun Heo   libata-link: intr...
1681
  	tf->ctl = dev->link->ap->ctl;
5fe7454aa   Tejun Heo   libata-sff: ap->[...
1682
1683
1684
  #else
  	tf->ctl = ATA_DEVCTL_OBS;
  #endif
3373efd89   Tejun Heo   [PATCH] libata: u...
1685
  	if (dev->devno == 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1686
1687
1688
1689
  		tf->device = ATA_DEVICE_OBS;
  	else
  		tf->device = ATA_DEVICE_OBS | ATA_DEV1;
  }
2c13b7cee   Jeff Garzik   [libata] minor fi...
1690
1691
  static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
  {
501e0c500   Tejun Heo   libata: initializ...
1692
  	qc->dma_dir = DMA_NONE;
ff2aeb1eb   Tejun Heo   libata: convert t...
1693
  	qc->sg = NULL;
2c13b7cee   Jeff Garzik   [libata] minor fi...
1694
  	qc->flags = 0;
872602162   Jens Axboe   libata: convert t...
1695
1696
  	qc->cursg = NULL;
  	qc->cursg_ofs = 0;
aacda3753   Tejun Heo   libata: implement...
1697
  	qc->nbytes = qc->extrabytes = qc->curbytes = 0;
7a801184f   Brian King   libata: Fixup n_e...
1698
  	qc->n_elem = 0;
a22e2eb07   Albert Lee   [PATCH] libata: m...
1699
  	qc->err_mask = 0;
5a5dbd18a   Mark Lord   libata: add suppo...
1700
  	qc->sect_size = ATA_SECT_SIZE;
2c13b7cee   Jeff Garzik   [libata] minor fi...
1701

3373efd89   Tejun Heo   [PATCH] libata: u...
1702
  	ata_tf_init(qc->dev, &qc->tf);
e61e06722   Tejun Heo   [PATCH] libata: i...
1703
1704
1705
1706
  
  	/* init result_tf such that it indicates normal completion */
  	qc->result_tf.command = ATA_DRDY;
  	qc->result_tf.feature = 0;
2c13b7cee   Jeff Garzik   [libata] minor fi...
1707
  }
057ace5e7   Jeff Garzik   libata: const-ifi...
1708
  static inline int ata_try_flush_cache(const struct ata_device *dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1709
1710
1711
1712
1713
  {
  	return ata_id_wcache_enabled(dev->id) ||
  	       ata_id_has_flush(dev->id) ||
  	       ata_id_has_flush_ext(dev->id);
  }
a7dac447b   Jeff Garzik   [libata] change a...
1714
1715
  static inline unsigned int ac_err_mask(u8 status)
  {
3655d1d32   Albert Lee   [PATCH] libata: F...
1716
  	if (status & (ATA_BUSY | ATA_DRQ))
11a56d243   Tejun Heo   [PATCH] libata: a...
1717
  		return AC_ERR_HSM;
a7dac447b   Jeff Garzik   [libata] change a...
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
  	if (status & (ATA_ERR | ATA_DF))
  		return AC_ERR_DEV;
  	return 0;
  }
  
  static inline unsigned int __ac_err_mask(u8 status)
  {
  	unsigned int mask = ac_err_mask(status);
  	if (mask == 0)
  		return AC_ERR_OTHER;
  	return mask;
  }
35bb94b11   Jeff Garzik   libata: Add helpe...
1730
1731
  static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
  {
4911487a3   Tejun Heo   libata: allocate ...
1732
  	return *(struct ata_port **)&host->hostdata[0];
35bb94b11   Jeff Garzik   libata: Add helpe...
1733
  }
78ab88f04   Tejun Heo   libata: improve p...
1734
1735
  static inline int ata_check_ready(u8 status)
  {
005b1f749   Jeff Garzik   [libata] revert n...
1736
1737
  	if (!(status & ATA_BUSY))
  		return 1;
78ab88f04   Tejun Heo   libata: improve p...
1738
1739
1740
1741
  
  	/* 0xff indicates either no device or device not ready */
  	if (status == 0xff)
  		return -ENODEV;
005b1f749   Jeff Garzik   [libata] revert n...
1742
  	return 0;
78ab88f04   Tejun Heo   libata: improve p...
1743
  }
341c2c958   Tejun Heo   libata: consisten...
1744
1745
1746
1747
1748
  static inline unsigned long ata_deadline(unsigned long from_jiffies,
  					 unsigned long timeout_msecs)
  {
  	return from_jiffies + msecs_to_jiffies(timeout_msecs);
  }
b15b3ebae   Alan Cox   libata: Fix a lar...
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
  /* Don't open code these in drivers as there are traps. Firstly the range may
     change in future hardware and specs, secondly 0xFF means 'no DMA' but is
     > UDMA_0. Dyma ddreigiau */
  
  static inline int ata_using_mwdma(struct ata_device *adev)
  {
  	if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
  		return 1;
  	return 0;
  }
  
  static inline int ata_using_udma(struct ata_device *adev)
  {
  	if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
  		return 1;
  	return 0;
  }
  
  static inline int ata_dma_enabled(struct ata_device *adev)
  {
  	return (adev->dma_mode == 0xFF ? 0 : 1);
  }
48515f6c0   Tejun Heo   libata: separate ...
1771
1772
  
  /**************************************************************************
a9b2c120e   Bartlomiej Zolnierkiewicz   ata: separate PAT...
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
   * PATA timings - drivers/ata/libata-pata-timings.c
   */
  extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
  extern int ata_timing_compute(struct ata_device *, unsigned short,
  			      struct ata_timing *, int, int);
  extern void ata_timing_merge(const struct ata_timing *,
  			     const struct ata_timing *, struct ata_timing *,
  			     unsigned int);
  
  /**************************************************************************
48515f6c0   Tejun Heo   libata: separate ...
1783
1784
   * PMP - drivers/ata/libata-pmp.c
   */
88fcd5627   Tejun Heo   libata: make PMP ...
1785
  #ifdef CONFIG_SATA_PMP
48515f6c0   Tejun Heo   libata: separate ...
1786
1787
1788
1789
  extern const struct ata_port_operations sata_pmp_port_ops;
  
  extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
  extern void sata_pmp_error_handler(struct ata_port *ap);
88fcd5627   Tejun Heo   libata: make PMP ...
1790
1791
1792
1793
1794
1795
1796
  #else /* CONFIG_SATA_PMP */
  
  #define sata_pmp_port_ops		sata_port_ops
  #define sata_pmp_qc_defer_cmd_switch	ata_std_qc_defer
  #define sata_pmp_error_handler		ata_std_error_handler
  
  #endif /* CONFIG_SATA_PMP */
48515f6c0   Tejun Heo   libata: separate ...
1797

624d5c514   Tejun Heo   libata: reorganiz...
1798
1799
1800
  /**************************************************************************
   * SFF - drivers/ata/libata-sff.c
   */
127102aea   Tejun Heo   libata: make SFF ...
1801
  #ifdef CONFIG_ATA_SFF
624d5c514   Tejun Heo   libata: reorganiz...
1802
  extern const struct ata_port_operations ata_sff_port_ops;
871af1210   Alan Cox   libata: Add 32bit...
1803
  extern const struct ata_port_operations ata_bmdma32_port_ops;
624d5c514   Tejun Heo   libata: reorganiz...
1804
1805
1806
1807
1808
1809
  
  /* PIO only, sg_tablesize and dma_boundary limits can be removed */
  #define ATA_PIO_SHT(drv_name)					\
  	ATA_BASE_SHT(drv_name),					\
  	.sg_tablesize		= LIBATA_MAX_PRD,		\
  	.dma_boundary		= ATA_DMA_BOUNDARY
9363c3825   Tejun Heo   libata: rename SF...
1810
1811
  extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
  extern u8 ata_sff_check_status(struct ata_port *ap);
a57c1bade   Alan Cox   libata-sff: Fix o...
1812
1813
  extern void ata_sff_pause(struct ata_port *ap);
  extern void ata_sff_dma_pause(struct ata_port *ap);
9363c3825   Tejun Heo   libata: rename SF...
1814
1815
  extern int ata_sff_busy_sleep(struct ata_port *ap,
  			      unsigned long timeout_pat, unsigned long timeout);
705e76beb   Tejun Heo   libata: restructu...
1816
  extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
9363c3825   Tejun Heo   libata: rename SF...
1817
1818
1819
1820
  extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
  extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
  extern void ata_sff_exec_command(struct ata_port *ap,
  				 const struct ata_taskfile *tf);
989e0aac1   Bartlomiej Zolnierkiewicz   ata: pass queued ...
1821
  extern unsigned int ata_sff_data_xfer(struct ata_queued_cmd *qc,
624d5c514   Tejun Heo   libata: reorganiz...
1822
  			unsigned char *buf, unsigned int buflen, int rw);
989e0aac1   Bartlomiej Zolnierkiewicz   ata: pass queued ...
1823
  extern unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc,
871af1210   Alan Cox   libata: Add 32bit...
1824
  			unsigned char *buf, unsigned int buflen, int rw);
e42a542ba   Sergei Shtylyov   libata: make sff_...
1825
  extern void ata_sff_irq_on(struct ata_port *ap);
9363c3825   Tejun Heo   libata: rename SF...
1826
1827
1828
  extern void ata_sff_irq_clear(struct ata_port *ap);
  extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
  			    u8 status, int in_wq);
64b975942   Viresh Kumar   libata-sff: add a...
1829
1830
1831
  extern void ata_sff_queue_work(struct work_struct *work);
  extern void ata_sff_queue_delayed_work(struct delayed_work *dwork,
  		unsigned long delay);
ea3c64506   Gwendal Grignou   libata-sff: Reena...
1832
  extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay);
9363c3825   Tejun Heo   libata: rename SF...
1833
  extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
22183bf56   Tejun Heo   libata: add qc_fi...
1834
  extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
c3b288942   Tejun Heo   libata-sff: separ...
1835
  extern unsigned int ata_sff_port_intr(struct ata_port *ap,
9363c3825   Tejun Heo   libata: rename SF...
1836
1837
  				      struct ata_queued_cmd *qc);
  extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance);
c96f1732e   Alan Cox   [libata] Improve ...
1838
  extern void ata_sff_lost_interrupt(struct ata_port *ap);
9363c3825   Tejun Heo   libata: rename SF...
1839
1840
1841
1842
1843
  extern void ata_sff_freeze(struct ata_port *ap);
  extern void ata_sff_thaw(struct ata_port *ap);
  extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline);
  extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
  					  u8 *r_err);
705e76beb   Tejun Heo   libata: restructu...
1844
1845
  extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
  				    unsigned long deadline);
9363c3825   Tejun Heo   libata: rename SF...
1846
  extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
624d5c514   Tejun Heo   libata: reorganiz...
1847
  			     unsigned long deadline);
9363c3825   Tejun Heo   libata: rename SF...
1848
1849
1850
  extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
  			       unsigned long deadline);
  extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes);
3d47aa8e7   Alan Cox   [libata] Drain da...
1851
  extern void ata_sff_drain_fifo(struct ata_queued_cmd *qc);
9363c3825   Tejun Heo   libata: rename SF...
1852
  extern void ata_sff_error_handler(struct ata_port *ap);
9363c3825   Tejun Heo   libata: rename SF...
1853
  extern void ata_sff_std_ports(struct ata_ioports *ioaddr);
624d5c514   Tejun Heo   libata: reorganiz...
1854
  #ifdef CONFIG_PCI
9363c3825   Tejun Heo   libata: rename SF...
1855
1856
  extern int ata_pci_sff_init_host(struct ata_host *host);
  extern int ata_pci_sff_prepare_host(struct pci_dev *pdev,
624d5c514   Tejun Heo   libata: reorganiz...
1857
1858
  				    const struct ata_port_info * const * ppi,
  				    struct ata_host **r_host);
9363c3825   Tejun Heo   libata: rename SF...
1859
  extern int ata_pci_sff_activate_host(struct ata_host *host,
624d5c514   Tejun Heo   libata: reorganiz...
1860
1861
  				     irq_handler_t irq_handler,
  				     struct scsi_host_template *sht);
9363c3825   Tejun Heo   libata: rename SF...
1862
  extern int ata_pci_sff_init_one(struct pci_dev *pdev,
16ea0fc98   Alan Cox   libata: Pass host...
1863
1864
  		const struct ata_port_info * const * ppi,
  		struct scsi_host_template *sht, void *host_priv, int hflags);
624d5c514   Tejun Heo   libata: reorganiz...
1865
  #endif /* CONFIG_PCI */
9a7780c9a   Tejun Heo   libata-sff: make ...
1866
1867
1868
1869
1870
1871
1872
1873
  #ifdef CONFIG_ATA_BMDMA
  
  extern const struct ata_port_operations ata_bmdma_port_ops;
  
  #define ATA_BMDMA_SHT(drv_name)					\
  	ATA_BASE_SHT(drv_name),					\
  	.sg_tablesize		= LIBATA_MAX_PRD,		\
  	.dma_boundary		= ATA_DMA_BOUNDARY
95364f367   Jiri Slaby   ata: make qc_prep...
1874
  extern enum ata_completion_errors ata_bmdma_qc_prep(struct ata_queued_cmd *qc);
360ff7833   Tejun Heo   libata-sff: separ...
1875
  extern unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc);
95364f367   Jiri Slaby   ata: make qc_prep...
1876
  extern enum ata_completion_errors ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc);
c3b288942   Tejun Heo   libata-sff: separ...
1877
1878
1879
  extern unsigned int ata_bmdma_port_intr(struct ata_port *ap,
  				      struct ata_queued_cmd *qc);
  extern irqreturn_t ata_bmdma_interrupt(int irq, void *dev_instance);
fe06e5f9b   Tejun Heo   libata-sff: separ...
1880
1881
  extern void ata_bmdma_error_handler(struct ata_port *ap);
  extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
37f65b8bc   Tejun Heo   libata-sff: ata_s...
1882
  extern void ata_bmdma_irq_clear(struct ata_port *ap);
9f2f72107   Tejun Heo   libata-sff: reord...
1883
1884
1885
1886
  extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
  extern void ata_bmdma_start(struct ata_queued_cmd *qc);
  extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
  extern u8 ata_bmdma_status(struct ata_port *ap);
c7087652e   Tejun Heo   libata-sff: clean...
1887
1888
  extern int ata_bmdma_port_start(struct ata_port *ap);
  extern int ata_bmdma_port_start32(struct ata_port *ap);
9f2f72107   Tejun Heo   libata-sff: reord...
1889
1890
1891
  
  #ifdef CONFIG_PCI
  extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev);
c7087652e   Tejun Heo   libata-sff: clean...
1892
  extern void ata_pci_bmdma_init(struct ata_host *host);
1c5afdf7a   Tejun Heo   libata-sff: separ...
1893
1894
1895
1896
1897
1898
1899
  extern int ata_pci_bmdma_prepare_host(struct pci_dev *pdev,
  				      const struct ata_port_info * const * ppi,
  				      struct ata_host **r_host);
  extern int ata_pci_bmdma_init_one(struct pci_dev *pdev,
  				  const struct ata_port_info * const * ppi,
  				  struct scsi_host_template *sht,
  				  void *host_priv, int hflags);
9f2f72107   Tejun Heo   libata-sff: reord...
1900
  #endif /* CONFIG_PCI */
9a7780c9a   Tejun Heo   libata-sff: make ...
1901
  #endif /* CONFIG_ATA_BMDMA */
9f2f72107   Tejun Heo   libata-sff: reord...
1902

624d5c514   Tejun Heo   libata: reorganiz...
1903
  /**
9363c3825   Tejun Heo   libata: rename SF...
1904
   *	ata_sff_busy_wait - Wait for a port status register
624d5c514   Tejun Heo   libata: reorganiz...
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
   *	@ap: Port to wait for.
   *	@bits: bits that must be clear
   *	@max: number of 10uS waits to perform
   *
   *	Waits up to max*10 microseconds for the selected bits in the port's
   *	status register to be cleared.
   *	Returns final value of status register.
   *
   *	LOCKING:
   *	Inherited from caller.
   */
9363c3825   Tejun Heo   libata: rename SF...
1916
1917
  static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits,
  				   unsigned int max)
624d5c514   Tejun Heo   libata: reorganiz...
1918
1919
1920
1921
1922
  {
  	u8 status;
  
  	do {
  		udelay(10);
5682ed33a   Tejun Heo   libata: rename SF...
1923
  		status = ap->ops->sff_check_status(ap);
624d5c514   Tejun Heo   libata: reorganiz...
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
  		max--;
  	} while (status != 0xff && (status & bits) && (max > 0));
  
  	return status;
  }
  
  /**
   *	ata_wait_idle - Wait for a port to be idle.
   *	@ap: Port to wait for.
   *
   *	Waits up to 10ms for port's BUSY and DRQ signals to clear.
   *	Returns final value of status register.
   *
   *	LOCKING:
   *	Inherited from caller.
   */
  static inline u8 ata_wait_idle(struct ata_port *ap)
  {
9363c3825   Tejun Heo   libata: rename SF...
1942
  	u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
624d5c514   Tejun Heo   libata: reorganiz...
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
  
  #ifdef ATA_DEBUG
  	if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
  		ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X
  ",
  				status);
  #endif
  
  	return status;
  }
127102aea   Tejun Heo   libata: make SFF ...
1953
  #endif /* CONFIG_ATA_SFF */
624d5c514   Tejun Heo   libata: reorganiz...
1954

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1955
  #endif /* __LINUX_LIBATA_H__ */