diff options
-rw-r--r-- | Documentation/devicetree/bindings/ata/ahci-platform.txt | 18 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/ata/sata_highbank.txt | 44 | ||||
-rw-r--r-- | drivers/ata/ahci.c | 8 | ||||
-rw-r--r-- | drivers/ata/libata-acpi.c | 278 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 29 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 38 | ||||
-rw-r--r-- | drivers/ata/libata-transport.c | 2 | ||||
-rw-r--r-- | drivers/ata/libata-zpodd.c | 12 | ||||
-rw-r--r-- | drivers/ata/libata.h | 19 | ||||
-rw-r--r-- | drivers/ata/pata_acpi.c | 4 | ||||
-rw-r--r-- | drivers/ata/pata_arasan_cf.c | 4 | ||||
-rw-r--r-- | drivers/ata/pata_at32.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_at91.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_ixp4xx_cf.c | 4 | ||||
-rw-r--r-- | drivers/ata/pata_octeon_cf.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_platform.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_pxa.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_samsung_cf.c | 10 | ||||
-rw-r--r-- | drivers/ata/sata_highbank.c | 74 | ||||
-rw-r--r-- | drivers/ata/sata_mv.c | 26 | ||||
-rw-r--r-- | drivers/ata/sata_rcar.c | 5 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 22 | ||||
-rw-r--r-- | include/linux/ata.h | 123 | ||||
-rw-r--r-- | include/linux/libata.h | 120 |
24 files changed, 423 insertions, 427 deletions
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt index 3ec0c5c4f0e9..89de1564950c 100644 --- a/Documentation/devicetree/bindings/ata/ahci-platform.txt +++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt | |||
@@ -4,27 +4,17 @@ SATA nodes are defined to describe on-chip Serial ATA controllers. | |||
4 | Each SATA controller should have its own node. | 4 | Each SATA controller should have its own node. |
5 | 5 | ||
6 | Required properties: | 6 | Required properties: |
7 | - compatible : compatible list, contains "calxeda,hb-ahci" or "snps,spear-ahci" | 7 | - compatible : compatible list, contains "snps,spear-ahci" |
8 | - interrupts : <interrupt mapping for SATA IRQ> | 8 | - interrupts : <interrupt mapping for SATA IRQ> |
9 | - reg : <registers mapping> | 9 | - reg : <registers mapping> |
10 | 10 | ||
11 | Optional properties: | 11 | Optional properties: |
12 | - calxeda,port-phys: phandle-combophy and lane assignment, which maps each | ||
13 | SATA port to a combophy and a lane within that | ||
14 | combophy | ||
15 | - calxeda,sgpio-gpio: phandle-gpio bank, bit offset, and default on or off, | ||
16 | which indicates that the driver supports SGPIO | ||
17 | indicator lights using the indicated GPIOs | ||
18 | - calxeda,led-order : a u32 array that map port numbers to offsets within the | ||
19 | SGPIO bitstream. | ||
20 | - dma-coherent : Present if dma operations are coherent | 12 | - dma-coherent : Present if dma operations are coherent |
21 | 13 | ||
22 | Example: | 14 | Example: |
23 | sata@ffe08000 { | 15 | sata@ffe08000 { |
24 | compatible = "calxeda,hb-ahci"; | 16 | compatible = "snps,spear-ahci"; |
25 | reg = <0xffe08000 0x1000>; | 17 | reg = <0xffe08000 0x1000>; |
26 | interrupts = <115>; | 18 | interrupts = <115>; |
27 | calxeda,port-phys = <&combophy5 0 &combophy0 0 &combophy0 1 | ||
28 | &combophy0 2 &combophy0 3>; | ||
29 | 19 | ||
30 | }; | 20 | }; |
diff --git a/Documentation/devicetree/bindings/ata/sata_highbank.txt b/Documentation/devicetree/bindings/ata/sata_highbank.txt new file mode 100644 index 000000000000..aa83407cb7a4 --- /dev/null +++ b/Documentation/devicetree/bindings/ata/sata_highbank.txt | |||
@@ -0,0 +1,44 @@ | |||
1 | * Calxeda AHCI SATA Controller | ||
2 | |||
3 | SATA nodes are defined to describe on-chip Serial ATA controllers. | ||
4 | The Calxeda SATA controller mostly conforms to the AHCI interface | ||
5 | with some special extensions to add functionality. | ||
6 | Each SATA controller should have its own node. | ||
7 | |||
8 | Required properties: | ||
9 | - compatible : compatible list, contains "calxeda,hb-ahci" | ||
10 | - interrupts : <interrupt mapping for SATA IRQ> | ||
11 | - reg : <registers mapping> | ||
12 | |||
13 | Optional properties: | ||
14 | - dma-coherent : Present if dma operations are coherent | ||
15 | - calxeda,port-phys : phandle-combophy and lane assignment, which maps each | ||
16 | SATA port to a combophy and a lane within that | ||
17 | combophy | ||
18 | - calxeda,sgpio-gpio: phandle-gpio bank, bit offset, and default on or off, | ||
19 | which indicates that the driver supports SGPIO | ||
20 | indicator lights using the indicated GPIOs | ||
21 | - calxeda,led-order : a u32 array that map port numbers to offsets within the | ||
22 | SGPIO bitstream. | ||
23 | - calxeda,tx-atten : a u32 array that contains TX attenuation override | ||
24 | codes, one per port. The upper 3 bytes are always | ||
25 | 0 and thus ignored. | ||
26 | - calxeda,pre-clocks : a u32 that indicates the number of additional clock | ||
27 | cycles to transmit before sending an SGPIO pattern | ||
28 | - calxeda,post-clocks: a u32 that indicates the number of additional clock | ||
29 | cycles to transmit after sending an SGPIO pattern | ||
30 | |||
31 | Example: | ||
32 | sata@ffe08000 { | ||
33 | compatible = "calxeda,hb-ahci"; | ||
34 | reg = <0xffe08000 0x1000>; | ||
35 | interrupts = <115>; | ||
36 | dma-coherent; | ||
37 | calxeda,port-phys = <&combophy5 0 &combophy0 0 &combophy0 1 | ||
38 | &combophy0 2 &combophy0 3>; | ||
39 | calxeda,sgpio-gpio =<&gpioh 5 1 &gpioh 6 1 &gpioh 7 1>; | ||
40 | calxeda,led-order = <4 0 1 2 3>; | ||
41 | calxeda,tx-atten = <0xff 22 0xff 0xff 23>; | ||
42 | calxeda,pre-clocks = <10>; | ||
43 | calxeda,post-clocks = <0>; | ||
44 | }; | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index db4380d70031..9d715ae5ff6b 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1295,6 +1295,14 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1295 | */ | 1295 | */ |
1296 | if (!(hpriv->flags & AHCI_HFLAG_NO_FPDMA_AA)) | 1296 | if (!(hpriv->flags & AHCI_HFLAG_NO_FPDMA_AA)) |
1297 | pi.flags |= ATA_FLAG_FPDMA_AA; | 1297 | pi.flags |= ATA_FLAG_FPDMA_AA; |
1298 | |||
1299 | /* | ||
1300 | * All AHCI controllers should be forward-compatible | ||
1301 | * with the new auxiliary field. This code should be | ||
1302 | * conditionalized if any buggy AHCI controllers are | ||
1303 | * encountered. | ||
1304 | */ | ||
1305 | pi.flags |= ATA_FLAG_FPDMA_AUX; | ||
1298 | } | 1306 | } |
1299 | 1307 | ||
1300 | if (hpriv->cap & HOST_CAP_PMP) | 1308 | if (hpriv->cap & HOST_CAP_PMP) |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index da8170dfc90f..4ba8b0405572 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -34,14 +34,6 @@ struct ata_acpi_gtf { | |||
34 | u8 tf[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ | 34 | u8 tf[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ |
35 | } __packed; | 35 | } __packed; |
36 | 36 | ||
37 | /* | ||
38 | * Helper - belongs in the PCI layer somewhere eventually | ||
39 | */ | ||
40 | static int is_pci_dev(struct device *dev) | ||
41 | { | ||
42 | return (dev->bus == &pci_bus_type); | ||
43 | } | ||
44 | |||
45 | static void ata_acpi_clear_gtf(struct ata_device *dev) | 37 | static void ata_acpi_clear_gtf(struct ata_device *dev) |
46 | { | 38 | { |
47 | kfree(dev->gtf_cache); | 39 | kfree(dev->gtf_cache); |
@@ -49,47 +41,18 @@ static void ata_acpi_clear_gtf(struct ata_device *dev) | |||
49 | } | 41 | } |
50 | 42 | ||
51 | /** | 43 | /** |
52 | * ata_ap_acpi_handle - provide the acpi_handle for an ata_port | ||
53 | * @ap: the acpi_handle returned will correspond to this port | ||
54 | * | ||
55 | * Returns the acpi_handle for the ACPI namespace object corresponding to | ||
56 | * the ata_port passed into the function, or NULL if no such object exists | ||
57 | */ | ||
58 | acpi_handle ata_ap_acpi_handle(struct ata_port *ap) | ||
59 | { | ||
60 | if (ap->flags & ATA_FLAG_ACPI_SATA) | ||
61 | return NULL; | ||
62 | |||
63 | return ap->scsi_host ? | ||
64 | DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL; | ||
65 | } | ||
66 | EXPORT_SYMBOL(ata_ap_acpi_handle); | ||
67 | |||
68 | /** | ||
69 | * ata_dev_acpi_handle - provide the acpi_handle for an ata_device | 44 | * ata_dev_acpi_handle - provide the acpi_handle for an ata_device |
70 | * @dev: the acpi_device returned will correspond to this port | 45 | * @dev: the acpi_handle returned will correspond to this device |
71 | * | 46 | * |
72 | * Returns the acpi_handle for the ACPI namespace object corresponding to | 47 | * Returns the acpi_handle for the ACPI namespace object corresponding to |
73 | * the ata_device passed into the function, or NULL if no such object exists | 48 | * the ata_device passed into the function, or NULL if no such object exists |
49 | * or ACPI is disabled for this device due to consecutive errors. | ||
74 | */ | 50 | */ |
75 | acpi_handle ata_dev_acpi_handle(struct ata_device *dev) | 51 | acpi_handle ata_dev_acpi_handle(struct ata_device *dev) |
76 | { | 52 | { |
77 | acpi_integer adr; | 53 | return dev->flags & ATA_DFLAG_ACPI_DISABLED ? |
78 | struct ata_port *ap = dev->link->ap; | 54 | NULL : ACPI_HANDLE(&dev->tdev); |
79 | |||
80 | if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED) | ||
81 | return NULL; | ||
82 | |||
83 | if (ap->flags & ATA_FLAG_ACPI_SATA) { | ||
84 | if (!sata_pmp_attached(ap)) | ||
85 | adr = SATA_ADR(ap->port_no, NO_PORT_MULT); | ||
86 | else | ||
87 | adr = SATA_ADR(ap->port_no, dev->link->pmp); | ||
88 | return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), adr); | ||
89 | } else | ||
90 | return acpi_get_child(ata_ap_acpi_handle(ap), dev->devno); | ||
91 | } | 55 | } |
92 | EXPORT_SYMBOL(ata_dev_acpi_handle); | ||
93 | 56 | ||
94 | /* @ap and @dev are the same as ata_acpi_handle_hotplug() */ | 57 | /* @ap and @dev are the same as ata_acpi_handle_hotplug() */ |
95 | static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev) | 58 | static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev) |
@@ -156,10 +119,8 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev, | |||
156 | 119 | ||
157 | spin_unlock_irqrestore(ap->lock, flags); | 120 | spin_unlock_irqrestore(ap->lock, flags); |
158 | 121 | ||
159 | if (wait) { | 122 | if (wait) |
160 | ata_port_wait_eh(ap); | 123 | ata_port_wait_eh(ap); |
161 | flush_work(&ap->hotplug_task.work); | ||
162 | } | ||
163 | } | 124 | } |
164 | 125 | ||
165 | static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) | 126 | static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) |
@@ -216,37 +177,55 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = { | |||
216 | .uevent = ata_acpi_ap_uevent, | 177 | .uevent = ata_acpi_ap_uevent, |
217 | }; | 178 | }; |
218 | 179 | ||
219 | void ata_acpi_hotplug_init(struct ata_host *host) | 180 | /* bind acpi handle to pata port */ |
181 | void ata_acpi_bind_port(struct ata_port *ap) | ||
220 | { | 182 | { |
221 | int i; | 183 | acpi_handle host_handle = ACPI_HANDLE(ap->host->dev); |
222 | 184 | ||
223 | for (i = 0; i < host->n_ports; i++) { | 185 | if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_handle) |
224 | struct ata_port *ap = host->ports[i]; | 186 | return; |
225 | acpi_handle handle; | ||
226 | struct ata_device *dev; | ||
227 | 187 | ||
228 | if (!ap) | 188 | ACPI_HANDLE_SET(&ap->tdev, acpi_get_child(host_handle, ap->port_no)); |
229 | continue; | ||
230 | 189 | ||
231 | handle = ata_ap_acpi_handle(ap); | 190 | if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) |
232 | if (handle) { | 191 | ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; |
233 | /* we might be on a docking station */ | ||
234 | register_hotplug_dock_device(handle, | ||
235 | &ata_acpi_ap_dock_ops, ap, | ||
236 | NULL, NULL); | ||
237 | } | ||
238 | 192 | ||
239 | ata_for_each_dev(dev, &ap->link, ALL) { | 193 | /* we might be on a docking station */ |
240 | handle = ata_dev_acpi_handle(dev); | 194 | register_hotplug_dock_device(ACPI_HANDLE(&ap->tdev), |
241 | if (!handle) | 195 | &ata_acpi_ap_dock_ops, ap, NULL, NULL); |
242 | continue; | 196 | } |
243 | 197 | ||
244 | /* we might be on a docking station */ | 198 | void ata_acpi_bind_dev(struct ata_device *dev) |
245 | register_hotplug_dock_device(handle, | 199 | { |
246 | &ata_acpi_dev_dock_ops, | 200 | struct ata_port *ap = dev->link->ap; |
247 | dev, NULL, NULL); | 201 | acpi_handle port_handle = ACPI_HANDLE(&ap->tdev); |
248 | } | 202 | acpi_handle host_handle = ACPI_HANDLE(ap->host->dev); |
203 | acpi_handle parent_handle; | ||
204 | u64 adr; | ||
205 | |||
206 | /* | ||
207 | * For both sata/pata devices, host handle is required. | ||
208 | * For pata device, port handle is also required. | ||
209 | */ | ||
210 | if (libata_noacpi || !host_handle || | ||
211 | (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_handle)) | ||
212 | return; | ||
213 | |||
214 | if (ap->flags & ATA_FLAG_ACPI_SATA) { | ||
215 | if (!sata_pmp_attached(ap)) | ||
216 | adr = SATA_ADR(ap->port_no, NO_PORT_MULT); | ||
217 | else | ||
218 | adr = SATA_ADR(ap->port_no, dev->link->pmp); | ||
219 | parent_handle = host_handle; | ||
220 | } else { | ||
221 | adr = dev->devno; | ||
222 | parent_handle = port_handle; | ||
249 | } | 223 | } |
224 | |||
225 | ACPI_HANDLE_SET(&dev->tdev, acpi_get_child(parent_handle, adr)); | ||
226 | |||
227 | register_hotplug_dock_device(ata_dev_acpi_handle(dev), | ||
228 | &ata_acpi_dev_dock_ops, dev, NULL, NULL); | ||
250 | } | 229 | } |
251 | 230 | ||
252 | /** | 231 | /** |
@@ -270,18 +249,34 @@ void ata_acpi_dissociate(struct ata_host *host) | |||
270 | struct ata_port *ap = host->ports[i]; | 249 | struct ata_port *ap = host->ports[i]; |
271 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); | 250 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); |
272 | 251 | ||
273 | if (ata_ap_acpi_handle(ap) && gtm) | 252 | if (ACPI_HANDLE(&ap->tdev) && gtm) |
274 | ata_acpi_stm(ap, gtm); | 253 | ata_acpi_stm(ap, gtm); |
275 | } | 254 | } |
276 | } | 255 | } |
277 | 256 | ||
278 | static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle, | 257 | /** |
279 | struct ata_acpi_gtm *gtm) | 258 | * ata_acpi_gtm - execute _GTM |
259 | * @ap: target ATA port | ||
260 | * @gtm: out parameter for _GTM result | ||
261 | * | ||
262 | * Evaluate _GTM and store the result in @gtm. | ||
263 | * | ||
264 | * LOCKING: | ||
265 | * EH context. | ||
266 | * | ||
267 | * RETURNS: | ||
268 | * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. | ||
269 | */ | ||
270 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) | ||
280 | { | 271 | { |
281 | struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; | 272 | struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; |
282 | union acpi_object *out_obj; | 273 | union acpi_object *out_obj; |
283 | acpi_status status; | 274 | acpi_status status; |
284 | int rc = 0; | 275 | int rc = 0; |
276 | acpi_handle handle = ACPI_HANDLE(&ap->tdev); | ||
277 | |||
278 | if (!handle) | ||
279 | return -EINVAL; | ||
285 | 280 | ||
286 | status = acpi_evaluate_object(handle, "_GTM", NULL, &output); | 281 | status = acpi_evaluate_object(handle, "_GTM", NULL, &output); |
287 | 282 | ||
@@ -317,27 +312,6 @@ static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle, | |||
317 | return rc; | 312 | return rc; |
318 | } | 313 | } |
319 | 314 | ||
320 | /** | ||
321 | * ata_acpi_gtm - execute _GTM | ||
322 | * @ap: target ATA port | ||
323 | * @gtm: out parameter for _GTM result | ||
324 | * | ||
325 | * Evaluate _GTM and store the result in @gtm. | ||
326 | * | ||
327 | * LOCKING: | ||
328 | * EH context. | ||
329 | * | ||
330 | * RETURNS: | ||
331 | * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. | ||
332 | */ | ||
333 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) | ||
334 | { | ||
335 | if (ata_ap_acpi_handle(ap)) | ||
336 | return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm); | ||
337 | else | ||
338 | return -EINVAL; | ||
339 | } | ||
340 | |||
341 | EXPORT_SYMBOL_GPL(ata_acpi_gtm); | 315 | EXPORT_SYMBOL_GPL(ata_acpi_gtm); |
342 | 316 | ||
343 | /** | 317 | /** |
@@ -374,8 +348,8 @@ int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm) | |||
374 | input.count = 3; | 348 | input.count = 3; |
375 | input.pointer = in_params; | 349 | input.pointer = in_params; |
376 | 350 | ||
377 | status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_STM", &input, | 351 | status = acpi_evaluate_object(ACPI_HANDLE(&ap->tdev), "_STM", |
378 | NULL); | 352 | &input, NULL); |
379 | 353 | ||
380 | if (status == AE_NOT_FOUND) | 354 | if (status == AE_NOT_FOUND) |
381 | return -ENOENT; | 355 | return -ENOENT; |
@@ -850,7 +824,7 @@ void ata_acpi_on_resume(struct ata_port *ap) | |||
850 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); | 824 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); |
851 | struct ata_device *dev; | 825 | struct ata_device *dev; |
852 | 826 | ||
853 | if (ata_ap_acpi_handle(ap) && gtm) { | 827 | if (ACPI_HANDLE(&ap->tdev) && gtm) { |
854 | /* _GTM valid */ | 828 | /* _GTM valid */ |
855 | 829 | ||
856 | /* restore timing parameters */ | 830 | /* restore timing parameters */ |
@@ -894,8 +868,7 @@ static int ata_acpi_choose_suspend_state(struct ata_device *dev, bool runtime) | |||
894 | d_max_in = ACPI_STATE_D3_HOT; | 868 | d_max_in = ACPI_STATE_D3_HOT; |
895 | 869 | ||
896 | out: | 870 | out: |
897 | return acpi_pm_device_sleep_state(&dev->sdev->sdev_gendev, | 871 | return acpi_pm_device_sleep_state(&dev->tdev, NULL, d_max_in); |
898 | NULL, d_max_in); | ||
899 | } | 872 | } |
900 | 873 | ||
901 | static void sata_acpi_set_state(struct ata_port *ap, pm_message_t state) | 874 | static void sata_acpi_set_state(struct ata_port *ap, pm_message_t state) |
@@ -932,7 +905,7 @@ static void pata_acpi_set_state(struct ata_port *ap, pm_message_t state) | |||
932 | struct ata_device *dev; | 905 | struct ata_device *dev; |
933 | acpi_handle port_handle; | 906 | acpi_handle port_handle; |
934 | 907 | ||
935 | port_handle = ata_ap_acpi_handle(ap); | 908 | port_handle = ACPI_HANDLE(&ap->tdev); |
936 | if (!port_handle) | 909 | if (!port_handle) |
937 | return; | 910 | return; |
938 | 911 | ||
@@ -1063,109 +1036,16 @@ void ata_acpi_on_disable(struct ata_device *dev) | |||
1063 | ata_acpi_clear_gtf(dev); | 1036 | ata_acpi_clear_gtf(dev); |
1064 | } | 1037 | } |
1065 | 1038 | ||
1066 | static int compat_pci_ata(struct ata_port *ap) | 1039 | void ata_scsi_acpi_bind(struct ata_device *dev) |
1067 | { | ||
1068 | struct device *dev = ap->tdev.parent; | ||
1069 | struct pci_dev *pdev; | ||
1070 | |||
1071 | if (!is_pci_dev(dev)) | ||
1072 | return 0; | ||
1073 | |||
1074 | pdev = to_pci_dev(dev); | ||
1075 | |||
1076 | if ((pdev->class >> 8) != PCI_CLASS_STORAGE_SATA && | ||
1077 | (pdev->class >> 8) != PCI_CLASS_STORAGE_IDE) | ||
1078 | return 0; | ||
1079 | |||
1080 | return 1; | ||
1081 | } | ||
1082 | |||
1083 | static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle) | ||
1084 | { | ||
1085 | if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA) | ||
1086 | return -ENODEV; | ||
1087 | |||
1088 | *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent), | ||
1089 | ap->port_no); | ||
1090 | |||
1091 | if (!*handle) | ||
1092 | return -ENODEV; | ||
1093 | |||
1094 | if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0) | ||
1095 | ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; | ||
1096 | |||
1097 | return 0; | ||
1098 | } | ||
1099 | |||
1100 | static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev, | ||
1101 | acpi_handle *handle) | ||
1102 | { | ||
1103 | struct ata_device *ata_dev; | ||
1104 | |||
1105 | if (ap->flags & ATA_FLAG_ACPI_SATA) { | ||
1106 | if (!sata_pmp_attached(ap)) | ||
1107 | ata_dev = &ap->link.device[sdev->id]; | ||
1108 | else | ||
1109 | ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id]; | ||
1110 | } | ||
1111 | else { | ||
1112 | ata_dev = &ap->link.device[sdev->id]; | ||
1113 | } | ||
1114 | |||
1115 | *handle = ata_dev_acpi_handle(ata_dev); | ||
1116 | |||
1117 | if (!*handle) | ||
1118 | return -ENODEV; | ||
1119 | |||
1120 | return 0; | ||
1121 | } | ||
1122 | |||
1123 | static int is_ata_port(const struct device *dev) | ||
1124 | { | ||
1125 | return dev->type == &ata_port_type; | ||
1126 | } | ||
1127 | |||
1128 | static struct ata_port *dev_to_ata_port(struct device *dev) | ||
1129 | { | ||
1130 | while (!is_ata_port(dev)) { | ||
1131 | if (!dev->parent) | ||
1132 | return NULL; | ||
1133 | dev = dev->parent; | ||
1134 | } | ||
1135 | return to_ata_port(dev); | ||
1136 | } | ||
1137 | |||
1138 | static int ata_acpi_find_device(struct device *dev, acpi_handle *handle) | ||
1139 | { | ||
1140 | struct ata_port *ap = dev_to_ata_port(dev); | ||
1141 | |||
1142 | if (!ap) | ||
1143 | return -ENODEV; | ||
1144 | |||
1145 | if (!compat_pci_ata(ap)) | ||
1146 | return -ENODEV; | ||
1147 | |||
1148 | if (scsi_is_host_device(dev)) | ||
1149 | return ata_acpi_bind_host(ap, handle); | ||
1150 | else if (scsi_is_sdev_device(dev)) { | ||
1151 | struct scsi_device *sdev = to_scsi_device(dev); | ||
1152 | |||
1153 | return ata_acpi_bind_device(ap, sdev, handle); | ||
1154 | } else | ||
1155 | return -ENODEV; | ||
1156 | } | ||
1157 | |||
1158 | static struct acpi_bus_type ata_acpi_bus = { | ||
1159 | .name = "ATA", | ||
1160 | .find_device = ata_acpi_find_device, | ||
1161 | }; | ||
1162 | |||
1163 | int ata_acpi_register(void) | ||
1164 | { | 1040 | { |
1165 | return scsi_register_acpi_bus_type(&ata_acpi_bus); | 1041 | acpi_handle handle = ata_dev_acpi_handle(dev); |
1042 | if (handle) | ||
1043 | acpi_dev_pm_add_dependent(handle, &dev->sdev->sdev_gendev); | ||
1166 | } | 1044 | } |
1167 | 1045 | ||
1168 | void ata_acpi_unregister(void) | 1046 | void ata_scsi_acpi_unbind(struct ata_device *dev) |
1169 | { | 1047 | { |
1170 | scsi_unregister_acpi_bus_type(&ata_acpi_bus); | 1048 | acpi_handle handle = ata_dev_acpi_handle(dev); |
1049 | if (handle) | ||
1050 | acpi_dev_pm_remove_dependent(handle, &dev->sdev->sdev_gendev); | ||
1171 | } | 1051 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c24354d44f3d..83b1a9fb2d44 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -569,10 +569,10 @@ void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis) | |||
569 | fis[14] = 0; | 569 | fis[14] = 0; |
570 | fis[15] = tf->ctl; | 570 | fis[15] = tf->ctl; |
571 | 571 | ||
572 | fis[16] = 0; | 572 | fis[16] = tf->auxiliary & 0xff; |
573 | fis[17] = 0; | 573 | fis[17] = (tf->auxiliary >> 8) & 0xff; |
574 | fis[18] = 0; | 574 | fis[18] = (tf->auxiliary >> 16) & 0xff; |
575 | fis[19] = 0; | 575 | fis[19] = (tf->auxiliary >> 24) & 0xff; |
576 | } | 576 | } |
577 | 577 | ||
578 | /** | 578 | /** |
@@ -2139,6 +2139,22 @@ static int ata_dev_config_ncq(struct ata_device *dev, | |||
2139 | else | 2139 | else |
2140 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, | 2140 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, |
2141 | ddepth, aa_desc); | 2141 | ddepth, aa_desc); |
2142 | |||
2143 | if ((ap->flags & ATA_FLAG_FPDMA_AUX) && | ||
2144 | ata_id_has_ncq_send_and_recv(dev->id)) { | ||
2145 | err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV, | ||
2146 | 0, ap->sector_buf, 1); | ||
2147 | if (err_mask) { | ||
2148 | ata_dev_dbg(dev, | ||
2149 | "failed to get NCQ Send/Recv Log Emask 0x%x\n", | ||
2150 | err_mask); | ||
2151 | } else { | ||
2152 | dev->flags |= ATA_DFLAG_NCQ_SEND_RECV; | ||
2153 | memcpy(dev->ncq_send_recv_cmds, ap->sector_buf, | ||
2154 | ATA_LOG_NCQ_SEND_RECV_SIZE); | ||
2155 | } | ||
2156 | } | ||
2157 | |||
2142 | return 0; | 2158 | return 0; |
2143 | } | 2159 | } |
2144 | 2160 | ||
@@ -6150,8 +6166,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6150 | if (rc) | 6166 | if (rc) |
6151 | goto err_tadd; | 6167 | goto err_tadd; |
6152 | 6168 | ||
6153 | ata_acpi_hotplug_init(host); | ||
6154 | |||
6155 | /* set cable, sata_spd_limit and report */ | 6169 | /* set cable, sata_spd_limit and report */ |
6156 | for (i = 0; i < host->n_ports; i++) { | 6170 | for (i = 0; i < host->n_ports; i++) { |
6157 | struct ata_port *ap = host->ports[i]; | 6171 | struct ata_port *ap = host->ports[i]; |
@@ -6632,8 +6646,6 @@ static int __init ata_init(void) | |||
6632 | 6646 | ||
6633 | ata_parse_force_param(); | 6647 | ata_parse_force_param(); |
6634 | 6648 | ||
6635 | ata_acpi_register(); | ||
6636 | |||
6637 | rc = ata_sff_init(); | 6649 | rc = ata_sff_init(); |
6638 | if (rc) { | 6650 | if (rc) { |
6639 | kfree(ata_force_tbl); | 6651 | kfree(ata_force_tbl); |
@@ -6660,7 +6672,6 @@ static void __exit ata_exit(void) | |||
6660 | ata_release_transport(ata_scsi_transport_template); | 6672 | ata_release_transport(ata_scsi_transport_template); |
6661 | libata_transport_exit(); | 6673 | libata_transport_exit(); |
6662 | ata_sff_exit(); | 6674 | ata_sff_exit(); |
6663 | ata_acpi_unregister(); | ||
6664 | kfree(ata_force_tbl); | 6675 | kfree(ata_force_tbl); |
6665 | } | 6676 | } |
6666 | 6677 | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index b1e880a3c3da..97a0cef12959 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/hdreg.h> | 49 | #include <linux/hdreg.h> |
50 | #include <linux/uaccess.h> | 50 | #include <linux/uaccess.h> |
51 | #include <linux/suspend.h> | 51 | #include <linux/suspend.h> |
52 | #include <linux/pm_qos.h> | ||
53 | #include <asm/unaligned.h> | 52 | #include <asm/unaligned.h> |
54 | 53 | ||
55 | #include "libata.h" | 54 | #include "libata.h" |
@@ -3100,12 +3099,25 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) | |||
3100 | buf = page_address(sg_page(scsi_sglist(scmd))); | 3099 | buf = page_address(sg_page(scsi_sglist(scmd))); |
3101 | size = ata_set_lba_range_entries(buf, 512, block, n_block); | 3100 | size = ata_set_lba_range_entries(buf, 512, block, n_block); |
3102 | 3101 | ||
3103 | tf->protocol = ATA_PROT_DMA; | 3102 | if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { |
3104 | tf->hob_feature = 0; | 3103 | /* Newer devices support queued TRIM commands */ |
3105 | tf->feature = ATA_DSM_TRIM; | 3104 | tf->protocol = ATA_PROT_NCQ; |
3106 | tf->hob_nsect = (size / 512) >> 8; | 3105 | tf->command = ATA_CMD_FPDMA_SEND; |
3107 | tf->nsect = size / 512; | 3106 | tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f; |
3108 | tf->command = ATA_CMD_DSM; | 3107 | tf->nsect = qc->tag << 3; |
3108 | tf->hob_feature = (size / 512) >> 8; | ||
3109 | tf->feature = size / 512; | ||
3110 | |||
3111 | tf->auxiliary = 1; | ||
3112 | } else { | ||
3113 | tf->protocol = ATA_PROT_DMA; | ||
3114 | tf->hob_feature = 0; | ||
3115 | tf->feature = ATA_DSM_TRIM; | ||
3116 | tf->hob_nsect = (size / 512) >> 8; | ||
3117 | tf->nsect = size / 512; | ||
3118 | tf->command = ATA_CMD_DSM; | ||
3119 | } | ||
3120 | |||
3109 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | | 3121 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | |
3110 | ATA_TFLAG_WRITE; | 3122 | ATA_TFLAG_WRITE; |
3111 | 3123 | ||
@@ -3667,9 +3679,7 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) | |||
3667 | if (!IS_ERR(sdev)) { | 3679 | if (!IS_ERR(sdev)) { |
3668 | dev->sdev = sdev; | 3680 | dev->sdev = sdev; |
3669 | scsi_device_put(sdev); | 3681 | scsi_device_put(sdev); |
3670 | if (zpodd_dev_enabled(dev)) | 3682 | ata_scsi_acpi_bind(dev); |
3671 | dev_pm_qos_expose_flags( | ||
3672 | &sdev->sdev_gendev, 0); | ||
3673 | } else { | 3683 | } else { |
3674 | dev->sdev = NULL; | 3684 | dev->sdev = NULL; |
3675 | } | 3685 | } |
@@ -3757,6 +3767,8 @@ static void ata_scsi_remove_dev(struct ata_device *dev) | |||
3757 | struct scsi_device *sdev; | 3767 | struct scsi_device *sdev; |
3758 | unsigned long flags; | 3768 | unsigned long flags; |
3759 | 3769 | ||
3770 | ata_scsi_acpi_unbind(dev); | ||
3771 | |||
3760 | /* Alas, we need to grab scan_mutex to ensure SCSI device | 3772 | /* Alas, we need to grab scan_mutex to ensure SCSI device |
3761 | * state doesn't change underneath us and thus | 3773 | * state doesn't change underneath us and thus |
3762 | * scsi_device_get() always succeeds. The mutex locking can | 3774 | * scsi_device_get() always succeeds. The mutex locking can |
@@ -3766,9 +3778,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev) | |||
3766 | mutex_lock(&ap->scsi_host->scan_mutex); | 3778 | mutex_lock(&ap->scsi_host->scan_mutex); |
3767 | spin_lock_irqsave(ap->lock, flags); | 3779 | spin_lock_irqsave(ap->lock, flags); |
3768 | 3780 | ||
3769 | if (zpodd_dev_enabled(dev)) | ||
3770 | zpodd_exit(dev); | ||
3771 | |||
3772 | /* clearing dev->sdev is protected by host lock */ | 3781 | /* clearing dev->sdev is protected by host lock */ |
3773 | sdev = dev->sdev; | 3782 | sdev = dev->sdev; |
3774 | dev->sdev = NULL; | 3783 | dev->sdev = NULL; |
@@ -3818,6 +3827,9 @@ static void ata_scsi_handle_link_detach(struct ata_link *link) | |||
3818 | dev->flags &= ~ATA_DFLAG_DETACHED; | 3827 | dev->flags &= ~ATA_DFLAG_DETACHED; |
3819 | spin_unlock_irqrestore(ap->lock, flags); | 3828 | spin_unlock_irqrestore(ap->lock, flags); |
3820 | 3829 | ||
3830 | if (zpodd_dev_enabled(dev)) | ||
3831 | zpodd_exit(dev); | ||
3832 | |||
3821 | ata_scsi_remove_dev(dev); | 3833 | ata_scsi_remove_dev(dev); |
3822 | } | 3834 | } |
3823 | } | 3835 | } |
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c index 077a856f5fd0..150a917f0c3c 100644 --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c | |||
@@ -287,6 +287,7 @@ int ata_tport_add(struct device *parent, | |||
287 | dev->release = ata_tport_release; | 287 | dev->release = ata_tport_release; |
288 | dev_set_name(dev, "ata%d", ap->print_id); | 288 | dev_set_name(dev, "ata%d", ap->print_id); |
289 | transport_setup_device(dev); | 289 | transport_setup_device(dev); |
290 | ata_acpi_bind_port(ap); | ||
290 | error = device_add(dev); | 291 | error = device_add(dev); |
291 | if (error) { | 292 | if (error) { |
292 | goto tport_err; | 293 | goto tport_err; |
@@ -644,6 +645,7 @@ static int ata_tdev_add(struct ata_device *ata_dev) | |||
644 | dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); | 645 | dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); |
645 | 646 | ||
646 | transport_setup_device(dev); | 647 | transport_setup_device(dev); |
648 | ata_acpi_bind_dev(ata_dev); | ||
647 | error = device_add(dev); | 649 | error = device_add(dev); |
648 | if (error) { | 650 | if (error) { |
649 | ata_tdev_free(ata_dev); | 651 | ata_tdev_free(ata_dev); |
diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c index cd8daf47188b..68f9e3293e9c 100644 --- a/drivers/ata/libata-zpodd.c +++ b/drivers/ata/libata-zpodd.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/cdrom.h> | 2 | #include <linux/cdrom.h> |
3 | #include <linux/pm_runtime.h> | 3 | #include <linux/pm_runtime.h> |
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/pm_qos.h> | ||
5 | #include <scsi/scsi_device.h> | 6 | #include <scsi/scsi_device.h> |
6 | 7 | ||
7 | #include "libata.h" | 8 | #include "libata.h" |
@@ -190,8 +191,8 @@ void zpodd_enable_run_wake(struct ata_device *dev) | |||
190 | sdev_disable_disk_events(dev->sdev); | 191 | sdev_disable_disk_events(dev->sdev); |
191 | 192 | ||
192 | zpodd->powered_off = true; | 193 | zpodd->powered_off = true; |
193 | device_set_run_wake(&dev->sdev->sdev_gendev, true); | 194 | device_set_run_wake(&dev->tdev, true); |
194 | acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, true); | 195 | acpi_pm_device_run_wake(&dev->tdev, true); |
195 | } | 196 | } |
196 | 197 | ||
197 | /* Disable runtime wake capability if it is enabled */ | 198 | /* Disable runtime wake capability if it is enabled */ |
@@ -200,8 +201,8 @@ void zpodd_disable_run_wake(struct ata_device *dev) | |||
200 | struct zpodd *zpodd = dev->zpodd; | 201 | struct zpodd *zpodd = dev->zpodd; |
201 | 202 | ||
202 | if (zpodd->powered_off) { | 203 | if (zpodd->powered_off) { |
203 | acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, false); | 204 | acpi_pm_device_run_wake(&dev->tdev, false); |
204 | device_set_run_wake(&dev->sdev->sdev_gendev, false); | 205 | device_set_run_wake(&dev->tdev, false); |
205 | } | 206 | } |
206 | } | 207 | } |
207 | 208 | ||
@@ -262,7 +263,7 @@ static void ata_acpi_add_pm_notifier(struct ata_device *dev) | |||
262 | 263 | ||
263 | static void ata_acpi_remove_pm_notifier(struct ata_device *dev) | 264 | static void ata_acpi_remove_pm_notifier(struct ata_device *dev) |
264 | { | 265 | { |
265 | acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->sdev->sdev_gendev); | 266 | acpi_handle handle = ata_dev_acpi_handle(dev); |
266 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, zpodd_wake_dev); | 267 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, zpodd_wake_dev); |
267 | } | 268 | } |
268 | 269 | ||
@@ -290,6 +291,7 @@ void zpodd_init(struct ata_device *dev) | |||
290 | ata_acpi_add_pm_notifier(dev); | 291 | ata_acpi_add_pm_notifier(dev); |
291 | zpodd->dev = dev; | 292 | zpodd->dev = dev; |
292 | dev->zpodd = zpodd; | 293 | dev->zpodd = zpodd; |
294 | dev_pm_qos_expose_flags(&dev->tdev, 0); | ||
293 | } | 295 | } |
294 | 296 | ||
295 | void zpodd_exit(struct ata_device *dev) | 297 | void zpodd_exit(struct ata_device *dev) |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 577d902bc4de..eeeb77845d48 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -118,11 +118,11 @@ extern void ata_acpi_on_resume(struct ata_port *ap); | |||
118 | extern int ata_acpi_on_devcfg(struct ata_device *dev); | 118 | extern int ata_acpi_on_devcfg(struct ata_device *dev); |
119 | extern void ata_acpi_on_disable(struct ata_device *dev); | 119 | extern void ata_acpi_on_disable(struct ata_device *dev); |
120 | extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state); | 120 | extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state); |
121 | extern int ata_acpi_register(void); | 121 | extern void ata_acpi_bind_port(struct ata_port *ap); |
122 | extern void ata_acpi_unregister(void); | 122 | extern void ata_acpi_bind_dev(struct ata_device *dev); |
123 | extern void ata_acpi_bind(struct ata_device *dev); | 123 | extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev); |
124 | extern void ata_acpi_unbind(struct ata_device *dev); | 124 | extern void ata_scsi_acpi_bind(struct ata_device *dev); |
125 | extern void ata_acpi_hotplug_init(struct ata_host *host); | 125 | extern void ata_scsi_acpi_unbind(struct ata_device *dev); |
126 | #else | 126 | #else |
127 | static inline void ata_acpi_dissociate(struct ata_host *host) { } | 127 | static inline void ata_acpi_dissociate(struct ata_host *host) { } |
128 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } | 128 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } |
@@ -131,11 +131,10 @@ static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; } | |||
131 | static inline void ata_acpi_on_disable(struct ata_device *dev) { } | 131 | static inline void ata_acpi_on_disable(struct ata_device *dev) { } |
132 | static inline void ata_acpi_set_state(struct ata_port *ap, | 132 | static inline void ata_acpi_set_state(struct ata_port *ap, |
133 | pm_message_t state) { } | 133 | pm_message_t state) { } |
134 | static inline int ata_acpi_register(void) { return 0; } | 134 | static inline void ata_acpi_bind_port(struct ata_port *ap) {} |
135 | static inline void ata_acpi_unregister(void) { } | 135 | static inline void ata_acpi_bind_dev(struct ata_device *dev) {} |
136 | static inline void ata_acpi_bind(struct ata_device *dev) { } | 136 | static inline void ata_scsi_acpi_bind(struct ata_device *dev) {} |
137 | static inline void ata_acpi_unbind(struct ata_device *dev) { } | 137 | static inline void ata_scsi_acpi_unbind(struct ata_device *dev) {} |
138 | static inline void ata_acpi_hotplug_init(struct ata_host *host) {} | ||
139 | #endif | 138 | #endif |
140 | 139 | ||
141 | /* libata-scsi.c */ | 140 | /* libata-scsi.c */ |
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c index 09723b76beac..73212c9c6d5b 100644 --- a/drivers/ata/pata_acpi.c +++ b/drivers/ata/pata_acpi.c | |||
@@ -39,7 +39,7 @@ static int pacpi_pre_reset(struct ata_link *link, unsigned long deadline) | |||
39 | { | 39 | { |
40 | struct ata_port *ap = link->ap; | 40 | struct ata_port *ap = link->ap; |
41 | struct pata_acpi *acpi = ap->private_data; | 41 | struct pata_acpi *acpi = ap->private_data; |
42 | if (ata_ap_acpi_handle(ap) == NULL || ata_acpi_gtm(ap, &acpi->gtm) < 0) | 42 | if (ACPI_HANDLE(&ap->tdev) == NULL || ata_acpi_gtm(ap, &acpi->gtm) < 0) |
43 | return -ENODEV; | 43 | return -ENODEV; |
44 | 44 | ||
45 | return ata_sff_prereset(link, deadline); | 45 | return ata_sff_prereset(link, deadline); |
@@ -195,7 +195,7 @@ static int pacpi_port_start(struct ata_port *ap) | |||
195 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 195 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
196 | struct pata_acpi *acpi; | 196 | struct pata_acpi *acpi; |
197 | 197 | ||
198 | if (ata_ap_acpi_handle(ap) == NULL) | 198 | if (ACPI_HANDLE(&ap->tdev) == NULL) |
199 | return -ENODEV; | 199 | return -ENODEV; |
200 | 200 | ||
201 | acpi = ap->private_data = devm_kzalloc(&pdev->dev, sizeof(struct pata_acpi), GFP_KERNEL); | 201 | acpi = ap->private_data = devm_kzalloc(&pdev->dev, sizeof(struct pata_acpi), GFP_KERNEL); |
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index 848ed3254ddd..853f610af28f 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c | |||
@@ -654,7 +654,7 @@ static void arasan_cf_freeze(struct ata_port *ap) | |||
654 | ata_sff_freeze(ap); | 654 | ata_sff_freeze(ap); |
655 | } | 655 | } |
656 | 656 | ||
657 | void arasan_cf_error_handler(struct ata_port *ap) | 657 | static void arasan_cf_error_handler(struct ata_port *ap) |
658 | { | 658 | { |
659 | struct arasan_cf_dev *acdev = ap->host->private_data; | 659 | struct arasan_cf_dev *acdev = ap->host->private_data; |
660 | 660 | ||
@@ -683,7 +683,7 @@ static void arasan_cf_dma_start(struct arasan_cf_dev *acdev) | |||
683 | ata_sff_queue_work(&acdev->work); | 683 | ata_sff_queue_work(&acdev->work); |
684 | } | 684 | } |
685 | 685 | ||
686 | unsigned int arasan_cf_qc_issue(struct ata_queued_cmd *qc) | 686 | static unsigned int arasan_cf_qc_issue(struct ata_queued_cmd *qc) |
687 | { | 687 | { |
688 | struct ata_port *ap = qc->ap; | 688 | struct ata_port *ap = qc->ap; |
689 | struct arasan_cf_dev *acdev = ap->host->private_data; | 689 | struct arasan_cf_dev *acdev = ap->host->private_data; |
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c index 8d493b4a0961..d59d5239405f 100644 --- a/drivers/ata/pata_at32.c +++ b/drivers/ata/pata_at32.c | |||
@@ -271,7 +271,7 @@ static int __init pata_at32_probe(struct platform_device *pdev) | |||
271 | 271 | ||
272 | struct device *dev = &pdev->dev; | 272 | struct device *dev = &pdev->dev; |
273 | struct at32_ide_info *info; | 273 | struct at32_ide_info *info; |
274 | struct ide_platform_data *board = pdev->dev.platform_data; | 274 | struct ide_platform_data *board = dev_get_platdata(&pdev->dev); |
275 | struct resource *res; | 275 | struct resource *res; |
276 | 276 | ||
277 | int irq; | 277 | int irq; |
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c index 5364f97b42c6..d63ee8f41a4f 100644 --- a/drivers/ata/pata_at91.c +++ b/drivers/ata/pata_at91.c | |||
@@ -315,7 +315,7 @@ static struct ata_port_operations pata_at91_port_ops = { | |||
315 | 315 | ||
316 | static int pata_at91_probe(struct platform_device *pdev) | 316 | static int pata_at91_probe(struct platform_device *pdev) |
317 | { | 317 | { |
318 | struct at91_cf_data *board = pdev->dev.platform_data; | 318 | struct at91_cf_data *board = dev_get_platdata(&pdev->dev); |
319 | struct device *dev = &pdev->dev; | 319 | struct device *dev = &pdev->dev; |
320 | struct at91_ide_info *info; | 320 | struct at91_ide_info *info; |
321 | struct resource *mem_res; | 321 | struct resource *mem_res; |
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index dcc6b243e525..1ec53f8ca96f 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -48,7 +48,7 @@ static unsigned int ixp4xx_mmio_data_xfer(struct ata_device *dev, | |||
48 | u16 *buf16 = (u16 *) buf; | 48 | u16 *buf16 = (u16 *) buf; |
49 | struct ata_port *ap = dev->link->ap; | 49 | struct ata_port *ap = dev->link->ap; |
50 | void __iomem *mmio = ap->ioaddr.data_addr; | 50 | void __iomem *mmio = ap->ioaddr.data_addr; |
51 | struct ixp4xx_pata_data *data = ap->host->dev->platform_data; | 51 | struct ixp4xx_pata_data *data = dev_get_platdata(ap->host->dev); |
52 | 52 | ||
53 | /* set the expansion bus in 16bit mode and restore | 53 | /* set the expansion bus in 16bit mode and restore |
54 | * 8 bit mode after the transaction. | 54 | * 8 bit mode after the transaction. |
@@ -143,7 +143,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev) | |||
143 | struct resource *cs0, *cs1; | 143 | struct resource *cs0, *cs1; |
144 | struct ata_host *host; | 144 | struct ata_host *host; |
145 | struct ata_port *ap; | 145 | struct ata_port *ap; |
146 | struct ixp4xx_pata_data *data = pdev->dev.platform_data; | 146 | struct ixp4xx_pata_data *data = dev_get_platdata(&pdev->dev); |
147 | 147 | ||
148 | cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 148 | cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
149 | cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 149 | cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c index e73bef3093d2..c51bbb9ea8e8 100644 --- a/drivers/ata/pata_octeon_cf.c +++ b/drivers/ata/pata_octeon_cf.c | |||
@@ -1037,7 +1037,7 @@ static void octeon_cf_shutdown(struct device *dev) | |||
1037 | union cvmx_mio_boot_dma_cfgx dma_cfg; | 1037 | union cvmx_mio_boot_dma_cfgx dma_cfg; |
1038 | union cvmx_mio_boot_dma_intx dma_int; | 1038 | union cvmx_mio_boot_dma_intx dma_int; |
1039 | 1039 | ||
1040 | struct octeon_cf_port *cf_port = dev->platform_data; | 1040 | struct octeon_cf_port *cf_port = dev_get_platdata(dev); |
1041 | 1041 | ||
1042 | if (cf_port->dma_base) { | 1042 | if (cf_port->dma_base) { |
1043 | /* Stop and clear the dma engine. */ | 1043 | /* Stop and clear the dma engine. */ |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 71e093767f4e..02794885de10 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -180,7 +180,7 @@ static int pata_platform_probe(struct platform_device *pdev) | |||
180 | struct resource *io_res; | 180 | struct resource *io_res; |
181 | struct resource *ctl_res; | 181 | struct resource *ctl_res; |
182 | struct resource *irq_res; | 182 | struct resource *irq_res; |
183 | struct pata_platform_info *pp_info = pdev->dev.platform_data; | 183 | struct pata_platform_info *pp_info = dev_get_platdata(&pdev->dev); |
184 | 184 | ||
185 | /* | 185 | /* |
186 | * Simple resource validation .. | 186 | * Simple resource validation .. |
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c index 942ef94b29e6..a6f05acad61e 100644 --- a/drivers/ata/pata_pxa.c +++ b/drivers/ata/pata_pxa.c | |||
@@ -238,7 +238,7 @@ static int pxa_ata_probe(struct platform_device *pdev) | |||
238 | struct resource *ctl_res; | 238 | struct resource *ctl_res; |
239 | struct resource *dma_res; | 239 | struct resource *dma_res; |
240 | struct resource *irq_res; | 240 | struct resource *irq_res; |
241 | struct pata_pxa_pdata *pdata = pdev->dev.platform_data; | 241 | struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev); |
242 | int ret = 0; | 242 | int ret = 0; |
243 | 243 | ||
244 | /* | 244 | /* |
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c index 6ef27e98c508..898e544a7ae8 100644 --- a/drivers/ata/pata_samsung_cf.c +++ b/drivers/ata/pata_samsung_cf.c | |||
@@ -241,8 +241,8 @@ static u8 pata_s3c_check_altstatus(struct ata_port *ap) | |||
241 | /* | 241 | /* |
242 | * pata_s3c_data_xfer - Transfer data by PIO | 242 | * pata_s3c_data_xfer - Transfer data by PIO |
243 | */ | 243 | */ |
244 | unsigned int pata_s3c_data_xfer(struct ata_device *dev, unsigned char *buf, | 244 | static unsigned int pata_s3c_data_xfer(struct ata_device *dev, |
245 | unsigned int buflen, int rw) | 245 | unsigned char *buf, unsigned int buflen, int rw) |
246 | { | 246 | { |
247 | struct ata_port *ap = dev->link->ap; | 247 | struct ata_port *ap = dev->link->ap; |
248 | struct s3c_ide_info *info = ap->host->private_data; | 248 | struct s3c_ide_info *info = ap->host->private_data; |
@@ -418,7 +418,7 @@ static struct ata_port_operations pata_s5p_port_ops = { | |||
418 | .set_piomode = pata_s3c_set_piomode, | 418 | .set_piomode = pata_s3c_set_piomode, |
419 | }; | 419 | }; |
420 | 420 | ||
421 | static void pata_s3c_enable(void *s3c_ide_regbase, bool state) | 421 | static void pata_s3c_enable(void __iomem *s3c_ide_regbase, bool state) |
422 | { | 422 | { |
423 | u32 temp = readl(s3c_ide_regbase + S3C_ATA_CTRL); | 423 | u32 temp = readl(s3c_ide_regbase + S3C_ATA_CTRL); |
424 | temp = state ? (temp | 1) : (temp & ~1); | 424 | temp = state ? (temp | 1) : (temp & ~1); |
@@ -475,7 +475,7 @@ static void pata_s3c_hwinit(struct s3c_ide_info *info, | |||
475 | 475 | ||
476 | static int __init pata_s3c_probe(struct platform_device *pdev) | 476 | static int __init pata_s3c_probe(struct platform_device *pdev) |
477 | { | 477 | { |
478 | struct s3c_ide_platdata *pdata = pdev->dev.platform_data; | 478 | struct s3c_ide_platdata *pdata = dev_get_platdata(&pdev->dev); |
479 | struct device *dev = &pdev->dev; | 479 | struct device *dev = &pdev->dev; |
480 | struct s3c_ide_info *info; | 480 | struct s3c_ide_info *info; |
481 | struct resource *res; | 481 | struct resource *res; |
@@ -617,7 +617,7 @@ static int pata_s3c_resume(struct device *dev) | |||
617 | { | 617 | { |
618 | struct platform_device *pdev = to_platform_device(dev); | 618 | struct platform_device *pdev = to_platform_device(dev); |
619 | struct ata_host *host = platform_get_drvdata(pdev); | 619 | struct ata_host *host = platform_get_drvdata(pdev); |
620 | struct s3c_ide_platdata *pdata = pdev->dev.platform_data; | 620 | struct s3c_ide_platdata *pdata = dev_get_platdata(&pdev->dev); |
621 | struct s3c_ide_info *info = host->private_data; | 621 | struct s3c_ide_info *info = host->private_data; |
622 | 622 | ||
623 | pata_s3c_hwinit(info, pdata); | 623 | pata_s3c_hwinit(info, pdata); |
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c index e9a4f46d962e..7f5e5d96327f 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c | |||
@@ -46,14 +46,19 @@ | |||
46 | #define CR_BUSY 0x0001 | 46 | #define CR_BUSY 0x0001 |
47 | #define CR_START 0x0001 | 47 | #define CR_START 0x0001 |
48 | #define CR_WR_RDN 0x0002 | 48 | #define CR_WR_RDN 0x0002 |
49 | #define CPHY_TX_INPUT_STS 0x2001 | ||
49 | #define CPHY_RX_INPUT_STS 0x2002 | 50 | #define CPHY_RX_INPUT_STS 0x2002 |
50 | #define CPHY_SATA_OVERRIDE 0x4000 | 51 | #define CPHY_SATA_TX_OVERRIDE 0x8000 |
51 | #define CPHY_OVERRIDE 0x2005 | 52 | #define CPHY_SATA_RX_OVERRIDE 0x4000 |
53 | #define CPHY_TX_OVERRIDE 0x2004 | ||
54 | #define CPHY_RX_OVERRIDE 0x2005 | ||
52 | #define SPHY_LANE 0x100 | 55 | #define SPHY_LANE 0x100 |
53 | #define SPHY_HALF_RATE 0x0001 | 56 | #define SPHY_HALF_RATE 0x0001 |
54 | #define CPHY_SATA_DPLL_MODE 0x0700 | 57 | #define CPHY_SATA_DPLL_MODE 0x0700 |
55 | #define CPHY_SATA_DPLL_SHIFT 8 | 58 | #define CPHY_SATA_DPLL_SHIFT 8 |
56 | #define CPHY_SATA_DPLL_RESET (1 << 11) | 59 | #define CPHY_SATA_DPLL_RESET (1 << 11) |
60 | #define CPHY_SATA_TX_ATTEN 0x1c00 | ||
61 | #define CPHY_SATA_TX_ATTEN_SHIFT 10 | ||
57 | #define CPHY_PHY_COUNT 6 | 62 | #define CPHY_PHY_COUNT 6 |
58 | #define CPHY_LANE_COUNT 4 | 63 | #define CPHY_LANE_COUNT 4 |
59 | #define CPHY_PORT_COUNT (CPHY_PHY_COUNT * CPHY_LANE_COUNT) | 64 | #define CPHY_PORT_COUNT (CPHY_PHY_COUNT * CPHY_LANE_COUNT) |
@@ -66,6 +71,7 @@ struct phy_lane_info { | |||
66 | void __iomem *phy_base; | 71 | void __iomem *phy_base; |
67 | u8 lane_mapping; | 72 | u8 lane_mapping; |
68 | u8 phy_devs; | 73 | u8 phy_devs; |
74 | u8 tx_atten; | ||
69 | }; | 75 | }; |
70 | static struct phy_lane_info port_data[CPHY_PORT_COUNT]; | 76 | static struct phy_lane_info port_data[CPHY_PORT_COUNT]; |
71 | 77 | ||
@@ -76,9 +82,11 @@ static DEFINE_SPINLOCK(sgpio_lock); | |||
76 | #define SGPIO_PINS 3 | 82 | #define SGPIO_PINS 3 |
77 | #define SGPIO_PORTS 8 | 83 | #define SGPIO_PORTS 8 |
78 | 84 | ||
79 | /* can be cast as an ahci_host_priv for compatibility with most functions */ | ||
80 | struct ecx_plat_data { | 85 | struct ecx_plat_data { |
81 | u32 n_ports; | 86 | u32 n_ports; |
87 | /* number of extra clocks that the SGPIO PIC controller expects */ | ||
88 | u32 pre_clocks; | ||
89 | u32 post_clocks; | ||
82 | unsigned sgpio_gpio[SGPIO_PINS]; | 90 | unsigned sgpio_gpio[SGPIO_PINS]; |
83 | u32 sgpio_pattern; | 91 | u32 sgpio_pattern; |
84 | u32 port_to_sgpio[SGPIO_PORTS]; | 92 | u32 port_to_sgpio[SGPIO_PORTS]; |
@@ -155,6 +163,9 @@ static ssize_t ecx_transmit_led_message(struct ata_port *ap, u32 state, | |||
155 | spin_lock_irqsave(&sgpio_lock, flags); | 163 | spin_lock_irqsave(&sgpio_lock, flags); |
156 | ecx_parse_sgpio(pdata, ap->port_no, state); | 164 | ecx_parse_sgpio(pdata, ap->port_no, state); |
157 | sgpio_out = pdata->sgpio_pattern; | 165 | sgpio_out = pdata->sgpio_pattern; |
166 | for (i = 0; i < pdata->pre_clocks; i++) | ||
167 | ecx_led_cycle_clock(pdata); | ||
168 | |||
158 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); | 169 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); |
159 | ecx_led_cycle_clock(pdata); | 170 | ecx_led_cycle_clock(pdata); |
160 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); | 171 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); |
@@ -167,6 +178,8 @@ static ssize_t ecx_transmit_led_message(struct ata_port *ap, u32 state, | |||
167 | sgpio_out >>= 1; | 178 | sgpio_out >>= 1; |
168 | ecx_led_cycle_clock(pdata); | 179 | ecx_led_cycle_clock(pdata); |
169 | } | 180 | } |
181 | for (i = 0; i < pdata->post_clocks; i++) | ||
182 | ecx_led_cycle_clock(pdata); | ||
170 | 183 | ||
171 | /* save off new led state for port/slot */ | 184 | /* save off new led state for port/slot */ |
172 | emp->led_state = state; | 185 | emp->led_state = state; |
@@ -201,6 +214,11 @@ static void highbank_set_em_messages(struct device *dev, | |||
201 | of_property_read_u32_array(np, "calxeda,led-order", | 214 | of_property_read_u32_array(np, "calxeda,led-order", |
202 | pdata->port_to_sgpio, | 215 | pdata->port_to_sgpio, |
203 | pdata->n_ports); | 216 | pdata->n_ports); |
217 | if (of_property_read_u32(np, "calxeda,pre-clocks", &pdata->pre_clocks)) | ||
218 | pdata->pre_clocks = 0; | ||
219 | if (of_property_read_u32(np, "calxeda,post-clocks", | ||
220 | &pdata->post_clocks)) | ||
221 | pdata->post_clocks = 0; | ||
204 | 222 | ||
205 | /* store em_loc */ | 223 | /* store em_loc */ |
206 | hpriv->em_loc = 0; | 224 | hpriv->em_loc = 0; |
@@ -259,8 +277,27 @@ static void highbank_cphy_disable_overrides(u8 sata_port) | |||
259 | if (unlikely(port_data[sata_port].phy_base == NULL)) | 277 | if (unlikely(port_data[sata_port].phy_base == NULL)) |
260 | return; | 278 | return; |
261 | tmp = combo_phy_read(sata_port, CPHY_RX_INPUT_STS + lane * SPHY_LANE); | 279 | tmp = combo_phy_read(sata_port, CPHY_RX_INPUT_STS + lane * SPHY_LANE); |
262 | tmp &= ~CPHY_SATA_OVERRIDE; | 280 | tmp &= ~CPHY_SATA_RX_OVERRIDE; |
263 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 281 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
282 | } | ||
283 | |||
284 | static void cphy_override_tx_attenuation(u8 sata_port, u32 val) | ||
285 | { | ||
286 | u8 lane = port_data[sata_port].lane_mapping; | ||
287 | u32 tmp; | ||
288 | |||
289 | if (val & 0x8) | ||
290 | return; | ||
291 | |||
292 | tmp = combo_phy_read(sata_port, CPHY_TX_INPUT_STS + lane * SPHY_LANE); | ||
293 | tmp &= ~CPHY_SATA_TX_OVERRIDE; | ||
294 | combo_phy_write(sata_port, CPHY_TX_OVERRIDE + lane * SPHY_LANE, tmp); | ||
295 | |||
296 | tmp |= CPHY_SATA_TX_OVERRIDE; | ||
297 | combo_phy_write(sata_port, CPHY_TX_OVERRIDE + lane * SPHY_LANE, tmp); | ||
298 | |||
299 | tmp |= (val << CPHY_SATA_TX_ATTEN_SHIFT) & CPHY_SATA_TX_ATTEN; | ||
300 | combo_phy_write(sata_port, CPHY_TX_OVERRIDE + lane * SPHY_LANE, tmp); | ||
264 | } | 301 | } |
265 | 302 | ||
266 | static void cphy_override_rx_mode(u8 sata_port, u32 val) | 303 | static void cphy_override_rx_mode(u8 sata_port, u32 val) |
@@ -268,21 +305,21 @@ static void cphy_override_rx_mode(u8 sata_port, u32 val) | |||
268 | u8 lane = port_data[sata_port].lane_mapping; | 305 | u8 lane = port_data[sata_port].lane_mapping; |
269 | u32 tmp; | 306 | u32 tmp; |
270 | tmp = combo_phy_read(sata_port, CPHY_RX_INPUT_STS + lane * SPHY_LANE); | 307 | tmp = combo_phy_read(sata_port, CPHY_RX_INPUT_STS + lane * SPHY_LANE); |
271 | tmp &= ~CPHY_SATA_OVERRIDE; | 308 | tmp &= ~CPHY_SATA_RX_OVERRIDE; |
272 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 309 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
273 | 310 | ||
274 | tmp |= CPHY_SATA_OVERRIDE; | 311 | tmp |= CPHY_SATA_RX_OVERRIDE; |
275 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 312 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
276 | 313 | ||
277 | tmp &= ~CPHY_SATA_DPLL_MODE; | 314 | tmp &= ~CPHY_SATA_DPLL_MODE; |
278 | tmp |= val << CPHY_SATA_DPLL_SHIFT; | 315 | tmp |= val << CPHY_SATA_DPLL_SHIFT; |
279 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 316 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
280 | 317 | ||
281 | tmp |= CPHY_SATA_DPLL_RESET; | 318 | tmp |= CPHY_SATA_DPLL_RESET; |
282 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 319 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
283 | 320 | ||
284 | tmp &= ~CPHY_SATA_DPLL_RESET; | 321 | tmp &= ~CPHY_SATA_DPLL_RESET; |
285 | combo_phy_write(sata_port, CPHY_OVERRIDE + lane * SPHY_LANE, tmp); | 322 | combo_phy_write(sata_port, CPHY_RX_OVERRIDE + lane * SPHY_LANE, tmp); |
286 | 323 | ||
287 | msleep(15); | 324 | msleep(15); |
288 | } | 325 | } |
@@ -299,16 +336,20 @@ static void highbank_cphy_override_lane(u8 sata_port) | |||
299 | lane * SPHY_LANE); | 336 | lane * SPHY_LANE); |
300 | } while ((tmp & SPHY_HALF_RATE) && (k++ < 1000)); | 337 | } while ((tmp & SPHY_HALF_RATE) && (k++ < 1000)); |
301 | cphy_override_rx_mode(sata_port, 3); | 338 | cphy_override_rx_mode(sata_port, 3); |
339 | cphy_override_tx_attenuation(sata_port, port_data[sata_port].tx_atten); | ||
302 | } | 340 | } |
303 | 341 | ||
304 | static int highbank_initialize_phys(struct device *dev, void __iomem *addr) | 342 | static int highbank_initialize_phys(struct device *dev, void __iomem *addr) |
305 | { | 343 | { |
306 | struct device_node *sata_node = dev->of_node; | 344 | struct device_node *sata_node = dev->of_node; |
307 | int phy_count = 0, phy, port = 0; | 345 | int phy_count = 0, phy, port = 0, i; |
308 | void __iomem *cphy_base[CPHY_PHY_COUNT]; | 346 | void __iomem *cphy_base[CPHY_PHY_COUNT]; |
309 | struct device_node *phy_nodes[CPHY_PHY_COUNT]; | 347 | struct device_node *phy_nodes[CPHY_PHY_COUNT]; |
348 | u32 tx_atten[CPHY_PORT_COUNT]; | ||
349 | |||
310 | memset(port_data, 0, sizeof(struct phy_lane_info) * CPHY_PORT_COUNT); | 350 | memset(port_data, 0, sizeof(struct phy_lane_info) * CPHY_PORT_COUNT); |
311 | memset(phy_nodes, 0, sizeof(struct device_node*) * CPHY_PHY_COUNT); | 351 | memset(phy_nodes, 0, sizeof(struct device_node*) * CPHY_PHY_COUNT); |
352 | memset(tx_atten, 0xff, CPHY_PORT_COUNT); | ||
312 | 353 | ||
313 | do { | 354 | do { |
314 | u32 tmp; | 355 | u32 tmp; |
@@ -336,6 +377,10 @@ static int highbank_initialize_phys(struct device *dev, void __iomem *addr) | |||
336 | of_node_put(phy_data.np); | 377 | of_node_put(phy_data.np); |
337 | port += 1; | 378 | port += 1; |
338 | } while (port < CPHY_PORT_COUNT); | 379 | } while (port < CPHY_PORT_COUNT); |
380 | of_property_read_u32_array(sata_node, "calxeda,tx-atten", | ||
381 | tx_atten, port); | ||
382 | for (i = 0; i < port; i++) | ||
383 | port_data[i].tx_atten = (u8) tx_atten[i]; | ||
339 | return 0; | 384 | return 0; |
340 | } | 385 | } |
341 | 386 | ||
@@ -479,6 +524,9 @@ static int ahci_highbank_probe(struct platform_device *pdev) | |||
479 | if (hpriv->cap & HOST_CAP_PMP) | 524 | if (hpriv->cap & HOST_CAP_PMP) |
480 | pi.flags |= ATA_FLAG_PMP; | 525 | pi.flags |= ATA_FLAG_PMP; |
481 | 526 | ||
527 | if (hpriv->cap & HOST_CAP_64) | ||
528 | dma_set_coherent_mask(dev, DMA_BIT_MASK(64)); | ||
529 | |||
482 | /* CAP.NP sometimes indicate the index of the last enabled | 530 | /* CAP.NP sometimes indicate the index of the last enabled |
483 | * port, at other times, that of the last possible port, so | 531 | * port, at other times, that of the last possible port, so |
484 | * determining the maximum port number requires looking at | 532 | * determining the maximum port number requires looking at |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 35c6b6d09c27..56be31819897 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -553,10 +553,15 @@ struct mv_host_priv { | |||
553 | u32 irq_mask_offset; | 553 | u32 irq_mask_offset; |
554 | u32 unmask_all_irqs; | 554 | u32 unmask_all_irqs; |
555 | 555 | ||
556 | #if defined(CONFIG_HAVE_CLK) | 556 | /* |
557 | * Needed on some devices that require their clocks to be enabled. | ||
558 | * These are optional: if the platform device does not have any | ||
559 | * clocks, they won't be used. Also, if the underlying hardware | ||
560 | * does not support the common clock framework (CONFIG_HAVE_CLK=n), | ||
561 | * all the clock operations become no-ops (see clk.h). | ||
562 | */ | ||
557 | struct clk *clk; | 563 | struct clk *clk; |
558 | struct clk **port_clks; | 564 | struct clk **port_clks; |
559 | #endif | ||
560 | /* | 565 | /* |
561 | * These consistent DMA memory pools give us guaranteed | 566 | * These consistent DMA memory pools give us guaranteed |
562 | * alignment for hardware-accessed data structures, | 567 | * alignment for hardware-accessed data structures, |
@@ -4032,9 +4037,7 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4032 | struct resource *res; | 4037 | struct resource *res; |
4033 | int n_ports = 0, irq = 0; | 4038 | int n_ports = 0, irq = 0; |
4034 | int rc; | 4039 | int rc; |
4035 | #if defined(CONFIG_HAVE_CLK) | ||
4036 | int port; | 4040 | int port; |
4037 | #endif | ||
4038 | 4041 | ||
4039 | ata_print_version_once(&pdev->dev, DRV_VERSION); | 4042 | ata_print_version_once(&pdev->dev, DRV_VERSION); |
4040 | 4043 | ||
@@ -4058,7 +4061,7 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4058 | of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports); | 4061 | of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports); |
4059 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | 4062 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); |
4060 | } else { | 4063 | } else { |
4061 | mv_platform_data = pdev->dev.platform_data; | 4064 | mv_platform_data = dev_get_platdata(&pdev->dev); |
4062 | n_ports = mv_platform_data->n_ports; | 4065 | n_ports = mv_platform_data->n_ports; |
4063 | irq = platform_get_irq(pdev, 0); | 4066 | irq = platform_get_irq(pdev, 0); |
4064 | } | 4067 | } |
@@ -4068,13 +4071,11 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4068 | 4071 | ||
4069 | if (!host || !hpriv) | 4072 | if (!host || !hpriv) |
4070 | return -ENOMEM; | 4073 | return -ENOMEM; |
4071 | #if defined(CONFIG_HAVE_CLK) | ||
4072 | hpriv->port_clks = devm_kzalloc(&pdev->dev, | 4074 | hpriv->port_clks = devm_kzalloc(&pdev->dev, |
4073 | sizeof(struct clk *) * n_ports, | 4075 | sizeof(struct clk *) * n_ports, |
4074 | GFP_KERNEL); | 4076 | GFP_KERNEL); |
4075 | if (!hpriv->port_clks) | 4077 | if (!hpriv->port_clks) |
4076 | return -ENOMEM; | 4078 | return -ENOMEM; |
4077 | #endif | ||
4078 | host->private_data = hpriv; | 4079 | host->private_data = hpriv; |
4079 | hpriv->n_ports = n_ports; | 4080 | hpriv->n_ports = n_ports; |
4080 | hpriv->board_idx = chip_soc; | 4081 | hpriv->board_idx = chip_soc; |
@@ -4084,7 +4085,6 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4084 | resource_size(res)); | 4085 | resource_size(res)); |
4085 | hpriv->base -= SATAHC0_REG_BASE; | 4086 | hpriv->base -= SATAHC0_REG_BASE; |
4086 | 4087 | ||
4087 | #if defined(CONFIG_HAVE_CLK) | ||
4088 | hpriv->clk = clk_get(&pdev->dev, NULL); | 4088 | hpriv->clk = clk_get(&pdev->dev, NULL); |
4089 | if (IS_ERR(hpriv->clk)) | 4089 | if (IS_ERR(hpriv->clk)) |
4090 | dev_notice(&pdev->dev, "cannot get optional clkdev\n"); | 4090 | dev_notice(&pdev->dev, "cannot get optional clkdev\n"); |
@@ -4098,7 +4098,6 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4098 | if (!IS_ERR(hpriv->port_clks[port])) | 4098 | if (!IS_ERR(hpriv->port_clks[port])) |
4099 | clk_prepare_enable(hpriv->port_clks[port]); | 4099 | clk_prepare_enable(hpriv->port_clks[port]); |
4100 | } | 4100 | } |
4101 | #endif | ||
4102 | 4101 | ||
4103 | /* | 4102 | /* |
4104 | * (Re-)program MBUS remapping windows if we are asked to. | 4103 | * (Re-)program MBUS remapping windows if we are asked to. |
@@ -4124,7 +4123,6 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4124 | return 0; | 4123 | return 0; |
4125 | 4124 | ||
4126 | err: | 4125 | err: |
4127 | #if defined(CONFIG_HAVE_CLK) | ||
4128 | if (!IS_ERR(hpriv->clk)) { | 4126 | if (!IS_ERR(hpriv->clk)) { |
4129 | clk_disable_unprepare(hpriv->clk); | 4127 | clk_disable_unprepare(hpriv->clk); |
4130 | clk_put(hpriv->clk); | 4128 | clk_put(hpriv->clk); |
@@ -4135,7 +4133,6 @@ err: | |||
4135 | clk_put(hpriv->port_clks[port]); | 4133 | clk_put(hpriv->port_clks[port]); |
4136 | } | 4134 | } |
4137 | } | 4135 | } |
4138 | #endif | ||
4139 | 4136 | ||
4140 | return rc; | 4137 | return rc; |
4141 | } | 4138 | } |
@@ -4151,13 +4148,10 @@ err: | |||
4151 | static int mv_platform_remove(struct platform_device *pdev) | 4148 | static int mv_platform_remove(struct platform_device *pdev) |
4152 | { | 4149 | { |
4153 | struct ata_host *host = platform_get_drvdata(pdev); | 4150 | struct ata_host *host = platform_get_drvdata(pdev); |
4154 | #if defined(CONFIG_HAVE_CLK) | ||
4155 | struct mv_host_priv *hpriv = host->private_data; | 4151 | struct mv_host_priv *hpriv = host->private_data; |
4156 | int port; | 4152 | int port; |
4157 | #endif | ||
4158 | ata_host_detach(host); | 4153 | ata_host_detach(host); |
4159 | 4154 | ||
4160 | #if defined(CONFIG_HAVE_CLK) | ||
4161 | if (!IS_ERR(hpriv->clk)) { | 4155 | if (!IS_ERR(hpriv->clk)) { |
4162 | clk_disable_unprepare(hpriv->clk); | 4156 | clk_disable_unprepare(hpriv->clk); |
4163 | clk_put(hpriv->clk); | 4157 | clk_put(hpriv->clk); |
@@ -4168,7 +4162,6 @@ static int mv_platform_remove(struct platform_device *pdev) | |||
4168 | clk_put(hpriv->port_clks[port]); | 4162 | clk_put(hpriv->port_clks[port]); |
4169 | } | 4163 | } |
4170 | } | 4164 | } |
4171 | #endif | ||
4172 | return 0; | 4165 | return 0; |
4173 | } | 4166 | } |
4174 | 4167 | ||
@@ -4428,9 +4421,6 @@ static int mv_pci_device_resume(struct pci_dev *pdev) | |||
4428 | #endif | 4421 | #endif |
4429 | #endif | 4422 | #endif |
4430 | 4423 | ||
4431 | static int mv_platform_probe(struct platform_device *pdev); | ||
4432 | static int mv_platform_remove(struct platform_device *pdev); | ||
4433 | |||
4434 | static int __init mv_init(void) | 4424 | static int __init mv_init(void) |
4435 | { | 4425 | { |
4436 | int rc = -ENODEV; | 4426 | int rc = -ENODEV; |
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 8108eb065444..c2d95e9fb971 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c | |||
@@ -778,10 +778,6 @@ static int sata_rcar_probe(struct platform_device *pdev) | |||
778 | int irq; | 778 | int irq; |
779 | int ret = 0; | 779 | int ret = 0; |
780 | 780 | ||
781 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
782 | if (mem == NULL) | ||
783 | return -EINVAL; | ||
784 | |||
785 | irq = platform_get_irq(pdev, 0); | 781 | irq = platform_get_irq(pdev, 0); |
786 | if (irq <= 0) | 782 | if (irq <= 0) |
787 | return -EINVAL; | 783 | return -EINVAL; |
@@ -807,6 +803,7 @@ static int sata_rcar_probe(struct platform_device *pdev) | |||
807 | 803 | ||
808 | host->private_data = priv; | 804 | host->private_data = priv; |
809 | 805 | ||
806 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
810 | priv->base = devm_ioremap_resource(&pdev->dev, mem); | 807 | priv->base = devm_ioremap_resource(&pdev->dev, mem); |
811 | if (IS_ERR(priv->base)) { | 808 | if (IS_ERR(priv->base)) { |
812 | ret = PTR_ERR(priv->base); | 809 | ret = PTR_ERR(priv->base); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d545931c85eb..d1549b74e2d1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -68,28 +68,6 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = { | |||
68 | 68 | ||
69 | struct kmem_cache *scsi_sdb_cache; | 69 | struct kmem_cache *scsi_sdb_cache; |
70 | 70 | ||
71 | #ifdef CONFIG_ACPI | ||
72 | #include <acpi/acpi_bus.h> | ||
73 | |||
74 | static bool acpi_scsi_bus_match(struct device *dev) | ||
75 | { | ||
76 | return dev->bus == &scsi_bus_type; | ||
77 | } | ||
78 | |||
79 | int scsi_register_acpi_bus_type(struct acpi_bus_type *bus) | ||
80 | { | ||
81 | bus->match = acpi_scsi_bus_match; | ||
82 | return register_acpi_bus_type(bus); | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type); | ||
85 | |||
86 | void scsi_unregister_acpi_bus_type(struct acpi_bus_type *bus) | ||
87 | { | ||
88 | unregister_acpi_bus_type(bus); | ||
89 | } | ||
90 | EXPORT_SYMBOL_GPL(scsi_unregister_acpi_bus_type); | ||
91 | #endif | ||
92 | |||
93 | /* | 71 | /* |
94 | * When to reinvoke queueing after a resource shortage. It's 3 msecs to | 72 | * When to reinvoke queueing after a resource shortage. It's 3 msecs to |
95 | * not change behaviour from the previous unplug mechanism, experimentation | 73 | * not change behaviour from the previous unplug mechanism, experimentation |
diff --git a/include/linux/ata.h b/include/linux/ata.h index ee0bd9524055..bf4c69ca76df 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -239,6 +239,8 @@ enum { | |||
239 | ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E, | 239 | ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E, |
240 | ATA_CMD_FPDMA_READ = 0x60, | 240 | ATA_CMD_FPDMA_READ = 0x60, |
241 | ATA_CMD_FPDMA_WRITE = 0x61, | 241 | ATA_CMD_FPDMA_WRITE = 0x61, |
242 | ATA_CMD_FPDMA_SEND = 0x64, | ||
243 | ATA_CMD_FPDMA_RECV = 0x65, | ||
242 | ATA_CMD_PIO_READ = 0x20, | 244 | ATA_CMD_PIO_READ = 0x20, |
243 | ATA_CMD_PIO_READ_EXT = 0x24, | 245 | ATA_CMD_PIO_READ_EXT = 0x24, |
244 | ATA_CMD_PIO_WRITE = 0x30, | 246 | ATA_CMD_PIO_WRITE = 0x30, |
@@ -293,8 +295,13 @@ enum { | |||
293 | /* marked obsolete in the ATA/ATAPI-7 spec */ | 295 | /* marked obsolete in the ATA/ATAPI-7 spec */ |
294 | ATA_CMD_RESTORE = 0x10, | 296 | ATA_CMD_RESTORE = 0x10, |
295 | 297 | ||
298 | /* Subcmds for ATA_CMD_FPDMA_SEND */ | ||
299 | ATA_SUBCMD_FPDMA_SEND_DSM = 0x00, | ||
300 | ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02, | ||
301 | |||
296 | /* READ_LOG_EXT pages */ | 302 | /* READ_LOG_EXT pages */ |
297 | ATA_LOG_SATA_NCQ = 0x10, | 303 | ATA_LOG_SATA_NCQ = 0x10, |
304 | ATA_LOG_NCQ_SEND_RECV = 0x13, | ||
298 | ATA_LOG_SATA_ID_DEV_DATA = 0x30, | 305 | ATA_LOG_SATA_ID_DEV_DATA = 0x30, |
299 | ATA_LOG_SATA_SETTINGS = 0x08, | 306 | ATA_LOG_SATA_SETTINGS = 0x08, |
300 | ATA_LOG_DEVSLP_OFFSET = 0x30, | 307 | ATA_LOG_DEVSLP_OFFSET = 0x30, |
@@ -305,6 +312,15 @@ enum { | |||
305 | ATA_LOG_DEVSLP_VALID = 0x07, | 312 | ATA_LOG_DEVSLP_VALID = 0x07, |
306 | ATA_LOG_DEVSLP_VALID_MASK = 0x80, | 313 | ATA_LOG_DEVSLP_VALID_MASK = 0x80, |
307 | 314 | ||
315 | /* NCQ send and receive log */ | ||
316 | ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0x00, | ||
317 | ATA_LOG_NCQ_SEND_RECV_SUBCMDS_DSM = (1 << 0), | ||
318 | ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET = 0x04, | ||
319 | ATA_LOG_NCQ_SEND_RECV_DSM_TRIM = (1 << 0), | ||
320 | ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET = 0x08, | ||
321 | ATA_LOG_NCQ_SEND_RECV_WR_LOG_OFFSET = 0x0C, | ||
322 | ATA_LOG_NCQ_SEND_RECV_SIZE = 0x10, | ||
323 | |||
308 | /* READ/WRITE LONG (obsolete) */ | 324 | /* READ/WRITE LONG (obsolete) */ |
309 | ATA_CMD_READ_LONG = 0x22, | 325 | ATA_CMD_READ_LONG = 0x22, |
310 | ATA_CMD_READ_LONG_ONCE = 0x23, | 326 | ATA_CMD_READ_LONG_ONCE = 0x23, |
@@ -446,22 +462,6 @@ enum { | |||
446 | SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */ | 462 | SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */ |
447 | SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */ | 463 | SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */ |
448 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ | 464 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ |
449 | |||
450 | /* struct ata_taskfile flags */ | ||
451 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ | ||
452 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ | ||
453 | ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */ | ||
454 | ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ | ||
455 | ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ | ||
456 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ | ||
457 | ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ | ||
458 | |||
459 | /* protocol flags */ | ||
460 | ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */ | ||
461 | ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */ | ||
462 | ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA, | ||
463 | ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */ | ||
464 | ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */ | ||
465 | }; | 465 | }; |
466 | 466 | ||
467 | enum ata_tf_protocols { | 467 | enum ata_tf_protocols { |
@@ -488,83 +488,6 @@ struct ata_bmdma_prd { | |||
488 | __le32 flags_len; | 488 | __le32 flags_len; |
489 | }; | 489 | }; |
490 | 490 | ||
491 | struct ata_taskfile { | ||
492 | unsigned long flags; /* ATA_TFLAG_xxx */ | ||
493 | u8 protocol; /* ATA_PROT_xxx */ | ||
494 | |||
495 | u8 ctl; /* control reg */ | ||
496 | |||
497 | u8 hob_feature; /* additional data */ | ||
498 | u8 hob_nsect; /* to support LBA48 */ | ||
499 | u8 hob_lbal; | ||
500 | u8 hob_lbam; | ||
501 | u8 hob_lbah; | ||
502 | |||
503 | u8 feature; | ||
504 | u8 nsect; | ||
505 | u8 lbal; | ||
506 | u8 lbam; | ||
507 | u8 lbah; | ||
508 | |||
509 | u8 device; | ||
510 | |||
511 | u8 command; /* IO operation */ | ||
512 | }; | ||
513 | |||
514 | /* | ||
515 | * protocol tests | ||
516 | */ | ||
517 | static inline unsigned int ata_prot_flags(u8 prot) | ||
518 | { | ||
519 | switch (prot) { | ||
520 | case ATA_PROT_NODATA: | ||
521 | return 0; | ||
522 | case ATA_PROT_PIO: | ||
523 | return ATA_PROT_FLAG_PIO; | ||
524 | case ATA_PROT_DMA: | ||
525 | return ATA_PROT_FLAG_DMA; | ||
526 | case ATA_PROT_NCQ: | ||
527 | return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ; | ||
528 | case ATAPI_PROT_NODATA: | ||
529 | return ATA_PROT_FLAG_ATAPI; | ||
530 | case ATAPI_PROT_PIO: | ||
531 | return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO; | ||
532 | case ATAPI_PROT_DMA: | ||
533 | return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA; | ||
534 | } | ||
535 | return 0; | ||
536 | } | ||
537 | |||
538 | static inline int ata_is_atapi(u8 prot) | ||
539 | { | ||
540 | return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI; | ||
541 | } | ||
542 | |||
543 | static inline int ata_is_nodata(u8 prot) | ||
544 | { | ||
545 | return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA); | ||
546 | } | ||
547 | |||
548 | static inline int ata_is_pio(u8 prot) | ||
549 | { | ||
550 | return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; | ||
551 | } | ||
552 | |||
553 | static inline int ata_is_dma(u8 prot) | ||
554 | { | ||
555 | return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA; | ||
556 | } | ||
557 | |||
558 | static inline int ata_is_ncq(u8 prot) | ||
559 | { | ||
560 | return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ; | ||
561 | } | ||
562 | |||
563 | static inline int ata_is_data(u8 prot) | ||
564 | { | ||
565 | return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA; | ||
566 | } | ||
567 | |||
568 | /* | 491 | /* |
569 | * id tests | 492 | * id tests |
570 | */ | 493 | */ |
@@ -865,6 +788,11 @@ static inline int ata_id_rotation_rate(const u16 *id) | |||
865 | return val; | 788 | return val; |
866 | } | 789 | } |
867 | 790 | ||
791 | static inline bool ata_id_has_ncq_send_and_recv(const u16 *id) | ||
792 | { | ||
793 | return id[ATA_ID_SATA_CAPABILITY_2] & BIT(6); | ||
794 | } | ||
795 | |||
868 | static inline bool ata_id_has_trim(const u16 *id) | 796 | static inline bool ata_id_has_trim(const u16 *id) |
869 | { | 797 | { |
870 | if (ata_id_major_version(id) >= 7 && | 798 | if (ata_id_major_version(id) >= 7 && |
@@ -1060,15 +988,6 @@ static inline unsigned ata_set_lba_range_entries(void *_buffer, | |||
1060 | return used_bytes; | 988 | return used_bytes; |
1061 | } | 989 | } |
1062 | 990 | ||
1063 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | ||
1064 | { | ||
1065 | return (tf->command == ATA_CMD_READ_MULTI) || | ||
1066 | (tf->command == ATA_CMD_WRITE_MULTI) || | ||
1067 | (tf->command == ATA_CMD_READ_MULTI_EXT) || | ||
1068 | (tf->command == ATA_CMD_WRITE_MULTI_EXT) || | ||
1069 | (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); | ||
1070 | } | ||
1071 | |||
1072 | static inline bool ata_ok(u8 status) | 991 | static inline bool ata_ok(u8 status) |
1073 | { | 992 | { |
1074 | return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) | 993 | return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 4ea55bb45deb..0e23c26485f4 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -138,6 +138,22 @@ enum { | |||
138 | ATA_SHT_THIS_ID = -1, | 138 | ATA_SHT_THIS_ID = -1, |
139 | ATA_SHT_USE_CLUSTERING = 1, | 139 | ATA_SHT_USE_CLUSTERING = 1, |
140 | 140 | ||
141 | /* struct ata_taskfile flags */ | ||
142 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ | ||
143 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ | ||
144 | ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */ | ||
145 | ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ | ||
146 | ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ | ||
147 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ | ||
148 | ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ | ||
149 | |||
150 | /* protocol flags */ | ||
151 | ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */ | ||
152 | ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */ | ||
153 | ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA, | ||
154 | ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */ | ||
155 | ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */ | ||
156 | |||
141 | /* struct ata_device stuff */ | 157 | /* struct ata_device stuff */ |
142 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ | 158 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ |
143 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ | 159 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ |
@@ -156,6 +172,7 @@ enum { | |||
156 | ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ | 172 | ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ |
157 | ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ | 173 | ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ |
158 | ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ | 174 | ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ |
175 | ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */ | ||
159 | ATA_DFLAG_INIT_MASK = (1 << 24) - 1, | 176 | ATA_DFLAG_INIT_MASK = (1 << 24) - 1, |
160 | 177 | ||
161 | ATA_DFLAG_DETACH = (1 << 24), | 178 | ATA_DFLAG_DETACH = (1 << 24), |
@@ -207,6 +224,7 @@ enum { | |||
207 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ | 224 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ |
208 | ATA_FLAG_AN = (1 << 18), /* controller supports AN */ | 225 | ATA_FLAG_AN = (1 << 18), /* controller supports AN */ |
209 | ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ | 226 | ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ |
227 | ATA_FLAG_FPDMA_AUX = (1 << 20), /* controller supports H2DFIS aux field */ | ||
210 | ATA_FLAG_EM = (1 << 21), /* driver supports enclosure | 228 | ATA_FLAG_EM = (1 << 21), /* driver supports enclosure |
211 | * management */ | 229 | * management */ |
212 | ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity | 230 | ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity |
@@ -518,6 +536,33 @@ enum sw_activity { | |||
518 | BLINK_OFF, | 536 | BLINK_OFF, |
519 | }; | 537 | }; |
520 | 538 | ||
539 | struct ata_taskfile { | ||
540 | unsigned long flags; /* ATA_TFLAG_xxx */ | ||
541 | u8 protocol; /* ATA_PROT_xxx */ | ||
542 | |||
543 | u8 ctl; /* control reg */ | ||
544 | |||
545 | u8 hob_feature; /* additional data */ | ||
546 | u8 hob_nsect; /* to support LBA48 */ | ||
547 | u8 hob_lbal; | ||
548 | u8 hob_lbam; | ||
549 | u8 hob_lbah; | ||
550 | |||
551 | u8 feature; | ||
552 | u8 nsect; | ||
553 | u8 lbal; | ||
554 | u8 lbam; | ||
555 | u8 lbah; | ||
556 | |||
557 | u8 device; | ||
558 | |||
559 | u8 command; /* IO operation */ | ||
560 | |||
561 | u32 auxiliary; /* auxiliary field */ | ||
562 | /* from SATA 3.1 and */ | ||
563 | /* ATA-8 ACS-3 */ | ||
564 | }; | ||
565 | |||
521 | #ifdef CONFIG_ATA_SFF | 566 | #ifdef CONFIG_ATA_SFF |
522 | struct ata_ioports { | 567 | struct ata_ioports { |
523 | void __iomem *cmd_addr; | 568 | void __iomem *cmd_addr; |
@@ -660,6 +705,9 @@ struct ata_device { | |||
660 | /* DEVSLP Timing Variables from Identify Device Data Log */ | 705 | /* DEVSLP Timing Variables from Identify Device Data Log */ |
661 | u8 devslp_timing[ATA_LOG_DEVSLP_SIZE]; | 706 | u8 devslp_timing[ATA_LOG_DEVSLP_SIZE]; |
662 | 707 | ||
708 | /* NCQ send and receive log subcommand support */ | ||
709 | u8 ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE]; | ||
710 | |||
663 | /* error history */ | 711 | /* error history */ |
664 | int spdn_cnt; | 712 | int spdn_cnt; |
665 | /* ering is CLEAR_END, read comment above CLEAR_END */ | 713 | /* ering is CLEAR_END, read comment above CLEAR_END */ |
@@ -959,6 +1007,69 @@ extern const unsigned long sata_deb_timing_long[]; | |||
959 | extern struct ata_port_operations ata_dummy_port_ops; | 1007 | extern struct ata_port_operations ata_dummy_port_ops; |
960 | extern const struct ata_port_info ata_dummy_port_info; | 1008 | extern const struct ata_port_info ata_dummy_port_info; |
961 | 1009 | ||
1010 | /* | ||
1011 | * protocol tests | ||
1012 | */ | ||
1013 | static inline unsigned int ata_prot_flags(u8 prot) | ||
1014 | { | ||
1015 | switch (prot) { | ||
1016 | case ATA_PROT_NODATA: | ||
1017 | return 0; | ||
1018 | case ATA_PROT_PIO: | ||
1019 | return ATA_PROT_FLAG_PIO; | ||
1020 | case ATA_PROT_DMA: | ||
1021 | return ATA_PROT_FLAG_DMA; | ||
1022 | case ATA_PROT_NCQ: | ||
1023 | return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ; | ||
1024 | case ATAPI_PROT_NODATA: | ||
1025 | return ATA_PROT_FLAG_ATAPI; | ||
1026 | case ATAPI_PROT_PIO: | ||
1027 | return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO; | ||
1028 | case ATAPI_PROT_DMA: | ||
1029 | return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA; | ||
1030 | } | ||
1031 | return 0; | ||
1032 | } | ||
1033 | |||
1034 | static inline int ata_is_atapi(u8 prot) | ||
1035 | { | ||
1036 | return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI; | ||
1037 | } | ||
1038 | |||
1039 | static inline int ata_is_nodata(u8 prot) | ||
1040 | { | ||
1041 | return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA); | ||
1042 | } | ||
1043 | |||
1044 | static inline int ata_is_pio(u8 prot) | ||
1045 | { | ||
1046 | return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; | ||
1047 | } | ||
1048 | |||
1049 | static inline int ata_is_dma(u8 prot) | ||
1050 | { | ||
1051 | return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA; | ||
1052 | } | ||
1053 | |||
1054 | static inline int ata_is_ncq(u8 prot) | ||
1055 | { | ||
1056 | return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ; | ||
1057 | } | ||
1058 | |||
1059 | static inline int ata_is_data(u8 prot) | ||
1060 | { | ||
1061 | return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA; | ||
1062 | } | ||
1063 | |||
1064 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | ||
1065 | { | ||
1066 | return (tf->command == ATA_CMD_READ_MULTI) || | ||
1067 | (tf->command == ATA_CMD_WRITE_MULTI) || | ||
1068 | (tf->command == ATA_CMD_READ_MULTI_EXT) || | ||
1069 | (tf->command == ATA_CMD_WRITE_MULTI_EXT) || | ||
1070 | (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); | ||
1071 | } | ||
1072 | |||
962 | static inline const unsigned long * | 1073 | static inline const unsigned long * |
963 | sata_ehc_deb_timing(struct ata_eh_context *ehc) | 1074 | sata_ehc_deb_timing(struct ata_eh_context *ehc) |
964 | { | 1075 | { |
@@ -1142,8 +1253,6 @@ int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); | |||
1142 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); | 1253 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); |
1143 | unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, | 1254 | unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, |
1144 | const struct ata_acpi_gtm *gtm); | 1255 | const struct ata_acpi_gtm *gtm); |
1145 | acpi_handle ata_ap_acpi_handle(struct ata_port *ap); | ||
1146 | acpi_handle ata_dev_acpi_handle(struct ata_device *dev); | ||
1147 | int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); | 1256 | int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); |
1148 | #else | 1257 | #else |
1149 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | 1258 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) |
@@ -1497,6 +1606,13 @@ static inline int ata_ncq_enabled(struct ata_device *dev) | |||
1497 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; | 1606 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; |
1498 | } | 1607 | } |
1499 | 1608 | ||
1609 | static inline bool ata_fpdma_dsm_supported(struct ata_device *dev) | ||
1610 | { | ||
1611 | return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) && | ||
1612 | (dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] & | ||
1613 | ATA_LOG_NCQ_SEND_RECV_DSM_TRIM); | ||
1614 | } | ||
1615 | |||
1500 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | 1616 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) |
1501 | { | 1617 | { |
1502 | qc->tf.ctl |= ATA_NIEN; | 1618 | qc->tf.ctl |= ATA_NIEN; |