ahci.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  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 const 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. mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
  277. if (!mem) {
  278. kfree(pp);
  279. return -ENOMEM;
  280. }
  281. memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
  282. /*
  283. * First item in chunk of DMA memory: 32-slot command table,
  284. * 32 bytes each in size
  285. */
  286. pp->cmd_slot = mem;
  287. pp->cmd_slot_dma = mem_dma;
  288. mem += AHCI_CMD_SLOT_SZ;
  289. mem_dma += AHCI_CMD_SLOT_SZ;
  290. /*
  291. * Second item: Received-FIS area
  292. */
  293. pp->rx_fis = mem;
  294. pp->rx_fis_dma = mem_dma;
  295. mem += AHCI_RX_FIS_SZ;
  296. mem_dma += AHCI_RX_FIS_SZ;
  297. /*
  298. * Third item: data area for storing a single command
  299. * and its scatter-gather table
  300. */
  301. pp->cmd_tbl = mem;
  302. pp->cmd_tbl_dma = mem_dma;
  303. pp->cmd_tbl_sg = mem + AHCI_CMD_TBL_HDR;
  304. ap->private_data = pp;
  305. if (hpriv->cap & HOST_CAP_64)
  306. writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
  307. writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
  308. readl(port_mmio + PORT_LST_ADDR); /* flush */
  309. if (hpriv->cap & HOST_CAP_64)
  310. writel((pp->rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
  311. writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
  312. readl(port_mmio + PORT_FIS_ADDR); /* flush */
  313. writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
  314. PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
  315. PORT_CMD_START, port_mmio + PORT_CMD);
  316. readl(port_mmio + PORT_CMD); /* flush */
  317. return 0;
  318. }
  319. static void ahci_port_stop(struct ata_port *ap)
  320. {
  321. struct device *dev = ap->host_set->dev;
  322. struct ahci_port_priv *pp = ap->private_data;
  323. void __iomem *mmio = ap->host_set->mmio_base;
  324. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  325. u32 tmp;
  326. tmp = readl(port_mmio + PORT_CMD);
  327. tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX);
  328. writel(tmp, port_mmio + PORT_CMD);
  329. readl(port_mmio + PORT_CMD); /* flush */
  330. /* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so
  331. * this is slightly incorrect.
  332. */
  333. msleep(500);
  334. ap->private_data = NULL;
  335. dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
  336. pp->cmd_slot, pp->cmd_slot_dma);
  337. kfree(pp);
  338. }
  339. static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
  340. {
  341. unsigned int sc_reg;
  342. switch (sc_reg_in) {
  343. case SCR_STATUS: sc_reg = 0; break;
  344. case SCR_CONTROL: sc_reg = 1; break;
  345. case SCR_ERROR: sc_reg = 2; break;
  346. case SCR_ACTIVE: sc_reg = 3; break;
  347. default:
  348. return 0xffffffffU;
  349. }
  350. return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
  351. }
  352. static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
  353. u32 val)
  354. {
  355. unsigned int sc_reg;
  356. switch (sc_reg_in) {
  357. case SCR_STATUS: sc_reg = 0; break;
  358. case SCR_CONTROL: sc_reg = 1; break;
  359. case SCR_ERROR: sc_reg = 2; break;
  360. case SCR_ACTIVE: sc_reg = 3; break;
  361. default:
  362. return;
  363. }
  364. writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
  365. }
  366. static void ahci_phy_reset(struct ata_port *ap)
  367. {
  368. void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  369. struct ata_taskfile tf;
  370. struct ata_device *dev = &ap->device[0];
  371. u32 tmp;
  372. __sata_phy_reset(ap);
  373. if (ap->flags & ATA_FLAG_PORT_DISABLED)
  374. return;
  375. tmp = readl(port_mmio + PORT_SIG);
  376. tf.lbah = (tmp >> 24) & 0xff;
  377. tf.lbam = (tmp >> 16) & 0xff;
  378. tf.lbal = (tmp >> 8) & 0xff;
  379. tf.nsect = (tmp) & 0xff;
  380. dev->class = ata_dev_classify(&tf);
  381. if (!ata_dev_present(dev))
  382. ata_port_disable(ap);
  383. }
  384. static u8 ahci_check_status(struct ata_port *ap)
  385. {
  386. void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  387. return readl(mmio + PORT_TFDATA) & 0xFF;
  388. }
  389. static u8 ahci_check_err(struct ata_port *ap)
  390. {
  391. void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  392. return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF;
  393. }
  394. static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
  395. {
  396. struct ahci_port_priv *pp = ap->private_data;
  397. u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
  398. ata_tf_from_fis(d2h_fis, tf);
  399. }
  400. static void ahci_fill_sg(struct ata_queued_cmd *qc)
  401. {
  402. struct ahci_port_priv *pp = qc->ap->private_data;
  403. unsigned int i;
  404. VPRINTK("ENTER\n");
  405. /*
  406. * Next, the S/G list.
  407. */
  408. for (i = 0; i < qc->n_elem; i++) {
  409. u32 sg_len;
  410. dma_addr_t addr;
  411. addr = sg_dma_address(&qc->sg[i]);
  412. sg_len = sg_dma_len(&qc->sg[i]);
  413. pp->cmd_tbl_sg[i].addr = cpu_to_le32(addr & 0xffffffff);
  414. pp->cmd_tbl_sg[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
  415. pp->cmd_tbl_sg[i].flags_size = cpu_to_le32(sg_len - 1);
  416. }
  417. }
  418. static void ahci_qc_prep(struct ata_queued_cmd *qc)
  419. {
  420. struct ata_port *ap = qc->ap;
  421. struct ahci_port_priv *pp = ap->private_data;
  422. u32 opts;
  423. const u32 cmd_fis_len = 5; /* five dwords */
  424. /*
  425. * Fill in command slot information (currently only one slot,
  426. * slot 0, is currently since we don't do queueing)
  427. */
  428. opts = (qc->n_elem << 16) | cmd_fis_len;
  429. if (qc->tf.flags & ATA_TFLAG_WRITE)
  430. opts |= AHCI_CMD_WRITE;
  431. if (is_atapi_taskfile(&qc->tf))
  432. opts |= AHCI_CMD_ATAPI;
  433. pp->cmd_slot[0].opts = cpu_to_le32(opts);
  434. pp->cmd_slot[0].status = 0;
  435. pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff);
  436. pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
  437. /*
  438. * Fill in command table information. First, the header,
  439. * a SATA Register - Host to Device command FIS.
  440. */
  441. ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0);
  442. if (opts & AHCI_CMD_ATAPI) {
  443. memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
  444. memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len);
  445. }
  446. if (!(qc->flags & ATA_QCFLAG_DMAMAP))
  447. return;
  448. ahci_fill_sg(qc);
  449. }
  450. static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
  451. {
  452. void __iomem *mmio = ap->host_set->mmio_base;
  453. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  454. u32 tmp;
  455. int work;
  456. /* stop DMA */
  457. tmp = readl(port_mmio + PORT_CMD);
  458. tmp &= ~PORT_CMD_START;
  459. writel(tmp, port_mmio + PORT_CMD);
  460. /* wait for engine to stop. TODO: this could be
  461. * as long as 500 msec
  462. */
  463. work = 1000;
  464. while (work-- > 0) {
  465. tmp = readl(port_mmio + PORT_CMD);
  466. if ((tmp & PORT_CMD_LIST_ON) == 0)
  467. break;
  468. udelay(10);
  469. }
  470. /* clear SATA phy error, if any */
  471. tmp = readl(port_mmio + PORT_SCR_ERR);
  472. writel(tmp, port_mmio + PORT_SCR_ERR);
  473. /* if DRQ/BSY is set, device needs to be reset.
  474. * if so, issue COMRESET
  475. */
  476. tmp = readl(port_mmio + PORT_TFDATA);
  477. if (tmp & (ATA_BUSY | ATA_DRQ)) {
  478. writel(0x301, port_mmio + PORT_SCR_CTL);
  479. readl(port_mmio + PORT_SCR_CTL); /* flush */
  480. udelay(10);
  481. writel(0x300, port_mmio + PORT_SCR_CTL);
  482. readl(port_mmio + PORT_SCR_CTL); /* flush */
  483. }
  484. /* re-start DMA */
  485. tmp = readl(port_mmio + PORT_CMD);
  486. tmp |= PORT_CMD_START;
  487. writel(tmp, port_mmio + PORT_CMD);
  488. readl(port_mmio + PORT_CMD); /* flush */
  489. printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id);
  490. }
  491. static void ahci_eng_timeout(struct ata_port *ap)
  492. {
  493. struct ata_host_set *host_set = ap->host_set;
  494. void __iomem *mmio = host_set->mmio_base;
  495. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  496. struct ata_queued_cmd *qc;
  497. unsigned long flags;
  498. DPRINTK("ENTER\n");
  499. spin_lock_irqsave(&host_set->lock, flags);
  500. ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
  501. qc = ata_qc_from_tag(ap, ap->active_tag);
  502. if (!qc) {
  503. printk(KERN_ERR "ata%u: BUG: timeout without command\n",
  504. ap->id);
  505. } else {
  506. /* hack alert! We cannot use the supplied completion
  507. * function from inside the ->eh_strategy_handler() thread.
  508. * libata is the only user of ->eh_strategy_handler() in
  509. * any kernel, so the default scsi_done() assumes it is
  510. * not being called from the SCSI EH.
  511. */
  512. qc->scsidone = scsi_finish_command;
  513. ata_qc_complete(qc, ATA_ERR);
  514. }
  515. spin_unlock_irqrestore(&host_set->lock, flags);
  516. }
  517. static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
  518. {
  519. void __iomem *mmio = ap->host_set->mmio_base;
  520. void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
  521. u32 status, serr, ci;
  522. serr = readl(port_mmio + PORT_SCR_ERR);
  523. writel(serr, port_mmio + PORT_SCR_ERR);
  524. status = readl(port_mmio + PORT_IRQ_STAT);
  525. writel(status, port_mmio + PORT_IRQ_STAT);
  526. ci = readl(port_mmio + PORT_CMD_ISSUE);
  527. if (likely((ci & 0x1) == 0)) {
  528. if (qc) {
  529. ata_qc_complete(qc, 0);
  530. qc = NULL;
  531. }
  532. }
  533. if (status & PORT_IRQ_FATAL) {
  534. ahci_intr_error(ap, status);
  535. if (qc)
  536. ata_qc_complete(qc, ATA_ERR);
  537. }
  538. return 1;
  539. }
  540. static void ahci_irq_clear(struct ata_port *ap)
  541. {
  542. /* TODO */
  543. }
  544. static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
  545. {
  546. struct ata_host_set *host_set = dev_instance;
  547. struct ahci_host_priv *hpriv;
  548. unsigned int i, handled = 0;
  549. void __iomem *mmio;
  550. u32 irq_stat, irq_ack = 0;
  551. VPRINTK("ENTER\n");
  552. hpriv = host_set->private_data;
  553. mmio = host_set->mmio_base;
  554. /* sigh. 0xffffffff is a valid return from h/w */
  555. irq_stat = readl(mmio + HOST_IRQ_STAT);
  556. irq_stat &= hpriv->port_map;
  557. if (!irq_stat)
  558. return IRQ_NONE;
  559. spin_lock(&host_set->lock);
  560. for (i = 0; i < host_set->n_ports; i++) {
  561. struct ata_port *ap;
  562. if (!(irq_stat & (1 << i)))
  563. continue;
  564. ap = host_set->ports[i];
  565. if (ap) {
  566. struct ata_queued_cmd *qc;
  567. qc = ata_qc_from_tag(ap, ap->active_tag);
  568. if (!ahci_host_intr(ap, qc))
  569. if (ata_ratelimit()) {
  570. struct pci_dev *pdev =
  571. to_pci_dev(ap->host_set->dev);
  572. printk(KERN_WARNING
  573. "ahci(%s): unhandled interrupt on port %u\n",
  574. pci_name(pdev), i);
  575. }
  576. VPRINTK("port %u\n", i);
  577. } else {
  578. VPRINTK("port %u (no irq)\n", i);
  579. if (ata_ratelimit()) {
  580. struct pci_dev *pdev =
  581. to_pci_dev(ap->host_set->dev);
  582. printk(KERN_WARNING
  583. "ahci(%s): interrupt on disabled port %u\n",
  584. pci_name(pdev), i);
  585. }
  586. }
  587. irq_ack |= (1 << i);
  588. }
  589. if (irq_ack) {
  590. writel(irq_ack, mmio + HOST_IRQ_STAT);
  591. handled = 1;
  592. }
  593. spin_unlock(&host_set->lock);
  594. VPRINTK("EXIT\n");
  595. return IRQ_RETVAL(handled);
  596. }
  597. static int ahci_qc_issue(struct ata_queued_cmd *qc)
  598. {
  599. struct ata_port *ap = qc->ap;
  600. void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
  601. writel(1, port_mmio + PORT_CMD_ISSUE);
  602. readl(port_mmio + PORT_CMD_ISSUE); /* flush */
  603. return 0;
  604. }
  605. static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
  606. unsigned int port_idx)
  607. {
  608. VPRINTK("ENTER, base==0x%lx, port_idx %u\n", base, port_idx);
  609. base = ahci_port_base_ul(base, port_idx);
  610. VPRINTK("base now==0x%lx\n", base);
  611. port->cmd_addr = base;
  612. port->scr_addr = base + PORT_SCR;
  613. VPRINTK("EXIT\n");
  614. }
  615. static int ahci_host_init(struct ata_probe_ent *probe_ent)
  616. {
  617. struct ahci_host_priv *hpriv = probe_ent->private_data;
  618. struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
  619. void __iomem *mmio = probe_ent->mmio_base;
  620. u32 tmp, cap_save;
  621. u16 tmp16;
  622. unsigned int i, j, using_dac;
  623. int rc;
  624. void __iomem *port_mmio;
  625. cap_save = readl(mmio + HOST_CAP);
  626. cap_save &= ( (1<<28) | (1<<17) );
  627. cap_save |= (1 << 27);
  628. /* global controller reset */
  629. tmp = readl(mmio + HOST_CTL);
  630. if ((tmp & HOST_RESET) == 0) {
  631. writel(tmp | HOST_RESET, mmio + HOST_CTL);
  632. readl(mmio + HOST_CTL); /* flush */
  633. }
  634. /* reset must complete within 1 second, or
  635. * the hardware should be considered fried.
  636. */
  637. ssleep(1);
  638. tmp = readl(mmio + HOST_CTL);
  639. if (tmp & HOST_RESET) {
  640. printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n",
  641. pci_name(pdev), tmp);
  642. return -EIO;
  643. }
  644. writel(HOST_AHCI_EN, mmio + HOST_CTL);
  645. (void) readl(mmio + HOST_CTL); /* flush */
  646. writel(cap_save, mmio + HOST_CAP);
  647. writel(0xf, mmio + HOST_PORTS_IMPL);
  648. (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
  649. pci_read_config_word(pdev, 0x92, &tmp16);
  650. tmp16 |= 0xf;
  651. pci_write_config_word(pdev, 0x92, tmp16);
  652. hpriv->cap = readl(mmio + HOST_CAP);
  653. hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
  654. probe_ent->n_ports = (hpriv->cap & 0x1f) + 1;
  655. VPRINTK("cap 0x%x port_map 0x%x n_ports %d\n",
  656. hpriv->cap, hpriv->port_map, probe_ent->n_ports);
  657. using_dac = hpriv->cap & HOST_CAP_64;
  658. if (using_dac &&
  659. !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
  660. rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
  661. if (rc) {
  662. rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
  663. if (rc) {
  664. printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n",
  665. pci_name(pdev));
  666. return rc;
  667. }
  668. }
  669. } else {
  670. rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
  671. if (rc) {
  672. printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n",
  673. pci_name(pdev));
  674. return rc;
  675. }
  676. rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
  677. if (rc) {
  678. printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n",
  679. pci_name(pdev));
  680. return rc;
  681. }
  682. }
  683. for (i = 0; i < probe_ent->n_ports; i++) {
  684. #if 0 /* BIOSen initialize this incorrectly */
  685. if (!(hpriv->port_map & (1 << i)))
  686. continue;
  687. #endif
  688. port_mmio = ahci_port_base(mmio, i);
  689. VPRINTK("mmio %p port_mmio %p\n", mmio, port_mmio);
  690. ahci_setup_port(&probe_ent->port[i],
  691. (unsigned long) mmio, i);
  692. /* make sure port is not active */
  693. tmp = readl(port_mmio + PORT_CMD);
  694. VPRINTK("PORT_CMD 0x%x\n", tmp);
  695. if (tmp & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
  696. PORT_CMD_FIS_RX | PORT_CMD_START)) {
  697. tmp &= ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
  698. PORT_CMD_FIS_RX | PORT_CMD_START);
  699. writel(tmp, port_mmio + PORT_CMD);
  700. readl(port_mmio + PORT_CMD); /* flush */
  701. /* spec says 500 msecs for each bit, so
  702. * this is slightly incorrect.
  703. */
  704. msleep(500);
  705. }
  706. writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD);
  707. j = 0;
  708. while (j < 100) {
  709. msleep(10);
  710. tmp = readl(port_mmio + PORT_SCR_STAT);
  711. if ((tmp & 0xf) == 0x3)
  712. break;
  713. j++;
  714. }
  715. tmp = readl(port_mmio + PORT_SCR_ERR);
  716. VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
  717. writel(tmp, port_mmio + PORT_SCR_ERR);
  718. /* ack any pending irq events for this port */
  719. tmp = readl(port_mmio + PORT_IRQ_STAT);
  720. VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
  721. if (tmp)
  722. writel(tmp, port_mmio + PORT_IRQ_STAT);
  723. writel(1 << i, mmio + HOST_IRQ_STAT);
  724. /* set irq mask (enables interrupts) */
  725. writel(DEF_PORT_IRQ, port_mmio + PORT_IRQ_MASK);
  726. }
  727. tmp = readl(mmio + HOST_CTL);
  728. VPRINTK("HOST_CTL 0x%x\n", tmp);
  729. writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
  730. tmp = readl(mmio + HOST_CTL);
  731. VPRINTK("HOST_CTL 0x%x\n", tmp);
  732. pci_set_master(pdev);
  733. return 0;
  734. }
  735. static void ahci_print_info(struct ata_probe_ent *probe_ent)
  736. {
  737. struct ahci_host_priv *hpriv = probe_ent->private_data;
  738. struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
  739. void __iomem *mmio = probe_ent->mmio_base;
  740. u32 vers, cap, impl, speed;
  741. const char *speed_s;
  742. u16 cc;
  743. const char *scc_s;
  744. vers = readl(mmio + HOST_VERSION);
  745. cap = hpriv->cap;
  746. impl = hpriv->port_map;
  747. speed = (cap >> 20) & 0xf;
  748. if (speed == 1)
  749. speed_s = "1.5";
  750. else if (speed == 2)
  751. speed_s = "3";
  752. else
  753. speed_s = "?";
  754. pci_read_config_word(pdev, 0x0a, &cc);
  755. if (cc == 0x0101)
  756. scc_s = "IDE";
  757. else if (cc == 0x0106)
  758. scc_s = "SATA";
  759. else if (cc == 0x0104)
  760. scc_s = "RAID";
  761. else
  762. scc_s = "unknown";
  763. printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x "
  764. "%u slots %u ports %s Gbps 0x%x impl %s mode\n"
  765. ,
  766. pci_name(pdev),
  767. (vers >> 24) & 0xff,
  768. (vers >> 16) & 0xff,
  769. (vers >> 8) & 0xff,
  770. vers & 0xff,
  771. ((cap >> 8) & 0x1f) + 1,
  772. (cap & 0x1f) + 1,
  773. speed_s,
  774. impl,
  775. scc_s);
  776. printk(KERN_INFO DRV_NAME "(%s) flags: "
  777. "%s%s%s%s%s%s"
  778. "%s%s%s%s%s%s%s\n"
  779. ,
  780. pci_name(pdev),
  781. cap & (1 << 31) ? "64bit " : "",
  782. cap & (1 << 30) ? "ncq " : "",
  783. cap & (1 << 28) ? "ilck " : "",
  784. cap & (1 << 27) ? "stag " : "",
  785. cap & (1 << 26) ? "pm " : "",
  786. cap & (1 << 25) ? "led " : "",
  787. cap & (1 << 24) ? "clo " : "",
  788. cap & (1 << 19) ? "nz " : "",
  789. cap & (1 << 18) ? "only " : "",
  790. cap & (1 << 17) ? "pmp " : "",
  791. cap & (1 << 15) ? "pio " : "",
  792. cap & (1 << 14) ? "slum " : "",
  793. cap & (1 << 13) ? "part " : ""
  794. );
  795. }
  796. static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  797. {
  798. static int printed_version;
  799. struct ata_probe_ent *probe_ent = NULL;
  800. struct ahci_host_priv *hpriv;
  801. unsigned long base;
  802. void __iomem *mmio_base;
  803. unsigned int board_idx = (unsigned int) ent->driver_data;
  804. int have_msi, pci_dev_busy = 0;
  805. int rc;
  806. VPRINTK("ENTER\n");
  807. if (!printed_version++)
  808. printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
  809. rc = pci_enable_device(pdev);
  810. if (rc)
  811. return rc;
  812. rc = pci_request_regions(pdev, DRV_NAME);
  813. if (rc) {
  814. pci_dev_busy = 1;
  815. goto err_out;
  816. }
  817. if (pci_enable_msi(pdev) == 0)
  818. have_msi = 1;
  819. else {
  820. pci_intx(pdev, 1);
  821. have_msi = 0;
  822. }
  823. probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
  824. if (probe_ent == NULL) {
  825. rc = -ENOMEM;
  826. goto err_out_msi;
  827. }
  828. memset(probe_ent, 0, sizeof(*probe_ent));
  829. probe_ent->dev = pci_dev_to_dev(pdev);
  830. INIT_LIST_HEAD(&probe_ent->node);
  831. mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0);
  832. if (mmio_base == NULL) {
  833. rc = -ENOMEM;
  834. goto err_out_free_ent;
  835. }
  836. base = (unsigned long) mmio_base;
  837. hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
  838. if (!hpriv) {
  839. rc = -ENOMEM;
  840. goto err_out_iounmap;
  841. }
  842. memset(hpriv, 0, sizeof(*hpriv));
  843. probe_ent->sht = ahci_port_info[board_idx].sht;
  844. probe_ent->host_flags = ahci_port_info[board_idx].host_flags;
  845. probe_ent->pio_mask = ahci_port_info[board_idx].pio_mask;
  846. probe_ent->udma_mask = ahci_port_info[board_idx].udma_mask;
  847. probe_ent->port_ops = ahci_port_info[board_idx].port_ops;
  848. probe_ent->irq = pdev->irq;
  849. probe_ent->irq_flags = SA_SHIRQ;
  850. probe_ent->mmio_base = mmio_base;
  851. probe_ent->private_data = hpriv;
  852. if (have_msi)
  853. hpriv->flags |= AHCI_FLAG_MSI;
  854. /* initialize adapter */
  855. rc = ahci_host_init(probe_ent);
  856. if (rc)
  857. goto err_out_hpriv;
  858. ahci_print_info(probe_ent);
  859. /* FIXME: check ata_device_add return value */
  860. ata_device_add(probe_ent);
  861. kfree(probe_ent);
  862. return 0;
  863. err_out_hpriv:
  864. kfree(hpriv);
  865. err_out_iounmap:
  866. pci_iounmap(pdev, mmio_base);
  867. err_out_free_ent:
  868. kfree(probe_ent);
  869. err_out_msi:
  870. if (have_msi)
  871. pci_disable_msi(pdev);
  872. else
  873. pci_intx(pdev, 0);
  874. pci_release_regions(pdev);
  875. err_out:
  876. if (!pci_dev_busy)
  877. pci_disable_device(pdev);
  878. return rc;
  879. }
  880. static void ahci_remove_one (struct pci_dev *pdev)
  881. {
  882. struct device *dev = pci_dev_to_dev(pdev);
  883. struct ata_host_set *host_set = dev_get_drvdata(dev);
  884. struct ahci_host_priv *hpriv = host_set->private_data;
  885. struct ata_port *ap;
  886. unsigned int i;
  887. int have_msi;
  888. for (i = 0; i < host_set->n_ports; i++) {
  889. ap = host_set->ports[i];
  890. scsi_remove_host(ap->host);
  891. }
  892. have_msi = hpriv->flags & AHCI_FLAG_MSI;
  893. free_irq(host_set->irq, host_set);
  894. for (i = 0; i < host_set->n_ports; i++) {
  895. ap = host_set->ports[i];
  896. ata_scsi_release(ap->host);
  897. scsi_host_put(ap->host);
  898. }
  899. kfree(hpriv);
  900. pci_iounmap(pdev, host_set->mmio_base);
  901. kfree(host_set);
  902. if (have_msi)
  903. pci_disable_msi(pdev);
  904. else
  905. pci_intx(pdev, 0);
  906. pci_release_regions(pdev);
  907. pci_disable_device(pdev);
  908. dev_set_drvdata(dev, NULL);
  909. }
  910. static int __init ahci_init(void)
  911. {
  912. return pci_module_init(&ahci_pci_driver);
  913. }
  914. static void __exit ahci_exit(void)
  915. {
  916. pci_unregister_driver(&ahci_pci_driver);
  917. }
  918. MODULE_AUTHOR("Jeff Garzik");
  919. MODULE_DESCRIPTION("AHCI SATA low-level driver");
  920. MODULE_LICENSE("GPL");
  921. MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
  922. MODULE_VERSION(DRV_VERSION);
  923. module_init(ahci_init);
  924. module_exit(ahci_exit);