aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 13:19:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 13:19:17 -0500
commitabce00f962a11ed6f748c2569e11695a30716b53 (patch)
treef76a7d999dc47bb84cc72b2691aa47080ef97262 /drivers/ata
parent90160371b3a3e67ef78d68210a94dd30664a703d (diff)
parent318893e1429a9d50569a0379d1e20b0ecc45c555 (diff)
Merge branch 'upstream-linus' of git://github.com/jgarzik/libata-dev
* 'upstream-linus' of git://github.com/jgarzik/libata-dev: ahci: support the STA2X11 I/O Hub pata_bf54x: fix BMIDE status register emulation ata: add ata port hibernate callbacks ata: update ata port's runtime status during system resume [SCSI] runtime resume parent for child's system-resume ahci: platform support for suspend/resume libata-core: kill duplicate statement in ata_do_set_mode() pata_of_platform: remove direct dependency on OF_IRQ SATA/PATA: convert drivers/ata/* to use module_platform_driver() pata_cs5536: forward port changes from cs5536 libata-sff: use ATAPI_{COD|IO} ata: add ata port runtime PM callbacks ata: add ata port system PM callbacks [SCSI] sd: check runtime PM status in sd_shutdown [SCSI] check runtime PM status in system PM [SCSI] add flag to skip the runtime PM calls on the host ata: make ata port as parent device of scsi host ahci: start engine only during soft/hard resets
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/ata/ahci.c26
-rw-r--r--drivers/ata/ahci_platform.c68
-rw-r--r--drivers/ata/libahci.c5
-rw-r--r--drivers/ata/libata-core.c188
-rw-r--r--drivers/ata/libata-scsi.c3
-rw-r--r--drivers/ata/libata-sff.c4
-rw-r--r--drivers/ata/libata-transport.c5
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_arasan_cf.c12
-rw-r--r--drivers/ata/pata_at91.c15
-rw-r--r--drivers/ata/pata_bf54x.c20
-rw-r--r--drivers/ata/pata_cs5536.c99
-rw-r--r--drivers/ata/pata_imx.c12
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c13
-rw-r--r--drivers/ata/pata_mpc52xx.c21
-rw-r--r--drivers/ata/pata_of_platform.c27
-rw-r--r--drivers/ata/pata_palmld.c13
-rw-r--r--drivers/ata/pata_platform.c12
-rw-r--r--drivers/ata/pata_pxa.c13
-rw-r--r--drivers/ata/pata_rb532_cf.c21
-rw-r--r--drivers/ata/sata_dwc_460ex.c13
-rw-r--r--drivers/ata/sata_fsl.c14
23 files changed, 288 insertions, 319 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index cf047c406d92..6bdedd7cca2c 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -820,7 +820,7 @@ config PATA_PLATFORM
820 820
821config PATA_OF_PLATFORM 821config PATA_OF_PLATFORM
822 tristate "OpenFirmware platform device PATA support" 822 tristate "OpenFirmware platform device PATA support"
823 depends on PATA_PLATFORM && OF && OF_IRQ 823 depends on PATA_PLATFORM && OF
824 help 824 help
825 This option enables support for generic directly connected ATA 825 This option enables support for generic directly connected ATA
826 devices commonly found on embedded systems with OpenFirmware 826 devices commonly found on embedded systems with OpenFirmware
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index cf26222a93c5..d07bf0366d99 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -52,7 +52,8 @@
52#define DRV_VERSION "3.0" 52#define DRV_VERSION "3.0"
53 53
54enum { 54enum {
55 AHCI_PCI_BAR = 5, 55 AHCI_PCI_BAR_STA2X11 = 0,
56 AHCI_PCI_BAR_STANDARD = 5,
56}; 57};
57 58
58enum board_ids { 59enum board_ids {
@@ -375,6 +376,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
375 { PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 968 */ 376 { PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 968 */
376 { PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */ 377 { PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */
377 378
379 /* ST Microelectronics */
380 { PCI_VDEVICE(STMICRO, 0xCC06), board_ahci }, /* ST ConneXt */
381
378 /* Marvell */ 382 /* Marvell */
379 { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ 383 { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
380 { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */ 384 { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
@@ -622,6 +626,13 @@ static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
622{ 626{
623 int rc; 627 int rc;
624 628
629 /*
630 * If the device fixup already set the dma_mask to some non-standard
631 * value, don't extend it here. This happens on STA2X11, for example.
632 */
633 if (pdev->dma_mask && pdev->dma_mask < DMA_BIT_MASK(32))
634 return 0;
635
625 if (using_dac && 636 if (using_dac &&
626 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { 637 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
627 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); 638 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
@@ -1026,6 +1037,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1026 struct ahci_host_priv *hpriv; 1037 struct ahci_host_priv *hpriv;
1027 struct ata_host *host; 1038 struct ata_host *host;
1028 int n_ports, i, rc; 1039 int n_ports, i, rc;
1040 int ahci_pci_bar = AHCI_PCI_BAR_STANDARD;
1029 1041
1030 VPRINTK("ENTER\n"); 1042 VPRINTK("ENTER\n");
1031 1043
@@ -1057,6 +1069,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1057 dev_info(&pdev->dev, 1069 dev_info(&pdev->dev,
1058 "PDC42819 can only drive SATA devices with this driver\n"); 1070 "PDC42819 can only drive SATA devices with this driver\n");
1059 1071
1072 /* The Connext uses non-standard BAR */
1073 if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)
1074 ahci_pci_bar = AHCI_PCI_BAR_STA2X11;
1075
1060 /* acquire resources */ 1076 /* acquire resources */
1061 rc = pcim_enable_device(pdev); 1077 rc = pcim_enable_device(pdev);
1062 if (rc) 1078 if (rc)
@@ -1065,7 +1081,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1065 /* AHCI controllers often implement SFF compatible interface. 1081 /* AHCI controllers often implement SFF compatible interface.
1066 * Grab all PCI BARs just in case. 1082 * Grab all PCI BARs just in case.
1067 */ 1083 */
1068 rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); 1084 rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME);
1069 if (rc == -EBUSY) 1085 if (rc == -EBUSY)
1070 pcim_pin_device(pdev); 1086 pcim_pin_device(pdev);
1071 if (rc) 1087 if (rc)
@@ -1108,7 +1124,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1108 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) 1124 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
1109 pci_intx(pdev, 1); 1125 pci_intx(pdev, 1);
1110 1126
1111 hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 1127 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
1112 1128
1113 /* save initial config */ 1129 /* save initial config */
1114 ahci_pci_save_initial_config(pdev, hpriv); 1130 ahci_pci_save_initial_config(pdev, hpriv);
@@ -1172,8 +1188,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1172 for (i = 0; i < host->n_ports; i++) { 1188 for (i = 0; i < host->n_ports; i++) {
1173 struct ata_port *ap = host->ports[i]; 1189 struct ata_port *ap = host->ports[i];
1174 1190
1175 ata_port_pbar_desc(ap, AHCI_PCI_BAR, -1, "abar"); 1191 ata_port_pbar_desc(ap, ahci_pci_bar, -1, "abar");
1176 ata_port_pbar_desc(ap, AHCI_PCI_BAR, 1192 ata_port_pbar_desc(ap, ahci_pci_bar,
1177 0x100 + ap->port_no * 0x80, "port"); 1193 0x100 + ap->port_no * 0x80, "port");
1178 1194
1179 /* set enclosure management message type */ 1195 /* set enclosure management message type */
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 43b875810d1b..48be4e189163 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -202,6 +202,71 @@ static int __devexit ahci_remove(struct platform_device *pdev)
202 return 0; 202 return 0;
203} 203}
204 204
205#ifdef CONFIG_PM
206static int ahci_suspend(struct device *dev)
207{
208 struct ahci_platform_data *pdata = dev_get_platdata(dev);
209 struct ata_host *host = dev_get_drvdata(dev);
210 struct ahci_host_priv *hpriv = host->private_data;
211 void __iomem *mmio = hpriv->mmio;
212 u32 ctl;
213 int rc;
214
215 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
216 dev_err(dev, "firmware update required for suspend/resume\n");
217 return -EIO;
218 }
219
220 /*
221 * AHCI spec rev1.1 section 8.3.3:
222 * Software must disable interrupts prior to requesting a
223 * transition of the HBA to D3 state.
224 */
225 ctl = readl(mmio + HOST_CTL);
226 ctl &= ~HOST_IRQ_EN;
227 writel(ctl, mmio + HOST_CTL);
228 readl(mmio + HOST_CTL); /* flush */
229
230 rc = ata_host_suspend(host, PMSG_SUSPEND);
231 if (rc)
232 return rc;
233
234 if (pdata && pdata->suspend)
235 return pdata->suspend(dev);
236 return 0;
237}
238
239static int ahci_resume(struct device *dev)
240{
241 struct ahci_platform_data *pdata = dev_get_platdata(dev);
242 struct ata_host *host = dev_get_drvdata(dev);
243 int rc;
244
245 if (pdata && pdata->resume) {
246 rc = pdata->resume(dev);
247 if (rc)
248 return rc;
249 }
250
251 if (dev->power.power_state.event == PM_EVENT_SUSPEND) {
252 rc = ahci_reset_controller(host);
253 if (rc)
254 return rc;
255
256 ahci_init_controller(host);
257 }
258
259 ata_host_resume(host);
260
261 return 0;
262}
263
264static struct dev_pm_ops ahci_pm_ops = {
265 .suspend = &ahci_suspend,
266 .resume = &ahci_resume,
267};
268#endif
269
205static const struct of_device_id ahci_of_match[] = { 270static const struct of_device_id ahci_of_match[] = {
206 { .compatible = "calxeda,hb-ahci", }, 271 { .compatible = "calxeda,hb-ahci", },
207 {}, 272 {},
@@ -214,6 +279,9 @@ static struct platform_driver ahci_driver = {
214 .name = "ahci", 279 .name = "ahci",
215 .owner = THIS_MODULE, 280 .owner = THIS_MODULE,
216 .of_match_table = ahci_of_match, 281 .of_match_table = ahci_of_match,
282#ifdef CONFIG_PM
283 .pm = &ahci_pm_ops,
284#endif
217 }, 285 },
218 .id_table = ahci_devtype, 286 .id_table = ahci_devtype,
219}; 287};
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 3c92dbd751e0..a72bfd0ecfee 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -746,9 +746,6 @@ static void ahci_start_port(struct ata_port *ap)
746 /* enable FIS reception */ 746 /* enable FIS reception */
747 ahci_start_fis_rx(ap); 747 ahci_start_fis_rx(ap);
748 748
749 /* enable DMA */
750 ahci_start_engine(ap);
751
752 /* turn on LEDs */ 749 /* turn on LEDs */
753 if (ap->flags & ATA_FLAG_EM) { 750 if (ap->flags & ATA_FLAG_EM) {
754 ata_for_each_link(link, ap, EDGE) { 751 ata_for_each_link(link, ap, EDGE) {
@@ -2022,7 +2019,7 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
2022 ahci_power_down(ap); 2019 ahci_power_down(ap);
2023 else { 2020 else {
2024 ata_port_err(ap, "%s (%d)\n", emsg, rc); 2021 ata_port_err(ap, "%s (%d)\n", emsg, rc);
2025 ahci_start_port(ap); 2022 ata_port_freeze(ap);
2026 } 2023 }
2027 2024
2028 return rc; 2025 return rc;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c04ad68cb602..11c9aea4f4f7 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -66,6 +66,7 @@
66#include <asm/byteorder.h> 66#include <asm/byteorder.h>
67#include <linux/cdrom.h> 67#include <linux/cdrom.h>
68#include <linux/ratelimit.h> 68#include <linux/ratelimit.h>
69#include <linux/pm_runtime.h>
69 70
70#include "libata.h" 71#include "libata.h"
71#include "libata-transport.h" 72#include "libata-transport.h"
@@ -3248,10 +3249,10 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
3248 ata_force_xfermask(dev); 3249 ata_force_xfermask(dev);
3249 3250
3250 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); 3251 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
3251 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
3252 3252
3253 if (libata_dma_mask & mode_mask) 3253 if (libata_dma_mask & mode_mask)
3254 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 3254 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask,
3255 dev->udma_mask);
3255 else 3256 else
3256 dma_mask = 0; 3257 dma_mask = 0;
3257 3258
@@ -5234,73 +5235,55 @@ bool ata_link_offline(struct ata_link *link)
5234} 5235}
5235 5236
5236#ifdef CONFIG_PM 5237#ifdef CONFIG_PM
5237static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, 5238static int ata_port_request_pm(struct ata_port *ap, pm_message_t mesg,
5238 unsigned int action, unsigned int ehi_flags, 5239 unsigned int action, unsigned int ehi_flags,
5239 int wait) 5240 int wait)
5240{ 5241{
5242 struct ata_link *link;
5241 unsigned long flags; 5243 unsigned long flags;
5242 int i, rc; 5244 int rc;
5243
5244 for (i = 0; i < host->n_ports; i++) {
5245 struct ata_port *ap = host->ports[i];
5246 struct ata_link *link;
5247 5245
5248 /* Previous resume operation might still be in 5246 /* Previous resume operation might still be in
5249 * progress. Wait for PM_PENDING to clear. 5247 * progress. Wait for PM_PENDING to clear.
5250 */ 5248 */
5251 if (ap->pflags & ATA_PFLAG_PM_PENDING) { 5249 if (ap->pflags & ATA_PFLAG_PM_PENDING) {
5252 ata_port_wait_eh(ap); 5250 ata_port_wait_eh(ap);
5253 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING); 5251 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
5254 } 5252 }
5255 5253
5256 /* request PM ops to EH */ 5254 /* request PM ops to EH */
5257 spin_lock_irqsave(ap->lock, flags); 5255 spin_lock_irqsave(ap->lock, flags);
5258 5256
5259 ap->pm_mesg = mesg; 5257 ap->pm_mesg = mesg;
5260 if (wait) { 5258 if (wait) {
5261 rc = 0; 5259 rc = 0;
5262 ap->pm_result = &rc; 5260 ap->pm_result = &rc;
5263 } 5261 }
5264 5262
5265 ap->pflags |= ATA_PFLAG_PM_PENDING; 5263 ap->pflags |= ATA_PFLAG_PM_PENDING;
5266 ata_for_each_link(link, ap, HOST_FIRST) { 5264 ata_for_each_link(link, ap, HOST_FIRST) {
5267 link->eh_info.action |= action; 5265 link->eh_info.action |= action;
5268 link->eh_info.flags |= ehi_flags; 5266 link->eh_info.flags |= ehi_flags;
5269 } 5267 }
5270 5268
5271 ata_port_schedule_eh(ap); 5269 ata_port_schedule_eh(ap);
5272 5270
5273 spin_unlock_irqrestore(ap->lock, flags); 5271 spin_unlock_irqrestore(ap->lock, flags);
5274 5272
5275 /* wait and check result */ 5273 /* wait and check result */
5276 if (wait) { 5274 if (wait) {
5277 ata_port_wait_eh(ap); 5275 ata_port_wait_eh(ap);
5278 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING); 5276 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
5279 if (rc)
5280 return rc;
5281 }
5282 } 5277 }
5283 5278
5284 return 0; 5279 return rc;
5285} 5280}
5286 5281
5287/** 5282#define to_ata_port(d) container_of(d, struct ata_port, tdev)
5288 * ata_host_suspend - suspend host 5283
5289 * @host: host to suspend 5284static int ata_port_suspend_common(struct device *dev, pm_message_t mesg)
5290 * @mesg: PM message
5291 *
5292 * Suspend @host. Actual operation is performed by EH. This
5293 * function requests EH to perform PM operations and waits for EH
5294 * to finish.
5295 *
5296 * LOCKING:
5297 * Kernel thread context (may sleep).
5298 *
5299 * RETURNS:
5300 * 0 on success, -errno on failure.
5301 */
5302int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5303{ 5285{
5286 struct ata_port *ap = to_ata_port(dev);
5304 unsigned int ehi_flags = ATA_EHI_QUIET; 5287 unsigned int ehi_flags = ATA_EHI_QUIET;
5305 int rc; 5288 int rc;
5306 5289
@@ -5315,31 +5298,108 @@ int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5315 if (mesg.event == PM_EVENT_SUSPEND) 5298 if (mesg.event == PM_EVENT_SUSPEND)
5316 ehi_flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_NO_RECOVERY; 5299 ehi_flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_NO_RECOVERY;
5317 5300
5318 rc = ata_host_request_pm(host, mesg, 0, ehi_flags, 1); 5301 rc = ata_port_request_pm(ap, mesg, 0, ehi_flags, 1);
5319 if (rc == 0)
5320 host->dev->power.power_state = mesg;
5321 return rc; 5302 return rc;
5322} 5303}
5323 5304
5305static int ata_port_suspend(struct device *dev)
5306{
5307 if (pm_runtime_suspended(dev))
5308 return 0;
5309
5310 return ata_port_suspend_common(dev, PMSG_SUSPEND);
5311}
5312
5313static int ata_port_do_freeze(struct device *dev)
5314{
5315 if (pm_runtime_suspended(dev))
5316 pm_runtime_resume(dev);
5317
5318 return ata_port_suspend_common(dev, PMSG_FREEZE);
5319}
5320
5321static int ata_port_poweroff(struct device *dev)
5322{
5323 if (pm_runtime_suspended(dev))
5324 return 0;
5325
5326 return ata_port_suspend_common(dev, PMSG_HIBERNATE);
5327}
5328
5329static int ata_port_resume_common(struct device *dev)
5330{
5331 struct ata_port *ap = to_ata_port(dev);
5332 int rc;
5333
5334 rc = ata_port_request_pm(ap, PMSG_ON, ATA_EH_RESET,
5335 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 1);
5336 return rc;
5337}
5338
5339static int ata_port_resume(struct device *dev)
5340{
5341 int rc;
5342
5343 rc = ata_port_resume_common(dev);
5344 if (!rc) {
5345 pm_runtime_disable(dev);
5346 pm_runtime_set_active(dev);
5347 pm_runtime_enable(dev);
5348 }
5349
5350 return rc;
5351}
5352
5353static int ata_port_runtime_idle(struct device *dev)
5354{
5355 return pm_runtime_suspend(dev);
5356}
5357
5358static const struct dev_pm_ops ata_port_pm_ops = {
5359 .suspend = ata_port_suspend,
5360 .resume = ata_port_resume,
5361 .freeze = ata_port_do_freeze,
5362 .thaw = ata_port_resume,
5363 .poweroff = ata_port_poweroff,
5364 .restore = ata_port_resume,
5365
5366 .runtime_suspend = ata_port_suspend,
5367 .runtime_resume = ata_port_resume_common,
5368 .runtime_idle = ata_port_runtime_idle,
5369};
5370
5371/**
5372 * ata_host_suspend - suspend host
5373 * @host: host to suspend
5374 * @mesg: PM message
5375 *
5376 * Suspend @host. Actual operation is performed by port suspend.
5377 */
5378int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5379{
5380 host->dev->power.power_state = mesg;
5381 return 0;
5382}
5383
5324/** 5384/**
5325 * ata_host_resume - resume host 5385 * ata_host_resume - resume host
5326 * @host: host to resume 5386 * @host: host to resume
5327 * 5387 *
5328 * Resume @host. Actual operation is performed by EH. This 5388 * Resume @host. Actual operation is performed by port resume.
5329 * function requests EH to perform PM operations and returns.
5330 * Note that all resume operations are performed parallelly.
5331 *
5332 * LOCKING:
5333 * Kernel thread context (may sleep).
5334 */ 5389 */
5335void ata_host_resume(struct ata_host *host) 5390void ata_host_resume(struct ata_host *host)
5336{ 5391{
5337 ata_host_request_pm(host, PMSG_ON, ATA_EH_RESET,
5338 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
5339 host->dev->power.power_state = PMSG_ON; 5392 host->dev->power.power_state = PMSG_ON;
5340} 5393}
5341#endif 5394#endif
5342 5395
5396struct device_type ata_port_type = {
5397 .name = "ata_port",
5398#ifdef CONFIG_PM
5399 .pm = &ata_port_pm_ops,
5400#endif
5401};
5402
5343/** 5403/**
5344 * ata_dev_init - Initialize an ata_device structure 5404 * ata_dev_init - Initialize an ata_device structure
5345 * @dev: Device structure to initialize 5405 * @dev: Device structure to initialize
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 2a5412e7e9c1..508a60bfe5c1 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3381,6 +3381,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
3381 if (!shost) 3381 if (!shost)
3382 goto err_alloc; 3382 goto err_alloc;
3383 3383
3384 shost->eh_noresume = 1;
3384 *(struct ata_port **)&shost->hostdata[0] = ap; 3385 *(struct ata_port **)&shost->hostdata[0] = ap;
3385 ap->scsi_host = shost; 3386 ap->scsi_host = shost;
3386 3387
@@ -3398,7 +3399,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
3398 */ 3399 */
3399 shost->max_host_blocked = 1; 3400 shost->max_host_blocked = 1;
3400 3401
3401 rc = scsi_add_host(ap->scsi_host, ap->host->dev); 3402 rc = scsi_add_host(ap->scsi_host, &ap->tdev);
3402 if (rc) 3403 if (rc)
3403 goto err_add; 3404 goto err_add;
3404 } 3405 }
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 4cadfa28f940..9691dd0966d7 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -929,11 +929,11 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
929 bytes = (bc_hi << 8) | bc_lo; 929 bytes = (bc_hi << 8) | bc_lo;
930 930
931 /* shall be cleared to zero, indicating xfer of data */ 931 /* shall be cleared to zero, indicating xfer of data */
932 if (unlikely(ireason & (1 << 0))) 932 if (unlikely(ireason & ATAPI_COD))
933 goto atapi_check; 933 goto atapi_check;
934 934
935 /* make sure transfer direction matches expected */ 935 /* make sure transfer direction matches expected */
936 i_write = ((ireason & (1 << 1)) == 0) ? 1 : 0; 936 i_write = ((ireason & ATAPI_IO) == 0) ? 1 : 0;
937 if (unlikely(do_write != i_write)) 937 if (unlikely(do_write != i_write))
938 goto atapi_check; 938 goto atapi_check;
939 939
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index ce9dc6207f37..9a7f0ea565df 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -32,6 +32,7 @@
32#include <linux/libata.h> 32#include <linux/libata.h>
33#include <linux/hdreg.h> 33#include <linux/hdreg.h>
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/pm_runtime.h>
35 36
36#include "libata.h" 37#include "libata.h"
37#include "libata-transport.h" 38#include "libata-transport.h"
@@ -279,6 +280,7 @@ int ata_tport_add(struct device *parent,
279 struct device *dev = &ap->tdev; 280 struct device *dev = &ap->tdev;
280 281
281 device_initialize(dev); 282 device_initialize(dev);
283 dev->type = &ata_port_type;
282 284
283 dev->parent = get_device(parent); 285 dev->parent = get_device(parent);
284 dev->release = ata_tport_release; 286 dev->release = ata_tport_release;
@@ -289,6 +291,9 @@ int ata_tport_add(struct device *parent,
289 goto tport_err; 291 goto tport_err;
290 } 292 }
291 293
294 pm_runtime_set_active(dev);
295 pm_runtime_enable(dev);
296
292 transport_add_device(dev); 297 transport_add_device(dev);
293 transport_configure_device(dev); 298 transport_configure_device(dev);
294 299
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 773de97988a2..814486d35c44 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -58,6 +58,7 @@ extern int atapi_passthru16;
58extern int libata_fua; 58extern int libata_fua;
59extern int libata_noacpi; 59extern int libata_noacpi;
60extern int libata_allow_tpm; 60extern int libata_allow_tpm;
61extern struct device_type ata_port_type;
61extern struct ata_link *ata_dev_phys_link(struct ata_device *dev); 62extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
62extern void ata_force_cbl(struct ata_port *ap); 63extern void ata_force_cbl(struct ata_port *ap);
63extern u64 ata_tf_to_lba(const struct ata_taskfile *tf); 64extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index e8574bba3ee4..048589fad2ca 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -963,17 +963,7 @@ static struct platform_driver arasan_cf_driver = {
963 }, 963 },
964}; 964};
965 965
966static int __init arasan_cf_init(void) 966module_platform_driver(arasan_cf_driver);
967{
968 return platform_driver_register(&arasan_cf_driver);
969}
970module_init(arasan_cf_init);
971
972static void __exit arasan_cf_exit(void)
973{
974 platform_driver_unregister(&arasan_cf_driver);
975}
976module_exit(arasan_cf_exit);
977 967
978MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>"); 968MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>");
979MODULE_DESCRIPTION("Arasan ATA Compact Flash driver"); 969MODULE_DESCRIPTION("Arasan ATA Compact Flash driver");
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 5249e6d918a3..a7d91a72ee35 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -454,20 +454,7 @@ static struct platform_driver pata_at91_driver = {
454 }, 454 },
455}; 455};
456 456
457static int __init pata_at91_init(void) 457module_platform_driver(pata_at91_driver);
458{
459 return platform_driver_register(&pata_at91_driver);
460}
461
462static void __exit pata_at91_exit(void)
463{
464 platform_driver_unregister(&pata_at91_driver);
465}
466
467
468module_init(pata_at91_init);
469module_exit(pata_at91_exit);
470
471 458
472MODULE_LICENSE("GPL"); 459MODULE_LICENSE("GPL");
473MODULE_DESCRIPTION("Driver for CF in True IDE mode on AT91SAM9260 SoC"); 460MODULE_DESCRIPTION("Driver for CF in True IDE mode on AT91SAM9260 SoC");
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index bd987bb082eb..d6a4677fdf71 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -418,14 +418,6 @@ static void bfin_set_dmamode(struct ata_port *ap, struct ata_device *adev)
418 (tcyc_tdvs<<8 | tdvs)); 418 (tcyc_tdvs<<8 | tdvs));
419 ATAPI_SET_ULTRA_TIM_2(base, (tmli<<8 | tss)); 419 ATAPI_SET_ULTRA_TIM_2(base, (tmli<<8 | tss));
420 ATAPI_SET_ULTRA_TIM_3(base, (trp<<8 | tzah)); 420 ATAPI_SET_ULTRA_TIM_3(base, (trp<<8 | tzah));
421
422 /* Enable host ATAPI Untra DMA interrupts */
423 ATAPI_SET_INT_MASK(base,
424 ATAPI_GET_INT_MASK(base)
425 | UDMAIN_DONE_MASK
426 | UDMAOUT_DONE_MASK
427 | UDMAIN_TERM_MASK
428 | UDMAOUT_TERM_MASK);
429 } 421 }
430 } 422 }
431 } 423 }
@@ -470,10 +462,6 @@ static void bfin_set_dmamode(struct ata_port *ap, struct ata_device *adev)
470 ATAPI_SET_MULTI_TIM_0(base, (tm<<8 | td)); 462 ATAPI_SET_MULTI_TIM_0(base, (tm<<8 | td));
471 ATAPI_SET_MULTI_TIM_1(base, (tkr<<8 | tkw)); 463 ATAPI_SET_MULTI_TIM_1(base, (tkr<<8 | tkw));
472 ATAPI_SET_MULTI_TIM_2(base, (teoc<<8 | th)); 464 ATAPI_SET_MULTI_TIM_2(base, (teoc<<8 | th));
473
474 /* Enable host ATAPI Multi DMA interrupts */
475 ATAPI_SET_INT_MASK(base, ATAPI_GET_INT_MASK(base)
476 | MULTI_DONE_MASK | MULTI_TERM_MASK);
477 SSYNC(); 465 SSYNC();
478 } 466 }
479 } 467 }
@@ -1153,15 +1141,11 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap)
1153{ 1141{
1154 unsigned char host_stat = 0; 1142 unsigned char host_stat = 0;
1155 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 1143 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
1156 unsigned short int_status = ATAPI_GET_INT_STATUS(base);
1157 1144
1158 if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) 1145 if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON | ULTRA_XFER_ON))
1159 host_stat |= ATA_DMA_ACTIVE; 1146 host_stat |= ATA_DMA_ACTIVE;
1160 if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT| 1147 if (ATAPI_GET_INT_STATUS(base) & ATAPI_DEV_INT)
1161 ATAPI_DEV_INT))
1162 host_stat |= ATA_DMA_INTR; 1148 host_stat |= ATA_DMA_INTR;
1163 if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT))
1164 host_stat |= ATA_DMA_ERR|ATA_DMA_INTR;
1165 1149
1166 dev_dbg(ap->dev, "ATAPI: host_stat=0x%x\n", host_stat); 1150 dev_dbg(ap->dev, "ATAPI: host_stat=0x%x\n", host_stat);
1167 1151
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c
index 628c8fae5937..7a402c75ab90 100644
--- a/drivers/ata/pata_cs5536.c
+++ b/drivers/ata/pata_cs5536.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * pata_cs5536.c - CS5536 PATA for new ATA layer 2 * pata_cs5536.c - CS5536 PATA for new ATA layer
3 * (C) 2007 Martin K. Petersen <mkp@mkp.net> 3 * (C) 2007 Martin K. Petersen <mkp@mkp.net>
4 * (C) 2011 Bartlomiej Zolnierkiewicz
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -55,24 +56,16 @@ MODULE_PARM_DESC(msr, "Force using MSR to configure IDE function (Default: 0)");
55#define DRV_VERSION "0.0.8" 56#define DRV_VERSION "0.0.8"
56 57
57enum { 58enum {
58 CFG = 0, 59 MSR_IDE_CFG = 0x51300010,
59 DTC = 1,
60 CAST = 2,
61 ETC = 3,
62
63 MSR_IDE_BASE = 0x51300000,
64 MSR_IDE_CFG = (MSR_IDE_BASE + 0x10),
65 MSR_IDE_DTC = (MSR_IDE_BASE + 0x12),
66 MSR_IDE_CAST = (MSR_IDE_BASE + 0x13),
67 MSR_IDE_ETC = (MSR_IDE_BASE + 0x14),
68
69 PCI_IDE_CFG = 0x40, 60 PCI_IDE_CFG = 0x40,
70 PCI_IDE_DTC = 0x48,
71 PCI_IDE_CAST = 0x4c,
72 PCI_IDE_ETC = 0x50,
73 61
74 IDE_CFG_CHANEN = 0x2, 62 CFG = 0,
75 IDE_CFG_CABLE = 0x10000, 63 DTC = 2,
64 CAST = 3,
65 ETC = 4,
66
67 IDE_CFG_CHANEN = (1 << 1),
68 IDE_CFG_CABLE = (1 << 17) | (1 << 16),
76 69
77 IDE_D0_SHIFT = 24, 70 IDE_D0_SHIFT = 24,
78 IDE_D1_SHIFT = 16, 71 IDE_D1_SHIFT = 16,
@@ -84,45 +77,50 @@ enum {
84 IDE_CAST_CMD_MASK = 0xff, 77 IDE_CAST_CMD_MASK = 0xff,
85 IDE_CAST_CMD_SHIFT = 24, 78 IDE_CAST_CMD_SHIFT = 24,
86 79
87 IDE_ETC_NODMA = 0x03, 80 IDE_ETC_UDMA_MASK = 0xc0,
88};
89
90static const u32 msr_reg[4] = {
91 MSR_IDE_CFG, MSR_IDE_DTC, MSR_IDE_CAST, MSR_IDE_ETC,
92};
93
94static const u8 pci_reg[4] = {
95 PCI_IDE_CFG, PCI_IDE_DTC, PCI_IDE_CAST, PCI_IDE_ETC,
96}; 81};
97 82
98static inline int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) 83static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val)
99{ 84{
100 if (unlikely(use_msr)) { 85 if (unlikely(use_msr)) {
101 u32 dummy __maybe_unused; 86 u32 dummy __maybe_unused;
102 87
103 rdmsr(msr_reg[reg], *val, dummy); 88 rdmsr(MSR_IDE_CFG + reg, *val, dummy);
104 return 0; 89 return 0;
105 } 90 }
106 91
107 return pci_read_config_dword(pdev, pci_reg[reg], val); 92 return pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val);
108} 93}
109 94
110static inline int cs5536_write(struct pci_dev *pdev, int reg, int val) 95static int cs5536_write(struct pci_dev *pdev, int reg, int val)
111{ 96{
112 if (unlikely(use_msr)) { 97 if (unlikely(use_msr)) {
113 wrmsr(msr_reg[reg], val, 0); 98 wrmsr(MSR_IDE_CFG + reg, val, 0);
114 return 0; 99 return 0;
115 } 100 }
116 101
117 return pci_write_config_dword(pdev, pci_reg[reg], val); 102 return pci_write_config_dword(pdev, PCI_IDE_CFG + reg * 4, val);
103}
104
105static void cs5536_program_dtc(struct ata_device *adev, u8 tim)
106{
107 struct pci_dev *pdev = to_pci_dev(adev->link->ap->host->dev);
108 int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT;
109 u32 dtc;
110
111 cs5536_read(pdev, DTC, &dtc);
112 dtc &= ~(IDE_DRV_MASK << dshift);
113 dtc |= tim << dshift;
114 cs5536_write(pdev, DTC, dtc);
118} 115}
119 116
120/** 117/**
121 * cs5536_cable_detect - detect cable type 118 * cs5536_cable_detect - detect cable type
122 * @ap: Port to detect on 119 * @ap: Port to detect on
123 * 120 *
124 * Perform cable detection for ATA66 capable cable. Return a libata 121 * Perform cable detection for ATA66 capable cable.
125 * cable type. 122 *
123 * Returns a cable type.
126 */ 124 */
127 125
128static int cs5536_cable_detect(struct ata_port *ap) 126static int cs5536_cable_detect(struct ata_port *ap)
@@ -132,7 +130,7 @@ static int cs5536_cable_detect(struct ata_port *ap)
132 130
133 cs5536_read(pdev, CFG, &cfg); 131 cs5536_read(pdev, CFG, &cfg);
134 132
135 if (cfg & (IDE_CFG_CABLE << ap->port_no)) 133 if (cfg & IDE_CFG_CABLE)
136 return ATA_CBL_PATA80; 134 return ATA_CBL_PATA80;
137 else 135 else
138 return ATA_CBL_PATA40; 136 return ATA_CBL_PATA40;
@@ -162,19 +160,15 @@ static void cs5536_set_piomode(struct ata_port *ap, struct ata_device *adev)
162 struct ata_device *pair = ata_dev_pair(adev); 160 struct ata_device *pair = ata_dev_pair(adev);
163 int mode = adev->pio_mode - XFER_PIO_0; 161 int mode = adev->pio_mode - XFER_PIO_0;
164 int cmdmode = mode; 162 int cmdmode = mode;
165 int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT;
166 int cshift = adev->devno ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; 163 int cshift = adev->devno ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT;
167 u32 dtc, cast, etc; 164 u32 cast;
168 165
169 if (pair) 166 if (pair)
170 cmdmode = min(mode, pair->pio_mode - XFER_PIO_0); 167 cmdmode = min(mode, pair->pio_mode - XFER_PIO_0);
171 168
172 cs5536_read(pdev, DTC, &dtc); 169 cs5536_program_dtc(adev, drv_timings[mode]);
173 cs5536_read(pdev, CAST, &cast);
174 cs5536_read(pdev, ETC, &etc);
175 170
176 dtc &= ~(IDE_DRV_MASK << dshift); 171 cs5536_read(pdev, CAST, &cast);
177 dtc |= drv_timings[mode] << dshift;
178 172
179 cast &= ~(IDE_CAST_DRV_MASK << cshift); 173 cast &= ~(IDE_CAST_DRV_MASK << cshift);
180 cast |= addr_timings[mode] << cshift; 174 cast |= addr_timings[mode] << cshift;
@@ -182,12 +176,7 @@ static void cs5536_set_piomode(struct ata_port *ap, struct ata_device *adev)
182 cast &= ~(IDE_CAST_CMD_MASK << IDE_CAST_CMD_SHIFT); 176 cast &= ~(IDE_CAST_CMD_MASK << IDE_CAST_CMD_SHIFT);
183 cast |= cmd_timings[cmdmode] << IDE_CAST_CMD_SHIFT; 177 cast |= cmd_timings[cmdmode] << IDE_CAST_CMD_SHIFT;
184 178
185 etc &= ~(IDE_DRV_MASK << dshift);
186 etc |= IDE_ETC_NODMA << dshift;
187
188 cs5536_write(pdev, DTC, dtc);
189 cs5536_write(pdev, CAST, cast); 179 cs5536_write(pdev, CAST, cast);
190 cs5536_write(pdev, ETC, etc);
191} 180}
192 181
193/** 182/**
@@ -208,25 +197,21 @@ static void cs5536_set_dmamode(struct ata_port *ap, struct ata_device *adev)
208 }; 197 };
209 198
210 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 199 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
211 u32 dtc, etc; 200 u32 etc;
212 int mode = adev->dma_mode; 201 int mode = adev->dma_mode;
213 int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT; 202 int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT;
214 203
215 if (mode >= XFER_UDMA_0) { 204 cs5536_read(pdev, ETC, &etc);
216 cs5536_read(pdev, ETC, &etc);
217 205
206 if (mode >= XFER_UDMA_0) {
218 etc &= ~(IDE_DRV_MASK << dshift); 207 etc &= ~(IDE_DRV_MASK << dshift);
219 etc |= udma_timings[mode - XFER_UDMA_0] << dshift; 208 etc |= udma_timings[mode - XFER_UDMA_0] << dshift;
220
221 cs5536_write(pdev, ETC, etc);
222 } else { /* MWDMA */ 209 } else { /* MWDMA */
223 cs5536_read(pdev, DTC, &dtc); 210 etc &= ~(IDE_ETC_UDMA_MASK << dshift);
224 211 cs5536_program_dtc(adev, mwdma_timings[mode - XFER_MW_DMA_0]);
225 dtc &= ~(IDE_DRV_MASK << dshift);
226 dtc |= mwdma_timings[mode - XFER_MW_DMA_0] << dshift;
227
228 cs5536_write(pdev, DTC, dtc);
229 } 212 }
213
214 cs5536_write(pdev, ETC, etc);
230} 215}
231 216
232static struct scsi_host_template cs5536_sht = { 217static struct scsi_host_template cs5536_sht = {
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index ca9d9caedfa3..c5af97f5107b 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -235,17 +235,7 @@ static struct platform_driver pata_imx_driver = {
235 }, 235 },
236}; 236};
237 237
238static int __init pata_imx_init(void) 238module_platform_driver(pata_imx_driver);
239{
240 return platform_driver_register(&pata_imx_driver);
241}
242
243static void __exit pata_imx_exit(void)
244{
245 platform_driver_unregister(&pata_imx_driver);
246}
247module_init(pata_imx_init);
248module_exit(pata_imx_exit);
249 239
250MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); 240MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
251MODULE_DESCRIPTION("low-level driver for iMX PATA"); 241MODULE_DESCRIPTION("low-level driver for iMX PATA");
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 15b64311fe0a..badb1789a918 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -205,21 +205,10 @@ static struct platform_driver ixp4xx_pata_platform_driver = {
205 .remove = __devexit_p(ixp4xx_pata_remove), 205 .remove = __devexit_p(ixp4xx_pata_remove),
206}; 206};
207 207
208static int __init ixp4xx_pata_init(void) 208module_platform_driver(ixp4xx_pata_platform_driver);
209{
210 return platform_driver_register(&ixp4xx_pata_platform_driver);
211}
212
213static void __exit ixp4xx_pata_exit(void)
214{
215 platform_driver_unregister(&ixp4xx_pata_platform_driver);
216}
217 209
218MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 210MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
219MODULE_DESCRIPTION("low-level driver for ixp4xx Compact Flash PATA"); 211MODULE_DESCRIPTION("low-level driver for ixp4xx Compact Flash PATA");
220MODULE_LICENSE("GPL"); 212MODULE_LICENSE("GPL");
221MODULE_VERSION(DRV_VERSION); 213MODULE_VERSION(DRV_VERSION);
222MODULE_ALIAS("platform:" DRV_NAME); 214MODULE_ALIAS("platform:" DRV_NAME);
223
224module_init(ixp4xx_pata_init);
225module_exit(ixp4xx_pata_exit);
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 3e1746314f22..00748ae1a016 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -897,26 +897,7 @@ static struct platform_driver mpc52xx_ata_of_platform_driver = {
897 }, 897 },
898}; 898};
899 899
900 900module_platform_driver(mpc52xx_ata_of_platform_driver);
901/* ======================================================================== */
902/* Module */
903/* ======================================================================== */
904
905static int __init
906mpc52xx_ata_init(void)
907{
908 printk(KERN_INFO "ata: MPC52xx IDE/ATA libata driver\n");
909 return platform_driver_register(&mpc52xx_ata_of_platform_driver);
910}
911
912static void __exit
913mpc52xx_ata_exit(void)
914{
915 platform_driver_unregister(&mpc52xx_ata_of_platform_driver);
916}
917
918module_init(mpc52xx_ata_init);
919module_exit(mpc52xx_ata_exit);
920 901
921MODULE_AUTHOR("Sylvain Munaut <tnt@246tNt.com>"); 902MODULE_AUTHOR("Sylvain Munaut <tnt@246tNt.com>");
922MODULE_DESCRIPTION("Freescale MPC52xx IDE/ATA libata driver"); 903MODULE_DESCRIPTION("Freescale MPC52xx IDE/ATA libata driver");
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 2a472c5bb7db..1654dc27e7f8 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -12,8 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/of_address.h> 14#include <linux/of_address.h>
15#include <linux/of_irq.h> 15#include <linux/platform_device.h>
16#include <linux/of_platform.h>
17#include <linux/ata_platform.h> 16#include <linux/ata_platform.h>
18 17
19static int __devinit pata_of_platform_probe(struct platform_device *ofdev) 18static int __devinit pata_of_platform_probe(struct platform_device *ofdev)
@@ -22,7 +21,7 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev)
22 struct device_node *dn = ofdev->dev.of_node; 21 struct device_node *dn = ofdev->dev.of_node;
23 struct resource io_res; 22 struct resource io_res;
24 struct resource ctl_res; 23 struct resource ctl_res;
25 struct resource irq_res; 24 struct resource *irq_res;
26 unsigned int reg_shift = 0; 25 unsigned int reg_shift = 0;
27 int pio_mode = 0; 26 int pio_mode = 0;
28 int pio_mask; 27 int pio_mask;
@@ -51,11 +50,9 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev)
51 } 50 }
52 } 51 }
53 52
54 ret = of_irq_to_resource(dn, 0, &irq_res); 53 irq_res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0);
55 if (!ret) 54 if (irq_res)
56 irq_res.start = irq_res.end = 0; 55 irq_res->flags = 0;
57 else
58 irq_res.flags = 0;
59 56
60 prop = of_get_property(dn, "reg-shift", NULL); 57 prop = of_get_property(dn, "reg-shift", NULL);
61 if (prop) 58 if (prop)
@@ -75,7 +72,7 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev)
75 pio_mask = 1 << pio_mode; 72 pio_mask = 1 << pio_mode;
76 pio_mask |= (1 << pio_mode) - 1; 73 pio_mask |= (1 << pio_mode) - 1;
77 74
78 return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res, 75 return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res,
79 reg_shift, pio_mask); 76 reg_shift, pio_mask);
80} 77}
81 78
@@ -101,17 +98,7 @@ static struct platform_driver pata_of_platform_driver = {
101 .remove = __devexit_p(pata_of_platform_remove), 98 .remove = __devexit_p(pata_of_platform_remove),
102}; 99};
103 100
104static int __init pata_of_platform_init(void) 101module_platform_driver(pata_of_platform_driver);
105{
106 return platform_driver_register(&pata_of_platform_driver);
107}
108module_init(pata_of_platform_init);
109
110static void __exit pata_of_platform_exit(void)
111{
112 platform_driver_unregister(&pata_of_platform_driver);
113}
114module_exit(pata_of_platform_exit);
115 102
116MODULE_DESCRIPTION("OF-platform PATA driver"); 103MODULE_DESCRIPTION("OF-platform PATA driver");
117MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>"); 104MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c
index b86d7e22595e..5ff31b68135c 100644
--- a/drivers/ata/pata_palmld.c
+++ b/drivers/ata/pata_palmld.c
@@ -132,20 +132,9 @@ static struct platform_driver palmld_pata_platform_driver = {
132 .remove = __devexit_p(palmld_pata_remove), 132 .remove = __devexit_p(palmld_pata_remove),
133}; 133};
134 134
135static int __init palmld_pata_init(void) 135module_platform_driver(palmld_pata_platform_driver);
136{
137 return platform_driver_register(&palmld_pata_platform_driver);
138}
139
140static void __exit palmld_pata_exit(void)
141{
142 platform_driver_unregister(&palmld_pata_platform_driver);
143}
144 136
145MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); 137MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
146MODULE_DESCRIPTION("PalmLD PATA driver"); 138MODULE_DESCRIPTION("PalmLD PATA driver");
147MODULE_LICENSE("GPL"); 139MODULE_LICENSE("GPL");
148MODULE_ALIAS("platform:" DRV_NAME); 140MODULE_ALIAS("platform:" DRV_NAME);
149
150module_init(palmld_pata_init);
151module_exit(palmld_pata_exit);
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 2067308f683f..f1848aeda783 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -256,17 +256,7 @@ static struct platform_driver pata_platform_driver = {
256 }, 256 },
257}; 257};
258 258
259static int __init pata_platform_init(void) 259module_platform_driver(pata_platform_driver);
260{
261 return platform_driver_register(&pata_platform_driver);
262}
263
264static void __exit pata_platform_exit(void)
265{
266 platform_driver_unregister(&pata_platform_driver);
267}
268module_init(pata_platform_init);
269module_exit(pata_platform_exit);
270 260
271module_param(pio_mask, int, 0); 261module_param(pio_mask, int, 0);
272 262
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index b4ede40f8ae1..0bb0fb7b26bc 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -390,18 +390,7 @@ static struct platform_driver pxa_ata_driver = {
390 }, 390 },
391}; 391};
392 392
393static int __init pxa_ata_init(void) 393module_platform_driver(pxa_ata_driver);
394{
395 return platform_driver_register(&pxa_ata_driver);
396}
397
398static void __exit pxa_ata_exit(void)
399{
400 platform_driver_unregister(&pxa_ata_driver);
401}
402
403module_init(pxa_ata_init);
404module_exit(pxa_ata_exit);
405 394
406MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); 395MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
407MODULE_DESCRIPTION("DMA-capable driver for PATA on PXA CPU"); 396MODULE_DESCRIPTION("DMA-capable driver for PATA on PXA CPU");
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 1b9d10d9c5d9..9417101bd5ca 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -188,9 +188,6 @@ static __devexit int rb532_pata_driver_remove(struct platform_device *pdev)
188 return 0; 188 return 0;
189} 189}
190 190
191/* work with hotplug and coldplug */
192MODULE_ALIAS("platform:" DRV_NAME);
193
194static struct platform_driver rb532_pata_platform_driver = { 191static struct platform_driver rb532_pata_platform_driver = {
195 .probe = rb532_pata_driver_probe, 192 .probe = rb532_pata_driver_probe,
196 .remove = __devexit_p(rb532_pata_driver_remove), 193 .remove = __devexit_p(rb532_pata_driver_remove),
@@ -200,27 +197,13 @@ static struct platform_driver rb532_pata_platform_driver = {
200 }, 197 },
201}; 198};
202 199
203/* ------------------------------------------------------------------------ */
204
205#define DRV_INFO DRV_DESC " version " DRV_VERSION 200#define DRV_INFO DRV_DESC " version " DRV_VERSION
206 201
207static int __init rb532_pata_module_init(void) 202module_platform_driver(rb532_pata_platform_driver);
208{
209 printk(KERN_INFO DRV_INFO "\n");
210
211 return platform_driver_register(&rb532_pata_platform_driver);
212}
213
214static void __exit rb532_pata_module_exit(void)
215{
216 platform_driver_unregister(&rb532_pata_platform_driver);
217}
218 203
219MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>"); 204MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
220MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); 205MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
221MODULE_DESCRIPTION(DRV_DESC); 206MODULE_DESCRIPTION(DRV_DESC);
222MODULE_VERSION(DRV_VERSION); 207MODULE_VERSION(DRV_VERSION);
223MODULE_LICENSE("GPL"); 208MODULE_LICENSE("GPL");
224 209MODULE_ALIAS("platform:" DRV_NAME);
225module_init(rb532_pata_module_init);
226module_exit(rb532_pata_module_exit);
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 5c4237452f50..69f7cde49c6b 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1777,18 +1777,7 @@ static struct platform_driver sata_dwc_driver = {
1777 .remove = sata_dwc_remove, 1777 .remove = sata_dwc_remove,
1778}; 1778};
1779 1779
1780static int __init sata_dwc_init(void) 1780module_platform_driver(sata_dwc_driver);
1781{
1782 return platform_driver_register(&sata_dwc_driver);
1783}
1784
1785static void __exit sata_dwc_exit(void)
1786{
1787 platform_driver_unregister(&sata_dwc_driver);
1788}
1789
1790module_init(sata_dwc_init);
1791module_exit(sata_dwc_exit);
1792 1781
1793MODULE_LICENSE("GPL"); 1782MODULE_LICENSE("GPL");
1794MODULE_AUTHOR("Mark Miesfeld <mmiesfeld@amcc.com>"); 1783MODULE_AUTHOR("Mark Miesfeld <mmiesfeld@amcc.com>");
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 78ae7b67b09e..5a2c95ba050a 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1452,21 +1452,9 @@ static struct platform_driver fsl_sata_driver = {
1452#endif 1452#endif
1453}; 1453};
1454 1454
1455static int __init sata_fsl_init(void) 1455module_platform_driver(fsl_sata_driver);
1456{
1457 platform_driver_register(&fsl_sata_driver);
1458 return 0;
1459}
1460
1461static void __exit sata_fsl_exit(void)
1462{
1463 platform_driver_unregister(&fsl_sata_driver);
1464}
1465 1456
1466MODULE_LICENSE("GPL"); 1457MODULE_LICENSE("GPL");
1467MODULE_AUTHOR("Ashish Kalra, Freescale Semiconductor"); 1458MODULE_AUTHOR("Ashish Kalra, Freescale Semiconductor");
1468MODULE_DESCRIPTION("Freescale 3.0Gbps SATA controller low level driver"); 1459MODULE_DESCRIPTION("Freescale 3.0Gbps SATA controller low level driver");
1469MODULE_VERSION("1.10"); 1460MODULE_VERSION("1.10");
1470
1471module_init(sata_fsl_init);
1472module_exit(sata_fsl_exit);