// SPDX-License-Identifier: GPL-2.0-only /* * Libata driver for the highpoint 366 and 368 UDMA66 ATA controllers. * * This driver is heavily based upon: * * linux/drivers/ide/pci/hpt366.c Version 0.36 April 25, 2003 * * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> * Portions Copyright (C) 2001 Sun Microsystems, Inc. * Portions Copyright (C) 2003 Red Hat Inc * * * TODO * Look into engine reset on timeout errors. Should not be required.
*/ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <scsi/scsi_host.h> #include <linux/libata.h>
/* key for bus clock timings * bit * 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA. * cycles = value + 1 * 4:7 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA. * cycles = value + 1 * 8:11 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file * register access. * 12:15 cmd_low_time. Active time of DIOW_/DIOR_ during task file * register access. * 16:18 udma_cycle_time. Clock cycles for UDMA xfer? * 19:21 pre_high_time. Time to initialize 1st cycle for PIO and MW DMA xfer. * 22:24 cmd_pre_high_time. Time to initialize 1st PIO cycle for task file * register access. * 28 UDMA enable. * 29 DMA enable. * 30 PIO_MST enable. If set, the chip is in bus master mode during * PIO xfer. * 31 FIFO enable.
*/
/** * hpt36x_find_mode - find the hpt36x timing * @ap: ATA port * @speed: transfer mode * * Return the 32bit register programming information for this channel * that matches the speed provided.
*/
i = match_string(list, -1, model_num); if (i >= 0) {
ata_dev_warn(dev, "%s is not supported for %s\n", modestr, list[i]); return 1;
} return 0;
}
/** * hpt366_filter - mode selection filter * @adev: ATA device * @mask: Current mask to manipulate and pass back * * Block UDMA on devices that cause trouble with this controller.
*/
/* * Each channel of pata_hpt366 occupies separate PCI function * as the primary channel and bit1 indicates the cable type.
*/
pci_read_config_byte(pdev, 0x5A, &ata66); if (ata66 & 2) return ATA_CBL_PATA40; return ATA_CBL_PATA80;
}
/** * hpt366_set_dmamode - DMA timing setup * @ap: ATA interface * @adev: Device being configured * * Set up the channel for MWDMA or UDMA modes. Much the same as with * PIO, load the mode number and then set MWDMA or UDMA flag.
*/
/** * hpt366_prereset - reset the hpt36x bus * @link: ATA link to reset * @deadline: deadline jiffies for the operation * * Perform the initial reset handling for the 36x series controllers. * Reset the hardware and state machine,
*/
staticint hpt366_prereset(struct ata_link *link, unsignedlong deadline)
{ struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); /* * HPT36x chips have one channel per function and have * both channel enable bits located differently and visible * to both functions -- really stupid design decision... :-( * Bit 4 is for the primary channel, bit 5 for the secondary.
*/ staticconststruct pci_bits hpt366_enable_bits = {
0x50, 1, 0x30, 0x30
};
u8 mcr2;
if (!pci_test_config_bits(pdev, &hpt366_enable_bits)) return -ENOENT;
/* * Now we'll have to force both channels enabled if at least one * of them has been enabled by BIOS...
*/
pci_read_config_byte(dev, 0x50, &mcr1); if (mcr1 & 0x30)
pci_write_config_byte(dev, 0x50, mcr1 | 0x30);
}
/** * hpt36x_init_one - Initialise an HPT366/368 * @dev: PCI device * @id: Entry in match table * * Initialise an HPT36x device. There are some interesting complications * here. Firstly the chip may report 366 and be one of several variants. * Secondly all the timings depend on the clock for the chip which we must * detect and look up * * This is the known chip mappings. It may be missing a couple of later * releases. * * Chip version PCI Rev Notes * HPT366 4 (HPT366) 0 UDMA66 * HPT366 4 (HPT366) 1 UDMA66 * HPT368 4 (HPT366) 2 UDMA66 * HPT37x/30x 4 (HPT366) 3+ Other driver *
*/
/* May be a later chip in disguise. Check */ /* Newer chips are not in the HPT36x driver. Ignore them */ if (dev->revision > 2) return -ENODEV;
hpt36x_init_chipset(dev);
pci_read_config_dword(dev, 0x40, ®1);
/* PCI clocking determines the ATA timing values to use */ /* info_hpt366 is safe against re-entry so we can scribble on it */ switch ((reg1 & 0xf00) >> 8) { case 9:
hpriv = &hpt366_40; break; case 5:
hpriv = &hpt366_25; break; default:
hpriv = &hpt366_33; break;
} /* Now kick off ATA set up */ return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, (void *)hpriv, 0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.