diff options
Diffstat (limited to 'drivers/ide/pci/sis5513.c')
-rw-r--r-- | drivers/ide/pci/sis5513.c | 253 |
1 files changed, 128 insertions, 125 deletions
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 512bb4c1fd5c..4b0b85d8faf5 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -59,10 +59,10 @@ | |||
59 | #define ATA_16 0x01 | 59 | #define ATA_16 0x01 |
60 | #define ATA_33 0x02 | 60 | #define ATA_33 0x02 |
61 | #define ATA_66 0x03 | 61 | #define ATA_66 0x03 |
62 | #define ATA_100a 0x04 // SiS730/SiS550 is ATA100 with ATA66 layout | 62 | #define ATA_100a 0x04 /* SiS730/SiS550 is ATA100 with ATA66 layout */ |
63 | #define ATA_100 0x05 | 63 | #define ATA_100 0x05 |
64 | #define ATA_133a 0x06 // SiS961b with 133 support | 64 | #define ATA_133a 0x06 /* SiS961b with 133 support */ |
65 | #define ATA_133 0x07 // SiS962/963 | 65 | #define ATA_133 0x07 /* SiS962/963 */ |
66 | 66 | ||
67 | static u8 chipset_family; | 67 | static u8 chipset_family; |
68 | 68 | ||
@@ -111,69 +111,70 @@ static const struct { | |||
111 | Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ | 111 | Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ |
112 | 112 | ||
113 | /* {0, ATA_16, ATA_33, ATA_66, ATA_100a, ATA_100, ATA_133} */ | 113 | /* {0, ATA_16, ATA_33, ATA_66, ATA_100a, ATA_100, ATA_133} */ |
114 | static u8 cycle_time_offset[] = {0,0,5,4,4,0,0}; | 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}; | 115 | static u8 cycle_time_range[] = { 0, 0, 2, 3, 3, 4, 4 }; |
116 | static u8 cycle_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { | 116 | static u8 cycle_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
117 | {0,0,0,0,0,0,0}, /* no udma */ | 117 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
118 | {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 */ | 119 | { 3, 2, 1, 0, 0, 0, 0 }, /* ATA_33 */ |
120 | {7,5,3,2,1,0,0}, /* ATA_66 */ | 120 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_66 */ |
121 | {7,5,3,2,1,0,0}, /* ATA_100a (730 specific), differences are on cycle_time range and offset */ | 121 | { 7, 5, 3, 2, 1, 0, 0 }, /* ATA_100a (730 specific), |
122 | {11,7,5,4,2,1,0}, /* ATA_100 */ | 122 | different cycle_time range and offset */ |
123 | {15,10,7,5,3,2,1}, /* ATA_133a (earliest 691 southbridges) */ | 123 | { 11, 7, 5, 4, 2, 1, 0 }, /* ATA_100 */ |
124 | {15,10,7,5,3,2,1}, /* ATA_133 */ | 124 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133a (earliest 691 southbridges) */ |
125 | { 15, 10, 7, 5, 3, 2, 1 }, /* ATA_133 */ | ||
125 | }; | 126 | }; |
126 | /* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 | 127 | /* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 |
127 | See SiS962 data sheet for more detail */ | 128 | See SiS962 data sheet for more detail */ |
128 | static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { | 129 | static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { |
129 | {0,0,0,0,0,0,0}, /* no udma */ | 130 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
130 | {0,0,0,0,0,0,0}, /* no udma */ | 131 | { 0, 0, 0, 0, 0, 0, 0 }, /* no UDMA */ |
131 | {2,1,1,0,0,0,0}, | 132 | { 2, 1, 1, 0, 0, 0, 0 }, |
132 | {4,3,2,1,0,0,0}, | 133 | { 4, 3, 2, 1, 0, 0, 0 }, |
133 | {4,3,2,1,0,0,0}, | 134 | { 4, 3, 2, 1, 0, 0, 0 }, |
134 | {6,4,3,1,1,1,0}, | 135 | { 6, 4, 3, 1, 1, 1, 0 }, |
135 | {9,6,4,2,2,2,2}, | 136 | { 9, 6, 4, 2, 2, 2, 2 }, |
136 | {9,6,4,2,2,2,2}, | 137 | { 9, 6, 4, 2, 2, 2, 2 }, |
137 | }; | 138 | }; |
138 | /* Initialize time, Active time, Recovery time vary across | 139 | /* Initialize time, Active time, Recovery time vary across |
139 | IDE clock settings. These 3 arrays hold the register value | 140 | IDE clock settings. These 3 arrays hold the register value |
140 | for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ | 141 | for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ |
141 | static u8 ini_time_value[][8] = { | 142 | static u8 ini_time_value[][8] = { |
142 | {0,0,0,0,0,0,0,0}, | 143 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
143 | {0,0,0,0,0,0,0,0}, | 144 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
144 | {2,1,0,0,0,1,0,0}, | 145 | { 2, 1, 0, 0, 0, 1, 0, 0 }, |
145 | {4,3,1,1,1,3,1,1}, | 146 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
146 | {4,3,1,1,1,3,1,1}, | 147 | { 4, 3, 1, 1, 1, 3, 1, 1 }, |
147 | {6,4,2,2,2,4,2,2}, | 148 | { 6, 4, 2, 2, 2, 4, 2, 2 }, |
148 | {9,6,3,3,3,6,3,3}, | 149 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
149 | {9,6,3,3,3,6,3,3}, | 150 | { 9, 6, 3, 3, 3, 6, 3, 3 }, |
150 | }; | 151 | }; |
151 | static u8 act_time_value[][8] = { | 152 | static u8 act_time_value[][8] = { |
152 | {0,0,0,0,0,0,0,0}, | 153 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
153 | {0,0,0,0,0,0,0,0}, | 154 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
154 | {9,9,9,2,2,7,2,2}, | 155 | { 9, 9, 9, 2, 2, 7, 2, 2 }, |
155 | {19,19,19,5,4,14,5,4}, | 156 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
156 | {19,19,19,5,4,14,5,4}, | 157 | { 19, 19, 19, 5, 4, 14, 5, 4 }, |
157 | {28,28,28,7,6,21,7,6}, | 158 | { 28, 28, 28, 7, 6, 21, 7, 6 }, |
158 | {38,38,38,10,9,28,10,9}, | 159 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
159 | {38,38,38,10,9,28,10,9}, | 160 | { 38, 38, 38, 10, 9, 28, 10, 9 }, |
160 | }; | 161 | }; |
161 | static u8 rco_time_value[][8] = { | 162 | static u8 rco_time_value[][8] = { |
162 | {0,0,0,0,0,0,0,0}, | 163 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
163 | {0,0,0,0,0,0,0,0}, | 164 | { 0, 0, 0, 0, 0, 0, 0, 0 }, |
164 | {9,2,0,2,0,7,1,1}, | 165 | { 9, 2, 0, 2, 0, 7, 1, 1 }, |
165 | {19,5,1,5,2,16,3,2}, | 166 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
166 | {19,5,1,5,2,16,3,2}, | 167 | { 19, 5, 1, 5, 2, 16, 3, 2 }, |
167 | {30,9,3,9,4,25,6,4}, | 168 | { 30, 9, 3, 9, 4, 25, 6, 4 }, |
168 | {40,12,4,12,5,34,12,5}, | 169 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
169 | {40,12,4,12,5,34,12,5}, | 170 | { 40, 12, 4, 12, 5, 34, 12, 5 }, |
170 | }; | 171 | }; |
171 | 172 | ||
172 | /* | 173 | /* |
173 | * Printing configuration | 174 | * Printing configuration |
174 | */ | 175 | */ |
175 | /* Used for chipset type printing at boot time */ | 176 | /* Used for chipset type printing at boot time */ |
176 | static char* chipset_capability[] = { | 177 | static char *chipset_capability[] = { |
177 | "ATA", "ATA 16", | 178 | "ATA", "ATA 16", |
178 | "ATA 33", "ATA 66", | 179 | "ATA 33", "ATA 66", |
179 | "ATA 100 (1st gen)", "ATA 100 (2nd gen)", | 180 | "ATA 100 (1st gen)", "ATA 100 (2nd gen)", |
@@ -272,7 +273,7 @@ static void sis_program_timings(ide_drive_t *drive, const u8 mode) | |||
272 | sis_ata133_program_timings(drive, mode); | 273 | sis_ata133_program_timings(drive, mode); |
273 | } | 274 | } |
274 | 275 | ||
275 | static void config_drive_art_rwp (ide_drive_t *drive) | 276 | static void config_drive_art_rwp(ide_drive_t *drive) |
276 | { | 277 | { |
277 | ide_hwif_t *hwif = HWIF(drive); | 278 | ide_hwif_t *hwif = HWIF(drive); |
278 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 279 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -346,7 +347,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
346 | sis_program_timings(drive, speed); | 347 | sis_program_timings(drive, speed); |
347 | } | 348 | } |
348 | 349 | ||
349 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | 350 | static u8 sis_ata133_udma_filter(ide_drive_t *drive) |
350 | { | 351 | { |
351 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 352 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
352 | u32 regdw = 0; | 353 | u32 regdw = 0; |
@@ -358,8 +359,7 @@ static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | |||
358 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; | 359 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; |
359 | } | 360 | } |
360 | 361 | ||
361 | /* Chip detection and general config */ | 362 | static int __devinit sis_find_family(struct pci_dev *dev) |
362 | static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name) | ||
363 | { | 363 | { |
364 | struct pci_dev *host; | 364 | struct pci_dev *host; |
365 | int i = 0; | 365 | int i = 0; |
@@ -381,7 +381,7 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c | |||
381 | chipset_family = ATA_100a; | 381 | chipset_family = ATA_100a; |
382 | } | 382 | } |
383 | pci_dev_put(host); | 383 | pci_dev_put(host); |
384 | 384 | ||
385 | printk(KERN_INFO "SIS5513: %s %s controller\n", | 385 | printk(KERN_INFO "SIS5513: %s %s controller\n", |
386 | SiSHostChipInfo[i].name, chipset_capability[chipset_family]); | 386 | SiSHostChipInfo[i].name, chipset_capability[chipset_family]); |
387 | } | 387 | } |
@@ -440,63 +440,60 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c | |||
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | if (!chipset_family) | 443 | return chipset_family; |
444 | return -1; | 444 | } |
445 | 445 | ||
446 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev, | ||
447 | const char *name) | ||
448 | { | ||
446 | /* Make general config ops here | 449 | /* Make general config ops here |
447 | 1/ tell IDE channels to operate in Compatibility mode only | 450 | 1/ tell IDE channels to operate in Compatibility mode only |
448 | 2/ tell old chips to allow per drive IDE timings */ | 451 | 2/ tell old chips to allow per drive IDE timings */ |
449 | 452 | ||
450 | { | 453 | u8 reg; |
451 | u8 reg; | 454 | u16 regw; |
452 | u16 regw; | 455 | |
453 | 456 | switch (chipset_family) { | |
454 | switch(chipset_family) { | 457 | case ATA_133: |
455 | case ATA_133: | 458 | /* SiS962 operation mode */ |
456 | /* SiS962 operation mode */ | 459 | pci_read_config_word(dev, 0x50, ®w); |
457 | pci_read_config_word(dev, 0x50, ®w); | 460 | if (regw & 0x08) |
458 | if (regw & 0x08) | 461 | pci_write_config_word(dev, 0x50, regw&0xfff7); |
459 | pci_write_config_word(dev, 0x50, regw&0xfff7); | 462 | pci_read_config_word(dev, 0x52, ®w); |
460 | pci_read_config_word(dev, 0x52, ®w); | 463 | if (regw & 0x08) |
461 | if (regw & 0x08) | 464 | pci_write_config_word(dev, 0x52, regw&0xfff7); |
462 | pci_write_config_word(dev, 0x52, regw&0xfff7); | 465 | break; |
463 | break; | 466 | case ATA_133a: |
464 | case ATA_133a: | 467 | case ATA_100: |
465 | case ATA_100: | 468 | /* Fixup latency */ |
466 | /* Fixup latency */ | 469 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x80); |
467 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x80); | 470 | /* Set compatibility bit */ |
468 | /* Set compatibility bit */ | 471 | pci_read_config_byte(dev, 0x49, ®); |
469 | pci_read_config_byte(dev, 0x49, ®); | 472 | if (!(reg & 0x01)) |
470 | if (!(reg & 0x01)) { | 473 | pci_write_config_byte(dev, 0x49, reg|0x01); |
471 | pci_write_config_byte(dev, 0x49, reg|0x01); | 474 | break; |
472 | } | 475 | case ATA_100a: |
473 | break; | 476 | case ATA_66: |
474 | case ATA_100a: | 477 | /* Fixup latency */ |
475 | case ATA_66: | 478 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x10); |
476 | /* Fixup latency */ | 479 | |
477 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x10); | 480 | /* On ATA_66 chips the bit was elsewhere */ |
478 | 481 | pci_read_config_byte(dev, 0x52, ®); | |
479 | /* On ATA_66 chips the bit was elsewhere */ | 482 | if (!(reg & 0x04)) |
480 | pci_read_config_byte(dev, 0x52, ®); | 483 | pci_write_config_byte(dev, 0x52, reg|0x04); |
481 | if (!(reg & 0x04)) { | 484 | break; |
482 | pci_write_config_byte(dev, 0x52, reg|0x04); | 485 | case ATA_33: |
483 | } | 486 | /* On ATA_33 we didn't have a single bit to set */ |
484 | break; | 487 | pci_read_config_byte(dev, 0x09, ®); |
485 | case ATA_33: | 488 | if ((reg & 0x0f) != 0x00) |
486 | /* On ATA_33 we didn't have a single bit to set */ | 489 | pci_write_config_byte(dev, 0x09, reg&0xf0); |
487 | pci_read_config_byte(dev, 0x09, ®); | 490 | case ATA_16: |
488 | if ((reg & 0x0f) != 0x00) { | 491 | /* force per drive recovery and active timings |
489 | pci_write_config_byte(dev, 0x09, reg&0xf0); | 492 | needed on ATA_33 and below chips */ |
490 | } | 493 | pci_read_config_byte(dev, 0x52, ®); |
491 | case ATA_16: | 494 | if (!(reg & 0x08)) |
492 | /* force per drive recovery and active timings | 495 | pci_write_config_byte(dev, 0x52, reg|0x08); |
493 | needed on ATA_33 and below chips */ | 496 | break; |
494 | pci_read_config_byte(dev, 0x52, ®); | ||
495 | if (!(reg & 0x08)) { | ||
496 | pci_write_config_byte(dev, 0x52, reg|0x08); | ||
497 | } | ||
498 | break; | ||
499 | } | ||
500 | } | 497 | } |
501 | 498 | ||
502 | return 0; | 499 | return 0; |
@@ -517,7 +514,7 @@ static const struct sis_laptop sis_laptop[] = { | |||
517 | { 0, } | 514 | { 0, } |
518 | }; | 515 | }; |
519 | 516 | ||
520 | static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | 517 | static u8 __devinit sis_cable_detect(ide_hwif_t *hwif) |
521 | { | 518 | { |
522 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 519 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
523 | const struct sis_laptop *lap = &sis_laptop[0]; | 520 | const struct sis_laptop *lap = &sis_laptop[0]; |
@@ -546,38 +543,44 @@ static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | |||
546 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 543 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
547 | } | 544 | } |
548 | 545 | ||
549 | static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | 546 | static const struct ide_port_ops sis_port_ops = { |
550 | { | 547 | .set_pio_mode = sis_set_pio_mode, |
551 | u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; | 548 | .set_dma_mode = sis_set_dma_mode, |
552 | 549 | .cable_detect = sis_cable_detect, | |
553 | hwif->set_pio_mode = &sis_set_pio_mode; | 550 | }; |
554 | hwif->set_dma_mode = &sis_set_dma_mode; | ||
555 | |||
556 | if (chipset_family >= ATA_133) | ||
557 | hwif->udma_filter = sis5513_ata133_udma_filter; | ||
558 | |||
559 | hwif->cable_detect = ata66_sis5513; | ||
560 | |||
561 | if (hwif->dma_base == 0) | ||
562 | return; | ||
563 | 551 | ||
564 | hwif->ultra_mask = udma_rates[chipset_family]; | 552 | static const struct ide_port_ops sis_ata133_port_ops = { |
565 | } | 553 | .set_pio_mode = sis_set_pio_mode, |
554 | .set_dma_mode = sis_set_dma_mode, | ||
555 | .udma_filter = sis_ata133_udma_filter, | ||
556 | .cable_detect = sis_cable_detect, | ||
557 | }; | ||
566 | 558 | ||
567 | static const struct ide_port_info sis5513_chipset __devinitdata = { | 559 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
568 | .name = "SIS5513", | 560 | .name = "SIS5513", |
569 | .init_chipset = init_chipset_sis5513, | 561 | .init_chipset = init_chipset_sis5513, |
570 | .init_hwif = init_hwif_sis5513, | 562 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
571 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 563 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, |
572 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA | | ||
573 | IDE_HFLAG_BOOTABLE, | ||
574 | .pio_mask = ATA_PIO4, | 564 | .pio_mask = ATA_PIO4, |
575 | .mwdma_mask = ATA_MWDMA2, | 565 | .mwdma_mask = ATA_MWDMA2, |
576 | }; | 566 | }; |
577 | 567 | ||
578 | static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 568 | static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
579 | { | 569 | { |
580 | return ide_setup_pci_device(dev, &sis5513_chipset); | 570 | struct ide_port_info d = sis5513_chipset; |
571 | u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; | ||
572 | |||
573 | if (sis_find_family(dev) == 0) | ||
574 | return -ENOTSUPP; | ||
575 | |||
576 | if (chipset_family >= ATA_133) | ||
577 | d.port_ops = &sis_ata133_port_ops; | ||
578 | else | ||
579 | d.port_ops = &sis_port_ops; | ||
580 | |||
581 | d.udma_mask = udma_rates[chipset_family]; | ||
582 | |||
583 | return ide_setup_pci_device(dev, &d); | ||
581 | } | 584 | } |
582 | 585 | ||
583 | static const struct pci_device_id sis5513_pci_tbl[] = { | 586 | static const struct pci_device_id sis5513_pci_tbl[] = { |