aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/tx4939ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/tx4939ide.c')
-rw-r--r--drivers/ide/tx4939ide.c76
1 files changed, 43 insertions, 33 deletions
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index bafb7d1a22e2..882f6f07c476 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -259,6 +259,12 @@ static int tx4939ide_build_dmatable(ide_drive_t *drive, struct request *rq)
259 bcount = 0x10000 - (cur_addr & 0xffff); 259 bcount = 0x10000 - (cur_addr & 0xffff);
260 if (bcount > cur_len) 260 if (bcount > cur_len)
261 bcount = cur_len; 261 bcount = cur_len;
262 /*
263 * This workaround for zero count seems required.
264 * (standard ide_build_dmatable do it too)
265 */
266 if ((bcount & 0xffff) == 0x0000)
267 bcount = 0x8000;
262 *table++ = bcount & 0xffff; 268 *table++ = bcount & 0xffff;
263 *table++ = cur_addr; 269 *table++ = cur_addr;
264 cur_addr += bcount; 270 cur_addr += bcount;
@@ -287,7 +293,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive)
287{ 293{
288 ide_hwif_t *hwif = drive->hwif; 294 ide_hwif_t *hwif = drive->hwif;
289 void __iomem *base = TX4939IDE_BASE(hwif); 295 void __iomem *base = TX4939IDE_BASE(hwif);
290 struct request *rq = hwif->hwgroup->rq; 296 struct request *rq = hwif->rq;
291 u8 reading; 297 u8 reading;
292 int nent; 298 int nent;
293 299
@@ -391,6 +397,17 @@ static int tx4939ide_dma_test_irq(ide_drive_t *drive)
391 return found; 397 return found;
392} 398}
393 399
400#ifdef __BIG_ENDIAN
401static u8 tx4939ide_dma_sff_read_status(ide_hwif_t *hwif)
402{
403 void __iomem *base = TX4939IDE_BASE(hwif);
404
405 return tx4939ide_readb(base, TX4939IDE_DMA_Stat);
406}
407#else
408#define tx4939ide_dma_sff_read_status ide_dma_sff_read_status
409#endif
410
394static void tx4939ide_init_hwif(ide_hwif_t *hwif) 411static void tx4939ide_init_hwif(ide_hwif_t *hwif)
395{ 412{
396 void __iomem *base = TX4939IDE_BASE(hwif); 413 void __iomem *base = TX4939IDE_BASE(hwif);
@@ -437,13 +454,6 @@ static void tx4939ide_tf_load_fixup(ide_drive_t *drive, ide_task_t *task)
437 454
438#ifdef __BIG_ENDIAN 455#ifdef __BIG_ENDIAN
439 456
440static u8 tx4939ide_read_sff_dma_status(ide_hwif_t *hwif)
441{
442 void __iomem *base = TX4939IDE_BASE(hwif);
443
444 return tx4939ide_readb(base, TX4939IDE_DMA_Stat);
445}
446
447/* custom iops (independent from SWAP_IO_SPACE) */ 457/* custom iops (independent from SWAP_IO_SPACE) */
448static u8 tx4939ide_inb(unsigned long port) 458static u8 tx4939ide_inb(unsigned long port)
449{ 459{
@@ -558,7 +568,7 @@ static void tx4939ide_input_data_swap(ide_drive_t *drive, struct request *rq,
558 568
559 while (count--) 569 while (count--)
560 *ptr++ = cpu_to_le16(__raw_readw((void __iomem *)port)); 570 *ptr++ = cpu_to_le16(__raw_readw((void __iomem *)port));
561 __ide_flush_dcache_range((unsigned long)buf, count * 2); 571 __ide_flush_dcache_range((unsigned long)buf, roundup(len, 2));
562} 572}
563 573
564static void tx4939ide_output_data_swap(ide_drive_t *drive, struct request *rq, 574static void tx4939ide_output_data_swap(ide_drive_t *drive, struct request *rq,
@@ -572,14 +582,13 @@ static void tx4939ide_output_data_swap(ide_drive_t *drive, struct request *rq,
572 __raw_writew(le16_to_cpu(*ptr), (void __iomem *)port); 582 __raw_writew(le16_to_cpu(*ptr), (void __iomem *)port);
573 ptr++; 583 ptr++;
574 } 584 }
575 __ide_flush_dcache_range((unsigned long)buf, count * 2); 585 __ide_flush_dcache_range((unsigned long)buf, roundup(len, 2));
576} 586}
577 587
578static const struct ide_tp_ops tx4939ide_tp_ops = { 588static const struct ide_tp_ops tx4939ide_tp_ops = {
579 .exec_command = ide_exec_command, 589 .exec_command = ide_exec_command,
580 .read_status = ide_read_status, 590 .read_status = ide_read_status,
581 .read_altstatus = ide_read_altstatus, 591 .read_altstatus = ide_read_altstatus,
582 .read_sff_dma_status = tx4939ide_read_sff_dma_status,
583 592
584 .set_irq = ide_set_irq, 593 .set_irq = ide_set_irq,
585 594
@@ -603,7 +612,6 @@ static const struct ide_tp_ops tx4939ide_tp_ops = {
603 .exec_command = ide_exec_command, 612 .exec_command = ide_exec_command,
604 .read_status = ide_read_status, 613 .read_status = ide_read_status,
605 .read_altstatus = ide_read_altstatus, 614 .read_altstatus = ide_read_altstatus,
606 .read_sff_dma_status = ide_read_sff_dma_status,
607 615
608 .set_irq = ide_set_irq, 616 .set_irq = ide_set_irq,
609 617
@@ -617,33 +625,35 @@ static const struct ide_tp_ops tx4939ide_tp_ops = {
617#endif /* __LITTLE_ENDIAN */ 625#endif /* __LITTLE_ENDIAN */
618 626
619static const struct ide_port_ops tx4939ide_port_ops = { 627static const struct ide_port_ops tx4939ide_port_ops = {
620 .set_pio_mode = tx4939ide_set_pio_mode, 628 .set_pio_mode = tx4939ide_set_pio_mode,
621 .set_dma_mode = tx4939ide_set_dma_mode, 629 .set_dma_mode = tx4939ide_set_dma_mode,
622 .clear_irq = tx4939ide_clear_irq, 630 .clear_irq = tx4939ide_clear_irq,
623 .cable_detect = tx4939ide_cable_detect, 631 .cable_detect = tx4939ide_cable_detect,
624}; 632};
625 633
626static const struct ide_dma_ops tx4939ide_dma_ops = { 634static const struct ide_dma_ops tx4939ide_dma_ops = {
627 .dma_host_set = tx4939ide_dma_host_set, 635 .dma_host_set = tx4939ide_dma_host_set,
628 .dma_setup = tx4939ide_dma_setup, 636 .dma_setup = tx4939ide_dma_setup,
629 .dma_exec_cmd = ide_dma_exec_cmd, 637 .dma_exec_cmd = ide_dma_exec_cmd,
630 .dma_start = ide_dma_start, 638 .dma_start = ide_dma_start,
631 .dma_end = tx4939ide_dma_end, 639 .dma_end = tx4939ide_dma_end,
632 .dma_test_irq = tx4939ide_dma_test_irq, 640 .dma_test_irq = tx4939ide_dma_test_irq,
633 .dma_lost_irq = ide_dma_lost_irq, 641 .dma_lost_irq = ide_dma_lost_irq,
634 .dma_timeout = ide_dma_timeout, 642 .dma_timeout = ide_dma_timeout,
643 .dma_sff_read_status = tx4939ide_dma_sff_read_status,
635}; 644};
636 645
637static const struct ide_port_info tx4939ide_port_info __initdata = { 646static const struct ide_port_info tx4939ide_port_info __initdata = {
638 .init_hwif = tx4939ide_init_hwif, 647 .init_hwif = tx4939ide_init_hwif,
639 .init_dma = tx4939ide_init_dma, 648 .init_dma = tx4939ide_init_dma,
640 .port_ops = &tx4939ide_port_ops, 649 .port_ops = &tx4939ide_port_ops,
641 .dma_ops = &tx4939ide_dma_ops, 650 .dma_ops = &tx4939ide_dma_ops,
642 .tp_ops = &tx4939ide_tp_ops, 651 .tp_ops = &tx4939ide_tp_ops,
643 .host_flags = IDE_HFLAG_MMIO, 652 .host_flags = IDE_HFLAG_MMIO,
644 .pio_mask = ATA_PIO4, 653 .pio_mask = ATA_PIO4,
645 .mwdma_mask = ATA_MWDMA2, 654 .mwdma_mask = ATA_MWDMA2,
646 .udma_mask = ATA_UDMA5, 655 .udma_mask = ATA_UDMA5,
656 .chipset = ide_generic,
647}; 657};
648 658
649static int __init tx4939ide_probe(struct platform_device *pdev) 659static int __init tx4939ide_probe(struct platform_device *pdev)