aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_sx4.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_sx4.c')
-rw-r--r--drivers/ata/sata_sx4.c207
1 files changed, 62 insertions, 145 deletions
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index ae7992de4b08..06e87a377382 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -42,7 +42,6 @@
42#include <scsi/scsi_host.h> 42#include <scsi/scsi_host.h>
43#include <scsi/scsi_cmnd.h> 43#include <scsi/scsi_cmnd.h>
44#include <linux/libata.h> 44#include <linux/libata.h>
45#include <asm/io.h>
46#include "sata_promise.h" 45#include "sata_promise.h"
47 46
48#define DRV_NAME "sata_sx4" 47#define DRV_NAME "sata_sx4"
@@ -50,6 +49,9 @@
50 49
51 50
52enum { 51enum {
52 PDC_MMIO_BAR = 3,
53 PDC_DIMM_BAR = 4,
54
53 PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */ 55 PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */
54 56
55 PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ 57 PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */
@@ -138,8 +140,6 @@ struct pdc_port_priv {
138}; 140};
139 141
140struct pdc_host_priv { 142struct pdc_host_priv {
141 void __iomem *dimm_mmio;
142
143 unsigned int doing_hdma; 143 unsigned int doing_hdma;
144 unsigned int hdma_prod; 144 unsigned int hdma_prod;
145 unsigned int hdma_cons; 145 unsigned int hdma_cons;
@@ -156,11 +156,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance);
156static void pdc_eng_timeout(struct ata_port *ap); 156static void pdc_eng_timeout(struct ata_port *ap);
157static void pdc_20621_phy_reset (struct ata_port *ap); 157static void pdc_20621_phy_reset (struct ata_port *ap);
158static int pdc_port_start(struct ata_port *ap); 158static int pdc_port_start(struct ata_port *ap);
159static void pdc_port_stop(struct ata_port *ap);
160static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 159static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
161static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 160static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
162static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 161static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
163static void pdc20621_host_stop(struct ata_host *host);
164static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); 162static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
165static int pdc20621_detect_dimm(struct ata_probe_ent *pe); 163static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
166static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, 164static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
@@ -205,13 +203,13 @@ static const struct ata_port_operations pdc_20621_ops = {
205 .phy_reset = pdc_20621_phy_reset, 203 .phy_reset = pdc_20621_phy_reset,
206 .qc_prep = pdc20621_qc_prep, 204 .qc_prep = pdc20621_qc_prep,
207 .qc_issue = pdc20621_qc_issue_prot, 205 .qc_issue = pdc20621_qc_issue_prot,
208 .data_xfer = ata_mmio_data_xfer, 206 .data_xfer = ata_data_xfer,
209 .eng_timeout = pdc_eng_timeout, 207 .eng_timeout = pdc_eng_timeout,
210 .irq_handler = pdc20621_interrupt, 208 .irq_handler = pdc20621_interrupt,
211 .irq_clear = pdc20621_irq_clear, 209 .irq_clear = pdc20621_irq_clear,
210 .irq_on = ata_irq_on,
211 .irq_ack = ata_irq_ack,
212 .port_start = pdc_port_start, 212 .port_start = pdc_port_start,
213 .port_stop = pdc_port_stop,
214 .host_stop = pdc20621_host_stop,
215}; 213};
216 214
217static const struct ata_port_info pdc_port_info[] = { 215static const struct ata_port_info pdc_port_info[] = {
@@ -243,18 +241,6 @@ static struct pci_driver pdc_sata_pci_driver = {
243}; 241};
244 242
245 243
246static void pdc20621_host_stop(struct ata_host *host)
247{
248 struct pci_dev *pdev = to_pci_dev(host->dev);
249 struct pdc_host_priv *hpriv = host->private_data;
250 void __iomem *dimm_mmio = hpriv->dimm_mmio;
251
252 pci_iounmap(pdev, dimm_mmio);
253 kfree(hpriv);
254
255 pci_iounmap(pdev, host->mmio_base);
256}
257
258static int pdc_port_start(struct ata_port *ap) 244static int pdc_port_start(struct ata_port *ap)
259{ 245{
260 struct device *dev = ap->host->dev; 246 struct device *dev = ap->host->dev;
@@ -265,43 +251,19 @@ static int pdc_port_start(struct ata_port *ap)
265 if (rc) 251 if (rc)
266 return rc; 252 return rc;
267 253
268 pp = kmalloc(sizeof(*pp), GFP_KERNEL); 254 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
269 if (!pp) { 255 if (!pp)
270 rc = -ENOMEM; 256 return -ENOMEM;
271 goto err_out;
272 }
273 memset(pp, 0, sizeof(*pp));
274 257
275 pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); 258 pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
276 if (!pp->pkt) { 259 if (!pp->pkt)
277 rc = -ENOMEM; 260 return -ENOMEM;
278 goto err_out_kfree;
279 }
280 261
281 ap->private_data = pp; 262 ap->private_data = pp;
282 263
283 return 0; 264 return 0;
284
285err_out_kfree:
286 kfree(pp);
287err_out:
288 ata_port_stop(ap);
289 return rc;
290}
291
292
293static void pdc_port_stop(struct ata_port *ap)
294{
295 struct device *dev = ap->host->dev;
296 struct pdc_port_priv *pp = ap->private_data;
297
298 ap->private_data = NULL;
299 dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
300 kfree(pp);
301 ata_port_stop(ap);
302} 265}
303 266
304
305static void pdc_20621_phy_reset (struct ata_port *ap) 267static void pdc_20621_phy_reset (struct ata_port *ap)
306{ 268{
307 VPRINTK("ENTER\n"); 269 VPRINTK("ENTER\n");
@@ -452,9 +414,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
452 struct scatterlist *sg; 414 struct scatterlist *sg;
453 struct ata_port *ap = qc->ap; 415 struct ata_port *ap = qc->ap;
454 struct pdc_port_priv *pp = ap->private_data; 416 struct pdc_port_priv *pp = ap->private_data;
455 void __iomem *mmio = ap->host->mmio_base; 417 void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
456 struct pdc_host_priv *hpriv = ap->host->private_data; 418 void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
457 void __iomem *dimm_mmio = hpriv->dimm_mmio;
458 unsigned int portno = ap->port_no; 419 unsigned int portno = ap->port_no;
459 unsigned int i, idx, total_len = 0, sgt_len; 420 unsigned int i, idx, total_len = 0, sgt_len;
460 u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; 421 u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
@@ -513,9 +474,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
513{ 474{
514 struct ata_port *ap = qc->ap; 475 struct ata_port *ap = qc->ap;
515 struct pdc_port_priv *pp = ap->private_data; 476 struct pdc_port_priv *pp = ap->private_data;
516 void __iomem *mmio = ap->host->mmio_base; 477 void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
517 struct pdc_host_priv *hpriv = ap->host->private_data; 478 void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
518 void __iomem *dimm_mmio = hpriv->dimm_mmio;
519 unsigned int portno = ap->port_no; 479 unsigned int portno = ap->port_no;
520 unsigned int i; 480 unsigned int i;
521 481
@@ -565,7 +525,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
565{ 525{
566 struct ata_port *ap = qc->ap; 526 struct ata_port *ap = qc->ap;
567 struct ata_host *host = ap->host; 527 struct ata_host *host = ap->host;
568 void __iomem *mmio = host->mmio_base; 528 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
569 529
570 /* hard-code chip #0 */ 530 /* hard-code chip #0 */
571 mmio += PDC_CHIP0_OFS; 531 mmio += PDC_CHIP0_OFS;
@@ -619,8 +579,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
619{ 579{
620 struct ata_port *ap = qc->ap; 580 struct ata_port *ap = qc->ap;
621 unsigned int port_no = ap->port_no; 581 unsigned int port_no = ap->port_no;
622 struct pdc_host_priv *hpriv = ap->host->private_data; 582 void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
623 void *dimm_mmio = hpriv->dimm_mmio;
624 583
625 dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); 584 dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP);
626 dimm_mmio += PDC_DIMM_HOST_PKT; 585 dimm_mmio += PDC_DIMM_HOST_PKT;
@@ -639,7 +598,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
639 struct ata_port *ap = qc->ap; 598 struct ata_port *ap = qc->ap;
640 struct ata_host *host = ap->host; 599 struct ata_host *host = ap->host;
641 unsigned int port_no = ap->port_no; 600 unsigned int port_no = ap->port_no;
642 void __iomem *mmio = host->mmio_base; 601 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
643 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); 602 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
644 u8 seq = (u8) (port_no + 1); 603 u8 seq = (u8) (port_no + 1);
645 unsigned int port_ofs; 604 unsigned int port_ofs;
@@ -668,8 +627,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
668 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ 627 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */
669 628
670 writel(port_ofs + PDC_DIMM_ATA_PKT, 629 writel(port_ofs + PDC_DIMM_ATA_PKT,
671 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 630 ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
672 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 631 readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
673 VPRINTK("submitted ofs 0x%x (%u), seq %u\n", 632 VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
674 port_ofs + PDC_DIMM_ATA_PKT, 633 port_ofs + PDC_DIMM_ATA_PKT,
675 port_ofs + PDC_DIMM_ATA_PKT, 634 port_ofs + PDC_DIMM_ATA_PKT,
@@ -747,8 +706,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
747 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); 706 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
748 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); 707 readl(mmio + PDC_20621_SEQCTL + (seq * 4));
749 writel(port_ofs + PDC_DIMM_ATA_PKT, 708 writel(port_ofs + PDC_DIMM_ATA_PKT,
750 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 709 ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
751 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 710 readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
752 } 711 }
753 712
754 /* step two - execute ATA command */ 713 /* step two - execute ATA command */
@@ -781,7 +740,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
781static void pdc20621_irq_clear(struct ata_port *ap) 740static void pdc20621_irq_clear(struct ata_port *ap)
782{ 741{
783 struct ata_host *host = ap->host; 742 struct ata_host *host = ap->host;
784 void __iomem *mmio = host->mmio_base; 743 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
785 744
786 mmio += PDC_CHIP0_OFS; 745 mmio += PDC_CHIP0_OFS;
787 746
@@ -799,12 +758,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
799 758
800 VPRINTK("ENTER\n"); 759 VPRINTK("ENTER\n");
801 760
802 if (!host || !host->mmio_base) { 761 if (!host || !host->iomap[PDC_MMIO_BAR]) {
803 VPRINTK("QUICK EXIT\n"); 762 VPRINTK("QUICK EXIT\n");
804 return IRQ_NONE; 763 return IRQ_NONE;
805 } 764 }
806 765
807 mmio_base = host->mmio_base; 766 mmio_base = host->iomap[PDC_MMIO_BAR];
808 767
809 /* reading should also clear interrupts */ 768 /* reading should also clear interrupts */
810 mmio_base += PDC_CHIP0_OFS; 769 mmio_base += PDC_CHIP0_OFS;
@@ -905,7 +864,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
905} 864}
906 865
907 866
908static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base) 867static void pdc_sata_setup_port(struct ata_ioports *port, void __iomem *base)
909{ 868{
910 port->cmd_addr = base; 869 port->cmd_addr = base;
911 port->data_addr = base; 870 port->data_addr = base;
@@ -931,9 +890,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
931 u16 idx; 890 u16 idx;
932 u8 page_mask; 891 u8 page_mask;
933 long dist; 892 long dist;
934 void __iomem *mmio = pe->mmio_base; 893 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
935 struct pdc_host_priv *hpriv = pe->private_data; 894 void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
936 void __iomem *dimm_mmio = hpriv->dimm_mmio;
937 895
938 /* hard-code chip #0 */ 896 /* hard-code chip #0 */
939 mmio += PDC_CHIP0_OFS; 897 mmio += PDC_CHIP0_OFS;
@@ -987,9 +945,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
987 u16 idx; 945 u16 idx;
988 u8 page_mask; 946 u8 page_mask;
989 long dist; 947 long dist;
990 void __iomem *mmio = pe->mmio_base; 948 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
991 struct pdc_host_priv *hpriv = pe->private_data; 949 void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
992 void __iomem *dimm_mmio = hpriv->dimm_mmio;
993 950
994 /* hard-code chip #0 */ 951 /* hard-code chip #0 */
995 mmio += PDC_CHIP0_OFS; 952 mmio += PDC_CHIP0_OFS;
@@ -1034,7 +991,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1034static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, 991static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
1035 u32 subaddr, u32 *pdata) 992 u32 subaddr, u32 *pdata)
1036{ 993{
1037 void __iomem *mmio = pe->mmio_base; 994 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
1038 u32 i2creg = 0; 995 u32 i2creg = 0;
1039 u32 status; 996 u32 status;
1040 u32 count =0; 997 u32 count =0;
@@ -1093,7 +1050,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1093 u32 data = 0; 1050 u32 data = 0;
1094 int size, i; 1051 int size, i;
1095 u8 bdimmsize; 1052 u8 bdimmsize;
1096 void __iomem *mmio = pe->mmio_base; 1053 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
1097 static const struct { 1054 static const struct {
1098 unsigned int reg; 1055 unsigned int reg;
1099 unsigned int ofs; 1056 unsigned int ofs;
@@ -1155,8 +1112,8 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1155static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) 1112static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
1156{ 1113{
1157 u32 data, spd0; 1114 u32 data, spd0;
1158 int error, i; 1115 int error, i;
1159 void __iomem *mmio = pe->mmio_base; 1116 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
1160 1117
1161 /* hard-code chip #0 */ 1118 /* hard-code chip #0 */
1162 mmio += PDC_CHIP0_OFS; 1119 mmio += PDC_CHIP0_OFS;
@@ -1210,7 +1167,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1210 u32 ticks=0; 1167 u32 ticks=0;
1211 u32 clock=0; 1168 u32 clock=0;
1212 u32 fparam=0; 1169 u32 fparam=0;
1213 void __iomem *mmio = pe->mmio_base; 1170 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
1214 1171
1215 /* hard-code chip #0 */ 1172 /* hard-code chip #0 */
1216 mmio += PDC_CHIP0_OFS; 1173 mmio += PDC_CHIP0_OFS;
@@ -1334,7 +1291,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1334static void pdc_20621_init(struct ata_probe_ent *pe) 1291static void pdc_20621_init(struct ata_probe_ent *pe)
1335{ 1292{
1336 u32 tmp; 1293 u32 tmp;
1337 void __iomem *mmio = pe->mmio_base; 1294 void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
1338 1295
1339 /* hard-code chip #0 */ 1296 /* hard-code chip #0 */
1340 mmio += PDC_CHIP0_OFS; 1297 mmio += PDC_CHIP0_OFS;
@@ -1365,67 +1322,43 @@ static void pdc_20621_init(struct ata_probe_ent *pe)
1365static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1322static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1366{ 1323{
1367 static int printed_version; 1324 static int printed_version;
1368 struct ata_probe_ent *probe_ent = NULL; 1325 struct ata_probe_ent *probe_ent;
1369 unsigned long base; 1326 void __iomem *base;
1370 void __iomem *mmio_base; 1327 struct pdc_host_priv *hpriv;
1371 void __iomem *dimm_mmio = NULL;
1372 struct pdc_host_priv *hpriv = NULL;
1373 unsigned int board_idx = (unsigned int) ent->driver_data; 1328 unsigned int board_idx = (unsigned int) ent->driver_data;
1374 int pci_dev_busy = 0;
1375 int rc; 1329 int rc;
1376 1330
1377 if (!printed_version++) 1331 if (!printed_version++)
1378 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 1332 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1379 1333
1380 rc = pci_enable_device(pdev); 1334 rc = pcim_enable_device(pdev);
1381 if (rc) 1335 if (rc)
1382 return rc; 1336 return rc;
1383 1337
1384 rc = pci_request_regions(pdev, DRV_NAME); 1338 rc = pcim_iomap_regions(pdev, (1 << PDC_MMIO_BAR) | (1 << PDC_DIMM_BAR),
1385 if (rc) { 1339 DRV_NAME);
1386 pci_dev_busy = 1; 1340 if (rc == -EBUSY)
1387 goto err_out; 1341 pcim_pin_device(pdev);
1388 } 1342 if (rc)
1343 return rc;
1389 1344
1390 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 1345 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
1391 if (rc) 1346 if (rc)
1392 goto err_out_regions; 1347 return rc;
1393 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); 1348 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
1394 if (rc) 1349 if (rc)
1395 goto err_out_regions; 1350 return rc;
1396 1351
1397 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 1352 probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
1398 if (probe_ent == NULL) { 1353 if (probe_ent == NULL)
1399 rc = -ENOMEM; 1354 return -ENOMEM;
1400 goto err_out_regions;
1401 }
1402 1355
1403 memset(probe_ent, 0, sizeof(*probe_ent));
1404 probe_ent->dev = pci_dev_to_dev(pdev); 1356 probe_ent->dev = pci_dev_to_dev(pdev);
1405 INIT_LIST_HEAD(&probe_ent->node); 1357 INIT_LIST_HEAD(&probe_ent->node);
1406 1358
1407 mmio_base = pci_iomap(pdev, 3, 0); 1359 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
1408 if (mmio_base == NULL) { 1360 if (!hpriv)
1409 rc = -ENOMEM; 1361 return -ENOMEM;
1410 goto err_out_free_ent;
1411 }
1412 base = (unsigned long) mmio_base;
1413
1414 hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
1415 if (!hpriv) {
1416 rc = -ENOMEM;
1417 goto err_out_iounmap;
1418 }
1419 memset(hpriv, 0, sizeof(*hpriv));
1420
1421 dimm_mmio = pci_iomap(pdev, 4, 0);
1422 if (!dimm_mmio) {
1423 kfree(hpriv);
1424 rc = -ENOMEM;
1425 goto err_out_iounmap;
1426 }
1427
1428 hpriv->dimm_mmio = dimm_mmio;
1429 1362
1430 probe_ent->sht = pdc_port_info[board_idx].sht; 1363 probe_ent->sht = pdc_port_info[board_idx].sht;
1431 probe_ent->port_flags = pdc_port_info[board_idx].flags; 1364 probe_ent->port_flags = pdc_port_info[board_idx].flags;
@@ -1436,10 +1369,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1436 1369
1437 probe_ent->irq = pdev->irq; 1370 probe_ent->irq = pdev->irq;
1438 probe_ent->irq_flags = IRQF_SHARED; 1371 probe_ent->irq_flags = IRQF_SHARED;
1439 probe_ent->mmio_base = mmio_base; 1372 probe_ent->iomap = pcim_iomap_table(pdev);
1440 1373
1441 probe_ent->private_data = hpriv; 1374 probe_ent->private_data = hpriv;
1442 base += PDC_CHIP0_OFS; 1375 base = probe_ent->iomap[PDC_MMIO_BAR] + PDC_CHIP0_OFS;
1443 1376
1444 probe_ent->n_ports = 4; 1377 probe_ent->n_ports = 4;
1445 pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); 1378 pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
@@ -1451,31 +1384,15 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1451 1384
1452 /* initialize adapter */ 1385 /* initialize adapter */
1453 /* initialize local dimm */ 1386 /* initialize local dimm */
1454 if (pdc20621_dimm_init(probe_ent)) { 1387 if (pdc20621_dimm_init(probe_ent))
1455 rc = -ENOMEM; 1388 return -ENOMEM;
1456 goto err_out_iounmap_dimm;
1457 }
1458 pdc_20621_init(probe_ent); 1389 pdc_20621_init(probe_ent);
1459 1390
1460 /* FIXME: check ata_device_add return value */ 1391 if (!ata_device_add(probe_ent))
1461 ata_device_add(probe_ent); 1392 return -ENODEV;
1462 kfree(probe_ent);
1463 1393
1394 devm_kfree(&pdev->dev, probe_ent);
1464 return 0; 1395 return 0;
1465
1466err_out_iounmap_dimm: /* only get to this label if 20621 */
1467 kfree(hpriv);
1468 pci_iounmap(pdev, dimm_mmio);
1469err_out_iounmap:
1470 pci_iounmap(pdev, mmio_base);
1471err_out_free_ent:
1472 kfree(probe_ent);
1473err_out_regions:
1474 pci_release_regions(pdev);
1475err_out:
1476 if (!pci_dev_busy)
1477 pci_disable_device(pdev);
1478 return rc;
1479} 1396}
1480 1397
1481 1398