serverworks.c 18 KB

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