Lines Matching +full:- +full:33000
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pata-legacy.c - Legacy port PATA/SATA controller driver.
9 * Opti 82C465/82C611 support: Data sheets at opti-inc.com
21 * Samuel Thibault <samuel.thibault@ens-lyon.org>
40 * Goldstar GM82C711, PIC-1288A-125, UMC 82C871F, Winbond W83759,
41 * Winbond W83759A, Promise PDC20230-B
140 UNKNOWN = -1
178 * legacy_probe_add - Add interface to probe list
200 if (lp->port == 0 && free == NULL) in legacy_probe_add()
203 if (lp->port == port || legacy_port[i] == port) { in legacy_probe_add()
205 return -1; in legacy_probe_add()
213 return -1; in legacy_probe_add()
216 free->port = port; in legacy_probe_add()
217 free->irq = irq; in legacy_probe_add()
218 free->type = type; in legacy_probe_add()
219 free->private = private; in legacy_probe_add()
225 * legacy_set_mode - mode setting
243 dev->pio_mode = XFER_PIO_0; in legacy_set_mode()
244 dev->xfer_mode = XFER_PIO_0; in legacy_set_mode()
245 dev->xfer_shift = ATA_SHIFT_PIO; in legacy_set_mode()
246 dev->flags |= ATA_DFLAG_PIO; in legacy_set_mode()
291 int pio = adev->pio_mode - XFER_PIO_0; in pdc20230_set_piomode()
309 while ((inb(0x1F2) & 0x80) && --tries); in pdc20230_set_piomode()
316 rt &= ~(0x07 << (3 * !adev->devno)); in pdc20230_set_piomode()
318 rt |= (1 + 3 * pio) << (3 * !adev->devno); in pdc20230_set_piomode()
331 struct ata_device *dev = qc->dev; in pdc_data_xfer_vlb()
332 struct ata_port *ap = dev->link->ap; in pdc_data_xfer_vlb()
336 if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3) in pdc_data_xfer_vlb()
337 && (ap->pflags & ATA_PFLAG_PIO32)) { in pdc_data_xfer_vlb()
343 ioread8(ap->ioaddr.nsect_addr); in pdc_data_xfer_vlb()
344 ioread8(ap->ioaddr.nsect_addr); in pdc_data_xfer_vlb()
345 ioread8(ap->ioaddr.nsect_addr); in pdc_data_xfer_vlb()
349 ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); in pdc_data_xfer_vlb()
351 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); in pdc_data_xfer_vlb()
357 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); in pdc_data_xfer_vlb()
358 memcpy(buf + buflen - slop, &pad, slop); in pdc_data_xfer_vlb()
360 memcpy(&pad, buf + buflen - slop, slop); in pdc_data_xfer_vlb()
361 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); in pdc_data_xfer_vlb()
363 buflen += 4 - slop; in pdc_data_xfer_vlb()
391 ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000); in ht6560a_set_piomode()
401 iowrite8(recover << 4 | active, ap->ioaddr.device_addr); in ht6560a_set_piomode()
402 ioread8(ap->ioaddr.status_addr); in ht6560a_set_piomode()
425 ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000); in ht6560b_set_piomode()
435 iowrite8(recover << 4 | active, ap->ioaddr.device_addr); in ht6560b_set_piomode()
437 if (adev->class != ATA_DEV_ATA) { in ht6560b_set_piomode()
444 ioread8(ap->ioaddr.status_addr); in ht6560b_set_piomode()
457 * opti_syscfg - read OPTI chipset configuration
489 int khz[4] = { 50000, 40000, 33000, 25000 }; in opti82c611a_set_piomode()
493 ioread16(ap->ioaddr.error_addr); in opti82c611a_set_piomode()
494 ioread16(ap->ioaddr.error_addr); in opti82c611a_set_piomode()
495 iowrite8(3, ap->ioaddr.nsect_addr); in opti82c611a_set_piomode()
498 clock = 1000000000 / khz[ioread8(ap->ioaddr.lbah_addr) & 0x03]; in opti82c611a_set_piomode()
501 ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000); in opti82c611a_set_piomode()
506 ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000); in opti82c611a_set_piomode()
511 active = clamp_val(t.active, 2, 17) - 2; in opti82c611a_set_piomode()
512 recover = clamp_val(t.recover, 1, 16) - 1; in opti82c611a_set_piomode()
513 setup = clamp_val(t.setup, 1, 4) - 1; in opti82c611a_set_piomode()
516 rc = ioread8(ap->ioaddr.lbal_addr); in opti82c611a_set_piomode()
518 rc |= (adev->devno << 7); in opti82c611a_set_piomode()
519 iowrite8(rc, ap->ioaddr.lbal_addr); in opti82c611a_set_piomode()
522 iowrite8(active << 4 | recover, ap->ioaddr.error_addr); in opti82c611a_set_piomode()
526 rc = ioread8(ap->ioaddr.device_addr); in opti82c611a_set_piomode()
528 rc |= adev->devno; /* Index select */ in opti82c611a_set_piomode()
530 iowrite8(rc, ap->ioaddr.device_addr); in opti82c611a_set_piomode()
533 iowrite8(active << 4 | recover, ap->ioaddr.data_addr); in opti82c611a_set_piomode()
536 rc = ioread8(ap->ioaddr.lbal_addr); in opti82c611a_set_piomode()
539 iowrite8(rc, ap->ioaddr.lbal_addr); in opti82c611a_set_piomode()
542 iowrite8(0x83, ap->ioaddr.nsect_addr); in opti82c611a_set_piomode()
564 int khz[4] = { 50000, 40000, 33000, 25000 }; in opti82c46x_set_piomode()
572 ioread16(ap->ioaddr.error_addr); in opti82c46x_set_piomode()
573 ioread16(ap->ioaddr.error_addr); in opti82c46x_set_piomode()
574 iowrite8(3, ap->ioaddr.nsect_addr); in opti82c46x_set_piomode()
580 ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000); in opti82c46x_set_piomode()
585 ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000); in opti82c46x_set_piomode()
590 active = clamp_val(t.active, 2, 17) - 2; in opti82c46x_set_piomode()
591 recover = clamp_val(t.recover, 1, 16) - 1; in opti82c46x_set_piomode()
592 setup = clamp_val(t.setup, 1, 4) - 1; in opti82c46x_set_piomode()
595 rc = ioread8(ap->ioaddr.lbal_addr); in opti82c46x_set_piomode()
597 rc |= (adev->devno << 7); in opti82c46x_set_piomode()
598 iowrite8(rc, ap->ioaddr.lbal_addr); in opti82c46x_set_piomode()
601 iowrite8(active << 4 | recover, ap->ioaddr.error_addr); in opti82c46x_set_piomode()
605 rc = ioread8(ap->ioaddr.device_addr); in opti82c46x_set_piomode()
607 rc |= adev->devno; /* Index select */ in opti82c46x_set_piomode()
609 iowrite8(rc, ap->ioaddr.device_addr); in opti82c46x_set_piomode()
612 iowrite8(active << 4 | recover, ap->ioaddr.data_addr); in opti82c46x_set_piomode()
615 rc = ioread8(ap->ioaddr.lbal_addr); in opti82c46x_set_piomode()
618 iowrite8(rc, ap->ioaddr.lbal_addr); in opti82c46x_set_piomode()
621 iowrite8(0x83, ap->ioaddr.nsect_addr); in opti82c46x_set_piomode()
624 ap->host->private_data = ap; in opti82c46x_set_piomode()
628 * opti82c46x_qc_issue - command issue
639 * FIXME: dual channel needs ->serialize support
644 struct ata_port *ap = qc->ap; in opti82c46x_qc_issue()
645 struct ata_device *adev = qc->dev; in opti82c46x_qc_issue()
649 if (ap->host->private_data != ap->host in opti82c46x_qc_issue()
650 && ap->host->private_data != NULL) in opti82c46x_qc_issue()
663 * qdi65x0_set_piomode - PIO setup for QDI65x0
678 struct legacy_data *ld_qdi = ap->host->private_data; in qdi65x0_set_piomode()
683 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); in qdi65x0_set_piomode()
685 if (ld_qdi->fast) { in qdi65x0_set_piomode()
686 active = 8 - clamp_val(t.active, 1, 8); in qdi65x0_set_piomode()
687 recovery = 18 - clamp_val(t.recover, 3, 18); in qdi65x0_set_piomode()
689 active = 9 - clamp_val(t.active, 2, 9); in qdi65x0_set_piomode()
690 recovery = 15 - clamp_val(t.recover, 0, 15); in qdi65x0_set_piomode()
693 ld_qdi->clock[adev->devno] = timing; in qdi65x0_set_piomode()
695 if (ld_qdi->type == QDI6580) in qdi65x0_set_piomode()
696 outb(timing, ld_qdi->timing + 2 * adev->devno); in qdi65x0_set_piomode()
698 outb(timing, ld_qdi->timing + 2 * ap->port_no); in qdi65x0_set_piomode()
701 if (ld_qdi->type != QDI6500 && adev->class != ATA_DEV_ATA) in qdi65x0_set_piomode()
702 outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3); in qdi65x0_set_piomode()
706 * qdi_qc_issue - command issue
715 struct ata_port *ap = qc->ap; in qdi_qc_issue()
716 struct ata_device *adev = qc->dev; in qdi_qc_issue()
717 struct legacy_data *ld_qdi = ap->host->private_data; in qdi_qc_issue()
719 if (ld_qdi->clock[adev->devno] != ld_qdi->last) { in qdi_qc_issue()
720 if (adev->pio_mode) { in qdi_qc_issue()
721 ld_qdi->last = ld_qdi->clock[adev->devno]; in qdi_qc_issue()
722 outb(ld_qdi->clock[adev->devno], ld_qdi->timing + in qdi_qc_issue()
723 2 * ap->port_no); in qdi_qc_issue()
733 struct ata_device *adev = qc->dev; in vlb32_data_xfer()
734 struct ata_port *ap = adev->link->ap; in vlb32_data_xfer()
737 if (ata_id_has_dword_io(adev->id) && (slop == 0 || slop == 3) in vlb32_data_xfer()
738 && (ap->pflags & ATA_PFLAG_PIO32)) { in vlb32_data_xfer()
740 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); in vlb32_data_xfer()
742 ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); in vlb32_data_xfer()
748 memcpy(&pad, buf + buflen - slop, slop); in vlb32_data_xfer()
749 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); in vlb32_data_xfer()
751 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); in vlb32_data_xfer()
752 memcpy(buf + buflen - slop, &pad, slop); in vlb32_data_xfer()
763 if (devm_request_region(&dev->dev, lp->private, 4, "qdi") == NULL) in qdi_port()
764 return -EBUSY; in qdi_port()
765 ld->timing = lp->private; in qdi_port()
816 struct legacy_data *ld_winbond = ap->host->private_data; in winbond_set_piomode()
819 int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2); in winbond_set_piomode()
821 reg = winbond_readcfg(ld_winbond->timing, 0x81); in winbond_set_piomode()
825 ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000); in winbond_set_piomode()
827 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); in winbond_set_piomode()
829 active = (clamp_val(t.active, 3, 17) - 1) & 0x0F; in winbond_set_piomode()
832 winbond_writecfg(ld_winbond->timing, timing, reg); in winbond_set_piomode()
837 if (adev->class != ATA_DEV_ATA) in winbond_set_piomode()
842 winbond_writecfg(ld_winbond->timing, timing + 1, reg); in winbond_set_piomode()
848 if (devm_request_region(&dev->dev, lp->private, 4, "winbond") == NULL) in winbond_port()
849 return -EBUSY; in winbond_port()
850 ld->timing = lp->private; in winbond_port()
889 * probe_chip_type - Discover controller
898 int mask = 1 << probe->slot; in probe_chip_type()
900 if (winbond && (probe->port == 0x1F0 || probe->port == 0x170)) { in probe_chip_type()
916 if (probe->port == 0x1F0) { in probe_chip_type()
930 printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller" in probe_chip_type()
941 printk(KERN_INFO "PDC20230-B VLB ATA " in probe_chip_type()
963 * legacy_init_one - attach a legacy interface
972 struct legacy_controller *controller = &controllers[probe->type]; in legacy_init_one()
973 int pio_modes = controller->pio_mask; in legacy_init_one()
974 unsigned long io = probe->port; in legacy_init_one()
975 u32 mask = (1 << probe->slot); in legacy_init_one()
976 struct ata_port_operations *ops = controller->ops; in legacy_init_one()
977 struct legacy_data *ld = &legacy_data[probe->slot]; in legacy_init_one()
986 iordy |= controller->flags; in legacy_init_one()
988 pdev = platform_device_register_simple(DRV_NAME, probe->slot, NULL, 0); in legacy_init_one()
992 ret = -EBUSY; in legacy_init_one()
993 if (devm_request_region(&pdev->dev, io, 8, "pata_legacy") == NULL || in legacy_init_one()
994 devm_request_region(&pdev->dev, io + 0x0206, 1, in legacy_init_one()
998 ret = -ENOMEM; in legacy_init_one()
999 io_addr = devm_ioport_map(&pdev->dev, io, 8); in legacy_init_one()
1000 ctrl_addr = devm_ioport_map(&pdev->dev, io + 0x0206, 1); in legacy_init_one()
1003 ld->type = probe->type; in legacy_init_one()
1004 if (controller->setup) in legacy_init_one()
1005 if (controller->setup(pdev, probe, ld) < 0) in legacy_init_one()
1007 host = ata_host_alloc(&pdev->dev, 1); in legacy_init_one()
1010 ap = host->ports[0]; in legacy_init_one()
1012 ap->ops = ops; in legacy_init_one()
1013 ap->pio_mask = pio_modes; in legacy_init_one()
1014 ap->flags |= ATA_FLAG_SLAVE_POSS | iordy; in legacy_init_one()
1015 ap->pflags |= controller->pflags; in legacy_init_one()
1016 ap->ioaddr.cmd_addr = io_addr; in legacy_init_one()
1017 ap->ioaddr.altstatus_addr = ctrl_addr; in legacy_init_one()
1018 ap->ioaddr.ctl_addr = ctrl_addr; in legacy_init_one()
1019 ata_sff_std_ports(&ap->ioaddr); in legacy_init_one()
1020 ap->host->private_data = ld; in legacy_init_one()
1024 ret = ata_host_activate(host, probe->irq, ata_sff_interrupt, 0, in legacy_init_one()
1029 ld->platform_dev = pdev; in legacy_init_one()
1033 ret = -ENODEV; in legacy_init_one()
1034 ata_for_each_dev(dev, &ap->link, ALL) { in legacy_init_one()
1036 legacy_host[probe->slot] = host; in legacy_init_one()
1037 ld->platform_dev = pdev; in legacy_init_one()
1048 * legacy_check_special_cases - ATA special cases
1064 if (p->vendor == 0x1078 && p->device == 0x0000) { in legacy_check_special_cases()
1069 if (p->vendor == 0x1078 && p->device == 0x0002) { in legacy_check_special_cases()
1073 /* Intel MPIIX - PIO ATA on non PCI side of bridge */ in legacy_check_special_cases()
1074 if (p->vendor == 0x8086 && p->device == 0x1234) { in legacy_check_special_cases()
1198 * legacy_init - attach legacy interfaces
1260 if (pl->port == 0) in legacy_init()
1262 if (pl->type == UNKNOWN) in legacy_init()
1263 pl->type = probe_chip_type(pl); in legacy_init()
1264 pl->slot = slot++; in legacy_init()
1270 return -ENODEV; in legacy_init()
1282 platform_device_unregister(ld->platform_dev); in legacy_exit()
1287 MODULE_DESCRIPTION("low-level driver for legacy ATA");