0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <linux/kernel.h>
0019 #include <linux/module.h>
0020 #include <linux/pci.h>
0021 #include <linux/blkdev.h>
0022 #include <linux/delay.h>
0023 #include <scsi/scsi_host.h>
0024 #include <linux/libata.h>
0025
0026 #define DRV_NAME "pata_piccolo"
0027 #define DRV_VERSION "0.0.1"
0028
0029
0030
0031 static void tosh_set_piomode(struct ata_port *ap, struct ata_device *adev)
0032 {
0033 static const u16 pio[6] = {
0034 0x0566, 0x0433, 0x0311, 0x0201, 0x0200, 0x0100
0035 };
0036 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
0037 u16 conf;
0038 pci_read_config_word(pdev, 0x50, &conf);
0039 conf &= 0xE088;
0040 conf |= pio[adev->pio_mode - XFER_PIO_0];
0041 pci_write_config_word(pdev, 0x50, conf);
0042 }
0043
0044 static void tosh_set_dmamode(struct ata_port *ap, struct ata_device *adev)
0045 {
0046 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
0047 u32 conf;
0048 pci_read_config_dword(pdev, 0x5C, &conf);
0049 conf &= 0x78FFE088;
0050 if (adev->dma_mode >= XFER_UDMA_0) {
0051 int udma = adev->dma_mode - XFER_UDMA_0;
0052 conf |= 0x80000000;
0053 conf |= (udma + 2) << 28;
0054 conf |= (2 - udma) * 0x111;
0055 } else {
0056 static const u32 mwdma[4] = {
0057 0x0655, 0x0200, 0x0200, 0x0100
0058 };
0059 conf |= mwdma[adev->dma_mode - XFER_MW_DMA_0];
0060 }
0061 pci_write_config_dword(pdev, 0x5C, conf);
0062 }
0063
0064
0065 static struct scsi_host_template tosh_sht = {
0066 ATA_BMDMA_SHT(DRV_NAME),
0067 };
0068
0069 static struct ata_port_operations tosh_port_ops = {
0070 .inherits = &ata_bmdma_port_ops,
0071 .cable_detect = ata_cable_unknown,
0072 .set_piomode = tosh_set_piomode,
0073 .set_dmamode = tosh_set_dmamode
0074 };
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id)
0087 {
0088 static const struct ata_port_info info = {
0089 .flags = ATA_FLAG_SLAVE_POSS,
0090 .pio_mask = ATA_PIO5,
0091 .mwdma_mask = ATA_MWDMA2,
0092 .udma_mask = ATA_UDMA2,
0093 .port_ops = &tosh_port_ops
0094 };
0095 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
0096
0097 return ata_pci_bmdma_init_one(dev, ppi, &tosh_sht, NULL, 0);
0098 }
0099
0100 static struct pci_device_id ata_tosh[] = {
0101 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
0102 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
0103 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), },
0104 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), },
0105 { 0, },
0106 };
0107
0108 static struct pci_driver ata_tosh_pci_driver = {
0109 .name = DRV_NAME,
0110 .id_table = ata_tosh,
0111 .probe = ata_tosh_init_one,
0112 .remove = ata_pci_remove_one,
0113 #ifdef CONFIG_PM_SLEEP
0114 .suspend = ata_pci_device_suspend,
0115 .resume = ata_pci_device_resume,
0116 #endif
0117 };
0118
0119 module_pci_driver(ata_tosh_pci_driver);
0120
0121 MODULE_AUTHOR("Alan Cox");
0122 MODULE_DESCRIPTION("Low level driver for Toshiba Piccolo ATA");
0123 MODULE_LICENSE("GPL");
0124 MODULE_DEVICE_TABLE(pci, ata_tosh);
0125 MODULE_VERSION(DRV_VERSION);