aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sata_nv.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-03-22 23:59:46 -0500
committerJeff Garzik <jeff@garzik.org>2006-03-22 23:59:46 -0500
commit02cbd926e9acdc03574d26803050cd2664f59ada (patch)
tree09535e44392d50d2fd7853e99ded7b7b5aedfea7 /drivers/scsi/sata_nv.c
parent10ad05df14fb5b6ac1fcdaa312a9c13e77627a97 (diff)
[libata sata_nv] eliminate duplicate codepaths with iomap
eliminate a bunch of if (mmio) writel() else outl() code with the pci_iomap() and io{read,write}{8,16,32}() interface.
Diffstat (limited to 'drivers/scsi/sata_nv.c')
-rw-r--r--drivers/scsi/sata_nv.c57
1 files changed, 13 insertions, 44 deletions
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 834003eb36a7..f77bf183dfab 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -149,8 +149,6 @@ static const struct pci_device_id nv_pci_tbl[] = {
149 { 0, } /* terminate list */ 149 { 0, } /* terminate list */
150}; 150};
151 151
152#define NV_HOST_FLAGS_SCR_MMIO 0x00000001
153
154struct nv_host_desc 152struct nv_host_desc
155{ 153{
156 enum nv_host_type host_type; 154 enum nv_host_type host_type;
@@ -306,36 +304,23 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
306 304
307static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg) 305static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
308{ 306{
309 struct ata_host_set *host_set = ap->host_set;
310 struct nv_host *host = host_set->private_data;
311
312 if (sc_reg > SCR_CONTROL) 307 if (sc_reg > SCR_CONTROL)
313 return 0xffffffffU; 308 return 0xffffffffU;
314 309
315 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 310 return ioread32((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
316 return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
317 else
318 return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
319} 311}
320 312
321static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 313static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
322{ 314{
323 struct ata_host_set *host_set = ap->host_set;
324 struct nv_host *host = host_set->private_data;
325
326 if (sc_reg > SCR_CONTROL) 315 if (sc_reg > SCR_CONTROL)
327 return; 316 return;
328 317
329 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 318 iowrite32(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
330 writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
331 else
332 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
333} 319}
334 320
335static void nv_host_stop (struct ata_host_set *host_set) 321static void nv_host_stop (struct ata_host_set *host_set)
336{ 322{
337 struct nv_host *host = host_set->private_data; 323 struct nv_host *host = host_set->private_data;
338 struct pci_dev *pdev = to_pci_dev(host_set->dev);
339 324
340 // Disable hotplug event interrupts. 325 // Disable hotplug event interrupts.
341 if (host->host_desc->disable_hotplug) 326 if (host->host_desc->disable_hotplug)
@@ -343,8 +328,7 @@ static void nv_host_stop (struct ata_host_set *host_set)
343 328
344 kfree(host); 329 kfree(host);
345 330
346 if (host_set->mmio_base) 331 ata_pci_host_stop(host_set);
347 pci_iounmap(pdev, host_set->mmio_base);
348} 332}
349 333
350static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 334static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -356,6 +340,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
356 int pci_dev_busy = 0; 340 int pci_dev_busy = 0;
357 int rc; 341 int rc;
358 u32 bar; 342 u32 bar;
343 unsigned long base;
359 344
360 // Make sure this is a SATA controller by counting the number of bars 345 // Make sure this is a SATA controller by counting the number of bars
361 // (NVIDIA SATA controllers will always have six bars). Otherwise, 346 // (NVIDIA SATA controllers will always have six bars). Otherwise,
@@ -400,31 +385,16 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
400 385
401 probe_ent->private_data = host; 386 probe_ent->private_data = host;
402 387
403 if (pci_resource_flags(pdev, 5) & IORESOURCE_MEM) 388 probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
404 host->host_flags |= NV_HOST_FLAGS_SCR_MMIO; 389 if (!probe_ent->mmio_base) {
405 390 rc = -EIO;
406 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) { 391 goto err_out_free_host;
407 unsigned long base; 392 }
408
409 probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
410 if (probe_ent->mmio_base == NULL) {
411 rc = -EIO;
412 goto err_out_free_host;
413 }
414
415 base = (unsigned long)probe_ent->mmio_base;
416 393
417 probe_ent->port[0].scr_addr = 394 base = (unsigned long)probe_ent->mmio_base;
418 base + NV_PORT0_SCR_REG_OFFSET;
419 probe_ent->port[1].scr_addr =
420 base + NV_PORT1_SCR_REG_OFFSET;
421 } else {
422 395
423 probe_ent->port[0].scr_addr = 396 probe_ent->port[0].scr_addr = base + NV_PORT0_SCR_REG_OFFSET;
424 pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET; 397 probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
425 probe_ent->port[1].scr_addr =
426 pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
427 }
428 398
429 pci_set_master(pdev); 399 pci_set_master(pdev);
430 400
@@ -441,8 +411,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
441 return 0; 411 return 0;
442 412
443err_out_iounmap: 413err_out_iounmap:
444 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 414 pci_iounmap(pdev, probe_ent->mmio_base);
445 pci_iounmap(pdev, probe_ent->mmio_base);
446err_out_free_host: 415err_out_free_host:
447 kfree(host); 416 kfree(host);
448err_out_free_ent: 417err_out_free_ent: