diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 21:19:53 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 21:19:53 -0400 |
| commit | 357397a14117f0c2eeafcac06a1f8412a02aa6af (patch) | |
| tree | 8420d5aab6b80fc211979d894174462c9806b26e /drivers/ata | |
| parent | 9ee52a1633a77961cb7b7fb5bd40be682f8412c7 (diff) | |
| parent | 86a565e61bcb9574bae3b622799682fef2d855bb (diff) | |
Merge branch 'for-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata changes from Tejun Heo:
"Two interesting changes.
- libata acpi handling has been restructured so that the association
between ata devices and ACPI handles are less convoluted. This
change shouldn't change visible behavior.
- Queued TRIM support, which enables sending TRIM to the device
without draining in-flight RW commands, is added. Currently only
enabled for ahci (and likely to stay that way for the foreseeable
future).
Other changes are driver-specific updates / fixes"
* 'for-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
libata: bugfix: Remove __le32 in ata_tf_to_fis()
libata: acpi: Remove ata_dev_acpi_handle stub in libata.h
libata: Add support for queued DSM TRIM
libata: Add support for SEND/RECEIVE FPDMA QUEUED
libata: Add H2D FIS "auxiliary" port flag
libata: Populate host-to-device FIS "auxiliary" field
ata: acpi: rework the ata acpi bind support
sata, highbank: send extra clock cycles in SGPIO patterns
sata, highbank: set tx_atten override bits
devicetree: create a separate binding description for sata_highbank
drivers/ata/sata_rcar.c: simplify use of devm_ioremap_resource
sata highbank: enable 64-bit DMA mask when using LPAE
ata: pata_samsung_cf: add missing __iomem annotation
ata: pata_arasan: Staticize local symbols
sata_mv: Remove unneeded CONFIG_HAVE_CLK ifdefs
ata: use dev_get_platdata()
sata_mv: Remove unneeded forward declaration
libata: acpi: remove dead code for ata_acpi_(un)bind
libata: move 'struct ata_taskfile' and friends from ata.h to libata.h
Diffstat (limited to 'drivers/ata')
| -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 |
19 files changed, 236 insertions, 287 deletions
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); |
