pdc202xx_new.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*
  2. * Promise TX2/TX4/TX2000/133 IDE driver
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * Split from:
  10. * linux/drivers/ide/pdc202xx.c Version 0.35 Mar. 30, 2002
  11. * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>
  12. * Copyright (C) 2005-2006 MontaVista Software, Inc.
  13. * Portions Copyright (C) 1999 Promise Technology, Inc.
  14. * Author: Frank Tiernan (frankt@promise.com)
  15. * Released under terms of General Public License
  16. */
  17. #include <linux/module.h>
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/delay.h>
  21. #include <linux/timer.h>
  22. #include <linux/mm.h>
  23. #include <linux/ioport.h>
  24. #include <linux/blkdev.h>
  25. #include <linux/hdreg.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/pci.h>
  28. #include <linux/init.h>
  29. #include <linux/ide.h>
  30. #include <asm/io.h>
  31. #include <asm/irq.h>
  32. #ifdef CONFIG_PPC_PMAC
  33. #include <asm/prom.h>
  34. #include <asm/pci-bridge.h>
  35. #endif
  36. #define PDC202_DEBUG_CABLE 0
  37. #undef DEBUG
  38. #ifdef DEBUG
  39. #define DBG(fmt, args...) printk("%s: " fmt, __FUNCTION__, ## args)
  40. #else
  41. #define DBG(fmt, args...)
  42. #endif
  43. static const char *pdc_quirk_drives[] = {
  44. "QUANTUM FIREBALLlct08 08",
  45. "QUANTUM FIREBALLP KA6.4",
  46. "QUANTUM FIREBALLP KA9.1",
  47. "QUANTUM FIREBALLP LM20.4",
  48. "QUANTUM FIREBALLP KX13.6",
  49. "QUANTUM FIREBALLP KX20.5",
  50. "QUANTUM FIREBALLP KX27.3",
  51. "QUANTUM FIREBALLP LM20.5",
  52. NULL
  53. };
  54. static u8 max_dma_rate(struct pci_dev *pdev)
  55. {
  56. u8 mode;
  57. switch(pdev->device) {
  58. case PCI_DEVICE_ID_PROMISE_20277:
  59. case PCI_DEVICE_ID_PROMISE_20276:
  60. case PCI_DEVICE_ID_PROMISE_20275:
  61. case PCI_DEVICE_ID_PROMISE_20271:
  62. case PCI_DEVICE_ID_PROMISE_20269:
  63. mode = 4;
  64. break;
  65. case PCI_DEVICE_ID_PROMISE_20270:
  66. case PCI_DEVICE_ID_PROMISE_20268:
  67. mode = 3;
  68. break;
  69. default:
  70. return 0;
  71. }
  72. return mode;
  73. }
  74. static u8 pdcnew_ratemask(ide_drive_t *drive)
  75. {
  76. u8 mode = max_dma_rate(HWIF(drive)->pci_dev);
  77. if (!eighty_ninty_three(drive))
  78. mode = min_t(u8, mode, 1);
  79. return mode;
  80. }
  81. /**
  82. * get_indexed_reg - Get indexed register
  83. * @hwif: for the port address
  84. * @index: index of the indexed register
  85. */
  86. static u8 get_indexed_reg(ide_hwif_t *hwif, u8 index)
  87. {
  88. u8 value;
  89. hwif->OUTB(index, hwif->dma_vendor1);
  90. value = hwif->INB(hwif->dma_vendor3);
  91. DBG("index[%02X] value[%02X]\n", index, value);
  92. return value;
  93. }
  94. /**
  95. * set_indexed_reg - Set indexed register
  96. * @hwif: for the port address
  97. * @index: index of the indexed register
  98. */
  99. static void set_indexed_reg(ide_hwif_t *hwif, u8 index, u8 value)
  100. {
  101. hwif->OUTB(index, hwif->dma_vendor1);
  102. hwif->OUTB(value, hwif->dma_vendor3);
  103. DBG("index[%02X] value[%02X]\n", index, value);
  104. }
  105. /*
  106. * ATA Timing Tables based on 133 MHz PLL output clock.
  107. *
  108. * If the PLL outputs 100 MHz clock, the ASIC hardware will set
  109. * the timing registers automatically when "set features" command is
  110. * issued to the device. However, if the PLL output clock is 133 MHz,
  111. * the following tables must be used.
  112. */
  113. static struct pio_timing {
  114. u8 reg0c, reg0d, reg13;
  115. } pio_timings [] = {
  116. { 0xfb, 0x2b, 0xac }, /* PIO mode 0, IORDY off, Prefetch off */
  117. { 0x46, 0x29, 0xa4 }, /* PIO mode 1, IORDY off, Prefetch off */
  118. { 0x23, 0x26, 0x64 }, /* PIO mode 2, IORDY off, Prefetch off */
  119. { 0x27, 0x0d, 0x35 }, /* PIO mode 3, IORDY on, Prefetch off */
  120. { 0x23, 0x09, 0x25 }, /* PIO mode 4, IORDY on, Prefetch off */
  121. };
  122. static struct mwdma_timing {
  123. u8 reg0e, reg0f;
  124. } mwdma_timings [] = {
  125. { 0xdf, 0x5f }, /* MWDMA mode 0 */
  126. { 0x6b, 0x27 }, /* MWDMA mode 1 */
  127. { 0x69, 0x25 }, /* MWDMA mode 2 */
  128. };
  129. static struct udma_timing {
  130. u8 reg10, reg11, reg12;
  131. } udma_timings [] = {
  132. { 0x4a, 0x0f, 0xd5 }, /* UDMA mode 0 */
  133. { 0x3a, 0x0a, 0xd0 }, /* UDMA mode 1 */
  134. { 0x2a, 0x07, 0xcd }, /* UDMA mode 2 */
  135. { 0x1a, 0x05, 0xcd }, /* UDMA mode 3 */
  136. { 0x1a, 0x03, 0xcd }, /* UDMA mode 4 */
  137. { 0x1a, 0x02, 0xcb }, /* UDMA mode 5 */
  138. { 0x1a, 0x01, 0xcb }, /* UDMA mode 6 */
  139. };
  140. static int pdcnew_tune_chipset(ide_drive_t *drive, u8 speed)
  141. {
  142. ide_hwif_t *hwif = HWIF(drive);
  143. u8 adj = (drive->dn & 1) ? 0x08 : 0x00;
  144. int err;
  145. speed = ide_rate_filter(pdcnew_ratemask(drive), speed);
  146. /*
  147. * Issue SETFEATURES_XFER to the drive first. PDC202xx hardware will
  148. * automatically set the timing registers based on 100 MHz PLL output.
  149. */
  150. err = ide_config_drive_speed(drive, speed);
  151. /*
  152. * As we set up the PLL to output 133 MHz for UltraDMA/133 capable
  153. * chips, we must override the default register settings...
  154. */
  155. if (max_dma_rate(hwif->pci_dev) == 4) {
  156. u8 mode = speed & 0x07;
  157. switch (speed) {
  158. case XFER_UDMA_6:
  159. case XFER_UDMA_5:
  160. case XFER_UDMA_4:
  161. case XFER_UDMA_3:
  162. case XFER_UDMA_2:
  163. case XFER_UDMA_1:
  164. case XFER_UDMA_0:
  165. set_indexed_reg(hwif, 0x10 + adj,
  166. udma_timings[mode].reg10);
  167. set_indexed_reg(hwif, 0x11 + adj,
  168. udma_timings[mode].reg11);
  169. set_indexed_reg(hwif, 0x12 + adj,
  170. udma_timings[mode].reg12);
  171. break;
  172. case XFER_MW_DMA_2:
  173. case XFER_MW_DMA_1:
  174. case XFER_MW_DMA_0:
  175. set_indexed_reg(hwif, 0x0e + adj,
  176. mwdma_timings[mode].reg0e);
  177. set_indexed_reg(hwif, 0x0f + adj,
  178. mwdma_timings[mode].reg0f);
  179. break;
  180. case XFER_PIO_4:
  181. case XFER_PIO_3:
  182. case XFER_PIO_2:
  183. case XFER_PIO_1:
  184. case XFER_PIO_0:
  185. set_indexed_reg(hwif, 0x0c + adj,
  186. pio_timings[mode].reg0c);
  187. set_indexed_reg(hwif, 0x0d + adj,
  188. pio_timings[mode].reg0d);
  189. set_indexed_reg(hwif, 0x13 + adj,
  190. pio_timings[mode].reg13);
  191. break;
  192. default:
  193. printk(KERN_ERR "pdc202xx_new: "
  194. "Unknown speed %d ignored\n", speed);
  195. }
  196. } else if (speed == XFER_UDMA_2) {
  197. /* Set tHOLD bit to 0 if using UDMA mode 2 */
  198. u8 tmp = get_indexed_reg(hwif, 0x10 + adj);
  199. set_indexed_reg(hwif, 0x10 + adj, tmp & 0x7f);
  200. }
  201. return err;
  202. }
  203. static void pdcnew_tune_drive(ide_drive_t *drive, u8 pio)
  204. {
  205. pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
  206. (void)pdcnew_tune_chipset(drive, XFER_PIO_0 + pio);
  207. }
  208. static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
  209. {
  210. return get_indexed_reg(hwif, 0x0b) & 0x04;
  211. }
  212. static int config_chipset_for_dma(ide_drive_t *drive)
  213. {
  214. struct hd_driveid *id = drive->id;
  215. ide_hwif_t *hwif = HWIF(drive);
  216. u8 ultra_66 = (id->dma_ultra & 0x0078) ? 1 : 0;
  217. u8 cable = pdcnew_cable_detect(hwif);
  218. u8 speed;
  219. if (ultra_66 && cable) {
  220. printk(KERN_WARNING "Warning: %s channel "
  221. "requires an 80-pin cable for operation.\n",
  222. hwif->channel ? "Secondary" : "Primary");
  223. printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
  224. }
  225. if (drive->media != ide_disk)
  226. return 0;
  227. if (id->capability & 4) {
  228. /*
  229. * Set IORDY_EN & PREFETCH_EN (this seems to have
  230. * NO real effect since this register is reloaded
  231. * by hardware when the transfer mode is selected)
  232. */
  233. u8 tmp, adj = (drive->dn & 1) ? 0x08 : 0x00;
  234. tmp = get_indexed_reg(hwif, 0x13 + adj);
  235. set_indexed_reg(hwif, 0x13 + adj, tmp | 0x03);
  236. }
  237. speed = ide_dma_speed(drive, pdcnew_ratemask(drive));
  238. if (!speed)
  239. return 0;
  240. (void) hwif->speedproc(drive, speed);
  241. return ide_dma_enable(drive);
  242. }
  243. static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
  244. {
  245. ide_hwif_t *hwif = HWIF(drive);
  246. struct hd_driveid *id = drive->id;
  247. drive->init_speed = 0;
  248. if ((id->capability & 1) && drive->autodma) {
  249. if (ide_use_dma(drive) && config_chipset_for_dma(drive))
  250. return hwif->ide_dma_on(drive);
  251. goto fast_ata_pio;
  252. } else if ((id->capability & 8) || (id->field_valid & 2)) {
  253. fast_ata_pio:
  254. hwif->tuneproc(drive, 255);
  255. return hwif->ide_dma_off_quietly(drive);
  256. }
  257. /* IORDY not supported */
  258. return 0;
  259. }
  260. static int pdcnew_quirkproc(ide_drive_t *drive)
  261. {
  262. const char **list, *model = drive->id->model;
  263. for (list = pdc_quirk_drives; *list != NULL; list++)
  264. if (strstr(model, *list) != NULL)
  265. return 2;
  266. return 0;
  267. }
  268. static void pdcnew_reset(ide_drive_t *drive)
  269. {
  270. /*
  271. * Deleted this because it is redundant from the caller.
  272. */
  273. printk(KERN_WARNING "pdc202xx_new: %s channel reset.\n",
  274. HWIF(drive)->channel ? "Secondary" : "Primary");
  275. }
  276. /**
  277. * read_counter - Read the byte count registers
  278. * @dma_base: for the port address
  279. */
  280. static long __devinit read_counter(u32 dma_base)
  281. {
  282. u32 pri_dma_base = dma_base, sec_dma_base = dma_base + 0x08;
  283. u8 cnt0, cnt1, cnt2, cnt3;
  284. long count = 0, last;
  285. int retry = 3;
  286. do {
  287. last = count;
  288. /* Read the current count */
  289. outb(0x20, pri_dma_base + 0x01);
  290. cnt0 = inb(pri_dma_base + 0x03);
  291. outb(0x21, pri_dma_base + 0x01);
  292. cnt1 = inb(pri_dma_base + 0x03);
  293. outb(0x20, sec_dma_base + 0x01);
  294. cnt2 = inb(sec_dma_base + 0x03);
  295. outb(0x21, sec_dma_base + 0x01);
  296. cnt3 = inb(sec_dma_base + 0x03);
  297. count = (cnt3 << 23) | (cnt2 << 15) | (cnt1 << 8) | cnt0;
  298. /*
  299. * The 30-bit decrementing counter is read in 4 pieces.
  300. * Incorrect value may be read when the most significant bytes
  301. * are changing...
  302. */
  303. } while (retry-- && (((last ^ count) & 0x3fff8000) || last < count));
  304. DBG("cnt0[%02X] cnt1[%02X] cnt2[%02X] cnt3[%02X]\n",
  305. cnt0, cnt1, cnt2, cnt3);
  306. return count;
  307. }
  308. /**
  309. * detect_pll_input_clock - Detect the PLL input clock in Hz.
  310. * @dma_base: for the port address
  311. * E.g. 16949000 on 33 MHz PCI bus, i.e. half of the PCI clock.
  312. */
  313. static long __devinit detect_pll_input_clock(unsigned long dma_base)
  314. {
  315. long start_count, end_count;
  316. long pll_input;
  317. u8 scr1;
  318. start_count = read_counter(dma_base);
  319. /* Start the test mode */
  320. outb(0x01, dma_base + 0x01);
  321. scr1 = inb(dma_base + 0x03);
  322. DBG("scr1[%02X]\n", scr1);
  323. outb(scr1 | 0x40, dma_base + 0x03);
  324. /* Let the counter run for 10 ms. */
  325. mdelay(10);
  326. end_count = read_counter(dma_base);
  327. /* Stop the test mode */
  328. outb(0x01, dma_base + 0x01);
  329. scr1 = inb(dma_base + 0x03);
  330. DBG("scr1[%02X]\n", scr1);
  331. outb(scr1 & ~0x40, dma_base + 0x03);
  332. /*
  333. * Calculate the input clock in Hz
  334. * (the clock counter is 30 bit wide and counts down)
  335. */
  336. pll_input = ((start_count - end_count) & 0x3ffffff) * 100;
  337. DBG("start[%ld] end[%ld]\n", start_count, end_count);
  338. return pll_input;
  339. }
  340. #ifdef CONFIG_PPC_PMAC
  341. static void __devinit apple_kiwi_init(struct pci_dev *pdev)
  342. {
  343. struct device_node *np = pci_device_to_OF_node(pdev);
  344. unsigned int class_rev = 0;
  345. u8 conf;
  346. if (np == NULL || !device_is_compatible(np, "kiwi-root"))
  347. return;
  348. pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
  349. class_rev &= 0xff;
  350. if (class_rev >= 0x03) {
  351. /* Setup chip magic config stuff (from darwin) */
  352. pci_read_config_byte (pdev, 0x40, &conf);
  353. pci_write_config_byte(pdev, 0x40, (conf | 0x01));
  354. }
  355. }
  356. #endif /* CONFIG_PPC_PMAC */
  357. static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name)
  358. {
  359. unsigned long dma_base = pci_resource_start(dev, 4);
  360. unsigned long sec_dma_base = dma_base + 0x08;
  361. long pll_input, pll_output, ratio;
  362. int f, r;
  363. u8 pll_ctl0, pll_ctl1;
  364. if (dev->resource[PCI_ROM_RESOURCE].start) {
  365. pci_write_config_dword(dev, PCI_ROM_ADDRESS,
  366. dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
  367. printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name,
  368. (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
  369. }
  370. #ifdef CONFIG_PPC_PMAC
  371. apple_kiwi_init(dev);
  372. #endif
  373. /* Calculate the required PLL output frequency */
  374. switch(max_dma_rate(dev)) {
  375. case 4: /* it's 133 MHz for Ultra133 chips */
  376. pll_output = 133333333;
  377. break;
  378. case 3: /* and 100 MHz for Ultra100 chips */
  379. default:
  380. pll_output = 100000000;
  381. break;
  382. }
  383. /*
  384. * Detect PLL input clock.
  385. * On some systems, where PCI bus is running at non-standard clock rate
  386. * (e.g. 25 or 40 MHz), we have to adjust the cycle time.
  387. * PDC20268 and newer chips employ PLL circuit to help correct timing
  388. * registers setting.
  389. */
  390. pll_input = detect_pll_input_clock(dma_base);
  391. printk("%s: PLL input clock is %ld kHz\n", name, pll_input / 1000);
  392. /* Sanity check */
  393. if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) {
  394. printk(KERN_ERR "%s: Bad PLL input clock %ld Hz, giving up!\n",
  395. name, pll_input);
  396. goto out;
  397. }
  398. #ifdef DEBUG
  399. DBG("pll_output is %ld Hz\n", pll_output);
  400. /* Show the current clock value of PLL control register
  401. * (maybe already configured by the BIOS)
  402. */
  403. outb(0x02, sec_dma_base + 0x01);
  404. pll_ctl0 = inb(sec_dma_base + 0x03);
  405. outb(0x03, sec_dma_base + 0x01);
  406. pll_ctl1 = inb(sec_dma_base + 0x03);
  407. DBG("pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1);
  408. #endif
  409. /*
  410. * Calculate the ratio of F, R and NO
  411. * POUT = (F + 2) / (( R + 2) * NO)
  412. */
  413. ratio = pll_output / (pll_input / 1000);
  414. if (ratio < 8600L) { /* 8.6x */
  415. /* Using NO = 0x01, R = 0x0d */
  416. r = 0x0d;
  417. } else if (ratio < 12900L) { /* 12.9x */
  418. /* Using NO = 0x01, R = 0x08 */
  419. r = 0x08;
  420. } else if (ratio < 16100L) { /* 16.1x */
  421. /* Using NO = 0x01, R = 0x06 */
  422. r = 0x06;
  423. } else if (ratio < 64000L) { /* 64x */
  424. r = 0x00;
  425. } else {
  426. /* Invalid ratio */
  427. printk(KERN_ERR "%s: Bad ratio %ld, giving up!\n", name, ratio);
  428. goto out;
  429. }
  430. f = (ratio * (r + 2)) / 1000 - 2;
  431. DBG("F[%d] R[%d] ratio*1000[%ld]\n", f, r, ratio);
  432. if (unlikely(f < 0 || f > 127)) {
  433. /* Invalid F */
  434. printk(KERN_ERR "%s: F[%d] invalid!\n", name, f);
  435. goto out;
  436. }
  437. pll_ctl0 = (u8) f;
  438. pll_ctl1 = (u8) r;
  439. DBG("Writing pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1);
  440. outb(0x02, sec_dma_base + 0x01);
  441. outb(pll_ctl0, sec_dma_base + 0x03);
  442. outb(0x03, sec_dma_base + 0x01);
  443. outb(pll_ctl1, sec_dma_base + 0x03);
  444. /* Wait the PLL circuit to be stable */
  445. mdelay(30);
  446. #ifdef DEBUG
  447. /*
  448. * Show the current clock value of PLL control register
  449. */
  450. outb(0x02, sec_dma_base + 0x01);
  451. pll_ctl0 = inb(sec_dma_base + 0x03);
  452. outb(0x03, sec_dma_base + 0x01);
  453. pll_ctl1 = inb(sec_dma_base + 0x03);
  454. DBG("pll_ctl[%02X][%02X]\n", pll_ctl0, pll_ctl1);
  455. #endif
  456. out:
  457. return dev->irq;
  458. }
  459. static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
  460. {
  461. hwif->autodma = 0;
  462. hwif->tuneproc = &pdcnew_tune_drive;
  463. hwif->quirkproc = &pdcnew_quirkproc;
  464. hwif->speedproc = &pdcnew_tune_chipset;
  465. hwif->resetproc = &pdcnew_reset;
  466. hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
  467. hwif->ultra_mask = 0x7f;
  468. hwif->mwdma_mask = 0x07;
  469. hwif->err_stops_fifo = 1;
  470. hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
  471. if (!hwif->udma_four)
  472. hwif->udma_four = pdcnew_cable_detect(hwif) ? 0 : 1;
  473. if (!noautodma)
  474. hwif->autodma = 1;
  475. hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
  476. #if PDC202_DEBUG_CABLE
  477. printk(KERN_DEBUG "%s: %s-pin cable\n",
  478. hwif->name, hwif->udma_four ? "80" : "40");
  479. #endif /* PDC202_DEBUG_CABLE */
  480. }
  481. static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d)
  482. {
  483. return ide_setup_pci_device(dev, d);
  484. }
  485. static int __devinit init_setup_pdc20270(struct pci_dev *dev,
  486. ide_pci_device_t *d)
  487. {
  488. struct pci_dev *findev = NULL;
  489. int ret;
  490. if ((dev->bus->self &&
  491. dev->bus->self->vendor == PCI_VENDOR_ID_DEC) &&
  492. (dev->bus->self->device == PCI_DEVICE_ID_DEC_21150)) {
  493. if (PCI_SLOT(dev->devfn) & 2)
  494. return -ENODEV;
  495. d->extra = 0;
  496. while ((findev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
  497. if ((findev->vendor == dev->vendor) &&
  498. (findev->device == dev->device) &&
  499. (PCI_SLOT(findev->devfn) & 2)) {
  500. if (findev->irq != dev->irq) {
  501. findev->irq = dev->irq;
  502. }
  503. ret = ide_setup_pci_devices(dev, findev, d);
  504. pci_dev_put(findev);
  505. return ret;
  506. }
  507. }
  508. }
  509. return ide_setup_pci_device(dev, d);
  510. }
  511. static int __devinit init_setup_pdc20276(struct pci_dev *dev,
  512. ide_pci_device_t *d)
  513. {
  514. if ((dev->bus->self) &&
  515. (dev->bus->self->vendor == PCI_VENDOR_ID_INTEL) &&
  516. ((dev->bus->self->device == PCI_DEVICE_ID_INTEL_I960) ||
  517. (dev->bus->self->device == PCI_DEVICE_ID_INTEL_I960RM))) {
  518. printk(KERN_INFO "ide: Skipping Promise PDC20276 "
  519. "attached to I2O RAID controller.\n");
  520. return -ENODEV;
  521. }
  522. return ide_setup_pci_device(dev, d);
  523. }
  524. static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
  525. { /* 0 */
  526. .name = "PDC20268",
  527. .init_setup = init_setup_pdcnew,
  528. .init_chipset = init_chipset_pdcnew,
  529. .init_hwif = init_hwif_pdc202new,
  530. .channels = 2,
  531. .autodma = AUTODMA,
  532. .bootable = OFF_BOARD,
  533. },{ /* 1 */
  534. .name = "PDC20269",
  535. .init_setup = init_setup_pdcnew,
  536. .init_chipset = init_chipset_pdcnew,
  537. .init_hwif = init_hwif_pdc202new,
  538. .channels = 2,
  539. .autodma = AUTODMA,
  540. .bootable = OFF_BOARD,
  541. },{ /* 2 */
  542. .name = "PDC20270",
  543. .init_setup = init_setup_pdc20270,
  544. .init_chipset = init_chipset_pdcnew,
  545. .init_hwif = init_hwif_pdc202new,
  546. .channels = 2,
  547. .autodma = AUTODMA,
  548. .bootable = OFF_BOARD,
  549. },{ /* 3 */
  550. .name = "PDC20271",
  551. .init_setup = init_setup_pdcnew,
  552. .init_chipset = init_chipset_pdcnew,
  553. .init_hwif = init_hwif_pdc202new,
  554. .channels = 2,
  555. .autodma = AUTODMA,
  556. .bootable = OFF_BOARD,
  557. },{ /* 4 */
  558. .name = "PDC20275",
  559. .init_setup = init_setup_pdcnew,
  560. .init_chipset = init_chipset_pdcnew,
  561. .init_hwif = init_hwif_pdc202new,
  562. .channels = 2,
  563. .autodma = AUTODMA,
  564. .bootable = OFF_BOARD,
  565. },{ /* 5 */
  566. .name = "PDC20276",
  567. .init_setup = init_setup_pdc20276,
  568. .init_chipset = init_chipset_pdcnew,
  569. .init_hwif = init_hwif_pdc202new,
  570. .channels = 2,
  571. .autodma = AUTODMA,
  572. .bootable = OFF_BOARD,
  573. },{ /* 6 */
  574. .name = "PDC20277",
  575. .init_setup = init_setup_pdcnew,
  576. .init_chipset = init_chipset_pdcnew,
  577. .init_hwif = init_hwif_pdc202new,
  578. .channels = 2,
  579. .autodma = AUTODMA,
  580. .bootable = OFF_BOARD,
  581. }
  582. };
  583. /**
  584. * pdc202new_init_one - called when a pdc202xx is found
  585. * @dev: the pdc202new device
  586. * @id: the matching pci id
  587. *
  588. * Called when the PCI registration layer (or the IDE initialization)
  589. * finds a device matching our IDE device tables.
  590. */
  591. static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  592. {
  593. ide_pci_device_t *d = &pdcnew_chipsets[id->driver_data];
  594. return d->init_setup(dev, d);
  595. }
  596. static struct pci_device_id pdc202new_pci_tbl[] = {
  597. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20268, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  598. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20269, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
  599. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
  600. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20271, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
  601. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20275, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  602. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20276, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5},
  603. { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20277, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6},
  604. { 0, },
  605. };
  606. MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl);
  607. static struct pci_driver driver = {
  608. .name = "Promise_IDE",
  609. .id_table = pdc202new_pci_tbl,
  610. .probe = pdc202new_init_one,
  611. };
  612. static int __init pdc202new_ide_init(void)
  613. {
  614. return ide_pci_register_driver(&driver);
  615. }
  616. module_init(pdc202new_ide_init);
  617. MODULE_AUTHOR("Andre Hedrick, Frank Tiernan");
  618. MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher");
  619. MODULE_LICENSE("GPL");