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) 1999-2000 Andre Hedrick <andre@linux-ide.org> |
| 3 | * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer |
| 4 | * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz> |
Bartlomiej Zolnierkiewicz | 6b8cf77 | 2007-05-16 00:51:42 +0200 | [diff] [blame] | 5 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * May be copied or modified under the terms of the GNU General Public License |
| 8 | * |
| 9 | * |
| 10 | * Thanks : |
| 11 | * |
| 12 | * SiS Taiwan : for direct support and hardware. |
| 13 | * Daniela Engert : for initial ATA100 advices and numerous others. |
| 14 | * John Fremlin, Manfred Spraul, Dave Morgan, Peter Kjellerstedt : |
| 15 | * for checking code correctness, providing patches. |
| 16 | * |
| 17 | * |
| 18 | * Original tests and design on the SiS620 chipset. |
| 19 | * ATA100 tests and design on the SiS735 chipset. |
| 20 | * ATA16/33 support from specs |
| 21 | * ATA133 support for SiS961/962 by L.C. Chang <lcchang@sis.com.tw> |
| 22 | * ATA133 961/962/963 fixes by Vojtech Pavlik <vojtech@suse.cz> |
| 23 | * |
| 24 | * Documentation: |
| 25 | * SiS chipset documentation available under NDA to companies only |
| 26 | * (not to individuals). |
| 27 | */ |
| 28 | |
| 29 | /* |
| 30 | * The original SiS5513 comes from a SiS5511/55112/5513 chipset. The original |
| 31 | * SiS5513 was also used in the SiS5596/5513 chipset. Thus if we see a SiS5511 |
| 32 | * or SiS5596, we can assume we see the first MWDMA-16 capable SiS5513 chip. |
| 33 | * |
| 34 | * Later SiS chipsets integrated the 5513 functionality into the NorthBridge, |
| 35 | * starting with SiS5571 and up to SiS745. The PCI ID didn't change, though. We |
| 36 | * can figure out that we have a more modern and more capable 5513 by looking |
| 37 | * for the respective NorthBridge IDs. |
| 38 | * |
| 39 | * Even later (96x family) SiS chipsets use the MuTIOL link and place the 5513 |
| 40 | * into the SouthBrige. Here we cannot rely on looking up the NorthBridge PCI |
| 41 | * ID, while the now ATA-133 capable 5513 still has the same PCI ID. |
| 42 | * Fortunately the 5513 can be 'unmasked' by fiddling with some config space |
| 43 | * bits, changing its device id to the true one - 5517 for 961 and 5518 for |
| 44 | * 962/963. |
| 45 | */ |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/types.h> |
| 48 | #include <linux/module.h> |
| 49 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #include <linux/hdreg.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/pci.h> |
| 52 | #include <linux/init.h> |
| 53 | #include <linux/ide.h> |
| 54 | |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 55 | #define DRV_NAME "sis5513" |
| 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | /* registers layout and init values are chipset family dependant */ |
| 58 | |
| 59 | #define ATA_16 0x01 |
| 60 | #define ATA_33 0x02 |
| 61 | #define ATA_66 0x03 |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 62 | #define ATA_100a 0x04 /* SiS730/SiS550 is ATA100 with ATA66 layout */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #define ATA_100 0x05 |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 64 | #define ATA_133a 0x06 /* SiS961b with 133 support */ |
| 65 | #define ATA_133 0x07 /* SiS962/963 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | static u8 chipset_family; |
| 68 | |
| 69 | /* |
| 70 | * Devices supported |
| 71 | */ |
| 72 | static const struct { |
| 73 | const char *name; |
| 74 | u16 host_id; |
| 75 | u8 chipset_family; |
| 76 | u8 flags; |
| 77 | } SiSHostChipInfo[] = { |
David Wang | 47d4b90 | 2006-09-08 09:47:51 -0700 | [diff] [blame] | 78 | { "SiS968", PCI_DEVICE_ID_SI_968, ATA_133 }, |
| 79 | { "SiS966", PCI_DEVICE_ID_SI_966, ATA_133 }, |
Aurelien Jarno | 14351f8 | 2005-11-19 21:43:45 +0100 | [diff] [blame] | 80 | { "SiS965", PCI_DEVICE_ID_SI_965, ATA_133 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { "SiS745", PCI_DEVICE_ID_SI_745, ATA_100 }, |
| 82 | { "SiS735", PCI_DEVICE_ID_SI_735, ATA_100 }, |
| 83 | { "SiS733", PCI_DEVICE_ID_SI_733, ATA_100 }, |
| 84 | { "SiS635", PCI_DEVICE_ID_SI_635, ATA_100 }, |
| 85 | { "SiS633", PCI_DEVICE_ID_SI_633, ATA_100 }, |
| 86 | |
| 87 | { "SiS730", PCI_DEVICE_ID_SI_730, ATA_100a }, |
| 88 | { "SiS550", PCI_DEVICE_ID_SI_550, ATA_100a }, |
| 89 | |
| 90 | { "SiS640", PCI_DEVICE_ID_SI_640, ATA_66 }, |
| 91 | { "SiS630", PCI_DEVICE_ID_SI_630, ATA_66 }, |
| 92 | { "SiS620", PCI_DEVICE_ID_SI_620, ATA_66 }, |
| 93 | { "SiS540", PCI_DEVICE_ID_SI_540, ATA_66 }, |
| 94 | { "SiS530", PCI_DEVICE_ID_SI_530, ATA_66 }, |
| 95 | |
| 96 | { "SiS5600", PCI_DEVICE_ID_SI_5600, ATA_33 }, |
| 97 | { "SiS5598", PCI_DEVICE_ID_SI_5598, ATA_33 }, |
| 98 | { "SiS5597", PCI_DEVICE_ID_SI_5597, ATA_33 }, |
| 99 | { "SiS5591/2", PCI_DEVICE_ID_SI_5591, ATA_33 }, |
| 100 | { "SiS5582", PCI_DEVICE_ID_SI_5582, ATA_33 }, |
| 101 | { "SiS5581", PCI_DEVICE_ID_SI_5581, ATA_33 }, |
| 102 | |
| 103 | { "SiS5596", PCI_DEVICE_ID_SI_5596, ATA_16 }, |
| 104 | { "SiS5571", PCI_DEVICE_ID_SI_5571, ATA_16 }, |
Alan Cox | d266ab8 | 2006-03-28 01:56:31 -0800 | [diff] [blame] | 105 | { "SiS5517", PCI_DEVICE_ID_SI_5517, ATA_16 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | { "SiS551x", PCI_DEVICE_ID_SI_5511, ATA_16 }, |
| 107 | }; |
| 108 | |
| 109 | /* Cycle time bits and values vary across chip dma capabilities |
| 110 | These three arrays hold the register layout and the values to set. |
| 111 | Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ |
| 112 | |
| 113 | /* {0, ATA_16, ATA_33, ATA_66, ATA_100a, ATA_100, ATA_133} */ |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 114 | static u8 cycle_time_offset[] = { 0, 0, 5, 4, 4, 0, 0 }; |
| 115 | static u8 cycle_time_range[] = { 0, 0, 2, 3, 3, 4, 4 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | static u8 cycle_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 117 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
| 118 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
| 119 | { 3, 2, 1, 0, 0, 0, 0 }, /* ATA_33 */ |
| 120 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_66 */ |
| 121 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_100a (730 specific), |
| 122 | different cycle_time range and offset */ |
| 123 | { 11, 7, 5, 4, 2, 1, 0 }, /* ATA_100 */ |
| 124 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133a (earliest 691 southbridges) */ |
| 125 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | }; |
| 127 | /* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 |
| 128 | See SiS962 data sheet for more detail */ |
| 129 | static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 130 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
| 131 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
| 132 | { 2, 1, 1, 0, 0, 0, 0 }, |
| 133 | { 4, 3, 2, 1, 0, 0, 0 }, |
| 134 | { 4, 3, 2, 1, 0, 0, 0 }, |
| 135 | { 6, 4, 3, 1, 1, 1, 0 }, |
| 136 | { 9, 6, 4, 2, 2, 2, 2 }, |
| 137 | { 9, 6, 4, 2, 2, 2, 2 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | }; |
| 139 | /* Initialize time, Active time, Recovery time vary across |
| 140 | IDE clock settings. These 3 arrays hold the register value |
| 141 | for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ |
| 142 | static u8 ini_time_value[][8] = { |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 143 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 144 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 145 | { 2, 1, 0, 0, 0, 1, 0, 0 }, |
| 146 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
| 147 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
| 148 | { 6, 4, 2, 2, 2, 4, 2, 2 }, |
| 149 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
| 150 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | }; |
| 152 | static u8 act_time_value[][8] = { |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 153 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 154 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 155 | { 9, 9, 9, 2, 2, 7, 2, 2 }, |
| 156 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
| 157 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
| 158 | { 28, 28, 28, 7, 6, 21, 7, 6 }, |
| 159 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
| 160 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | }; |
| 162 | static u8 rco_time_value[][8] = { |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 163 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 164 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 165 | { 9, 2, 0, 2, 0, 7, 1, 1 }, |
| 166 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
| 167 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
| 168 | { 30, 9, 3, 9, 4, 25, 6, 4 }, |
| 169 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
| 170 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | /* |
| 174 | * Printing configuration |
| 175 | */ |
| 176 | /* Used for chipset type printing at boot time */ |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 177 | static char *chipset_capability[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | "ATA", "ATA 16", |
| 179 | "ATA 33", "ATA 66", |
| 180 | "ATA 100 (1st gen)", "ATA 100 (2nd gen)", |
| 181 | "ATA 133 (1st gen)", "ATA 133 (2nd gen)" |
| 182 | }; |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /* |
| 185 | * Configuration functions |
| 186 | */ |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 187 | |
| 188 | static u8 sis_ata133_get_base(ide_drive_t *drive) |
| 189 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 190 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 191 | u32 reg54 = 0; |
| 192 | |
| 193 | pci_read_config_dword(dev, 0x54, ®54); |
| 194 | |
| 195 | return ((reg54 & 0x40000000) ? 0x70 : 0x40) + drive->dn * 4; |
| 196 | } |
| 197 | |
| 198 | static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) |
| 199 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 200 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 201 | u16 t1 = 0; |
| 202 | u8 drive_pci = 0x40 + drive->dn * 2; |
| 203 | |
| 204 | const u16 pio_timings[] = { 0x000, 0x607, 0x404, 0x303, 0x301 }; |
| 205 | const u16 mwdma_timings[] = { 0x008, 0x302, 0x301 }; |
| 206 | |
| 207 | pci_read_config_word(dev, drive_pci, &t1); |
| 208 | |
| 209 | /* clear active/recovery timings */ |
| 210 | t1 &= ~0x070f; |
| 211 | if (mode >= XFER_MW_DMA_0) { |
| 212 | if (chipset_family > ATA_16) |
| 213 | t1 &= ~0x8000; /* disable UDMA */ |
| 214 | t1 |= mwdma_timings[mode - XFER_MW_DMA_0]; |
| 215 | } else |
| 216 | t1 |= pio_timings[mode - XFER_PIO_0]; |
| 217 | |
| 218 | pci_write_config_word(dev, drive_pci, t1); |
| 219 | } |
| 220 | |
| 221 | static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) |
| 222 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 223 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 224 | u8 t1, drive_pci = 0x40 + drive->dn * 2; |
| 225 | |
| 226 | /* timing bits: 7:4 active 3:0 recovery */ |
| 227 | const u8 pio_timings[] = { 0x00, 0x67, 0x44, 0x33, 0x31 }; |
| 228 | const u8 mwdma_timings[] = { 0x08, 0x32, 0x31 }; |
| 229 | |
| 230 | if (mode >= XFER_MW_DMA_0) { |
| 231 | u8 t2 = 0; |
| 232 | |
| 233 | pci_read_config_byte(dev, drive_pci, &t2); |
| 234 | t2 &= ~0x80; /* disable UDMA */ |
| 235 | pci_write_config_byte(dev, drive_pci, t2); |
| 236 | |
| 237 | t1 = mwdma_timings[mode - XFER_MW_DMA_0]; |
| 238 | } else |
| 239 | t1 = pio_timings[mode - XFER_PIO_0]; |
| 240 | |
| 241 | pci_write_config_byte(dev, drive_pci + 1, t1); |
| 242 | } |
| 243 | |
| 244 | static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) |
| 245 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 246 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 247 | u32 t1 = 0; |
| 248 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; |
| 249 | |
| 250 | pci_read_config_dword(dev, drive_pci, &t1); |
| 251 | |
| 252 | t1 &= 0xc0c00fff; |
| 253 | clk = (t1 & 0x08) ? ATA_133 : ATA_100; |
| 254 | if (mode >= XFER_MW_DMA_0) { |
| 255 | t1 &= ~0x04; /* disable UDMA */ |
| 256 | idx = mode - XFER_MW_DMA_0 + 5; |
Adrian Bunk | 3dfd643 | 2007-10-20 00:32:29 +0200 | [diff] [blame] | 257 | } else |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 258 | idx = mode - XFER_PIO_0; |
| 259 | t1 |= ini_time_value[clk][idx] << 12; |
| 260 | t1 |= act_time_value[clk][idx] << 16; |
| 261 | t1 |= rco_time_value[clk][idx] << 24; |
| 262 | |
| 263 | pci_write_config_dword(dev, drive_pci, t1); |
| 264 | } |
| 265 | |
| 266 | static void sis_program_timings(ide_drive_t *drive, const u8 mode) |
| 267 | { |
| 268 | if (chipset_family < ATA_100) /* ATA_16/33/66/100a */ |
| 269 | sis_ata16_program_timings(drive, mode); |
| 270 | else if (chipset_family < ATA_133) /* ATA_100/133a */ |
| 271 | sis_ata100_program_timings(drive, mode); |
| 272 | else /* ATA_133 */ |
| 273 | sis_ata133_program_timings(drive, mode); |
| 274 | } |
| 275 | |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 276 | static void config_drive_art_rwp(ide_drive_t *drive) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | { |
| 278 | ide_hwif_t *hwif = HWIF(drive); |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 279 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | u8 reg4bh = 0; |
Bartlomiej Zolnierkiewicz | d83fca5 | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 281 | u8 rw_prefetch = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | pci_read_config_byte(dev, 0x4b, ®4bh); |
| 284 | |
Bartlomiej Zolnierkiewicz | d83fca5 | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 285 | if (drive->media == ide_disk) |
| 286 | rw_prefetch = 0x11 << drive->dn; |
| 287 | |
| 288 | if ((reg4bh & (0x11 << drive->dn)) != rw_prefetch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | pci_write_config_byte(dev, 0x4b, reg4bh|rw_prefetch); |
| 290 | } |
| 291 | |
Bartlomiej Zolnierkiewicz | 88b2b32 | 2007-10-13 17:47:51 +0200 | [diff] [blame] | 292 | static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | config_drive_art_rwp(drive); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 295 | sis_program_timings(drive, XFER_PIO_0 + pio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Bartlomiej Zolnierkiewicz | 428c644 | 2008-01-25 22:17:18 +0100 | [diff] [blame] | 298 | static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) |
| 299 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 300 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | 428c644 | 2008-01-25 22:17:18 +0100 | [diff] [blame] | 301 | u32 regdw = 0; |
| 302 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; |
| 303 | |
| 304 | pci_read_config_dword(dev, drive_pci, ®dw); |
| 305 | |
| 306 | regdw |= 0x04; |
| 307 | regdw &= 0xfffff00f; |
| 308 | /* check if ATA133 enable */ |
| 309 | clk = (regdw & 0x08) ? ATA_133 : ATA_100; |
| 310 | idx = mode - XFER_UDMA_0; |
| 311 | regdw |= cycle_time_value[clk][idx] << 4; |
| 312 | regdw |= cvs_time_value[clk][idx] << 8; |
| 313 | |
| 314 | pci_write_config_dword(dev, drive_pci, regdw); |
| 315 | } |
| 316 | |
| 317 | static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) |
| 318 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 319 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | 428c644 | 2008-01-25 22:17:18 +0100 | [diff] [blame] | 320 | u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; |
| 321 | |
| 322 | pci_read_config_byte(dev, drive_pci + 1, ®); |
| 323 | |
| 324 | /* force the UDMA bit on if we want to use UDMA */ |
| 325 | reg |= 0x80; |
| 326 | /* clean reg cycle time bits */ |
| 327 | reg &= ~((0xff >> (8 - cycle_time_range[i])) << cycle_time_offset[i]); |
| 328 | /* set reg cycle time bits */ |
| 329 | reg |= cycle_time_value[i][mode - XFER_UDMA_0] << cycle_time_offset[i]; |
| 330 | |
| 331 | pci_write_config_byte(dev, drive_pci + 1, reg); |
| 332 | } |
| 333 | |
| 334 | static void sis_program_udma_timings(ide_drive_t *drive, const u8 mode) |
| 335 | { |
| 336 | if (chipset_family >= ATA_133) /* ATA_133 */ |
| 337 | sis_ata133_program_udma_timings(drive, mode); |
| 338 | else /* ATA_33/66/100a/100/133a */ |
| 339 | sis_ata33_program_udma_timings(drive, mode); |
| 340 | } |
| 341 | |
Bartlomiej Zolnierkiewicz | 88b2b32 | 2007-10-13 17:47:51 +0200 | [diff] [blame] | 342 | static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | { |
Bartlomiej Zolnierkiewicz | 4db90a1 | 2008-01-25 22:17:18 +0100 | [diff] [blame] | 344 | if (speed >= XFER_UDMA_0) |
| 345 | sis_program_udma_timings(drive, speed); |
| 346 | else |
| 347 | sis_program_timings(drive, speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 350 | static u8 sis_ata133_udma_filter(ide_drive_t *drive) |
Bartlomiej Zolnierkiewicz | 3160d54 | 2007-10-11 23:53:59 +0200 | [diff] [blame] | 351 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 352 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
Bartlomiej Zolnierkiewicz | c77a89c | 2007-10-16 22:29:52 +0200 | [diff] [blame] | 353 | u32 regdw = 0; |
| 354 | u8 drive_pci = sis_ata133_get_base(drive); |
Bartlomiej Zolnierkiewicz | 3160d54 | 2007-10-11 23:53:59 +0200 | [diff] [blame] | 355 | |
Bartlomiej Zolnierkiewicz | 3160d54 | 2007-10-11 23:53:59 +0200 | [diff] [blame] | 356 | pci_read_config_dword(dev, drive_pci, ®dw); |
| 357 | |
| 358 | /* if ATA133 disable, we should not set speed above UDMA5 */ |
| 359 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; |
| 360 | } |
| 361 | |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 362 | static int __devinit sis_find_family(struct pci_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | { |
| 364 | struct pci_dev *host; |
| 365 | int i = 0; |
| 366 | |
| 367 | chipset_family = 0; |
| 368 | |
| 369 | for (i = 0; i < ARRAY_SIZE(SiSHostChipInfo) && !chipset_family; i++) { |
| 370 | |
Alan Cox | 40cddf2 | 2006-09-30 23:27:30 -0700 | [diff] [blame] | 371 | host = pci_get_device(PCI_VENDOR_ID_SI, SiSHostChipInfo[i].host_id, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
| 373 | if (!host) |
| 374 | continue; |
| 375 | |
| 376 | chipset_family = SiSHostChipInfo[i].chipset_family; |
| 377 | |
| 378 | /* Special case for SiS630 : 630S/ET is ATA_100a */ |
| 379 | if (SiSHostChipInfo[i].host_id == PCI_DEVICE_ID_SI_630) { |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 380 | if (host->revision >= 0x30) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | chipset_family = ATA_100a; |
| 382 | } |
Alan Cox | 40cddf2 | 2006-09-30 23:27:30 -0700 | [diff] [blame] | 383 | pci_dev_put(host); |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 384 | |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 385 | printk(KERN_INFO DRV_NAME " %s: %s %s controller\n", |
Bartlomiej Zolnierkiewicz | 28cfd8a | 2008-07-24 22:53:31 +0200 | [diff] [blame] | 386 | pci_name(dev), SiSHostChipInfo[i].name, |
| 387 | chipset_capability[chipset_family]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | if (!chipset_family) { /* Belongs to pci-quirks */ |
| 391 | |
| 392 | u32 idemisc; |
| 393 | u16 trueid; |
| 394 | |
| 395 | /* Disable ID masking and register remapping */ |
| 396 | pci_read_config_dword(dev, 0x54, &idemisc); |
| 397 | pci_write_config_dword(dev, 0x54, (idemisc & 0x7fffffff)); |
| 398 | pci_read_config_word(dev, PCI_DEVICE_ID, &trueid); |
| 399 | pci_write_config_dword(dev, 0x54, idemisc); |
| 400 | |
| 401 | if (trueid == 0x5518) { |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 402 | printk(KERN_INFO DRV_NAME " %s: SiS 962/963 MuTIOL IDE UDMA133 controller\n", |
Bartlomiej Zolnierkiewicz | 28cfd8a | 2008-07-24 22:53:31 +0200 | [diff] [blame] | 403 | pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | chipset_family = ATA_133; |
| 405 | |
| 406 | /* Check for 5513 compability mapping |
| 407 | * We must use this, else the port enabled code will fail, |
| 408 | * as it expects the enablebits at 0x4a. |
| 409 | */ |
| 410 | if ((idemisc & 0x40000000) == 0) { |
| 411 | pci_write_config_dword(dev, 0x54, idemisc | 0x40000000); |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 412 | printk(KERN_INFO DRV_NAME " %s: Switching to 5513 register mapping\n", |
Bartlomiej Zolnierkiewicz | 28cfd8a | 2008-07-24 22:53:31 +0200 | [diff] [blame] | 413 | pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | if (!chipset_family) { /* Belongs to pci-quirks */ |
| 419 | |
| 420 | struct pci_dev *lpc_bridge; |
| 421 | u16 trueid; |
| 422 | u8 prefctl; |
| 423 | u8 idecfg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
| 425 | pci_read_config_byte(dev, 0x4a, &idecfg); |
| 426 | pci_write_config_byte(dev, 0x4a, idecfg | 0x10); |
| 427 | pci_read_config_word(dev, PCI_DEVICE_ID, &trueid); |
| 428 | pci_write_config_byte(dev, 0x4a, idecfg); |
| 429 | |
| 430 | if (trueid == 0x5517) { /* SiS 961/961B */ |
| 431 | |
Alan Cox | b148900 | 2006-12-08 02:39:58 -0800 | [diff] [blame] | 432 | lpc_bridge = pci_get_slot(dev->bus, 0x10); /* Bus 0, Dev 2, Fn 0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | pci_read_config_byte(dev, 0x49, &prefctl); |
Alan Cox | b148900 | 2006-12-08 02:39:58 -0800 | [diff] [blame] | 434 | pci_dev_put(lpc_bridge); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 436 | if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 437 | printk(KERN_INFO DRV_NAME " %s: SiS 961B MuTIOL IDE UDMA133 controller\n", |
Bartlomiej Zolnierkiewicz | 28cfd8a | 2008-07-24 22:53:31 +0200 | [diff] [blame] | 438 | pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | chipset_family = ATA_133a; |
| 440 | } else { |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 441 | printk(KERN_INFO DRV_NAME " %s: SiS 961 MuTIOL IDE UDMA100 controller\n", |
Bartlomiej Zolnierkiewicz | 28cfd8a | 2008-07-24 22:53:31 +0200 | [diff] [blame] | 442 | pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | chipset_family = ATA_100; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 448 | return chipset_family; |
| 449 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Bartlomiej Zolnierkiewicz | a326b02 | 2008-07-24 22:53:33 +0200 | [diff] [blame] | 451 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev) |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 452 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | /* Make general config ops here |
| 454 | 1/ tell IDE channels to operate in Compatibility mode only |
| 455 | 2/ tell old chips to allow per drive IDE timings */ |
| 456 | |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 457 | u8 reg; |
| 458 | u16 regw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 460 | switch (chipset_family) { |
| 461 | case ATA_133: |
| 462 | /* SiS962 operation mode */ |
| 463 | pci_read_config_word(dev, 0x50, ®w); |
| 464 | if (regw & 0x08) |
| 465 | pci_write_config_word(dev, 0x50, regw&0xfff7); |
| 466 | pci_read_config_word(dev, 0x52, ®w); |
| 467 | if (regw & 0x08) |
| 468 | pci_write_config_word(dev, 0x52, regw&0xfff7); |
| 469 | break; |
| 470 | case ATA_133a: |
| 471 | case ATA_100: |
| 472 | /* Fixup latency */ |
| 473 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x80); |
| 474 | /* Set compatibility bit */ |
| 475 | pci_read_config_byte(dev, 0x49, ®); |
| 476 | if (!(reg & 0x01)) |
| 477 | pci_write_config_byte(dev, 0x49, reg|0x01); |
| 478 | break; |
| 479 | case ATA_100a: |
| 480 | case ATA_66: |
| 481 | /* Fixup latency */ |
| 482 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 484 | /* On ATA_66 chips the bit was elsewhere */ |
| 485 | pci_read_config_byte(dev, 0x52, ®); |
| 486 | if (!(reg & 0x04)) |
| 487 | pci_write_config_byte(dev, 0x52, reg|0x04); |
| 488 | break; |
| 489 | case ATA_33: |
| 490 | /* On ATA_33 we didn't have a single bit to set */ |
| 491 | pci_read_config_byte(dev, 0x09, ®); |
| 492 | if ((reg & 0x0f) != 0x00) |
| 493 | pci_write_config_byte(dev, 0x09, reg&0xf0); |
| 494 | case ATA_16: |
| 495 | /* force per drive recovery and active timings |
| 496 | needed on ATA_33 and below chips */ |
| 497 | pci_read_config_byte(dev, 0x52, ®); |
| 498 | if (!(reg & 0x08)) |
| 499 | pci_write_config_byte(dev, 0x52, reg|0x08); |
| 500 | break; |
| 501 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
| 503 | return 0; |
| 504 | } |
| 505 | |
Bartlomiej Zolnierkiewicz | f2befd9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 506 | struct sis_laptop { |
| 507 | u16 device; |
| 508 | u16 subvendor; |
| 509 | u16 subdevice; |
| 510 | }; |
| 511 | |
| 512 | static const struct sis_laptop sis_laptop[] = { |
| 513 | /* devid, subvendor, subdev */ |
| 514 | { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ |
David Lamparter | 1955f68 | 2007-08-01 23:46:44 +0200 | [diff] [blame] | 515 | { 0x5513, 0x1734, 0x105f }, /* FSC Amilo A1630 */ |
Gabriel Craciunescu | a1d8586 | 2007-11-27 21:35:52 +0100 | [diff] [blame] | 516 | { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */ |
Bartlomiej Zolnierkiewicz | f2befd9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 517 | /* end marker */ |
| 518 | { 0, } |
| 519 | }; |
| 520 | |
Bartlomiej Zolnierkiewicz | f454cbe | 2008-08-05 18:17:04 +0200 | [diff] [blame] | 521 | static u8 sis_cable_detect(ide_hwif_t *hwif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 523 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
Bartlomiej Zolnierkiewicz | f2befd9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 524 | const struct sis_laptop *lap = &sis_laptop[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | u8 ata66 = 0; |
| 526 | |
Bartlomiej Zolnierkiewicz | f2befd9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 527 | while (lap->device) { |
| 528 | if (lap->device == pdev->device && |
| 529 | lap->subvendor == pdev->subsystem_vendor && |
| 530 | lap->subdevice == pdev->subsystem_device) |
| 531 | return ATA_CBL_PATA40_SHORT; |
| 532 | lap++; |
| 533 | } |
| 534 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | if (chipset_family >= ATA_133) { |
| 536 | u16 regw = 0; |
| 537 | u16 reg_addr = hwif->channel ? 0x52: 0x50; |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 538 | pci_read_config_word(pdev, reg_addr, ®w); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | ata66 = (regw & 0x8000) ? 0 : 1; |
| 540 | } else if (chipset_family >= ATA_66) { |
| 541 | u8 reg48h = 0; |
| 542 | u8 mask = hwif->channel ? 0x20 : 0x10; |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 543 | pci_read_config_byte(pdev, 0x48, ®48h); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | ata66 = (reg48h & mask) ? 0 : 1; |
| 545 | } |
Bartlomiej Zolnierkiewicz | 49521f9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 546 | |
| 547 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | } |
| 549 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 550 | static const struct ide_port_ops sis_port_ops = { |
| 551 | .set_pio_mode = sis_set_pio_mode, |
| 552 | .set_dma_mode = sis_set_dma_mode, |
| 553 | .cable_detect = sis_cable_detect, |
| 554 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 556 | static const struct ide_port_ops sis_ata133_port_ops = { |
| 557 | .set_pio_mode = sis_set_pio_mode, |
| 558 | .set_dma_mode = sis_set_dma_mode, |
| 559 | .udma_filter = sis_ata133_udma_filter, |
| 560 | .cable_detect = sis_cable_detect, |
| 561 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 563 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
Bartlomiej Zolnierkiewicz | ced3ec8 | 2008-07-24 22:53:32 +0200 | [diff] [blame] | 564 | .name = DRV_NAME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | .init_chipset = init_chipset_sis5513, |
Paolo Ciarrocchi | 1eb3c2e | 2008-04-26 17:36:39 +0200 | [diff] [blame] | 566 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
Bartlomiej Zolnierkiewicz | 5e71d9c | 2008-04-26 17:36:35 +0200 | [diff] [blame] | 567 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, |
Bartlomiej Zolnierkiewicz | 4099d14 | 2007-07-20 01:11:59 +0200 | [diff] [blame] | 568 | .pio_mask = ATA_PIO4, |
Bartlomiej Zolnierkiewicz | 5f8b6c3 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 569 | .mwdma_mask = ATA_MWDMA2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | }; |
| 571 | |
| 572 | static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
| 573 | { |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 574 | struct ide_port_info d = sis5513_chipset; |
| 575 | u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; |
Bartlomiej Zolnierkiewicz | cd18f69 | 2008-06-10 20:56:36 +0200 | [diff] [blame] | 576 | int rc; |
| 577 | |
| 578 | rc = pci_enable_device(dev); |
| 579 | if (rc) |
| 580 | return rc; |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 581 | |
| 582 | if (sis_find_family(dev) == 0) |
| 583 | return -ENOTSUPP; |
| 584 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 585 | if (chipset_family >= ATA_133) |
| 586 | d.port_ops = &sis_ata133_port_ops; |
| 587 | else |
| 588 | d.port_ops = &sis_port_ops; |
| 589 | |
Bartlomiej Zolnierkiewicz | 4764b68 | 2008-04-26 17:36:43 +0200 | [diff] [blame] | 590 | d.udma_mask = udma_rates[chipset_family]; |
| 591 | |
Bartlomiej Zolnierkiewicz | 6cdf6eb | 2008-07-24 22:53:14 +0200 | [diff] [blame] | 592 | return ide_pci_init_one(dev, &d, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Bartlomiej Zolnierkiewicz | 1ceb906 | 2008-07-24 22:53:25 +0200 | [diff] [blame] | 595 | static void __devexit sis5513_remove(struct pci_dev *dev) |
| 596 | { |
| 597 | ide_pci_remove(dev); |
| 598 | pci_disable_device(dev); |
| 599 | } |
| 600 | |
Bartlomiej Zolnierkiewicz | 9cbcc5e | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 601 | static const struct pci_device_id sis5513_pci_tbl[] = { |
| 602 | { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_5513), 0 }, |
| 603 | { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_5518), 0 }, |
| 604 | { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_1180), 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | { 0, }, |
| 606 | }; |
| 607 | MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl); |
| 608 | |
| 609 | static struct pci_driver driver = { |
| 610 | .name = "SIS_IDE", |
| 611 | .id_table = sis5513_pci_tbl, |
| 612 | .probe = sis5513_init_one, |
Adrian Bunk | a69999e | 2008-08-18 21:40:03 +0200 | [diff] [blame] | 613 | .remove = __devexit_p(sis5513_remove), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | }; |
| 615 | |
Bartlomiej Zolnierkiewicz | 82ab1ee | 2007-01-27 13:46:56 +0100 | [diff] [blame] | 616 | static int __init sis5513_ide_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | { |
| 618 | return ide_pci_register_driver(&driver); |
| 619 | } |
| 620 | |
Bartlomiej Zolnierkiewicz | 1ceb906 | 2008-07-24 22:53:25 +0200 | [diff] [blame] | 621 | static void __exit sis5513_ide_exit(void) |
| 622 | { |
| 623 | pci_unregister_driver(&driver); |
| 624 | } |
| 625 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | module_init(sis5513_ide_init); |
Bartlomiej Zolnierkiewicz | 1ceb906 | 2008-07-24 22:53:25 +0200 | [diff] [blame] | 627 | module_exit(sis5513_ide_exit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
| 629 | MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); |
| 630 | MODULE_DESCRIPTION("PCI driver module for SIS IDE"); |
| 631 | MODULE_LICENSE("GPL"); |
| 632 | |
| 633 | /* |
| 634 | * TODO: |
| 635 | * - CLEANUP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | * - More checks in the config registers (force values instead of |
| 637 | * relying on the BIOS setting them correctly). |
| 638 | * - Further optimisations ? |
| 639 | * . for example ATA66+ regs 0x48 & 0x4A |
| 640 | */ |