- patches.fixes/patch-2.6.11-rc1: 2.6.11-rc1.
[linux-flexiantxendom0-3.2.10.git] / drivers / ide / pci / serverworks.c
1 /*
2  * linux/drivers/ide/pci/serverworks.c          Version 0.8      25 Ebr 2003
3  *
4  * Copyright (C) 1998-2000 Michel Aubry
5  * Copyright (C) 1998-2000 Andrzej Krzysztofowicz
6  * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
7  * Portions copyright (c) 2001 Sun Microsystems
8  *
9  *
10  * RCC/ServerWorks IDE driver for Linux
11  *
12  *   OSB4: `Open South Bridge' IDE Interface (fn 1)
13  *         supports UDMA mode 2 (33 MB/s)
14  *
15  *   CSB5: `Champion South Bridge' IDE Interface (fn 1)
16  *         all revisions support UDMA mode 4 (66 MB/s)
17  *         revision A2.0 and up support UDMA mode 5 (100 MB/s)
18  *
19  *         *** The CSB5 does not provide ANY register ***
20  *         *** to detect 80-conductor cable presence. ***
21  *
22  *   CSB6: `Champion South Bridge' IDE Interface (optional: third channel)
23  *
24  * Documentation:
25  *      Available under NDA only. Errata info very hard to get.
26  *
27  */
28
29 #include <linux/config.h>
30 #include <linux/types.h>
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/ioport.h>
34 #include <linux/pci.h>
35 #include <linux/hdreg.h>
36 #include <linux/ide.h>
37 #include <linux/init.h>
38 #include <linux/delay.h>
39
40 #include <asm/io.h>
41
42 #include "serverworks.h"
43
44 static u8 svwks_revision = 0;
45 static struct pci_dev *isa_dev;
46
47 static int check_in_drive_lists (ide_drive_t *drive, const char **list)
48 {
49         while (*list)
50                 if (!strcmp(*list++, drive->id->model))
51                         return 1;
52         return 0;
53 }
54
55 static u8 svwks_ratemask (ide_drive_t *drive)
56 {
57         struct pci_dev *dev     = HWIF(drive)->pci_dev;
58         u8 mode;
59
60         if (!svwks_revision)
61                 pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision);
62
63         if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
64                 u32 reg = 0;
65                 if (isa_dev)
66                         pci_read_config_dword(isa_dev, 0x64, &reg);
67                         
68                 /*
69                  *      Don't enable UDMA on disk devices for the moment
70                  */
71                 if(drive->media == ide_disk)
72                         return 0;
73                 /* Check the OSB4 DMA33 enable bit */
74                 return ((reg & 0x00004000) == 0x00004000) ? 1 : 0;
75         } else if (svwks_revision < SVWKS_CSB5_REVISION_NEW) {
76                 return 1;
77         } else if (svwks_revision >= SVWKS_CSB5_REVISION_NEW) {
78                 u8 btr = 0;
79                 pci_read_config_byte(dev, 0x5A, &btr);
80                 mode = btr & 0x3;
81                 if (!eighty_ninty_three(drive))
82                         mode = min(mode, (u8)1);
83                 /* If someone decides to do UDMA133 on CSB5 the same
84                    issue will bite so be inclusive */
85                 if (mode > 2 && check_in_drive_lists(drive, svwks_bad_ata100))
86                         mode = 2;
87         }
88         if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
89              (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&
90             (!(PCI_FUNC(dev->devfn) & 1)))
91                 mode = 2;
92         return mode;
93 }
94
95 static u8 svwks_csb_check (struct pci_dev *dev)
96 {
97         switch (dev->device) {
98                 case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
99                 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
100                 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
101                         return 1;
102                 default:
103                         break;
104         }
105         return 0;
106 }
107 static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
108 {
109         u8 udma_modes[]         = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
110         u8 dma_modes[]          = { 0x77, 0x21, 0x20 };
111         u8 pio_modes[]          = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
112         u8 drive_pci[]          = { 0x41, 0x40, 0x43, 0x42 };
113         u8 drive_pci2[]         = { 0x45, 0x44, 0x47, 0x46 };
114
115         ide_hwif_t *hwif        = HWIF(drive);
116         struct pci_dev *dev     = hwif->pci_dev;
117         u8 speed;
118         u8 pio                  = ide_get_best_pio_mode(drive, 255, 5, NULL);
119         u8 unit                 = (drive->select.b.unit & 0x01);
120         u8 csb5                 = svwks_csb_check(dev);
121         u8 ultra_enable         = 0, ultra_timing = 0;
122         u8 dma_timing           = 0, pio_timing = 0;
123         u16 csb5_pio            = 0;
124
125         if (xferspeed == 255)   /* PIO auto-tuning */
126                 speed = XFER_PIO_0 + pio;
127         else
128                 speed = ide_rate_filter(svwks_ratemask(drive), xferspeed);
129
130         /* If we are about to put a disk into UDMA mode we screwed up.
131            Our code assumes we never _ever_ do this on an OSB4 */
132            
133         if(dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4 &&
134                 drive->media == ide_disk && speed >= XFER_UDMA_0)
135                         BUG();
136                         
137         pci_read_config_byte(dev, drive_pci[drive->dn], &pio_timing);
138         pci_read_config_byte(dev, drive_pci2[drive->dn], &dma_timing);
139         pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing);
140         pci_read_config_word(dev, 0x4A, &csb5_pio);
141         pci_read_config_byte(dev, 0x54, &ultra_enable);
142
143         /* Per Specified Design by OEM, and ASIC Architect */
144         if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
145             (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
146                 if (!drive->init_speed) {
147                         u8 dma_stat = hwif->INB(hwif->dma_status);
148
149 dma_pio:
150                         if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
151                             ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) {
152                                 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)];
153                                 return 0;
154                         } else if ((dma_timing) &&
155                                    ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
156                                 u8 dmaspeed = dma_timing;
157
158                                 dma_timing &= ~0xFF;
159                                 if ((dmaspeed & 0x20) == 0x20)
160                                         dmaspeed = XFER_MW_DMA_2;
161                                 else if ((dmaspeed & 0x21) == 0x21)
162                                         dmaspeed = XFER_MW_DMA_1;
163                                 else if ((dmaspeed & 0x77) == 0x77)
164                                         dmaspeed = XFER_MW_DMA_0;
165                                 else
166                                         goto dma_pio;
167                                 drive->current_speed = drive->init_speed = dmaspeed;
168                                 return 0;
169                         } else if (pio_timing) {
170                                 u8 piospeed = pio_timing;
171
172                                 pio_timing &= ~0xFF;
173                                 if ((piospeed & 0x20) == 0x20)
174                                         piospeed = XFER_PIO_4;
175                                 else if ((piospeed & 0x22) == 0x22)
176                                         piospeed = XFER_PIO_3;
177                                 else if ((piospeed & 0x34) == 0x34)
178                                         piospeed = XFER_PIO_2;
179                                 else if ((piospeed & 0x47) == 0x47)
180                                         piospeed = XFER_PIO_1;
181                                 else if ((piospeed & 0x5d) == 0x5d)
182                                         piospeed = XFER_PIO_0;
183                                 else
184                                         goto oem_setup_failed;
185                                 drive->current_speed = drive->init_speed = piospeed;
186                                 return 0;
187                         }
188                 }
189         }
190
191 oem_setup_failed:
192
193         pio_timing      &= ~0xFF;
194         dma_timing      &= ~0xFF;
195         ultra_timing    &= ~(0x0F << (4*unit));
196         ultra_enable    &= ~(0x01 << drive->dn);
197         csb5_pio        &= ~(0x0F << (4*drive->dn));
198
199         switch(speed) {
200                 case XFER_PIO_4:
201                 case XFER_PIO_3:
202                 case XFER_PIO_2:
203                 case XFER_PIO_1:
204                 case XFER_PIO_0:
205                         pio_timing |= pio_modes[speed - XFER_PIO_0];
206                         csb5_pio   |= ((speed - XFER_PIO_0) << (4*drive->dn));
207                         break;
208
209                 case XFER_MW_DMA_2:
210                 case XFER_MW_DMA_1:
211                 case XFER_MW_DMA_0:
212                         pio_timing |= pio_modes[pio];
213                         csb5_pio   |= (pio << (4*drive->dn));
214                         dma_timing |= dma_modes[speed - XFER_MW_DMA_0];
215                         break;
216
217                 case XFER_UDMA_5:
218                 case XFER_UDMA_4:
219                 case XFER_UDMA_3:
220                 case XFER_UDMA_2:
221                 case XFER_UDMA_1:
222                 case XFER_UDMA_0:
223                         pio_timing   |= pio_modes[pio];
224                         csb5_pio     |= (pio << (4*drive->dn));
225                         dma_timing   |= dma_modes[2];
226                         ultra_timing |= ((udma_modes[speed - XFER_UDMA_0]) << (4*unit));
227                         ultra_enable |= (0x01 << drive->dn);
228                 default:
229                         break;
230         }
231
232         pci_write_config_byte(dev, drive_pci[drive->dn], pio_timing);
233         if (csb5)
234                 pci_write_config_word(dev, 0x4A, csb5_pio);
235
236         pci_write_config_byte(dev, drive_pci2[drive->dn], dma_timing);
237         pci_write_config_byte(dev, (0x56|hwif->channel), ultra_timing);
238         pci_write_config_byte(dev, 0x54, ultra_enable);
239
240         return (ide_config_drive_speed(drive, speed));
241 }
242
243 static void config_chipset_for_pio (ide_drive_t *drive)
244 {
245         u16 eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
246         u16 xfer_pio = drive->id->eide_pio_modes;
247         u8 timing, speed, pio;
248
249         pio = ide_get_best_pio_mode(drive, 255, 5, NULL);
250
251         if (xfer_pio > 4)
252                 xfer_pio = 0;
253
254         if (drive->id->eide_pio_iordy > 0)
255                 for (xfer_pio = 5;
256                         xfer_pio>0 &&
257                         drive->id->eide_pio_iordy>eide_pio_timing[xfer_pio];
258                         xfer_pio--);
259         else
260                 xfer_pio = (drive->id->eide_pio_modes & 4) ? 0x05 :
261                            (drive->id->eide_pio_modes & 2) ? 0x04 :
262                            (drive->id->eide_pio_modes & 1) ? 0x03 :
263                            (drive->id->tPIO & 2) ? 0x02 :
264                            (drive->id->tPIO & 1) ? 0x01 : xfer_pio;
265
266         timing = (xfer_pio >= pio) ? xfer_pio : pio;
267
268         switch(timing) {
269                 case 4: speed = XFER_PIO_4;break;
270                 case 3: speed = XFER_PIO_3;break;
271                 case 2: speed = XFER_PIO_2;break;
272                 case 1: speed = XFER_PIO_1;break;
273                 default:
274                         speed = (!drive->id->tPIO) ? XFER_PIO_0 : XFER_PIO_SLOW;
275                         break;
276         }
277         (void) svwks_tune_chipset(drive, speed);
278         drive->current_speed = speed;
279 }
280
281 static void svwks_tune_drive (ide_drive_t *drive, u8 pio)
282 {
283         if(pio == 255)
284                 (void) svwks_tune_chipset(drive, 255);
285         else
286                 (void) svwks_tune_chipset(drive, (XFER_PIO_0 + pio));
287 }
288
289 static int config_chipset_for_dma (ide_drive_t *drive)
290 {
291         u8 speed = ide_dma_speed(drive, svwks_ratemask(drive));
292
293         if (!(speed))
294                 speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);
295
296         (void) svwks_tune_chipset(drive, speed);
297         return ide_dma_enable(drive);
298 }
299
300 static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
301 {
302         ide_hwif_t *hwif        = HWIF(drive);
303         struct hd_driveid *id   = drive->id;
304
305         drive->init_speed = 0;
306
307         if ((id->capability & 1) && drive->autodma) {
308
309                 if (ide_use_dma(drive)) {
310                         if (config_chipset_for_dma(drive))
311                                 return hwif->ide_dma_on(drive);
312                 }
313
314                 goto fast_ata_pio;
315
316         } else if ((id->capability & 8) || (id->field_valid & 2)) {
317 fast_ata_pio:
318                 config_chipset_for_pio(drive);
319                 //      hwif->tuneproc(drive, 5);
320                 return hwif->ide_dma_off_quietly(drive);
321         }
322         /* IORDY not supported */
323         return 0;
324 }
325
326 /* This can go soon */
327
328 static int svwks_ide_dma_end (ide_drive_t *drive)
329 {
330         return __ide_dma_end(drive);
331 }
332
333 static unsigned int __init init_chipset_svwks (struct pci_dev *dev, const char *name)
334 {
335         unsigned int reg;
336         u8 btr;
337
338         /* save revision id to determine DMA capability */
339         pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision);
340
341         /* force Master Latency Timer value to 64 PCICLKs */
342         pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
343
344         /* OSB4 : South Bridge and IDE */
345         if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
346                 isa_dev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,
347                           PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL);
348                 if (isa_dev) {
349                         pci_read_config_dword(isa_dev, 0x64, &reg);
350                         reg &= ~0x00002000; /* disable 600ns interrupt mask */
351                         if(!(reg & 0x00004000))
352                                 printk(KERN_DEBUG "%s: UDMA not BIOS enabled.\n", name);
353                         reg |=  0x00004000; /* enable UDMA/33 support */
354                         pci_write_config_dword(isa_dev, 0x64, reg);
355                 }
356         }
357
358         /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
359         else if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
360                  (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
361                  (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
362
363                 /* Third Channel Test */
364                 if (!(PCI_FUNC(dev->devfn) & 1)) {
365                         struct pci_dev * findev = NULL;
366                         u32 reg4c = 0;
367                         findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,
368                                 PCI_DEVICE_ID_SERVERWORKS_CSB5, NULL);
369                         if (findev) {
370                                 pci_read_config_dword(findev, 0x4C, &reg4c);
371                                 reg4c &= ~0x000007FF;
372                                 reg4c |=  0x00000040;
373                                 reg4c |=  0x00000020;
374                                 pci_write_config_dword(findev, 0x4C, reg4c);
375                         }
376                         outb_p(0x06, 0x0c00);
377                         dev->irq = inb_p(0x0c01);
378 #if 0
379                         printk("%s: device class (0x%04x)\n",
380                                 name, dev->class);
381                         if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
382                                 dev->class &= ~0x000F0F00;
383                 //              dev->class |= ~0x00000400;
384                                 dev->class |= ~0x00010100;
385                                 /**/
386                         }
387 #endif
388                 } else {
389                         struct pci_dev * findev = NULL;
390                         u8 reg41 = 0;
391
392                         findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,
393                                         PCI_DEVICE_ID_SERVERWORKS_CSB6, NULL);
394                         if (findev) {
395                                 pci_read_config_byte(findev, 0x41, &reg41);
396                                 reg41 &= ~0x40;
397                                 pci_write_config_byte(findev, 0x41, reg41);
398                         }
399                         /*
400                          * This is a device pin issue on CSB6.
401                          * Since there will be a future raid mode,
402                          * early versions of the chipset require the
403                          * interrupt pin to be set, and it is a compatibility
404                          * mode issue.
405                          */
406                         if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
407                                 dev->irq = 0;
408                 }
409 //              pci_read_config_dword(dev, 0x40, &pioreg)
410 //              pci_write_config_dword(dev, 0x40, 0x99999999);
411 //              pci_read_config_dword(dev, 0x44, &dmareg);
412 //              pci_write_config_dword(dev, 0x44, 0xFFFFFFFF);
413                 /* setup the UDMA Control register
414                  *
415                  * 1. clear bit 6 to enable DMA
416                  * 2. enable DMA modes with bits 0-1
417                  *      00 : legacy
418                  *      01 : udma2
419                  *      10 : udma2/udma4
420                  *      11 : udma2/udma4/udma5
421                  */
422                 pci_read_config_byte(dev, 0x5A, &btr);
423                 btr &= ~0x40;
424                 if (!(PCI_FUNC(dev->devfn) & 1))
425                         btr |= 0x2;
426                 else
427                         btr |= (svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
428                 pci_write_config_byte(dev, 0x5A, btr);
429         }
430
431         return (dev->irq) ? dev->irq : 0;
432 }
433
434 static unsigned int __init ata66_svwks_svwks (ide_hwif_t *hwif)
435 {
436         return 1;
437 }
438
439 /* On Dell PowerEdge servers with a CSB5/CSB6, the top two bits
440  * of the subsystem device ID indicate presence of an 80-pin cable.
441  * Bit 15 clear = secondary IDE channel does not have 80-pin cable.
442  * Bit 15 set   = secondary IDE channel has 80-pin cable.
443  * Bit 14 clear = primary IDE channel does not have 80-pin cable.
444  * Bit 14 set   = primary IDE channel has 80-pin cable.
445  */
446 static unsigned int __init ata66_svwks_dell (ide_hwif_t *hwif)
447 {
448         struct pci_dev *dev = hwif->pci_dev;
449         if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL &&
450             dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
451             (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ||
452              dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE))
453                 return ((1 << (hwif->channel + 14)) &
454                         dev->subsystem_device) ? 1 : 0;
455         return 0;
456 }
457
458 /* Sun Cobalt Alpine hardware avoids the 80-pin cable
459  * detect issue by attaching the drives directly to the board.
460  * This check follows the Dell precedent (how scary is that?!)
461  *
462  * WARNING: this only works on Alpine hardware!
463  */
464 static unsigned int __init ata66_svwks_cobalt (ide_hwif_t *hwif)
465 {
466         struct pci_dev *dev = hwif->pci_dev;
467         if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN &&
468             dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
469             dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
470                 return ((1 << (hwif->channel + 14)) &
471                         dev->subsystem_device) ? 1 : 0;
472         return 0;
473 }
474
475 static unsigned int __init ata66_svwks (ide_hwif_t *hwif)
476 {
477         struct pci_dev *dev = hwif->pci_dev;
478
479         /* Per Specified Design by OEM, and ASIC Architect */
480         if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
481             (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
482                 return 1;
483
484         /* Server Works */
485         if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)
486                 return ata66_svwks_svwks (hwif);
487         
488         /* Dell PowerEdge */
489         if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL)
490                 return ata66_svwks_dell (hwif);
491
492         /* Cobalt Alpine */
493         if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)
494                 return ata66_svwks_cobalt (hwif);
495
496         return 0;
497 }
498
499 #undef CAN_SW_DMA
500 static void __init init_hwif_svwks (ide_hwif_t *hwif)
501 {
502         u8 dma_stat = 0;
503
504         if (!hwif->irq)
505                 hwif->irq = hwif->channel ? 15 : 14;
506
507         hwif->tuneproc = &svwks_tune_drive;
508         hwif->speedproc = &svwks_tune_chipset;
509
510         hwif->atapi_dma = 1;
511
512         if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)
513                 hwif->ultra_mask = 0x3f;
514
515         hwif->mwdma_mask = 0x07;
516 #ifdef CAN_SW_DMA
517         hwif->swdma_mask = 0x07;
518 #endif /* CAN_SW_DMA */
519
520         hwif->autodma = 0;
521
522         if (!hwif->dma_base) {
523                 hwif->drives[0].autotune = 1;
524                 hwif->drives[1].autotune = 1;
525                 return;
526         }
527
528         hwif->ide_dma_check = &svwks_config_drive_xfer_rate;
529         if (hwif->pci_dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)
530                 hwif->ide_dma_end = &svwks_ide_dma_end;
531         else if (!(hwif->udma_four))
532                 hwif->udma_four = ata66_svwks(hwif);
533         if (!noautodma)
534                 hwif->autodma = 1;
535
536         dma_stat = hwif->INB(hwif->dma_status);
537         hwif->drives[0].autodma = (dma_stat & 0x20);
538         hwif->drives[1].autodma = (dma_stat & 0x40);
539         hwif->drives[0].autotune = (!(dma_stat & 0x20));
540         hwif->drives[1].autotune = (!(dma_stat & 0x40));
541 //      hwif->drives[0].autodma = hwif->autodma;
542 //      hwif->drives[1].autodma = hwif->autodma;
543 }
544
545 /*
546  * We allow the BM-DMA driver to only work on enabled interfaces.
547  */
548 static void __init init_dma_svwks (ide_hwif_t *hwif, unsigned long dmabase)
549 {
550         struct pci_dev *dev = hwif->pci_dev;
551
552         if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
553              (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&
554             (!(PCI_FUNC(dev->devfn) & 1)) && (hwif->channel))
555                 return;
556
557         ide_setup_dma(hwif, dmabase, 8);
558 }
559
560 static int __init init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d)
561 {
562         return ide_setup_pci_device(dev, d);
563 }
564
565 static int __init init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d)
566 {
567         if (!(PCI_FUNC(dev->devfn) & 1)) {
568                 d->bootable = NEVER_BOARD;
569                 if (dev->resource[0].start == 0x01f1)
570                         d->bootable = ON_BOARD;
571         }
572 #if 0
573         if ((IDE_PCI_DEVID_EQ(d->devid, DEVID_CSB6) &&
574              (!(PCI_FUNC(dev->devfn) & 1)))
575                 d->autodma = AUTODMA;
576 #endif
577
578         d->channels = ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE ||
579                         dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) &&
580                        (!(PCI_FUNC(dev->devfn) & 1))) ? 1 : 2;
581
582         return ide_setup_pci_device(dev, d);
583 }
584
585
586 /**
587  *      svwks_init_one  -       called when a OSB/CSB is found
588  *      @dev: the svwks device
589  *      @id: the matching pci id
590  *
591  *      Called when the PCI registration layer (or the IDE initialization)
592  *      finds a device matching our IDE device tables.
593  */
594  
595 static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id)
596 {
597         ide_pci_device_t *d = &serverworks_chipsets[id->driver_data];
598
599         return d->init_setup(dev, d);
600 }
601
602 static struct pci_device_id svwks_pci_tbl[] = {
603         { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
604         { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
605         { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
606         { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
607         { 0, },
608 };
609 MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
610
611 static struct pci_driver driver = {
612         .name           = "Serverworks_IDE",
613         .id_table       = svwks_pci_tbl,
614         .probe          = svwks_init_one,
615 };
616
617 static int svwks_ide_init(void)
618 {
619         return ide_pci_register_driver(&driver);
620 }
621
622 module_init(svwks_ide_init);
623
624 MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick");
625 MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE");
626 MODULE_LICENSE("GPL");