* based upon
*
* it821x.c
- *
+ *
* linux/drivers/ide/pci/it821x.c Version 0.09 December 2004
*
* Copyright (C) 2004 Red Hat <alan@redhat.com>
#define DRV_NAME "pata_it821x"
-#define DRV_VERSION "0.3.2"
+#define DRV_VERSION "0.3.3"
struct it821x_dev
{
*
* Set the cable type
*/
-
+
static int it821x_pre_reset(struct ata_port *ap)
{
ap->cbl = ATA_CBL_PATA80;
*
* Set the cable type and trigger a probe
*/
-
+
static void it821x_error_handler(struct ata_port *ap)
{
return ata_bmdma_drive_eh(ap, it821x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
struct it821x_dev *itdev = ap->private_data;
int unit = adev->devno;
int mode_wanted = adev->pio_mode - XFER_PIO_0;
-
+
/* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
itdev->want[unit][1] = pio_want[mode_wanted];
itdev->want[unit][0] = 1; /* PIO is lowest priority */
* @adev: ATA device
*
* Set up the DMA modes. The actions taken depend heavily on the mode
- * to use. If UDMA is used as is hopefully the usual case then the
+ * to use. If UDMA is used as is hopefully the usual case then the
* timing register is private and we need only consider the clock. If
* we are using MWDMA then we have to manage the setting ourself as
* we switch devices and mode.
if (adev->dma_mode >= XFER_UDMA_0) {
int mode_wanted = adev->dma_mode - XFER_UDMA_0;
-
+
itdev->want[unit][1] = udma_want[mode_wanted];
itdev->want[unit][0] = 3; /* UDMA is high priority */
itdev->mwdma[unit] = MWDMA_OFF;
it821x_program_udma(ap, adev, itdev->udma[unit]);
} else {
int mode_wanted = adev->dma_mode - XFER_MW_DMA_0;
-
+
itdev->want[unit][1] = mwdma_want[mode_wanted];
itdev->want[unit][0] = 2; /* MWDMA is low priority */
itdev->mwdma[unit] = dma[mode_wanted];
* @qc: Command in progress
*
* Usually drivers set the DMA timing at the point the set_dmamode call
- * is made. IT821x however requires we load new timings on the
+ * is made. IT821x however requires we load new timings on the
* transitions in some cases.
*/
*
* Device selection hook. If neccessary perform clock switching
*/
-
+
static void it821x_passthru_dev_select(struct ata_port *ap,
unsigned int device)
{
* perform out own device selection timing loads before the
* usual happenings kick off
*/
-
+
static unsigned int it821x_smart_qc_issue_prot(struct ata_queued_cmd *qc)
{
switch(qc->tf.command)
* perform out own device selection timing loads before the
* usual happenings kick off
*/
-
+
static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
{
it821x_passthru_dev_select(qc->ap, qc->dev->devno);
* Use a non standard set_mode function. We don't want to be tuned.
* The BIOS configured everything. Our job is not to fiddle. We
* read the dma enabled bits from the PCI configuration of the device
- * and respect them.
+ * and respect them.
*/
-
+
static void it821x_smart_set_mode(struct ata_port *ap)
{
int dma_enabled = 0;
/* It is possible that BMDMA isn't allocated */
if (ap->ioaddr.bmdma_addr)
dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-
+
for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i];
if (ata_dev_enabled(dev)) {
/* We don't really care */
dev->pio_mode = XFER_PIO_0;
dev->dma_mode = XFER_MW_DMA_0;
- /* We do need the right mode information for DMA or PIO
+ /* We do need the right mode information for DMA or PIO
and this comes from the current configuration flags */
if (dma_enabled & (1 << (5 + i))) {
dev->xfer_mode = XFER_MW_DMA_0;
* FIXME: When FUA appears we need to block FUA too. And SMART and
* basically we need to filter commands for this chip.
*/
-
+
static void it821x_dev_config(struct ata_port *ap, struct ata_device *adev)
{
unsigned char model_num[40];
/* This block ought to be a library routine as it is in several
drivers now */
-
+
ata_id_string(adev->id, model_num, ATA_ID_PROD_OFS,
sizeof(model_num));
s = &model_num[0];
if (adev->max_sectors > 255)
adev->max_sectors = 255;
-
+
if (strstr(model_num, "Integrated Technology Express")) {
/* RAID mode */
printk(KERN_INFO "IT821x %sRAID%d volume",
* Decide if this ATAPI command can be issued by DMA on this
* controller. Return 0 if it can be.
*/
-
+
static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct it821x_dev *itdev = ap->private_data;
-
+
/* No ATAPI DMA in smart mode */
if (itdev->smart)
return -EOPNOTSUPP;
/* Cool */
return 0;
}
-
+
/**
* it821x_port_start - port setup
*
* The it821x needs to maintain private data structures and also to
* use the standard PCI interface which lacks support for this
- * functionality. We instead set up the private data on the port
+ * functionality. We instead set up the private data on the port
* start hook, and tear it down on port stop
*/
-
+
static int it821x_port_start(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
int ret = ata_port_start(ap);
if (ret < 0)
return ret;
-
+
ap->private_data = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL);
if (ap->private_data == NULL) {
ata_port_stop(ap);
return -ENOMEM;
}
-
+
itdev = ap->private_data;
memset(itdev, 0, sizeof(struct it821x_dev));
*
* Release the private objects we added in it821x_port_start
*/
-
+
static void it821x_port_stop(struct ata_port *ap) {
kfree(ap->private_data);
ap->private_data = NULL; /* We want an OOPS if we reuse this
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
- /* 255 sectors to begin with. This is locked in smart mode but not
- in pass through */
- .max_sectors = 255,
.cmd_per_lun = ATA_SHT_CMD_PER_LUN,
.emulated = ATA_SHT_EMULATED,
.use_clustering = ATA_SHT_USE_CLUSTERING,
.proc_name = DRV_NAME,
.dma_boundary = ATA_DMA_BOUNDARY,
.slave_configure = ata_scsi_slave_config,
+ .slave_destroy = ata_scsi_slave_destroy,
.bios_param = ata_std_bios_param,
+ .resume = ata_scsi_device_resume,
+ .suspend = ata_scsi_device_suspend,
};
static struct ata_port_operations it821x_smart_port_ops = {
.tf_load = ata_tf_load,
.tf_read = ata_tf_read,
.mode_filter = ata_pci_default_filter,
-
+
.check_status = ata_check_status,
.check_atapi_dma= it821x_check_atapi_dma,
.exec_command = ata_exec_command,
.qc_prep = ata_qc_prep,
.qc_issue = it821x_smart_qc_issue_prot,
- .eng_timeout = ata_eng_timeout,
+
.data_xfer = ata_pio_data_xfer,
.irq_handler = ata_interrupt,
.port_start = it821x_port_start,
.port_stop = it821x_port_stop,
.host_stop = ata_host_stop
-};
+};
static struct ata_port_operations it821x_passthru_port_ops = {
.port_disable = ata_port_disable,
.set_piomode = it821x_passthru_set_piomode,
.set_dmamode = it821x_passthru_set_dmamode,
.mode_filter = ata_pci_default_filter,
-
+
.tf_load = ata_tf_load,
.tf_read = ata_tf_read,
.check_status = ata_check_status,
.qc_prep = ata_qc_prep,
.qc_issue = it821x_passthru_qc_issue_prot,
- .eng_timeout = ata_eng_timeout,
+
.data_xfer = ata_pio_data_xfer,
.irq_clear = ata_bmdma_irq_clear,
.port_start = it821x_port_start,
.port_stop = it821x_port_stop,
.host_stop = ata_host_stop
-};
+};
static void __devinit it821x_disable_raid(struct pci_dev *pdev)
{
pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
}
-
+
static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
u8 conf;
-
+
static struct ata_port_info info_smart = {
.sht = &it821x_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.port_ops = &it821x_passthru_port_ops
};
static struct ata_port_info *port_info[2];
-
+
static char *mode[2] = { "pass through", "smart" };
/* Force the card into bypass mode if so requested */
}
pci_read_config_byte(pdev, 0x50, &conf);
conf &= 1;
-
+
printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]);
if (conf == 0)
port_info[0] = port_info[1] = &info_passthru;
else
port_info[0] = port_info[1] = &info_smart;
-
+
return ata_pci_init_one(pdev, port_info, 2);
}
-static struct pci_device_id it821x[] = {
- { PCI_DEVICE(PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8211), },
- { PCI_DEVICE(PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212), },
- { 0, },
+static int it821x_reinit_one(struct pci_dev *pdev)
+{
+ /* Resume - turn raid back off if need be */
+ if (it8212_noraid)
+ it821x_disable_raid(pdev);
+ return ata_pci_device_resume(pdev);
+}
+
+static const struct pci_device_id it821x[] = {
+ { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
+ { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), },
+
+ { },
};
static struct pci_driver it821x_pci_driver = {
- .name = DRV_NAME,
+ .name = DRV_NAME,
.id_table = it821x,
.probe = it821x_init_one,
- .remove = ata_pci_remove_one
+ .remove = ata_pci_remove_one,
+ .suspend = ata_pci_device_suspend,
+ .resume = it821x_reinit_one,
};
static int __init it821x_init(void)
return pci_register_driver(&it821x_pci_driver);
}
-
static void __exit it821x_exit(void)
{
pci_unregister_driver(&it821x_pci_driver);
}
-
MODULE_AUTHOR("Alan Cox");
MODULE_DESCRIPTION("low-level driver for the IT8211/IT8212 IDE RAID controller");
MODULE_LICENSE("GPL");