aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/sgiioc4.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/sgiioc4.c')
-rw-r--r--drivers/ide/pci/sgiioc4.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 1017fb4f631..dd634541ce3 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
3 * Copyright (C) 2008 MontaVista Software, Inc.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License 6 * under the terms of version 2 of the GNU General Public License
@@ -150,7 +151,7 @@ sgiioc4_clearirq(ide_drive_t * drive)
150 int count = 0; 151 int count = 0;
151 152
152 stat = sgiioc4_read_status(hwif); 153 stat = sgiioc4_read_status(hwif);
153 while ((stat & 0x80) && (count++ < 100)) { 154 while ((stat & ATA_BUSY) && (count++ < 100)) {
154 udelay(1); 155 udelay(1);
155 stat = sgiioc4_read_status(hwif); 156 stat = sgiioc4_read_status(hwif);
156 } 157 }
@@ -310,7 +311,7 @@ static u8 sgiioc4_read_status(ide_hwif_t *hwif)
310 u8 reg = (u8) readb((void __iomem *) port); 311 u8 reg = (u8) readb((void __iomem *) port);
311 312
312 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 313 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */
313 if (reg & 0x51) { /* Not busy...check for interrupt */ 314 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
314 unsigned long other_ir = port - 0x110; 315 unsigned long other_ir = port - 0x110;
315 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir); 316 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
316 317
@@ -338,35 +339,31 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
338 if (dma_base == 0) 339 if (dma_base == 0)
339 return -1; 340 return -1;
340 341
341 printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, 342 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
342 dma_base, dma_base + num_ports - 1);
343 343
344 if (!request_mem_region(dma_base, num_ports, hwif->name)) { 344 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
345 printk(KERN_ERR 345 printk(KERN_ERR "%s(%s) -- ERROR: addresses 0x%08lx to 0x%08lx "
346 "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " 346 "already in use\n", __func__, hwif->name,
347 "ALREADY in use\n", 347 dma_base, dma_base + num_ports - 1);
348 __func__, hwif->name, (void *) dma_base,
349 (void *) dma_base + num_ports - 1);
350 return -1; 348 return -1;
351 } 349 }
352 350
353 virt_dma_base = ioremap(dma_base, num_ports); 351 virt_dma_base = ioremap(dma_base, num_ports);
354 if (virt_dma_base == NULL) { 352 if (virt_dma_base == NULL) {
355 printk(KERN_ERR 353 printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses "
356 "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", 354 "0x%lx to 0x%lx\n", __func__, hwif->name,
357 __func__, hwif->name, dma_base, dma_base + num_ports - 1); 355 dma_base, dma_base + num_ports - 1);
358 goto dma_remap_failure; 356 goto dma_remap_failure;
359 } 357 }
360 hwif->dma_base = (unsigned long) virt_dma_base; 358 hwif->dma_base = (unsigned long) virt_dma_base;
361 359
362 hwif->dmatable_cpu = pci_alloc_consistent(dev, 360 hwif->sg_max_nents = IOC4_PRD_ENTRIES;
363 IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
364 &hwif->dmatable_dma);
365 361
366 if (!hwif->dmatable_cpu) 362 hwif->prd_max_nents = IOC4_PRD_ENTRIES;
367 goto dma_pci_alloc_failure; 363 hwif->prd_ent_size = IOC4_PRD_BYTES;
368 364
369 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 365 if (ide_allocate_dma_engine(hwif))
366 goto dma_pci_alloc_failure;
370 367
371 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, 368 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE,
372 (dma_addr_t *)&hwif->extra_base); 369 (dma_addr_t *)&hwif->extra_base);
@@ -375,13 +372,11 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
375 return 0; 372 return 0;
376 } 373 }
377 374
378 pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 375 ide_release_dma_engine(hwif);
379 hwif->dmatable_cpu, hwif->dmatable_dma); 376
380 printk(KERN_INFO 377 printk(KERN_ERR "%s(%s) -- ERROR: Unable to allocate DMA maps\n",
381 "%s() -- Error! Unable to allocate DMA Maps for drive %s\n",
382 __func__, hwif->name); 378 __func__, hwif->name);
383 printk(KERN_INFO 379 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
384 "Changing from DMA to PIO mode for Drive %s\n", hwif->name);
385 380
386dma_pci_alloc_failure: 381dma_pci_alloc_failure:
387 iounmap(virt_dma_base); 382 iounmap(virt_dma_base);
@@ -617,14 +612,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
617 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; 612 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET;
618 613
619 cmd_phys_base = bar0 + IOC4_CMD_OFFSET; 614 cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
620 if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, 615 if (request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
621 DRV_NAME)) { 616 DRV_NAME) == NULL) {
622 printk(KERN_ERR 617 printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx "
623 "%s %s: -- ERROR, Addresses " 618 "already in use\n", DRV_NAME, pci_name(dev),
624 "0x%p to 0x%p ALREADY in use\n", 619 cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
625 DRV_NAME, pci_name(dev), (void *)cmd_phys_base, 620 return -EBUSY;
626 (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
627 return -ENOMEM;
628 } 621 }
629 622
630 /* Initialize the IO registers */ 623 /* Initialize the IO registers */