2 * pata_sis.c - SiS ATA driver
5 * (C) 2007 Bartlomiej Zolnierkiewicz
7 * Based upon linux/drivers/ide/pci/sis5513.c
8 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org>
9 * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer
10 * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz>
11 * SiS Taiwan : for direct support and hardware.
12 * Daniela Engert : for initial ATA100 advices and numerous others.
13 * John Fremlin, Manfred Spraul, Dave Morgan, Peter Kjellerstedt :
14 * for checking code correctness, providing patches.
15 * Original tests and design on the SiS620 chipset.
16 * ATA100 tests and design on the SiS735 chipset.
17 * ATA16/33 support from specs
18 * ATA133 support for SiS961/962 by L.C. Chang <lcchang@sis.com.tw>
22 * Check MWDMA on drives that don't support MWDMA speed pio cycles ?
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/pci.h>
29 #include <linux/init.h>
30 #include <linux/blkdev.h>
31 #include <linux/delay.h>
32 #include <linux/device.h>
33 #include <scsi/scsi_host.h>
34 #include <linux/libata.h>
35 #include <linux/ata.h>
38 #define DRV_NAME "pata_sis"
39 #define DRV_VERSION "0.5.2"
42 u16 device
; /* PCI host ID */
43 const struct ata_port_info
*info
; /* Info block */
44 /* Probably add family, cable detect type etc here to clean
54 static const struct sis_laptop sis_laptop
[] = {
55 /* devid, subvendor, subdev */
56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */
58 { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */
63 static int sis_short_ata40(struct pci_dev
*dev
)
65 const struct sis_laptop
*lap
= &sis_laptop
[0];
68 if (lap
->device
== dev
->device
&&
69 lap
->subvendor
== dev
->subsystem_vendor
&&
70 lap
->subdevice
== dev
->subsystem_device
)
79 * sis_old_port_base - return PCI configuration base for dev
82 * Returns the base of the PCI configuration registers for this port
86 static int sis_old_port_base(struct ata_device
*adev
)
88 return 0x40 + (4 * adev
->link
->ap
->port_no
) + (2 * adev
->devno
);
92 * sis_133_cable_detect - check for 40/80 pin
94 * @deadline: deadline jiffies for the operation
96 * Perform cable detection for the later UDMA133 capable
100 static int sis_133_cable_detect(struct ata_port
*ap
)
102 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
105 /* The top bit of this register is the cable detect bit */
106 pci_read_config_word(pdev
, 0x50 + 2 * ap
->port_no
, &tmp
);
107 if ((tmp
& 0x8000) && !sis_short_ata40(pdev
))
108 return ATA_CBL_PATA40
;
109 return ATA_CBL_PATA80
;
113 * sis_66_cable_detect - check for 40/80 pin
116 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133
117 * SiS IDE controllers.
120 static int sis_66_cable_detect(struct ata_port
*ap
)
122 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
125 /* Older chips keep cable detect in bits 4/5 of reg 0x48 */
126 pci_read_config_byte(pdev
, 0x48, &tmp
);
128 if ((tmp
& 0x10) && !sis_short_ata40(pdev
))
129 return ATA_CBL_PATA40
;
130 return ATA_CBL_PATA80
;
135 * sis_pre_reset - probe begin
137 * @deadline: deadline jiffies for the operation
139 * Set up cable type and use generic probe init
142 static int sis_pre_reset(struct ata_link
*link
, unsigned long deadline
)
144 static const struct pci_bits sis_enable_bits
[] = {
145 { 0x4aU
, 1U, 0x02UL
, 0x02UL
}, /* port 0 */
146 { 0x4aU
, 1U, 0x04UL
, 0x04UL
}, /* port 1 */
149 struct ata_port
*ap
= link
->ap
;
150 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
152 if (!pci_test_config_bits(pdev
, &sis_enable_bits
[ap
->port_no
]))
155 /* Clear the FIFO settings. We can't enable the FIFO until
156 we know we are poking at a disk */
157 pci_write_config_byte(pdev
, 0x4B, 0);
158 return ata_sff_prereset(link
, deadline
);
163 * sis_set_fifo - Set RWP fifo bits for this device
167 * SIS chipsets implement prefetch/postwrite bits for each device
168 * on both channels. This functionality is not ATAPI compatible and
169 * must be configured according to the class of device present
172 static void sis_set_fifo(struct ata_port
*ap
, struct ata_device
*adev
)
174 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
178 mask
<<= (2 * ap
->port_no
);
179 mask
<<= adev
->devno
;
181 /* This holds various bits including the FIFO control */
182 pci_read_config_byte(pdev
, 0x4B, &fifoctrl
);
185 /* Enable for ATA (disk) only */
186 if (adev
->class == ATA_DEV_ATA
)
188 pci_write_config_byte(pdev
, 0x4B, fifoctrl
);
192 * sis_old_set_piomode - Initialize host controller PATA PIO timings
193 * @ap: Port whose timings we are configuring
194 * @adev: Device we are configuring for.
196 * Set PIO mode for device, in host controller PCI config space. This
197 * function handles PIO set up for all chips that are pre ATA100 and
198 * also early ATA100 devices.
201 * None (inherited from caller).
204 static void sis_old_set_piomode (struct ata_port
*ap
, struct ata_device
*adev
)
206 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
207 int port
= sis_old_port_base(adev
);
209 int speed
= adev
->pio_mode
- XFER_PIO_0
;
211 const u8 active
[] = { 0x00, 0x07, 0x04, 0x03, 0x01 };
212 const u8 recovery
[] = { 0x00, 0x06, 0x04, 0x03, 0x03 };
214 sis_set_fifo(ap
, adev
);
216 pci_read_config_byte(pdev
, port
, &t1
);
217 pci_read_config_byte(pdev
, port
+ 1, &t2
);
219 t1
&= ~0x0F; /* Clear active/recovery timings */
223 t2
|= recovery
[speed
];
225 pci_write_config_byte(pdev
, port
, t1
);
226 pci_write_config_byte(pdev
, port
+ 1, t2
);
230 * sis_100_set_piomode - Initialize host controller PATA PIO timings
231 * @ap: Port whose timings we are configuring
232 * @adev: Device we are configuring for.
234 * Set PIO mode for device, in host controller PCI config space. This
235 * function handles PIO set up for ATA100 devices and early ATA133.
238 * None (inherited from caller).
241 static void sis_100_set_piomode (struct ata_port
*ap
, struct ata_device
*adev
)
243 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
244 int port
= sis_old_port_base(adev
);
245 int speed
= adev
->pio_mode
- XFER_PIO_0
;
247 const u8 actrec
[] = { 0x00, 0x67, 0x44, 0x33, 0x31 };
249 sis_set_fifo(ap
, adev
);
251 pci_write_config_byte(pdev
, port
, actrec
[speed
]);
255 * sis_133_set_piomode - Initialize host controller PATA PIO timings
256 * @ap: Port whose timings we are configuring
257 * @adev: Device we are configuring for.
259 * Set PIO mode for device, in host controller PCI config space. This
260 * function handles PIO set up for the later ATA133 devices.
263 * None (inherited from caller).
266 static void sis_133_set_piomode (struct ata_port
*ap
, struct ata_device
*adev
)
268 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
272 int speed
= adev
->pio_mode
- XFER_PIO_0
;
274 const u32 timing133
[] = {
275 0x28269000, /* Recovery << 24 | Act << 16 | Ini << 12 */
281 const u32 timing100
[] = {
282 0x1E1C6000, /* Recovery << 24 | Act << 16 | Ini << 12 */
289 sis_set_fifo(ap
, adev
);
291 /* If bit 14 is set then the registers are mapped at 0x70 not 0x40 */
292 pci_read_config_dword(pdev
, 0x54, ®54
);
293 if (reg54
& 0x40000000)
295 port
+= 8 * ap
->port_no
+ 4 * adev
->devno
;
297 pci_read_config_dword(pdev
, port
, &t1
);
298 t1
&= 0xC0C00FFF; /* Mask out timing */
300 if (t1
& 0x08) /* 100 or 133 ? */
301 t1
|= timing133
[speed
];
303 t1
|= timing100
[speed
];
304 pci_write_config_byte(pdev
, port
, t1
);
308 * sis_old_set_dmamode - Initialize host controller PATA DMA timings
309 * @ap: Port whose timings we are configuring
310 * @adev: Device to program
312 * Set UDMA/MWDMA mode for device, in host controller PCI config space.
313 * Handles pre UDMA and UDMA33 devices. Supports MWDMA as well unlike
314 * the old ide/pci driver.
317 * None (inherited from caller).
320 static void sis_old_set_dmamode (struct ata_port
*ap
, struct ata_device
*adev
)
322 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
323 int speed
= adev
->dma_mode
- XFER_MW_DMA_0
;
324 int drive_pci
= sis_old_port_base(adev
);
327 const u16 mwdma_bits
[] = { 0x008, 0x302, 0x301 };
328 const u16 udma_bits
[] = { 0xE000, 0xC000, 0xA000 };
330 pci_read_config_word(pdev
, drive_pci
, &timing
);
332 if (adev
->dma_mode
< XFER_UDMA_0
) {
333 /* bits 3-0 hold recovery timing bits 8-10 active timing and
334 the higher bits are dependant on the device */
336 timing
|= mwdma_bits
[speed
];
338 /* Bit 15 is UDMA on/off, bit 13-14 are cycle time */
339 speed
= adev
->dma_mode
- XFER_UDMA_0
;
341 timing
|= udma_bits
[speed
];
343 pci_write_config_word(pdev
, drive_pci
, timing
);
347 * sis_66_set_dmamode - Initialize host controller PATA DMA timings
348 * @ap: Port whose timings we are configuring
349 * @adev: Device to program
351 * Set UDMA/MWDMA mode for device, in host controller PCI config space.
352 * Handles UDMA66 and early UDMA100 devices. Supports MWDMA as well unlike
353 * the old ide/pci driver.
356 * None (inherited from caller).
359 static void sis_66_set_dmamode (struct ata_port
*ap
, struct ata_device
*adev
)
361 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
362 int speed
= adev
->dma_mode
- XFER_MW_DMA_0
;
363 int drive_pci
= sis_old_port_base(adev
);
366 /* MWDMA 0-2 and UDMA 0-5 */
367 const u16 mwdma_bits
[] = { 0x008, 0x302, 0x301 };
368 const u16 udma_bits
[] = { 0xF000, 0xD000, 0xB000, 0xA000, 0x9000, 0x8000 };
370 pci_read_config_word(pdev
, drive_pci
, &timing
);
372 if (adev
->dma_mode
< XFER_UDMA_0
) {
373 /* bits 3-0 hold recovery timing bits 8-10 active timing and
374 the higher bits are dependant on the device, bit 15 udma */
376 timing
|= mwdma_bits
[speed
];
378 /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
379 speed
= adev
->dma_mode
- XFER_UDMA_0
;
381 timing
|= udma_bits
[speed
];
383 pci_write_config_word(pdev
, drive_pci
, timing
);
387 * sis_100_set_dmamode - Initialize host controller PATA DMA timings
388 * @ap: Port whose timings we are configuring
389 * @adev: Device to program
391 * Set UDMA/MWDMA mode for device, in host controller PCI config space.
392 * Handles UDMA66 and early UDMA100 devices.
395 * None (inherited from caller).
398 static void sis_100_set_dmamode (struct ata_port
*ap
, struct ata_device
*adev
)
400 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
401 int speed
= adev
->dma_mode
- XFER_MW_DMA_0
;
402 int drive_pci
= sis_old_port_base(adev
);
405 const u8 udma_bits
[] = { 0x8B, 0x87, 0x85, 0x83, 0x82, 0x81};
407 pci_read_config_byte(pdev
, drive_pci
+ 1, &timing
);
409 if (adev
->dma_mode
< XFER_UDMA_0
) {
410 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
412 /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
413 speed
= adev
->dma_mode
- XFER_UDMA_0
;
415 timing
|= udma_bits
[speed
];
417 pci_write_config_byte(pdev
, drive_pci
+ 1, timing
);
421 * sis_133_early_set_dmamode - Initialize host controller PATA DMA timings
422 * @ap: Port whose timings we are configuring
423 * @adev: Device to program
425 * Set UDMA/MWDMA mode for device, in host controller PCI config space.
426 * Handles early SiS 961 bridges.
429 * None (inherited from caller).
432 static void sis_133_early_set_dmamode (struct ata_port
*ap
, struct ata_device
*adev
)
434 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
435 int speed
= adev
->dma_mode
- XFER_MW_DMA_0
;
436 int drive_pci
= sis_old_port_base(adev
);
438 /* Low 4 bits are timing */
439 static const u8 udma_bits
[] = { 0x8F, 0x8A, 0x87, 0x85, 0x83, 0x82, 0x81};
441 pci_read_config_byte(pdev
, drive_pci
+ 1, &timing
);
443 if (adev
->dma_mode
< XFER_UDMA_0
) {
444 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
446 /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
447 speed
= adev
->dma_mode
- XFER_UDMA_0
;
449 timing
|= udma_bits
[speed
];
451 pci_write_config_byte(pdev
, drive_pci
+ 1, timing
);
455 * sis_133_set_dmamode - Initialize host controller PATA DMA timings
456 * @ap: Port whose timings we are configuring
457 * @adev: Device to program
459 * Set UDMA/MWDMA mode for device, in host controller PCI config space.
462 * None (inherited from caller).
465 static void sis_133_set_dmamode (struct ata_port
*ap
, struct ata_device
*adev
)
467 struct pci_dev
*pdev
= to_pci_dev(ap
->host
->dev
);
468 int speed
= adev
->dma_mode
- XFER_MW_DMA_0
;
473 /* bits 4- cycle time 8 - cvs time */
474 static const u32 timing_u100
[] = { 0x6B0, 0x470, 0x350, 0x140, 0x120, 0x110, 0x000 };
475 static const u32 timing_u133
[] = { 0x9F0, 0x6A0, 0x470, 0x250, 0x230, 0x220, 0x210 };
477 /* If bit 14 is set then the registers are mapped at 0x70 not 0x40 */
478 pci_read_config_dword(pdev
, 0x54, ®54
);
479 if (reg54
& 0x40000000)
481 port
+= (8 * ap
->port_no
) + (4 * adev
->devno
);
483 pci_read_config_dword(pdev
, port
, &t1
);
485 if (adev
->dma_mode
< XFER_UDMA_0
) {
487 /* FIXME: need data sheet to add MWDMA here. Also lacking on
490 speed
= adev
->dma_mode
- XFER_UDMA_0
;
491 /* if & 8 no UDMA133 - need info for ... */
495 t1
|= timing_u133
[speed
];
497 t1
|= timing_u100
[speed
];
499 pci_write_config_dword(pdev
, port
, t1
);
502 static struct scsi_host_template sis_sht
= {
503 ATA_BMDMA_SHT(DRV_NAME
),
506 static struct ata_port_operations sis_133_for_sata_ops
= {
507 .inherits
= &ata_bmdma_port_ops
,
508 .set_piomode
= sis_133_set_piomode
,
509 .set_dmamode
= sis_133_set_dmamode
,
510 .cable_detect
= sis_133_cable_detect
,
513 static struct ata_port_operations sis_base_ops
= {
514 .inherits
= &ata_bmdma_port_ops
,
515 .prereset
= sis_pre_reset
,
518 static struct ata_port_operations sis_133_ops
= {
519 .inherits
= &sis_base_ops
,
520 .set_piomode
= sis_133_set_piomode
,
521 .set_dmamode
= sis_133_set_dmamode
,
522 .cable_detect
= sis_133_cable_detect
,
525 static struct ata_port_operations sis_133_early_ops
= {
526 .inherits
= &sis_base_ops
,
527 .set_piomode
= sis_100_set_piomode
,
528 .set_dmamode
= sis_133_early_set_dmamode
,
529 .cable_detect
= sis_66_cable_detect
,
532 static struct ata_port_operations sis_100_ops
= {
533 .inherits
= &sis_base_ops
,
534 .set_piomode
= sis_100_set_piomode
,
535 .set_dmamode
= sis_100_set_dmamode
,
536 .cable_detect
= sis_66_cable_detect
,
539 static struct ata_port_operations sis_66_ops
= {
540 .inherits
= &sis_base_ops
,
541 .set_piomode
= sis_old_set_piomode
,
542 .set_dmamode
= sis_66_set_dmamode
,
543 .cable_detect
= sis_66_cable_detect
,
546 static struct ata_port_operations sis_old_ops
= {
547 .inherits
= &sis_base_ops
,
548 .set_piomode
= sis_old_set_piomode
,
549 .set_dmamode
= sis_old_set_dmamode
,
550 .cable_detect
= ata_cable_40wire
,
553 static const struct ata_port_info sis_info
= {
554 .flags
= ATA_FLAG_SLAVE_POSS
,
555 .pio_mask
= 0x1f, /* pio0-4 */
558 .port_ops
= &sis_old_ops
,
560 static const struct ata_port_info sis_info33
= {
561 .flags
= ATA_FLAG_SLAVE_POSS
,
562 .pio_mask
= 0x1f, /* pio0-4 */
564 .udma_mask
= ATA_UDMA2
, /* UDMA 33 */
565 .port_ops
= &sis_old_ops
,
567 static const struct ata_port_info sis_info66
= {
568 .flags
= ATA_FLAG_SLAVE_POSS
,
569 .pio_mask
= 0x1f, /* pio0-4 */
570 .udma_mask
= ATA_UDMA4
, /* UDMA 66 */
571 .port_ops
= &sis_66_ops
,
573 static const struct ata_port_info sis_info100
= {
574 .flags
= ATA_FLAG_SLAVE_POSS
,
575 .pio_mask
= 0x1f, /* pio0-4 */
576 .udma_mask
= ATA_UDMA5
,
577 .port_ops
= &sis_100_ops
,
579 static const struct ata_port_info sis_info100_early
= {
580 .flags
= ATA_FLAG_SLAVE_POSS
,
581 .udma_mask
= ATA_UDMA5
,
582 .pio_mask
= 0x1f, /* pio0-4 */
583 .port_ops
= &sis_66_ops
,
585 static const struct ata_port_info sis_info133
= {
586 .flags
= ATA_FLAG_SLAVE_POSS
,
587 .pio_mask
= 0x1f, /* pio0-4 */
588 .udma_mask
= ATA_UDMA6
,
589 .port_ops
= &sis_133_ops
,
591 const struct ata_port_info sis_info133_for_sata
= {
592 .flags
= ATA_FLAG_SLAVE_POSS
| ATA_FLAG_SRST
,
593 .pio_mask
= 0x1f, /* pio0-4 */
594 .udma_mask
= ATA_UDMA6
,
595 .port_ops
= &sis_133_for_sata_ops
,
597 static const struct ata_port_info sis_info133_early
= {
598 .flags
= ATA_FLAG_SLAVE_POSS
,
599 .pio_mask
= 0x1f, /* pio0-4 */
600 .udma_mask
= ATA_UDMA6
,
601 .port_ops
= &sis_133_early_ops
,
604 /* Privately shared with the SiS180 SATA driver, not for use elsewhere */
605 EXPORT_SYMBOL_GPL(sis_info133_for_sata
);
607 static void sis_fixup(struct pci_dev
*pdev
, struct sis_chipset
*sis
)
612 if (sis
->info
== &sis_info133
) {
613 pci_read_config_word(pdev
, 0x50, ®w
);
615 pci_write_config_word(pdev
, 0x50, regw
& ~0x08);
616 pci_read_config_word(pdev
, 0x52, ®w
);
618 pci_write_config_word(pdev
, 0x52, regw
& ~0x08);
622 if (sis
->info
== &sis_info133_early
|| sis
->info
== &sis_info100
) {
624 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, 0x80);
625 /* Set compatibility bit */
626 pci_read_config_byte(pdev
, 0x49, ®
);
628 pci_write_config_byte(pdev
, 0x49, reg
| 0x01);
632 if (sis
->info
== &sis_info66
|| sis
->info
== &sis_info100_early
) {
634 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, 0x80);
635 /* Set compatibility bit */
636 pci_read_config_byte(pdev
, 0x52, ®
);
638 pci_write_config_byte(pdev
, 0x52, reg
| 0x04);
642 if (sis
->info
== &sis_info33
) {
643 pci_read_config_byte(pdev
, PCI_CLASS_PROG
, ®
);
644 if (( reg
& 0x0F ) != 0x00)
645 pci_write_config_byte(pdev
, PCI_CLASS_PROG
, reg
& 0xF0);
646 /* Fall through to ATA16 fixup below */
649 if (sis
->info
== &sis_info
|| sis
->info
== &sis_info33
) {
650 /* force per drive recovery and active timings
651 needed on ATA_33 and below chips */
652 pci_read_config_byte(pdev
, 0x52, ®
);
654 pci_write_config_byte(pdev
, 0x52, reg
|0x08);
662 * sis_init_one - Register SiS ATA PCI device with kernel services
663 * @pdev: PCI device to register
664 * @ent: Entry in sis_pci_tbl matching with @pdev
666 * Called from kernel PCI layer. We probe for combined mode (sigh),
667 * and then hand over control to libata, for it to do the rest.
670 * Inherited from PCI layer (may sleep).
673 * Zero on success, or -ERRNO value.
676 static int sis_init_one (struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
678 static int printed_version
;
679 const struct ata_port_info
*ppi
[] = { NULL
, NULL
};
680 struct pci_dev
*host
= NULL
;
681 struct sis_chipset
*chipset
= NULL
;
682 struct sis_chipset
*sets
;
685 static struct sis_chipset sis_chipsets
[] = {
687 { 0x0968, &sis_info133
},
688 { 0x0966, &sis_info133
},
689 { 0x0965, &sis_info133
},
690 { 0x0745, &sis_info100
},
691 { 0x0735, &sis_info100
},
692 { 0x0733, &sis_info100
},
693 { 0x0635, &sis_info100
},
694 { 0x0633, &sis_info100
},
696 { 0x0730, &sis_info100_early
}, /* 100 with ATA 66 layout */
697 { 0x0550, &sis_info100_early
}, /* 100 with ATA 66 layout */
699 { 0x0640, &sis_info66
},
700 { 0x0630, &sis_info66
},
701 { 0x0620, &sis_info66
},
702 { 0x0540, &sis_info66
},
703 { 0x0530, &sis_info66
},
705 { 0x5600, &sis_info33
},
706 { 0x5598, &sis_info33
},
707 { 0x5597, &sis_info33
},
708 { 0x5591, &sis_info33
},
709 { 0x5582, &sis_info33
},
710 { 0x5581, &sis_info33
},
712 { 0x5596, &sis_info
},
713 { 0x5571, &sis_info
},
714 { 0x5517, &sis_info
},
715 { 0x5511, &sis_info
},
719 static struct sis_chipset sis133_early
= {
720 0x0, &sis_info133_early
722 static struct sis_chipset sis133
= {
725 static struct sis_chipset sis100_early
= {
726 0x0, &sis_info100_early
728 static struct sis_chipset sis100
= {
732 if (!printed_version
++)
733 dev_printk(KERN_DEBUG
, &pdev
->dev
,
734 "version " DRV_VERSION
"\n");
736 rc
= pcim_enable_device(pdev
);
740 /* We have to find the bridge first */
741 for (sets
= &sis_chipsets
[0]; sets
->device
; sets
++) {
742 host
= pci_get_device(PCI_VENDOR_ID_SI
, sets
->device
, NULL
);
744 chipset
= sets
; /* Match found */
745 if (sets
->device
== 0x630) { /* SIS630 */
746 if (host
->revision
>= 0x30) /* 630 ET */
747 chipset
= &sis100_early
;
753 /* Look for concealed bridges */
754 if (chipset
== NULL
) {
759 /* Disable ID masking and register remapping then
760 see what the real ID is */
762 pci_read_config_dword(pdev
, 0x54, &idemisc
);
763 pci_write_config_dword(pdev
, 0x54, idemisc
& 0x7fffffff);
764 pci_read_config_word(pdev
, PCI_DEVICE_ID
, &trueid
);
765 pci_write_config_dword(pdev
, 0x54, idemisc
);
768 case 0x5518: /* SIS 962/963 */
770 if ((idemisc
& 0x40000000) == 0) {
771 pci_write_config_dword(pdev
, 0x54, idemisc
| 0x40000000);
772 printk(KERN_INFO
"SIS5513: Switching to 5513 register mapping\n");
775 case 0x0180: /* SIS 965/965L */
778 case 0x1180: /* SIS 966/966L */
785 if (chipset
== NULL
) {
786 struct pci_dev
*lpc_bridge
;
791 /* Try the second unmasking technique */
792 pci_read_config_byte(pdev
, 0x4a, &idecfg
);
793 pci_write_config_byte(pdev
, 0x4a, idecfg
| 0x10);
794 pci_read_config_word(pdev
, PCI_DEVICE_ID
, &trueid
);
795 pci_write_config_byte(pdev
, 0x4a, idecfg
);
799 lpc_bridge
= pci_get_slot(pdev
->bus
, 0x10); /* Bus 0 Dev 2 Fn 0 */
800 if (lpc_bridge
== NULL
)
802 pci_read_config_byte(pdev
, 0x49, &prefctl
);
803 pci_dev_put(lpc_bridge
);
805 if (lpc_bridge
->revision
== 0x10 && (prefctl
& 0x80)) {
806 chipset
= &sis133_early
;
815 /* No chipset info, no support */
819 ppi
[0] = chipset
->info
;
821 sis_fixup(pdev
, chipset
);
823 return ata_pci_sff_init_one(pdev
, ppi
, &sis_sht
, chipset
);
826 static const struct pci_device_id sis_pci_tbl
[] = {
827 { PCI_VDEVICE(SI
, 0x5513), }, /* SiS 5513 */
828 { PCI_VDEVICE(SI
, 0x5518), }, /* SiS 5518 */
829 { PCI_VDEVICE(SI
, 0x1180), }, /* SiS 1180 */
834 static struct pci_driver sis_pci_driver
= {
836 .id_table
= sis_pci_tbl
,
837 .probe
= sis_init_one
,
838 .remove
= ata_pci_remove_one
,
840 .suspend
= ata_pci_device_suspend
,
841 .resume
= ata_pci_device_resume
,
845 static int __init
sis_init(void)
847 return pci_register_driver(&sis_pci_driver
);
850 static void __exit
sis_exit(void)
852 pci_unregister_driver(&sis_pci_driver
);
855 module_init(sis_init
);
856 module_exit(sis_exit
);
858 MODULE_AUTHOR("Alan Cox");
859 MODULE_DESCRIPTION("SCSI low-level driver for SiS ATA");
860 MODULE_LICENSE("GPL");
861 MODULE_DEVICE_TABLE(pci
, sis_pci_tbl
);
862 MODULE_VERSION(DRV_VERSION
);