ahci.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. /*
  2. * ahci.c - AHCI SATA support
  3. *
  4. * Maintained by: Jeff Garzik <jgarzik@pobox.com>
  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/init.h>
  38. #include <linux/blkdev.h>
  39. #include <linux/delay.h>
  40. #include <linux/interrupt.h>
  41. #include <linux/sched.h>
  42. #include <linux/dma-mapping.h>
  43. #include "scsi.h"
  44. #include <scsi/scsi_host.h>
  45. #include <linux/libata.h>
  46. #include <asm/io.h>
  47. #define DRV_NAME "ahci"
  48. #define DRV_VERSION "1.01"
  49. enum {
  50. AHCI_PCI_BAR = 5,
  51. AHCI_MAX_SG = 168, /* hardware max is 64K */
  52. AHCI_DMA_BOUNDARY = 0xffffffff,
  53. AHCI_USE_CLUSTERING = 0,
  54. AHCI_CMD_SLOT_SZ = 32 * 32,
  55. AHCI_RX_FIS_SZ = 256,
  56. AHCI_CMD_TBL_HDR = 0x80,
  57. AHCI_CMD_TBL_CDB = 0x40,
  58. AHCI_CMD_TBL_SZ = AHCI_CMD_TBL_HDR + (AHCI_MAX_SG * 16),
  59. AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_SZ +
  60. AHCI_RX_FIS_SZ,
  61. AHCI_IRQ_ON_SG = (1 << 31),
  62. AHCI_CMD_ATAPI = (1 << 5),
  63. AHCI_CMD_WRITE = (1 << 6),
  64. RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
  65. board_ahci = 0,
  66. /* global controller registers */
  67. HOST_CAP = 0x00, /* host capabilities */
  68. HOST_CTL = 0x04, /* global host control */
  69. HOST_IRQ_STAT = 0x08, /* interrupt status */
  70. HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */
  71. HOST_VERSION = 0x10, /* AHCI spec. version compliancy */
  72. /* HOST_CTL bits */
  73. HOST_RESET = (1 << 0), /* reset controller; self-clear */
  74. HOST_IRQ_EN = (1 << 1), /* global IRQ enable */
  75. HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
  76. /* HOST_CAP bits */
  77. HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
  78. /* registers for each SATA port */
  79. PORT_LST_ADDR = 0x00, /* command list DMA addr */
  80. PORT_LST_ADDR_HI = 0x04, /* command list DMA addr hi */
  81. PORT_FIS_ADDR = 0x08, /* FIS rx buf addr */
  82. PORT_FIS_ADDR_HI = 0x0c, /* FIS rx buf addr hi */
  83. PORT_IRQ_STAT = 0x10, /* interrupt status */
  84. PORT_IRQ_MASK = 0x14, /* interrupt enable/disable mask */
  85. PORT_CMD = 0x18, /* port command */
  86. PORT_TFDATA = 0x20, /* taskfile data */
  87. PORT_SIG = 0x24, /* device TF signature */
  88. PORT_CMD_ISSUE = 0x38, /* command issue */
  89. PORT_SCR = 0x28, /* SATA phy register block */
  90. PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */
  91. PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */
  92. PORT_SCR_ERR = 0x30, /* SATA phy register: SError */
  93. PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */
  94. /* PORT_IRQ_{STAT,MASK} bits */
  95. PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */
  96. PORT_IRQ_TF_ERR = (1 << 30), /* task file error */
  97. PORT_IRQ_HBUS_ERR = (1 << 29), /* host bus fatal error */
  98. PORT_IRQ_HBUS_DATA_ERR = (1 << 28), /* host bus data error */
  99. PORT_IRQ_IF_ERR = (1 << 27), /* interface fatal error */
  100. PORT_IRQ_IF_NONFATAL = (1 << 26), /* interface non-fatal error */
  101. PORT_IRQ_OVERFLOW = (1 << 24), /* xfer exhausted available S/G */
  102. PORT_IRQ_BAD_PMP = (1 << 23), /* incorrect port multiplier */
  103. PORT_IRQ_PHYRDY = (1 << 22), /* PhyRdy changed */
  104. PORT_IRQ_DEV_ILCK = (1 << 7), /* device interlock */
  105. PORT_IRQ_CONNECT = (1 << 6), /* port connect change status */
  106. PORT_IRQ_SG_DONE = (1 << 5), /* descriptor processed */
  107. PORT_IRQ_UNK_FIS = (1 << 4), /* unknown FIS rx'd */
  108. PORT_IRQ_SDB_FIS = (1 << 3), /* Set Device Bits FIS rx'd */
  109. PORT_IRQ_DMAS_FIS = (1 << 2), /* DMA Setup FIS rx'd */
  110. PORT_IRQ_PIOS_FIS = (1 << 1), /* PIO Setup FIS rx'd */
  111. PORT_IRQ_D2H_REG_FIS = (1 << 0), /* D2H Register FIS rx'd */
  112. PORT_IRQ_FATAL = PORT_IRQ_TF_ERR |
  113. PORT_IRQ_HBUS_ERR |
  114. PORT_IRQ_HBUS_DATA_ERR |
  115. PORT_IRQ_IF_ERR,
  116. DEF_PORT_IRQ = PORT_IRQ_FATAL | PORT_IRQ_PHYRDY |
  117. PORT_IRQ_CONNECT | PORT_IRQ_SG_DONE |
  118. PORT_IRQ_UNK_FIS | PORT_IRQ_SDB_FIS |
  119. PORT_IRQ_DMAS_FIS | PORT_IRQ_PIOS_FIS |
  120. PORT_IRQ_D2H_REG_FIS,
  121. /* PORT_CMD bits */
  122. PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */
  123. PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */
  124. PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */
  125. PORT_CMD_POWER_ON = (1 << 2), /* Power up device */
  126. PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */
  127. PORT_CMD_START = (1 << 0), /* Enable port DMA engine */
  128. PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */
  129. PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */
  130. PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */
  131. /* hpriv->flags bits */
  132. AHCI_FLAG_MSI = (1 << 0),
  133. };
  134. struct ahci_cmd_hdr {
  135. u32 opts;
  136. u32 status;
  137. u32 tbl_addr;
  138. u32 tbl_addr_hi;
  139. u32 reserved[4];
  140. };
  141. struct ahci_sg {
  142. u32 addr;
  143. u32 addr_hi;
  144. u32 reserved;
  145. u32 flags_size;
  146. };
  147. struct ahci_host_priv {
  148. unsigned long flags;
  149. u32 cap; /* cache of HOST_CAP register */
  150. u32 port_map; /* cache of HOST_PORTS_IMPL reg */
  151. };
  152. struct ahci_port_priv {
  153. struct ahci_cmd_hdr *cmd_slot;
  154. dma_addr_t cmd_slot_dma;
  155. void *cmd_tbl;
  156. dma_addr_t cmd_tbl_dma;
  157. struct ahci_sg *cmd_tbl_sg;
  158. void *rx_fis;
  159. dma_addr_t rx_fis_dma;
  160. };
  161. static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg);
  162. static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
  163. static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
  164. static int ahci_qc_issue(struct ata_queued_cmd *qc);
  165. static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
  166. static void ahci_phy_reset(struct ata_port *ap);
  167. static void ahci_irq_clear(struct ata_port *ap);
  168. static void ahci_eng_timeout(struct ata_port *ap);
  169. static int ahci_port_start(struct ata_port *ap);
  170. static void ahci_port_stop(struct ata_port *ap);
  171. static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
  172. static void ahci_qc_prep(struct ata_queued_cmd *qc);
  173. static u8 ahci_check_status(struct ata_port *ap);
  174. static u8 ahci_check_err(struct ata_port *ap);
  175. static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
  176. static void ahci_remove_one (struct pci_dev *pdev);
  177. static Scsi_Host_Template ahci_sht = {
  178. .module = THIS_MODULE,
  179. .name = DRV_NAME,
  180. .ioctl = ata_scsi_ioctl,
  181. .queuecommand = ata_scsi_queuecmd,
  182. .eh_strategy_handler = ata_scsi_error,
  183. .can_queue = ATA_DEF_QUEUE,
  184. .this_id = ATA_SHT_THIS_ID,
  185. .sg_tablesize = AHCI_MAX_SG,
  186. .max_sectors = ATA_MAX_SECTORS,
  187. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  188. .emulated = ATA_SHT_EMULATED,
  189. .use_clustering = AHCI_USE_CLUSTERING,
  190. .proc_name = DRV_NAME,
  191. .dma_boundary = AHCI_DMA_BOUNDARY,
  192. .slave_configure = ata_scsi_slave_config,
  193. .bios_param = ata_std_bios_param,
  194. .ordered_flush = 1,
  195. };
  196. static struct ata_port_operations ahci_ops = {
  197. .port_disable = ata_port_disable,
  198. .check_status = ahci_check_status,
  199. .check_altstatus = ahci_check_status,
  200. .check_err = ahci_check_err,
  201. .dev_select = ata_noop_dev_select,
  202. .tf_read = ahci_tf_read,
  203. .phy_reset = ahci_phy_reset,
  204. .qc_prep = ahci_qc_prep,
  205. .qc_issue = ahci_qc_issue,
  206. .eng_timeout = ahci_eng_timeout,
  207. .irq_handler = ahci_interrupt,
  208. .irq_clear = ahci_irq_clear,
  209. .scr_read = ahci_scr_read,
  210. .scr_write = ahci_scr_write,
  211. .port_start = ahci_port_start,
  212. .port_stop = ahci_port_stop,
  213. };
  214. static struct ata_port_info ahci_port_info[] = {
  215. /* board_ahci */
  216. {
  217. .sht = &ahci_sht,
  218. .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
  219. ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
  220. ATA_FLAG_PIO_DMA,
  221. .pio_mask = 0x1f, /* pio0-4 */
  222. .udma_mask = 0x7f, /* udma0-6 ; FIXME */
  223. .port_ops = &ahci_ops,
  224. },
  225. };
  226. static struct pci_device_id ahci_pci_tbl[] = {
  227. { PCI_VENDOR_ID_INTEL, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  228. board_ahci }, /* ICH6 */
  229. { PCI_VENDOR_ID_INTEL, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  230. board_ahci }, /* ICH6M */
  231. { PCI_VENDOR_ID_INTEL, 0x27c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  232. board_ahci }, /* ICH7 */
  233. { PCI_VENDOR_ID_INTEL, 0x27c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  234. board_ahci }, /* ICH7M */
  235. { PCI_VENDOR_ID_INTEL, 0x27c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  236. board_ahci }, /* ICH7R */
  237. { PCI_VENDOR_ID_AL, 0x5288, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  238. board_ahci }, /* ULi M5288 */
  239. { PCI_VENDOR_ID_INTEL, 0x2681, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  240. board_ahci }, /* ESB2 */
  241. { PCI_VENDOR_ID_INTEL, 0x2682, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  242. board_ahci }, /* ESB2 */
  243. { PCI_VENDOR_ID_INTEL, 0x2683, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  244. board_ahci }, /* ESB2 */
  245. { PCI_VENDOR_ID_INTEL, 0x27c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  246. board_ahci }, /* ICH7-M DH */
  247. { } /* terminate list */
  248. };
  249. static struct pci_driver ahci_pci_driver = {
  250. .name = DRV_NAME,
  251. .id_table = ahci_pci_tbl,
  252. .probe = ahci_init_one,
  253. .remove = ahci_remove_one,
  254. };
  255. static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int port)
  256. {
  257. return base + 0x100 + (port * 0x80);
  258. }
  259. static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int port)
  260. {
  261. return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
  262. }
  263. static int ahci_port_start(struct ata_port *ap)
  264. {
  265. struct device *dev = ap->host_set->dev;
  266. struct ahci_host_priv *hpriv = ap->host_set->private_data;
  267. struct ahci_port_priv *pp;
  268. void __iomem *mmio = ap->host_set->mmio_base;
  269. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  270. void *mem;
  271. dma_addr_t mem_dma;
  272. pp = kmalloc(sizeof(*pp), GFP_KERNEL);
  273. if (!pp)
  274. return -ENOMEM;
  275. memset(pp, 0, sizeof(*pp));
  276. ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, &ap->pad_dma, GFP_KERNEL);
  277. if (!ap->pad) {
  278. kfree(pp);
  279. return -ENOMEM;
  280. }
  281. mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
  282. if (!mem) {
  283. dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
  284. kfree(pp);
  285. return -ENOMEM;
  286. }
  287. memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
  288. /*
  289. * First item in chunk of DMA memory: 32-slot command table,
  290. * 32 bytes each in size
  291. */
  292. pp->cmd_slot = mem;
  293. pp->cmd_slot_dma = mem_dma;
  294. mem += AHCI_CMD_SLOT_SZ;
  295. mem_dma += AHCI_CMD_SLOT_SZ;
  296. /*
  297. * Second item: Received-FIS area
  298. */
  299. pp->rx_fis = mem;
  300. pp->rx_fis_dma = mem_dma;
  301. mem += AHCI_RX_FIS_SZ;
  302. mem_dma += AHCI_RX_FIS_SZ;
  303. /*
  304. * Third item: data area for storing a single command
  305. * and its scatter-gather table
  306. */
  307. pp->cmd_tbl = mem;
  308. pp->cmd_tbl_dma = mem_dma;
  309. pp->cmd_tbl_sg = mem + AHCI_CMD_TBL_HDR;
  310. ap->private_data = pp;
  311. if (hpriv->cap & HOST_CAP_64)
  312. writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
  313. writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
  314. readl(port_mmio + PORT_LST_ADDR); /* flush */
  315. if (hpriv->cap & HOST_CAP_64)
  316. writel((pp->rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
  317. writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
  318. readl(port_mmio + PORT_FIS_ADDR); /* flush */
  319. writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
  320. PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
  321. PORT_CMD_START, port_mmio + PORT_CMD);
  322. readl(port_mmio + PORT_CMD); /* flush */
  323. return 0;
  324. }
  325. static void ahci_port_stop(struct ata_port *ap)
  326. {
  327. struct device *dev = ap->host_set->dev;
  328. struct ahci_port_priv *pp = ap->private_data;
  329. void __iomem *mmio = ap->host_set->mmio_base;
  330. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  331. u32 tmp;
  332. tmp = readl(port_mmio + PORT_CMD);
  333. tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX);
  334. writel(tmp, port_mmio + PORT_CMD);
  335. readl(port_mmio + PORT_CMD); /* flush */
  336. /* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so
  337. * this is slightly incorrect.
  338. */
  339. msleep(500);
  340. ap->private_data = NULL;
  341. dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
  342. pp->cmd_slot, pp->cmd_slot_dma);
  343. dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
  344. kfree(pp);
  345. }
  346. static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
  347. {
  348. unsigned int sc_reg;
  349. switch (sc_reg_in) {
  350. case SCR_STATUS: sc_reg = 0; break;
  351. case SCR_CONTROL: sc_reg = 1; break;
  352. case SCR_ERROR: sc_reg = 2; break;
  353. case SCR_ACTIVE: sc_reg = 3; break;
  354. default:
  355. return 0xffffffffU;
  356. }
  357. return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4));
  358. }
  359. static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
  360. u32 val)
  361. {
  362. unsigned int sc_reg;
  363. switch (sc_reg_in) {
  364. case SCR_STATUS: sc_reg = 0; break;
  365. case SCR_CONTROL: sc_reg = 1; break;
  366. case SCR_ERROR: sc_reg = 2; break;
  367. case SCR_ACTIVE: sc_reg = 3; break;
  368. default:
  369. return;
  370. }
  371. writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4));
  372. }
  373. static void ahci_phy_reset(struct ata_port *ap)
  374. {
  375. void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  376. struct ata_taskfile tf;
  377. struct ata_device *dev = &ap->device[0];
  378. u32 tmp;
  379. __sata_phy_reset(ap);
  380. if (ap->flags & ATA_FLAG_PORT_DISABLED)
  381. return;
  382. tmp = readl(port_mmio + PORT_SIG);
  383. tf.lbah = (tmp >> 24) & 0xff;
  384. tf.lbam = (tmp >> 16) & 0xff;
  385. tf.lbal = (tmp >> 8) & 0xff;
  386. tf.nsect = (tmp) & 0xff;
  387. dev->class = ata_dev_classify(&tf);
  388. if (!ata_dev_present(dev))
  389. ata_port_disable(ap);
  390. }
  391. static u8 ahci_check_status(struct ata_port *ap)
  392. {
  393. void *mmio = (void *) ap->ioaddr.cmd_addr;
  394. return readl(mmio + PORT_TFDATA) & 0xFF;
  395. }
  396. static u8 ahci_check_err(struct ata_port *ap)
  397. {
  398. void *mmio = (void *) ap->ioaddr.cmd_addr;
  399. return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF;
  400. }
  401. static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
  402. {
  403. struct ahci_port_priv *pp = ap->private_data;
  404. u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
  405. ata_tf_from_fis(d2h_fis, tf);
  406. }
  407. static void ahci_fill_sg(struct ata_queued_cmd *qc)
  408. {
  409. struct ahci_port_priv *pp = qc->ap->private_data;
  410. struct scatterlist *sg;
  411. struct ahci_sg *ahci_sg;
  412. VPRINTK("ENTER\n");
  413. /*
  414. * Next, the S/G list.
  415. */
  416. ahci_sg = pp->cmd_tbl_sg;
  417. ata_for_each_sg(sg, qc) {
  418. dma_addr_t addr = sg_dma_address(sg);
  419. u32 sg_len = sg_dma_len(sg);
  420. ahci_sg->addr = cpu_to_le32(addr & 0xffffffff);
  421. ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16);
  422. ahci_sg->flags_size = cpu_to_le32(sg_len - 1);
  423. ahci_sg++;
  424. }
  425. }
  426. static void ahci_qc_prep(struct ata_queued_cmd *qc)
  427. {
  428. struct ata_port *ap = qc->ap;
  429. struct ahci_port_priv *pp = ap->private_data;
  430. u32 opts;
  431. const u32 cmd_fis_len = 5; /* five dwords */
  432. /*
  433. * Fill in command slot information (currently only one slot,
  434. * slot 0, is currently since we don't do queueing)
  435. */
  436. opts = (qc->n_elem << 16) | cmd_fis_len;
  437. if (qc->tf.flags & ATA_TFLAG_WRITE)
  438. opts |= AHCI_CMD_WRITE;
  439. if (is_atapi_taskfile(&qc->tf))
  440. opts |= AHCI_CMD_ATAPI;
  441. pp->cmd_slot[0].opts = cpu_to_le32(opts);
  442. pp->cmd_slot[0].status = 0;
  443. pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff);
  444. pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
  445. /*
  446. * Fill in command table information. First, the header,
  447. * a SATA Register - Host to Device command FIS.
  448. */
  449. ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0);
  450. if (opts & AHCI_CMD_ATAPI) {
  451. memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
  452. memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len);
  453. }
  454. if (!(qc->flags & ATA_QCFLAG_DMAMAP))
  455. return;
  456. ahci_fill_sg(qc);
  457. }
  458. static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
  459. {
  460. void __iomem *mmio = ap->host_set->mmio_base;
  461. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  462. u32 tmp;
  463. int work;
  464. /* stop DMA */
  465. tmp = readl(port_mmio + PORT_CMD);
  466. tmp &= ~PORT_CMD_START;
  467. writel(tmp, port_mmio + PORT_CMD);
  468. /* wait for engine to stop. TODO: this could be
  469. * as long as 500 msec
  470. */
  471. work = 1000;
  472. while (work-- > 0) {
  473. tmp = readl(port_mmio + PORT_CMD);
  474. if ((tmp & PORT_CMD_LIST_ON) == 0)
  475. break;
  476. udelay(10);
  477. }
  478. /* clear SATA phy error, if any */
  479. tmp = readl(port_mmio + PORT_SCR_ERR);
  480. writel(tmp, port_mmio + PORT_SCR_ERR);
  481. /* if DRQ/BSY is set, device needs to be reset.
  482. * if so, issue COMRESET
  483. */
  484. tmp = readl(port_mmio + PORT_TFDATA);
  485. if (tmp & (ATA_BUSY | ATA_DRQ)) {
  486. writel(0x301, port_mmio + PORT_SCR_CTL);
  487. readl(port_mmio + PORT_SCR_CTL); /* flush */
  488. udelay(10);
  489. writel(0x300, port_mmio + PORT_SCR_CTL);
  490. readl(port_mmio + PORT_SCR_CTL); /* flush */
  491. }
  492. /* re-start DMA */
  493. tmp = readl(port_mmio + PORT_CMD);
  494. tmp |= PORT_CMD_START;
  495. writel(tmp, port_mmio + PORT_CMD);
  496. readl(port_mmio + PORT_CMD); /* flush */
  497. printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id);
  498. }
  499. static void ahci_eng_timeout(struct ata_port *ap)
  500. {
  501. struct ata_host_set *host_set = ap->host_set;
  502. void __iomem *mmio = host_set->mmio_base;
  503. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  504. struct ata_queued_cmd *qc;
  505. unsigned long flags;
  506. DPRINTK("ENTER\n");
  507. spin_lock_irqsave(&host_set->lock, flags);
  508. ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
  509. qc = ata_qc_from_tag(ap, ap->active_tag);
  510. if (!qc) {
  511. printk(KERN_ERR "ata%u: BUG: timeout without command\n",
  512. ap->id);
  513. } else {
  514. /* hack alert! We cannot use the supplied completion
  515. * function from inside the ->eh_strategy_handler() thread.
  516. * libata is the only user of ->eh_strategy_handler() in
  517. * any kernel, so the default scsi_done() assumes it is
  518. * not being called from the SCSI EH.
  519. */
  520. qc->scsidone = scsi_finish_command;
  521. ata_qc_complete(qc, ATA_ERR);
  522. }
  523. spin_unlock_irqrestore(&host_set->lock, flags);
  524. }
  525. static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
  526. {
  527. void __iomem *mmio = ap->host_set->mmio_base;
  528. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  529. u32 status, serr, ci;
  530. serr = readl(port_mmio + PORT_SCR_ERR);
  531. writel(serr, port_mmio + PORT_SCR_ERR);
  532. status = readl(port_mmio + PORT_IRQ_STAT);
  533. writel(status, port_mmio + PORT_IRQ_STAT);
  534. ci = readl(port_mmio + PORT_CMD_ISSUE);
  535. if (likely((ci & 0x1) == 0)) {
  536. if (qc) {
  537. ata_qc_complete(qc, 0);
  538. qc = NULL;
  539. }
  540. }
  541. if (status & PORT_IRQ_FATAL) {
  542. ahci_intr_error(ap, status);
  543. if (qc)
  544. ata_qc_complete(qc, ATA_ERR);
  545. }
  546. return 1;
  547. }
  548. static void ahci_irq_clear(struct ata_port *ap)
  549. {
  550. /* TODO */
  551. }
  552. static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
  553. {
  554. struct ata_host_set *host_set = dev_instance;
  555. struct ahci_host_priv *hpriv;
  556. unsigned int i, handled = 0;
  557. void __iomem *mmio;
  558. u32 irq_stat, irq_ack = 0;
  559. VPRINTK("ENTER\n");
  560. hpriv = host_set->private_data;
  561. mmio = host_set->mmio_base;
  562. /* sigh. 0xffffffff is a valid return from h/w */
  563. irq_stat = readl(mmio + HOST_IRQ_STAT);
  564. irq_stat &= hpriv->port_map;
  565. if (!irq_stat)
  566. return IRQ_NONE;
  567. spin_lock(&host_set->lock);
  568. for (i = 0; i < host_set->n_ports; i++) {
  569. struct ata_port *ap;
  570. if (!(irq_stat & (1 << i)))
  571. continue;
  572. ap = host_set->ports[i];
  573. if (ap) {
  574. struct ata_queued_cmd *qc;
  575. qc = ata_qc_from_tag(ap, ap->active_tag);
  576. if (!ahci_host_intr(ap, qc))
  577. if (ata_ratelimit()) {
  578. struct pci_dev *pdev =
  579. to_pci_dev(ap->host_set->dev);
  580. printk(KERN_WARNING
  581. "ahci(%s): unhandled interrupt on port %u\n",
  582. pci_name(pdev), i);
  583. }
  584. VPRINTK("port %u\n", i);
  585. } else {
  586. VPRINTK("port %u (no irq)\n", i);
  587. if (ata_ratelimit()) {
  588. struct pci_dev *pdev =
  589. to_pci_dev(ap->host_set->dev);
  590. printk(KERN_WARNING
  591. "ahci(%s): interrupt on disabled port %u\n",
  592. pci_name(pdev), i);
  593. }
  594. }
  595. irq_ack |= (1 << i);
  596. }
  597. if (irq_ack) {
  598. writel(irq_ack, mmio + HOST_IRQ_STAT);
  599. handled = 1;
  600. }
  601. spin_unlock(&host_set->lock);
  602. VPRINTK("EXIT\n");
  603. return IRQ_RETVAL(handled);
  604. }
  605. static int ahci_qc_issue(struct ata_queued_cmd *qc)
  606. {
  607. struct ata_port *ap = qc->ap;
  608. void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  609. writel(1, port_mmio + PORT_CMD_ISSUE);
  610. readl(port_mmio + PORT_CMD_ISSUE); /* flush */
  611. return 0;
  612. }
  613. static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
  614. unsigned int port_idx)
  615. {
  616. VPRINTK("ENTER, base==0x%lx, port_idx %u\n", base, port_idx);
  617. base = ahci_port_base_ul(base, port_idx);
  618. VPRINTK("base now==0x%lx\n", base);
  619. port->cmd_addr = base;
  620. port->scr_addr = base + PORT_SCR;
  621. VPRINTK("EXIT\n");
  622. }
  623. static int ahci_host_init(struct ata_probe_ent *probe_ent)
  624. {
  625. struct ahci_host_priv *hpriv = probe_ent->private_data;
  626. struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
  627. void __iomem *mmio = probe_ent->mmio_base;
  628. u32 tmp, cap_save;
  629. u16 tmp16;
  630. unsigned int i, j, using_dac;
  631. int rc;
  632. void __iomem *port_mmio;
  633. cap_save = readl(mmio + HOST_CAP);
  634. cap_save &= ( (1<<28) | (1<<17) );
  635. cap_save |= (1 << 27);
  636. /* global controller reset */
  637. tmp = readl(mmio + HOST_CTL);
  638. if ((tmp & HOST_RESET) == 0) {
  639. writel(tmp | HOST_RESET, mmio + HOST_CTL);
  640. readl(mmio + HOST_CTL); /* flush */
  641. }
  642. /* reset must complete within 1 second, or
  643. * the hardware should be considered fried.
  644. */
  645. ssleep(1);
  646. tmp = readl(mmio + HOST_CTL);
  647. if (tmp & HOST_RESET) {
  648. printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n",
  649. pci_name(pdev), tmp);
  650. return -EIO;
  651. }
  652. writel(HOST_AHCI_EN, mmio + HOST_CTL);
  653. (void) readl(mmio + HOST_CTL); /* flush */
  654. writel(cap_save, mmio + HOST_CAP);
  655. writel(0xf, mmio + HOST_PORTS_IMPL);
  656. (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
  657. pci_read_config_word(pdev, 0x92, &tmp16);
  658. tmp16 |= 0xf;
  659. pci_write_config_word(pdev, 0x92, tmp16);
  660. hpriv->cap = readl(mmio + HOST_CAP);
  661. hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
  662. probe_ent->n_ports = (hpriv->cap & 0x1f) + 1;
  663. VPRINTK("cap 0x%x port_map 0x%x n_ports %d\n",
  664. hpriv->cap, hpriv->port_map, probe_ent->n_ports);
  665. using_dac = hpriv->cap & HOST_CAP_64;
  666. if (using_dac &&
  667. !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
  668. rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
  669. if (rc) {
  670. rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
  671. if (rc) {
  672. printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n",
  673. pci_name(pdev));
  674. return rc;
  675. }
  676. }
  677. } else {
  678. rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
  679. if (rc) {
  680. printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n",
  681. pci_name(pdev));
  682. return rc;
  683. }
  684. rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
  685. if (rc) {
  686. printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n",
  687. pci_name(pdev));
  688. return rc;
  689. }
  690. }
  691. for (i = 0; i < probe_ent->n_ports; i++) {
  692. #if 0 /* BIOSen initialize this incorrectly */
  693. if (!(hpriv->port_map & (1 << i)))
  694. continue;
  695. #endif
  696. port_mmio = ahci_port_base(mmio, i);
  697. VPRINTK("mmio %p port_mmio %p\n", mmio, port_mmio);
  698. ahci_setup_port(&probe_ent->port[i],
  699. (unsigned long) mmio, i);
  700. /* make sure port is not active */
  701. tmp = readl(port_mmio + PORT_CMD);
  702. VPRINTK("PORT_CMD 0x%x\n", tmp);
  703. if (tmp & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
  704. PORT_CMD_FIS_RX | PORT_CMD_START)) {
  705. tmp &= ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
  706. PORT_CMD_FIS_RX | PORT_CMD_START);
  707. writel(tmp, port_mmio + PORT_CMD);
  708. readl(port_mmio + PORT_CMD); /* flush */
  709. /* spec says 500 msecs for each bit, so
  710. * this is slightly incorrect.
  711. */
  712. msleep(500);
  713. }
  714. writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD);
  715. j = 0;
  716. while (j < 100) {
  717. msleep(10);
  718. tmp = readl(port_mmio + PORT_SCR_STAT);
  719. if ((tmp & 0xf) == 0x3)
  720. break;
  721. j++;
  722. }
  723. tmp = readl(port_mmio + PORT_SCR_ERR);
  724. VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
  725. writel(tmp, port_mmio + PORT_SCR_ERR);
  726. /* ack any pending irq events for this port */
  727. tmp = readl(port_mmio + PORT_IRQ_STAT);
  728. VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
  729. if (tmp)
  730. writel(tmp, port_mmio + PORT_IRQ_STAT);
  731. writel(1 << i, mmio + HOST_IRQ_STAT);
  732. /* set irq mask (enables interrupts) */
  733. writel(DEF_PORT_IRQ, port_mmio + PORT_IRQ_MASK);
  734. }
  735. tmp = readl(mmio + HOST_CTL);
  736. VPRINTK("HOST_CTL 0x%x\n", tmp);
  737. writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
  738. tmp = readl(mmio + HOST_CTL);
  739. VPRINTK("HOST_CTL 0x%x\n", tmp);
  740. pci_set_master(pdev);
  741. return 0;
  742. }
  743. static void ahci_print_info(struct ata_probe_ent *probe_ent)
  744. {
  745. struct ahci_host_priv *hpriv = probe_ent->private_data;
  746. struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
  747. void __iomem *mmio = probe_ent->mmio_base;
  748. u32 vers, cap, impl, speed;
  749. const char *speed_s;
  750. u16 cc;
  751. const char *scc_s;
  752. vers = readl(mmio + HOST_VERSION);
  753. cap = hpriv->cap;
  754. impl = hpriv->port_map;
  755. speed = (cap >> 20) & 0xf;
  756. if (speed == 1)
  757. speed_s = "1.5";
  758. else if (speed == 2)
  759. speed_s = "3";
  760. else
  761. speed_s = "?";
  762. pci_read_config_word(pdev, 0x0a, &cc);
  763. if (cc == 0x0101)
  764. scc_s = "IDE";
  765. else if (cc == 0x0106)
  766. scc_s = "SATA";
  767. else if (cc == 0x0104)
  768. scc_s = "RAID";
  769. else
  770. scc_s = "unknown";
  771. printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x "
  772. "%u slots %u ports %s Gbps 0x%x impl %s mode\n"
  773. ,
  774. pci_name(pdev),
  775. (vers >> 24) & 0xff,
  776. (vers >> 16) & 0xff,
  777. (vers >> 8) & 0xff,
  778. vers & 0xff,
  779. ((cap >> 8) & 0x1f) + 1,
  780. (cap & 0x1f) + 1,
  781. speed_s,
  782. impl,
  783. scc_s);
  784. printk(KERN_INFO DRV_NAME "(%s) flags: "
  785. "%s%s%s%s%s%s"
  786. "%s%s%s%s%s%s%s\n"
  787. ,
  788. pci_name(pdev),
  789. cap & (1 << 31) ? "64bit " : "",
  790. cap & (1 << 30) ? "ncq " : "",
  791. cap & (1 << 28) ? "ilck " : "",
  792. cap & (1 << 27) ? "stag " : "",
  793. cap & (1 << 26) ? "pm " : "",
  794. cap & (1 << 25) ? "led " : "",
  795. cap & (1 << 24) ? "clo " : "",
  796. cap & (1 << 19) ? "nz " : "",
  797. cap & (1 << 18) ? "only " : "",
  798. cap & (1 << 17) ? "pmp " : "",
  799. cap & (1 << 15) ? "pio " : "",
  800. cap & (1 << 14) ? "slum " : "",
  801. cap & (1 << 13) ? "part " : ""
  802. );
  803. }
  804. static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  805. {
  806. static int printed_version;
  807. struct ata_probe_ent *probe_ent = NULL;
  808. struct ahci_host_priv *hpriv;
  809. unsigned long base;
  810. void __iomem *mmio_base;
  811. unsigned int board_idx = (unsigned int) ent->driver_data;
  812. int have_msi, pci_dev_busy = 0;
  813. int rc;
  814. VPRINTK("ENTER\n");
  815. if (!printed_version++)
  816. printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
  817. rc = pci_enable_device(pdev);
  818. if (rc)
  819. return rc;
  820. rc = pci_request_regions(pdev, DRV_NAME);
  821. if (rc) {
  822. pci_dev_busy = 1;
  823. goto err_out;
  824. }
  825. if (pci_enable_msi(pdev) == 0)
  826. have_msi = 1;
  827. else {
  828. pci_intx(pdev, 1);
  829. have_msi = 0;
  830. }
  831. probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
  832. if (probe_ent == NULL) {
  833. rc = -ENOMEM;
  834. goto err_out_msi;
  835. }
  836. memset(probe_ent, 0, sizeof(*probe_ent));
  837. probe_ent->dev = pci_dev_to_dev(pdev);
  838. INIT_LIST_HEAD(&probe_ent->node);
  839. mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0);
  840. if (mmio_base == NULL) {
  841. rc = -ENOMEM;
  842. goto err_out_free_ent;
  843. }
  844. base = (unsigned long) mmio_base;
  845. hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
  846. if (!hpriv) {
  847. rc = -ENOMEM;
  848. goto err_out_iounmap;
  849. }
  850. memset(hpriv, 0, sizeof(*hpriv));
  851. probe_ent->sht = ahci_port_info[board_idx].sht;
  852. probe_ent->host_flags = ahci_port_info[board_idx].host_flags;
  853. probe_ent->pio_mask = ahci_port_info[board_idx].pio_mask;
  854. probe_ent->udma_mask = ahci_port_info[board_idx].udma_mask;
  855. probe_ent->port_ops = ahci_port_info[board_idx].port_ops;
  856. probe_ent->irq = pdev->irq;
  857. probe_ent->irq_flags = SA_SHIRQ;
  858. probe_ent->mmio_base = mmio_base;
  859. probe_ent->private_data = hpriv;
  860. if (have_msi)
  861. hpriv->flags |= AHCI_FLAG_MSI;
  862. /* initialize adapter */
  863. rc = ahci_host_init(probe_ent);
  864. if (rc)
  865. goto err_out_hpriv;
  866. ahci_print_info(probe_ent);
  867. /* FIXME: check ata_device_add return value */
  868. ata_device_add(probe_ent);
  869. kfree(probe_ent);
  870. return 0;
  871. err_out_hpriv:
  872. kfree(hpriv);
  873. err_out_iounmap:
  874. pci_iounmap(pdev, mmio_base);
  875. err_out_free_ent:
  876. kfree(probe_ent);
  877. err_out_msi:
  878. if (have_msi)
  879. pci_disable_msi(pdev);
  880. else
  881. pci_intx(pdev, 0);
  882. pci_release_regions(pdev);
  883. err_out:
  884. if (!pci_dev_busy)
  885. pci_disable_device(pdev);
  886. return rc;
  887. }
  888. static void ahci_remove_one (struct pci_dev *pdev)
  889. {
  890. struct device *dev = pci_dev_to_dev(pdev);
  891. struct ata_host_set *host_set = dev_get_drvdata(dev);
  892. struct ahci_host_priv *hpriv = host_set->private_data;
  893. struct ata_port *ap;
  894. unsigned int i;
  895. int have_msi;
  896. for (i = 0; i < host_set->n_ports; i++) {
  897. ap = host_set->ports[i];
  898. scsi_remove_host(ap->host);
  899. }
  900. have_msi = hpriv->flags & AHCI_FLAG_MSI;
  901. free_irq(host_set->irq, host_set);
  902. for (i = 0; i < host_set->n_ports; i++) {
  903. ap = host_set->ports[i];
  904. ata_scsi_release(ap->host);
  905. scsi_host_put(ap->host);
  906. }
  907. kfree(hpriv);
  908. pci_iounmap(pdev, host_set->mmio_base);
  909. kfree(host_set);
  910. if (have_msi)
  911. pci_disable_msi(pdev);
  912. else
  913. pci_intx(pdev, 0);
  914. pci_release_regions(pdev);
  915. pci_disable_device(pdev);
  916. dev_set_drvdata(dev, NULL);
  917. }
  918. static int __init ahci_init(void)
  919. {
  920. return pci_module_init(&ahci_pci_driver);
  921. }
  922. static void __exit ahci_exit(void)
  923. {
  924. pci_unregister_driver(&ahci_pci_driver);
  925. }
  926. MODULE_AUTHOR("Jeff Garzik");
  927. MODULE_DESCRIPTION("AHCI SATA low-level driver");
  928. MODULE_LICENSE("GPL");
  929. MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
  930. MODULE_VERSION(DRV_VERSION);
  931. module_init(ahci_init);
  932. module_exit(ahci_exit);