Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 1 | /* |
| 2 | * pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer |
| 3 | * (C) 2005 Red Hat Inc |
| 4 | * Alan Cox <alan@redhat.com> |
| 5 | * |
| 6 | * Based in part on linux/drivers/ide/pci/pdc202xx_old.c |
| 7 | * |
| 8 | * First cut with LBA48/ATAPI |
| 9 | * |
| 10 | * TODO: |
| 11 | * Channel interlock/reset on both required ? |
| 12 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 13 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 14 | #include <linux/kernel.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/pci.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/blkdev.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <scsi/scsi_host.h> |
| 21 | #include <linux/libata.h> |
| 22 | |
| 23 | #define DRV_NAME "pata_pdc202xx_old" |
Jeff Garzik | cb48cab | 2007-02-26 06:04:24 -0500 | [diff] [blame] | 24 | #define DRV_VERSION "0.3.0" |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * pdc2024x_pre_reset - probe begin |
| 28 | * @ap: ATA port |
| 29 | * |
| 30 | * Set up cable type and use generic probe init |
| 31 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 32 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 33 | static int pdc2024x_pre_reset(struct ata_port *ap) |
| 34 | { |
| 35 | ap->cbl = ATA_CBL_PATA40; |
| 36 | return ata_std_prereset(ap); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | static void pdc2024x_error_handler(struct ata_port *ap) |
| 41 | { |
| 42 | ata_bmdma_drive_eh(ap, pdc2024x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | static int pdc2026x_pre_reset(struct ata_port *ap) |
| 47 | { |
| 48 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
| 49 | u16 cis; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 50 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 51 | pci_read_config_word(pdev, 0x50, &cis); |
| 52 | if (cis & (1 << (10 + ap->port_no))) |
| 53 | ap->cbl = ATA_CBL_PATA80; |
| 54 | else |
| 55 | ap->cbl = ATA_CBL_PATA40; |
| 56 | |
| 57 | return ata_std_prereset(ap); |
| 58 | } |
| 59 | |
| 60 | static void pdc2026x_error_handler(struct ata_port *ap) |
| 61 | { |
| 62 | ata_bmdma_drive_eh(ap, pdc2026x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); |
| 63 | } |
| 64 | |
| 65 | /** |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 66 | * pdc202xx_configure_piomode - set chip PIO timing |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 67 | * @ap: ATA interface |
| 68 | * @adev: ATA device |
| 69 | * @pio: PIO mode |
| 70 | * |
| 71 | * Called to do the PIO mode setup. Our timing registers are shared |
| 72 | * so a configure_dmamode call will undo any work we do here and vice |
| 73 | * versa |
| 74 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 75 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 76 | static void pdc202xx_configure_piomode(struct ata_port *ap, struct ata_device *adev, int pio) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 77 | { |
| 78 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
| 79 | int port = 0x60 + 4 * ap->port_no + 2 * adev->devno; |
| 80 | static u16 pio_timing[5] = { |
| 81 | 0x0913, 0x050C , 0x0308, 0x0206, 0x0104 |
| 82 | }; |
| 83 | u8 r_ap, r_bp; |
| 84 | |
| 85 | pci_read_config_byte(pdev, port, &r_ap); |
| 86 | pci_read_config_byte(pdev, port + 1, &r_bp); |
| 87 | r_ap &= ~0x3F; /* Preserve ERRDY_EN, SYNC_IN */ |
| 88 | r_bp &= ~0x07; |
| 89 | r_ap |= (pio_timing[pio] >> 8); |
| 90 | r_bp |= (pio_timing[pio] & 0xFF); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 91 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 92 | if (ata_pio_need_iordy(adev)) |
| 93 | r_ap |= 0x20; /* IORDY enable */ |
| 94 | if (adev->class == ATA_DEV_ATA) |
| 95 | r_ap |= 0x10; /* FIFO enable */ |
| 96 | pci_write_config_byte(pdev, port, r_ap); |
| 97 | pci_write_config_byte(pdev, port + 1, r_bp); |
| 98 | } |
| 99 | |
| 100 | /** |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 101 | * pdc202xx_set_piomode - set initial PIO mode data |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 102 | * @ap: ATA interface |
| 103 | * @adev: ATA device |
| 104 | * |
| 105 | * Called to do the PIO mode setup. Our timing registers are shared |
| 106 | * but we want to set the PIO timing by default. |
| 107 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 108 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 109 | static void pdc202xx_set_piomode(struct ata_port *ap, struct ata_device *adev) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 110 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 111 | pdc202xx_configure_piomode(ap, adev, adev->pio_mode - XFER_PIO_0); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /** |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 115 | * pdc202xx_configure_dmamode - set DMA mode in chip |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 116 | * @ap: ATA interface |
| 117 | * @adev: ATA device |
| 118 | * |
| 119 | * Load DMA cycle times into the chip ready for a DMA transfer |
| 120 | * to occur. |
| 121 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 122 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 123 | static void pdc202xx_set_dmamode(struct ata_port *ap, struct ata_device *adev) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 124 | { |
| 125 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
| 126 | int port = 0x60 + 4 * ap->port_no + 2 * adev->devno; |
| 127 | static u8 udma_timing[6][2] = { |
| 128 | { 0x60, 0x03 }, /* 33 Mhz Clock */ |
| 129 | { 0x40, 0x02 }, |
| 130 | { 0x20, 0x01 }, |
| 131 | { 0x40, 0x02 }, /* 66 Mhz Clock */ |
| 132 | { 0x20, 0x01 }, |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 133 | { 0x20, 0x01 } |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 134 | }; |
| 135 | u8 r_bp, r_cp; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 136 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 137 | pci_read_config_byte(pdev, port + 1, &r_bp); |
| 138 | pci_read_config_byte(pdev, port + 2, &r_cp); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 139 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 140 | r_bp &= ~0xF0; |
| 141 | r_cp &= ~0x0F; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 142 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 143 | if (adev->dma_mode >= XFER_UDMA_0) { |
| 144 | int speed = adev->dma_mode - XFER_UDMA_0; |
| 145 | r_bp |= udma_timing[speed][0]; |
| 146 | r_cp |= udma_timing[speed][1]; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 147 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 148 | } else { |
| 149 | int speed = adev->dma_mode - XFER_MW_DMA_0; |
| 150 | r_bp |= 0x60; |
| 151 | r_cp |= (5 - speed); |
| 152 | } |
| 153 | pci_write_config_byte(pdev, port + 1, r_bp); |
| 154 | pci_write_config_byte(pdev, port + 2, r_cp); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 155 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
| 159 | * pdc2026x_bmdma_start - DMA engine begin |
| 160 | * @qc: ATA command |
| 161 | * |
| 162 | * In UDMA3 or higher we have to clock switch for the duration of the |
| 163 | * DMA transfer sequence. |
| 164 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 165 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 166 | static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc) |
| 167 | { |
| 168 | struct ata_port *ap = qc->ap; |
| 169 | struct ata_device *adev = qc->dev; |
| 170 | struct ata_taskfile *tf = &qc->tf; |
| 171 | int sel66 = ap->port_no ? 0x08: 0x02; |
| 172 | |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 173 | void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr; |
| 174 | void __iomem *clock = master + 0x11; |
| 175 | void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 176 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 177 | u32 len; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 178 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 179 | /* Check we keep host level locking here */ |
| 180 | if (adev->dma_mode >= XFER_UDMA_2) |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 181 | iowrite8(ioread8(clock) | sel66, clock); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 182 | else |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 183 | iowrite8(ioread8(clock) & ~sel66, clock); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 184 | |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 185 | /* The DMA clocks may have been trashed by a reset. FIXME: make conditional |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 186 | and move to qc_issue ? */ |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 187 | pdc202xx_set_dmamode(ap, qc->dev); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 188 | |
| 189 | /* Cases the state machine will not complete correctly without help */ |
| 190 | if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA) |
| 191 | { |
Tejun Heo | 726f078 | 2007-01-03 17:30:39 +0900 | [diff] [blame] | 192 | len = qc->nbytes; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 193 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 194 | if (tf->flags & ATA_TFLAG_WRITE) |
| 195 | len |= 0x06000000; |
| 196 | else |
| 197 | len |= 0x05000000; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 198 | |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 199 | iowrite32(len, atapi_reg); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 200 | } |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 201 | |
| 202 | /* Activate DMA */ |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 203 | ata_bmdma_start(qc); |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * pdc2026x_bmdma_end - DMA engine stop |
| 208 | * @qc: ATA command |
| 209 | * |
| 210 | * After a DMA completes we need to put the clock back to 33MHz for |
| 211 | * PIO timings. |
| 212 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 213 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 214 | static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc) |
| 215 | { |
| 216 | struct ata_port *ap = qc->ap; |
| 217 | struct ata_device *adev = qc->dev; |
| 218 | struct ata_taskfile *tf = &qc->tf; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 219 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 220 | int sel66 = ap->port_no ? 0x08: 0x02; |
| 221 | /* The clock bits are in the same register for both channels */ |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 222 | void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr; |
| 223 | void __iomem *clock = master + 0x11; |
| 224 | void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 225 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 226 | /* Cases the state machine will not complete correctly */ |
| 227 | if (tf->protocol == ATA_PROT_ATAPI_DMA || ( tf->flags & ATA_TFLAG_LBA48)) { |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 228 | iowrite32(0, atapi_reg); |
| 229 | iowrite8(ioread8(clock) & ~sel66, clock); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 230 | } |
| 231 | /* Check we keep host level locking here */ |
| 232 | /* Flip back to 33Mhz for PIO */ |
| 233 | if (adev->dma_mode >= XFER_UDMA_2) |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 234 | iowrite8(ioread8(clock) & ~sel66, clock); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 235 | |
| 236 | ata_bmdma_stop(qc); |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * pdc2026x_dev_config - device setup hook |
| 241 | * @ap: ATA port |
| 242 | * @adev: newly found device |
| 243 | * |
| 244 | * Perform chip specific early setup. We need to lock the transfer |
| 245 | * sizes to 8bit to avoid making the state engine on the 2026x cards |
| 246 | * barf. |
| 247 | */ |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 248 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 249 | static void pdc2026x_dev_config(struct ata_port *ap, struct ata_device *adev) |
| 250 | { |
| 251 | adev->max_sectors = 256; |
| 252 | } |
| 253 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 254 | static struct scsi_host_template pdc202xx_sht = { |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 255 | .module = THIS_MODULE, |
| 256 | .name = DRV_NAME, |
| 257 | .ioctl = ata_scsi_ioctl, |
| 258 | .queuecommand = ata_scsi_queuecmd, |
| 259 | .can_queue = ATA_DEF_QUEUE, |
| 260 | .this_id = ATA_SHT_THIS_ID, |
| 261 | .sg_tablesize = LIBATA_MAX_PRD, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 262 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
| 263 | .emulated = ATA_SHT_EMULATED, |
| 264 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
| 265 | .proc_name = DRV_NAME, |
| 266 | .dma_boundary = ATA_DMA_BOUNDARY, |
| 267 | .slave_configure = ata_scsi_slave_config, |
Tejun Heo | afdfe89 | 2006-11-29 11:26:47 +0900 | [diff] [blame] | 268 | .slave_destroy = ata_scsi_slave_destroy, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 269 | .bios_param = ata_std_bios_param, |
Alan | 62d64ae | 2006-11-27 16:27:20 +0000 | [diff] [blame] | 270 | .resume = ata_scsi_device_resume, |
| 271 | .suspend = ata_scsi_device_suspend, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | static struct ata_port_operations pdc2024x_port_ops = { |
| 275 | .port_disable = ata_port_disable, |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 276 | .set_piomode = pdc202xx_set_piomode, |
| 277 | .set_dmamode = pdc202xx_set_dmamode, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 278 | .mode_filter = ata_pci_default_filter, |
| 279 | .tf_load = ata_tf_load, |
| 280 | .tf_read = ata_tf_read, |
| 281 | .check_status = ata_check_status, |
| 282 | .exec_command = ata_exec_command, |
| 283 | .dev_select = ata_std_dev_select, |
| 284 | |
| 285 | .freeze = ata_bmdma_freeze, |
| 286 | .thaw = ata_bmdma_thaw, |
| 287 | .error_handler = pdc2024x_error_handler, |
| 288 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
| 289 | |
| 290 | .bmdma_setup = ata_bmdma_setup, |
| 291 | .bmdma_start = ata_bmdma_start, |
| 292 | .bmdma_stop = ata_bmdma_stop, |
| 293 | .bmdma_status = ata_bmdma_status, |
| 294 | |
| 295 | .qc_prep = ata_qc_prep, |
| 296 | .qc_issue = ata_qc_issue_prot, |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 297 | .data_xfer = ata_data_xfer, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 298 | |
| 299 | .irq_handler = ata_interrupt, |
| 300 | .irq_clear = ata_bmdma_irq_clear, |
Akira Iguchi | 246ce3b | 2007-01-26 16:27:58 +0900 | [diff] [blame] | 301 | .irq_on = ata_irq_on, |
| 302 | .irq_ack = ata_irq_ack, |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 303 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 304 | .port_start = ata_port_start, |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 305 | }; |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 306 | |
| 307 | static struct ata_port_operations pdc2026x_port_ops = { |
| 308 | .port_disable = ata_port_disable, |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 309 | .set_piomode = pdc202xx_set_piomode, |
| 310 | .set_dmamode = pdc202xx_set_dmamode, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 311 | .mode_filter = ata_pci_default_filter, |
| 312 | .tf_load = ata_tf_load, |
| 313 | .tf_read = ata_tf_read, |
| 314 | .check_status = ata_check_status, |
| 315 | .exec_command = ata_exec_command, |
| 316 | .dev_select = ata_std_dev_select, |
| 317 | .dev_config = pdc2026x_dev_config, |
| 318 | |
| 319 | .freeze = ata_bmdma_freeze, |
| 320 | .thaw = ata_bmdma_thaw, |
| 321 | .error_handler = pdc2026x_error_handler, |
| 322 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
| 323 | |
| 324 | .bmdma_setup = ata_bmdma_setup, |
| 325 | .bmdma_start = pdc2026x_bmdma_start, |
| 326 | .bmdma_stop = pdc2026x_bmdma_stop, |
| 327 | .bmdma_status = ata_bmdma_status, |
| 328 | |
| 329 | .qc_prep = ata_qc_prep, |
| 330 | .qc_issue = ata_qc_issue_prot, |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 331 | .data_xfer = ata_data_xfer, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 332 | |
| 333 | .irq_handler = ata_interrupt, |
| 334 | .irq_clear = ata_bmdma_irq_clear, |
Akira Iguchi | 246ce3b | 2007-01-26 16:27:58 +0900 | [diff] [blame] | 335 | .irq_on = ata_irq_on, |
| 336 | .irq_ack = ata_irq_ack, |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 337 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 338 | .port_start = ata_port_start, |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 339 | }; |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 340 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 341 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 342 | { |
| 343 | static struct ata_port_info info[3] = { |
| 344 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 345 | .sht = &pdc202xx_sht, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 346 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
| 347 | .pio_mask = 0x1f, |
| 348 | .mwdma_mask = 0x07, |
| 349 | .udma_mask = ATA_UDMA2, |
| 350 | .port_ops = &pdc2024x_port_ops |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 351 | }, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 352 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 353 | .sht = &pdc202xx_sht, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 354 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
| 355 | .pio_mask = 0x1f, |
| 356 | .mwdma_mask = 0x07, |
| 357 | .udma_mask = ATA_UDMA4, |
| 358 | .port_ops = &pdc2026x_port_ops |
| 359 | }, |
| 360 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 361 | .sht = &pdc202xx_sht, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 362 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
| 363 | .pio_mask = 0x1f, |
| 364 | .mwdma_mask = 0x07, |
| 365 | .udma_mask = ATA_UDMA5, |
| 366 | .port_ops = &pdc2026x_port_ops |
| 367 | } |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 368 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 369 | }; |
| 370 | static struct ata_port_info *port_info[2]; |
| 371 | |
| 372 | port_info[0] = port_info[1] = &info[id->driver_data]; |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 373 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 374 | if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { |
| 375 | struct pci_dev *bridge = dev->bus->self; |
| 376 | /* Don't grab anything behind a Promise I2O RAID */ |
| 377 | if (bridge && bridge->vendor == PCI_VENDOR_ID_INTEL) { |
| 378 | if( bridge->device == PCI_DEVICE_ID_INTEL_I960) |
| 379 | return -ENODEV; |
| 380 | if( bridge->device == PCI_DEVICE_ID_INTEL_I960RM) |
| 381 | return -ENODEV; |
| 382 | } |
| 383 | } |
| 384 | return ata_pci_init_one(dev, port_info, 2); |
| 385 | } |
| 386 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 387 | static const struct pci_device_id pdc202xx[] = { |
Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 388 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 }, |
| 389 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 }, |
| 390 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 1 }, |
| 391 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 2 }, |
| 392 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 2 }, |
| 393 | |
| 394 | { }, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 395 | }; |
| 396 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 397 | static struct pci_driver pdc202xx_pci_driver = { |
Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 398 | .name = DRV_NAME, |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 399 | .id_table = pdc202xx, |
| 400 | .probe = pdc202xx_init_one, |
Alan | 62d64ae | 2006-11-27 16:27:20 +0000 | [diff] [blame] | 401 | .remove = ata_pci_remove_one, |
| 402 | .suspend = ata_pci_device_suspend, |
| 403 | .resume = ata_pci_device_resume, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 404 | }; |
| 405 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 406 | static int __init pdc202xx_init(void) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 407 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 408 | return pci_register_driver(&pdc202xx_pci_driver); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 409 | } |
| 410 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 411 | static void __exit pdc202xx_exit(void) |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 412 | { |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 413 | pci_unregister_driver(&pdc202xx_pci_driver); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 414 | } |
| 415 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 416 | MODULE_AUTHOR("Alan Cox"); |
| 417 | MODULE_DESCRIPTION("low-level driver for Promise 2024x and 20262-20267"); |
| 418 | MODULE_LICENSE("GPL"); |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 419 | MODULE_DEVICE_TABLE(pci, pdc202xx); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 420 | MODULE_VERSION(DRV_VERSION); |
| 421 | |
Alan Cox | ada406c | 2006-11-03 13:18:06 +0000 | [diff] [blame] | 422 | module_init(pdc202xx_init); |
| 423 | module_exit(pdc202xx_exit); |