pdc202xx_new.c 18 KB

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