aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sata_mv.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-11-12 22:17:49 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-11-12 22:17:49 -0500
commit101ffae26c23ea928fce6d31a8b4901327d91a15 (patch)
tree1ca01659b0786b3d6968a2aa335a99890917522f /drivers/scsi/sata_mv.c
parent522479fb98c6667f081e75f87e298e413c0b1db8 (diff)
[libata sata_mv] move code around
No content changes. Move 60xx code to be closer to other 60xx code.
Diffstat (limited to 'drivers/scsi/sata_mv.c')
-rw-r--r--drivers/scsi/sata_mv.c200
1 files changed, 100 insertions, 100 deletions
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 180baa532068..f695d0bbb5cc 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -679,106 +679,6 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
679 } 679 }
680} 680}
681 681
682#undef ZERO
683#define ZERO(reg) writel(0, mmio + (reg))
684static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio)
685{
686 u32 tmp;
687
688 tmp = readl(mmio + MV_PCI_MODE);
689 tmp &= 0xff00ffff;
690 writel(tmp, mmio + MV_PCI_MODE);
691
692 ZERO(MV_PCI_DISC_TIMER);
693 ZERO(MV_PCI_MSI_TRIGGER);
694 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT);
695 ZERO(HC_MAIN_IRQ_MASK_OFS);
696 ZERO(MV_PCI_SERR_MASK);
697 ZERO(PCI_IRQ_CAUSE_OFS);
698 ZERO(PCI_IRQ_MASK_OFS);
699 ZERO(MV_PCI_ERR_LOW_ADDRESS);
700 ZERO(MV_PCI_ERR_HIGH_ADDRESS);
701 ZERO(MV_PCI_ERR_ATTRIBUTE);
702 ZERO(MV_PCI_ERR_COMMAND);
703}
704#undef ZERO
705
706static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
707{
708 u32 tmp;
709
710 mv5_reset_flash(hpriv, mmio);
711
712 tmp = readl(mmio + MV_GPIO_PORT_CTL);
713 tmp &= 0x3;
714 tmp |= (1 << 5) | (1 << 6);
715 writel(tmp, mmio + MV_GPIO_PORT_CTL);
716}
717
718/**
719 * mv6_reset_hc - Perform the 6xxx global soft reset
720 * @mmio: base address of the HBA
721 *
722 * This routine only applies to 6xxx parts.
723 *
724 * LOCKING:
725 * Inherited from caller.
726 */
727static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio)
728{
729 void __iomem *reg = mmio + PCI_MAIN_CMD_STS_OFS;
730 int i, rc = 0;
731 u32 t;
732
733 /* Following procedure defined in PCI "main command and status
734 * register" table.
735 */
736 t = readl(reg);
737 writel(t | STOP_PCI_MASTER, reg);
738
739 for (i = 0; i < 1000; i++) {
740 udelay(1);
741 t = readl(reg);
742 if (PCI_MASTER_EMPTY & t) {
743 break;
744 }
745 }
746 if (!(PCI_MASTER_EMPTY & t)) {
747 printk(KERN_ERR DRV_NAME ": PCI master won't flush\n");
748 rc = 1;
749 goto done;
750 }
751
752 /* set reset */
753 i = 5;
754 do {
755 writel(t | GLOB_SFT_RST, reg);
756 t = readl(reg);
757 udelay(1);
758 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
759
760 if (!(GLOB_SFT_RST & t)) {
761 printk(KERN_ERR DRV_NAME ": can't set global reset\n");
762 rc = 1;
763 goto done;
764 }
765
766 /* clear reset and *reenable the PCI master* (not mentioned in spec) */
767 i = 5;
768 do {
769 writel(t & ~(GLOB_SFT_RST | STOP_PCI_MASTER), reg);
770 t = readl(reg);
771 udelay(1);
772 } while ((GLOB_SFT_RST & t) && (i-- > 0));
773
774 if (GLOB_SFT_RST & t) {
775 printk(KERN_ERR DRV_NAME ": can't clear global reset\n");
776 rc = 1;
777 }
778done:
779 return rc;
780}
781
782/** 682/**
783 * mv_host_stop - Host specific cleanup/stop routine. 683 * mv_host_stop - Host specific cleanup/stop routine.
784 * @host_set: host data structure 684 * @host_set: host data structure
@@ -1386,6 +1286,106 @@ static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio)
1386 return 1; 1286 return 1;
1387} 1287}
1388 1288
1289#undef ZERO
1290#define ZERO(reg) writel(0, mmio + (reg))
1291static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio)
1292{
1293 u32 tmp;
1294
1295 tmp = readl(mmio + MV_PCI_MODE);
1296 tmp &= 0xff00ffff;
1297 writel(tmp, mmio + MV_PCI_MODE);
1298
1299 ZERO(MV_PCI_DISC_TIMER);
1300 ZERO(MV_PCI_MSI_TRIGGER);
1301 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT);
1302 ZERO(HC_MAIN_IRQ_MASK_OFS);
1303 ZERO(MV_PCI_SERR_MASK);
1304 ZERO(PCI_IRQ_CAUSE_OFS);
1305 ZERO(PCI_IRQ_MASK_OFS);
1306 ZERO(MV_PCI_ERR_LOW_ADDRESS);
1307 ZERO(MV_PCI_ERR_HIGH_ADDRESS);
1308 ZERO(MV_PCI_ERR_ATTRIBUTE);
1309 ZERO(MV_PCI_ERR_COMMAND);
1310}
1311#undef ZERO
1312
1313static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
1314{
1315 u32 tmp;
1316
1317 mv5_reset_flash(hpriv, mmio);
1318
1319 tmp = readl(mmio + MV_GPIO_PORT_CTL);
1320 tmp &= 0x3;
1321 tmp |= (1 << 5) | (1 << 6);
1322 writel(tmp, mmio + MV_GPIO_PORT_CTL);
1323}
1324
1325/**
1326 * mv6_reset_hc - Perform the 6xxx global soft reset
1327 * @mmio: base address of the HBA
1328 *
1329 * This routine only applies to 6xxx parts.
1330 *
1331 * LOCKING:
1332 * Inherited from caller.
1333 */
1334static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio)
1335{
1336 void __iomem *reg = mmio + PCI_MAIN_CMD_STS_OFS;
1337 int i, rc = 0;
1338 u32 t;
1339
1340 /* Following procedure defined in PCI "main command and status
1341 * register" table.
1342 */
1343 t = readl(reg);
1344 writel(t | STOP_PCI_MASTER, reg);
1345
1346 for (i = 0; i < 1000; i++) {
1347 udelay(1);
1348 t = readl(reg);
1349 if (PCI_MASTER_EMPTY & t) {
1350 break;
1351 }
1352 }
1353 if (!(PCI_MASTER_EMPTY & t)) {
1354 printk(KERN_ERR DRV_NAME ": PCI master won't flush\n");
1355 rc = 1;
1356 goto done;
1357 }
1358
1359 /* set reset */
1360 i = 5;
1361 do {
1362 writel(t | GLOB_SFT_RST, reg);
1363 t = readl(reg);
1364 udelay(1);
1365 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
1366
1367 if (!(GLOB_SFT_RST & t)) {
1368 printk(KERN_ERR DRV_NAME ": can't set global reset\n");
1369 rc = 1;
1370 goto done;
1371 }
1372
1373 /* clear reset and *reenable the PCI master* (not mentioned in spec) */
1374 i = 5;
1375 do {
1376 writel(t & ~(GLOB_SFT_RST | STOP_PCI_MASTER), reg);
1377 t = readl(reg);
1378 udelay(1);
1379 } while ((GLOB_SFT_RST & t) && (i-- > 0));
1380
1381 if (GLOB_SFT_RST & t) {
1382 printk(KERN_ERR DRV_NAME ": can't clear global reset\n");
1383 rc = 1;
1384 }
1385done:
1386 return rc;
1387}
1388
1389static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx, 1389static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx,
1390 void __iomem *mmio) 1390 void __iomem *mmio)
1391{ 1391{