[PATCH] sata_sil: separate out sil_init_controller()

Separate out controller initialization from sil_init_one() into
sil_init_controller(). This will be used by resume.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik 3d8ec913 500530f6

+48 -38
+48 -38
drivers/scsi/sata_sil.c
··· 561 561 } 562 562 } 563 563 564 + static void sil_init_controller(struct pci_dev *pdev, 565 + int n_ports, unsigned long host_flags, 566 + void __iomem *mmio_base) 567 + { 568 + u8 cls; 569 + u32 tmp; 570 + int i; 571 + 572 + /* Initialize FIFO PCI bus arbitration */ 573 + cls = sil_get_device_cache_line(pdev); 574 + if (cls) { 575 + cls >>= 3; 576 + cls++; /* cls = (line_size/8)+1 */ 577 + for (i = 0; i < n_ports; i++) 578 + writew(cls << 8 | cls, 579 + mmio_base + sil_port[i].fifo_cfg); 580 + } else 581 + dev_printk(KERN_WARNING, &pdev->dev, 582 + "cache line size not set. Driver may not function\n"); 583 + 584 + /* Apply R_ERR on DMA activate FIS errata workaround */ 585 + if (host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { 586 + int cnt; 587 + 588 + for (i = 0, cnt = 0; i < n_ports; i++) { 589 + tmp = readl(mmio_base + sil_port[i].sfis_cfg); 590 + if ((tmp & 0x3) != 0x01) 591 + continue; 592 + if (!cnt) 593 + dev_printk(KERN_INFO, &pdev->dev, 594 + "Applying R_ERR on DMA activate " 595 + "FIS errata fix\n"); 596 + writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg); 597 + cnt++; 598 + } 599 + } 600 + 601 + if (n_ports == 4) { 602 + /* flip the magic "make 4 ports work" bit */ 603 + tmp = readl(mmio_base + sil_port[2].bmdma); 604 + if ((tmp & SIL_INTR_STEERING) == 0) 605 + writel(tmp | SIL_INTR_STEERING, 606 + mmio_base + sil_port[2].bmdma); 607 + } 608 + } 609 + 564 610 static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 565 611 { 566 612 static int printed_version; ··· 616 570 int rc; 617 571 unsigned int i; 618 572 int pci_dev_busy = 0; 619 - u32 tmp; 620 - u8 cls; 621 573 622 574 if (!printed_version++) 623 575 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); ··· 674 630 ata_std_ports(&probe_ent->port[i]); 675 631 } 676 632 677 - /* Initialize FIFO PCI bus arbitration */ 678 - cls = sil_get_device_cache_line(pdev); 679 - if (cls) { 680 - cls >>= 3; 681 - cls++; /* cls = (line_size/8)+1 */ 682 - for (i = 0; i < probe_ent->n_ports; i++) 683 - writew(cls << 8 | cls, 684 - mmio_base + sil_port[i].fifo_cfg); 685 - } else 686 - dev_printk(KERN_WARNING, &pdev->dev, 687 - "cache line size not set. Driver may not function\n"); 688 - 689 - /* Apply R_ERR on DMA activate FIS errata workaround */ 690 - if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { 691 - int cnt; 692 - 693 - for (i = 0, cnt = 0; i < probe_ent->n_ports; i++) { 694 - tmp = readl(mmio_base + sil_port[i].sfis_cfg); 695 - if ((tmp & 0x3) != 0x01) 696 - continue; 697 - if (!cnt) 698 - dev_printk(KERN_INFO, &pdev->dev, 699 - "Applying R_ERR on DMA activate " 700 - "FIS errata fix\n"); 701 - writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg); 702 - cnt++; 703 - } 704 - } 705 - 706 - if (ent->driver_data == sil_3114) { 707 - /* flip the magic "make 4 ports work" bit */ 708 - tmp = readl(mmio_base + sil_port[2].bmdma); 709 - if ((tmp & SIL_INTR_STEERING) == 0) 710 - writel(tmp | SIL_INTR_STEERING, 711 - mmio_base + sil_port[2].bmdma); 712 - } 633 + sil_init_controller(pdev, probe_ent->n_ports, probe_ent->host_flags, 634 + mmio_base); 713 635 714 636 pci_set_master(pdev); 715 637