ahci_xgene.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /*
  2. * AppliedMicro X-Gene SoC SATA Host Controller Driver
  3. *
  4. * Copyright (c) 2014, Applied Micro Circuits Corporation
  5. * Author: Loc Ho <lho@apm.com>
  6. * Tuan Phan <tphan@apm.com>
  7. * Suman Tripathi <stripathi@apm.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * NOTE: PM support is not currently available.
  23. *
  24. */
  25. #include <linux/module.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/ahci_platform.h>
  28. #include <linux/of_address.h>
  29. #include <linux/of_irq.h>
  30. #include <linux/phy/phy.h>
  31. #include "ahci.h"
  32. /* Max # of disk per a controller */
  33. #define MAX_AHCI_CHN_PERCTR 2
  34. /* MUX CSR */
  35. #define SATA_ENET_CONFIG_REG 0x00000000
  36. #define CFG_SATA_ENET_SELECT_MASK 0x00000001
  37. /* SATA core host controller CSR */
  38. #define SLVRDERRATTRIBUTES 0x00000000
  39. #define SLVWRERRATTRIBUTES 0x00000004
  40. #define MSTRDERRATTRIBUTES 0x00000008
  41. #define MSTWRERRATTRIBUTES 0x0000000c
  42. #define BUSCTLREG 0x00000014
  43. #define IOFMSTRWAUX 0x00000018
  44. #define INTSTATUSMASK 0x0000002c
  45. #define ERRINTSTATUS 0x00000030
  46. #define ERRINTSTATUSMASK 0x00000034
  47. /* SATA host AHCI CSR */
  48. #define PORTCFG 0x000000a4
  49. #define PORTADDR_SET(dst, src) \
  50. (((dst) & ~0x0000003f) | (((u32)(src)) & 0x0000003f))
  51. #define PORTPHY1CFG 0x000000a8
  52. #define PORTPHY1CFG_FRCPHYRDY_SET(dst, src) \
  53. (((dst) & ~0x00100000) | (((u32)(src) << 0x14) & 0x00100000))
  54. #define PORTPHY2CFG 0x000000ac
  55. #define PORTPHY3CFG 0x000000b0
  56. #define PORTPHY4CFG 0x000000b4
  57. #define PORTPHY5CFG 0x000000b8
  58. #define SCTL0 0x0000012C
  59. #define PORTPHY5CFG_RTCHG_SET(dst, src) \
  60. (((dst) & ~0xfff00000) | (((u32)(src) << 0x14) & 0xfff00000))
  61. #define PORTAXICFG_EN_CONTEXT_SET(dst, src) \
  62. (((dst) & ~0x01000000) | (((u32)(src) << 0x18) & 0x01000000))
  63. #define PORTAXICFG 0x000000bc
  64. #define PORTAXICFG_OUTTRANS_SET(dst, src) \
  65. (((dst) & ~0x00f00000) | (((u32)(src) << 0x14) & 0x00f00000))
  66. #define PORTRANSCFG 0x000000c8
  67. #define PORTRANSCFG_RXWM_SET(dst, src) \
  68. (((dst) & ~0x0000007f) | (((u32)(src)) & 0x0000007f))
  69. /* SATA host controller AXI CSR */
  70. #define INT_SLV_TMOMASK 0x00000010
  71. /* SATA diagnostic CSR */
  72. #define CFG_MEM_RAM_SHUTDOWN 0x00000070
  73. #define BLOCK_MEM_RDY 0x00000074
  74. /* Max retry for link down */
  75. #define MAX_LINK_DOWN_RETRY 3
  76. struct xgene_ahci_context {
  77. struct ahci_host_priv *hpriv;
  78. struct device *dev;
  79. u8 last_cmd[MAX_AHCI_CHN_PERCTR]; /* tracking the last command issued*/
  80. void __iomem *csr_core; /* Core CSR address of IP */
  81. void __iomem *csr_diag; /* Diag CSR address of IP */
  82. void __iomem *csr_axi; /* AXI CSR address of IP */
  83. void __iomem *csr_mux; /* MUX CSR address of IP */
  84. };
  85. static int xgene_ahci_init_memram(struct xgene_ahci_context *ctx)
  86. {
  87. dev_dbg(ctx->dev, "Release memory from shutdown\n");
  88. writel(0x0, ctx->csr_diag + CFG_MEM_RAM_SHUTDOWN);
  89. readl(ctx->csr_diag + CFG_MEM_RAM_SHUTDOWN); /* Force a barrier */
  90. msleep(1); /* reset may take up to 1ms */
  91. if (readl(ctx->csr_diag + BLOCK_MEM_RDY) != 0xFFFFFFFF) {
  92. dev_err(ctx->dev, "failed to release memory from shutdown\n");
  93. return -ENODEV;
  94. }
  95. return 0;
  96. }
  97. /**
  98. * xgene_ahci_restart_engine - Restart the dma engine.
  99. * @ap : ATA port of interest
  100. *
  101. * Restarts the dma engine inside the controller.
  102. */
  103. static int xgene_ahci_restart_engine(struct ata_port *ap)
  104. {
  105. struct ahci_host_priv *hpriv = ap->host->private_data;
  106. ahci_stop_engine(ap);
  107. ahci_start_fis_rx(ap);
  108. hpriv->start_engine(ap);
  109. return 0;
  110. }
  111. /**
  112. * xgene_ahci_qc_issue - Issue commands to the device
  113. * @qc: Command to issue
  114. *
  115. * Due to Hardware errata for IDENTIFY DEVICE command, the controller cannot
  116. * clear the BSY bit after receiving the PIO setup FIS. This results in the dma
  117. * state machine goes into the CMFatalErrorUpdate state and locks up. By
  118. * restarting the dma engine, it removes the controller out of lock up state.
  119. */
  120. static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc)
  121. {
  122. struct ata_port *ap = qc->ap;
  123. struct ahci_host_priv *hpriv = ap->host->private_data;
  124. struct xgene_ahci_context *ctx = hpriv->plat_data;
  125. int rc = 0;
  126. if (unlikely(ctx->last_cmd[ap->port_no] == ATA_CMD_ID_ATA))
  127. xgene_ahci_restart_engine(ap);
  128. rc = ahci_qc_issue(qc);
  129. /* Save the last command issued */
  130. ctx->last_cmd[ap->port_no] = qc->tf.command;
  131. return rc;
  132. }
  133. static bool xgene_ahci_is_memram_inited(struct xgene_ahci_context *ctx)
  134. {
  135. void __iomem *diagcsr = ctx->csr_diag;
  136. return (readl(diagcsr + CFG_MEM_RAM_SHUTDOWN) == 0 &&
  137. readl(diagcsr + BLOCK_MEM_RDY) == 0xFFFFFFFF);
  138. }
  139. /**
  140. * xgene_ahci_read_id - Read ID data from the specified device
  141. * @dev: device
  142. * @tf: proposed taskfile
  143. * @id: data buffer
  144. *
  145. * This custom read ID function is required due to the fact that the HW
  146. * does not support DEVSLP.
  147. */
  148. static unsigned int xgene_ahci_read_id(struct ata_device *dev,
  149. struct ata_taskfile *tf, u16 *id)
  150. {
  151. u32 err_mask;
  152. err_mask = ata_do_dev_read_id(dev, tf, id);
  153. if (err_mask)
  154. return err_mask;
  155. /*
  156. * Mask reserved area. Word78 spec of Link Power Management
  157. * bit15-8: reserved
  158. * bit7: NCQ autosence
  159. * bit6: Software settings preservation supported
  160. * bit5: reserved
  161. * bit4: In-order sata delivery supported
  162. * bit3: DIPM requests supported
  163. * bit2: DMA Setup FIS Auto-Activate optimization supported
  164. * bit1: DMA Setup FIX non-Zero buffer offsets supported
  165. * bit0: Reserved
  166. *
  167. * Clear reserved bit 8 (DEVSLP bit) as we don't support DEVSLP
  168. */
  169. id[ATA_ID_FEATURE_SUPP] &= ~(1 << 8);
  170. return 0;
  171. }
  172. static void xgene_ahci_set_phy_cfg(struct xgene_ahci_context *ctx, int channel)
  173. {
  174. void __iomem *mmio = ctx->hpriv->mmio;
  175. u32 val;
  176. dev_dbg(ctx->dev, "port configure mmio 0x%p channel %d\n",
  177. mmio, channel);
  178. val = readl(mmio + PORTCFG);
  179. val = PORTADDR_SET(val, channel == 0 ? 2 : 3);
  180. writel(val, mmio + PORTCFG);
  181. readl(mmio + PORTCFG); /* Force a barrier */
  182. /* Disable fix rate */
  183. writel(0x0001fffe, mmio + PORTPHY1CFG);
  184. readl(mmio + PORTPHY1CFG); /* Force a barrier */
  185. writel(0x28183219, mmio + PORTPHY2CFG);
  186. readl(mmio + PORTPHY2CFG); /* Force a barrier */
  187. writel(0x13081008, mmio + PORTPHY3CFG);
  188. readl(mmio + PORTPHY3CFG); /* Force a barrier */
  189. writel(0x00480815, mmio + PORTPHY4CFG);
  190. readl(mmio + PORTPHY4CFG); /* Force a barrier */
  191. /* Set window negotiation */
  192. val = readl(mmio + PORTPHY5CFG);
  193. val = PORTPHY5CFG_RTCHG_SET(val, 0x300);
  194. writel(val, mmio + PORTPHY5CFG);
  195. readl(mmio + PORTPHY5CFG); /* Force a barrier */
  196. val = readl(mmio + PORTAXICFG);
  197. val = PORTAXICFG_EN_CONTEXT_SET(val, 0x1); /* Enable context mgmt */
  198. val = PORTAXICFG_OUTTRANS_SET(val, 0xe); /* Set outstanding */
  199. writel(val, mmio + PORTAXICFG);
  200. readl(mmio + PORTAXICFG); /* Force a barrier */
  201. /* Set the watermark threshold of the receive FIFO */
  202. val = readl(mmio + PORTRANSCFG);
  203. val = PORTRANSCFG_RXWM_SET(val, 0x30);
  204. writel(val, mmio + PORTRANSCFG);
  205. }
  206. /**
  207. * xgene_ahci_do_hardreset - Issue the actual COMRESET
  208. * @link: link to reset
  209. * @deadline: deadline jiffies for the operation
  210. * @online: Return value to indicate if device online
  211. *
  212. * Due to the limitation of the hardware PHY, a difference set of setting is
  213. * required for each supported disk speed - Gen3 (6.0Gbps), Gen2 (3.0Gbps),
  214. * and Gen1 (1.5Gbps). Otherwise during long IO stress test, the PHY will
  215. * report disparity error and etc. In addition, during COMRESET, there can
  216. * be error reported in the register PORT_SCR_ERR. For SERR_DISPARITY and
  217. * SERR_10B_8B_ERR, the PHY receiver line must be reseted. Also during long
  218. * reboot cycle regression, sometimes the PHY reports link down even if the
  219. * device is present because of speed negotiation failure. so need to retry
  220. * the COMRESET to get the link up. The following algorithm is followed to
  221. * proper configure the hardware PHY during COMRESET:
  222. *
  223. * Alg Part 1:
  224. * 1. Start the PHY at Gen3 speed (default setting)
  225. * 2. Issue the COMRESET
  226. * 3. If no link, go to Alg Part 3
  227. * 4. If link up, determine if the negotiated speed matches the PHY
  228. * configured speed
  229. * 5. If they matched, go to Alg Part 2
  230. * 6. If they do not matched and first time, configure the PHY for the linked
  231. * up disk speed and repeat step 2
  232. * 7. Go to Alg Part 2
  233. *
  234. * Alg Part 2:
  235. * 1. On link up, if there are any SERR_DISPARITY and SERR_10B_8B_ERR error
  236. * reported in the register PORT_SCR_ERR, then reset the PHY receiver line
  237. * 2. Go to Alg Part 4
  238. *
  239. * Alg Part 3:
  240. * 1. Check the PORT_SCR_STAT to see whether device presence detected but PHY
  241. * communication establishment failed and maximum link down attempts are
  242. * less than Max attempts 3 then goto Alg Part 1.
  243. * 2. Go to Alg Part 4.
  244. *
  245. * Alg Part 4:
  246. * 1. Clear any pending from register PORT_SCR_ERR.
  247. *
  248. * NOTE: For the initial version, we will NOT support Gen1/Gen2. In addition
  249. * and until the underlying PHY supports an method to reset the receiver
  250. * line, on detection of SERR_DISPARITY or SERR_10B_8B_ERR errors,
  251. * an warning message will be printed.
  252. */
  253. static int xgene_ahci_do_hardreset(struct ata_link *link,
  254. unsigned long deadline, bool *online)
  255. {
  256. const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
  257. struct ata_port *ap = link->ap;
  258. struct ahci_host_priv *hpriv = ap->host->private_data;
  259. struct xgene_ahci_context *ctx = hpriv->plat_data;
  260. struct ahci_port_priv *pp = ap->private_data;
  261. u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
  262. void __iomem *port_mmio = ahci_port_base(ap);
  263. struct ata_taskfile tf;
  264. int link_down_retry = 0;
  265. int rc;
  266. u32 val, sstatus;
  267. do {
  268. /* clear D2H reception area to properly wait for D2H FIS */
  269. ata_tf_init(link->device, &tf);
  270. tf.command = ATA_BUSY;
  271. ata_tf_to_fis(&tf, 0, 0, d2h_fis);
  272. rc = sata_link_hardreset(link, timing, deadline, online,
  273. ahci_check_ready);
  274. if (*online) {
  275. val = readl(port_mmio + PORT_SCR_ERR);
  276. if (val & (SERR_DISPARITY | SERR_10B_8B_ERR))
  277. dev_warn(ctx->dev, "link has error\n");
  278. break;
  279. }
  280. sata_scr_read(link, SCR_STATUS, &sstatus);
  281. } while (link_down_retry++ < MAX_LINK_DOWN_RETRY &&
  282. (sstatus & 0xff) == 0x1);
  283. /* clear all errors if any pending */
  284. val = readl(port_mmio + PORT_SCR_ERR);
  285. writel(val, port_mmio + PORT_SCR_ERR);
  286. return rc;
  287. }
  288. static int xgene_ahci_hardreset(struct ata_link *link, unsigned int *class,
  289. unsigned long deadline)
  290. {
  291. struct ata_port *ap = link->ap;
  292. struct ahci_host_priv *hpriv = ap->host->private_data;
  293. void __iomem *port_mmio = ahci_port_base(ap);
  294. bool online;
  295. int rc;
  296. u32 portcmd_saved;
  297. u32 portclb_saved;
  298. u32 portclbhi_saved;
  299. u32 portrxfis_saved;
  300. u32 portrxfishi_saved;
  301. /* As hardreset resets these CSR, save it to restore later */
  302. portcmd_saved = readl(port_mmio + PORT_CMD);
  303. portclb_saved = readl(port_mmio + PORT_LST_ADDR);
  304. portclbhi_saved = readl(port_mmio + PORT_LST_ADDR_HI);
  305. portrxfis_saved = readl(port_mmio + PORT_FIS_ADDR);
  306. portrxfishi_saved = readl(port_mmio + PORT_FIS_ADDR_HI);
  307. ahci_stop_engine(ap);
  308. rc = xgene_ahci_do_hardreset(link, deadline, &online);
  309. /* As controller hardreset clears them, restore them */
  310. writel(portcmd_saved, port_mmio + PORT_CMD);
  311. writel(portclb_saved, port_mmio + PORT_LST_ADDR);
  312. writel(portclbhi_saved, port_mmio + PORT_LST_ADDR_HI);
  313. writel(portrxfis_saved, port_mmio + PORT_FIS_ADDR);
  314. writel(portrxfishi_saved, port_mmio + PORT_FIS_ADDR_HI);
  315. hpriv->start_engine(ap);
  316. if (online)
  317. *class = ahci_dev_classify(ap);
  318. return rc;
  319. }
  320. static void xgene_ahci_host_stop(struct ata_host *host)
  321. {
  322. struct ahci_host_priv *hpriv = host->private_data;
  323. ahci_platform_disable_resources(hpriv);
  324. }
  325. static struct ata_port_operations xgene_ahci_ops = {
  326. .inherits = &ahci_ops,
  327. .host_stop = xgene_ahci_host_stop,
  328. .hardreset = xgene_ahci_hardreset,
  329. .read_id = xgene_ahci_read_id,
  330. .qc_issue = xgene_ahci_qc_issue,
  331. };
  332. static const struct ata_port_info xgene_ahci_port_info = {
  333. .flags = AHCI_FLAG_COMMON,
  334. .pio_mask = ATA_PIO4,
  335. .udma_mask = ATA_UDMA6,
  336. .port_ops = &xgene_ahci_ops,
  337. };
  338. static int xgene_ahci_hw_init(struct ahci_host_priv *hpriv)
  339. {
  340. struct xgene_ahci_context *ctx = hpriv->plat_data;
  341. int i;
  342. int rc;
  343. u32 val;
  344. /* Remove IP RAM out of shutdown */
  345. rc = xgene_ahci_init_memram(ctx);
  346. if (rc)
  347. return rc;
  348. for (i = 0; i < MAX_AHCI_CHN_PERCTR; i++)
  349. xgene_ahci_set_phy_cfg(ctx, i);
  350. /* AXI disable Mask */
  351. writel(0xffffffff, hpriv->mmio + HOST_IRQ_STAT);
  352. readl(hpriv->mmio + HOST_IRQ_STAT); /* Force a barrier */
  353. writel(0, ctx->csr_core + INTSTATUSMASK);
  354. val = readl(ctx->csr_core + INTSTATUSMASK); /* Force a barrier */
  355. dev_dbg(ctx->dev, "top level interrupt mask 0x%X value 0x%08X\n",
  356. INTSTATUSMASK, val);
  357. writel(0x0, ctx->csr_core + ERRINTSTATUSMASK);
  358. readl(ctx->csr_core + ERRINTSTATUSMASK); /* Force a barrier */
  359. writel(0x0, ctx->csr_axi + INT_SLV_TMOMASK);
  360. readl(ctx->csr_axi + INT_SLV_TMOMASK);
  361. /* Enable AXI Interrupt */
  362. writel(0xffffffff, ctx->csr_core + SLVRDERRATTRIBUTES);
  363. writel(0xffffffff, ctx->csr_core + SLVWRERRATTRIBUTES);
  364. writel(0xffffffff, ctx->csr_core + MSTRDERRATTRIBUTES);
  365. writel(0xffffffff, ctx->csr_core + MSTWRERRATTRIBUTES);
  366. /* Enable coherency */
  367. val = readl(ctx->csr_core + BUSCTLREG);
  368. val &= ~0x00000002; /* Enable write coherency */
  369. val &= ~0x00000001; /* Enable read coherency */
  370. writel(val, ctx->csr_core + BUSCTLREG);
  371. val = readl(ctx->csr_core + IOFMSTRWAUX);
  372. val |= (1 << 3); /* Enable read coherency */
  373. val |= (1 << 9); /* Enable write coherency */
  374. writel(val, ctx->csr_core + IOFMSTRWAUX);
  375. val = readl(ctx->csr_core + IOFMSTRWAUX);
  376. dev_dbg(ctx->dev, "coherency 0x%X value 0x%08X\n",
  377. IOFMSTRWAUX, val);
  378. return rc;
  379. }
  380. static int xgene_ahci_mux_select(struct xgene_ahci_context *ctx)
  381. {
  382. u32 val;
  383. /* Check for optional MUX resource */
  384. if (!ctx->csr_mux)
  385. return 0;
  386. val = readl(ctx->csr_mux + SATA_ENET_CONFIG_REG);
  387. val &= ~CFG_SATA_ENET_SELECT_MASK;
  388. writel(val, ctx->csr_mux + SATA_ENET_CONFIG_REG);
  389. val = readl(ctx->csr_mux + SATA_ENET_CONFIG_REG);
  390. return val & CFG_SATA_ENET_SELECT_MASK ? -1 : 0;
  391. }
  392. static int xgene_ahci_probe(struct platform_device *pdev)
  393. {
  394. struct device *dev = &pdev->dev;
  395. struct ahci_host_priv *hpriv;
  396. struct xgene_ahci_context *ctx;
  397. struct resource *res;
  398. int rc;
  399. hpriv = ahci_platform_get_resources(pdev);
  400. if (IS_ERR(hpriv))
  401. return PTR_ERR(hpriv);
  402. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  403. if (!ctx)
  404. return -ENOMEM;
  405. hpriv->plat_data = ctx;
  406. ctx->hpriv = hpriv;
  407. ctx->dev = dev;
  408. /* Retrieve the IP core resource */
  409. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  410. ctx->csr_core = devm_ioremap_resource(dev, res);
  411. if (IS_ERR(ctx->csr_core))
  412. return PTR_ERR(ctx->csr_core);
  413. /* Retrieve the IP diagnostic resource */
  414. res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
  415. ctx->csr_diag = devm_ioremap_resource(dev, res);
  416. if (IS_ERR(ctx->csr_diag))
  417. return PTR_ERR(ctx->csr_diag);
  418. /* Retrieve the IP AXI resource */
  419. res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
  420. ctx->csr_axi = devm_ioremap_resource(dev, res);
  421. if (IS_ERR(ctx->csr_axi))
  422. return PTR_ERR(ctx->csr_axi);
  423. /* Retrieve the optional IP mux resource */
  424. res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
  425. if (res) {
  426. void __iomem *csr = devm_ioremap_resource(dev, res);
  427. if (IS_ERR(csr))
  428. return PTR_ERR(csr);
  429. ctx->csr_mux = csr;
  430. }
  431. dev_dbg(dev, "VAddr 0x%p Mmio VAddr 0x%p\n", ctx->csr_core,
  432. hpriv->mmio);
  433. /* Select ATA */
  434. if ((rc = xgene_ahci_mux_select(ctx))) {
  435. dev_err(dev, "SATA mux selection failed error %d\n", rc);
  436. return -ENODEV;
  437. }
  438. if (xgene_ahci_is_memram_inited(ctx)) {
  439. dev_info(dev, "skip clock and PHY initialization\n");
  440. goto skip_clk_phy;
  441. }
  442. /* Due to errata, HW requires full toggle transition */
  443. rc = ahci_platform_enable_clks(hpriv);
  444. if (rc)
  445. goto disable_resources;
  446. ahci_platform_disable_clks(hpriv);
  447. rc = ahci_platform_enable_resources(hpriv);
  448. if (rc)
  449. goto disable_resources;
  450. /* Configure the host controller */
  451. xgene_ahci_hw_init(hpriv);
  452. skip_clk_phy:
  453. hpriv->flags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_NO_NCQ;
  454. rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info);
  455. if (rc)
  456. goto disable_resources;
  457. dev_dbg(dev, "X-Gene SATA host controller initialized\n");
  458. return 0;
  459. disable_resources:
  460. ahci_platform_disable_resources(hpriv);
  461. return rc;
  462. }
  463. static const struct of_device_id xgene_ahci_of_match[] = {
  464. {.compatible = "apm,xgene-ahci"},
  465. {},
  466. };
  467. MODULE_DEVICE_TABLE(of, xgene_ahci_of_match);
  468. static struct platform_driver xgene_ahci_driver = {
  469. .probe = xgene_ahci_probe,
  470. .remove = ata_platform_remove_one,
  471. .driver = {
  472. .name = "xgene-ahci",
  473. .owner = THIS_MODULE,
  474. .of_match_table = xgene_ahci_of_match,
  475. },
  476. };
  477. module_platform_driver(xgene_ahci_driver);
  478. MODULE_DESCRIPTION("APM X-Gene AHCI SATA driver");
  479. MODULE_AUTHOR("Loc Ho <lho@apm.com>");
  480. MODULE_LICENSE("GPL");
  481. MODULE_VERSION("0.4");