diff options
Diffstat (limited to 'drivers/ide/pci/amd74xx.c')
-rw-r--r-- | drivers/ide/pci/amd74xx.c | 155 |
1 files changed, 72 insertions, 83 deletions
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index ef7d971031ee..2cea7bf51a0f 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
23 | 23 | ||
24 | #define DRV_NAME "amd74xx" | ||
25 | |||
24 | enum { | 26 | enum { |
25 | AMD_IDE_CONFIG = 0x41, | 27 | AMD_IDE_CONFIG = 0x41, |
26 | AMD_CABLE_DETECT = 0x42, | 28 | AMD_CABLE_DETECT = 0x42, |
@@ -110,15 +112,13 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
110 | amd_set_drive(drive, XFER_PIO_0 + pio); | 112 | amd_set_drive(drive, XFER_PIO_0 + pio); |
111 | } | 113 | } |
112 | 114 | ||
113 | static void __devinit amd7409_cable_detect(struct pci_dev *dev, | 115 | static void __devinit amd7409_cable_detect(struct pci_dev *dev) |
114 | const char *name) | ||
115 | { | 116 | { |
116 | /* no host side cable detection */ | 117 | /* no host side cable detection */ |
117 | amd_80w = 0x03; | 118 | amd_80w = 0x03; |
118 | } | 119 | } |
119 | 120 | ||
120 | static void __devinit amd7411_cable_detect(struct pci_dev *dev, | 121 | static void __devinit amd7411_cable_detect(struct pci_dev *dev) |
121 | const char *name) | ||
122 | { | 122 | { |
123 | int i; | 123 | int i; |
124 | u32 u = 0; | 124 | u32 u = 0; |
@@ -129,9 +129,9 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev, | |||
129 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); | 129 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); |
130 | for (i = 24; i >= 0; i -= 8) | 130 | for (i = 24; i >= 0; i -= 8) |
131 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { | 131 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { |
132 | printk(KERN_WARNING "%s: BIOS didn't set cable bits " | 132 | printk(KERN_WARNING DRV_NAME " %s: BIOS didn't set " |
133 | "correctly. Enabling workaround.\n", | 133 | "cable bits correctly. Enabling workaround.\n", |
134 | name); | 134 | pci_name(dev)); |
135 | amd_80w |= (1 << (1 - (i >> 4))); | 135 | amd_80w |= (1 << (1 - (i >> 4))); |
136 | } | 136 | } |
137 | } | 137 | } |
@@ -140,8 +140,7 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev, | |||
140 | * The initialization callback. Initialize drive independent registers. | 140 | * The initialization callback. Initialize drive independent registers. |
141 | */ | 141 | */ |
142 | 142 | ||
143 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | 143 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev) |
144 | const char *name) | ||
145 | { | 144 | { |
146 | u8 t = 0, offset = amd_offset(dev); | 145 | u8 t = 0, offset = amd_offset(dev); |
147 | 146 | ||
@@ -154,9 +153,9 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
154 | ; /* no UDMA > 2 */ | 153 | ; /* no UDMA > 2 */ |
155 | else if (dev->vendor == PCI_VENDOR_ID_AMD && | 154 | else if (dev->vendor == PCI_VENDOR_ID_AMD && |
156 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) | 155 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) |
157 | amd7409_cable_detect(dev, name); | 156 | amd7409_cable_detect(dev); |
158 | else | 157 | else |
159 | amd7411_cable_detect(dev, name); | 158 | amd7411_cable_detect(dev); |
160 | 159 | ||
161 | /* | 160 | /* |
162 | * Take care of prefetch & postwrite. | 161 | * Take care of prefetch & postwrite. |
@@ -173,24 +172,6 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
173 | t |= 0xf0; | 172 | t |= 0xf0; |
174 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); | 173 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); |
175 | 174 | ||
176 | /* | ||
177 | * Determine the system bus clock. | ||
178 | */ | ||
179 | |||
180 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
181 | |||
182 | switch (amd_clock) { | ||
183 | case 33000: amd_clock = 33333; break; | ||
184 | case 37000: amd_clock = 37500; break; | ||
185 | case 41000: amd_clock = 41666; break; | ||
186 | } | ||
187 | |||
188 | if (amd_clock < 20000 || amd_clock > 50000) { | ||
189 | printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", | ||
190 | name, amd_clock); | ||
191 | amd_clock = 33333; | ||
192 | } | ||
193 | |||
194 | return dev->irq; | 175 | return dev->irq; |
195 | } | 176 | } |
196 | 177 | ||
@@ -222,9 +203,9 @@ static const struct ide_port_ops amd_port_ops = { | |||
222 | IDE_HFLAG_IO_32BIT | \ | 203 | IDE_HFLAG_IO_32BIT | \ |
223 | IDE_HFLAG_UNMASK_IRQS) | 204 | IDE_HFLAG_UNMASK_IRQS) |
224 | 205 | ||
225 | #define DECLARE_AMD_DEV(name_str, swdma, udma) \ | 206 | #define DECLARE_AMD_DEV(swdma, udma) \ |
226 | { \ | 207 | { \ |
227 | .name = name_str, \ | 208 | .name = DRV_NAME, \ |
228 | .init_chipset = init_chipset_amd74xx, \ | 209 | .init_chipset = init_chipset_amd74xx, \ |
229 | .init_hwif = init_hwif_amd74xx, \ | 210 | .init_hwif = init_hwif_amd74xx, \ |
230 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 211 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
@@ -236,9 +217,9 @@ static const struct ide_port_ops amd_port_ops = { | |||
236 | .udma_mask = udma, \ | 217 | .udma_mask = udma, \ |
237 | } | 218 | } |
238 | 219 | ||
239 | #define DECLARE_NV_DEV(name_str, udma) \ | 220 | #define DECLARE_NV_DEV(udma) \ |
240 | { \ | 221 | { \ |
241 | .name = name_str, \ | 222 | .name = DRV_NAME, \ |
242 | .init_chipset = init_chipset_amd74xx, \ | 223 | .init_chipset = init_chipset_amd74xx, \ |
243 | .init_hwif = init_hwif_amd74xx, \ | 224 | .init_hwif = init_hwif_amd74xx, \ |
244 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 225 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
@@ -251,31 +232,15 @@ static const struct ide_port_ops amd_port_ops = { | |||
251 | } | 232 | } |
252 | 233 | ||
253 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { | 234 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { |
254 | /* 0 */ DECLARE_AMD_DEV("AMD7401", 0x00, ATA_UDMA2), | 235 | /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2), |
255 | /* 1 */ DECLARE_AMD_DEV("AMD7409", ATA_SWDMA2, ATA_UDMA4), | 236 | /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4), |
256 | /* 2 */ DECLARE_AMD_DEV("AMD7411", ATA_SWDMA2, ATA_UDMA5), | 237 | /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5), |
257 | /* 3 */ DECLARE_AMD_DEV("AMD7441", ATA_SWDMA2, ATA_UDMA5), | 238 | /* 3: AMD8111 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA6), |
258 | /* 4 */ DECLARE_AMD_DEV("AMD8111", ATA_SWDMA2, ATA_UDMA6), | 239 | |
259 | 240 | /* 4: NFORCE */ DECLARE_NV_DEV(ATA_UDMA5), | |
260 | /* 5 */ DECLARE_NV_DEV("NFORCE", ATA_UDMA5), | 241 | /* 5: >= NFORCE2 */ DECLARE_NV_DEV(ATA_UDMA6), |
261 | /* 6 */ DECLARE_NV_DEV("NFORCE2", ATA_UDMA6), | 242 | |
262 | /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R", ATA_UDMA6), | 243 | /* 6: AMD5536 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5), |
263 | /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA", ATA_UDMA6), | ||
264 | /* 9 */ DECLARE_NV_DEV("NFORCE3-150", ATA_UDMA6), | ||
265 | /* 10 */ DECLARE_NV_DEV("NFORCE3-250", ATA_UDMA6), | ||
266 | /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA", ATA_UDMA6), | ||
267 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2", ATA_UDMA6), | ||
268 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804", ATA_UDMA6), | ||
269 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04", ATA_UDMA6), | ||
270 | /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51", ATA_UDMA6), | ||
271 | /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55", ATA_UDMA6), | ||
272 | /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61", ATA_UDMA6), | ||
273 | /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65", ATA_UDMA6), | ||
274 | /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67", ATA_UDMA6), | ||
275 | /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73", ATA_UDMA6), | ||
276 | /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77", ATA_UDMA6), | ||
277 | |||
278 | /* 22 */ DECLARE_AMD_DEV("AMD5536", ATA_SWDMA2, ATA_UDMA5), | ||
279 | }; | 244 | }; |
280 | 245 | ||
281 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) | 246 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) |
@@ -292,47 +257,64 @@ static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_ | |||
292 | if (dev->revision <= 7) | 257 | if (dev->revision <= 7) |
293 | d.swdma_mask = 0; | 258 | d.swdma_mask = 0; |
294 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | 259 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; |
295 | } else if (idx == 4) { | 260 | } else if (idx == 3) { |
296 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && | 261 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && |
297 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) | 262 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) |
298 | d.udma_mask = ATA_UDMA5; | 263 | d.udma_mask = ATA_UDMA5; |
299 | } | 264 | } |
300 | 265 | ||
301 | printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", | 266 | printk(KERN_INFO "%s %s: UDMA%s controller\n", |
302 | d.name, pci_name(dev), dev->revision, | 267 | d.name, pci_name(dev), amd_dma[fls(d.udma_mask) - 1]); |
303 | amd_dma[fls(d.udma_mask) - 1]); | 268 | |
269 | /* | ||
270 | * Determine the system bus clock. | ||
271 | */ | ||
272 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
273 | |||
274 | switch (amd_clock) { | ||
275 | case 33000: amd_clock = 33333; break; | ||
276 | case 37000: amd_clock = 37500; break; | ||
277 | case 41000: amd_clock = 41666; break; | ||
278 | } | ||
279 | |||
280 | if (amd_clock < 20000 || amd_clock > 50000) { | ||
281 | printk(KERN_WARNING "%s: User given PCI clock speed impossible" | ||
282 | " (%d), using 33 MHz instead.\n", | ||
283 | d.name, amd_clock); | ||
284 | amd_clock = 33333; | ||
285 | } | ||
304 | 286 | ||
305 | return ide_setup_pci_device(dev, &d); | 287 | return ide_pci_init_one(dev, &d, NULL); |
306 | } | 288 | } |
307 | 289 | ||
308 | static const struct pci_device_id amd74xx_pci_tbl[] = { | 290 | static const struct pci_device_id amd74xx_pci_tbl[] = { |
309 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, | 291 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, |
310 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, | 292 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, |
311 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 }, | 293 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 }, |
312 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 3 }, | 294 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 2 }, |
313 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 4 }, | 295 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 3 }, |
314 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 5 }, | 296 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 4 }, |
315 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 6 }, | 297 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 5 }, |
316 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 7 }, | 298 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 5 }, |
317 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 299 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
318 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 8 }, | 300 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 5 }, |
319 | #endif | 301 | #endif |
320 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 9 }, | 302 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 5 }, |
321 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 10 }, | 303 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 5 }, |
322 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 304 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
323 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 11 }, | 305 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 5 }, |
324 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 12 }, | 306 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 5 }, |
325 | #endif | 307 | #endif |
326 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 13 }, | 308 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 5 }, |
327 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 14 }, | 309 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 5 }, |
328 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 15 }, | 310 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 5 }, |
329 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 16 }, | 311 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 5 }, |
330 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 17 }, | 312 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 5 }, |
331 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 18 }, | 313 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 5 }, |
332 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 19 }, | 314 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 5 }, |
333 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 20 }, | 315 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 5 }, |
334 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 21 }, | 316 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 5 }, |
335 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 22 }, | 317 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 6 }, |
336 | { 0, }, | 318 | { 0, }, |
337 | }; | 319 | }; |
338 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); | 320 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); |
@@ -341,6 +323,7 @@ static struct pci_driver driver = { | |||
341 | .name = "AMD_IDE", | 323 | .name = "AMD_IDE", |
342 | .id_table = amd74xx_pci_tbl, | 324 | .id_table = amd74xx_pci_tbl, |
343 | .probe = amd74xx_probe, | 325 | .probe = amd74xx_probe, |
326 | .remove = ide_pci_remove, | ||
344 | }; | 327 | }; |
345 | 328 | ||
346 | static int __init amd74xx_ide_init(void) | 329 | static int __init amd74xx_ide_init(void) |
@@ -348,7 +331,13 @@ static int __init amd74xx_ide_init(void) | |||
348 | return ide_pci_register_driver(&driver); | 331 | return ide_pci_register_driver(&driver); |
349 | } | 332 | } |
350 | 333 | ||
334 | static void __exit amd74xx_ide_exit(void) | ||
335 | { | ||
336 | pci_unregister_driver(&driver); | ||
337 | } | ||
338 | |||
351 | module_init(amd74xx_ide_init); | 339 | module_init(amd74xx_ide_init); |
340 | module_exit(amd74xx_ide_exit); | ||
352 | 341 | ||
353 | MODULE_AUTHOR("Vojtech Pavlik"); | 342 | MODULE_AUTHOR("Vojtech Pavlik"); |
354 | MODULE_DESCRIPTION("AMD PCI IDE driver"); | 343 | MODULE_DESCRIPTION("AMD PCI IDE driver"); |