Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer |
| 3 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator |
| 4 | * |
| 5 | * CYPRESS CY82C693 chipset IDE controller |
| 6 | * |
| 7 | * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. |
| 8 | * Writing the driver was quite simple, since most of the job is |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 9 | * done by the generic pci-ide support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * The hard part was finding the CY82C693's datasheet on Cypress's |
| 11 | * web page :-(. But Altavista solved this problem :-). |
| 12 | * |
| 13 | * |
| 14 | * Notes: |
| 15 | * - I recently got a 16.8G IBM DTTA, so I was able to test it with |
| 16 | * a large and fast disk - the results look great, so I'd say the |
| 17 | * driver is working fine :-) |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 18 | * hdparm -t reports 8.17 MB/sec at about 6% CPU usage for the DTTA |
| 19 | * - this is my first linux driver, so there's probably a lot of room |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | * for optimizations and bug fixing, so feel free to do it. |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 21 | * - if using PIO mode it's a good idea to set the PIO mode and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * 32-bit I/O support (if possible), e.g. hdparm -p2 -c1 /dev/hda |
| 23 | * - I had some problems with my IBM DHEA with PIO modes < 2 |
| 24 | * (lost interrupts) ????? |
| 25 | * - first tests with DMA look okay, they seem to work, but there is a |
| 26 | * problem with sound - the BusMaster IDE TimeOut should fixed this |
| 27 | * |
| 28 | * Ancient History: |
| 29 | * AMH@1999-08-24: v0.34 init_cy82c693_chip moved to pci_init_cy82c693 |
| 30 | * ASK@1999-01-23: v0.33 made a few minor code clean ups |
| 31 | * removed DMA clock speed setting by default |
| 32 | * added boot message |
| 33 | * ASK@1998-11-01: v0.32 added support to set BusMaster IDE TimeOut |
| 34 | * added support to set DMA Controller Clock Speed |
| 35 | * ASK@1998-10-31: v0.31 fixed problem with setting to high DMA modes |
| 36 | * on some drives. |
| 37 | * ASK@1998-10-29: v0.3 added support to set DMA modes |
| 38 | * ASK@1998-10-28: v0.2 added support to set PIO modes |
| 39 | * ASK@1998-10-27: v0.1 first version - chipset detection |
| 40 | * |
| 41 | */ |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/module.h> |
| 44 | #include <linux/types.h> |
| 45 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <linux/ide.h> |
| 47 | #include <linux/init.h> |
| 48 | |
| 49 | #include <asm/io.h> |
| 50 | |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 51 | #define DRV_NAME "cy82c693" |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | * NOTE: the value for busmaster timeout is tricky and I got it by |
| 55 | * trial and error! By using a to low value will cause DMA timeouts |
| 56 | * and drop IDE performance, and by using a to high value will cause |
| 57 | * audio playback to scatter. |
| 58 | * If you know a better value or how to calc it, please let me know. |
| 59 | */ |
| 60 | |
| 61 | /* twice the value written in cy82c693ub datasheet */ |
| 62 | #define BUSMASTER_TIMEOUT 0x50 |
| 63 | /* |
| 64 | * the value above was tested on my machine and it seems to work okay |
| 65 | */ |
| 66 | |
| 67 | /* here are the offset definitions for the registers */ |
| 68 | #define CY82_IDE_CMDREG 0x04 |
| 69 | #define CY82_IDE_ADDRSETUP 0x48 |
| 70 | #define CY82_IDE_MASTER_IOR 0x4C |
| 71 | #define CY82_IDE_MASTER_IOW 0x4D |
| 72 | #define CY82_IDE_SLAVE_IOR 0x4E |
| 73 | #define CY82_IDE_SLAVE_IOW 0x4F |
| 74 | #define CY82_IDE_MASTER_8BIT 0x50 |
| 75 | #define CY82_IDE_SLAVE_8BIT 0x51 |
| 76 | |
| 77 | #define CY82_INDEX_PORT 0x22 |
| 78 | #define CY82_DATA_PORT 0x23 |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define CY82_INDEX_CHANNEL0 0x30 |
| 81 | #define CY82_INDEX_CHANNEL1 0x31 |
| 82 | #define CY82_INDEX_TIMEOUT 0x32 |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* the min and max PCI bus speed in MHz - from datasheet */ |
| 85 | #define CY82C963_MIN_BUS_SPEED 25 |
| 86 | #define CY82C963_MAX_BUS_SPEED 33 |
| 87 | |
| 88 | /* the struct for the PIO mode timings */ |
| 89 | typedef struct pio_clocks_s { |
| 90 | u8 address_time; /* Address setup (clocks) */ |
| 91 | u8 time_16r; /* clocks for 16bit IOR (0xF0=Active/data, 0x0F=Recovery) */ |
| 92 | u8 time_16w; /* clocks for 16bit IOW (0xF0=Active/data, 0x0F=Recovery) */ |
| 93 | u8 time_8; /* clocks for 8bit (0xF0=Active/data, 0x0F=Recovery) */ |
| 94 | } pio_clocks_t; |
| 95 | |
| 96 | /* |
| 97 | * calc clocks using bus_speed |
| 98 | * returns (rounded up) time in bus clocks for time in ns |
| 99 | */ |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 100 | static int calc_clk(int time, int bus_speed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | int clocks; |
| 103 | |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 104 | clocks = (time*bus_speed+999)/1000 - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | if (clocks < 0) |
| 107 | clocks = 0; |
| 108 | |
| 109 | if (clocks > 0x0F) |
| 110 | clocks = 0x0F; |
| 111 | |
| 112 | return clocks; |
| 113 | } |
| 114 | |
| 115 | /* |
| 116 | * compute the values for the clock registers for PIO |
| 117 | * mode and pci_clk [MHz] speed |
| 118 | * |
| 119 | * NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used |
| 120 | * for mode 3 and 4 drives 8 and 16-bit timings are the same |
| 121 | * |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 122 | */ |
| 123 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
Bartlomiej Zolnierkiewicz | 713a590 | 2008-07-16 20:33:38 +0200 | [diff] [blame] | 125 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | int clk1, clk2; |
Bartlomiej Zolnierkiewicz | 30e5ee4 | 2008-07-15 21:21:46 +0200 | [diff] [blame] | 127 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | /* we don't check against CY82C693's min and max speed, |
| 130 | * so you can play with the idebus=xx parameter |
| 131 | */ |
| 132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* let's calc the address setup time clocks */ |
Bartlomiej Zolnierkiewicz | 713a590 | 2008-07-16 20:33:38 +0200 | [diff] [blame] | 134 | p_pclk->address_time = (u8)calc_clk(t->setup, bus_speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | /* let's calc the active and recovery time clocks */ |
Bartlomiej Zolnierkiewicz | 713a590 | 2008-07-16 20:33:38 +0200 | [diff] [blame] | 137 | clk1 = calc_clk(t->active, bus_speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* calc recovery timing */ |
Bartlomiej Zolnierkiewicz | 713a590 | 2008-07-16 20:33:38 +0200 | [diff] [blame] | 140 | clk2 = t->cycle - t->active - t->setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
| 142 | clk2 = calc_clk(clk2, bus_speed); |
| 143 | |
| 144 | clk1 = (clk1<<4)|clk2; /* combine active and recovery clocks */ |
| 145 | |
| 146 | /* note: we use the same values for 16bit IOR and IOW |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 147 | * those are all the same, since I don't have other |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | * timings than those from ide-lib.c |
| 149 | */ |
| 150 | |
| 151 | p_pclk->time_16r = (u8)clk1; |
| 152 | p_pclk->time_16w = (u8)clk1; |
| 153 | |
| 154 | /* what are good values for 8bit ?? */ |
| 155 | p_pclk->time_8 = (u8)clk1; |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | * set DMA mode a specific channel for CY82C693 |
| 160 | */ |
| 161 | |
Bartlomiej Zolnierkiewicz | 8704de8 | 2008-01-26 20:13:00 +0100 | [diff] [blame] | 162 | static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | { |
Bartlomiej Zolnierkiewicz | 8704de8 | 2008-01-26 20:13:00 +0100 | [diff] [blame] | 164 | ide_hwif_t *hwif = drive->hwif; |
| 165 | u8 single = (mode & 0x10) >> 4, index = 0, data = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
Bartlomiej Zolnierkiewicz | 8704de8 | 2008-01-26 20:13:00 +0100 | [diff] [blame] | 167 | index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Bartlomiej Zolnierkiewicz | 8704de8 | 2008-01-26 20:13:00 +0100 | [diff] [blame] | 169 | data = (mode & 3) | (single << 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Bartlomiej Zolnierkiewicz | 0ecdca2 | 2007-02-17 02:40:25 +0100 | [diff] [blame] | 171 | outb(index, CY82_INDEX_PORT); |
| 172 | outb(data, CY82_DATA_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 174 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | * note: below we set the value for Bus Master IDE TimeOut Register |
| 176 | * I'm not absolutly sure what this does, but it solved my problem |
| 177 | * with IDE DMA and sound, so I now can play sound and work with |
| 178 | * my IDE driver at the same time :-) |
| 179 | * |
| 180 | * If you know the correct (best) value for this register please |
| 181 | * let me know - ASK |
| 182 | */ |
| 183 | |
| 184 | data = BUSMASTER_TIMEOUT; |
Bartlomiej Zolnierkiewicz | 0ecdca2 | 2007-02-17 02:40:25 +0100 | [diff] [blame] | 185 | outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT); |
| 186 | outb(data, CY82_DATA_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Bartlomiej Zolnierkiewicz | 26bcb87 | 2007-10-11 23:54:00 +0200 | [diff] [blame] | 189 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
Bartlomiej Zolnierkiewicz | 898ec22 | 2009-01-06 17:20:52 +0100 | [diff] [blame] | 191 | ide_hwif_t *hwif = drive->hwif; |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 192 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | pio_clocks_t pclk; |
| 194 | unsigned int addrCtrl; |
| 195 | |
| 196 | /* select primary or secondary channel */ |
| 197 | if (hwif->index > 0) { /* drive is on the secondary channel */ |
Alan Cox | 652aa16 | 2006-10-03 01:14:35 -0700 | [diff] [blame] | 198 | dev = pci_get_slot(dev->bus, dev->devfn+1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | if (!dev) { |
| 200 | printk(KERN_ERR "%s: tune_drive: " |
| 201 | "Cannot find secondary interface!\n", |
| 202 | drive->name); |
| 203 | return; |
| 204 | } |
| 205 | } |
| 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | /* let's calc the values for this PIO mode */ |
| 208 | compute_clocks(pio, &pclk); |
| 209 | |
| 210 | /* now let's write the clocks registers */ |
Bartlomiej Zolnierkiewicz | 123995b | 2008-10-13 21:39:40 +0200 | [diff] [blame] | 211 | if ((drive->dn & 1) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /* |
| 213 | * set master drive |
| 214 | * address setup control register |
| 215 | * is 32 bit !!! |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 216 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | addrCtrl &= (~0xF); |
| 220 | addrCtrl |= (unsigned int)pclk.address_time; |
| 221 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); |
| 222 | |
| 223 | /* now let's set the remaining registers */ |
| 224 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, pclk.time_16r); |
| 225 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, pclk.time_16w); |
| 226 | pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, pclk.time_8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } else { |
| 228 | /* |
| 229 | * set slave drive |
| 230 | * address setup control register |
| 231 | * is 32 bit !!! |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 232 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
| 234 | |
| 235 | addrCtrl &= (~0xF0); |
| 236 | addrCtrl |= ((unsigned int)pclk.address_time<<4); |
| 237 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); |
| 238 | |
| 239 | /* now let's set the remaining registers */ |
| 240 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOR, pclk.time_16r); |
| 241 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOW, pclk.time_16w); |
| 242 | pci_write_config_byte(dev, CY82_IDE_SLAVE_8BIT, pclk.time_8); |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Adrian Bunk | e851b62 | 2005-11-09 23:07:56 +0100 | [diff] [blame] | 246 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | { |
Bartlomiej Zolnierkiewicz | f32d26a | 2007-10-26 20:31:15 +0200 | [diff] [blame] | 248 | static ide_hwif_t *primary; |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 249 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
Bartlomiej Zolnierkiewicz | f32d26a | 2007-10-26 20:31:15 +0200 | [diff] [blame] | 250 | |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 251 | if (PCI_FUNC(dev->devfn) == 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | primary = hwif; |
| 253 | else { |
| 254 | hwif->mate = primary; |
| 255 | hwif->channel = 1; |
| 256 | } |
| 257 | } |
| 258 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 259 | static const struct ide_port_ops cy82c693_port_ops = { |
| 260 | .set_pio_mode = cy82c693_set_pio_mode, |
| 261 | .set_dma_mode = cy82c693_set_dma_mode, |
| 262 | }; |
| 263 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 264 | static const struct ide_port_info cy82c693_chipset __devinitdata = { |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 265 | .name = DRV_NAME, |
Bartlomiej Zolnierkiewicz | 7b77d86 | 2007-02-17 02:40:24 +0100 | [diff] [blame] | 266 | .init_iops = init_iops_cy82c693, |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 267 | .port_ops = &cy82c693_port_ops, |
Bartlomiej Zolnierkiewicz | 951784b | 2008-04-26 17:36:38 +0200 | [diff] [blame] | 268 | .host_flags = IDE_HFLAG_SINGLE, |
Bartlomiej Zolnierkiewicz | 4099d14 | 2007-07-20 01:11:59 +0200 | [diff] [blame] | 269 | .pio_mask = ATA_PIO4, |
Bartlomiej Zolnierkiewicz | 8704de8 | 2008-01-26 20:13:00 +0100 | [diff] [blame] | 270 | .swdma_mask = ATA_SWDMA2, |
| 271 | .mwdma_mask = ATA_MWDMA2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
| 275 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | struct pci_dev *dev2; |
| 277 | int ret = -ENODEV; |
| 278 | |
| 279 | /* CY82C693 is more than only a IDE controller. |
| 280 | Function 1 is primary IDE channel, function 2 - secondary. */ |
Paolo Ciarrocchi | 175f354 | 2008-04-26 17:36:42 +0200 | [diff] [blame] | 281 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | PCI_FUNC(dev->devfn) == 1) { |
Alan Cox | 652aa16 | 2006-10-03 01:14:35 -0700 | [diff] [blame] | 283 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
Bartlomiej Zolnierkiewicz | 6cdf6eb | 2008-07-24 22:53:14 +0200 | [diff] [blame] | 284 | ret = ide_pci_init_two(dev, dev2, &cy82c693_chipset, NULL); |
Bartlomiej Zolnierkiewicz | cd68841 | 2008-07-24 22:53:21 +0200 | [diff] [blame] | 285 | if (ret) |
| 286 | pci_dev_put(dev2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
| 288 | return ret; |
| 289 | } |
| 290 | |
Bartlomiej Zolnierkiewicz | cd68841 | 2008-07-24 22:53:21 +0200 | [diff] [blame] | 291 | static void __devexit cy82c693_remove(struct pci_dev *dev) |
| 292 | { |
| 293 | struct ide_host *host = pci_get_drvdata(dev); |
| 294 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; |
| 295 | |
| 296 | ide_pci_remove(dev); |
| 297 | pci_dev_put(dev2); |
| 298 | } |
| 299 | |
Bartlomiej Zolnierkiewicz | 9cbcc5e | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 300 | static const struct pci_device_id cy82c693_pci_tbl[] = { |
| 301 | { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | { 0, }, |
| 303 | }; |
| 304 | MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl); |
| 305 | |
Bartlomiej Zolnierkiewicz | a9ab09e2 | 2008-10-13 21:39:41 +0200 | [diff] [blame] | 306 | static struct pci_driver cy82c693_pci_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | .name = "Cypress_IDE", |
| 308 | .id_table = cy82c693_pci_tbl, |
| 309 | .probe = cy82c693_init_one, |
Adrian Bunk | a69999e | 2008-08-18 21:40:03 +0200 | [diff] [blame] | 310 | .remove = __devexit_p(cy82c693_remove), |
Bartlomiej Zolnierkiewicz | feb22b7 | 2008-10-10 22:39:32 +0200 | [diff] [blame] | 311 | .suspend = ide_pci_suspend, |
| 312 | .resume = ide_pci_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | }; |
| 314 | |
Bartlomiej Zolnierkiewicz | 82ab1ee | 2007-01-27 13:46:56 +0100 | [diff] [blame] | 315 | static int __init cy82c693_ide_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
Bartlomiej Zolnierkiewicz | a9ab09e2 | 2008-10-13 21:39:41 +0200 | [diff] [blame] | 317 | return ide_pci_register_driver(&cy82c693_pci_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Bartlomiej Zolnierkiewicz | cd68841 | 2008-07-24 22:53:21 +0200 | [diff] [blame] | 320 | static void __exit cy82c693_ide_exit(void) |
| 321 | { |
Bartlomiej Zolnierkiewicz | a9ab09e2 | 2008-10-13 21:39:41 +0200 | [diff] [blame] | 322 | pci_unregister_driver(&cy82c693_pci_driver); |
Bartlomiej Zolnierkiewicz | cd68841 | 2008-07-24 22:53:21 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | module_init(cy82c693_ide_init); |
Bartlomiej Zolnierkiewicz | cd68841 | 2008-07-24 22:53:21 +0200 | [diff] [blame] | 326 | module_exit(cy82c693_ide_exit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
| 328 | MODULE_AUTHOR("Andreas Krebs, Andre Hedrick"); |
| 329 | MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); |
| 330 | MODULE_LICENSE("GPL"); |