diff options
Diffstat (limited to 'drivers/ata/sata_nv.c')
-rw-r--r-- | drivers/ata/sata_nv.c | 120 |
1 files changed, 65 insertions, 55 deletions
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index f1b422f7c749..35b2df297527 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -291,7 +291,7 @@ struct nv_swncq_port_priv { | |||
291 | }; | 291 | }; |
292 | 292 | ||
293 | 293 | ||
294 | #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT))))) | 294 | #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & (1 << (19 + (12 * (PORT))))) |
295 | 295 | ||
296 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 296 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
297 | #ifdef CONFIG_PM | 297 | #ifdef CONFIG_PM |
@@ -884,8 +884,9 @@ static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) | |||
884 | /* Notifier bits set without a command may indicate the drive | 884 | /* Notifier bits set without a command may indicate the drive |
885 | is misbehaving. Raise host state machine violation on this | 885 | is misbehaving. Raise host state machine violation on this |
886 | condition. */ | 886 | condition. */ |
887 | ata_port_printk(ap, KERN_ERR, "notifier for tag %d with no command?\n", | 887 | ata_port_printk(ap, KERN_ERR, |
888 | cpb_num); | 888 | "notifier for tag %d with no cmd?\n", |
889 | cpb_num); | ||
889 | ehi->err_mask |= AC_ERR_HSM; | 890 | ehi->err_mask |= AC_ERR_HSM; |
890 | ehi->action |= ATA_EH_SOFTRESET; | 891 | ehi->action |= ATA_EH_SOFTRESET; |
891 | ata_port_freeze(ap); | 892 | ata_port_freeze(ap); |
@@ -1012,7 +1013,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
1012 | u32 check_commands; | 1013 | u32 check_commands; |
1013 | int pos, error = 0; | 1014 | int pos, error = 0; |
1014 | 1015 | ||
1015 | if(ata_tag_valid(ap->link.active_tag)) | 1016 | if (ata_tag_valid(ap->link.active_tag)) |
1016 | check_commands = 1 << ap->link.active_tag; | 1017 | check_commands = 1 << ap->link.active_tag; |
1017 | else | 1018 | else |
1018 | check_commands = ap->link.sactive; | 1019 | check_commands = ap->link.sactive; |
@@ -1021,14 +1022,14 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
1021 | while ((pos = ffs(check_commands)) && !error) { | 1022 | while ((pos = ffs(check_commands)) && !error) { |
1022 | pos--; | 1023 | pos--; |
1023 | error = nv_adma_check_cpb(ap, pos, | 1024 | error = nv_adma_check_cpb(ap, pos, |
1024 | notifier_error & (1 << pos) ); | 1025 | notifier_error & (1 << pos)); |
1025 | check_commands &= ~(1 << pos ); | 1026 | check_commands &= ~(1 << pos); |
1026 | } | 1027 | } |
1027 | } | 1028 | } |
1028 | } | 1029 | } |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | if(notifier_clears[0] || notifier_clears[1]) { | 1032 | if (notifier_clears[0] || notifier_clears[1]) { |
1032 | /* Note: Both notifier clear registers must be written | 1033 | /* Note: Both notifier clear registers must be written |
1033 | if either is set, even if one is zero, according to NVIDIA. */ | 1034 | if either is set, even if one is zero, according to NVIDIA. */ |
1034 | struct nv_adma_port_priv *pp = host->ports[0]->private_data; | 1035 | struct nv_adma_port_priv *pp = host->ports[0]->private_data; |
@@ -1061,7 +1062,7 @@ static void nv_adma_freeze(struct ata_port *ap) | |||
1061 | tmp = readw(mmio + NV_ADMA_CTL); | 1062 | tmp = readw(mmio + NV_ADMA_CTL); |
1062 | writew(tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), | 1063 | writew(tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), |
1063 | mmio + NV_ADMA_CTL); | 1064 | mmio + NV_ADMA_CTL); |
1064 | readw(mmio + NV_ADMA_CTL ); /* flush posted write */ | 1065 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1065 | } | 1066 | } |
1066 | 1067 | ||
1067 | static void nv_adma_thaw(struct ata_port *ap) | 1068 | static void nv_adma_thaw(struct ata_port *ap) |
@@ -1079,7 +1080,7 @@ static void nv_adma_thaw(struct ata_port *ap) | |||
1079 | tmp = readw(mmio + NV_ADMA_CTL); | 1080 | tmp = readw(mmio + NV_ADMA_CTL); |
1080 | writew(tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), | 1081 | writew(tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), |
1081 | mmio + NV_ADMA_CTL); | 1082 | mmio + NV_ADMA_CTL); |
1082 | readw(mmio + NV_ADMA_CTL ); /* flush posted write */ | 1083 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | static void nv_adma_irq_clear(struct ata_port *ap) | 1086 | static void nv_adma_irq_clear(struct ata_port *ap) |
@@ -1119,7 +1120,7 @@ static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc) | |||
1119 | { | 1120 | { |
1120 | struct nv_adma_port_priv *pp = qc->ap->private_data; | 1121 | struct nv_adma_port_priv *pp = qc->ap->private_data; |
1121 | 1122 | ||
1122 | if(pp->flags & NV_ADMA_PORT_REGISTER_MODE) | 1123 | if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) |
1123 | ata_bmdma_post_internal_cmd(qc); | 1124 | ata_bmdma_post_internal_cmd(qc); |
1124 | } | 1125 | } |
1125 | 1126 | ||
@@ -1165,7 +1166,7 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
1165 | pp->cpb_dma = mem_dma; | 1166 | pp->cpb_dma = mem_dma; |
1166 | 1167 | ||
1167 | writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); | 1168 | writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); |
1168 | writel((mem_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); | 1169 | writel((mem_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); |
1169 | 1170 | ||
1170 | mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; | 1171 | mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; |
1171 | mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; | 1172 | mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; |
@@ -1189,15 +1190,15 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
1189 | 1190 | ||
1190 | /* clear GO for register mode, enable interrupt */ | 1191 | /* clear GO for register mode, enable interrupt */ |
1191 | tmp = readw(mmio + NV_ADMA_CTL); | 1192 | tmp = readw(mmio + NV_ADMA_CTL); |
1192 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | | 1193 | writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
1193 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | 1194 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); |
1194 | 1195 | ||
1195 | tmp = readw(mmio + NV_ADMA_CTL); | 1196 | tmp = readw(mmio + NV_ADMA_CTL); |
1196 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1197 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1197 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1198 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1198 | udelay(1); | 1199 | udelay(1); |
1199 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1200 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1200 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1201 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1201 | 1202 | ||
1202 | return 0; | 1203 | return 0; |
1203 | } | 1204 | } |
@@ -1237,7 +1238,7 @@ static int nv_adma_port_resume(struct ata_port *ap) | |||
1237 | 1238 | ||
1238 | /* set CPB block location */ | 1239 | /* set CPB block location */ |
1239 | writel(pp->cpb_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); | 1240 | writel(pp->cpb_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); |
1240 | writel((pp->cpb_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); | 1241 | writel((pp->cpb_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); |
1241 | 1242 | ||
1242 | /* clear any outstanding interrupt conditions */ | 1243 | /* clear any outstanding interrupt conditions */ |
1243 | writew(0xffff, mmio + NV_ADMA_STAT); | 1244 | writew(0xffff, mmio + NV_ADMA_STAT); |
@@ -1250,15 +1251,15 @@ static int nv_adma_port_resume(struct ata_port *ap) | |||
1250 | 1251 | ||
1251 | /* clear GO for register mode, enable interrupt */ | 1252 | /* clear GO for register mode, enable interrupt */ |
1252 | tmp = readw(mmio + NV_ADMA_CTL); | 1253 | tmp = readw(mmio + NV_ADMA_CTL); |
1253 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | | 1254 | writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
1254 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | 1255 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); |
1255 | 1256 | ||
1256 | tmp = readw(mmio + NV_ADMA_CTL); | 1257 | tmp = readw(mmio + NV_ADMA_CTL); |
1257 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1258 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1258 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1259 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1259 | udelay(1); | 1260 | udelay(1); |
1260 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1261 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1261 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1262 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1262 | 1263 | ||
1263 | return 0; | 1264 | return 0; |
1264 | } | 1265 | } |
@@ -1342,7 +1343,8 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) | |||
1342 | idx = 0; | 1343 | idx = 0; |
1343 | 1344 | ||
1344 | ata_for_each_sg(sg, qc) { | 1345 | ata_for_each_sg(sg, qc) { |
1345 | aprd = (idx < 5) ? &cpb->aprd[idx] : &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; | 1346 | aprd = (idx < 5) ? &cpb->aprd[idx] : |
1347 | &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; | ||
1346 | nv_adma_fill_aprd(qc, sg, idx, aprd); | 1348 | nv_adma_fill_aprd(qc, sg, idx, aprd); |
1347 | idx++; | 1349 | idx++; |
1348 | } | 1350 | } |
@@ -1359,12 +1361,12 @@ static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) | |||
1359 | /* ADMA engine can only be used for non-ATAPI DMA commands, | 1361 | /* ADMA engine can only be used for non-ATAPI DMA commands, |
1360 | or interrupt-driven no-data commands, where a result taskfile | 1362 | or interrupt-driven no-data commands, where a result taskfile |
1361 | is not required. */ | 1363 | is not required. */ |
1362 | if((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || | 1364 | if ((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || |
1363 | (qc->tf.flags & ATA_TFLAG_POLLING) || | 1365 | (qc->tf.flags & ATA_TFLAG_POLLING) || |
1364 | (qc->flags & ATA_QCFLAG_RESULT_TF)) | 1366 | (qc->flags & ATA_QCFLAG_RESULT_TF)) |
1365 | return 1; | 1367 | return 1; |
1366 | 1368 | ||
1367 | if((qc->flags & ATA_QCFLAG_DMAMAP) || | 1369 | if ((qc->flags & ATA_QCFLAG_DMAMAP) || |
1368 | (qc->tf.protocol == ATA_PROT_NODATA)) | 1370 | (qc->tf.protocol == ATA_PROT_NODATA)) |
1369 | return 0; | 1371 | return 0; |
1370 | 1372 | ||
@@ -1401,14 +1403,14 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) | |||
1401 | 1403 | ||
1402 | nv_adma_tf_to_cpb(&qc->tf, cpb->tf); | 1404 | nv_adma_tf_to_cpb(&qc->tf, cpb->tf); |
1403 | 1405 | ||
1404 | if(qc->flags & ATA_QCFLAG_DMAMAP) { | 1406 | if (qc->flags & ATA_QCFLAG_DMAMAP) { |
1405 | nv_adma_fill_sg(qc, cpb); | 1407 | nv_adma_fill_sg(qc, cpb); |
1406 | ctl_flags |= NV_CPB_CTL_APRD_VALID; | 1408 | ctl_flags |= NV_CPB_CTL_APRD_VALID; |
1407 | } else | 1409 | } else |
1408 | memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5); | 1410 | memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5); |
1409 | 1411 | ||
1410 | /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID until we are | 1412 | /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID |
1411 | finished filling in all of the contents */ | 1413 | until we are finished filling in all of the contents */ |
1412 | wmb(); | 1414 | wmb(); |
1413 | cpb->ctl_flags = ctl_flags; | 1415 | cpb->ctl_flags = ctl_flags; |
1414 | wmb(); | 1416 | wmb(); |
@@ -1435,16 +1437,16 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) | |||
1435 | and (number of cpbs to append -1) in top 8 bits */ | 1437 | and (number of cpbs to append -1) in top 8 bits */ |
1436 | wmb(); | 1438 | wmb(); |
1437 | 1439 | ||
1438 | if(curr_ncq != pp->last_issue_ncq) { | 1440 | if (curr_ncq != pp->last_issue_ncq) { |
1439 | /* Seems to need some delay before switching between NCQ and non-NCQ | 1441 | /* Seems to need some delay before switching between NCQ and |
1440 | commands, else we get command timeouts and such. */ | 1442 | non-NCQ commands, else we get command timeouts and such. */ |
1441 | udelay(20); | 1443 | udelay(20); |
1442 | pp->last_issue_ncq = curr_ncq; | 1444 | pp->last_issue_ncq = curr_ncq; |
1443 | } | 1445 | } |
1444 | 1446 | ||
1445 | writew(qc->tag, mmio + NV_ADMA_APPEND); | 1447 | writew(qc->tag, mmio + NV_ADMA_APPEND); |
1446 | 1448 | ||
1447 | DPRINTK("Issued tag %u\n",qc->tag); | 1449 | DPRINTK("Issued tag %u\n", qc->tag); |
1448 | 1450 | ||
1449 | return 0; | 1451 | return 0; |
1450 | } | 1452 | } |
@@ -1641,12 +1643,12 @@ static void nv_error_handler(struct ata_port *ap) | |||
1641 | static void nv_adma_error_handler(struct ata_port *ap) | 1643 | static void nv_adma_error_handler(struct ata_port *ap) |
1642 | { | 1644 | { |
1643 | struct nv_adma_port_priv *pp = ap->private_data; | 1645 | struct nv_adma_port_priv *pp = ap->private_data; |
1644 | if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { | 1646 | if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { |
1645 | void __iomem *mmio = pp->ctl_block; | 1647 | void __iomem *mmio = pp->ctl_block; |
1646 | int i; | 1648 | int i; |
1647 | u16 tmp; | 1649 | u16 tmp; |
1648 | 1650 | ||
1649 | if(ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { | 1651 | if (ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { |
1650 | u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); | 1652 | u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); |
1651 | u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); | 1653 | u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); |
1652 | u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); | 1654 | u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); |
@@ -1654,16 +1656,17 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1654 | u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); | 1656 | u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); |
1655 | u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); | 1657 | u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); |
1656 | 1658 | ||
1657 | ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X " | 1659 | ata_port_printk(ap, KERN_ERR, |
1660 | "EH in ADMA mode, notifier 0x%X " | ||
1658 | "notifier_error 0x%X gen_ctl 0x%X status 0x%X " | 1661 | "notifier_error 0x%X gen_ctl 0x%X status 0x%X " |
1659 | "next cpb count 0x%X next cpb idx 0x%x\n", | 1662 | "next cpb count 0x%X next cpb idx 0x%x\n", |
1660 | notifier, notifier_error, gen_ctl, status, | 1663 | notifier, notifier_error, gen_ctl, status, |
1661 | cpb_count, next_cpb_idx); | 1664 | cpb_count, next_cpb_idx); |
1662 | 1665 | ||
1663 | for( i=0;i<NV_ADMA_MAX_CPBS;i++) { | 1666 | for (i = 0; i < NV_ADMA_MAX_CPBS; i++) { |
1664 | struct nv_adma_cpb *cpb = &pp->cpb[i]; | 1667 | struct nv_adma_cpb *cpb = &pp->cpb[i]; |
1665 | if( (ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || | 1668 | if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || |
1666 | ap->link.sactive & (1 << i) ) | 1669 | ap->link.sactive & (1 << i)) |
1667 | ata_port_printk(ap, KERN_ERR, | 1670 | ata_port_printk(ap, KERN_ERR, |
1668 | "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", | 1671 | "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", |
1669 | i, cpb->ctl_flags, cpb->resp_flags); | 1672 | i, cpb->ctl_flags, cpb->resp_flags); |
@@ -1673,8 +1676,9 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1673 | /* Push us back into port register mode for error handling. */ | 1676 | /* Push us back into port register mode for error handling. */ |
1674 | nv_adma_register_mode(ap); | 1677 | nv_adma_register_mode(ap); |
1675 | 1678 | ||
1676 | /* Mark all of the CPBs as invalid to prevent them from being executed */ | 1679 | /* Mark all of the CPBs as invalid to prevent them from |
1677 | for( i=0;i<NV_ADMA_MAX_CPBS;i++) | 1680 | being executed */ |
1681 | for (i = 0; i < NV_ADMA_MAX_CPBS; i++) | ||
1678 | pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID; | 1682 | pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID; |
1679 | 1683 | ||
1680 | /* clear CPB fetch count */ | 1684 | /* clear CPB fetch count */ |
@@ -1683,10 +1687,10 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1683 | /* Reset channel */ | 1687 | /* Reset channel */ |
1684 | tmp = readw(mmio + NV_ADMA_CTL); | 1688 | tmp = readw(mmio + NV_ADMA_CTL); |
1685 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1689 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1686 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1690 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1687 | udelay(1); | 1691 | udelay(1); |
1688 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1692 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1689 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1693 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1690 | } | 1694 | } |
1691 | 1695 | ||
1692 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, | 1696 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, |
@@ -2350,9 +2354,9 @@ static irqreturn_t nv_swncq_interrupt(int irq, void *dev_instance) | |||
2350 | return IRQ_RETVAL(handled); | 2354 | return IRQ_RETVAL(handled); |
2351 | } | 2355 | } |
2352 | 2356 | ||
2353 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 2357 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
2354 | { | 2358 | { |
2355 | static int printed_version = 0; | 2359 | static int printed_version; |
2356 | const struct ata_port_info *ppi[] = { NULL, NULL }; | 2360 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
2357 | struct ata_host *host; | 2361 | struct ata_host *host; |
2358 | struct nv_host_priv *hpriv; | 2362 | struct nv_host_priv *hpriv; |
@@ -2364,7 +2368,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2364 | // Make sure this is a SATA controller by counting the number of bars | 2368 | // Make sure this is a SATA controller by counting the number of bars |
2365 | // (NVIDIA SATA controllers will always have six bars). Otherwise, | 2369 | // (NVIDIA SATA controllers will always have six bars). Otherwise, |
2366 | // it's an IDE controller and we ignore it. | 2370 | // it's an IDE controller and we ignore it. |
2367 | for (bar=0; bar<6; bar++) | 2371 | for (bar = 0; bar < 6; bar++) |
2368 | if (pci_resource_start(pdev, bar) == 0) | 2372 | if (pci_resource_start(pdev, bar) == 0) |
2369 | return -ENODEV; | 2373 | return -ENODEV; |
2370 | 2374 | ||
@@ -2381,6 +2385,14 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2381 | type = ADMA; | 2385 | type = ADMA; |
2382 | } | 2386 | } |
2383 | 2387 | ||
2388 | if (type == SWNCQ) { | ||
2389 | if (swncq_enabled) | ||
2390 | dev_printk(KERN_NOTICE, &pdev->dev, | ||
2391 | "Using SWNCQ mode\n"); | ||
2392 | else | ||
2393 | type = GENERIC; | ||
2394 | } | ||
2395 | |||
2384 | ppi[0] = &nv_port_info[type]; | 2396 | ppi[0] = &nv_port_info[type]; |
2385 | rc = ata_pci_prepare_sff_host(pdev, ppi, &host); | 2397 | rc = ata_pci_prepare_sff_host(pdev, ppi, &host); |
2386 | if (rc) | 2398 | if (rc) |
@@ -2422,10 +2434,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2422 | rc = nv_adma_host_init(host); | 2434 | rc = nv_adma_host_init(host); |
2423 | if (rc) | 2435 | if (rc) |
2424 | return rc; | 2436 | return rc; |
2425 | } else if (type == SWNCQ && swncq_enabled) { | 2437 | } else if (type == SWNCQ) |
2426 | dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ mode\n"); | ||
2427 | nv_swncq_host_init(host); | 2438 | nv_swncq_host_init(host); |
2428 | } | ||
2429 | 2439 | ||
2430 | pci_set_master(pdev); | 2440 | pci_set_master(pdev); |
2431 | return ata_host_activate(host, pdev->irq, ppi[0]->irq_handler, | 2441 | return ata_host_activate(host, pdev->irq, ppi[0]->irq_handler, |
@@ -2440,37 +2450,37 @@ static int nv_pci_device_resume(struct pci_dev *pdev) | |||
2440 | int rc; | 2450 | int rc; |
2441 | 2451 | ||
2442 | rc = ata_pci_device_do_resume(pdev); | 2452 | rc = ata_pci_device_do_resume(pdev); |
2443 | if(rc) | 2453 | if (rc) |
2444 | return rc; | 2454 | return rc; |
2445 | 2455 | ||
2446 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | 2456 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { |
2447 | if(hpriv->type >= CK804) { | 2457 | if (hpriv->type >= CK804) { |
2448 | u8 regval; | 2458 | u8 regval; |
2449 | 2459 | ||
2450 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); | 2460 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); |
2451 | regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN; | 2461 | regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN; |
2452 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); | 2462 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); |
2453 | } | 2463 | } |
2454 | if(hpriv->type == ADMA) { | 2464 | if (hpriv->type == ADMA) { |
2455 | u32 tmp32; | 2465 | u32 tmp32; |
2456 | struct nv_adma_port_priv *pp; | 2466 | struct nv_adma_port_priv *pp; |
2457 | /* enable/disable ADMA on the ports appropriately */ | 2467 | /* enable/disable ADMA on the ports appropriately */ |
2458 | pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32); | 2468 | pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32); |
2459 | 2469 | ||
2460 | pp = host->ports[0]->private_data; | 2470 | pp = host->ports[0]->private_data; |
2461 | if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) | 2471 | if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) |
2462 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN | | 2472 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN | |
2463 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); | 2473 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); |
2464 | else | 2474 | else |
2465 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT0_EN | | 2475 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT0_EN | |
2466 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); | 2476 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); |
2467 | pp = host->ports[1]->private_data; | 2477 | pp = host->ports[1]->private_data; |
2468 | if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) | 2478 | if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) |
2469 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN | | 2479 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN | |
2470 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); | 2480 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); |
2471 | else | 2481 | else |
2472 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT1_EN | | 2482 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT1_EN | |
2473 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); | 2483 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); |
2474 | 2484 | ||
2475 | pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32); | 2485 | pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32); |
2476 | } | 2486 | } |