diff options
Diffstat (limited to 'drivers/ide/pci/cmd64x.c')
-rw-r--r-- | drivers/ide/pci/cmd64x.c | 90 |
1 files changed, 27 insertions, 63 deletions
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 77f51ab6d439..61ea96b5555c 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -74,7 +74,7 @@ | |||
74 | #define UDIDETCR1 0x7B | 74 | #define UDIDETCR1 0x7B |
75 | #define DTPR1 0x7C | 75 | #define DTPR1 0x7C |
76 | 76 | ||
77 | #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) | 77 | #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS) |
78 | #include <linux/stat.h> | 78 | #include <linux/stat.h> |
79 | #include <linux/proc_fs.h> | 79 | #include <linux/proc_fs.h> |
80 | 80 | ||
@@ -165,7 +165,7 @@ static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count) | |||
165 | return p-buffer; /* => must be less than 4k! */ | 165 | return p-buffer; /* => must be less than 4k! */ |
166 | } | 166 | } |
167 | 167 | ||
168 | #endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */ | 168 | #endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */ |
169 | 169 | ||
170 | static u8 quantize_timing(int timing, int quant) | 170 | static u8 quantize_timing(int timing, int quant) |
171 | { | 171 | { |
@@ -292,55 +292,6 @@ static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio) | |||
292 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 292 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
293 | } | 293 | } |
294 | 294 | ||
295 | static u8 cmd64x_ratemask (ide_drive_t *drive) | ||
296 | { | ||
297 | struct pci_dev *dev = HWIF(drive)->pci_dev; | ||
298 | u8 mode = 0; | ||
299 | |||
300 | switch(dev->device) { | ||
301 | case PCI_DEVICE_ID_CMD_649: | ||
302 | mode = 3; | ||
303 | break; | ||
304 | case PCI_DEVICE_ID_CMD_648: | ||
305 | mode = 2; | ||
306 | break; | ||
307 | case PCI_DEVICE_ID_CMD_643: | ||
308 | return 0; | ||
309 | |||
310 | case PCI_DEVICE_ID_CMD_646: | ||
311 | { | ||
312 | unsigned int class_rev = 0; | ||
313 | pci_read_config_dword(dev, | ||
314 | PCI_CLASS_REVISION, &class_rev); | ||
315 | class_rev &= 0xff; | ||
316 | /* | ||
317 | * UltraDMA only supported on PCI646U and PCI646U2, which | ||
318 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. | ||
319 | * Actually, although the CMD tech support people won't | ||
320 | * tell me the details, the 0x03 revision cannot support | ||
321 | * UDMA correctly without hardware modifications, and even | ||
322 | * then it only works with Quantum disks due to some | ||
323 | * hold time assumptions in the 646U part which are fixed | ||
324 | * in the 646U2. | ||
325 | * | ||
326 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
327 | */ | ||
328 | switch(class_rev) { | ||
329 | case 0x07: | ||
330 | case 0x05: | ||
331 | return 1; | ||
332 | case 0x03: | ||
333 | case 0x01: | ||
334 | default: | ||
335 | return 0; | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | if (!eighty_ninty_three(drive)) | ||
340 | mode = min(mode, (u8)1); | ||
341 | return mode; | ||
342 | } | ||
343 | |||
344 | static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed) | 295 | static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed) |
345 | { | 296 | { |
346 | ide_hwif_t *hwif = HWIF(drive); | 297 | ide_hwif_t *hwif = HWIF(drive); |
@@ -348,7 +299,7 @@ static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed) | |||
348 | u8 unit = drive->dn & 0x01; | 299 | u8 unit = drive->dn & 0x01; |
349 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; | 300 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; |
350 | 301 | ||
351 | speed = ide_rate_filter(cmd64x_ratemask(drive), speed); | 302 | speed = ide_rate_filter(drive, speed); |
352 | 303 | ||
353 | if (speed >= XFER_SW_DMA_0) { | 304 | if (speed >= XFER_SW_DMA_0) { |
354 | (void) pci_read_config_byte(dev, pciU, ®U); | 305 | (void) pci_read_config_byte(dev, pciU, ®U); |
@@ -403,7 +354,7 @@ static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed) | |||
403 | 354 | ||
404 | static int config_chipset_for_dma (ide_drive_t *drive) | 355 | static int config_chipset_for_dma (ide_drive_t *drive) |
405 | { | 356 | { |
406 | u8 speed = ide_dma_speed(drive, cmd64x_ratemask(drive)); | 357 | u8 speed = ide_max_dma_mode(drive); |
407 | 358 | ||
408 | if (!speed) | 359 | if (!speed) |
409 | return 0; | 360 | return 0; |
@@ -597,7 +548,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha | |||
597 | (void) pci_write_config_byte(dev, UDIDETCR0, 0xf0); | 548 | (void) pci_write_config_byte(dev, UDIDETCR0, 0xf0); |
598 | #endif /* CONFIG_PPC */ | 549 | #endif /* CONFIG_PPC */ |
599 | 550 | ||
600 | #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) | 551 | #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS) |
601 | 552 | ||
602 | cmd_devs[n_cmd_devs++] = dev; | 553 | cmd_devs[n_cmd_devs++] = dev; |
603 | 554 | ||
@@ -605,7 +556,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha | |||
605 | cmd64x_proc = 1; | 556 | cmd64x_proc = 1; |
606 | ide_pci_create_host_proc("cmd64x", cmd64x_get_info); | 557 | ide_pci_create_host_proc("cmd64x", cmd64x_get_info); |
607 | } | 558 | } |
608 | #endif /* DISPLAY_CMD64X_TIMINGS && CONFIG_PROC_FS */ | 559 | #endif /* DISPLAY_CMD64X_TIMINGS && CONFIG_IDE_PROC_FS */ |
609 | 560 | ||
610 | return 0; | 561 | return 0; |
611 | } | 562 | } |
@@ -644,15 +595,24 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
644 | 595 | ||
645 | hwif->atapi_dma = 1; | 596 | hwif->atapi_dma = 1; |
646 | 597 | ||
647 | hwif->ultra_mask = 0x3f; | 598 | hwif->ultra_mask = hwif->cds->udma_mask; |
648 | hwif->mwdma_mask = 0x07; | 599 | |
600 | /* | ||
601 | * UltraDMA only supported on PCI646U and PCI646U2, which | ||
602 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. | ||
603 | * Actually, although the CMD tech support people won't | ||
604 | * tell me the details, the 0x03 revision cannot support | ||
605 | * UDMA correctly without hardware modifications, and even | ||
606 | * then it only works with Quantum disks due to some | ||
607 | * hold time assumptions in the 646U part which are fixed | ||
608 | * in the 646U2. | ||
609 | * | ||
610 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
611 | */ | ||
612 | if (dev->device == PCI_DEVICE_ID_CMD_646 && class_rev < 5) | ||
613 | hwif->ultra_mask = 0x00; | ||
649 | 614 | ||
650 | if (dev->device == PCI_DEVICE_ID_CMD_643) | 615 | hwif->mwdma_mask = 0x07; |
651 | hwif->ultra_mask = 0x80; | ||
652 | if (dev->device == PCI_DEVICE_ID_CMD_646) | ||
653 | hwif->ultra_mask = (class_rev > 0x04) ? 0x07 : 0x80; | ||
654 | if (dev->device == PCI_DEVICE_ID_CMD_648) | ||
655 | hwif->ultra_mask = 0x1f; | ||
656 | 616 | ||
657 | hwif->ide_dma_check = &cmd64x_config_drive_for_dma; | 617 | hwif->ide_dma_check = &cmd64x_config_drive_for_dma; |
658 | if (!(hwif->udma_four)) | 618 | if (!(hwif->udma_four)) |
@@ -716,6 +676,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
716 | .autodma = AUTODMA, | 676 | .autodma = AUTODMA, |
717 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 677 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
718 | .bootable = ON_BOARD, | 678 | .bootable = ON_BOARD, |
679 | .udma_mask = 0x00, /* no udma */ | ||
719 | },{ /* 1 */ | 680 | },{ /* 1 */ |
720 | .name = "CMD646", | 681 | .name = "CMD646", |
721 | .init_setup = init_setup_cmd646, | 682 | .init_setup = init_setup_cmd646, |
@@ -725,6 +686,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
725 | .autodma = AUTODMA, | 686 | .autodma = AUTODMA, |
726 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 687 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
727 | .bootable = ON_BOARD, | 688 | .bootable = ON_BOARD, |
689 | .udma_mask = 0x07, /* udma0-2 */ | ||
728 | },{ /* 2 */ | 690 | },{ /* 2 */ |
729 | .name = "CMD648", | 691 | .name = "CMD648", |
730 | .init_setup = init_setup_cmd64x, | 692 | .init_setup = init_setup_cmd64x, |
@@ -734,6 +696,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
734 | .autodma = AUTODMA, | 696 | .autodma = AUTODMA, |
735 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 697 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
736 | .bootable = ON_BOARD, | 698 | .bootable = ON_BOARD, |
699 | .udma_mask = 0x1f, /* udma0-4 */ | ||
737 | },{ /* 3 */ | 700 | },{ /* 3 */ |
738 | .name = "CMD649", | 701 | .name = "CMD649", |
739 | .init_setup = init_setup_cmd64x, | 702 | .init_setup = init_setup_cmd64x, |
@@ -743,6 +706,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
743 | .autodma = AUTODMA, | 706 | .autodma = AUTODMA, |
744 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 707 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
745 | .bootable = ON_BOARD, | 708 | .bootable = ON_BOARD, |
709 | .udma_mask = 0x3f, /* udma0-5 */ | ||
746 | } | 710 | } |
747 | }; | 711 | }; |
748 | 712 | ||