aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_platform.c')
-rw-r--r--drivers/ata/pata_platform.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index fc72a965643d..ac03a90a6168 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Generic platform device PATA driver 2 * Generic platform device PATA driver
3 * 3 *
4 * Copyright (C) 2006 Paul Mundt 4 * Copyright (C) 2006 - 2007 Paul Mundt
5 * 5 *
6 * Based on pata_pcmcia: 6 * Based on pata_pcmcia:
7 * 7 *
@@ -22,7 +22,7 @@
22#include <linux/pata_platform.h> 22#include <linux/pata_platform.h>
23 23
24#define DRV_NAME "pata_platform" 24#define DRV_NAME "pata_platform"
25#define DRV_VERSION "1.1" 25#define DRV_VERSION "1.2"
26 26
27static int pio_mask = 1; 27static int pio_mask = 1;
28 28
@@ -120,15 +120,20 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,
120 * Register a platform bus IDE interface. Such interfaces are PIO and we 120 * Register a platform bus IDE interface. Such interfaces are PIO and we
121 * assume do not support IRQ sharing. 121 * assume do not support IRQ sharing.
122 * 122 *
123 * Platform devices are expected to contain 3 resources per port: 123 * Platform devices are expected to contain at least 2 resources per port:
124 * 124 *
125 * - I/O Base (IORESOURCE_IO or IORESOURCE_MEM) 125 * - I/O Base (IORESOURCE_IO or IORESOURCE_MEM)
126 * - CTL Base (IORESOURCE_IO or IORESOURCE_MEM) 126 * - CTL Base (IORESOURCE_IO or IORESOURCE_MEM)
127 *
128 * and optionally:
129 *
127 * - IRQ (IORESOURCE_IRQ) 130 * - IRQ (IORESOURCE_IRQ)
128 * 131 *
129 * If the base resources are both mem types, the ioremap() is handled 132 * If the base resources are both mem types, the ioremap() is handled
130 * here. For IORESOURCE_IO, it's assumed that there's no remapping 133 * here. For IORESOURCE_IO, it's assumed that there's no remapping
131 * necessary. 134 * necessary.
135 *
136 * If no IRQ resource is present, PIO polling mode is used instead.
132 */ 137 */
133static int __devinit pata_platform_probe(struct platform_device *pdev) 138static int __devinit pata_platform_probe(struct platform_device *pdev)
134{ 139{
@@ -137,11 +142,12 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
137 struct ata_port *ap; 142 struct ata_port *ap;
138 struct pata_platform_info *pp_info; 143 struct pata_platform_info *pp_info;
139 unsigned int mmio; 144 unsigned int mmio;
145 int irq;
140 146
141 /* 147 /*
142 * Simple resource validation .. 148 * Simple resource validation ..
143 */ 149 */
144 if (unlikely(pdev->num_resources != 3)) { 150 if ((pdev->num_resources != 3) && (pdev->num_resources != 2)) {
145 dev_err(&pdev->dev, "invalid number of resources\n"); 151 dev_err(&pdev->dev, "invalid number of resources\n");
146 return -EINVAL; 152 return -EINVAL;
147 } 153 }
@@ -173,6 +179,13 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
173 (ctl_res->flags == IORESOURCE_MEM)); 179 (ctl_res->flags == IORESOURCE_MEM));
174 180
175 /* 181 /*
182 * And the IRQ
183 */
184 irq = platform_get_irq(pdev, 0);
185 if (irq < 0)
186 irq = 0; /* no irq */
187
188 /*
176 * Now that that's out of the way, wire up the port.. 189 * Now that that's out of the way, wire up the port..
177 */ 190 */
178 host = ata_host_alloc(&pdev->dev, 1); 191 host = ata_host_alloc(&pdev->dev, 1);
@@ -185,6 +198,14 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
185 ap->flags |= ATA_FLAG_SLAVE_POSS; 198 ap->flags |= ATA_FLAG_SLAVE_POSS;
186 199
187 /* 200 /*
201 * Use polling mode if there's no IRQ
202 */
203 if (!irq) {
204 ap->flags |= ATA_FLAG_PIO_POLLING;
205 ata_port_desc(ap, "no IRQ, using PIO polling");
206 }
207
208 /*
188 * Handle the MMIO case 209 * Handle the MMIO case
189 */ 210 */
190 if (mmio) { 211 if (mmio) {
@@ -213,9 +234,9 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
213 (unsigned long long)ctl_res->start); 234 (unsigned long long)ctl_res->start);
214 235
215 /* activate */ 236 /* activate */
216 return ata_host_activate(host, platform_get_irq(pdev, 0), 237 return ata_host_activate(host, irq, irq ? ata_interrupt : NULL,
217 ata_interrupt, pp_info ? pp_info->irq_flags 238 pp_info ? pp_info->irq_flags : 0,
218 : 0, &pata_platform_sht); 239 &pata_platform_sht);
219} 240}
220 241
221/** 242/**