aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_sx4.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_sx4.c')
-rw-r--r--drivers/ata/sata_sx4.c173
1 files changed, 88 insertions, 85 deletions
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 16b3b8a7924b..4d857185f33b 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -212,9 +212,9 @@ struct pdc_host_priv {
212}; 212};
213 213
214 214
215static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 215static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
216static void pdc_eng_timeout(struct ata_port *ap); 216static void pdc_eng_timeout(struct ata_port *ap);
217static void pdc_20621_phy_reset (struct ata_port *ap); 217static void pdc_20621_phy_reset(struct ata_port *ap);
218static int pdc_port_start(struct ata_port *ap); 218static int pdc_port_start(struct ata_port *ap);
219static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 219static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
220static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 220static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
@@ -320,16 +320,16 @@ static int pdc_port_start(struct ata_port *ap)
320 return 0; 320 return 0;
321} 321}
322 322
323static void pdc_20621_phy_reset (struct ata_port *ap) 323static void pdc_20621_phy_reset(struct ata_port *ap)
324{ 324{
325 VPRINTK("ENTER\n"); 325 VPRINTK("ENTER\n");
326 ap->cbl = ATA_CBL_SATA; 326 ap->cbl = ATA_CBL_SATA;
327 ata_port_probe(ap); 327 ata_port_probe(ap);
328 ata_bus_reset(ap); 328 ata_bus_reset(ap);
329} 329}
330 330
331static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, 331static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf,
332 unsigned int portno, 332 unsigned int portno,
333 unsigned int total_len) 333 unsigned int total_len)
334{ 334{
335 u32 addr; 335 u32 addr;
@@ -351,7 +351,7 @@ static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf,
351} 351}
352 352
353static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, 353static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf,
354 unsigned int portno, 354 unsigned int portno,
355 unsigned int total_len) 355 unsigned int total_len)
356{ 356{
357 u32 addr; 357 u32 addr;
@@ -711,8 +711,8 @@ static unsigned int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc)
711 return ata_qc_issue_prot(qc); 711 return ata_qc_issue_prot(qc);
712} 712}
713 713
714static inline unsigned int pdc20621_host_intr( struct ata_port *ap, 714static inline unsigned int pdc20621_host_intr(struct ata_port *ap,
715 struct ata_queued_cmd *qc, 715 struct ata_queued_cmd *qc,
716 unsigned int doing_hdma, 716 unsigned int doing_hdma,
717 void __iomem *mmio) 717 void __iomem *mmio)
718{ 718{
@@ -803,7 +803,7 @@ static void pdc20621_irq_clear(struct ata_port *ap)
803 readl(mmio + PDC_20621_SEQMASK); 803 readl(mmio + PDC_20621_SEQMASK);
804} 804}
805 805
806static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) 806static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance)
807{ 807{
808 struct ata_host *host = dev_instance; 808 struct ata_host *host = dev_instance;
809 struct ata_port *ap; 809 struct ata_port *ap;
@@ -836,9 +836,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
836 return IRQ_NONE; 836 return IRQ_NONE;
837 } 837 }
838 838
839 spin_lock(&host->lock); 839 spin_lock(&host->lock);
840 840
841 for (i = 1; i < 9; i++) { 841 for (i = 1; i < 9; i++) {
842 port_no = i - 1; 842 port_no = i - 1;
843 if (port_no > 3) 843 if (port_no > 3)
844 port_no -= 4; 844 port_no -= 4;
@@ -859,7 +859,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
859 } 859 }
860 } 860 }
861 861
862 spin_unlock(&host->lock); 862 spin_unlock(&host->lock);
863 863
864 VPRINTK("mask == 0x%x\n", mask); 864 VPRINTK("mask == 0x%x\n", mask);
865 865
@@ -906,16 +906,16 @@ static void pdc_eng_timeout(struct ata_port *ap)
906 906
907static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 907static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
908{ 908{
909 WARN_ON (tf->protocol == ATA_PROT_DMA || 909 WARN_ON(tf->protocol == ATA_PROT_DMA ||
910 tf->protocol == ATA_PROT_NODATA); 910 tf->protocol == ATA_PROT_NODATA);
911 ata_tf_load(ap, tf); 911 ata_tf_load(ap, tf);
912} 912}
913 913
914 914
915static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 915static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
916{ 916{
917 WARN_ON (tf->protocol == ATA_PROT_DMA || 917 WARN_ON(tf->protocol == ATA_PROT_DMA ||
918 tf->protocol == ATA_PROT_NODATA); 918 tf->protocol == ATA_PROT_NODATA);
919 ata_exec_command(ap, tf); 919 ata_exec_command(ap, tf);
920} 920}
921 921
@@ -953,7 +953,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource,
953 mmio += PDC_CHIP0_OFS; 953 mmio += PDC_CHIP0_OFS;
954 954
955 page_mask = 0x00; 955 page_mask = 0x00;
956 window_size = 0x2000 * 4; /* 32K byte uchar size */ 956 window_size = 0x2000 * 4; /* 32K byte uchar size */
957 idx = (u16) (offset / window_size); 957 idx = (u16) (offset / window_size);
958 958
959 writel(0x01, mmio + PDC_GENERAL_CTLR); 959 writel(0x01, mmio + PDC_GENERAL_CTLR);
@@ -979,7 +979,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource,
979 window_size / 4); 979 window_size / 4);
980 psource += window_size; 980 psource += window_size;
981 size -= window_size; 981 size -= window_size;
982 idx ++; 982 idx++;
983 } 983 }
984 984
985 if (size) { 985 if (size) {
@@ -1008,7 +1008,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource,
1008 mmio += PDC_CHIP0_OFS; 1008 mmio += PDC_CHIP0_OFS;
1009 1009
1010 page_mask = 0x00; 1010 page_mask = 0x00;
1011 window_size = 0x2000 * 4; /* 32K byte uchar size */ 1011 window_size = 0x2000 * 4; /* 32K byte uchar size */
1012 idx = (u16) (offset / window_size); 1012 idx = (u16) (offset / window_size);
1013 1013
1014 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1014 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
@@ -1031,7 +1031,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource,
1031 readl(mmio + PDC_GENERAL_CTLR); 1031 readl(mmio + PDC_GENERAL_CTLR);
1032 psource += window_size; 1032 psource += window_size;
1033 size -= window_size; 1033 size -= window_size;
1034 idx ++; 1034 idx++;
1035 } 1035 }
1036 1036
1037 if (size) { 1037 if (size) {
@@ -1050,7 +1050,7 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device,
1050 void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; 1050 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
1051 u32 i2creg = 0; 1051 u32 i2creg = 0;
1052 u32 status; 1052 u32 status;
1053 u32 count =0; 1053 u32 count = 0;
1054 1054
1055 /* hard-code chip #0 */ 1055 /* hard-code chip #0 */
1056 mmio += PDC_CHIP0_OFS; 1056 mmio += PDC_CHIP0_OFS;
@@ -1082,21 +1082,21 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device,
1082 1082
1083static int pdc20621_detect_dimm(struct ata_host *host) 1083static int pdc20621_detect_dimm(struct ata_host *host)
1084{ 1084{
1085 u32 data=0 ; 1085 u32 data = 0;
1086 if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1086 if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1087 PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { 1087 PDC_DIMM_SPD_SYSTEM_FREQ, &data)) {
1088 if (data == 100) 1088 if (data == 100)
1089 return 100; 1089 return 100;
1090 } else 1090 } else
1091 return 0; 1091 return 0;
1092 1092
1093 if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { 1093 if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) {
1094 if (data <= 0x75) 1094 if (data <= 0x75)
1095 return 133; 1095 return 133;
1096 } else 1096 } else
1097 return 0; 1097 return 0;
1098 1098
1099 return 0; 1099 return 0;
1100} 1100}
1101 1101
1102 1102
@@ -1104,8 +1104,8 @@ static int pdc20621_prog_dimm0(struct ata_host *host)
1104{ 1104{
1105 u32 spd0[50]; 1105 u32 spd0[50];
1106 u32 data = 0; 1106 u32 data = 0;
1107 int size, i; 1107 int size, i;
1108 u8 bdimmsize; 1108 u8 bdimmsize;
1109 void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; 1109 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
1110 static const struct { 1110 static const struct {
1111 unsigned int reg; 1111 unsigned int reg;
@@ -1128,40 +1128,40 @@ static int pdc20621_prog_dimm0(struct ata_host *host)
1128 /* hard-code chip #0 */ 1128 /* hard-code chip #0 */
1129 mmio += PDC_CHIP0_OFS; 1129 mmio += PDC_CHIP0_OFS;
1130 1130
1131 for(i=0; i<ARRAY_SIZE(pdc_i2c_read_data); i++) 1131 for (i = 0; i < ARRAY_SIZE(pdc_i2c_read_data); i++)
1132 pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1132 pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1133 pdc_i2c_read_data[i].reg, 1133 pdc_i2c_read_data[i].reg,
1134 &spd0[pdc_i2c_read_data[i].ofs]); 1134 &spd0[pdc_i2c_read_data[i].ofs]);
1135 1135
1136 data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4); 1136 data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4);
1137 data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) | 1137 data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) |
1138 ((((spd0[27] + 9) / 10) - 1) << 8) ; 1138 ((((spd0[27] + 9) / 10) - 1) << 8) ;
1139 data |= (((((spd0[29] > spd0[28]) 1139 data |= (((((spd0[29] > spd0[28])
1140 ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; 1140 ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10;
1141 data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; 1141 data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12;
1142 1142
1143 if (spd0[18] & 0x08) 1143 if (spd0[18] & 0x08)
1144 data |= ((0x03) << 14); 1144 data |= ((0x03) << 14);
1145 else if (spd0[18] & 0x04) 1145 else if (spd0[18] & 0x04)
1146 data |= ((0x02) << 14); 1146 data |= ((0x02) << 14);
1147 else if (spd0[18] & 0x01) 1147 else if (spd0[18] & 0x01)
1148 data |= ((0x01) << 14); 1148 data |= ((0x01) << 14);
1149 else 1149 else
1150 data |= (0 << 14); 1150 data |= (0 << 14);
1151 1151
1152 /* 1152 /*
1153 Calculate the size of bDIMMSize (power of 2) and 1153 Calculate the size of bDIMMSize (power of 2) and
1154 merge the DIMM size by program start/end address. 1154 merge the DIMM size by program start/end address.
1155 */ 1155 */
1156 1156
1157 bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; 1157 bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3;
1158 size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ 1158 size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */
1159 data |= (((size / 16) - 1) << 16); 1159 data |= (((size / 16) - 1) << 16);
1160 data |= (0 << 23); 1160 data |= (0 << 23);
1161 data |= 8; 1161 data |= 8;
1162 writel(data, mmio + PDC_DIMM0_CONTROL); 1162 writel(data, mmio + PDC_DIMM0_CONTROL);
1163 readl(mmio + PDC_DIMM0_CONTROL); 1163 readl(mmio + PDC_DIMM0_CONTROL);
1164 return size; 1164 return size;
1165} 1165}
1166 1166
1167 1167
@@ -1172,9 +1172,9 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
1172 void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; 1172 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
1173 1173
1174 /* hard-code chip #0 */ 1174 /* hard-code chip #0 */
1175 mmio += PDC_CHIP0_OFS; 1175 mmio += PDC_CHIP0_OFS;
1176 1176
1177 /* 1177 /*
1178 Set To Default : DIMM Module Global Control Register (0x022259F1) 1178 Set To Default : DIMM Module Global Control Register (0x022259F1)
1179 DIMM Arbitration Disable (bit 20) 1179 DIMM Arbitration Disable (bit 20)
1180 DIMM Data/Control Output Driving Selection (bit12 - bit15) 1180 DIMM Data/Control Output Driving Selection (bit12 - bit15)
@@ -1193,40 +1193,40 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
1193 writel(data, mmio + PDC_SDRAM_CONTROL); 1193 writel(data, mmio + PDC_SDRAM_CONTROL);
1194 readl(mmio + PDC_SDRAM_CONTROL); 1194 readl(mmio + PDC_SDRAM_CONTROL);
1195 printk(KERN_ERR "Local DIMM ECC Enabled\n"); 1195 printk(KERN_ERR "Local DIMM ECC Enabled\n");
1196 } 1196 }
1197 1197
1198 /* DIMM Initialization Select/Enable (bit 18/19) */ 1198 /* DIMM Initialization Select/Enable (bit 18/19) */
1199 data &= (~(1<<18)); 1199 data &= (~(1<<18));
1200 data |= (1<<19); 1200 data |= (1<<19);
1201 writel(data, mmio + PDC_SDRAM_CONTROL); 1201 writel(data, mmio + PDC_SDRAM_CONTROL);
1202 1202
1203 error = 1; 1203 error = 1;
1204 for (i = 1; i <= 10; i++) { /* polling ~5 secs */ 1204 for (i = 1; i <= 10; i++) { /* polling ~5 secs */
1205 data = readl(mmio + PDC_SDRAM_CONTROL); 1205 data = readl(mmio + PDC_SDRAM_CONTROL);
1206 if (!(data & (1<<19))) { 1206 if (!(data & (1<<19))) {
1207 error = 0; 1207 error = 0;
1208 break; 1208 break;
1209 } 1209 }
1210 msleep(i*100); 1210 msleep(i*100);
1211 } 1211 }
1212 return error; 1212 return error;
1213} 1213}
1214 1214
1215 1215
1216static unsigned int pdc20621_dimm_init(struct ata_host *host) 1216static unsigned int pdc20621_dimm_init(struct ata_host *host)
1217{ 1217{
1218 int speed, size, length; 1218 int speed, size, length;
1219 u32 addr,spd0,pci_status; 1219 u32 addr, spd0, pci_status;
1220 u32 tmp=0; 1220 u32 tmp = 0;
1221 u32 time_period=0; 1221 u32 time_period = 0;
1222 u32 tcount=0; 1222 u32 tcount = 0;
1223 u32 ticks=0; 1223 u32 ticks = 0;
1224 u32 clock=0; 1224 u32 clock = 0;
1225 u32 fparam=0; 1225 u32 fparam = 0;
1226 void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; 1226 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
1227 1227
1228 /* hard-code chip #0 */ 1228 /* hard-code chip #0 */
1229 mmio += PDC_CHIP0_OFS; 1229 mmio += PDC_CHIP0_OFS;
1230 1230
1231 /* Initialize PLL based upon PCI Bus Frequency */ 1231 /* Initialize PLL based upon PCI Bus Frequency */
1232 1232
@@ -1285,41 +1285,43 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
1285 if (!(speed = pdc20621_detect_dimm(host))) { 1285 if (!(speed = pdc20621_detect_dimm(host))) {
1286 printk(KERN_ERR "Detect Local DIMM Fail\n"); 1286 printk(KERN_ERR "Detect Local DIMM Fail\n");
1287 return 1; /* DIMM error */ 1287 return 1; /* DIMM error */
1288 } 1288 }
1289 VPRINTK("Local DIMM Speed = %d\n", speed); 1289 VPRINTK("Local DIMM Speed = %d\n", speed);
1290 1290
1291 /* Programming DIMM0 Module Control Register (index_CID0:80h) */ 1291 /* Programming DIMM0 Module Control Register (index_CID0:80h) */
1292 size = pdc20621_prog_dimm0(host); 1292 size = pdc20621_prog_dimm0(host);
1293 VPRINTK("Local DIMM Size = %dMB\n",size); 1293 VPRINTK("Local DIMM Size = %dMB\n", size);
1294 1294
1295 /* Programming DIMM Module Global Control Register (index_CID0:88h) */ 1295 /* Programming DIMM Module Global Control Register (index_CID0:88h) */
1296 if (pdc20621_prog_dimm_global(host)) { 1296 if (pdc20621_prog_dimm_global(host)) {
1297 printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); 1297 printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n");
1298 return 1; 1298 return 1;
1299 } 1299 }
1300 1300
1301#ifdef ATA_VERBOSE_DEBUG 1301#ifdef ATA_VERBOSE_DEBUG
1302 { 1302 {
1303 u8 test_parttern1[40] = {0x55,0xAA,'P','r','o','m','i','s','e',' ', 1303 u8 test_parttern1[40] =
1304 'N','o','t',' ','Y','e','t',' ','D','e','f','i','n','e','d',' ', 1304 {0x55,0xAA,'P','r','o','m','i','s','e',' ',
1305 '1','.','1','0', 1305 'N','o','t',' ','Y','e','t',' ',
1306 '9','8','0','3','1','6','1','2',0,0}; 1306 'D','e','f','i','n','e','d',' ',
1307 '1','.','1','0',
1308 '9','8','0','3','1','6','1','2',0,0};
1307 u8 test_parttern2[40] = {0}; 1309 u8 test_parttern2[40] = {0};
1308 1310
1309 pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x10040, 40); 1311 pdc20621_put_to_dimm(host, test_parttern2, 0x10040, 40);
1310 pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x40, 40); 1312 pdc20621_put_to_dimm(host, test_parttern2, 0x40, 40);
1311 1313
1312 pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x10040, 40); 1314 pdc20621_put_to_dimm(host, test_parttern1, 0x10040, 40);
1313 pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); 1315 pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40);
1314 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1316 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1315 test_parttern2[1], &(test_parttern2[2])); 1317 test_parttern2[1], &(test_parttern2[2]));
1316 pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x10040, 1318 pdc20621_get_from_dimm(host, test_parttern2, 0x10040,
1317 40); 1319 40);
1318 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1320 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1319 test_parttern2[1], &(test_parttern2[2])); 1321 test_parttern2[1], &(test_parttern2[2]));
1320 1322
1321 pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x40, 40); 1323 pdc20621_put_to_dimm(host, test_parttern1, 0x40, 40);
1322 pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); 1324 pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40);
1323 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1325 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1324 test_parttern2[1], &(test_parttern2[2])); 1326 test_parttern2[1], &(test_parttern2[2]));
1325 } 1327 }
@@ -1375,7 +1377,8 @@ static void pdc_20621_init(struct ata_host *host)
1375 readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ 1377 readl(mmio + PDC_HDMA_CTLSTAT); /* flush */
1376} 1378}
1377 1379
1378static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1380static int pdc_sata_init_one(struct pci_dev *pdev,
1381 const struct pci_device_id *ent)
1379{ 1382{
1380 static int printed_version; 1383 static int printed_version;
1381 const struct ata_port_info *ppi[] = 1384 const struct ata_port_info *ppi[] =