diff options
-rw-r--r-- | drivers/ata/ahci.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index f55c9e746b73..4f2c05ef1f09 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -814,39 +814,49 @@ static int ahci_reset_controller(struct ata_host *host) | |||
814 | return 0; | 814 | return 0; |
815 | } | 815 | } |
816 | 816 | ||
817 | static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap, | ||
818 | int port_no, void __iomem *mmio, | ||
819 | void __iomem *port_mmio) | ||
820 | { | ||
821 | const char *emsg = NULL; | ||
822 | int rc; | ||
823 | u32 tmp; | ||
824 | |||
825 | /* make sure port is not active */ | ||
826 | rc = ahci_deinit_port(ap, &emsg); | ||
827 | if (rc) | ||
828 | dev_printk(KERN_WARNING, &pdev->dev, | ||
829 | "%s (%d)\n", emsg, rc); | ||
830 | |||
831 | /* clear SError */ | ||
832 | tmp = readl(port_mmio + PORT_SCR_ERR); | ||
833 | VPRINTK("PORT_SCR_ERR 0x%x\n", tmp); | ||
834 | writel(tmp, port_mmio + PORT_SCR_ERR); | ||
835 | |||
836 | /* clear port IRQ */ | ||
837 | tmp = readl(port_mmio + PORT_IRQ_STAT); | ||
838 | VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp); | ||
839 | if (tmp) | ||
840 | writel(tmp, port_mmio + PORT_IRQ_STAT); | ||
841 | |||
842 | writel(1 << port_no, mmio + HOST_IRQ_STAT); | ||
843 | } | ||
844 | |||
817 | static void ahci_init_controller(struct ata_host *host) | 845 | static void ahci_init_controller(struct ata_host *host) |
818 | { | 846 | { |
819 | struct pci_dev *pdev = to_pci_dev(host->dev); | 847 | struct pci_dev *pdev = to_pci_dev(host->dev); |
820 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; | 848 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; |
821 | int i, rc; | 849 | int i; |
822 | u32 tmp; | 850 | u32 tmp; |
823 | 851 | ||
824 | for (i = 0; i < host->n_ports; i++) { | 852 | for (i = 0; i < host->n_ports; i++) { |
825 | struct ata_port *ap = host->ports[i]; | 853 | struct ata_port *ap = host->ports[i]; |
826 | void __iomem *port_mmio = ahci_port_base(ap); | 854 | void __iomem *port_mmio = ahci_port_base(ap); |
827 | const char *emsg = NULL; | ||
828 | 855 | ||
829 | if (ata_port_is_dummy(ap)) | 856 | if (ata_port_is_dummy(ap)) |
830 | continue; | 857 | continue; |
831 | 858 | ||
832 | /* make sure port is not active */ | 859 | ahci_port_init(pdev, ap, i, mmio, port_mmio); |
833 | rc = ahci_deinit_port(ap, &emsg); | ||
834 | if (rc) | ||
835 | dev_printk(KERN_WARNING, &pdev->dev, | ||
836 | "%s (%d)\n", emsg, rc); | ||
837 | |||
838 | /* clear SError */ | ||
839 | tmp = readl(port_mmio + PORT_SCR_ERR); | ||
840 | VPRINTK("PORT_SCR_ERR 0x%x\n", tmp); | ||
841 | writel(tmp, port_mmio + PORT_SCR_ERR); | ||
842 | |||
843 | /* clear port IRQ */ | ||
844 | tmp = readl(port_mmio + PORT_IRQ_STAT); | ||
845 | VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp); | ||
846 | if (tmp) | ||
847 | writel(tmp, port_mmio + PORT_IRQ_STAT); | ||
848 | |||
849 | writel(1 << i, mmio + HOST_IRQ_STAT); | ||
850 | } | 860 | } |
851 | 861 | ||
852 | tmp = readl(mmio + HOST_CTL); | 862 | tmp = readl(mmio + HOST_CTL); |