0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/kernel.h>
0016 #include <linux/module.h>
0017 #include <linux/pci.h>
0018 #include <linux/blkdev.h>
0019 #include <linux/delay.h>
0020 #include <scsi/scsi_host.h>
0021 #include <linux/libata.h>
0022
0023 #define DRV_NAME "pata_rz1000"
0024 #define DRV_VERSION "0.2.4"
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 static int rz1000_set_mode(struct ata_link *link, struct ata_device **unused)
0038 {
0039 struct ata_device *dev;
0040
0041 ata_for_each_dev(dev, link, ENABLED) {
0042
0043 dev->pio_mode = XFER_PIO_0;
0044 dev->xfer_mode = XFER_PIO_0;
0045 dev->xfer_shift = ATA_SHIFT_PIO;
0046 dev->flags |= ATA_DFLAG_PIO;
0047 ata_dev_info(dev, "configured for PIO\n");
0048 }
0049 return 0;
0050 }
0051
0052
0053 static struct scsi_host_template rz1000_sht = {
0054 ATA_PIO_SHT(DRV_NAME),
0055 };
0056
0057 static struct ata_port_operations rz1000_port_ops = {
0058 .inherits = &ata_sff_port_ops,
0059 .cable_detect = ata_cable_40wire,
0060 .set_mode = rz1000_set_mode,
0061 };
0062
0063 static int rz1000_fifo_disable(struct pci_dev *pdev)
0064 {
0065 u16 reg;
0066
0067 if (pci_read_config_word(pdev, 0x40, ®) != 0)
0068 return -1;
0069 reg &= 0xDFFF;
0070 if (pci_write_config_word(pdev, 0x40, reg) != 0)
0071 return -1;
0072 dev_info(&pdev->dev, "disabled chipset readahead.\n");
0073 return 0;
0074 }
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
0087 {
0088 static const struct ata_port_info info = {
0089 .flags = ATA_FLAG_SLAVE_POSS,
0090 .pio_mask = ATA_PIO4,
0091 .port_ops = &rz1000_port_ops
0092 };
0093 const struct ata_port_info *ppi[] = { &info, NULL };
0094
0095 ata_print_version_once(&pdev->dev, DRV_VERSION);
0096
0097 if (rz1000_fifo_disable(pdev) == 0)
0098 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0);
0099
0100 dev_err(&pdev->dev, "failed to disable read-ahead on chipset.\n");
0101
0102 return -ENODEV;
0103 }
0104
0105 #ifdef CONFIG_PM_SLEEP
0106 static int rz1000_reinit_one(struct pci_dev *pdev)
0107 {
0108 struct ata_host *host = pci_get_drvdata(pdev);
0109 int rc;
0110
0111 rc = ata_pci_device_do_resume(pdev);
0112 if (rc)
0113 return rc;
0114
0115
0116
0117 if (rz1000_fifo_disable(pdev))
0118 panic("rz1000 fifo");
0119
0120 ata_host_resume(host);
0121 return 0;
0122 }
0123 #endif
0124
0125 static const struct pci_device_id pata_rz1000[] = {
0126 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), },
0127 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), },
0128
0129 { },
0130 };
0131
0132 static struct pci_driver rz1000_pci_driver = {
0133 .name = DRV_NAME,
0134 .id_table = pata_rz1000,
0135 .probe = rz1000_init_one,
0136 .remove = ata_pci_remove_one,
0137 #ifdef CONFIG_PM_SLEEP
0138 .suspend = ata_pci_device_suspend,
0139 .resume = rz1000_reinit_one,
0140 #endif
0141 };
0142
0143 module_pci_driver(rz1000_pci_driver);
0144
0145 MODULE_AUTHOR("Alan Cox");
0146 MODULE_DESCRIPTION("low-level driver for RZ1000 PCI ATA");
0147 MODULE_LICENSE("GPL");
0148 MODULE_DEVICE_TABLE(pci, pata_rz1000);
0149 MODULE_VERSION(DRV_VERSION);