hpt366.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. /*
  2. * linux/drivers/ide/pci/hpt366.c Version 1.01 Dec 23, 2006
  3. *
  4. * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
  5. * Portions Copyright (C) 2001 Sun Microsystems, Inc.
  6. * Portions Copyright (C) 2003 Red Hat Inc
  7. * Portions Copyright (C) 2005-2006 MontaVista Software, Inc.
  8. *
  9. * Thanks to HighPoint Technologies for their assistance, and hardware.
  10. * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
  11. * donation of an ABit BP6 mainboard, processor, and memory acellerated
  12. * development and support.
  13. *
  14. *
  15. * HighPoint has its own drivers (open source except for the RAID part)
  16. * available from http://www.highpoint-tech.com/BIOS%20+%20Driver/.
  17. * This may be useful to anyone wanting to work on this driver, however do not
  18. * trust them too much since the code tends to become less and less meaningful
  19. * as the time passes... :-/
  20. *
  21. * Note that final HPT370 support was done by force extraction of GPL.
  22. *
  23. * - add function for getting/setting power status of drive
  24. * - the HPT370's state machine can get confused. reset it before each dma
  25. * xfer to prevent that from happening.
  26. * - reset state engine whenever we get an error.
  27. * - check for busmaster state at end of dma.
  28. * - use new highpoint timings.
  29. * - detect bus speed using highpoint register.
  30. * - use pll if we don't have a clock table. added a 66MHz table that's
  31. * just 2x the 33MHz table.
  32. * - removed turnaround. NOTE: we never want to switch between pll and
  33. * pci clocks as the chip can glitch in those cases. the highpoint
  34. * approved workaround slows everything down too much to be useful. in
  35. * addition, we would have to serialize access to each chip.
  36. * Adrian Sun <a.sun@sun.com>
  37. *
  38. * add drive timings for 66MHz PCI bus,
  39. * fix ATA Cable signal detection, fix incorrect /proc info
  40. * add /proc display for per-drive PIO/DMA/UDMA mode and
  41. * per-channel ATA-33/66 Cable detect.
  42. * Duncan Laurie <void@sun.com>
  43. *
  44. * fixup /proc output for multiple controllers
  45. * Tim Hockin <thockin@sun.com>
  46. *
  47. * On hpt366:
  48. * Reset the hpt366 on error, reset on dma
  49. * Fix disabling Fast Interrupt hpt366.
  50. * Mike Waychison <crlf@sun.com>
  51. *
  52. * Added support for 372N clocking and clock switching. The 372N needs
  53. * different clocks on read/write. This requires overloading rw_disk and
  54. * other deeply crazy things. Thanks to <http://www.hoerstreich.de> for
  55. * keeping me sane.
  56. * Alan Cox <alan@redhat.com>
  57. *
  58. * - fix the clock turnaround code: it was writing to the wrong ports when
  59. * called for the secondary channel, caching the current clock mode per-
  60. * channel caused the cached register value to get out of sync with the
  61. * actual one, the channels weren't serialized, the turnaround shouldn't
  62. * be done on 66 MHz PCI bus
  63. * - disable UltraATA/100 for HPT370 by default as the 33 MHz clock being used
  64. * does not allow for this speed anyway
  65. * - avoid touching disabled channels (e.g. HPT371/N are single channel chips,
  66. * their primary channel is kind of virtual, it isn't tied to any pins)
  67. * - fix/remove bad/unused timing tables and use one set of tables for the whole
  68. * HPT37x chip family; save space by introducing the separate transfer mode
  69. * table in which the mode lookup is done
  70. * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives
  71. * the wrong PCI frequency since DPLL has already been calibrated by BIOS
  72. * - fix the hotswap code: it caused RESET- to glitch when tristating the bus,
  73. * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead
  74. * - pass to init_chipset() handlers a copy of the IDE PCI device structure as
  75. * they tamper with its fields
  76. * - pass to the init_setup handlers a copy of the ide_pci_device_t structure
  77. * since they may tamper with its fields
  78. * - prefix the driver startup messages with the real chip name
  79. * - claim the extra 240 bytes of I/O space for all chips
  80. * - optimize the rate masking/filtering and the drive list lookup code
  81. * - use pci_get_slot() to get to the function 1 of HPT36x/374
  82. * - cache offset of the channel's misc. control registers (MCRs) being used
  83. * throughout the driver
  84. * - only touch the relevant MCR when detecting the cable type on HPT374's
  85. * function 1
  86. * - rename all the register related variables consistently
  87. * - move all the interrupt twiddling code from the speedproc handlers into
  88. * init_hwif_hpt366(), also grouping all the DMA related code together there
  89. * - merge two HPT37x speedproc handlers, fix the PIO timing register mask and
  90. * separate the UltraDMA and MWDMA masks there to avoid changing PIO timings
  91. * when setting an UltraDMA mode
  92. * - fix hpt3xx_tune_drive() to set the PIO mode requested, not always select
  93. * the best possible one
  94. * - clean up DMA timeout handling for HPT370
  95. * - switch to using the enumeration type to differ between the numerous chip
  96. * variants, matching PCI device/revision ID with the chip type early, at the
  97. * init_setup stage
  98. * - extend the hpt_info structure to hold the DPLL and PCI clock frequencies,
  99. * stop duplicating it for each channel by storing the pointer in the pci_dev
  100. * structure: first, at the init_setup stage, point it to a static "template"
  101. * with only the chip type and its specific base DPLL frequency, the highest
  102. * supported DMA mode, and the chip settings table pointer filled, then, at
  103. * the init_chipset stage, allocate per-chip instance and fill it with the
  104. * rest of the necessary information
  105. * - get rid of the constant thresholds in the HPT37x PCI clock detection code,
  106. * switch to calculating PCI clock frequency based on the chip's base DPLL
  107. * frequency
  108. * - switch to using the DPLL clock and enable UltraATA/133 mode by default on
  109. * anything newer than HPT370/A
  110. * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(),
  111. * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips;
  112. * unify HPT36x/37x timing setup code and the speedproc handlers by joining
  113. * the register setting lists into the table indexed by the clock selected
  114. * Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com>
  115. */
  116. #include <linux/types.h>
  117. #include <linux/module.h>
  118. #include <linux/kernel.h>
  119. #include <linux/delay.h>
  120. #include <linux/timer.h>
  121. #include <linux/mm.h>
  122. #include <linux/ioport.h>
  123. #include <linux/blkdev.h>
  124. #include <linux/hdreg.h>
  125. #include <linux/interrupt.h>
  126. #include <linux/pci.h>
  127. #include <linux/init.h>
  128. #include <linux/ide.h>
  129. #include <asm/uaccess.h>
  130. #include <asm/io.h>
  131. #include <asm/irq.h>
  132. /* various tuning parameters */
  133. #define HPT_RESET_STATE_ENGINE
  134. #undef HPT_DELAY_INTERRUPT
  135. #define HPT_SERIALIZE_IO 0
  136. static const char *quirk_drives[] = {
  137. "QUANTUM FIREBALLlct08 08",
  138. "QUANTUM FIREBALLP KA6.4",
  139. "QUANTUM FIREBALLP LM20.4",
  140. "QUANTUM FIREBALLP LM20.5",
  141. NULL
  142. };
  143. static const char *bad_ata100_5[] = {
  144. "IBM-DTLA-307075",
  145. "IBM-DTLA-307060",
  146. "IBM-DTLA-307045",
  147. "IBM-DTLA-307030",
  148. "IBM-DTLA-307020",
  149. "IBM-DTLA-307015",
  150. "IBM-DTLA-305040",
  151. "IBM-DTLA-305030",
  152. "IBM-DTLA-305020",
  153. "IC35L010AVER07-0",
  154. "IC35L020AVER07-0",
  155. "IC35L030AVER07-0",
  156. "IC35L040AVER07-0",
  157. "IC35L060AVER07-0",
  158. "WDC AC310200R",
  159. NULL
  160. };
  161. static const char *bad_ata66_4[] = {
  162. "IBM-DTLA-307075",
  163. "IBM-DTLA-307060",
  164. "IBM-DTLA-307045",
  165. "IBM-DTLA-307030",
  166. "IBM-DTLA-307020",
  167. "IBM-DTLA-307015",
  168. "IBM-DTLA-305040",
  169. "IBM-DTLA-305030",
  170. "IBM-DTLA-305020",
  171. "IC35L010AVER07-0",
  172. "IC35L020AVER07-0",
  173. "IC35L030AVER07-0",
  174. "IC35L040AVER07-0",
  175. "IC35L060AVER07-0",
  176. "WDC AC310200R",
  177. NULL
  178. };
  179. static const char *bad_ata66_3[] = {
  180. "WDC AC310200R",
  181. NULL
  182. };
  183. static const char *bad_ata33[] = {
  184. "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2",
  185. "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2",
  186. "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4",
  187. "Maxtor 90510D4",
  188. "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2",
  189. "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4",
  190. "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2",
  191. NULL
  192. };
  193. static u8 xfer_speeds[] = {
  194. XFER_UDMA_6,
  195. XFER_UDMA_5,
  196. XFER_UDMA_4,
  197. XFER_UDMA_3,
  198. XFER_UDMA_2,
  199. XFER_UDMA_1,
  200. XFER_UDMA_0,
  201. XFER_MW_DMA_2,
  202. XFER_MW_DMA_1,
  203. XFER_MW_DMA_0,
  204. XFER_PIO_4,
  205. XFER_PIO_3,
  206. XFER_PIO_2,
  207. XFER_PIO_1,
  208. XFER_PIO_0
  209. };
  210. /* Key for bus clock timings
  211. * 36x 37x
  212. * bits bits
  213. * 0:3 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA.
  214. * cycles = value + 1
  215. * 4:7 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA.
  216. * cycles = value + 1
  217. * 8:11 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file
  218. * register access.
  219. * 12:15 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file
  220. * register access.
  221. * 16:18 18:20 udma_cycle_time. Clock cycles for UDMA xfer.
  222. * - 21 CLK frequency: 0=ATA clock, 1=dual ATA clock.
  223. * 19:21 22:24 pre_high_time. Time to initialize the 1st cycle for PIO and
  224. * MW DMA xfer.
  225. * 22:24 25:27 cmd_pre_high_time. Time to initialize the 1st PIO cycle for
  226. * task file register access.
  227. * 28 28 UDMA enable.
  228. * 29 29 DMA enable.
  229. * 30 30 PIO MST enable. If set, the chip is in bus master mode during
  230. * PIO xfer.
  231. * 31 31 FIFO enable.
  232. */
  233. static u32 forty_base_hpt36x[] = {
  234. /* XFER_UDMA_6 */ 0x900fd943,
  235. /* XFER_UDMA_5 */ 0x900fd943,
  236. /* XFER_UDMA_4 */ 0x900fd943,
  237. /* XFER_UDMA_3 */ 0x900ad943,
  238. /* XFER_UDMA_2 */ 0x900bd943,
  239. /* XFER_UDMA_1 */ 0x9008d943,
  240. /* XFER_UDMA_0 */ 0x9008d943,
  241. /* XFER_MW_DMA_2 */ 0xa008d943,
  242. /* XFER_MW_DMA_1 */ 0xa010d955,
  243. /* XFER_MW_DMA_0 */ 0xa010d9fc,
  244. /* XFER_PIO_4 */ 0xc008d963,
  245. /* XFER_PIO_3 */ 0xc010d974,
  246. /* XFER_PIO_2 */ 0xc010d997,
  247. /* XFER_PIO_1 */ 0xc010d9c7,
  248. /* XFER_PIO_0 */ 0xc018d9d9
  249. };
  250. static u32 thirty_three_base_hpt36x[] = {
  251. /* XFER_UDMA_6 */ 0x90c9a731,
  252. /* XFER_UDMA_5 */ 0x90c9a731,
  253. /* XFER_UDMA_4 */ 0x90c9a731,
  254. /* XFER_UDMA_3 */ 0x90cfa731,
  255. /* XFER_UDMA_2 */ 0x90caa731,
  256. /* XFER_UDMA_1 */ 0x90cba731,
  257. /* XFER_UDMA_0 */ 0x90c8a731,
  258. /* XFER_MW_DMA_2 */ 0xa0c8a731,
  259. /* XFER_MW_DMA_1 */ 0xa0c8a732, /* 0xa0c8a733 */
  260. /* XFER_MW_DMA_0 */ 0xa0c8a797,
  261. /* XFER_PIO_4 */ 0xc0c8a731,
  262. /* XFER_PIO_3 */ 0xc0c8a742,
  263. /* XFER_PIO_2 */ 0xc0d0a753,
  264. /* XFER_PIO_1 */ 0xc0d0a7a3, /* 0xc0d0a793 */
  265. /* XFER_PIO_0 */ 0xc0d0a7aa /* 0xc0d0a7a7 */
  266. };
  267. static u32 twenty_five_base_hpt36x[] = {
  268. /* XFER_UDMA_6 */ 0x90c98521,
  269. /* XFER_UDMA_5 */ 0x90c98521,
  270. /* XFER_UDMA_4 */ 0x90c98521,
  271. /* XFER_UDMA_3 */ 0x90cf8521,
  272. /* XFER_UDMA_2 */ 0x90cf8521,
  273. /* XFER_UDMA_1 */ 0x90cb8521,
  274. /* XFER_UDMA_0 */ 0x90cb8521,
  275. /* XFER_MW_DMA_2 */ 0xa0ca8521,
  276. /* XFER_MW_DMA_1 */ 0xa0ca8532,
  277. /* XFER_MW_DMA_0 */ 0xa0ca8575,
  278. /* XFER_PIO_4 */ 0xc0ca8521,
  279. /* XFER_PIO_3 */ 0xc0ca8532,
  280. /* XFER_PIO_2 */ 0xc0ca8542,
  281. /* XFER_PIO_1 */ 0xc0d08572,
  282. /* XFER_PIO_0 */ 0xc0d08585
  283. };
  284. static u32 thirty_three_base_hpt37x[] = {
  285. /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */
  286. /* XFER_UDMA_5 */ 0x12446231,
  287. /* XFER_UDMA_4 */ 0x12446231,
  288. /* XFER_UDMA_3 */ 0x126c6231,
  289. /* XFER_UDMA_2 */ 0x12486231,
  290. /* XFER_UDMA_1 */ 0x124c6233,
  291. /* XFER_UDMA_0 */ 0x12506297,
  292. /* XFER_MW_DMA_2 */ 0x22406c31,
  293. /* XFER_MW_DMA_1 */ 0x22406c33,
  294. /* XFER_MW_DMA_0 */ 0x22406c97,
  295. /* XFER_PIO_4 */ 0x06414e31,
  296. /* XFER_PIO_3 */ 0x06414e42,
  297. /* XFER_PIO_2 */ 0x06414e53,
  298. /* XFER_PIO_1 */ 0x06814e93,
  299. /* XFER_PIO_0 */ 0x06814ea7
  300. };
  301. static u32 fifty_base_hpt37x[] = {
  302. /* XFER_UDMA_6 */ 0x12848242,
  303. /* XFER_UDMA_5 */ 0x12848242,
  304. /* XFER_UDMA_4 */ 0x12ac8242,
  305. /* XFER_UDMA_3 */ 0x128c8242,
  306. /* XFER_UDMA_2 */ 0x120c8242,
  307. /* XFER_UDMA_1 */ 0x12148254,
  308. /* XFER_UDMA_0 */ 0x121882ea,
  309. /* XFER_MW_DMA_2 */ 0x22808242,
  310. /* XFER_MW_DMA_1 */ 0x22808254,
  311. /* XFER_MW_DMA_0 */ 0x228082ea,
  312. /* XFER_PIO_4 */ 0x0a81f442,
  313. /* XFER_PIO_3 */ 0x0a81f443,
  314. /* XFER_PIO_2 */ 0x0a81f454,
  315. /* XFER_PIO_1 */ 0x0ac1f465,
  316. /* XFER_PIO_0 */ 0x0ac1f48a
  317. };
  318. static u32 sixty_six_base_hpt37x[] = {
  319. /* XFER_UDMA_6 */ 0x1c869c62,
  320. /* XFER_UDMA_5 */ 0x1cae9c62, /* 0x1c8a9c62 */
  321. /* XFER_UDMA_4 */ 0x1c8a9c62,
  322. /* XFER_UDMA_3 */ 0x1c8e9c62,
  323. /* XFER_UDMA_2 */ 0x1c929c62,
  324. /* XFER_UDMA_1 */ 0x1c9a9c62,
  325. /* XFER_UDMA_0 */ 0x1c829c62,
  326. /* XFER_MW_DMA_2 */ 0x2c829c62,
  327. /* XFER_MW_DMA_1 */ 0x2c829c66,
  328. /* XFER_MW_DMA_0 */ 0x2c829d2e,
  329. /* XFER_PIO_4 */ 0x0c829c62,
  330. /* XFER_PIO_3 */ 0x0c829c84,
  331. /* XFER_PIO_2 */ 0x0c829ca6,
  332. /* XFER_PIO_1 */ 0x0d029d26,
  333. /* XFER_PIO_0 */ 0x0d029d5e
  334. };
  335. #define HPT366_DEBUG_DRIVE_INFO 0
  336. #define HPT374_ALLOW_ATA133_6 1
  337. #define HPT371_ALLOW_ATA133_6 1
  338. #define HPT302_ALLOW_ATA133_6 1
  339. #define HPT372_ALLOW_ATA133_6 1
  340. #define HPT370_ALLOW_ATA100_5 0
  341. #define HPT366_ALLOW_ATA66_4 1
  342. #define HPT366_ALLOW_ATA66_3 1
  343. #define HPT366_MAX_DEVS 8
  344. /* Supported ATA clock frequencies */
  345. enum ata_clock {
  346. ATA_CLOCK_25MHZ,
  347. ATA_CLOCK_33MHZ,
  348. ATA_CLOCK_40MHZ,
  349. ATA_CLOCK_50MHZ,
  350. ATA_CLOCK_66MHZ,
  351. NUM_ATA_CLOCKS
  352. };
  353. /*
  354. * Hold all the HighPoint chip information in one place.
  355. */
  356. struct hpt_info {
  357. u8 chip_type; /* Chip type */
  358. u8 max_mode; /* Speeds allowed */
  359. u8 dpll_clk; /* DPLL clock in MHz */
  360. u8 pci_clk; /* PCI clock in MHz */
  361. u32 **settings; /* Chipset settings table */
  362. };
  363. /* Supported HighPoint chips */
  364. enum {
  365. HPT36x,
  366. HPT370,
  367. HPT370A,
  368. HPT374,
  369. HPT372,
  370. HPT372A,
  371. HPT302,
  372. HPT371,
  373. HPT372N,
  374. HPT302N,
  375. HPT371N
  376. };
  377. static u32 *hpt36x_settings[NUM_ATA_CLOCKS] = {
  378. twenty_five_base_hpt36x,
  379. thirty_three_base_hpt36x,
  380. forty_base_hpt36x,
  381. NULL,
  382. NULL
  383. };
  384. static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = {
  385. NULL,
  386. thirty_three_base_hpt37x,
  387. NULL,
  388. fifty_base_hpt37x,
  389. sixty_six_base_hpt37x
  390. };
  391. static struct hpt_info hpt36x __devinitdata = {
  392. .chip_type = HPT36x,
  393. .max_mode = (HPT366_ALLOW_ATA66_4 || HPT366_ALLOW_ATA66_3) ? 2 : 1,
  394. .dpll_clk = 0, /* no DPLL */
  395. .settings = hpt36x_settings
  396. };
  397. static struct hpt_info hpt370 __devinitdata = {
  398. .chip_type = HPT370,
  399. .max_mode = HPT370_ALLOW_ATA100_5 ? 3 : 2,
  400. .dpll_clk = 48,
  401. .settings = hpt37x_settings
  402. };
  403. static struct hpt_info hpt370a __devinitdata = {
  404. .chip_type = HPT370A,
  405. .max_mode = HPT370_ALLOW_ATA100_5 ? 3 : 2,
  406. .dpll_clk = 48,
  407. .settings = hpt37x_settings
  408. };
  409. static struct hpt_info hpt374 __devinitdata = {
  410. .chip_type = HPT374,
  411. .max_mode = HPT374_ALLOW_ATA133_6 ? 4 : 3,
  412. .dpll_clk = 48,
  413. .settings = hpt37x_settings
  414. };
  415. static struct hpt_info hpt372 __devinitdata = {
  416. .chip_type = HPT372,
  417. .max_mode = HPT372_ALLOW_ATA133_6 ? 4 : 3,
  418. .dpll_clk = 55,
  419. .settings = hpt37x_settings
  420. };
  421. static struct hpt_info hpt372a __devinitdata = {
  422. .chip_type = HPT372A,
  423. .max_mode = HPT372_ALLOW_ATA133_6 ? 4 : 3,
  424. .dpll_clk = 66,
  425. .settings = hpt37x_settings
  426. };
  427. static struct hpt_info hpt302 __devinitdata = {
  428. .chip_type = HPT302,
  429. .max_mode = HPT302_ALLOW_ATA133_6 ? 4 : 3,
  430. .dpll_clk = 66,
  431. .settings = hpt37x_settings
  432. };
  433. static struct hpt_info hpt371 __devinitdata = {
  434. .chip_type = HPT371,
  435. .max_mode = HPT371_ALLOW_ATA133_6 ? 4 : 3,
  436. .dpll_clk = 66,
  437. .settings = hpt37x_settings
  438. };
  439. static struct hpt_info hpt372n __devinitdata = {
  440. .chip_type = HPT372N,
  441. .max_mode = HPT372_ALLOW_ATA133_6 ? 4 : 3,
  442. .dpll_clk = 77,
  443. .settings = hpt37x_settings
  444. };
  445. static struct hpt_info hpt302n __devinitdata = {
  446. .chip_type = HPT302N,
  447. .max_mode = HPT302_ALLOW_ATA133_6 ? 4 : 3,
  448. .dpll_clk = 77,
  449. };
  450. static struct hpt_info hpt371n __devinitdata = {
  451. .chip_type = HPT371N,
  452. .max_mode = HPT371_ALLOW_ATA133_6 ? 4 : 3,
  453. .dpll_clk = 77,
  454. .settings = hpt37x_settings
  455. };
  456. static int check_in_drive_list(ide_drive_t *drive, const char **list)
  457. {
  458. struct hd_driveid *id = drive->id;
  459. while (*list)
  460. if (!strcmp(*list++,id->model))
  461. return 1;
  462. return 0;
  463. }
  464. static u8 hpt3xx_ratemask(ide_drive_t *drive)
  465. {
  466. struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev);
  467. u8 mode = info->max_mode;
  468. if (!eighty_ninty_three(drive) && mode)
  469. mode = min(mode, (u8)1);
  470. return mode;
  471. }
  472. /*
  473. * Note for the future; the SATA hpt37x we must set
  474. * either PIO or UDMA modes 0,4,5
  475. */
  476. static u8 hpt3xx_ratefilter(ide_drive_t *drive, u8 speed)
  477. {
  478. struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev);
  479. u8 chip_type = info->chip_type;
  480. u8 mode = hpt3xx_ratemask(drive);
  481. if (drive->media != ide_disk)
  482. return min(speed, (u8)XFER_PIO_4);
  483. switch (mode) {
  484. case 0x04:
  485. speed = min_t(u8, speed, XFER_UDMA_6);
  486. break;
  487. case 0x03:
  488. speed = min_t(u8, speed, XFER_UDMA_5);
  489. if (chip_type >= HPT374)
  490. break;
  491. if (!check_in_drive_list(drive, bad_ata100_5))
  492. goto check_bad_ata33;
  493. /* fall thru */
  494. case 0x02:
  495. speed = min_t(u8, speed, XFER_UDMA_4);
  496. /*
  497. * CHECK ME, Does this need to be changed to HPT374 ??
  498. */
  499. if (chip_type >= HPT370)
  500. goto check_bad_ata33;
  501. if (HPT366_ALLOW_ATA66_4 &&
  502. !check_in_drive_list(drive, bad_ata66_4))
  503. goto check_bad_ata33;
  504. speed = min_t(u8, speed, XFER_UDMA_3);
  505. if (HPT366_ALLOW_ATA66_3 &&
  506. !check_in_drive_list(drive, bad_ata66_3))
  507. goto check_bad_ata33;
  508. /* fall thru */
  509. case 0x01:
  510. speed = min_t(u8, speed, XFER_UDMA_2);
  511. check_bad_ata33:
  512. if (chip_type >= HPT370A)
  513. break;
  514. if (!check_in_drive_list(drive, bad_ata33))
  515. break;
  516. /* fall thru */
  517. case 0x00:
  518. default:
  519. speed = min_t(u8, speed, XFER_MW_DMA_2);
  520. break;
  521. }
  522. return speed;
  523. }
  524. static u32 get_speed_setting(u8 speed, struct hpt_info *info)
  525. {
  526. int i;
  527. /*
  528. * Lookup the transfer mode table to get the index into
  529. * the timing table.
  530. *
  531. * NOTE: For XFER_PIO_SLOW, PIO mode 0 timings will be used.
  532. */
  533. for (i = 0; i < ARRAY_SIZE(xfer_speeds) - 1; i++)
  534. if (xfer_speeds[i] == speed)
  535. break;
  536. /*
  537. * NOTE: info->settings only points to the pointer
  538. * to the list of the actual register values
  539. */
  540. return (*info->settings)[i];
  541. }
  542. static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
  543. {
  544. ide_hwif_t *hwif = HWIF(drive);
  545. struct pci_dev *dev = hwif->pci_dev;
  546. struct hpt_info *info = pci_get_drvdata(dev);
  547. u8 speed = hpt3xx_ratefilter(drive, xferspeed);
  548. u8 itr_addr = drive->dn ? 0x44 : 0x40;
  549. u32 itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 :
  550. (speed < XFER_UDMA_0 ? 0xc0070000 : 0xc03800ff);
  551. u32 new_itr = get_speed_setting(speed, info);
  552. u32 old_itr = 0;
  553. /*
  554. * Disable on-chip PIO FIFO/buffer (and PIO MST mode as well)
  555. * to avoid problems handling I/O errors later
  556. */
  557. pci_read_config_dword(dev, itr_addr, &old_itr);
  558. new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask);
  559. new_itr &= ~0xc0000000;
  560. pci_write_config_dword(dev, itr_addr, new_itr);
  561. return ide_config_drive_speed(drive, speed);
  562. }
  563. static int hpt37x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
  564. {
  565. ide_hwif_t *hwif = HWIF(drive);
  566. struct pci_dev *dev = hwif->pci_dev;
  567. struct hpt_info *info = pci_get_drvdata(dev);
  568. u8 speed = hpt3xx_ratefilter(drive, xferspeed);
  569. u8 itr_addr = 0x40 + (drive->dn * 4);
  570. u32 itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 :
  571. (speed < XFER_UDMA_0 ? 0xc03c0000 : 0xc1c001ff);
  572. u32 new_itr = get_speed_setting(speed, info);
  573. u32 old_itr = 0;
  574. pci_read_config_dword(dev, itr_addr, &old_itr);
  575. new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask);
  576. if (speed < XFER_MW_DMA_0)
  577. new_itr &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */
  578. pci_write_config_dword(dev, itr_addr, new_itr);
  579. return ide_config_drive_speed(drive, speed);
  580. }
  581. static int hpt3xx_tune_chipset(ide_drive_t *drive, u8 speed)
  582. {
  583. ide_hwif_t *hwif = HWIF(drive);
  584. struct hpt_info *info = pci_get_drvdata(hwif->pci_dev);
  585. if (info->chip_type >= HPT370)
  586. return hpt37x_tune_chipset(drive, speed);
  587. else /* hpt368: hpt_minimum_revision(dev, 2) */
  588. return hpt36x_tune_chipset(drive, speed);
  589. }
  590. static void hpt3xx_tune_drive(ide_drive_t *drive, u8 pio)
  591. {
  592. pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
  593. (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio);
  594. }
  595. /*
  596. * This allows the configuration of ide_pci chipset registers
  597. * for cards that learn about the drive's UDMA, DMA, PIO capabilities
  598. * after the drive is reported by the OS. Initially designed for
  599. * HPT366 UDMA chipset by HighPoint|Triones Technologies, Inc.
  600. *
  601. */
  602. static int config_chipset_for_dma(ide_drive_t *drive)
  603. {
  604. u8 speed = ide_dma_speed(drive, hpt3xx_ratemask(drive));
  605. if (!speed)
  606. return 0;
  607. (void) hpt3xx_tune_chipset(drive, speed);
  608. return ide_dma_enable(drive);
  609. }
  610. static int hpt3xx_quirkproc(ide_drive_t *drive)
  611. {
  612. struct hd_driveid *id = drive->id;
  613. const char **list = quirk_drives;
  614. while (*list)
  615. if (strstr(id->model, *list++))
  616. return 1;
  617. return 0;
  618. }
  619. static void hpt3xx_intrproc(ide_drive_t *drive)
  620. {
  621. ide_hwif_t *hwif = HWIF(drive);
  622. if (drive->quirk_list)
  623. return;
  624. /* drives in the quirk_list may not like intr setups/cleanups */
  625. hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
  626. }
  627. static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
  628. {
  629. ide_hwif_t *hwif = HWIF(drive);
  630. struct pci_dev *dev = hwif->pci_dev;
  631. struct hpt_info *info = pci_get_drvdata(dev);
  632. if (drive->quirk_list) {
  633. if (info->chip_type >= HPT370) {
  634. u8 scr1 = 0;
  635. pci_read_config_byte(dev, 0x5a, &scr1);
  636. if (((scr1 & 0x10) >> 4) != mask) {
  637. if (mask)
  638. scr1 |= 0x10;
  639. else
  640. scr1 &= ~0x10;
  641. pci_write_config_byte(dev, 0x5a, scr1);
  642. }
  643. } else {
  644. if (mask)
  645. disable_irq(hwif->irq);
  646. else
  647. enable_irq (hwif->irq);
  648. }
  649. } else
  650. hwif->OUTB(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
  651. IDE_CONTROL_REG);
  652. }
  653. static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
  654. {
  655. ide_hwif_t *hwif = HWIF(drive);
  656. struct hd_driveid *id = drive->id;
  657. drive->init_speed = 0;
  658. if ((id->capability & 1) && drive->autodma) {
  659. if (ide_use_dma(drive) && config_chipset_for_dma(drive))
  660. return hwif->ide_dma_on(drive);
  661. goto fast_ata_pio;
  662. } else if ((id->capability & 8) || (id->field_valid & 2)) {
  663. fast_ata_pio:
  664. hpt3xx_tune_drive(drive, 255);
  665. return hwif->ide_dma_off_quietly(drive);
  666. }
  667. /* IORDY not supported */
  668. return 0;
  669. }
  670. /*
  671. * This is specific to the HPT366 UDMA chipset
  672. * by HighPoint|Triones Technologies, Inc.
  673. */
  674. static int hpt366_ide_dma_lostirq(ide_drive_t *drive)
  675. {
  676. struct pci_dev *dev = HWIF(drive)->pci_dev;
  677. u8 mcr1 = 0, mcr3 = 0, scr1 = 0;
  678. pci_read_config_byte(dev, 0x50, &mcr1);
  679. pci_read_config_byte(dev, 0x52, &mcr3);
  680. pci_read_config_byte(dev, 0x5a, &scr1);
  681. printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n",
  682. drive->name, __FUNCTION__, mcr1, mcr3, scr1);
  683. if (scr1 & 0x10)
  684. pci_write_config_byte(dev, 0x5a, scr1 & ~0x10);
  685. return __ide_dma_lostirq(drive);
  686. }
  687. static void hpt370_clear_engine(ide_drive_t *drive)
  688. {
  689. ide_hwif_t *hwif = HWIF(drive);
  690. pci_write_config_byte(hwif->pci_dev, hwif->select_data, 0x37);
  691. udelay(10);
  692. }
  693. static void hpt370_irq_timeout(ide_drive_t *drive)
  694. {
  695. ide_hwif_t *hwif = HWIF(drive);
  696. u16 bfifo = 0;
  697. u8 dma_cmd;
  698. pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo);
  699. printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff);
  700. /* get DMA command mode */
  701. dma_cmd = hwif->INB(hwif->dma_command);
  702. /* stop DMA */
  703. hwif->OUTB(dma_cmd & ~0x1, hwif->dma_command);
  704. hpt370_clear_engine(drive);
  705. }
  706. static void hpt370_ide_dma_start(ide_drive_t *drive)
  707. {
  708. #ifdef HPT_RESET_STATE_ENGINE
  709. hpt370_clear_engine(drive);
  710. #endif
  711. ide_dma_start(drive);
  712. }
  713. static int hpt370_ide_dma_end(ide_drive_t *drive)
  714. {
  715. ide_hwif_t *hwif = HWIF(drive);
  716. u8 dma_stat = hwif->INB(hwif->dma_status);
  717. if (dma_stat & 0x01) {
  718. /* wait a little */
  719. udelay(20);
  720. dma_stat = hwif->INB(hwif->dma_status);
  721. if (dma_stat & 0x01)
  722. hpt370_irq_timeout(drive);
  723. }
  724. return __ide_dma_end(drive);
  725. }
  726. static int hpt370_ide_dma_timeout(ide_drive_t *drive)
  727. {
  728. hpt370_irq_timeout(drive);
  729. return __ide_dma_timeout(drive);
  730. }
  731. /* returns 1 if DMA IRQ issued, 0 otherwise */
  732. static int hpt374_ide_dma_test_irq(ide_drive_t *drive)
  733. {
  734. ide_hwif_t *hwif = HWIF(drive);
  735. u16 bfifo = 0;
  736. u8 dma_stat;
  737. pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo);
  738. if (bfifo & 0x1FF) {
  739. // printk("%s: %d bytes in FIFO\n", drive->name, bfifo);
  740. return 0;
  741. }
  742. dma_stat = hwif->INB(hwif->dma_status);
  743. /* return 1 if INTR asserted */
  744. if (dma_stat & 4)
  745. return 1;
  746. if (!drive->waiting_for_dma)
  747. printk(KERN_WARNING "%s: (%s) called while not waiting\n",
  748. drive->name, __FUNCTION__);
  749. return 0;
  750. }
  751. static int hpt374_ide_dma_end(ide_drive_t *drive)
  752. {
  753. ide_hwif_t *hwif = HWIF(drive);
  754. struct pci_dev *dev = hwif->pci_dev;
  755. u8 mcr = 0, mcr_addr = hwif->select_data;
  756. u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01;
  757. pci_read_config_byte(dev, 0x6a, &bwsr);
  758. pci_read_config_byte(dev, mcr_addr, &mcr);
  759. if (bwsr & mask)
  760. pci_write_config_byte(dev, mcr_addr, mcr | 0x30);
  761. return __ide_dma_end(drive);
  762. }
  763. /**
  764. * hpt3xxn_set_clock - perform clock switching dance
  765. * @hwif: hwif to switch
  766. * @mode: clocking mode (0x21 for write, 0x23 otherwise)
  767. *
  768. * Switch the DPLL clock on the HPT3xxN devices. This is a right mess.
  769. */
  770. static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode)
  771. {
  772. u8 scr2 = hwif->INB(hwif->dma_master + 0x7b);
  773. if ((scr2 & 0x7f) == mode)
  774. return;
  775. /* Tristate the bus */
  776. hwif->OUTB(0x80, hwif->dma_master + 0x73);
  777. hwif->OUTB(0x80, hwif->dma_master + 0x77);
  778. /* Switch clock and reset channels */
  779. hwif->OUTB(mode, hwif->dma_master + 0x7b);
  780. hwif->OUTB(0xc0, hwif->dma_master + 0x79);
  781. /*
  782. * Reset the state machines.
  783. * NOTE: avoid accidentally enabling the disabled channels.
  784. */
  785. hwif->OUTB(hwif->INB(hwif->dma_master + 0x70) | 0x32,
  786. hwif->dma_master + 0x70);
  787. hwif->OUTB(hwif->INB(hwif->dma_master + 0x74) | 0x32,
  788. hwif->dma_master + 0x74);
  789. /* Complete reset */
  790. hwif->OUTB(0x00, hwif->dma_master + 0x79);
  791. /* Reconnect channels to bus */
  792. hwif->OUTB(0x00, hwif->dma_master + 0x73);
  793. hwif->OUTB(0x00, hwif->dma_master + 0x77);
  794. }
  795. /**
  796. * hpt3xxn_rw_disk - prepare for I/O
  797. * @drive: drive for command
  798. * @rq: block request structure
  799. *
  800. * This is called when a disk I/O is issued to HPT3xxN.
  801. * We need it because of the clock switching.
  802. */
  803. static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq)
  804. {
  805. hpt3xxn_set_clock(HWIF(drive), rq_data_dir(rq) ? 0x23 : 0x21);
  806. }
  807. /*
  808. * Set/get power state for a drive.
  809. * NOTE: affects both drives on each channel.
  810. *
  811. * When we turn the power back on, we need to re-initialize things.
  812. */
  813. #define TRISTATE_BIT 0x8000
  814. static int hpt3xx_busproc(ide_drive_t *drive, int state)
  815. {
  816. ide_hwif_t *hwif = HWIF(drive);
  817. struct pci_dev *dev = hwif->pci_dev;
  818. u8 mcr_addr = hwif->select_data + 2;
  819. u8 resetmask = hwif->channel ? 0x80 : 0x40;
  820. u8 bsr2 = 0;
  821. u16 mcr = 0;
  822. hwif->bus_state = state;
  823. /* Grab the status. */
  824. pci_read_config_word(dev, mcr_addr, &mcr);
  825. pci_read_config_byte(dev, 0x59, &bsr2);
  826. /*
  827. * Set the state. We don't set it if we don't need to do so.
  828. * Make sure that the drive knows that it has failed if it's off.
  829. */
  830. switch (state) {
  831. case BUSSTATE_ON:
  832. if (!(bsr2 & resetmask))
  833. return 0;
  834. hwif->drives[0].failures = hwif->drives[1].failures = 0;
  835. pci_write_config_byte(dev, 0x59, bsr2 & ~resetmask);
  836. pci_write_config_word(dev, mcr_addr, mcr & ~TRISTATE_BIT);
  837. return 0;
  838. case BUSSTATE_OFF:
  839. if ((bsr2 & resetmask) && !(mcr & TRISTATE_BIT))
  840. return 0;
  841. mcr &= ~TRISTATE_BIT;
  842. break;
  843. case BUSSTATE_TRISTATE:
  844. if ((bsr2 & resetmask) && (mcr & TRISTATE_BIT))
  845. return 0;
  846. mcr |= TRISTATE_BIT;
  847. break;
  848. default:
  849. return -EINVAL;
  850. }
  851. hwif->drives[0].failures = hwif->drives[0].max_failures + 1;
  852. hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
  853. pci_write_config_word(dev, mcr_addr, mcr);
  854. pci_write_config_byte(dev, 0x59, bsr2 | resetmask);
  855. return 0;
  856. }
  857. /**
  858. * hpt37x_calibrate_dpll - calibrate the DPLL
  859. * @dev: PCI device
  860. *
  861. * Perform a calibration cycle on the DPLL.
  862. * Returns 1 if this succeeds
  863. */
  864. static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f_high)
  865. {
  866. u32 dpll = (f_high << 16) | f_low | 0x100;
  867. u8 scr2;
  868. int i;
  869. pci_write_config_dword(dev, 0x5c, dpll);
  870. /* Wait for oscillator ready */
  871. for(i = 0; i < 0x5000; ++i) {
  872. udelay(50);
  873. pci_read_config_byte(dev, 0x5b, &scr2);
  874. if (scr2 & 0x80)
  875. break;
  876. }
  877. /* See if it stays ready (we'll just bail out if it's not yet) */
  878. for(i = 0; i < 0x1000; ++i) {
  879. pci_read_config_byte(dev, 0x5b, &scr2);
  880. /* DPLL destabilized? */
  881. if(!(scr2 & 0x80))
  882. return 0;
  883. }
  884. /* Turn off tuning, we have the DPLL set */
  885. pci_read_config_dword (dev, 0x5c, &dpll);
  886. pci_write_config_dword(dev, 0x5c, (dpll & ~0x100));
  887. return 1;
  888. }
  889. static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name)
  890. {
  891. struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL);
  892. unsigned long io_base = pci_resource_start(dev, 4);
  893. u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */
  894. enum ata_clock clock;
  895. if (info == NULL) {
  896. printk(KERN_ERR "%s: out of memory!\n", name);
  897. return -ENOMEM;
  898. }
  899. /*
  900. * Copy everything from a static "template" structure
  901. * to just allocated per-chip hpt_info structure.
  902. */
  903. *info = *(struct hpt_info *)pci_get_drvdata(dev);
  904. /*
  905. * FIXME: Not portable. Also, why do we enable the ROM in the first place?
  906. * We don't seem to be using it.
  907. */
  908. if (dev->resource[PCI_ROM_RESOURCE].start)
  909. pci_write_config_dword(dev, PCI_ROM_ADDRESS,
  910. dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
  911. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
  912. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
  913. pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
  914. pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
  915. /*
  916. * First, try to estimate the PCI clock frequency...
  917. */
  918. if (info->chip_type >= HPT370) {
  919. u8 scr1 = 0;
  920. u16 f_cnt = 0;
  921. u32 temp = 0;
  922. /* Interrupt force enable. */
  923. pci_read_config_byte(dev, 0x5a, &scr1);
  924. if (scr1 & 0x10)
  925. pci_write_config_byte(dev, 0x5a, scr1 & ~0x10);
  926. /*
  927. * HighPoint does this for HPT372A.
  928. * NOTE: This register is only writeable via I/O space.
  929. */
  930. if (info->chip_type == HPT372A)
  931. outb(0x0e, io_base + 0x9c);
  932. /*
  933. * Default to PCI clock. Make sure MA15/16 are set to output
  934. * to prevent drives having problems with 40-pin cables.
  935. */
  936. pci_write_config_byte(dev, 0x5b, 0x23);
  937. /*
  938. * We'll have to read f_CNT value in order to determine
  939. * the PCI clock frequency according to the following ratio:
  940. *
  941. * f_CNT = Fpci * 192 / Fdpll
  942. *
  943. * First try reading the register in which the HighPoint BIOS
  944. * saves f_CNT value before reprogramming the DPLL from its
  945. * default setting (which differs for the various chips).
  946. * NOTE: This register is only accessible via I/O space.
  947. *
  948. * In case the signature check fails, we'll have to resort to
  949. * reading the f_CNT register itself in hopes that nobody has
  950. * touched the DPLL yet...
  951. */
  952. temp = inl(io_base + 0x90);
  953. if ((temp & 0xFFFFF000) != 0xABCDE000) {
  954. int i;
  955. printk(KERN_WARNING "%s: no clock data saved by BIOS\n",
  956. name);
  957. /* Calculate the average value of f_CNT. */
  958. for (temp = i = 0; i < 128; i++) {
  959. pci_read_config_word(dev, 0x78, &f_cnt);
  960. temp += f_cnt & 0x1ff;
  961. mdelay(1);
  962. }
  963. f_cnt = temp / 128;
  964. } else
  965. f_cnt = temp & 0x1ff;
  966. dpll_clk = info->dpll_clk;
  967. pci_clk = (f_cnt * dpll_clk) / 192;
  968. /* Clamp PCI clock to bands. */
  969. if (pci_clk < 40)
  970. pci_clk = 33;
  971. else if(pci_clk < 45)
  972. pci_clk = 40;
  973. else if(pci_clk < 55)
  974. pci_clk = 50;
  975. else
  976. pci_clk = 66;
  977. printk(KERN_INFO "%s: DPLL base: %d MHz, f_CNT: %d, "
  978. "assuming %d MHz PCI\n", name, dpll_clk, f_cnt, pci_clk);
  979. } else {
  980. u32 itr1 = 0;
  981. pci_read_config_dword(dev, 0x40, &itr1);
  982. /* Detect PCI clock by looking at cmd_high_time. */
  983. switch((itr1 >> 8) & 0x07) {
  984. case 0x09:
  985. pci_clk = 40;
  986. break;
  987. case 0x05:
  988. pci_clk = 25;
  989. break;
  990. case 0x07:
  991. default:
  992. pci_clk = 33;
  993. break;
  994. }
  995. }
  996. /* Let's assume we'll use PCI clock for the ATA clock... */
  997. switch (pci_clk) {
  998. case 25:
  999. clock = ATA_CLOCK_25MHZ;
  1000. break;
  1001. case 33:
  1002. default:
  1003. clock = ATA_CLOCK_33MHZ;
  1004. break;
  1005. case 40:
  1006. clock = ATA_CLOCK_40MHZ;
  1007. break;
  1008. case 50:
  1009. clock = ATA_CLOCK_50MHZ;
  1010. break;
  1011. case 66:
  1012. clock = ATA_CLOCK_66MHZ;
  1013. break;
  1014. }
  1015. /*
  1016. * Only try the DPLL if we don't have a table for the PCI clock that
  1017. * we are running at for HPT370/A, always use it for anything newer...
  1018. *
  1019. * NOTE: Using the internal DPLL results in slow reads on 33 MHz PCI.
  1020. * We also don't like using the DPLL because this causes glitches
  1021. * on PRST-/SRST- when the state engine gets reset...
  1022. */
  1023. if (info->chip_type >= HPT374 || info->settings[clock] == NULL) {
  1024. u16 f_low, delta = pci_clk < 50 ? 2 : 4;
  1025. int adjust;
  1026. /*
  1027. * Select 66 MHz DPLL clock only if UltraATA/133 mode is
  1028. * supported/enabled, use 50 MHz DPLL clock otherwise...
  1029. */
  1030. if (info->max_mode == 0x04) {
  1031. dpll_clk = 66;
  1032. clock = ATA_CLOCK_66MHZ;
  1033. } else if (dpll_clk) { /* HPT36x chips don't have DPLL */
  1034. dpll_clk = 50;
  1035. clock = ATA_CLOCK_50MHZ;
  1036. }
  1037. if (info->settings[clock] == NULL) {
  1038. printk(KERN_ERR "%s: unknown bus timing!\n", name);
  1039. kfree(info);
  1040. return -EIO;
  1041. }
  1042. /* Select the DPLL clock. */
  1043. pci_write_config_byte(dev, 0x5b, 0x21);
  1044. /*
  1045. * Adjust the DPLL based upon PCI clock, enable it,
  1046. * and wait for stabilization...
  1047. */
  1048. f_low = (pci_clk * 48) / dpll_clk;
  1049. for (adjust = 0; adjust < 8; adjust++) {
  1050. if(hpt37x_calibrate_dpll(dev, f_low, f_low + delta))
  1051. break;
  1052. /*
  1053. * See if it'll settle at a fractionally different clock
  1054. */
  1055. if (adjust & 1)
  1056. f_low -= adjust >> 1;
  1057. else
  1058. f_low += adjust >> 1;
  1059. }
  1060. if (adjust == 8) {
  1061. printk(KERN_ERR "%s: DPLL did not stabilize!\n", name);
  1062. kfree(info);
  1063. return -EIO;
  1064. }
  1065. printk("%s: using %d MHz DPLL clock\n", name, dpll_clk);
  1066. } else {
  1067. /* Mark the fact that we're not using the DPLL. */
  1068. dpll_clk = 0;
  1069. printk("%s: using %d MHz PCI clock\n", name, pci_clk);
  1070. }
  1071. /*
  1072. * Advance the table pointer to a slot which points to the list
  1073. * of the register values settings matching the clock being used.
  1074. */
  1075. info->settings += clock;
  1076. /* Store the clock frequencies. */
  1077. info->dpll_clk = dpll_clk;
  1078. info->pci_clk = pci_clk;
  1079. /* Point to this chip's own instance of the hpt_info structure. */
  1080. pci_set_drvdata(dev, info);
  1081. if (info->chip_type >= HPT370) {
  1082. u8 mcr1, mcr4;
  1083. /*
  1084. * Reset the state engines.
  1085. * NOTE: Avoid accidentally enabling the disabled channels.
  1086. */
  1087. pci_read_config_byte (dev, 0x50, &mcr1);
  1088. pci_read_config_byte (dev, 0x54, &mcr4);
  1089. pci_write_config_byte(dev, 0x50, (mcr1 | 0x32));
  1090. pci_write_config_byte(dev, 0x54, (mcr4 | 0x32));
  1091. udelay(100);
  1092. }
  1093. /*
  1094. * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
  1095. * the MISC. register to stretch the UltraDMA Tss timing.
  1096. * NOTE: This register is only writeable via I/O space.
  1097. */
  1098. if (info->chip_type == HPT371N && clock == ATA_CLOCK_66MHZ)
  1099. outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c);
  1100. return dev->irq;
  1101. }
  1102. static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
  1103. {
  1104. struct pci_dev *dev = hwif->pci_dev;
  1105. struct hpt_info *info = pci_get_drvdata(dev);
  1106. int serialize = HPT_SERIALIZE_IO;
  1107. u8 scr1 = 0, ata66 = (hwif->channel) ? 0x01 : 0x02;
  1108. u8 chip_type = info->chip_type;
  1109. u8 new_mcr, old_mcr = 0;
  1110. /* Cache the channel's MISC. control registers' offset */
  1111. hwif->select_data = hwif->channel ? 0x54 : 0x50;
  1112. hwif->tuneproc = &hpt3xx_tune_drive;
  1113. hwif->speedproc = &hpt3xx_tune_chipset;
  1114. hwif->quirkproc = &hpt3xx_quirkproc;
  1115. hwif->intrproc = &hpt3xx_intrproc;
  1116. hwif->maskproc = &hpt3xx_maskproc;
  1117. hwif->busproc = &hpt3xx_busproc;
  1118. /*
  1119. * HPT3xxN chips have some complications:
  1120. *
  1121. * - on 33 MHz PCI we must clock switch
  1122. * - on 66 MHz PCI we must NOT use the PCI clock
  1123. */
  1124. if (chip_type >= HPT372N && info->dpll_clk && info->pci_clk < 66) {
  1125. /*
  1126. * Clock is shared between the channels,
  1127. * so we'll have to serialize them... :-(
  1128. */
  1129. serialize = 1;
  1130. hwif->rw_disk = &hpt3xxn_rw_disk;
  1131. }
  1132. /* Serialize access to this device if needed */
  1133. if (serialize && hwif->mate)
  1134. hwif->serialized = hwif->mate->serialized = 1;
  1135. /*
  1136. * Disable the "fast interrupt" prediction. Don't hold off
  1137. * on interrupts. (== 0x01 despite what the docs say)
  1138. */
  1139. pci_read_config_byte(dev, hwif->select_data + 1, &old_mcr);
  1140. if (info->chip_type >= HPT374)
  1141. new_mcr = old_mcr & ~0x07;
  1142. else if (info->chip_type >= HPT370) {
  1143. new_mcr = old_mcr;
  1144. new_mcr &= ~0x02;
  1145. #ifdef HPT_DELAY_INTERRUPT
  1146. new_mcr &= ~0x01;
  1147. #else
  1148. new_mcr |= 0x01;
  1149. #endif
  1150. } else /* HPT366 and HPT368 */
  1151. new_mcr = old_mcr & ~0x80;
  1152. if (new_mcr != old_mcr)
  1153. pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
  1154. if (!hwif->dma_base) {
  1155. hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
  1156. return;
  1157. }
  1158. hwif->ultra_mask = 0x7f;
  1159. hwif->mwdma_mask = 0x07;
  1160. /*
  1161. * The HPT37x uses the CBLID pins as outputs for MA15/MA16
  1162. * address lines to access an external EEPROM. To read valid
  1163. * cable detect state the pins must be enabled as inputs.
  1164. */
  1165. if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
  1166. /*
  1167. * HPT374 PCI function 1
  1168. * - set bit 15 of reg 0x52 to enable TCBLID as input
  1169. * - set bit 15 of reg 0x56 to enable FCBLID as input
  1170. */
  1171. u8 mcr_addr = hwif->select_data + 2;
  1172. u16 mcr;
  1173. pci_read_config_word (dev, mcr_addr, &mcr);
  1174. pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
  1175. /* now read cable id register */
  1176. pci_read_config_byte (dev, 0x5a, &scr1);
  1177. pci_write_config_word(dev, mcr_addr, mcr);
  1178. } else if (chip_type >= HPT370) {
  1179. /*
  1180. * HPT370/372 and 374 pcifn 0
  1181. * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
  1182. */
  1183. u8 scr2 = 0;
  1184. pci_read_config_byte (dev, 0x5b, &scr2);
  1185. pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
  1186. /* now read cable id register */
  1187. pci_read_config_byte (dev, 0x5a, &scr1);
  1188. pci_write_config_byte(dev, 0x5b, scr2);
  1189. } else
  1190. pci_read_config_byte (dev, 0x5a, &scr1);
  1191. if (!hwif->udma_four)
  1192. hwif->udma_four = (scr1 & ata66) ? 0 : 1;
  1193. hwif->ide_dma_check = &hpt366_config_drive_xfer_rate;
  1194. if (chip_type >= HPT374) {
  1195. hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq;
  1196. hwif->ide_dma_end = &hpt374_ide_dma_end;
  1197. } else if (chip_type >= HPT370) {
  1198. hwif->dma_start = &hpt370_ide_dma_start;
  1199. hwif->ide_dma_end = &hpt370_ide_dma_end;
  1200. hwif->ide_dma_timeout = &hpt370_ide_dma_timeout;
  1201. } else
  1202. hwif->ide_dma_lostirq = &hpt366_ide_dma_lostirq;
  1203. if (!noautodma)
  1204. hwif->autodma = 1;
  1205. hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
  1206. }
  1207. static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
  1208. {
  1209. struct pci_dev *dev = hwif->pci_dev;
  1210. u8 masterdma = 0, slavedma = 0;
  1211. u8 dma_new = 0, dma_old = 0;
  1212. unsigned long flags;
  1213. if (!dmabase)
  1214. return;
  1215. dma_old = hwif->INB(dmabase + 2);
  1216. local_irq_save(flags);
  1217. dma_new = dma_old;
  1218. pci_read_config_byte(dev, hwif->channel ? 0x4b : 0x43, &masterdma);
  1219. pci_read_config_byte(dev, hwif->channel ? 0x4f : 0x47, &slavedma);
  1220. if (masterdma & 0x30) dma_new |= 0x20;
  1221. if ( slavedma & 0x30) dma_new |= 0x40;
  1222. if (dma_new != dma_old)
  1223. hwif->OUTB(dma_new, dmabase + 2);
  1224. local_irq_restore(flags);
  1225. ide_setup_dma(hwif, dmabase, 8);
  1226. }
  1227. static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d)
  1228. {
  1229. struct pci_dev *dev2;
  1230. if (PCI_FUNC(dev->devfn) & 1)
  1231. return -ENODEV;
  1232. pci_set_drvdata(dev, &hpt374);
  1233. if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
  1234. int ret;
  1235. pci_set_drvdata(dev2, &hpt374);
  1236. if (dev2->irq != dev->irq) {
  1237. /* FIXME: we need a core pci_set_interrupt() */
  1238. dev2->irq = dev->irq;
  1239. printk(KERN_WARNING "%s: PCI config space interrupt "
  1240. "fixed.\n", d->name);
  1241. }
  1242. ret = ide_setup_pci_devices(dev, dev2, d);
  1243. if (ret < 0)
  1244. pci_dev_put(dev2);
  1245. return ret;
  1246. }
  1247. return ide_setup_pci_device(dev, d);
  1248. }
  1249. static int __devinit init_setup_hpt372n(struct pci_dev *dev, ide_pci_device_t *d)
  1250. {
  1251. pci_set_drvdata(dev, &hpt372n);
  1252. return ide_setup_pci_device(dev, d);
  1253. }
  1254. static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d)
  1255. {
  1256. struct hpt_info *info;
  1257. u8 rev = 0, mcr1 = 0;
  1258. pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
  1259. if (rev > 1) {
  1260. d->name = "HPT371N";
  1261. info = &hpt371n;
  1262. } else
  1263. info = &hpt371;
  1264. /*
  1265. * HPT371 chips physically have only one channel, the secondary one,
  1266. * but the primary channel registers do exist! Go figure...
  1267. * So, we manually disable the non-existing channel here
  1268. * (if the BIOS hasn't done this already).
  1269. */
  1270. pci_read_config_byte(dev, 0x50, &mcr1);
  1271. if (mcr1 & 0x04)
  1272. pci_write_config_byte(dev, 0x50, mcr1 & ~0x04);
  1273. pci_set_drvdata(dev, info);
  1274. return ide_setup_pci_device(dev, d);
  1275. }
  1276. static int __devinit init_setup_hpt372a(struct pci_dev *dev, ide_pci_device_t *d)
  1277. {
  1278. struct hpt_info *info;
  1279. u8 rev = 0;
  1280. pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
  1281. if (rev > 1) {
  1282. d->name = "HPT372N";
  1283. info = &hpt372n;
  1284. } else
  1285. info = &hpt372a;
  1286. pci_set_drvdata(dev, info);
  1287. return ide_setup_pci_device(dev, d);
  1288. }
  1289. static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d)
  1290. {
  1291. struct hpt_info *info;
  1292. u8 rev = 0;
  1293. pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
  1294. if (rev > 1) {
  1295. d->name = "HPT302N";
  1296. info = &hpt302n;
  1297. } else
  1298. info = &hpt302;
  1299. pci_set_drvdata(dev, info);
  1300. return ide_setup_pci_device(dev, d);
  1301. }
  1302. static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
  1303. {
  1304. struct pci_dev *dev2;
  1305. u8 rev = 0;
  1306. static char *chipset_names[] = { "HPT366", "HPT366", "HPT368",
  1307. "HPT370", "HPT370A", "HPT372",
  1308. "HPT372N" };
  1309. static struct hpt_info *info[] = { &hpt36x, &hpt36x, &hpt36x,
  1310. &hpt370, &hpt370a, &hpt372,
  1311. &hpt372n };
  1312. if (PCI_FUNC(dev->devfn) & 1)
  1313. return -ENODEV;
  1314. pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
  1315. if (rev > 6)
  1316. rev = 6;
  1317. d->name = chipset_names[rev];
  1318. pci_set_drvdata(dev, info[rev]);
  1319. if (rev > 2)
  1320. goto init_single;
  1321. d->channels = 1;
  1322. if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
  1323. u8 pin1 = 0, pin2 = 0;
  1324. int ret;
  1325. pci_set_drvdata(dev2, info[rev]);
  1326. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1);
  1327. pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2);
  1328. if (pin1 != pin2 && dev->irq == dev2->irq) {
  1329. d->bootable = ON_BOARD;
  1330. printk("%s: onboard version of chipset, pin1=%d pin2=%d\n",
  1331. d->name, pin1, pin2);
  1332. }
  1333. ret = ide_setup_pci_devices(dev, dev2, d);
  1334. if (ret < 0)
  1335. pci_dev_put(dev2);
  1336. return ret;
  1337. }
  1338. init_single:
  1339. return ide_setup_pci_device(dev, d);
  1340. }
  1341. static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
  1342. { /* 0 */
  1343. .name = "HPT366",
  1344. .init_setup = init_setup_hpt366,
  1345. .init_chipset = init_chipset_hpt366,
  1346. .init_hwif = init_hwif_hpt366,
  1347. .init_dma = init_dma_hpt366,
  1348. .channels = 2,
  1349. .autodma = AUTODMA,
  1350. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1351. .bootable = OFF_BOARD,
  1352. .extra = 240
  1353. },{ /* 1 */
  1354. .name = "HPT372A",
  1355. .init_setup = init_setup_hpt372a,
  1356. .init_chipset = init_chipset_hpt366,
  1357. .init_hwif = init_hwif_hpt366,
  1358. .init_dma = init_dma_hpt366,
  1359. .channels = 2,
  1360. .autodma = AUTODMA,
  1361. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1362. .bootable = OFF_BOARD,
  1363. .extra = 240
  1364. },{ /* 2 */
  1365. .name = "HPT302",
  1366. .init_setup = init_setup_hpt302,
  1367. .init_chipset = init_chipset_hpt366,
  1368. .init_hwif = init_hwif_hpt366,
  1369. .init_dma = init_dma_hpt366,
  1370. .channels = 2,
  1371. .autodma = AUTODMA,
  1372. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1373. .bootable = OFF_BOARD,
  1374. .extra = 240
  1375. },{ /* 3 */
  1376. .name = "HPT371",
  1377. .init_setup = init_setup_hpt371,
  1378. .init_chipset = init_chipset_hpt366,
  1379. .init_hwif = init_hwif_hpt366,
  1380. .init_dma = init_dma_hpt366,
  1381. .channels = 2,
  1382. .autodma = AUTODMA,
  1383. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1384. .bootable = OFF_BOARD,
  1385. .extra = 240
  1386. },{ /* 4 */
  1387. .name = "HPT374",
  1388. .init_setup = init_setup_hpt374,
  1389. .init_chipset = init_chipset_hpt366,
  1390. .init_hwif = init_hwif_hpt366,
  1391. .init_dma = init_dma_hpt366,
  1392. .channels = 2, /* 4 */
  1393. .autodma = AUTODMA,
  1394. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1395. .bootable = OFF_BOARD,
  1396. .extra = 240
  1397. },{ /* 5 */
  1398. .name = "HPT372N",
  1399. .init_setup = init_setup_hpt372n,
  1400. .init_chipset = init_chipset_hpt366,
  1401. .init_hwif = init_hwif_hpt366,
  1402. .init_dma = init_dma_hpt366,
  1403. .channels = 2, /* 4 */
  1404. .autodma = AUTODMA,
  1405. .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
  1406. .bootable = OFF_BOARD,
  1407. .extra = 240
  1408. }
  1409. };
  1410. /**
  1411. * hpt366_init_one - called when an HPT366 is found
  1412. * @dev: the hpt366 device
  1413. * @id: the matching pci id
  1414. *
  1415. * Called when the PCI registration layer (or the IDE initialization)
  1416. * finds a device matching our IDE device tables.
  1417. *
  1418. * NOTE: since we'll have to modify some fields of the ide_pci_device_t
  1419. * structure depending on the chip's revision, we'd better pass a local
  1420. * copy down the call chain...
  1421. */
  1422. static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  1423. {
  1424. ide_pci_device_t d = hpt366_chipsets[id->driver_data];
  1425. return d.init_setup(dev, &d);
  1426. }
  1427. static struct pci_device_id hpt366_pci_tbl[] = {
  1428. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT366, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  1429. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
  1430. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
  1431. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
  1432. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT374, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  1433. { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372N, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5},
  1434. { 0, },
  1435. };
  1436. MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl);
  1437. static struct pci_driver driver = {
  1438. .name = "HPT366_IDE",
  1439. .id_table = hpt366_pci_tbl,
  1440. .probe = hpt366_init_one,
  1441. };
  1442. static int __init hpt366_ide_init(void)
  1443. {
  1444. return ide_pci_register_driver(&driver);
  1445. }
  1446. module_init(hpt366_ide_init);
  1447. MODULE_AUTHOR("Andre Hedrick");
  1448. MODULE_DESCRIPTION("PCI driver module for Highpoint HPT366 IDE");
  1449. MODULE_LICENSE("GPL");