pata_hpt37x.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. * Libata driver for the highpoint 37x and 30x UDMA66 ATA controllers.
  3. *
  4. * This driver is heavily based upon:
  5. *
  6. * linux/drivers/ide/pci/hpt366.c Version 0.36 April 25, 2003
  7. *
  8. * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
  9. * Portions Copyright (C) 2001 Sun Microsystems, Inc.
  10. * Portions Copyright (C) 2003 Red Hat Inc
  11. * Portions Copyright (C) 2005-2006 MontaVista Software, Inc.
  12. *
  13. * TODO
  14. * PLL mode
  15. * Look into engine reset on timeout errors. Should not be
  16. * required.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/pci.h>
  21. #include <linux/init.h>
  22. #include <linux/blkdev.h>
  23. #include <linux/delay.h>
  24. #include <scsi/scsi_host.h>
  25. #include <linux/libata.h>
  26. #define DRV_NAME "pata_hpt37x"
  27. #define DRV_VERSION "0.6.4"
  28. struct hpt_clock {
  29. u8 xfer_speed;
  30. u32 timing;
  31. };
  32. struct hpt_chip {
  33. const char *name;
  34. unsigned int base;
  35. struct hpt_clock const *clocks[4];
  36. };
  37. /* key for bus clock timings
  38. * bit
  39. * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW
  40. * DMA. cycles = value + 1
  41. * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW
  42. * DMA. cycles = value + 1
  43. * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file
  44. * register access.
  45. * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file
  46. * register access.
  47. * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer.
  48. * during task file register access.
  49. * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA
  50. * xfer.
  51. * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task
  52. * register access.
  53. * 28 UDMA enable
  54. * 29 DMA enable
  55. * 30 PIO_MST enable. if set, the chip is in bus master mode during
  56. * PIO.
  57. * 31 FIFO enable.
  58. */
  59. static struct hpt_clock hpt37x_timings_33[] = {
  60. { XFER_UDMA_6, 0x12446231 }, /* 0x12646231 ?? */
  61. { XFER_UDMA_5, 0x12446231 },
  62. { XFER_UDMA_4, 0x12446231 },
  63. { XFER_UDMA_3, 0x126c6231 },
  64. { XFER_UDMA_2, 0x12486231 },
  65. { XFER_UDMA_1, 0x124c6233 },
  66. { XFER_UDMA_0, 0x12506297 },
  67. { XFER_MW_DMA_2, 0x22406c31 },
  68. { XFER_MW_DMA_1, 0x22406c33 },
  69. { XFER_MW_DMA_0, 0x22406c97 },
  70. { XFER_PIO_4, 0x06414e31 },
  71. { XFER_PIO_3, 0x06414e42 },
  72. { XFER_PIO_2, 0x06414e53 },
  73. { XFER_PIO_1, 0x06814e93 },
  74. { XFER_PIO_0, 0x06814ea7 }
  75. };
  76. static struct hpt_clock hpt37x_timings_50[] = {
  77. { XFER_UDMA_6, 0x12848242 },
  78. { XFER_UDMA_5, 0x12848242 },
  79. { XFER_UDMA_4, 0x12ac8242 },
  80. { XFER_UDMA_3, 0x128c8242 },
  81. { XFER_UDMA_2, 0x120c8242 },
  82. { XFER_UDMA_1, 0x12148254 },
  83. { XFER_UDMA_0, 0x121882ea },
  84. { XFER_MW_DMA_2, 0x22808242 },
  85. { XFER_MW_DMA_1, 0x22808254 },
  86. { XFER_MW_DMA_0, 0x228082ea },
  87. { XFER_PIO_4, 0x0a81f442 },
  88. { XFER_PIO_3, 0x0a81f443 },
  89. { XFER_PIO_2, 0x0a81f454 },
  90. { XFER_PIO_1, 0x0ac1f465 },
  91. { XFER_PIO_0, 0x0ac1f48a }
  92. };
  93. static struct hpt_clock hpt37x_timings_66[] = {
  94. { XFER_UDMA_6, 0x1c869c62 },
  95. { XFER_UDMA_5, 0x1cae9c62 }, /* 0x1c8a9c62 */
  96. { XFER_UDMA_4, 0x1c8a9c62 },
  97. { XFER_UDMA_3, 0x1c8e9c62 },
  98. { XFER_UDMA_2, 0x1c929c62 },
  99. { XFER_UDMA_1, 0x1c9a9c62 },
  100. { XFER_UDMA_0, 0x1c829c62 },
  101. { XFER_MW_DMA_2, 0x2c829c62 },
  102. { XFER_MW_DMA_1, 0x2c829c66 },
  103. { XFER_MW_DMA_0, 0x2c829d2e },
  104. { XFER_PIO_4, 0x0c829c62 },
  105. { XFER_PIO_3, 0x0c829c84 },
  106. { XFER_PIO_2, 0x0c829ca6 },
  107. { XFER_PIO_1, 0x0d029d26 },
  108. { XFER_PIO_0, 0x0d029d5e }
  109. };
  110. static const struct hpt_chip hpt370 = {
  111. "HPT370",
  112. 48,
  113. {
  114. hpt37x_timings_33,
  115. NULL,
  116. NULL,
  117. hpt37x_timings_66
  118. }
  119. };
  120. static const struct hpt_chip hpt370a = {
  121. "HPT370A",
  122. 48,
  123. {
  124. hpt37x_timings_33,
  125. NULL,
  126. hpt37x_timings_50,
  127. hpt37x_timings_66
  128. }
  129. };
  130. static const struct hpt_chip hpt372 = {
  131. "HPT372",
  132. 55,
  133. {
  134. hpt37x_timings_33,
  135. NULL,
  136. hpt37x_timings_50,
  137. hpt37x_timings_66
  138. }
  139. };
  140. static const struct hpt_chip hpt302 = {
  141. "HPT302",
  142. 66,
  143. {
  144. hpt37x_timings_33,
  145. NULL,
  146. hpt37x_timings_50,
  147. hpt37x_timings_66
  148. }
  149. };
  150. static const struct hpt_chip hpt371 = {
  151. "HPT371",
  152. 66,
  153. {
  154. hpt37x_timings_33,
  155. NULL,
  156. hpt37x_timings_50,
  157. hpt37x_timings_66
  158. }
  159. };
  160. static const struct hpt_chip hpt372a = {
  161. "HPT372A",
  162. 66,
  163. {
  164. hpt37x_timings_33,
  165. NULL,
  166. hpt37x_timings_50,
  167. hpt37x_timings_66
  168. }
  169. };
  170. static const struct hpt_chip hpt374 = {
  171. "HPT374",
  172. 48,
  173. {
  174. hpt37x_timings_33,
  175. NULL,
  176. NULL,
  177. NULL
  178. }
  179. };
  180. /**
  181. * hpt37x_find_mode - reset the hpt37x bus
  182. * @ap: ATA port
  183. * @speed: transfer mode
  184. *
  185. * Return the 32bit register programming information for this channel
  186. * that matches the speed provided.
  187. */
  188. static u32 hpt37x_find_mode(struct ata_port *ap, int speed)
  189. {
  190. struct hpt_clock *clocks = ap->host->private_data;
  191. while(clocks->xfer_speed) {
  192. if (clocks->xfer_speed == speed)
  193. return clocks->timing;
  194. clocks++;
  195. }
  196. BUG();
  197. return 0xffffffffU; /* silence compiler warning */
  198. }
  199. static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[])
  200. {
  201. unsigned char model_num[ATA_ID_PROD_LEN + 1];
  202. int i = 0;
  203. ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
  204. while (list[i] != NULL) {
  205. if (!strcmp(list[i], model_num)) {
  206. printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",
  207. modestr, list[i]);
  208. return 1;
  209. }
  210. i++;
  211. }
  212. return 0;
  213. }
  214. static const char *bad_ata33[] = {
  215. "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2",
  216. "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2",
  217. "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4",
  218. "Maxtor 90510D4",
  219. "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2",
  220. "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4",
  221. "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2",
  222. NULL
  223. };
  224. static const char *bad_ata100_5[] = {
  225. "IBM-DTLA-307075",
  226. "IBM-DTLA-307060",
  227. "IBM-DTLA-307045",
  228. "IBM-DTLA-307030",
  229. "IBM-DTLA-307020",
  230. "IBM-DTLA-307015",
  231. "IBM-DTLA-305040",
  232. "IBM-DTLA-305030",
  233. "IBM-DTLA-305020",
  234. "IC35L010AVER07-0",
  235. "IC35L020AVER07-0",
  236. "IC35L030AVER07-0",
  237. "IC35L040AVER07-0",
  238. "IC35L060AVER07-0",
  239. "WDC AC310200R",
  240. NULL
  241. };
  242. /**
  243. * hpt370_filter - mode selection filter
  244. * @ap: ATA interface
  245. * @adev: ATA device
  246. *
  247. * Block UDMA on devices that cause trouble with this controller.
  248. */
  249. static unsigned long hpt370_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
  250. {
  251. if (adev->class == ATA_DEV_ATA) {
  252. if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
  253. mask &= ~ATA_MASK_UDMA;
  254. if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
  255. mask &= ~(0x1F << ATA_SHIFT_UDMA);
  256. }
  257. return ata_pci_default_filter(ap, adev, mask);
  258. }
  259. /**
  260. * hpt370a_filter - mode selection filter
  261. * @ap: ATA interface
  262. * @adev: ATA device
  263. *
  264. * Block UDMA on devices that cause trouble with this controller.
  265. */
  266. static unsigned long hpt370a_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
  267. {
  268. if (adev->class != ATA_DEV_ATA) {
  269. if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
  270. mask &= ~ (0x1F << ATA_SHIFT_UDMA);
  271. }
  272. return ata_pci_default_filter(ap, adev, mask);
  273. }
  274. /**
  275. * hpt37x_pre_reset - reset the hpt37x bus
  276. * @ap: ATA port to reset
  277. *
  278. * Perform the initial reset handling for the 370/372 and 374 func 0
  279. */
  280. static int hpt37x_pre_reset(struct ata_port *ap)
  281. {
  282. u8 scr2, ata66;
  283. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  284. static const struct pci_bits hpt37x_enable_bits[] = {
  285. { 0x50, 1, 0x04, 0x04 },
  286. { 0x54, 1, 0x04, 0x04 }
  287. };
  288. if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
  289. return -ENOENT;
  290. pci_read_config_byte(pdev, 0x5B, &scr2);
  291. pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
  292. /* Cable register now active */
  293. pci_read_config_byte(pdev, 0x5A, &ata66);
  294. /* Restore state */
  295. pci_write_config_byte(pdev, 0x5B, scr2);
  296. if (ata66 & (1 << ap->port_no))
  297. ap->cbl = ATA_CBL_PATA40;
  298. else
  299. ap->cbl = ATA_CBL_PATA80;
  300. /* Reset the state machine */
  301. pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
  302. udelay(100);
  303. return ata_std_prereset(ap);
  304. }
  305. /**
  306. * hpt37x_error_handler - reset the hpt374
  307. * @ap: ATA port to reset
  308. *
  309. * Perform probe for HPT37x, except for HPT374 channel 2
  310. */
  311. static void hpt37x_error_handler(struct ata_port *ap)
  312. {
  313. ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
  314. }
  315. static int hpt374_pre_reset(struct ata_port *ap)
  316. {
  317. static const struct pci_bits hpt37x_enable_bits[] = {
  318. { 0x50, 1, 0x04, 0x04 },
  319. { 0x54, 1, 0x04, 0x04 }
  320. };
  321. u16 mcr3, mcr6;
  322. u8 ata66;
  323. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  324. if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
  325. return -ENOENT;
  326. /* Do the extra channel work */
  327. pci_read_config_word(pdev, 0x52, &mcr3);
  328. pci_read_config_word(pdev, 0x56, &mcr6);
  329. /* Set bit 15 of 0x52 to enable TCBLID as input
  330. Set bit 15 of 0x56 to enable FCBLID as input
  331. */
  332. pci_write_config_word(pdev, 0x52, mcr3 | 0x8000);
  333. pci_write_config_word(pdev, 0x56, mcr6 | 0x8000);
  334. pci_read_config_byte(pdev, 0x5A, &ata66);
  335. /* Reset TCBLID/FCBLID to output */
  336. pci_write_config_word(pdev, 0x52, mcr3);
  337. pci_write_config_word(pdev, 0x56, mcr6);
  338. if (ata66 & (1 << ap->port_no))
  339. ap->cbl = ATA_CBL_PATA40;
  340. else
  341. ap->cbl = ATA_CBL_PATA80;
  342. /* Reset the state machine */
  343. pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
  344. udelay(100);
  345. return ata_std_prereset(ap);
  346. }
  347. /**
  348. * hpt374_error_handler - reset the hpt374
  349. * @classes:
  350. *
  351. * The 374 cable detect is a little different due to the extra
  352. * channels. The function 0 channels work like usual but function 1
  353. * is special
  354. */
  355. static void hpt374_error_handler(struct ata_port *ap)
  356. {
  357. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  358. if (!(PCI_FUNC(pdev->devfn) & 1))
  359. hpt37x_error_handler(ap);
  360. else
  361. ata_bmdma_drive_eh(ap, hpt374_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
  362. }
  363. /**
  364. * hpt370_set_piomode - PIO setup
  365. * @ap: ATA interface
  366. * @adev: device on the interface
  367. *
  368. * Perform PIO mode setup.
  369. */
  370. static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
  371. {
  372. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  373. u32 addr1, addr2;
  374. u32 reg;
  375. u32 mode;
  376. u8 fast;
  377. addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
  378. addr2 = 0x51 + 4 * ap->port_no;
  379. /* Fast interrupt prediction disable, hold off interrupt disable */
  380. pci_read_config_byte(pdev, addr2, &fast);
  381. fast &= ~0x02;
  382. fast |= 0x01;
  383. pci_write_config_byte(pdev, addr2, fast);
  384. pci_read_config_dword(pdev, addr1, &reg);
  385. mode = hpt37x_find_mode(ap, adev->pio_mode);
  386. mode &= ~0x8000000; /* No FIFO in PIO */
  387. mode &= ~0x30070000; /* Leave config bits alone */
  388. reg &= 0x30070000; /* Strip timing bits */
  389. pci_write_config_dword(pdev, addr1, reg | mode);
  390. }
  391. /**
  392. * hpt370_set_dmamode - DMA timing setup
  393. * @ap: ATA interface
  394. * @adev: Device being configured
  395. *
  396. * Set up the channel for MWDMA or UDMA modes. Much the same as with
  397. * PIO, load the mode number and then set MWDMA or UDMA flag.
  398. */
  399. static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
  400. {
  401. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  402. u32 addr1, addr2;
  403. u32 reg;
  404. u32 mode;
  405. u8 fast;
  406. addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
  407. addr2 = 0x51 + 4 * ap->port_no;
  408. /* Fast interrupt prediction disable, hold off interrupt disable */
  409. pci_read_config_byte(pdev, addr2, &fast);
  410. fast &= ~0x02;
  411. fast |= 0x01;
  412. pci_write_config_byte(pdev, addr2, fast);
  413. pci_read_config_dword(pdev, addr1, &reg);
  414. mode = hpt37x_find_mode(ap, adev->dma_mode);
  415. mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
  416. mode &= ~0xC0000000; /* Leave config bits alone */
  417. reg &= 0xC0000000; /* Strip timing bits */
  418. pci_write_config_dword(pdev, addr1, reg | mode);
  419. }
  420. /**
  421. * hpt370_bmdma_start - DMA engine begin
  422. * @qc: ATA command
  423. *
  424. * The 370 and 370A want us to reset the DMA engine each time we
  425. * use it. The 372 and later are fine.
  426. */
  427. static void hpt370_bmdma_start(struct ata_queued_cmd *qc)
  428. {
  429. struct ata_port *ap = qc->ap;
  430. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  431. pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
  432. udelay(10);
  433. ata_bmdma_start(qc);
  434. }
  435. /**
  436. * hpt370_bmdma_end - DMA engine stop
  437. * @qc: ATA command
  438. *
  439. * Work around the HPT370 DMA engine.
  440. */
  441. static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
  442. {
  443. struct ata_port *ap = qc->ap;
  444. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  445. u8 dma_stat = ioread8(ap->ioaddr.bmdma_addr + 2);
  446. u8 dma_cmd;
  447. void __iomem *bmdma = ap->ioaddr.bmdma_addr;
  448. if (dma_stat & 0x01) {
  449. udelay(20);
  450. dma_stat = ioread8(bmdma + 2);
  451. }
  452. if (dma_stat & 0x01) {
  453. /* Clear the engine */
  454. pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
  455. udelay(10);
  456. /* Stop DMA */
  457. dma_cmd = ioread8(bmdma );
  458. iowrite8(dma_cmd & 0xFE, bmdma);
  459. /* Clear Error */
  460. dma_stat = ioread8(bmdma + 2);
  461. iowrite8(dma_stat | 0x06 , bmdma + 2);
  462. /* Clear the engine */
  463. pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
  464. udelay(10);
  465. }
  466. ata_bmdma_stop(qc);
  467. }
  468. /**
  469. * hpt372_set_piomode - PIO setup
  470. * @ap: ATA interface
  471. * @adev: device on the interface
  472. *
  473. * Perform PIO mode setup.
  474. */
  475. static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
  476. {
  477. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  478. u32 addr1, addr2;
  479. u32 reg;
  480. u32 mode;
  481. u8 fast;
  482. addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
  483. addr2 = 0x51 + 4 * ap->port_no;
  484. /* Fast interrupt prediction disable, hold off interrupt disable */
  485. pci_read_config_byte(pdev, addr2, &fast);
  486. fast &= ~0x07;
  487. pci_write_config_byte(pdev, addr2, fast);
  488. pci_read_config_dword(pdev, addr1, &reg);
  489. mode = hpt37x_find_mode(ap, adev->pio_mode);
  490. printk("Find mode for %d reports %X\n", adev->pio_mode, mode);
  491. mode &= ~0x80000000; /* No FIFO in PIO */
  492. mode &= ~0x30070000; /* Leave config bits alone */
  493. reg &= 0x30070000; /* Strip timing bits */
  494. pci_write_config_dword(pdev, addr1, reg | mode);
  495. }
  496. /**
  497. * hpt372_set_dmamode - DMA timing setup
  498. * @ap: ATA interface
  499. * @adev: Device being configured
  500. *
  501. * Set up the channel for MWDMA or UDMA modes. Much the same as with
  502. * PIO, load the mode number and then set MWDMA or UDMA flag.
  503. */
  504. static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
  505. {
  506. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  507. u32 addr1, addr2;
  508. u32 reg;
  509. u32 mode;
  510. u8 fast;
  511. addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
  512. addr2 = 0x51 + 4 * ap->port_no;
  513. /* Fast interrupt prediction disable, hold off interrupt disable */
  514. pci_read_config_byte(pdev, addr2, &fast);
  515. fast &= ~0x07;
  516. pci_write_config_byte(pdev, addr2, fast);
  517. pci_read_config_dword(pdev, addr1, &reg);
  518. mode = hpt37x_find_mode(ap, adev->dma_mode);
  519. printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode);
  520. mode &= ~0xC0000000; /* Leave config bits alone */
  521. mode |= 0x80000000; /* FIFO in MWDMA or UDMA */
  522. reg &= 0xC0000000; /* Strip timing bits */
  523. pci_write_config_dword(pdev, addr1, reg | mode);
  524. }
  525. /**
  526. * hpt37x_bmdma_end - DMA engine stop
  527. * @qc: ATA command
  528. *
  529. * Clean up after the HPT372 and later DMA engine
  530. */
  531. static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc)
  532. {
  533. struct ata_port *ap = qc->ap;
  534. struct pci_dev *pdev = to_pci_dev(ap->host->dev);
  535. int mscreg = 0x50 + 4 * ap->port_no;
  536. u8 bwsr_stat, msc_stat;
  537. pci_read_config_byte(pdev, 0x6A, &bwsr_stat);
  538. pci_read_config_byte(pdev, mscreg, &msc_stat);
  539. if (bwsr_stat & (1 << ap->port_no))
  540. pci_write_config_byte(pdev, mscreg, msc_stat | 0x30);
  541. ata_bmdma_stop(qc);
  542. }
  543. static struct scsi_host_template hpt37x_sht = {
  544. .module = THIS_MODULE,
  545. .name = DRV_NAME,
  546. .ioctl = ata_scsi_ioctl,
  547. .queuecommand = ata_scsi_queuecmd,
  548. .can_queue = ATA_DEF_QUEUE,
  549. .this_id = ATA_SHT_THIS_ID,
  550. .sg_tablesize = LIBATA_MAX_PRD,
  551. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  552. .emulated = ATA_SHT_EMULATED,
  553. .use_clustering = ATA_SHT_USE_CLUSTERING,
  554. .proc_name = DRV_NAME,
  555. .dma_boundary = ATA_DMA_BOUNDARY,
  556. .slave_configure = ata_scsi_slave_config,
  557. .slave_destroy = ata_scsi_slave_destroy,
  558. .bios_param = ata_std_bios_param,
  559. };
  560. /*
  561. * Configuration for HPT370
  562. */
  563. static struct ata_port_operations hpt370_port_ops = {
  564. .port_disable = ata_port_disable,
  565. .set_piomode = hpt370_set_piomode,
  566. .set_dmamode = hpt370_set_dmamode,
  567. .mode_filter = hpt370_filter,
  568. .tf_load = ata_tf_load,
  569. .tf_read = ata_tf_read,
  570. .check_status = ata_check_status,
  571. .exec_command = ata_exec_command,
  572. .dev_select = ata_std_dev_select,
  573. .freeze = ata_bmdma_freeze,
  574. .thaw = ata_bmdma_thaw,
  575. .error_handler = hpt37x_error_handler,
  576. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  577. .bmdma_setup = ata_bmdma_setup,
  578. .bmdma_start = hpt370_bmdma_start,
  579. .bmdma_stop = hpt370_bmdma_stop,
  580. .bmdma_status = ata_bmdma_status,
  581. .qc_prep = ata_qc_prep,
  582. .qc_issue = ata_qc_issue_prot,
  583. .data_xfer = ata_data_xfer,
  584. .irq_handler = ata_interrupt,
  585. .irq_clear = ata_bmdma_irq_clear,
  586. .irq_on = ata_irq_on,
  587. .irq_ack = ata_irq_ack,
  588. .port_start = ata_port_start,
  589. };
  590. /*
  591. * Configuration for HPT370A. Close to 370 but less filters
  592. */
  593. static struct ata_port_operations hpt370a_port_ops = {
  594. .port_disable = ata_port_disable,
  595. .set_piomode = hpt370_set_piomode,
  596. .set_dmamode = hpt370_set_dmamode,
  597. .mode_filter = hpt370a_filter,
  598. .tf_load = ata_tf_load,
  599. .tf_read = ata_tf_read,
  600. .check_status = ata_check_status,
  601. .exec_command = ata_exec_command,
  602. .dev_select = ata_std_dev_select,
  603. .freeze = ata_bmdma_freeze,
  604. .thaw = ata_bmdma_thaw,
  605. .error_handler = hpt37x_error_handler,
  606. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  607. .bmdma_setup = ata_bmdma_setup,
  608. .bmdma_start = hpt370_bmdma_start,
  609. .bmdma_stop = hpt370_bmdma_stop,
  610. .bmdma_status = ata_bmdma_status,
  611. .qc_prep = ata_qc_prep,
  612. .qc_issue = ata_qc_issue_prot,
  613. .data_xfer = ata_data_xfer,
  614. .irq_handler = ata_interrupt,
  615. .irq_clear = ata_bmdma_irq_clear,
  616. .irq_on = ata_irq_on,
  617. .irq_ack = ata_irq_ack,
  618. .port_start = ata_port_start,
  619. };
  620. /*
  621. * Configuration for HPT372, HPT371, HPT302. Slightly different PIO
  622. * and DMA mode setting functionality.
  623. */
  624. static struct ata_port_operations hpt372_port_ops = {
  625. .port_disable = ata_port_disable,
  626. .set_piomode = hpt372_set_piomode,
  627. .set_dmamode = hpt372_set_dmamode,
  628. .mode_filter = ata_pci_default_filter,
  629. .tf_load = ata_tf_load,
  630. .tf_read = ata_tf_read,
  631. .check_status = ata_check_status,
  632. .exec_command = ata_exec_command,
  633. .dev_select = ata_std_dev_select,
  634. .freeze = ata_bmdma_freeze,
  635. .thaw = ata_bmdma_thaw,
  636. .error_handler = hpt37x_error_handler,
  637. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  638. .bmdma_setup = ata_bmdma_setup,
  639. .bmdma_start = ata_bmdma_start,
  640. .bmdma_stop = hpt37x_bmdma_stop,
  641. .bmdma_status = ata_bmdma_status,
  642. .qc_prep = ata_qc_prep,
  643. .qc_issue = ata_qc_issue_prot,
  644. .data_xfer = ata_data_xfer,
  645. .irq_handler = ata_interrupt,
  646. .irq_clear = ata_bmdma_irq_clear,
  647. .irq_on = ata_irq_on,
  648. .irq_ack = ata_irq_ack,
  649. .port_start = ata_port_start,
  650. };
  651. /*
  652. * Configuration for HPT374. Mode setting works like 372 and friends
  653. * but we have a different cable detection procedure.
  654. */
  655. static struct ata_port_operations hpt374_port_ops = {
  656. .port_disable = ata_port_disable,
  657. .set_piomode = hpt372_set_piomode,
  658. .set_dmamode = hpt372_set_dmamode,
  659. .mode_filter = ata_pci_default_filter,
  660. .tf_load = ata_tf_load,
  661. .tf_read = ata_tf_read,
  662. .check_status = ata_check_status,
  663. .exec_command = ata_exec_command,
  664. .dev_select = ata_std_dev_select,
  665. .freeze = ata_bmdma_freeze,
  666. .thaw = ata_bmdma_thaw,
  667. .error_handler = hpt374_error_handler,
  668. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  669. .bmdma_setup = ata_bmdma_setup,
  670. .bmdma_start = ata_bmdma_start,
  671. .bmdma_stop = hpt37x_bmdma_stop,
  672. .bmdma_status = ata_bmdma_status,
  673. .qc_prep = ata_qc_prep,
  674. .qc_issue = ata_qc_issue_prot,
  675. .data_xfer = ata_data_xfer,
  676. .irq_handler = ata_interrupt,
  677. .irq_clear = ata_bmdma_irq_clear,
  678. .irq_on = ata_irq_on,
  679. .irq_ack = ata_irq_ack,
  680. .port_start = ata_port_start,
  681. };
  682. /**
  683. * htp37x_clock_slot - Turn timing to PC clock entry
  684. * @freq: Reported frequency timing
  685. * @base: Base timing
  686. *
  687. * Turn the timing data intoa clock slot (0 for 33, 1 for 40, 2 for 50
  688. * and 3 for 66Mhz)
  689. */
  690. static int hpt37x_clock_slot(unsigned int freq, unsigned int base)
  691. {
  692. unsigned int f = (base * freq) / 192; /* Mhz */
  693. if (f < 40)
  694. return 0; /* 33Mhz slot */
  695. if (f < 45)
  696. return 1; /* 40Mhz slot */
  697. if (f < 55)
  698. return 2; /* 50Mhz slot */
  699. return 3; /* 60Mhz slot */
  700. }
  701. /**
  702. * hpt37x_calibrate_dpll - Calibrate the DPLL loop
  703. * @dev: PCI device
  704. *
  705. * Perform a calibration cycle on the HPT37x DPLL. Returns 1 if this
  706. * succeeds
  707. */
  708. static int hpt37x_calibrate_dpll(struct pci_dev *dev)
  709. {
  710. u8 reg5b;
  711. u32 reg5c;
  712. int tries;
  713. for(tries = 0; tries < 0x5000; tries++) {
  714. udelay(50);
  715. pci_read_config_byte(dev, 0x5b, &reg5b);
  716. if (reg5b & 0x80) {
  717. /* See if it stays set */
  718. for(tries = 0; tries < 0x1000; tries ++) {
  719. pci_read_config_byte(dev, 0x5b, &reg5b);
  720. /* Failed ? */
  721. if ((reg5b & 0x80) == 0)
  722. return 0;
  723. }
  724. /* Turn off tuning, we have the DPLL set */
  725. pci_read_config_dword(dev, 0x5c, &reg5c);
  726. pci_write_config_dword(dev, 0x5c, reg5c & ~ 0x100);
  727. return 1;
  728. }
  729. }
  730. /* Never went stable */
  731. return 0;
  732. }
  733. /**
  734. * hpt37x_init_one - Initialise an HPT37X/302
  735. * @dev: PCI device
  736. * @id: Entry in match table
  737. *
  738. * Initialise an HPT37x device. There are some interesting complications
  739. * here. Firstly the chip may report 366 and be one of several variants.
  740. * Secondly all the timings depend on the clock for the chip which we must
  741. * detect and look up
  742. *
  743. * This is the known chip mappings. It may be missing a couple of later
  744. * releases.
  745. *
  746. * Chip version PCI Rev Notes
  747. * HPT366 4 (HPT366) 0 Other driver
  748. * HPT366 4 (HPT366) 1 Other driver
  749. * HPT368 4 (HPT366) 2 Other driver
  750. * HPT370 4 (HPT366) 3 UDMA100
  751. * HPT370A 4 (HPT366) 4 UDMA100
  752. * HPT372 4 (HPT366) 5 UDMA133 (1)
  753. * HPT372N 4 (HPT366) 6 Other driver
  754. * HPT372A 5 (HPT372) 1 UDMA133 (1)
  755. * HPT372N 5 (HPT372) 2 Other driver
  756. * HPT302 6 (HPT302) 1 UDMA133
  757. * HPT302N 6 (HPT302) 2 Other driver
  758. * HPT371 7 (HPT371) * UDMA133
  759. * HPT374 8 (HPT374) * UDMA133 4 channel
  760. * HPT372N 9 (HPT372N) * Other driver
  761. *
  762. * (1) UDMA133 support depends on the bus clock
  763. */
  764. static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  765. {
  766. /* HPT370 - UDMA100 */
  767. static struct ata_port_info info_hpt370 = {
  768. .sht = &hpt37x_sht,
  769. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  770. .pio_mask = 0x1f,
  771. .mwdma_mask = 0x07,
  772. .udma_mask = 0x3f,
  773. .port_ops = &hpt370_port_ops
  774. };
  775. /* HPT370A - UDMA100 */
  776. static struct ata_port_info info_hpt370a = {
  777. .sht = &hpt37x_sht,
  778. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  779. .pio_mask = 0x1f,
  780. .mwdma_mask = 0x07,
  781. .udma_mask = 0x3f,
  782. .port_ops = &hpt370a_port_ops
  783. };
  784. /* HPT370 - UDMA100 */
  785. static struct ata_port_info info_hpt370_33 = {
  786. .sht = &hpt37x_sht,
  787. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  788. .pio_mask = 0x1f,
  789. .mwdma_mask = 0x07,
  790. .udma_mask = 0x0f,
  791. .port_ops = &hpt370_port_ops
  792. };
  793. /* HPT370A - UDMA100 */
  794. static struct ata_port_info info_hpt370a_33 = {
  795. .sht = &hpt37x_sht,
  796. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  797. .pio_mask = 0x1f,
  798. .mwdma_mask = 0x07,
  799. .udma_mask = 0x0f,
  800. .port_ops = &hpt370a_port_ops
  801. };
  802. /* HPT371, 372 and friends - UDMA133 */
  803. static struct ata_port_info info_hpt372 = {
  804. .sht = &hpt37x_sht,
  805. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  806. .pio_mask = 0x1f,
  807. .mwdma_mask = 0x07,
  808. .udma_mask = 0x7f,
  809. .port_ops = &hpt372_port_ops
  810. };
  811. /* HPT371, 372 and friends - UDMA100 at 50MHz clock */
  812. static struct ata_port_info info_hpt372_50 = {
  813. .sht = &hpt37x_sht,
  814. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  815. .pio_mask = 0x1f,
  816. .mwdma_mask = 0x07,
  817. .udma_mask = 0x3f,
  818. .port_ops = &hpt372_port_ops
  819. };
  820. /* HPT374 - UDMA133 */
  821. static struct ata_port_info info_hpt374 = {
  822. .sht = &hpt37x_sht,
  823. .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
  824. .pio_mask = 0x1f,
  825. .mwdma_mask = 0x07,
  826. .udma_mask = 0x7f,
  827. .port_ops = &hpt374_port_ops
  828. };
  829. static const int MHz[4] = { 33, 40, 50, 66 };
  830. struct ata_port_info *port_info[2];
  831. struct ata_port_info *port;
  832. u8 irqmask;
  833. u32 class_rev;
  834. u8 mcr1;
  835. u32 freq;
  836. int prefer_dpll = 1;
  837. unsigned long iobase = pci_resource_start(dev, 4);
  838. const struct hpt_chip *chip_table;
  839. int clock_slot;
  840. pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
  841. class_rev &= 0xFF;
  842. if (dev->device == PCI_DEVICE_ID_TTI_HPT366) {
  843. /* May be a later chip in disguise. Check */
  844. /* Older chips are in the HPT366 driver. Ignore them */
  845. if (class_rev < 3)
  846. return -ENODEV;
  847. /* N series chips have their own driver. Ignore */
  848. if (class_rev == 6)
  849. return -ENODEV;
  850. switch(class_rev) {
  851. case 3:
  852. port = &info_hpt370;
  853. chip_table = &hpt370;
  854. prefer_dpll = 0;
  855. break;
  856. case 4:
  857. port = &info_hpt370a;
  858. chip_table = &hpt370a;
  859. prefer_dpll = 0;
  860. break;
  861. case 5:
  862. port = &info_hpt372;
  863. chip_table = &hpt372;
  864. break;
  865. default:
  866. printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype please report (%d).\n", class_rev);
  867. return -ENODEV;
  868. }
  869. } else {
  870. switch(dev->device) {
  871. case PCI_DEVICE_ID_TTI_HPT372:
  872. /* 372N if rev >= 2*/
  873. if (class_rev >= 2)
  874. return -ENODEV;
  875. port = &info_hpt372;
  876. chip_table = &hpt372a;
  877. break;
  878. case PCI_DEVICE_ID_TTI_HPT302:
  879. /* 302N if rev > 1 */
  880. if (class_rev > 1)
  881. return -ENODEV;
  882. port = &info_hpt372;
  883. /* Check this */
  884. chip_table = &hpt302;
  885. break;
  886. case PCI_DEVICE_ID_TTI_HPT371:
  887. if (class_rev > 1)
  888. return -ENODEV;
  889. port = &info_hpt372;
  890. chip_table = &hpt371;
  891. /* Single channel device, paster is not present
  892. but the NIOS (or us for non x86) must mark it
  893. absent */
  894. pci_read_config_byte(dev, 0x50, &mcr1);
  895. mcr1 &= ~0x04;
  896. pci_write_config_byte(dev, 0x50, mcr1);
  897. break;
  898. case PCI_DEVICE_ID_TTI_HPT374:
  899. chip_table = &hpt374;
  900. port = &info_hpt374;
  901. break;
  902. default:
  903. printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device);
  904. return -ENODEV;
  905. }
  906. }
  907. /* Ok so this is a chip we support */
  908. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
  909. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
  910. pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
  911. pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
  912. pci_read_config_byte(dev, 0x5A, &irqmask);
  913. irqmask &= ~0x10;
  914. pci_write_config_byte(dev, 0x5a, irqmask);
  915. /*
  916. * default to pci clock. make sure MA15/16 are set to output
  917. * to prevent drives having problems with 40-pin cables. Needed
  918. * for some drives such as IBM-DTLA which will not enter ready
  919. * state on reset when PDIAG is a input.
  920. */
  921. pci_write_config_byte(dev, 0x5b, 0x23);
  922. /*
  923. * HighPoint does this for HPT372A.
  924. * NOTE: This register is only writeable via I/O space.
  925. */
  926. if (chip_table == &hpt372a)
  927. outb(0x0e, iobase + 0x9c);
  928. /* Some devices do not let this value be accessed via PCI space
  929. according to the old driver */
  930. freq = inl(iobase + 0x90);
  931. if ((freq >> 12) != 0xABCDE) {
  932. int i;
  933. u8 sr;
  934. u32 total = 0;
  935. printk(KERN_WARNING "pata_hpt37x: BIOS has not set timing clocks.\n");
  936. /* This is the process the HPT371 BIOS is reported to use */
  937. for(i = 0; i < 128; i++) {
  938. pci_read_config_byte(dev, 0x78, &sr);
  939. total += sr & 0x1FF;
  940. udelay(15);
  941. }
  942. freq = total / 128;
  943. }
  944. freq &= 0x1FF;
  945. /*
  946. * Turn the frequency check into a band and then find a timing
  947. * table to match it.
  948. */
  949. clock_slot = hpt37x_clock_slot(freq, chip_table->base);
  950. if (chip_table->clocks[clock_slot] == NULL || prefer_dpll) {
  951. /*
  952. * We need to try PLL mode instead
  953. *
  954. * For non UDMA133 capable devices we should
  955. * use a 50MHz DPLL by choice
  956. */
  957. unsigned int f_low, f_high;
  958. int adjust;
  959. clock_slot = 2;
  960. if (port->udma_mask & 0xE0)
  961. clock_slot = 3;
  962. f_low = (MHz[clock_slot] * chip_table->base) / 192;
  963. f_high = f_low + 2;
  964. /* Select the DPLL clock. */
  965. pci_write_config_byte(dev, 0x5b, 0x21);
  966. for(adjust = 0; adjust < 8; adjust++) {
  967. if (hpt37x_calibrate_dpll(dev))
  968. break;
  969. /* See if it'll settle at a fractionally different clock */
  970. if ((adjust & 3) == 3) {
  971. f_low --;
  972. f_high ++;
  973. }
  974. pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
  975. }
  976. if (adjust == 8) {
  977. printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n");
  978. return -ENODEV;
  979. }
  980. if (clock_slot == 3)
  981. port->private_data = (void *)hpt37x_timings_66;
  982. else
  983. port->private_data = (void *)hpt37x_timings_50;
  984. printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]);
  985. } else {
  986. port->private_data = (void *)chip_table->clocks[clock_slot];
  987. /*
  988. * Perform a final fixup. The 371 and 372 clock determines
  989. * if UDMA133 is available. (FIXME: should we use DPLL then ?)
  990. */
  991. if (clock_slot == 2 && chip_table == &hpt372) { /* 50Mhz */
  992. printk(KERN_WARNING "pata_hpt37x: No UDMA133 support available with 50MHz bus clock.\n");
  993. if (port == &info_hpt372)
  994. port = &info_hpt372_50;
  995. else BUG();
  996. }
  997. if (clock_slot < 2 && port == &info_hpt370)
  998. port = &info_hpt370_33;
  999. if (clock_slot < 2 && port == &info_hpt370a)
  1000. port = &info_hpt370a_33;
  1001. printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]);
  1002. }
  1003. port_info[0] = port_info[1] = port;
  1004. /* Now kick off ATA set up */
  1005. return ata_pci_init_one(dev, port_info, 2);
  1006. }
  1007. static const struct pci_device_id hpt37x[] = {
  1008. { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), },
  1009. { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT371), },
  1010. { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), },
  1011. { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT374), },
  1012. { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), },
  1013. { },
  1014. };
  1015. static struct pci_driver hpt37x_pci_driver = {
  1016. .name = DRV_NAME,
  1017. .id_table = hpt37x,
  1018. .probe = hpt37x_init_one,
  1019. .remove = ata_pci_remove_one
  1020. };
  1021. static int __init hpt37x_init(void)
  1022. {
  1023. return pci_register_driver(&hpt37x_pci_driver);
  1024. }
  1025. static void __exit hpt37x_exit(void)
  1026. {
  1027. pci_unregister_driver(&hpt37x_pci_driver);
  1028. }
  1029. MODULE_AUTHOR("Alan Cox");
  1030. MODULE_DESCRIPTION("low-level driver for the Highpoint HPT37x/30x");
  1031. MODULE_LICENSE("GPL");
  1032. MODULE_DEVICE_TABLE(pci, hpt37x);
  1033. MODULE_VERSION(DRV_VERSION);
  1034. module_init(hpt37x_init);
  1035. module_exit(hpt37x_exit);