ahci.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733
  1. /*
  2. * ahci.c - AHCI SATA support
  3. *
  4. * Maintained by: Tejun Heo <tj@kernel.org>
  5. * Please ALWAYS copy linux-ide@vger.kernel.org
  6. * on emails.
  7. *
  8. * Copyright 2004-2005 Red Hat, Inc.
  9. *
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; see the file COPYING. If not, write to
  23. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. *
  26. * libata documentation is available via 'make {ps|pdf}docs',
  27. * as Documentation/DocBook/libata.*
  28. *
  29. * AHCI hardware documentation:
  30. * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
  31. * http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
  32. *
  33. */
  34. #include <linux/kernel.h>
  35. #include <linux/module.h>
  36. #include <linux/pci.h>
  37. #include <linux/blkdev.h>
  38. #include <linux/delay.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/dma-mapping.h>
  41. #include <linux/device.h>
  42. #include <linux/dmi.h>
  43. #include <linux/gfp.h>
  44. #include <linux/msi.h>
  45. #include <scsi/scsi_host.h>
  46. #include <scsi/scsi_cmnd.h>
  47. #include <linux/libata.h>
  48. #include "ahci.h"
  49. #define DRV_NAME "ahci"
  50. #define DRV_VERSION "3.0"
  51. enum {
  52. AHCI_PCI_BAR_STA2X11 = 0,
  53. AHCI_PCI_BAR_CAVIUM = 0,
  54. AHCI_PCI_BAR_ENMOTUS = 2,
  55. AHCI_PCI_BAR_STANDARD = 5,
  56. };
  57. enum board_ids {
  58. /* board IDs by feature in alphabetical order */
  59. board_ahci,
  60. board_ahci_ign_iferr,
  61. board_ahci_nomsi,
  62. board_ahci_noncq,
  63. board_ahci_nosntf,
  64. board_ahci_yes_fbs,
  65. /* board IDs for specific chipsets in alphabetical order */
  66. board_ahci_avn,
  67. board_ahci_mcp65,
  68. board_ahci_mcp77,
  69. board_ahci_mcp89,
  70. board_ahci_mv,
  71. board_ahci_sb600,
  72. board_ahci_sb700, /* for SB700 and SB800 */
  73. board_ahci_vt8251,
  74. /* aliases */
  75. board_ahci_mcp_linux = board_ahci_mcp65,
  76. board_ahci_mcp67 = board_ahci_mcp65,
  77. board_ahci_mcp73 = board_ahci_mcp65,
  78. board_ahci_mcp79 = board_ahci_mcp77,
  79. };
  80. static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
  81. static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
  82. unsigned long deadline);
  83. static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
  84. unsigned long deadline);
  85. static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
  86. static bool is_mcp89_apple(struct pci_dev *pdev);
  87. static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
  88. unsigned long deadline);
  89. #ifdef CONFIG_PM
  90. static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
  91. static int ahci_pci_device_resume(struct pci_dev *pdev);
  92. #endif
  93. static struct scsi_host_template ahci_sht = {
  94. AHCI_SHT("ahci"),
  95. };
  96. static struct ata_port_operations ahci_vt8251_ops = {
  97. .inherits = &ahci_ops,
  98. .hardreset = ahci_vt8251_hardreset,
  99. };
  100. static struct ata_port_operations ahci_p5wdh_ops = {
  101. .inherits = &ahci_ops,
  102. .hardreset = ahci_p5wdh_hardreset,
  103. };
  104. static struct ata_port_operations ahci_avn_ops = {
  105. .inherits = &ahci_ops,
  106. .hardreset = ahci_avn_hardreset,
  107. };
  108. static const struct ata_port_info ahci_port_info[] = {
  109. /* by features */
  110. [board_ahci] = {
  111. .flags = AHCI_FLAG_COMMON,
  112. .pio_mask = ATA_PIO4,
  113. .udma_mask = ATA_UDMA6,
  114. .port_ops = &ahci_ops,
  115. },
  116. [board_ahci_ign_iferr] = {
  117. AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
  118. .flags = AHCI_FLAG_COMMON,
  119. .pio_mask = ATA_PIO4,
  120. .udma_mask = ATA_UDMA6,
  121. .port_ops = &ahci_ops,
  122. },
  123. [board_ahci_nomsi] = {
  124. AHCI_HFLAGS (AHCI_HFLAG_NO_MSI),
  125. .flags = AHCI_FLAG_COMMON,
  126. .pio_mask = ATA_PIO4,
  127. .udma_mask = ATA_UDMA6,
  128. .port_ops = &ahci_ops,
  129. },
  130. [board_ahci_noncq] = {
  131. AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ),
  132. .flags = AHCI_FLAG_COMMON,
  133. .pio_mask = ATA_PIO4,
  134. .udma_mask = ATA_UDMA6,
  135. .port_ops = &ahci_ops,
  136. },
  137. [board_ahci_nosntf] = {
  138. AHCI_HFLAGS (AHCI_HFLAG_NO_SNTF),
  139. .flags = AHCI_FLAG_COMMON,
  140. .pio_mask = ATA_PIO4,
  141. .udma_mask = ATA_UDMA6,
  142. .port_ops = &ahci_ops,
  143. },
  144. [board_ahci_yes_fbs] = {
  145. AHCI_HFLAGS (AHCI_HFLAG_YES_FBS),
  146. .flags = AHCI_FLAG_COMMON,
  147. .pio_mask = ATA_PIO4,
  148. .udma_mask = ATA_UDMA6,
  149. .port_ops = &ahci_ops,
  150. },
  151. /* by chipsets */
  152. [board_ahci_avn] = {
  153. .flags = AHCI_FLAG_COMMON,
  154. .pio_mask = ATA_PIO4,
  155. .udma_mask = ATA_UDMA6,
  156. .port_ops = &ahci_avn_ops,
  157. },
  158. [board_ahci_mcp65] = {
  159. AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP |
  160. AHCI_HFLAG_YES_NCQ),
  161. .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
  162. .pio_mask = ATA_PIO4,
  163. .udma_mask = ATA_UDMA6,
  164. .port_ops = &ahci_ops,
  165. },
  166. [board_ahci_mcp77] = {
  167. AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP),
  168. .flags = AHCI_FLAG_COMMON,
  169. .pio_mask = ATA_PIO4,
  170. .udma_mask = ATA_UDMA6,
  171. .port_ops = &ahci_ops,
  172. },
  173. [board_ahci_mcp89] = {
  174. AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA),
  175. .flags = AHCI_FLAG_COMMON,
  176. .pio_mask = ATA_PIO4,
  177. .udma_mask = ATA_UDMA6,
  178. .port_ops = &ahci_ops,
  179. },
  180. [board_ahci_mv] = {
  181. AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
  182. AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
  183. .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
  184. .pio_mask = ATA_PIO4,
  185. .udma_mask = ATA_UDMA6,
  186. .port_ops = &ahci_ops,
  187. },
  188. [board_ahci_sb600] = {
  189. AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
  190. AHCI_HFLAG_NO_MSI | AHCI_HFLAG_SECT255 |
  191. AHCI_HFLAG_32BIT_ONLY),
  192. .flags = AHCI_FLAG_COMMON,
  193. .pio_mask = ATA_PIO4,
  194. .udma_mask = ATA_UDMA6,
  195. .port_ops = &ahci_pmp_retry_srst_ops,
  196. },
  197. [board_ahci_sb700] = { /* for SB700 and SB800 */
  198. AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
  199. .flags = AHCI_FLAG_COMMON,
  200. .pio_mask = ATA_PIO4,
  201. .udma_mask = ATA_UDMA6,
  202. .port_ops = &ahci_pmp_retry_srst_ops,
  203. },
  204. [board_ahci_vt8251] = {
  205. AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
  206. .flags = AHCI_FLAG_COMMON,
  207. .pio_mask = ATA_PIO4,
  208. .udma_mask = ATA_UDMA6,
  209. .port_ops = &ahci_vt8251_ops,
  210. },
  211. };
  212. static const struct pci_device_id ahci_pci_tbl[] = {
  213. /* Intel */
  214. { PCI_VDEVICE(INTEL, 0x2652), board_ahci }, /* ICH6 */
  215. { PCI_VDEVICE(INTEL, 0x2653), board_ahci }, /* ICH6M */
  216. { PCI_VDEVICE(INTEL, 0x27c1), board_ahci }, /* ICH7 */
  217. { PCI_VDEVICE(INTEL, 0x27c5), board_ahci }, /* ICH7M */
  218. { PCI_VDEVICE(INTEL, 0x27c3), board_ahci }, /* ICH7R */
  219. { PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr }, /* ULi M5288 */
  220. { PCI_VDEVICE(INTEL, 0x2681), board_ahci }, /* ESB2 */
  221. { PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */
  222. { PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */
  223. { PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */
  224. { PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */
  225. { PCI_VDEVICE(INTEL, 0x2822), board_ahci_nosntf }, /* ICH8 */
  226. { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */
  227. { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */
  228. { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */
  229. { PCI_VDEVICE(INTEL, 0x2922), board_ahci }, /* ICH9 */
  230. { PCI_VDEVICE(INTEL, 0x2923), board_ahci }, /* ICH9 */
  231. { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
  232. { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
  233. { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
  234. { PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */
  235. { PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */
  236. { PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */
  237. { PCI_VDEVICE(INTEL, 0x292c), board_ahci }, /* ICH9M */
  238. { PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */
  239. { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
  240. { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */
  241. { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
  242. { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
  243. { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
  244. { PCI_VDEVICE(INTEL, 0x3a22), board_ahci }, /* ICH10 */
  245. { PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */
  246. { PCI_VDEVICE(INTEL, 0x3b22), board_ahci }, /* PCH AHCI */
  247. { PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
  248. { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
  249. { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
  250. { PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH M AHCI */
  251. { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
  252. { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH M RAID */
  253. { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
  254. { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
  255. { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
  256. { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */
  257. { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */
  258. { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */
  259. { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */
  260. { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */
  261. { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */
  262. { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */
  263. { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */
  264. { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */
  265. { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */
  266. { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */
  267. { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */
  268. { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */
  269. { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */
  270. { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */
  271. { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */
  272. { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
  273. { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
  274. { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
  275. { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT M AHCI */
  276. { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
  277. { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT M RAID */
  278. { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
  279. { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
  280. { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
  281. { PCI_VDEVICE(INTEL, 0x1d04), board_ahci }, /* PBG RAID */
  282. { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */
  283. { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
  284. { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
  285. { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
  286. { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point M AHCI */
  287. { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
  288. { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
  289. { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
  290. { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point M RAID */
  291. { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
  292. { PCI_VDEVICE(INTEL, 0x8c02), board_ahci }, /* Lynx Point AHCI */
  293. { PCI_VDEVICE(INTEL, 0x8c03), board_ahci }, /* Lynx Point M AHCI */
  294. { PCI_VDEVICE(INTEL, 0x8c04), board_ahci }, /* Lynx Point RAID */
  295. { PCI_VDEVICE(INTEL, 0x8c05), board_ahci }, /* Lynx Point M RAID */
  296. { PCI_VDEVICE(INTEL, 0x8c06), board_ahci }, /* Lynx Point RAID */
  297. { PCI_VDEVICE(INTEL, 0x8c07), board_ahci }, /* Lynx Point M RAID */
  298. { PCI_VDEVICE(INTEL, 0x8c0e), board_ahci }, /* Lynx Point RAID */
  299. { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci }, /* Lynx Point M RAID */
  300. { PCI_VDEVICE(INTEL, 0x9c02), board_ahci }, /* Lynx Point-LP AHCI */
  301. { PCI_VDEVICE(INTEL, 0x9c03), board_ahci }, /* Lynx Point-LP AHCI */
  302. { PCI_VDEVICE(INTEL, 0x9c04), board_ahci }, /* Lynx Point-LP RAID */
  303. { PCI_VDEVICE(INTEL, 0x9c05), board_ahci }, /* Lynx Point-LP RAID */
  304. { PCI_VDEVICE(INTEL, 0x9c06), board_ahci }, /* Lynx Point-LP RAID */
  305. { PCI_VDEVICE(INTEL, 0x9c07), board_ahci }, /* Lynx Point-LP RAID */
  306. { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci }, /* Lynx Point-LP RAID */
  307. { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci }, /* Lynx Point-LP RAID */
  308. { PCI_VDEVICE(INTEL, 0x1f22), board_ahci }, /* Avoton AHCI */
  309. { PCI_VDEVICE(INTEL, 0x1f23), board_ahci }, /* Avoton AHCI */
  310. { PCI_VDEVICE(INTEL, 0x1f24), board_ahci }, /* Avoton RAID */
  311. { PCI_VDEVICE(INTEL, 0x1f25), board_ahci }, /* Avoton RAID */
  312. { PCI_VDEVICE(INTEL, 0x1f26), board_ahci }, /* Avoton RAID */
  313. { PCI_VDEVICE(INTEL, 0x1f27), board_ahci }, /* Avoton RAID */
  314. { PCI_VDEVICE(INTEL, 0x1f2e), board_ahci }, /* Avoton RAID */
  315. { PCI_VDEVICE(INTEL, 0x1f2f), board_ahci }, /* Avoton RAID */
  316. { PCI_VDEVICE(INTEL, 0x1f32), board_ahci_avn }, /* Avoton AHCI */
  317. { PCI_VDEVICE(INTEL, 0x1f33), board_ahci_avn }, /* Avoton AHCI */
  318. { PCI_VDEVICE(INTEL, 0x1f34), board_ahci_avn }, /* Avoton RAID */
  319. { PCI_VDEVICE(INTEL, 0x1f35), board_ahci_avn }, /* Avoton RAID */
  320. { PCI_VDEVICE(INTEL, 0x1f36), board_ahci_avn }, /* Avoton RAID */
  321. { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */
  322. { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */
  323. { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */
  324. { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */
  325. { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */
  326. { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */
  327. { PCI_VDEVICE(INTEL, 0x8d04), board_ahci }, /* Wellsburg RAID */
  328. { PCI_VDEVICE(INTEL, 0x8d06), board_ahci }, /* Wellsburg RAID */
  329. { PCI_VDEVICE(INTEL, 0x8d0e), board_ahci }, /* Wellsburg RAID */
  330. { PCI_VDEVICE(INTEL, 0x8d62), board_ahci }, /* Wellsburg AHCI */
  331. { PCI_VDEVICE(INTEL, 0x8d64), board_ahci }, /* Wellsburg RAID */
  332. { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
  333. { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
  334. { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
  335. { PCI_VDEVICE(INTEL, 0x9c83), board_ahci }, /* Wildcat Point-LP AHCI */
  336. { PCI_VDEVICE(INTEL, 0x9c85), board_ahci }, /* Wildcat Point-LP RAID */
  337. { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */
  338. { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */
  339. { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */
  340. { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series M AHCI */
  341. { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */
  342. { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series M RAID */
  343. { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */
  344. { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series M RAID */
  345. { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
  346. { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series M RAID */
  347. { PCI_VDEVICE(INTEL, 0x9d03), board_ahci }, /* Sunrise Point-LP AHCI */
  348. { PCI_VDEVICE(INTEL, 0x9d05), board_ahci }, /* Sunrise Point-LP RAID */
  349. { PCI_VDEVICE(INTEL, 0x9d07), board_ahci }, /* Sunrise Point-LP RAID */
  350. { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */
  351. { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H M AHCI */
  352. { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
  353. { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */
  354. { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H M RAID */
  355. { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
  356. { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
  357. { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/
  358. { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
  359. { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Lewisburg RAID*/
  360. { PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
  361. { PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
  362. { PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
  363. { PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
  364. { PCI_VDEVICE(INTEL, 0xa1d2), board_ahci }, /* Lewisburg RAID*/
  365. { PCI_VDEVICE(INTEL, 0xa1d6), board_ahci }, /* Lewisburg RAID*/
  366. { PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
  367. { PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
  368. { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
  369. { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
  370. { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
  371. { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
  372. { PCI_VDEVICE(INTEL, 0xa356), board_ahci }, /* Cannon Lake PCH-H RAID */
  373. { PCI_VDEVICE(INTEL, 0x0f22), board_ahci }, /* Bay Trail AHCI */
  374. { PCI_VDEVICE(INTEL, 0x0f23), board_ahci }, /* Bay Trail AHCI */
  375. { PCI_VDEVICE(INTEL, 0x22a3), board_ahci }, /* Cherry Trail AHCI */
  376. { PCI_VDEVICE(INTEL, 0x5ae3), board_ahci }, /* Apollo Lake AHCI */
  377. /* JMicron 360/1/3/5/6, match class to avoid IDE function */
  378. { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  379. PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr },
  380. /* JMicron 362B and 362C have an AHCI function with IDE class code */
  381. { PCI_VDEVICE(JMICRON, 0x2362), board_ahci_ign_iferr },
  382. { PCI_VDEVICE(JMICRON, 0x236f), board_ahci_ign_iferr },
  383. /* May need to update quirk_jmicron_async_suspend() for additions */
  384. /* ATI */
  385. { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
  386. { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 }, /* ATI SB700/800 */
  387. { PCI_VDEVICE(ATI, 0x4391), board_ahci_sb700 }, /* ATI SB700/800 */
  388. { PCI_VDEVICE(ATI, 0x4392), board_ahci_sb700 }, /* ATI SB700/800 */
  389. { PCI_VDEVICE(ATI, 0x4393), board_ahci_sb700 }, /* ATI SB700/800 */
  390. { PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */
  391. { PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */
  392. /* AMD */
  393. { PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */
  394. { PCI_VDEVICE(AMD, 0x7900), board_ahci }, /* AMD CZ */
  395. /* AMD is using RAID class only for ahci controllers */
  396. { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  397. PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
  398. /* VIA */
  399. { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
  400. { PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */
  401. /* NVIDIA */
  402. { PCI_VDEVICE(NVIDIA, 0x044c), board_ahci_mcp65 }, /* MCP65 */
  403. { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci_mcp65 }, /* MCP65 */
  404. { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci_mcp65 }, /* MCP65 */
  405. { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci_mcp65 }, /* MCP65 */
  406. { PCI_VDEVICE(NVIDIA, 0x045c), board_ahci_mcp65 }, /* MCP65 */
  407. { PCI_VDEVICE(NVIDIA, 0x045d), board_ahci_mcp65 }, /* MCP65 */
  408. { PCI_VDEVICE(NVIDIA, 0x045e), board_ahci_mcp65 }, /* MCP65 */
  409. { PCI_VDEVICE(NVIDIA, 0x045f), board_ahci_mcp65 }, /* MCP65 */
  410. { PCI_VDEVICE(NVIDIA, 0x0550), board_ahci_mcp67 }, /* MCP67 */
  411. { PCI_VDEVICE(NVIDIA, 0x0551), board_ahci_mcp67 }, /* MCP67 */
  412. { PCI_VDEVICE(NVIDIA, 0x0552), board_ahci_mcp67 }, /* MCP67 */
  413. { PCI_VDEVICE(NVIDIA, 0x0553), board_ahci_mcp67 }, /* MCP67 */
  414. { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci_mcp67 }, /* MCP67 */
  415. { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci_mcp67 }, /* MCP67 */
  416. { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci_mcp67 }, /* MCP67 */
  417. { PCI_VDEVICE(NVIDIA, 0x0557), board_ahci_mcp67 }, /* MCP67 */
  418. { PCI_VDEVICE(NVIDIA, 0x0558), board_ahci_mcp67 }, /* MCP67 */
  419. { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci_mcp67 }, /* MCP67 */
  420. { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci_mcp67 }, /* MCP67 */
  421. { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci_mcp67 }, /* MCP67 */
  422. { PCI_VDEVICE(NVIDIA, 0x0580), board_ahci_mcp_linux }, /* Linux ID */
  423. { PCI_VDEVICE(NVIDIA, 0x0581), board_ahci_mcp_linux }, /* Linux ID */
  424. { PCI_VDEVICE(NVIDIA, 0x0582), board_ahci_mcp_linux }, /* Linux ID */
  425. { PCI_VDEVICE(NVIDIA, 0x0583), board_ahci_mcp_linux }, /* Linux ID */
  426. { PCI_VDEVICE(NVIDIA, 0x0584), board_ahci_mcp_linux }, /* Linux ID */
  427. { PCI_VDEVICE(NVIDIA, 0x0585), board_ahci_mcp_linux }, /* Linux ID */
  428. { PCI_VDEVICE(NVIDIA, 0x0586), board_ahci_mcp_linux }, /* Linux ID */
  429. { PCI_VDEVICE(NVIDIA, 0x0587), board_ahci_mcp_linux }, /* Linux ID */
  430. { PCI_VDEVICE(NVIDIA, 0x0588), board_ahci_mcp_linux }, /* Linux ID */
  431. { PCI_VDEVICE(NVIDIA, 0x0589), board_ahci_mcp_linux }, /* Linux ID */
  432. { PCI_VDEVICE(NVIDIA, 0x058a), board_ahci_mcp_linux }, /* Linux ID */
  433. { PCI_VDEVICE(NVIDIA, 0x058b), board_ahci_mcp_linux }, /* Linux ID */
  434. { PCI_VDEVICE(NVIDIA, 0x058c), board_ahci_mcp_linux }, /* Linux ID */
  435. { PCI_VDEVICE(NVIDIA, 0x058d), board_ahci_mcp_linux }, /* Linux ID */
  436. { PCI_VDEVICE(NVIDIA, 0x058e), board_ahci_mcp_linux }, /* Linux ID */
  437. { PCI_VDEVICE(NVIDIA, 0x058f), board_ahci_mcp_linux }, /* Linux ID */
  438. { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci_mcp73 }, /* MCP73 */
  439. { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci_mcp73 }, /* MCP73 */
  440. { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci_mcp73 }, /* MCP73 */
  441. { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci_mcp73 }, /* MCP73 */
  442. { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci_mcp73 }, /* MCP73 */
  443. { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci_mcp73 }, /* MCP73 */
  444. { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci_mcp73 }, /* MCP73 */
  445. { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci_mcp73 }, /* MCP73 */
  446. { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci_mcp73 }, /* MCP73 */
  447. { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci_mcp73 }, /* MCP73 */
  448. { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci_mcp73 }, /* MCP73 */
  449. { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci_mcp73 }, /* MCP73 */
  450. { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci_mcp77 }, /* MCP77 */
  451. { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci_mcp77 }, /* MCP77 */
  452. { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci_mcp77 }, /* MCP77 */
  453. { PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci_mcp77 }, /* MCP77 */
  454. { PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci_mcp77 }, /* MCP77 */
  455. { PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci_mcp77 }, /* MCP77 */
  456. { PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci_mcp77 }, /* MCP77 */
  457. { PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci_mcp77 }, /* MCP77 */
  458. { PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci_mcp77 }, /* MCP77 */
  459. { PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci_mcp77 }, /* MCP77 */
  460. { PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci_mcp77 }, /* MCP77 */
  461. { PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci_mcp77 }, /* MCP77 */
  462. { PCI_VDEVICE(NVIDIA, 0x0ab4), board_ahci_mcp79 }, /* MCP79 */
  463. { PCI_VDEVICE(NVIDIA, 0x0ab5), board_ahci_mcp79 }, /* MCP79 */
  464. { PCI_VDEVICE(NVIDIA, 0x0ab6), board_ahci_mcp79 }, /* MCP79 */
  465. { PCI_VDEVICE(NVIDIA, 0x0ab7), board_ahci_mcp79 }, /* MCP79 */
  466. { PCI_VDEVICE(NVIDIA, 0x0ab8), board_ahci_mcp79 }, /* MCP79 */
  467. { PCI_VDEVICE(NVIDIA, 0x0ab9), board_ahci_mcp79 }, /* MCP79 */
  468. { PCI_VDEVICE(NVIDIA, 0x0aba), board_ahci_mcp79 }, /* MCP79 */
  469. { PCI_VDEVICE(NVIDIA, 0x0abb), board_ahci_mcp79 }, /* MCP79 */
  470. { PCI_VDEVICE(NVIDIA, 0x0abc), board_ahci_mcp79 }, /* MCP79 */
  471. { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci_mcp79 }, /* MCP79 */
  472. { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci_mcp79 }, /* MCP79 */
  473. { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci_mcp79 }, /* MCP79 */
  474. { PCI_VDEVICE(NVIDIA, 0x0d84), board_ahci_mcp89 }, /* MCP89 */
  475. { PCI_VDEVICE(NVIDIA, 0x0d85), board_ahci_mcp89 }, /* MCP89 */
  476. { PCI_VDEVICE(NVIDIA, 0x0d86), board_ahci_mcp89 }, /* MCP89 */
  477. { PCI_VDEVICE(NVIDIA, 0x0d87), board_ahci_mcp89 }, /* MCP89 */
  478. { PCI_VDEVICE(NVIDIA, 0x0d88), board_ahci_mcp89 }, /* MCP89 */
  479. { PCI_VDEVICE(NVIDIA, 0x0d89), board_ahci_mcp89 }, /* MCP89 */
  480. { PCI_VDEVICE(NVIDIA, 0x0d8a), board_ahci_mcp89 }, /* MCP89 */
  481. { PCI_VDEVICE(NVIDIA, 0x0d8b), board_ahci_mcp89 }, /* MCP89 */
  482. { PCI_VDEVICE(NVIDIA, 0x0d8c), board_ahci_mcp89 }, /* MCP89 */
  483. { PCI_VDEVICE(NVIDIA, 0x0d8d), board_ahci_mcp89 }, /* MCP89 */
  484. { PCI_VDEVICE(NVIDIA, 0x0d8e), board_ahci_mcp89 }, /* MCP89 */
  485. { PCI_VDEVICE(NVIDIA, 0x0d8f), board_ahci_mcp89 }, /* MCP89 */
  486. /* SiS */
  487. { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
  488. { PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 968 */
  489. { PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */
  490. /* ST Microelectronics */
  491. { PCI_VDEVICE(STMICRO, 0xCC06), board_ahci }, /* ST ConneXt */
  492. /* Marvell */
  493. { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
  494. { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
  495. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9123),
  496. .class = PCI_CLASS_STORAGE_SATA_AHCI,
  497. .class_mask = 0xffffff,
  498. .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
  499. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9125),
  500. .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
  501. { PCI_DEVICE_SUB(PCI_VENDOR_ID_MARVELL_EXT, 0x9178,
  502. PCI_VENDOR_ID_MARVELL_EXT, 0x9170),
  503. .driver_data = board_ahci_yes_fbs }, /* 88se9170 */
  504. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x917a),
  505. .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
  506. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9172),
  507. .driver_data = board_ahci_yes_fbs }, /* 88se9182 */
  508. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9182),
  509. .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
  510. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9192),
  511. .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */
  512. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0),
  513. .driver_data = board_ahci_yes_fbs },
  514. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a2), /* 88se91a2 */
  515. .driver_data = board_ahci_yes_fbs },
  516. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3),
  517. .driver_data = board_ahci_yes_fbs },
  518. { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
  519. .driver_data = board_ahci_yes_fbs },
  520. { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */
  521. .driver_data = board_ahci_yes_fbs },
  522. { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0645), /* highpoint rocketraid 644L */
  523. .driver_data = board_ahci_yes_fbs },
  524. /* Promise */
  525. { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
  526. { PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode */
  527. /* Asmedia */
  528. { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */
  529. { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */
  530. { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */
  531. { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
  532. /*
  533. * Samsung SSDs found on some macbooks. NCQ times out if MSI is
  534. * enabled. https://bugzilla.kernel.org/show_bug.cgi?id=60731
  535. */
  536. { PCI_VDEVICE(SAMSUNG, 0x1600), board_ahci_nomsi },
  537. { PCI_VDEVICE(SAMSUNG, 0xa800), board_ahci_nomsi },
  538. /* Enmotus */
  539. { PCI_DEVICE(0x1c44, 0x8000), board_ahci },
  540. /* Generic, PCI class code for AHCI */
  541. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  542. PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
  543. { } /* terminate list */
  544. };
  545. static struct pci_driver ahci_pci_driver = {
  546. .name = DRV_NAME,
  547. .id_table = ahci_pci_tbl,
  548. .probe = ahci_init_one,
  549. .remove = ata_pci_remove_one,
  550. #ifdef CONFIG_PM
  551. .suspend = ahci_pci_device_suspend,
  552. .resume = ahci_pci_device_resume,
  553. #endif
  554. };
  555. #if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
  556. static int marvell_enable;
  557. #else
  558. static int marvell_enable = 1;
  559. #endif
  560. module_param(marvell_enable, int, 0644);
  561. MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
  562. static void ahci_pci_save_initial_config(struct pci_dev *pdev,
  563. struct ahci_host_priv *hpriv)
  564. {
  565. if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
  566. dev_info(&pdev->dev, "JMB361 has only one port\n");
  567. hpriv->force_port_map = 1;
  568. }
  569. /*
  570. * Temporary Marvell 6145 hack: PATA port presence
  571. * is asserted through the standard AHCI port
  572. * presence register, as bit 4 (counting from 0)
  573. */
  574. if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
  575. if (pdev->device == 0x6121)
  576. hpriv->mask_port_map = 0x3;
  577. else
  578. hpriv->mask_port_map = 0xf;
  579. dev_info(&pdev->dev,
  580. "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
  581. }
  582. ahci_save_initial_config(&pdev->dev, hpriv);
  583. }
  584. static int ahci_pci_reset_controller(struct ata_host *host)
  585. {
  586. struct pci_dev *pdev = to_pci_dev(host->dev);
  587. int rc;
  588. rc = ahci_reset_controller(host);
  589. if (rc)
  590. return rc;
  591. if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
  592. struct ahci_host_priv *hpriv = host->private_data;
  593. u16 tmp16;
  594. /* configure PCS */
  595. pci_read_config_word(pdev, 0x92, &tmp16);
  596. if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
  597. tmp16 |= hpriv->port_map;
  598. pci_write_config_word(pdev, 0x92, tmp16);
  599. }
  600. }
  601. return 0;
  602. }
  603. static void ahci_pci_init_controller(struct ata_host *host)
  604. {
  605. struct ahci_host_priv *hpriv = host->private_data;
  606. struct pci_dev *pdev = to_pci_dev(host->dev);
  607. void __iomem *port_mmio;
  608. u32 tmp;
  609. int mv;
  610. if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
  611. if (pdev->device == 0x6121)
  612. mv = 2;
  613. else
  614. mv = 4;
  615. port_mmio = __ahci_port_base(host, mv);
  616. writel(0, port_mmio + PORT_IRQ_MASK);
  617. /* clear port IRQ */
  618. tmp = readl(port_mmio + PORT_IRQ_STAT);
  619. VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
  620. if (tmp)
  621. writel(tmp, port_mmio + PORT_IRQ_STAT);
  622. }
  623. ahci_init_controller(host);
  624. }
  625. static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
  626. unsigned long deadline)
  627. {
  628. struct ata_port *ap = link->ap;
  629. struct ahci_host_priv *hpriv = ap->host->private_data;
  630. bool online;
  631. int rc;
  632. DPRINTK("ENTER\n");
  633. ahci_stop_engine(ap);
  634. rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
  635. deadline, &online, NULL);
  636. hpriv->start_engine(ap);
  637. DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
  638. /* vt8251 doesn't clear BSY on signature FIS reception,
  639. * request follow-up softreset.
  640. */
  641. return online ? -EAGAIN : rc;
  642. }
  643. static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
  644. unsigned long deadline)
  645. {
  646. struct ata_port *ap = link->ap;
  647. struct ahci_port_priv *pp = ap->private_data;
  648. struct ahci_host_priv *hpriv = ap->host->private_data;
  649. u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
  650. struct ata_taskfile tf;
  651. bool online;
  652. int rc;
  653. ahci_stop_engine(ap);
  654. /* clear D2H reception area to properly wait for D2H FIS */
  655. ata_tf_init(link->device, &tf);
  656. tf.command = ATA_BUSY;
  657. ata_tf_to_fis(&tf, 0, 0, d2h_fis);
  658. rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
  659. deadline, &online, NULL);
  660. hpriv->start_engine(ap);
  661. /* The pseudo configuration device on SIMG4726 attached to
  662. * ASUS P5W-DH Deluxe doesn't send signature FIS after
  663. * hardreset if no device is attached to the first downstream
  664. * port && the pseudo device locks up on SRST w/ PMP==0. To
  665. * work around this, wait for !BSY only briefly. If BSY isn't
  666. * cleared, perform CLO and proceed to IDENTIFY (achieved by
  667. * ATA_LFLAG_NO_SRST and ATA_LFLAG_ASSUME_ATA).
  668. *
  669. * Wait for two seconds. Devices attached to downstream port
  670. * which can't process the following IDENTIFY after this will
  671. * have to be reset again. For most cases, this should
  672. * suffice while making probing snappish enough.
  673. */
  674. if (online) {
  675. rc = ata_wait_after_reset(link, jiffies + 2 * HZ,
  676. ahci_check_ready);
  677. if (rc)
  678. ahci_kick_engine(ap);
  679. }
  680. return rc;
  681. }
  682. /*
  683. * ahci_avn_hardreset - attempt more aggressive recovery of Avoton ports.
  684. *
  685. * It has been observed with some SSDs that the timing of events in the
  686. * link synchronization phase can leave the port in a state that can not
  687. * be recovered by a SATA-hard-reset alone. The failing signature is
  688. * SStatus.DET stuck at 1 ("Device presence detected but Phy
  689. * communication not established"). It was found that unloading and
  690. * reloading the driver when this problem occurs allows the drive
  691. * connection to be recovered (DET advanced to 0x3). The critical
  692. * component of reloading the driver is that the port state machines are
  693. * reset by bouncing "port enable" in the AHCI PCS configuration
  694. * register. So, reproduce that effect by bouncing a port whenever we
  695. * see DET==1 after a reset.
  696. */
  697. static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
  698. unsigned long deadline)
  699. {
  700. const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
  701. struct ata_port *ap = link->ap;
  702. struct ahci_port_priv *pp = ap->private_data;
  703. struct ahci_host_priv *hpriv = ap->host->private_data;
  704. u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
  705. unsigned long tmo = deadline - jiffies;
  706. struct ata_taskfile tf;
  707. bool online;
  708. int rc, i;
  709. DPRINTK("ENTER\n");
  710. ahci_stop_engine(ap);
  711. for (i = 0; i < 2; i++) {
  712. u16 val;
  713. u32 sstatus;
  714. int port = ap->port_no;
  715. struct ata_host *host = ap->host;
  716. struct pci_dev *pdev = to_pci_dev(host->dev);
  717. /* clear D2H reception area to properly wait for D2H FIS */
  718. ata_tf_init(link->device, &tf);
  719. tf.command = ATA_BUSY;
  720. ata_tf_to_fis(&tf, 0, 0, d2h_fis);
  721. rc = sata_link_hardreset(link, timing, deadline, &online,
  722. ahci_check_ready);
  723. if (sata_scr_read(link, SCR_STATUS, &sstatus) != 0 ||
  724. (sstatus & 0xf) != 1)
  725. break;
  726. ata_link_printk(link, KERN_INFO, "avn bounce port%d\n",
  727. port);
  728. pci_read_config_word(pdev, 0x92, &val);
  729. val &= ~(1 << port);
  730. pci_write_config_word(pdev, 0x92, val);
  731. ata_msleep(ap, 1000);
  732. val |= 1 << port;
  733. pci_write_config_word(pdev, 0x92, val);
  734. deadline += tmo;
  735. }
  736. hpriv->start_engine(ap);
  737. if (online)
  738. *class = ahci_dev_classify(ap);
  739. DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
  740. return rc;
  741. }
  742. #ifdef CONFIG_PM
  743. static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
  744. {
  745. struct ata_host *host = pci_get_drvdata(pdev);
  746. struct ahci_host_priv *hpriv = host->private_data;
  747. void __iomem *mmio = hpriv->mmio;
  748. u32 ctl;
  749. if (mesg.event & PM_EVENT_SUSPEND &&
  750. hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
  751. dev_err(&pdev->dev,
  752. "BIOS update required for suspend/resume\n");
  753. return -EIO;
  754. }
  755. if (mesg.event & PM_EVENT_SLEEP) {
  756. /* AHCI spec rev1.1 section 8.3.3:
  757. * Software must disable interrupts prior to requesting a
  758. * transition of the HBA to D3 state.
  759. */
  760. ctl = readl(mmio + HOST_CTL);
  761. ctl &= ~HOST_IRQ_EN;
  762. writel(ctl, mmio + HOST_CTL);
  763. readl(mmio + HOST_CTL); /* flush */
  764. }
  765. return ata_pci_device_suspend(pdev, mesg);
  766. }
  767. static int ahci_pci_device_resume(struct pci_dev *pdev)
  768. {
  769. struct ata_host *host = pci_get_drvdata(pdev);
  770. int rc;
  771. rc = ata_pci_device_do_resume(pdev);
  772. if (rc)
  773. return rc;
  774. /* Apple BIOS helpfully mangles the registers on resume */
  775. if (is_mcp89_apple(pdev))
  776. ahci_mcp89_apple_enable(pdev);
  777. if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
  778. rc = ahci_pci_reset_controller(host);
  779. if (rc)
  780. return rc;
  781. ahci_pci_init_controller(host);
  782. }
  783. ata_host_resume(host);
  784. return 0;
  785. }
  786. #endif
  787. static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
  788. {
  789. int rc;
  790. /*
  791. * If the device fixup already set the dma_mask to some non-standard
  792. * value, don't extend it here. This happens on STA2X11, for example.
  793. */
  794. if (pdev->dma_mask && pdev->dma_mask < DMA_BIT_MASK(32))
  795. return 0;
  796. if (using_dac &&
  797. !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
  798. rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
  799. if (rc) {
  800. rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
  801. if (rc) {
  802. dev_err(&pdev->dev,
  803. "64-bit DMA enable failed\n");
  804. return rc;
  805. }
  806. }
  807. } else {
  808. rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
  809. if (rc) {
  810. dev_err(&pdev->dev, "32-bit DMA enable failed\n");
  811. return rc;
  812. }
  813. rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
  814. if (rc) {
  815. dev_err(&pdev->dev,
  816. "32-bit consistent DMA enable failed\n");
  817. return rc;
  818. }
  819. }
  820. return 0;
  821. }
  822. static void ahci_pci_print_info(struct ata_host *host)
  823. {
  824. struct pci_dev *pdev = to_pci_dev(host->dev);
  825. u16 cc;
  826. const char *scc_s;
  827. pci_read_config_word(pdev, 0x0a, &cc);
  828. if (cc == PCI_CLASS_STORAGE_IDE)
  829. scc_s = "IDE";
  830. else if (cc == PCI_CLASS_STORAGE_SATA)
  831. scc_s = "SATA";
  832. else if (cc == PCI_CLASS_STORAGE_RAID)
  833. scc_s = "RAID";
  834. else
  835. scc_s = "unknown";
  836. ahci_print_info(host, scc_s);
  837. }
  838. /* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is
  839. * hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't
  840. * support PMP and the 4726 either directly exports the device
  841. * attached to the first downstream port or acts as a hardware storage
  842. * controller and emulate a single ATA device (can be RAID 0/1 or some
  843. * other configuration).
  844. *
  845. * When there's no device attached to the first downstream port of the
  846. * 4726, "Config Disk" appears, which is a pseudo ATA device to
  847. * configure the 4726. However, ATA emulation of the device is very
  848. * lame. It doesn't send signature D2H Reg FIS after the initial
  849. * hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues.
  850. *
  851. * The following function works around the problem by always using
  852. * hardreset on the port and not depending on receiving signature FIS
  853. * afterward. If signature FIS isn't received soon, ATA class is
  854. * assumed without follow-up softreset.
  855. */
  856. static void ahci_p5wdh_workaround(struct ata_host *host)
  857. {
  858. static const struct dmi_system_id sysids[] = {
  859. {
  860. .ident = "P5W DH Deluxe",
  861. .matches = {
  862. DMI_MATCH(DMI_SYS_VENDOR,
  863. "ASUSTEK COMPUTER INC"),
  864. DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"),
  865. },
  866. },
  867. { }
  868. };
  869. struct pci_dev *pdev = to_pci_dev(host->dev);
  870. if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) &&
  871. dmi_check_system(sysids)) {
  872. struct ata_port *ap = host->ports[1];
  873. dev_info(&pdev->dev,
  874. "enabling ASUS P5W DH Deluxe on-board SIMG4726 workaround\n");
  875. ap->ops = &ahci_p5wdh_ops;
  876. ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA;
  877. }
  878. }
  879. /*
  880. * Macbook7,1 firmware forcibly disables MCP89 AHCI and changes PCI ID when
  881. * booting in BIOS compatibility mode. We restore the registers but not ID.
  882. */
  883. static void ahci_mcp89_apple_enable(struct pci_dev *pdev)
  884. {
  885. u32 val;
  886. printk(KERN_INFO "ahci: enabling MCP89 AHCI mode\n");
  887. pci_read_config_dword(pdev, 0xf8, &val);
  888. val |= 1 << 0x1b;
  889. /* the following changes the device ID, but appears not to affect function */
  890. /* val = (val & ~0xf0000000) | 0x80000000; */
  891. pci_write_config_dword(pdev, 0xf8, val);
  892. pci_read_config_dword(pdev, 0x54c, &val);
  893. val |= 1 << 0xc;
  894. pci_write_config_dword(pdev, 0x54c, val);
  895. pci_read_config_dword(pdev, 0x4a4, &val);
  896. val &= 0xff;
  897. val |= 0x01060100;
  898. pci_write_config_dword(pdev, 0x4a4, val);
  899. pci_read_config_dword(pdev, 0x54c, &val);
  900. val &= ~(1 << 0xc);
  901. pci_write_config_dword(pdev, 0x54c, val);
  902. pci_read_config_dword(pdev, 0xf8, &val);
  903. val &= ~(1 << 0x1b);
  904. pci_write_config_dword(pdev, 0xf8, val);
  905. }
  906. static bool is_mcp89_apple(struct pci_dev *pdev)
  907. {
  908. return pdev->vendor == PCI_VENDOR_ID_NVIDIA &&
  909. pdev->device == PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA &&
  910. pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE &&
  911. pdev->subsystem_device == 0xcb89;
  912. }
  913. /* only some SB600 ahci controllers can do 64bit DMA */
  914. static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
  915. {
  916. static const struct dmi_system_id sysids[] = {
  917. /*
  918. * The oldest version known to be broken is 0901 and
  919. * working is 1501 which was released on 2007-10-26.
  920. * Enable 64bit DMA on 1501 and anything newer.
  921. *
  922. * Please read bko#9412 for more info.
  923. */
  924. {
  925. .ident = "ASUS M2A-VM",
  926. .matches = {
  927. DMI_MATCH(DMI_BOARD_VENDOR,
  928. "ASUSTeK Computer INC."),
  929. DMI_MATCH(DMI_BOARD_NAME, "M2A-VM"),
  930. },
  931. .driver_data = "20071026", /* yyyymmdd */
  932. },
  933. /*
  934. * All BIOS versions for the MSI K9A2 Platinum (MS-7376)
  935. * support 64bit DMA.
  936. *
  937. * BIOS versions earlier than 1.5 had the Manufacturer DMI
  938. * fields as "MICRO-STAR INTERANTIONAL CO.,LTD".
  939. * This spelling mistake was fixed in BIOS version 1.5, so
  940. * 1.5 and later have the Manufacturer as
  941. * "MICRO-STAR INTERNATIONAL CO.,LTD".
  942. * So try to match on DMI_BOARD_VENDOR of "MICRO-STAR INTER".
  943. *
  944. * BIOS versions earlier than 1.9 had a Board Product Name
  945. * DMI field of "MS-7376". This was changed to be
  946. * "K9A2 Platinum (MS-7376)" in version 1.9, but we can still
  947. * match on DMI_BOARD_NAME of "MS-7376".
  948. */
  949. {
  950. .ident = "MSI K9A2 Platinum",
  951. .matches = {
  952. DMI_MATCH(DMI_BOARD_VENDOR,
  953. "MICRO-STAR INTER"),
  954. DMI_MATCH(DMI_BOARD_NAME, "MS-7376"),
  955. },
  956. },
  957. /*
  958. * All BIOS versions for the MSI K9AGM2 (MS-7327) support
  959. * 64bit DMA.
  960. *
  961. * This board also had the typo mentioned above in the
  962. * Manufacturer DMI field (fixed in BIOS version 1.5), so
  963. * match on DMI_BOARD_VENDOR of "MICRO-STAR INTER" again.
  964. */
  965. {
  966. .ident = "MSI K9AGM2",
  967. .matches = {
  968. DMI_MATCH(DMI_BOARD_VENDOR,
  969. "MICRO-STAR INTER"),
  970. DMI_MATCH(DMI_BOARD_NAME, "MS-7327"),
  971. },
  972. },
  973. /*
  974. * All BIOS versions for the Asus M3A support 64bit DMA.
  975. * (all release versions from 0301 to 1206 were tested)
  976. */
  977. {
  978. .ident = "ASUS M3A",
  979. .matches = {
  980. DMI_MATCH(DMI_BOARD_VENDOR,
  981. "ASUSTeK Computer INC."),
  982. DMI_MATCH(DMI_BOARD_NAME, "M3A"),
  983. },
  984. },
  985. { }
  986. };
  987. const struct dmi_system_id *match;
  988. int year, month, date;
  989. char buf[9];
  990. match = dmi_first_match(sysids);
  991. if (pdev->bus->number != 0 || pdev->devfn != PCI_DEVFN(0x12, 0) ||
  992. !match)
  993. return false;
  994. if (!match->driver_data)
  995. goto enable_64bit;
  996. dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
  997. snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
  998. if (strcmp(buf, match->driver_data) >= 0)
  999. goto enable_64bit;
  1000. else {
  1001. dev_warn(&pdev->dev,
  1002. "%s: BIOS too old, forcing 32bit DMA, update BIOS\n",
  1003. match->ident);
  1004. return false;
  1005. }
  1006. enable_64bit:
  1007. dev_warn(&pdev->dev, "%s: enabling 64bit DMA\n", match->ident);
  1008. return true;
  1009. }
  1010. static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
  1011. {
  1012. static const struct dmi_system_id broken_systems[] = {
  1013. {
  1014. .ident = "HP Compaq nx6310",
  1015. .matches = {
  1016. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1017. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6310"),
  1018. },
  1019. /* PCI slot number of the controller */
  1020. .driver_data = (void *)0x1FUL,
  1021. },
  1022. {
  1023. .ident = "HP Compaq 6720s",
  1024. .matches = {
  1025. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1026. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6720s"),
  1027. },
  1028. /* PCI slot number of the controller */
  1029. .driver_data = (void *)0x1FUL,
  1030. },
  1031. { } /* terminate list */
  1032. };
  1033. const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
  1034. if (dmi) {
  1035. unsigned long slot = (unsigned long)dmi->driver_data;
  1036. /* apply the quirk only to on-board controllers */
  1037. return slot == PCI_SLOT(pdev->devfn);
  1038. }
  1039. return false;
  1040. }
  1041. static bool ahci_broken_suspend(struct pci_dev *pdev)
  1042. {
  1043. static const struct dmi_system_id sysids[] = {
  1044. /*
  1045. * On HP dv[4-6] and HDX18 with earlier BIOSen, link
  1046. * to the harddisk doesn't become online after
  1047. * resuming from STR. Warn and fail suspend.
  1048. *
  1049. * http://bugzilla.kernel.org/show_bug.cgi?id=12276
  1050. *
  1051. * Use dates instead of versions to match as HP is
  1052. * apparently recycling both product and version
  1053. * strings.
  1054. *
  1055. * http://bugzilla.kernel.org/show_bug.cgi?id=15462
  1056. */
  1057. {
  1058. .ident = "dv4",
  1059. .matches = {
  1060. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1061. DMI_MATCH(DMI_PRODUCT_NAME,
  1062. "HP Pavilion dv4 Notebook PC"),
  1063. },
  1064. .driver_data = "20090105", /* F.30 */
  1065. },
  1066. {
  1067. .ident = "dv5",
  1068. .matches = {
  1069. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1070. DMI_MATCH(DMI_PRODUCT_NAME,
  1071. "HP Pavilion dv5 Notebook PC"),
  1072. },
  1073. .driver_data = "20090506", /* F.16 */
  1074. },
  1075. {
  1076. .ident = "dv6",
  1077. .matches = {
  1078. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1079. DMI_MATCH(DMI_PRODUCT_NAME,
  1080. "HP Pavilion dv6 Notebook PC"),
  1081. },
  1082. .driver_data = "20090423", /* F.21 */
  1083. },
  1084. {
  1085. .ident = "HDX18",
  1086. .matches = {
  1087. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1088. DMI_MATCH(DMI_PRODUCT_NAME,
  1089. "HP HDX18 Notebook PC"),
  1090. },
  1091. .driver_data = "20090430", /* F.23 */
  1092. },
  1093. /*
  1094. * Acer eMachines G725 has the same problem. BIOS
  1095. * V1.03 is known to be broken. V3.04 is known to
  1096. * work. Between, there are V1.06, V2.06 and V3.03
  1097. * that we don't have much idea about. For now,
  1098. * blacklist anything older than V3.04.
  1099. *
  1100. * http://bugzilla.kernel.org/show_bug.cgi?id=15104
  1101. */
  1102. {
  1103. .ident = "G725",
  1104. .matches = {
  1105. DMI_MATCH(DMI_SYS_VENDOR, "eMachines"),
  1106. DMI_MATCH(DMI_PRODUCT_NAME, "eMachines G725"),
  1107. },
  1108. .driver_data = "20091216", /* V3.04 */
  1109. },
  1110. { } /* terminate list */
  1111. };
  1112. const struct dmi_system_id *dmi = dmi_first_match(sysids);
  1113. int year, month, date;
  1114. char buf[9];
  1115. if (!dmi || pdev->bus->number || pdev->devfn != PCI_DEVFN(0x1f, 2))
  1116. return false;
  1117. dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
  1118. snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
  1119. return strcmp(buf, dmi->driver_data) < 0;
  1120. }
  1121. static bool ahci_broken_lpm(struct pci_dev *pdev)
  1122. {
  1123. static const struct dmi_system_id sysids[] = {
  1124. /* Various Lenovo 50 series have LPM issues with older BIOSen */
  1125. {
  1126. .matches = {
  1127. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  1128. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X250"),
  1129. },
  1130. .driver_data = "20180406", /* 1.31 */
  1131. },
  1132. {
  1133. .matches = {
  1134. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  1135. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L450"),
  1136. },
  1137. .driver_data = "20180420", /* 1.28 */
  1138. },
  1139. {
  1140. .matches = {
  1141. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  1142. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T450s"),
  1143. },
  1144. .driver_data = "20180315", /* 1.33 */
  1145. },
  1146. {
  1147. .matches = {
  1148. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  1149. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
  1150. },
  1151. /*
  1152. * Note date based on release notes, 2.35 has been
  1153. * reported to be good, but I've been unable to get
  1154. * a hold of the reporter to get the DMI BIOS date.
  1155. * TODO: fix this.
  1156. */
  1157. .driver_data = "20180310", /* 2.35 */
  1158. },
  1159. { } /* terminate list */
  1160. };
  1161. const struct dmi_system_id *dmi = dmi_first_match(sysids);
  1162. int year, month, date;
  1163. char buf[9];
  1164. if (!dmi)
  1165. return false;
  1166. dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
  1167. snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
  1168. return strcmp(buf, dmi->driver_data) < 0;
  1169. }
  1170. static bool ahci_broken_online(struct pci_dev *pdev)
  1171. {
  1172. #define ENCODE_BUSDEVFN(bus, slot, func) \
  1173. (void *)(unsigned long)(((bus) << 8) | PCI_DEVFN((slot), (func)))
  1174. static const struct dmi_system_id sysids[] = {
  1175. /*
  1176. * There are several gigabyte boards which use
  1177. * SIMG5723s configured as hardware RAID. Certain
  1178. * 5723 firmware revisions shipped there keep the link
  1179. * online but fail to answer properly to SRST or
  1180. * IDENTIFY when no device is attached downstream
  1181. * causing libata to retry quite a few times leading
  1182. * to excessive detection delay.
  1183. *
  1184. * As these firmwares respond to the second reset try
  1185. * with invalid device signature, considering unknown
  1186. * sig as offline works around the problem acceptably.
  1187. */
  1188. {
  1189. .ident = "EP45-DQ6",
  1190. .matches = {
  1191. DMI_MATCH(DMI_BOARD_VENDOR,
  1192. "Gigabyte Technology Co., Ltd."),
  1193. DMI_MATCH(DMI_BOARD_NAME, "EP45-DQ6"),
  1194. },
  1195. .driver_data = ENCODE_BUSDEVFN(0x0a, 0x00, 0),
  1196. },
  1197. {
  1198. .ident = "EP45-DS5",
  1199. .matches = {
  1200. DMI_MATCH(DMI_BOARD_VENDOR,
  1201. "Gigabyte Technology Co., Ltd."),
  1202. DMI_MATCH(DMI_BOARD_NAME, "EP45-DS5"),
  1203. },
  1204. .driver_data = ENCODE_BUSDEVFN(0x03, 0x00, 0),
  1205. },
  1206. { } /* terminate list */
  1207. };
  1208. #undef ENCODE_BUSDEVFN
  1209. const struct dmi_system_id *dmi = dmi_first_match(sysids);
  1210. unsigned int val;
  1211. if (!dmi)
  1212. return false;
  1213. val = (unsigned long)dmi->driver_data;
  1214. return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff);
  1215. }
  1216. static bool ahci_broken_devslp(struct pci_dev *pdev)
  1217. {
  1218. /* device with broken DEVSLP but still showing SDS capability */
  1219. static const struct pci_device_id ids[] = {
  1220. { PCI_VDEVICE(INTEL, 0x0f23)}, /* Valleyview SoC */
  1221. {}
  1222. };
  1223. return pci_match_id(ids, pdev);
  1224. }
  1225. #ifdef CONFIG_ATA_ACPI
  1226. static void ahci_gtf_filter_workaround(struct ata_host *host)
  1227. {
  1228. static const struct dmi_system_id sysids[] = {
  1229. /*
  1230. * Aspire 3810T issues a bunch of SATA enable commands
  1231. * via _GTF including an invalid one and one which is
  1232. * rejected by the device. Among the successful ones
  1233. * is FPDMA non-zero offset enable which when enabled
  1234. * only on the drive side leads to NCQ command
  1235. * failures. Filter it out.
  1236. */
  1237. {
  1238. .ident = "Aspire 3810T",
  1239. .matches = {
  1240. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1241. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3810T"),
  1242. },
  1243. .driver_data = (void *)ATA_ACPI_FILTER_FPDMA_OFFSET,
  1244. },
  1245. { }
  1246. };
  1247. const struct dmi_system_id *dmi = dmi_first_match(sysids);
  1248. unsigned int filter;
  1249. int i;
  1250. if (!dmi)
  1251. return;
  1252. filter = (unsigned long)dmi->driver_data;
  1253. dev_info(host->dev, "applying extra ACPI _GTF filter 0x%x for %s\n",
  1254. filter, dmi->ident);
  1255. for (i = 0; i < host->n_ports; i++) {
  1256. struct ata_port *ap = host->ports[i];
  1257. struct ata_link *link;
  1258. struct ata_device *dev;
  1259. ata_for_each_link(link, ap, EDGE)
  1260. ata_for_each_dev(dev, link, ALL)
  1261. dev->gtf_filter |= filter;
  1262. }
  1263. }
  1264. #else
  1265. static inline void ahci_gtf_filter_workaround(struct ata_host *host)
  1266. {}
  1267. #endif
  1268. /*
  1269. * ahci_init_msix() only implements single MSI-X support, not multiple
  1270. * MSI-X per-port interrupts. This is needed for host controllers that only
  1271. * have MSI-X support implemented, but no MSI or intx.
  1272. */
  1273. static int ahci_init_msix(struct pci_dev *pdev, unsigned int n_ports,
  1274. struct ahci_host_priv *hpriv)
  1275. {
  1276. int rc, nvec;
  1277. struct msix_entry entry = {};
  1278. /* Do not init MSI-X if MSI is disabled for the device */
  1279. if (hpriv->flags & AHCI_HFLAG_NO_MSI)
  1280. return -ENODEV;
  1281. nvec = pci_msix_vec_count(pdev);
  1282. if (nvec < 0)
  1283. return nvec;
  1284. if (!nvec) {
  1285. rc = -ENODEV;
  1286. goto fail;
  1287. }
  1288. /*
  1289. * There can be more than one vector (e.g. for error detection or
  1290. * hdd hotplug). Only the first vector (entry.entry = 0) is used.
  1291. */
  1292. rc = pci_enable_msix_exact(pdev, &entry, 1);
  1293. if (rc < 0)
  1294. goto fail;
  1295. hpriv->irq = entry.vector;
  1296. return 1;
  1297. fail:
  1298. dev_err(&pdev->dev,
  1299. "failed to enable MSI-X with error %d, # of vectors: %d\n",
  1300. rc, nvec);
  1301. return rc;
  1302. }
  1303. static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
  1304. struct ahci_host_priv *hpriv)
  1305. {
  1306. int rc, nvec;
  1307. if (hpriv->flags & AHCI_HFLAG_NO_MSI)
  1308. return -ENODEV;
  1309. nvec = pci_msi_vec_count(pdev);
  1310. if (nvec < 0)
  1311. return nvec;
  1312. /*
  1313. * If number of MSIs is less than number of ports then Sharing Last
  1314. * Message mode could be enforced. In this case assume that advantage
  1315. * of multipe MSIs is negated and use single MSI mode instead.
  1316. */
  1317. if (nvec < n_ports)
  1318. goto single_msi;
  1319. rc = pci_enable_msi_exact(pdev, nvec);
  1320. if (rc == -ENOSPC)
  1321. goto single_msi;
  1322. if (rc < 0)
  1323. return rc;
  1324. /* fallback to single MSI mode if the controller enforced MRSM mode */
  1325. if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) {
  1326. pci_disable_msi(pdev);
  1327. printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n");
  1328. goto single_msi;
  1329. }
  1330. if (nvec > 1)
  1331. hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
  1332. goto out;
  1333. single_msi:
  1334. nvec = 1;
  1335. rc = pci_enable_msi(pdev);
  1336. if (rc < 0)
  1337. return rc;
  1338. out:
  1339. hpriv->irq = pdev->irq;
  1340. return nvec;
  1341. }
  1342. static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
  1343. struct ahci_host_priv *hpriv)
  1344. {
  1345. int nvec;
  1346. nvec = ahci_init_msi(pdev, n_ports, hpriv);
  1347. if (nvec >= 0)
  1348. return nvec;
  1349. /*
  1350. * Currently, MSI-X support only implements single IRQ mode and
  1351. * exists for controllers which can't do other types of IRQ. Only
  1352. * set it up if MSI fails.
  1353. */
  1354. nvec = ahci_init_msix(pdev, n_ports, hpriv);
  1355. if (nvec >= 0)
  1356. return nvec;
  1357. /* lagacy intx interrupts */
  1358. pci_intx(pdev, 1);
  1359. hpriv->irq = pdev->irq;
  1360. return 0;
  1361. }
  1362. static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
  1363. {
  1364. unsigned int board_id = ent->driver_data;
  1365. struct ata_port_info pi = ahci_port_info[board_id];
  1366. const struct ata_port_info *ppi[] = { &pi, NULL };
  1367. struct device *dev = &pdev->dev;
  1368. struct ahci_host_priv *hpriv;
  1369. struct ata_host *host;
  1370. int n_ports, i, rc;
  1371. int ahci_pci_bar = AHCI_PCI_BAR_STANDARD;
  1372. VPRINTK("ENTER\n");
  1373. WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS);
  1374. ata_print_version_once(&pdev->dev, DRV_VERSION);
  1375. /* The AHCI driver can only drive the SATA ports, the PATA driver
  1376. can drive them all so if both drivers are selected make sure
  1377. AHCI stays out of the way */
  1378. if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable)
  1379. return -ENODEV;
  1380. /* Apple BIOS on MCP89 prevents us using AHCI */
  1381. if (is_mcp89_apple(pdev))
  1382. ahci_mcp89_apple_enable(pdev);
  1383. /* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode.
  1384. * At the moment, we can only use the AHCI mode. Let the users know
  1385. * that for SAS drives they're out of luck.
  1386. */
  1387. if (pdev->vendor == PCI_VENDOR_ID_PROMISE)
  1388. dev_info(&pdev->dev,
  1389. "PDC42819 can only drive SATA devices with this driver\n");
  1390. /* Some devices use non-standard BARs */
  1391. if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)
  1392. ahci_pci_bar = AHCI_PCI_BAR_STA2X11;
  1393. else if (pdev->vendor == 0x1c44 && pdev->device == 0x8000)
  1394. ahci_pci_bar = AHCI_PCI_BAR_ENMOTUS;
  1395. else if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
  1396. ahci_pci_bar = AHCI_PCI_BAR_CAVIUM;
  1397. /* acquire resources */
  1398. rc = pcim_enable_device(pdev);
  1399. if (rc)
  1400. return rc;
  1401. if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
  1402. (pdev->device == 0x2652 || pdev->device == 0x2653)) {
  1403. u8 map;
  1404. /* ICH6s share the same PCI ID for both piix and ahci
  1405. * modes. Enabling ahci mode while MAP indicates
  1406. * combined mode is a bad idea. Yield to ata_piix.
  1407. */
  1408. pci_read_config_byte(pdev, ICH_MAP, &map);
  1409. if (map & 0x3) {
  1410. dev_info(&pdev->dev,
  1411. "controller is in combined mode, can't enable AHCI mode\n");
  1412. return -ENODEV;
  1413. }
  1414. }
  1415. /* AHCI controllers often implement SFF compatible interface.
  1416. * Grab all PCI BARs just in case.
  1417. */
  1418. rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME);
  1419. if (rc == -EBUSY)
  1420. pcim_pin_device(pdev);
  1421. if (rc)
  1422. return rc;
  1423. hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
  1424. if (!hpriv)
  1425. return -ENOMEM;
  1426. hpriv->flags |= (unsigned long)pi.private_data;
  1427. /* MCP65 revision A1 and A2 can't do MSI */
  1428. if (board_id == board_ahci_mcp65 &&
  1429. (pdev->revision == 0xa1 || pdev->revision == 0xa2))
  1430. hpriv->flags |= AHCI_HFLAG_NO_MSI;
  1431. /* SB800 does NOT need the workaround to ignore SERR_INTERNAL */
  1432. if (board_id == board_ahci_sb700 && pdev->revision >= 0x40)
  1433. hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL;
  1434. /* only some SB600s can do 64bit DMA */
  1435. if (ahci_sb600_enable_64bit(pdev))
  1436. hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
  1437. hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
  1438. /* must set flag prior to save config in order to take effect */
  1439. if (ahci_broken_devslp(pdev))
  1440. hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
  1441. /* save initial config */
  1442. ahci_pci_save_initial_config(pdev, hpriv);
  1443. /* prepare host */
  1444. if (hpriv->cap & HOST_CAP_NCQ) {
  1445. pi.flags |= ATA_FLAG_NCQ;
  1446. /*
  1447. * Auto-activate optimization is supposed to be
  1448. * supported on all AHCI controllers indicating NCQ
  1449. * capability, but it seems to be broken on some
  1450. * chipsets including NVIDIAs.
  1451. */
  1452. if (!(hpriv->flags & AHCI_HFLAG_NO_FPDMA_AA))
  1453. pi.flags |= ATA_FLAG_FPDMA_AA;
  1454. /*
  1455. * All AHCI controllers should be forward-compatible
  1456. * with the new auxiliary field. This code should be
  1457. * conditionalized if any buggy AHCI controllers are
  1458. * encountered.
  1459. */
  1460. pi.flags |= ATA_FLAG_FPDMA_AUX;
  1461. }
  1462. if (hpriv->cap & HOST_CAP_PMP)
  1463. pi.flags |= ATA_FLAG_PMP;
  1464. ahci_set_em_messages(hpriv, &pi);
  1465. if (ahci_broken_system_poweroff(pdev)) {
  1466. pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN;
  1467. dev_info(&pdev->dev,
  1468. "quirky BIOS, skipping spindown on poweroff\n");
  1469. }
  1470. if (ahci_broken_lpm(pdev)) {
  1471. pi.flags |= ATA_FLAG_NO_LPM;
  1472. dev_warn(&pdev->dev,
  1473. "BIOS update required for Link Power Management support\n");
  1474. }
  1475. if (ahci_broken_suspend(pdev)) {
  1476. hpriv->flags |= AHCI_HFLAG_NO_SUSPEND;
  1477. dev_warn(&pdev->dev,
  1478. "BIOS update required for suspend/resume\n");
  1479. }
  1480. if (ahci_broken_online(pdev)) {
  1481. hpriv->flags |= AHCI_HFLAG_SRST_TOUT_IS_OFFLINE;
  1482. dev_info(&pdev->dev,
  1483. "online status unreliable, applying workaround\n");
  1484. }
  1485. /* CAP.NP sometimes indicate the index of the last enabled
  1486. * port, at other times, that of the last possible port, so
  1487. * determining the maximum port number requires looking at
  1488. * both CAP.NP and port_map.
  1489. */
  1490. n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
  1491. host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
  1492. if (!host)
  1493. return -ENOMEM;
  1494. host->private_data = hpriv;
  1495. ahci_init_interrupts(pdev, n_ports, hpriv);
  1496. if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
  1497. host->flags |= ATA_HOST_PARALLEL_SCAN;
  1498. else
  1499. dev_info(&pdev->dev, "SSS flag set, parallel bus scan disabled\n");
  1500. if (pi.flags & ATA_FLAG_EM)
  1501. ahci_reset_em(host);
  1502. for (i = 0; i < host->n_ports; i++) {
  1503. struct ata_port *ap = host->ports[i];
  1504. ata_port_pbar_desc(ap, ahci_pci_bar, -1, "abar");
  1505. ata_port_pbar_desc(ap, ahci_pci_bar,
  1506. 0x100 + ap->port_no * 0x80, "port");
  1507. /* set enclosure management message type */
  1508. if (ap->flags & ATA_FLAG_EM)
  1509. ap->em_message_type = hpriv->em_msg_type;
  1510. /* disabled/not-implemented port */
  1511. if (!(hpriv->port_map & (1 << i)))
  1512. ap->ops = &ata_dummy_port_ops;
  1513. }
  1514. /* apply workaround for ASUS P5W DH Deluxe mainboard */
  1515. ahci_p5wdh_workaround(host);
  1516. /* apply gtf filter quirk */
  1517. ahci_gtf_filter_workaround(host);
  1518. /* initialize adapter */
  1519. rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
  1520. if (rc)
  1521. return rc;
  1522. rc = ahci_pci_reset_controller(host);
  1523. if (rc)
  1524. return rc;
  1525. ahci_pci_init_controller(host);
  1526. ahci_pci_print_info(host);
  1527. pci_set_master(pdev);
  1528. return ahci_host_activate(host, &ahci_sht);
  1529. }
  1530. module_pci_driver(ahci_pci_driver);
  1531. MODULE_AUTHOR("Jeff Garzik");
  1532. MODULE_DESCRIPTION("AHCI SATA low-level driver");
  1533. MODULE_LICENSE("GPL");
  1534. MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
  1535. MODULE_VERSION(DRV_VERSION);