aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_bf54x.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-04-22 07:34:25 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2008-04-22 07:34:25 -0400
commitf838bad1b3be8ca0c785ee0e0c570dfda74cf377 (patch)
tree5a842a8056a708cfad55a20fa8ab733dd94b0903 /drivers/ata/pata_bf54x.c
parentdd919660aacdf4adfcd279556aa03e595f7f0fc2 (diff)
parent807501475fce0ebe68baedf87f202c3e4ee0d12c (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/ata/pata_bf54x.c')
-rw-r--r--drivers/ata/pata_bf54x.c137
1 files changed, 54 insertions, 83 deletions
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 7f87f105c2f6..0a5ad98635b1 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -674,7 +674,7 @@ static void read_atapi_data(void __iomem *base,
674 * @ap: Port to which output is sent 674 * @ap: Port to which output is sent
675 * @tf: ATA taskfile register set 675 * @tf: ATA taskfile register set
676 * 676 *
677 * Note: Original code is ata_tf_load(). 677 * Note: Original code is ata_sff_tf_load().
678 */ 678 */
679 679
680static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 680static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
@@ -745,7 +745,7 @@ static u8 bfin_check_status(struct ata_port *ap)
745 * @ap: Port from which input is read 745 * @ap: Port from which input is read
746 * @tf: ATA taskfile register set for storing input 746 * @tf: ATA taskfile register set for storing input
747 * 747 *
748 * Note: Original code is ata_tf_read(). 748 * Note: Original code is ata_sff_tf_read().
749 */ 749 */
750 750
751static void bfin_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 751static void bfin_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
@@ -775,7 +775,7 @@ static void bfin_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
775 * @ap: port to which command is being issued 775 * @ap: port to which command is being issued
776 * @tf: ATA taskfile register set 776 * @tf: ATA taskfile register set
777 * 777 *
778 * Note: Original code is ata_exec_command(). 778 * Note: Original code is ata_sff_exec_command().
779 */ 779 */
780 780
781static void bfin_exec_command(struct ata_port *ap, 781static void bfin_exec_command(struct ata_port *ap,
@@ -785,7 +785,7 @@ static void bfin_exec_command(struct ata_port *ap,
785 dev_dbg(ap->dev, "ata%u: cmd 0x%X\n", ap->print_id, tf->command); 785 dev_dbg(ap->dev, "ata%u: cmd 0x%X\n", ap->print_id, tf->command);
786 786
787 write_atapi_register(base, ATA_REG_CMD, tf->command); 787 write_atapi_register(base, ATA_REG_CMD, tf->command);
788 ata_pause(ap); 788 ata_sff_pause(ap);
789} 789}
790 790
791/** 791/**
@@ -800,14 +800,14 @@ static u8 bfin_check_altstatus(struct ata_port *ap)
800} 800}
801 801
802/** 802/**
803 * bfin_std_dev_select - Select device 0/1 on ATA bus 803 * bfin_dev_select - Select device 0/1 on ATA bus
804 * @ap: ATA channel to manipulate 804 * @ap: ATA channel to manipulate
805 * @device: ATA device (numbered from zero) to select 805 * @device: ATA device (numbered from zero) to select
806 * 806 *
807 * Note: Original code is ata_std_dev_select(). 807 * Note: Original code is ata_sff_dev_select().
808 */ 808 */
809 809
810static void bfin_std_dev_select(struct ata_port *ap, unsigned int device) 810static void bfin_dev_select(struct ata_port *ap, unsigned int device)
811{ 811{
812 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 812 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
813 u8 tmp; 813 u8 tmp;
@@ -818,7 +818,7 @@ static void bfin_std_dev_select(struct ata_port *ap, unsigned int device)
818 tmp = ATA_DEVICE_OBS | ATA_DEV1; 818 tmp = ATA_DEVICE_OBS | ATA_DEV1;
819 819
820 write_atapi_register(base, ATA_REG_DEVICE, tmp); 820 write_atapi_register(base, ATA_REG_DEVICE, tmp);
821 ata_pause(ap); 821 ata_sff_pause(ap);
822} 822}
823 823
824/** 824/**
@@ -977,7 +977,7 @@ static unsigned int bfin_devchk(struct ata_port *ap,
977 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 977 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
978 u8 nsect, lbal; 978 u8 nsect, lbal;
979 979
980 bfin_std_dev_select(ap, device); 980 bfin_dev_select(ap, device);
981 981
982 write_atapi_register(base, ATA_REG_NSECT, 0x55); 982 write_atapi_register(base, ATA_REG_NSECT, 0x55);
983 write_atapi_register(base, ATA_REG_LBAL, 0xaa); 983 write_atapi_register(base, ATA_REG_LBAL, 0xaa);
@@ -1014,7 +1014,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1014 * BSY bit to clear 1014 * BSY bit to clear
1015 */ 1015 */
1016 if (dev0) 1016 if (dev0)
1017 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 1017 ata_sff_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
1018 1018
1019 /* if device 1 was found in ata_devchk, wait for 1019 /* if device 1 was found in ata_devchk, wait for
1020 * register access, then wait for BSY to clear 1020 * register access, then wait for BSY to clear
@@ -1023,7 +1023,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1023 while (dev1) { 1023 while (dev1) {
1024 u8 nsect, lbal; 1024 u8 nsect, lbal;
1025 1025
1026 bfin_std_dev_select(ap, 1); 1026 bfin_dev_select(ap, 1);
1027 nsect = read_atapi_register(base, ATA_REG_NSECT); 1027 nsect = read_atapi_register(base, ATA_REG_NSECT);
1028 lbal = read_atapi_register(base, ATA_REG_LBAL); 1028 lbal = read_atapi_register(base, ATA_REG_LBAL);
1029 if ((nsect == 1) && (lbal == 1)) 1029 if ((nsect == 1) && (lbal == 1))
@@ -1035,14 +1035,14 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1035 msleep(50); /* give drive a breather */ 1035 msleep(50); /* give drive a breather */
1036 } 1036 }
1037 if (dev1) 1037 if (dev1)
1038 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 1038 ata_sff_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
1039 1039
1040 /* is all this really necessary? */ 1040 /* is all this really necessary? */
1041 bfin_std_dev_select(ap, 0); 1041 bfin_dev_select(ap, 0);
1042 if (dev1) 1042 if (dev1)
1043 bfin_std_dev_select(ap, 1); 1043 bfin_dev_select(ap, 1);
1044 if (dev0) 1044 if (dev0)
1045 bfin_std_dev_select(ap, 0); 1045 bfin_dev_select(ap, 0);
1046} 1046}
1047 1047
1048/** 1048/**
@@ -1088,26 +1088,21 @@ static unsigned int bfin_bus_softreset(struct ata_port *ap,
1088} 1088}
1089 1089
1090/** 1090/**
1091 * bfin_std_softreset - reset host port via ATA SRST 1091 * bfin_softreset - reset host port via ATA SRST
1092 * @ap: port to reset 1092 * @ap: port to reset
1093 * @classes: resulting classes of attached devices 1093 * @classes: resulting classes of attached devices
1094 * 1094 *
1095 * Note: Original code is ata_std_softreset(). 1095 * Note: Original code is ata_sff_softreset().
1096 */ 1096 */
1097 1097
1098static int bfin_std_softreset(struct ata_link *link, unsigned int *classes, 1098static int bfin_softreset(struct ata_link *link, unsigned int *classes,
1099 unsigned long deadline) 1099 unsigned long deadline)
1100{ 1100{
1101 struct ata_port *ap = link->ap; 1101 struct ata_port *ap = link->ap;
1102 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; 1102 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
1103 unsigned int devmask = 0, err_mask; 1103 unsigned int devmask = 0, err_mask;
1104 u8 err; 1104 u8 err;
1105 1105
1106 if (ata_link_offline(link)) {
1107 classes[0] = ATA_DEV_NONE;
1108 goto out;
1109 }
1110
1111 /* determine if device 0/1 are present */ 1106 /* determine if device 0/1 are present */
1112 if (bfin_devchk(ap, 0)) 1107 if (bfin_devchk(ap, 0))
1113 devmask |= (1 << 0); 1108 devmask |= (1 << 0);
@@ -1115,7 +1110,7 @@ static int bfin_std_softreset(struct ata_link *link, unsigned int *classes,
1115 devmask |= (1 << 1); 1110 devmask |= (1 << 1);
1116 1111
1117 /* select device 0 again */ 1112 /* select device 0 again */
1118 bfin_std_dev_select(ap, 0); 1113 bfin_dev_select(ap, 0);
1119 1114
1120 /* issue bus reset */ 1115 /* issue bus reset */
1121 err_mask = bfin_bus_softreset(ap, devmask); 1116 err_mask = bfin_bus_softreset(ap, devmask);
@@ -1126,13 +1121,12 @@ static int bfin_std_softreset(struct ata_link *link, unsigned int *classes,
1126 } 1121 }
1127 1122
1128 /* determine by signature whether we have ATA or ATAPI devices */ 1123 /* determine by signature whether we have ATA or ATAPI devices */
1129 classes[0] = ata_dev_try_classify(&ap->link.device[0], 1124 classes[0] = ata_sff_dev_classify(&ap->link.device[0],
1130 devmask & (1 << 0), &err); 1125 devmask & (1 << 0), &err);
1131 if (slave_possible && err != 0x81) 1126 if (slave_possible && err != 0x81)
1132 classes[1] = ata_dev_try_classify(&ap->link.device[1], 1127 classes[1] = ata_sff_dev_classify(&ap->link.device[1],
1133 devmask & (1 << 1), &err); 1128 devmask & (1 << 1), &err);
1134 1129
1135 out:
1136 return 0; 1130 return 0;
1137} 1131}
1138 1132
@@ -1167,7 +1161,7 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap)
1167 * @buflen: buffer length 1161 * @buflen: buffer length
1168 * @write_data: read/write 1162 * @write_data: read/write
1169 * 1163 *
1170 * Note: Original code is ata_data_xfer(). 1164 * Note: Original code is ata_sff_data_xfer().
1171 */ 1165 */
1172 1166
1173static unsigned int bfin_data_xfer(struct ata_device *dev, unsigned char *buf, 1167static unsigned int bfin_data_xfer(struct ata_device *dev, unsigned char *buf,
@@ -1206,7 +1200,7 @@ static unsigned int bfin_data_xfer(struct ata_device *dev, unsigned char *buf,
1206 * bfin_irq_clear - Clear ATAPI interrupt. 1200 * bfin_irq_clear - Clear ATAPI interrupt.
1207 * @ap: Port associated with this ATA transaction. 1201 * @ap: Port associated with this ATA transaction.
1208 * 1202 *
1209 * Note: Original code is ata_bmdma_irq_clear(). 1203 * Note: Original code is ata_sff_irq_clear().
1210 */ 1204 */
1211 1205
1212static void bfin_irq_clear(struct ata_port *ap) 1206static void bfin_irq_clear(struct ata_port *ap)
@@ -1223,7 +1217,7 @@ static void bfin_irq_clear(struct ata_port *ap)
1223 * bfin_irq_on - Enable interrupts on a port. 1217 * bfin_irq_on - Enable interrupts on a port.
1224 * @ap: Port on which interrupts are enabled. 1218 * @ap: Port on which interrupts are enabled.
1225 * 1219 *
1226 * Note: Original code is ata_irq_on(). 1220 * Note: Original code is ata_sff_irq_on().
1227 */ 1221 */
1228 1222
1229static unsigned char bfin_irq_on(struct ata_port *ap) 1223static unsigned char bfin_irq_on(struct ata_port *ap)
@@ -1244,13 +1238,13 @@ static unsigned char bfin_irq_on(struct ata_port *ap)
1244} 1238}
1245 1239
1246/** 1240/**
1247 * bfin_bmdma_freeze - Freeze DMA controller port 1241 * bfin_freeze - Freeze DMA controller port
1248 * @ap: port to freeze 1242 * @ap: port to freeze
1249 * 1243 *
1250 * Note: Original code is ata_bmdma_freeze(). 1244 * Note: Original code is ata_sff_freeze().
1251 */ 1245 */
1252 1246
1253static void bfin_bmdma_freeze(struct ata_port *ap) 1247static void bfin_freeze(struct ata_port *ap)
1254{ 1248{
1255 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 1249 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
1256 1250
@@ -1264,19 +1258,19 @@ static void bfin_bmdma_freeze(struct ata_port *ap)
1264 * ATA_NIEN manipulation. Also, many controllers fail to mask 1258 * ATA_NIEN manipulation. Also, many controllers fail to mask
1265 * previously pending IRQ on ATA_NIEN assertion. Clear it. 1259 * previously pending IRQ on ATA_NIEN assertion. Clear it.
1266 */ 1260 */
1267 ata_chk_status(ap); 1261 ap->ops->sff_check_status(ap);
1268 1262
1269 bfin_irq_clear(ap); 1263 bfin_irq_clear(ap);
1270} 1264}
1271 1265
1272/** 1266/**
1273 * bfin_bmdma_thaw - Thaw DMA controller port 1267 * bfin_thaw - Thaw DMA controller port
1274 * @ap: port to thaw 1268 * @ap: port to thaw
1275 * 1269 *
1276 * Note: Original code is ata_bmdma_thaw(). 1270 * Note: Original code is ata_sff_thaw().
1277 */ 1271 */
1278 1272
1279void bfin_bmdma_thaw(struct ata_port *ap) 1273void bfin_thaw(struct ata_port *ap)
1280{ 1274{
1281 bfin_check_status(ap); 1275 bfin_check_status(ap);
1282 bfin_irq_clear(ap); 1276 bfin_irq_clear(ap);
@@ -1284,14 +1278,14 @@ void bfin_bmdma_thaw(struct ata_port *ap)
1284} 1278}
1285 1279
1286/** 1280/**
1287 * bfin_std_postreset - standard postreset callback 1281 * bfin_postreset - standard postreset callback
1288 * @ap: the target ata_port 1282 * @ap: the target ata_port
1289 * @classes: classes of attached devices 1283 * @classes: classes of attached devices
1290 * 1284 *
1291 * Note: Original code is ata_std_postreset(). 1285 * Note: Original code is ata_sff_postreset().
1292 */ 1286 */
1293 1287
1294static void bfin_std_postreset(struct ata_link *link, unsigned int *classes) 1288static void bfin_postreset(struct ata_link *link, unsigned int *classes)
1295{ 1289{
1296 struct ata_port *ap = link->ap; 1290 struct ata_port *ap = link->ap;
1297 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 1291 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
@@ -1301,9 +1295,9 @@ static void bfin_std_postreset(struct ata_link *link, unsigned int *classes)
1301 1295
1302 /* is double-select really necessary? */ 1296 /* is double-select really necessary? */
1303 if (classes[0] != ATA_DEV_NONE) 1297 if (classes[0] != ATA_DEV_NONE)
1304 bfin_std_dev_select(ap, 1); 1298 bfin_dev_select(ap, 1);
1305 if (classes[1] != ATA_DEV_NONE) 1299 if (classes[1] != ATA_DEV_NONE)
1306 bfin_std_dev_select(ap, 0); 1300 bfin_dev_select(ap, 0);
1307 1301
1308 /* bail out if no device is present */ 1302 /* bail out if no device is present */
1309 if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { 1303 if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) {
@@ -1314,17 +1308,6 @@ static void bfin_std_postreset(struct ata_link *link, unsigned int *classes)
1314 write_atapi_register(base, ATA_REG_CTRL, ap->ctl); 1308 write_atapi_register(base, ATA_REG_CTRL, ap->ctl);
1315} 1309}
1316 1310
1317/**
1318 * bfin_error_handler - Stock error handler for DMA controller
1319 * @ap: port to handle error for
1320 */
1321
1322static void bfin_error_handler(struct ata_port *ap)
1323{
1324 ata_bmdma_drive_eh(ap, ata_std_prereset, bfin_std_softreset, NULL,
1325 bfin_std_postreset);
1326}
1327
1328static void bfin_port_stop(struct ata_port *ap) 1311static void bfin_port_stop(struct ata_port *ap)
1329{ 1312{
1330 dev_dbg(ap->dev, "in atapi port stop\n"); 1313 dev_dbg(ap->dev, "in atapi port stop\n");
@@ -1357,51 +1340,40 @@ static int bfin_port_start(struct ata_port *ap)
1357} 1340}
1358 1341
1359static struct scsi_host_template bfin_sht = { 1342static struct scsi_host_template bfin_sht = {
1360 .module = THIS_MODULE, 1343 ATA_BASE_SHT(DRV_NAME),
1361 .name = DRV_NAME,
1362 .ioctl = ata_scsi_ioctl,
1363 .queuecommand = ata_scsi_queuecmd,
1364 .can_queue = ATA_DEF_QUEUE,
1365 .this_id = ATA_SHT_THIS_ID,
1366 .sg_tablesize = SG_NONE, 1344 .sg_tablesize = SG_NONE,
1367 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
1368 .emulated = ATA_SHT_EMULATED,
1369 .use_clustering = ATA_SHT_USE_CLUSTERING,
1370 .proc_name = DRV_NAME,
1371 .dma_boundary = ATA_DMA_BOUNDARY, 1345 .dma_boundary = ATA_DMA_BOUNDARY,
1372 .slave_configure = ata_scsi_slave_config,
1373 .slave_destroy = ata_scsi_slave_destroy,
1374 .bios_param = ata_std_bios_param,
1375}; 1346};
1376 1347
1377static const struct ata_port_operations bfin_pata_ops = { 1348static const struct ata_port_operations bfin_pata_ops = {
1349 .inherits = &ata_sff_port_ops,
1350
1378 .set_piomode = bfin_set_piomode, 1351 .set_piomode = bfin_set_piomode,
1379 .set_dmamode = bfin_set_dmamode, 1352 .set_dmamode = bfin_set_dmamode,
1380 1353
1381 .tf_load = bfin_tf_load, 1354 .sff_tf_load = bfin_tf_load,
1382 .tf_read = bfin_tf_read, 1355 .sff_tf_read = bfin_tf_read,
1383 .exec_command = bfin_exec_command, 1356 .sff_exec_command = bfin_exec_command,
1384 .check_status = bfin_check_status, 1357 .sff_check_status = bfin_check_status,
1385 .check_altstatus = bfin_check_altstatus, 1358 .sff_check_altstatus = bfin_check_altstatus,
1386 .dev_select = bfin_std_dev_select, 1359 .sff_dev_select = bfin_dev_select,
1387 1360
1388 .bmdma_setup = bfin_bmdma_setup, 1361 .bmdma_setup = bfin_bmdma_setup,
1389 .bmdma_start = bfin_bmdma_start, 1362 .bmdma_start = bfin_bmdma_start,
1390 .bmdma_stop = bfin_bmdma_stop, 1363 .bmdma_stop = bfin_bmdma_stop,
1391 .bmdma_status = bfin_bmdma_status, 1364 .bmdma_status = bfin_bmdma_status,
1392 .data_xfer = bfin_data_xfer, 1365 .sff_data_xfer = bfin_data_xfer,
1393 1366
1394 .qc_prep = ata_noop_qc_prep, 1367 .qc_prep = ata_noop_qc_prep,
1395 .qc_issue = ata_qc_issue_prot,
1396 1368
1397 .freeze = bfin_bmdma_freeze, 1369 .freeze = bfin_freeze,
1398 .thaw = bfin_bmdma_thaw, 1370 .thaw = bfin_thaw,
1399 .error_handler = bfin_error_handler, 1371 .softreset = bfin_softreset,
1372 .postreset = bfin_postreset,
1400 .post_internal_cmd = bfin_bmdma_stop, 1373 .post_internal_cmd = bfin_bmdma_stop,
1401 1374
1402 .irq_handler = ata_interrupt, 1375 .sff_irq_clear = bfin_irq_clear,
1403 .irq_clear = bfin_irq_clear, 1376 .sff_irq_on = bfin_irq_on,
1404 .irq_on = bfin_irq_on,
1405 1377
1406 .port_start = bfin_port_start, 1378 .port_start = bfin_port_start,
1407 .port_stop = bfin_port_stop, 1379 .port_stop = bfin_port_stop,
@@ -1409,7 +1381,6 @@ static const struct ata_port_operations bfin_pata_ops = {
1409 1381
1410static struct ata_port_info bfin_port_info[] = { 1382static struct ata_port_info bfin_port_info[] = {
1411 { 1383 {
1412 .sht = &bfin_sht,
1413 .flags = ATA_FLAG_SLAVE_POSS 1384 .flags = ATA_FLAG_SLAVE_POSS
1414 | ATA_FLAG_MMIO 1385 | ATA_FLAG_MMIO
1415 | ATA_FLAG_NO_LEGACY, 1386 | ATA_FLAG_NO_LEGACY,
@@ -1536,7 +1507,7 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
1536 } 1507 }
1537 1508
1538 if (ata_host_activate(host, platform_get_irq(pdev, 0), 1509 if (ata_host_activate(host, platform_get_irq(pdev, 0),
1539 ata_interrupt, IRQF_SHARED, &bfin_sht) != 0) { 1510 ata_sff_interrupt, IRQF_SHARED, &bfin_sht) != 0) {
1540 peripheral_free_list(atapi_io_port); 1511 peripheral_free_list(atapi_io_port);
1541 dev_err(&pdev->dev, "Fail to attach ATAPI device\n"); 1512 dev_err(&pdev->dev, "Fail to attach ATAPI device\n");
1542 return -ENODEV; 1513 return -ENODEV;