pata_ftide010.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. * Faraday Technology FTIDE010 driver
  3. * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
  4. *
  5. * Includes portions of the SL2312/SL3516/Gemini PATA driver
  6. * Copyright (C) 2003 StorLine, Inc <jason@storlink.com.tw>
  7. * Copyright (C) 2009 Janos Laube <janos.dev@gmail.com>
  8. * Copyright (C) 2010 Frederic Pecourt <opengemini@free.fr>
  9. * Copyright (C) 2011 Tobias Waldvogel <tobias.waldvogel@gmail.com>
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/module.h>
  13. #include <linux/libata.h>
  14. #include <linux/bitops.h>
  15. #include <linux/of_address.h>
  16. #include <linux/of_device.h>
  17. #include <linux/clk.h>
  18. #include "sata_gemini.h"
  19. #define DRV_NAME "pata_ftide010"
  20. /**
  21. * struct ftide010 - state container for the Faraday FTIDE010
  22. * @dev: pointer back to the device representing this controller
  23. * @base: remapped I/O space address
  24. * @pclk: peripheral clock for the IDE block
  25. * @host: pointer to the ATA host for this device
  26. * @master_cbl: master cable type
  27. * @slave_cbl: slave cable type
  28. * @sg: Gemini SATA bridge pointer, if running on the Gemini
  29. * @master_to_sata0: Gemini SATA bridge: the ATA master is connected
  30. * to the SATA0 bridge
  31. * @slave_to_sata0: Gemini SATA bridge: the ATA slave is connected
  32. * to the SATA0 bridge
  33. * @master_to_sata1: Gemini SATA bridge: the ATA master is connected
  34. * to the SATA1 bridge
  35. * @slave_to_sata1: Gemini SATA bridge: the ATA slave is connected
  36. * to the SATA1 bridge
  37. */
  38. struct ftide010 {
  39. struct device *dev;
  40. void __iomem *base;
  41. struct clk *pclk;
  42. struct ata_host *host;
  43. unsigned int master_cbl;
  44. unsigned int slave_cbl;
  45. /* Gemini-specific properties */
  46. struct sata_gemini *sg;
  47. bool master_to_sata0;
  48. bool slave_to_sata0;
  49. bool master_to_sata1;
  50. bool slave_to_sata1;
  51. };
  52. #define FTIDE010_DMA_REG 0x00
  53. #define FTIDE010_DMA_STATUS 0x02
  54. #define FTIDE010_IDE_BMDTPR 0x04
  55. #define FTIDE010_IDE_DEVICE_ID 0x08
  56. #define FTIDE010_PIO_TIMING 0x10
  57. #define FTIDE010_MWDMA_TIMING 0x11
  58. #define FTIDE010_UDMA_TIMING0 0x12 /* Master */
  59. #define FTIDE010_UDMA_TIMING1 0x13 /* Slave */
  60. #define FTIDE010_CLK_MOD 0x14
  61. /* These registers are mapped directly to the IDE registers */
  62. #define FTIDE010_CMD_DATA 0x20
  63. #define FTIDE010_ERROR_FEATURES 0x21
  64. #define FTIDE010_NSECT 0x22
  65. #define FTIDE010_LBAL 0x23
  66. #define FTIDE010_LBAM 0x24
  67. #define FTIDE010_LBAH 0x25
  68. #define FTIDE010_DEVICE 0x26
  69. #define FTIDE010_STATUS_COMMAND 0x27
  70. #define FTIDE010_ALTSTAT_CTRL 0x36
  71. /* Set this bit for UDMA mode 5 and 6 */
  72. #define FTIDE010_UDMA_TIMING_MODE_56 BIT(7)
  73. /* 0 = 50 MHz, 1 = 66 MHz */
  74. #define FTIDE010_CLK_MOD_DEV0_CLK_SEL BIT(0)
  75. #define FTIDE010_CLK_MOD_DEV1_CLK_SEL BIT(1)
  76. /* Enable UDMA on a device */
  77. #define FTIDE010_CLK_MOD_DEV0_UDMA_EN BIT(4)
  78. #define FTIDE010_CLK_MOD_DEV1_UDMA_EN BIT(5)
  79. static struct scsi_host_template pata_ftide010_sht = {
  80. ATA_BMDMA_SHT(DRV_NAME),
  81. };
  82. /*
  83. * Bus timings
  84. *
  85. * The unit of the below required timings is two clock periods of the ATA
  86. * reference clock which is 30 nanoseconds per unit at 66MHz and 20
  87. * nanoseconds per unit at 50 MHz. The PIO timings assume 33MHz speed for
  88. * PIO.
  89. *
  90. * pio_active_time: array of 5 elements for T2 timing for Mode 0,
  91. * 1, 2, 3 and 4. Range 0..15.
  92. * pio_recovery_time: array of 5 elements for T2l timing for Mode 0,
  93. * 1, 2, 3 and 4. Range 0..15.
  94. * mdma_50_active_time: array of 4 elements for Td timing for multi
  95. * word DMA, Mode 0, 1, and 2 at 50 MHz. Range 0..15.
  96. * mdma_50_recovery_time: array of 4 elements for Tk timing for
  97. * multi word DMA, Mode 0, 1 and 2 at 50 MHz. Range 0..15.
  98. * mdma_66_active_time: array of 4 elements for Td timing for multi
  99. * word DMA, Mode 0, 1 and 2 at 66 MHz. Range 0..15.
  100. * mdma_66_recovery_time: array of 4 elements for Tk timing for
  101. * multi word DMA, Mode 0, 1 and 2 at 66 MHz. Range 0..15.
  102. * udma_50_setup_time: array of 4 elements for Tvds timing for ultra
  103. * DMA, Mode 0, 1, 2, 3, 4 and 5 at 50 MHz. Range 0..7.
  104. * udma_50_hold_time: array of 4 elements for Tdvh timing for
  105. * multi word DMA, Mode 0, 1, 2, 3, 4 and 5 at 50 MHz, Range 0..7.
  106. * udma_66_setup_time: array of 4 elements for Tvds timing for multi
  107. * word DMA, Mode 0, 1, 2, 3, 4, 5 and 6 at 66 MHz. Range 0..7.
  108. * udma_66_hold_time: array of 4 elements for Tdvh timing for
  109. * multi word DMA, Mode 0, 1, 2, 3, 4, 5 and 6 at 66 MHz. Range 0..7.
  110. */
  111. static const u8 pio_active_time[5] = {10, 10, 10, 3, 3};
  112. static const u8 pio_recovery_time[5] = {10, 3, 1, 3, 1};
  113. static const u8 mwdma_50_active_time[3] = {6, 2, 2};
  114. static const u8 mwdma_50_recovery_time[3] = {6, 2, 1};
  115. static const u8 mwdma_66_active_time[3] = {8, 3, 3};
  116. static const u8 mwdma_66_recovery_time[3] = {8, 2, 1};
  117. static const u8 udma_50_setup_time[6] = {3, 3, 2, 2, 1, 1};
  118. static const u8 udma_50_hold_time[6] = {3, 1, 1, 1, 1, 1};
  119. static const u8 udma_66_setup_time[7] = {4, 4, 3, 2, };
  120. static const u8 udma_66_hold_time[7] = {};
  121. /*
  122. * We set 66 MHz for all MWDMA modes
  123. */
  124. static const bool set_mdma_66_mhz[] = { true, true, true, true };
  125. /*
  126. * We set 66 MHz for UDMA modes 3, 4 and 6 and no others
  127. */
  128. static const bool set_udma_66_mhz[] = { false, false, false, true, true, false, true };
  129. static void ftide010_set_dmamode(struct ata_port *ap, struct ata_device *adev)
  130. {
  131. struct ftide010 *ftide = ap->host->private_data;
  132. u8 speed = adev->dma_mode;
  133. u8 devno = adev->devno & 1;
  134. u8 udma_en_mask;
  135. u8 f66m_en_mask;
  136. u8 clkreg;
  137. u8 timreg;
  138. u8 i;
  139. /* Target device 0 (master) or 1 (slave) */
  140. if (!devno) {
  141. udma_en_mask = FTIDE010_CLK_MOD_DEV0_UDMA_EN;
  142. f66m_en_mask = FTIDE010_CLK_MOD_DEV0_CLK_SEL;
  143. } else {
  144. udma_en_mask = FTIDE010_CLK_MOD_DEV1_UDMA_EN;
  145. f66m_en_mask = FTIDE010_CLK_MOD_DEV1_CLK_SEL;
  146. }
  147. clkreg = readb(ftide->base + FTIDE010_CLK_MOD);
  148. clkreg &= ~udma_en_mask;
  149. clkreg &= ~f66m_en_mask;
  150. if (speed & XFER_UDMA_0) {
  151. i = speed & ~XFER_UDMA_0;
  152. dev_dbg(ftide->dev, "set UDMA mode %02x, index %d\n",
  153. speed, i);
  154. clkreg |= udma_en_mask;
  155. if (set_udma_66_mhz[i]) {
  156. clkreg |= f66m_en_mask;
  157. timreg = udma_66_setup_time[i] << 4 |
  158. udma_66_hold_time[i];
  159. } else {
  160. timreg = udma_50_setup_time[i] << 4 |
  161. udma_50_hold_time[i];
  162. }
  163. /* A special bit needs to be set for modes 5 and 6 */
  164. if (i >= 5)
  165. timreg |= FTIDE010_UDMA_TIMING_MODE_56;
  166. dev_dbg(ftide->dev, "UDMA write clkreg = %02x, timreg = %02x\n",
  167. clkreg, timreg);
  168. writeb(clkreg, ftide->base + FTIDE010_CLK_MOD);
  169. writeb(timreg, ftide->base + FTIDE010_UDMA_TIMING0 + devno);
  170. } else {
  171. i = speed & ~XFER_MW_DMA_0;
  172. dev_dbg(ftide->dev, "set MWDMA mode %02x, index %d\n",
  173. speed, i);
  174. if (set_mdma_66_mhz[i]) {
  175. clkreg |= f66m_en_mask;
  176. timreg = mwdma_66_active_time[i] << 4 |
  177. mwdma_66_recovery_time[i];
  178. } else {
  179. timreg = mwdma_50_active_time[i] << 4 |
  180. mwdma_50_recovery_time[i];
  181. }
  182. dev_dbg(ftide->dev,
  183. "MWDMA write clkreg = %02x, timreg = %02x\n",
  184. clkreg, timreg);
  185. /* This will affect all devices */
  186. writeb(clkreg, ftide->base + FTIDE010_CLK_MOD);
  187. writeb(timreg, ftide->base + FTIDE010_MWDMA_TIMING);
  188. }
  189. /*
  190. * Store the current device (master or slave) in ap->private_data
  191. * so that .qc_issue() can detect if this changes and reprogram
  192. * the DMA settings.
  193. */
  194. ap->private_data = adev;
  195. return;
  196. }
  197. static void ftide010_set_piomode(struct ata_port *ap, struct ata_device *adev)
  198. {
  199. struct ftide010 *ftide = ap->host->private_data;
  200. u8 pio = adev->pio_mode - XFER_PIO_0;
  201. dev_dbg(ftide->dev, "set PIO mode %02x, index %d\n",
  202. adev->pio_mode, pio);
  203. writeb(pio_active_time[pio] << 4 | pio_recovery_time[pio],
  204. ftide->base + FTIDE010_PIO_TIMING);
  205. }
  206. /*
  207. * We implement our own qc_issue() callback since we may need to set up
  208. * the timings differently for master and slave transfers: the CLK_MOD_REG
  209. * and MWDMA_TIMING_REG is shared between master and slave, so reprogramming
  210. * this may be necessary.
  211. */
  212. static unsigned int ftide010_qc_issue(struct ata_queued_cmd *qc)
  213. {
  214. struct ata_port *ap = qc->ap;
  215. struct ata_device *adev = qc->dev;
  216. /*
  217. * If the device changed, i.e. slave->master, master->slave,
  218. * then set up the DMA mode again so we are sure the timings
  219. * are correct.
  220. */
  221. if (adev != ap->private_data && ata_dma_enabled(adev))
  222. ftide010_set_dmamode(ap, adev);
  223. return ata_bmdma_qc_issue(qc);
  224. }
  225. static struct ata_port_operations pata_ftide010_port_ops = {
  226. .inherits = &ata_bmdma_port_ops,
  227. .set_dmamode = ftide010_set_dmamode,
  228. .set_piomode = ftide010_set_piomode,
  229. .qc_issue = ftide010_qc_issue,
  230. };
  231. static struct ata_port_info ftide010_port_info = {
  232. .flags = ATA_FLAG_SLAVE_POSS,
  233. .mwdma_mask = ATA_MWDMA2,
  234. .udma_mask = ATA_UDMA6,
  235. .pio_mask = ATA_PIO4,
  236. .port_ops = &pata_ftide010_port_ops,
  237. };
  238. #if IS_ENABLED(CONFIG_SATA_GEMINI)
  239. static int pata_ftide010_gemini_port_start(struct ata_port *ap)
  240. {
  241. struct ftide010 *ftide = ap->host->private_data;
  242. struct device *dev = ftide->dev;
  243. struct sata_gemini *sg = ftide->sg;
  244. int bridges = 0;
  245. int ret;
  246. ret = ata_bmdma_port_start(ap);
  247. if (ret)
  248. return ret;
  249. if (ftide->master_to_sata0) {
  250. dev_info(dev, "SATA0 (master) start\n");
  251. ret = gemini_sata_start_bridge(sg, 0);
  252. if (!ret)
  253. bridges++;
  254. }
  255. if (ftide->master_to_sata1) {
  256. dev_info(dev, "SATA1 (master) start\n");
  257. ret = gemini_sata_start_bridge(sg, 1);
  258. if (!ret)
  259. bridges++;
  260. }
  261. /* Avoid double-starting */
  262. if (ftide->slave_to_sata0 && !ftide->master_to_sata0) {
  263. dev_info(dev, "SATA0 (slave) start\n");
  264. ret = gemini_sata_start_bridge(sg, 0);
  265. if (!ret)
  266. bridges++;
  267. }
  268. /* Avoid double-starting */
  269. if (ftide->slave_to_sata1 && !ftide->master_to_sata1) {
  270. dev_info(dev, "SATA1 (slave) start\n");
  271. ret = gemini_sata_start_bridge(sg, 1);
  272. if (!ret)
  273. bridges++;
  274. }
  275. dev_info(dev, "brought %d bridges online\n", bridges);
  276. return (bridges > 0) ? 0 : -EINVAL; // -ENODEV;
  277. }
  278. static void pata_ftide010_gemini_port_stop(struct ata_port *ap)
  279. {
  280. struct ftide010 *ftide = ap->host->private_data;
  281. struct device *dev = ftide->dev;
  282. struct sata_gemini *sg = ftide->sg;
  283. if (ftide->master_to_sata0) {
  284. dev_info(dev, "SATA0 (master) stop\n");
  285. gemini_sata_stop_bridge(sg, 0);
  286. }
  287. if (ftide->master_to_sata1) {
  288. dev_info(dev, "SATA1 (master) stop\n");
  289. gemini_sata_stop_bridge(sg, 1);
  290. }
  291. /* Avoid double-stopping */
  292. if (ftide->slave_to_sata0 && !ftide->master_to_sata0) {
  293. dev_info(dev, "SATA0 (slave) stop\n");
  294. gemini_sata_stop_bridge(sg, 0);
  295. }
  296. /* Avoid double-stopping */
  297. if (ftide->slave_to_sata1 && !ftide->master_to_sata1) {
  298. dev_info(dev, "SATA1 (slave) stop\n");
  299. gemini_sata_stop_bridge(sg, 1);
  300. }
  301. }
  302. static int pata_ftide010_gemini_cable_detect(struct ata_port *ap)
  303. {
  304. struct ftide010 *ftide = ap->host->private_data;
  305. /*
  306. * Return the master cable, I have no clue how to return a different
  307. * cable for the slave than for the master.
  308. */
  309. return ftide->master_cbl;
  310. }
  311. static int pata_ftide010_gemini_init(struct ftide010 *ftide,
  312. struct ata_port_info *pi,
  313. bool is_ata1)
  314. {
  315. struct device *dev = ftide->dev;
  316. struct sata_gemini *sg;
  317. enum gemini_muxmode muxmode;
  318. /* Look up SATA bridge */
  319. sg = gemini_sata_bridge_get();
  320. if (IS_ERR(sg))
  321. return PTR_ERR(sg);
  322. ftide->sg = sg;
  323. muxmode = gemini_sata_get_muxmode(sg);
  324. /* Special ops */
  325. pata_ftide010_port_ops.port_start =
  326. pata_ftide010_gemini_port_start;
  327. pata_ftide010_port_ops.port_stop =
  328. pata_ftide010_gemini_port_stop;
  329. pata_ftide010_port_ops.cable_detect =
  330. pata_ftide010_gemini_cable_detect;
  331. /* Flag port as SATA-capable */
  332. if (gemini_sata_bridge_enabled(sg, is_ata1))
  333. pi->flags |= ATA_FLAG_SATA;
  334. /* This device has broken DMA, only PIO works */
  335. if (of_machine_is_compatible("itian,sq201")) {
  336. pi->mwdma_mask = 0;
  337. pi->udma_mask = 0;
  338. }
  339. /*
  340. * We assume that a simple 40-wire cable is used in the PATA mode.
  341. * if you're adding a system using the PATA interface, make sure
  342. * the right cable is set up here, it might be necessary to use
  343. * special hardware detection or encode the cable type in the device
  344. * tree with special properties.
  345. */
  346. if (!is_ata1) {
  347. switch (muxmode) {
  348. case GEMINI_MUXMODE_0:
  349. ftide->master_cbl = ATA_CBL_SATA;
  350. ftide->slave_cbl = ATA_CBL_PATA40;
  351. ftide->master_to_sata0 = true;
  352. break;
  353. case GEMINI_MUXMODE_1:
  354. ftide->master_cbl = ATA_CBL_SATA;
  355. ftide->slave_cbl = ATA_CBL_NONE;
  356. ftide->master_to_sata0 = true;
  357. break;
  358. case GEMINI_MUXMODE_2:
  359. ftide->master_cbl = ATA_CBL_PATA40;
  360. ftide->slave_cbl = ATA_CBL_PATA40;
  361. break;
  362. case GEMINI_MUXMODE_3:
  363. ftide->master_cbl = ATA_CBL_SATA;
  364. ftide->slave_cbl = ATA_CBL_SATA;
  365. ftide->master_to_sata0 = true;
  366. ftide->slave_to_sata1 = true;
  367. break;
  368. }
  369. } else {
  370. switch (muxmode) {
  371. case GEMINI_MUXMODE_0:
  372. ftide->master_cbl = ATA_CBL_SATA;
  373. ftide->slave_cbl = ATA_CBL_NONE;
  374. ftide->master_to_sata1 = true;
  375. break;
  376. case GEMINI_MUXMODE_1:
  377. ftide->master_cbl = ATA_CBL_SATA;
  378. ftide->slave_cbl = ATA_CBL_PATA40;
  379. ftide->master_to_sata1 = true;
  380. break;
  381. case GEMINI_MUXMODE_2:
  382. ftide->master_cbl = ATA_CBL_SATA;
  383. ftide->slave_cbl = ATA_CBL_SATA;
  384. ftide->slave_to_sata0 = true;
  385. ftide->master_to_sata1 = true;
  386. break;
  387. case GEMINI_MUXMODE_3:
  388. ftide->master_cbl = ATA_CBL_PATA40;
  389. ftide->slave_cbl = ATA_CBL_PATA40;
  390. break;
  391. }
  392. }
  393. dev_info(dev, "set up Gemini PATA%d\n", is_ata1);
  394. return 0;
  395. }
  396. #else
  397. static int pata_ftide010_gemini_init(struct ftide010 *ftide,
  398. struct ata_port_info *pi,
  399. bool is_ata1)
  400. {
  401. return -ENOTSUPP;
  402. }
  403. #endif
  404. static int pata_ftide010_probe(struct platform_device *pdev)
  405. {
  406. struct device *dev = &pdev->dev;
  407. struct device_node *np = dev->of_node;
  408. struct ata_port_info pi = ftide010_port_info;
  409. const struct ata_port_info *ppi[] = { &pi, NULL };
  410. struct ftide010 *ftide;
  411. struct resource *res;
  412. int irq;
  413. int ret;
  414. int i;
  415. ftide = devm_kzalloc(dev, sizeof(*ftide), GFP_KERNEL);
  416. if (!ftide)
  417. return -ENOMEM;
  418. ftide->dev = dev;
  419. irq = platform_get_irq(pdev, 0);
  420. if (irq < 0)
  421. return irq;
  422. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  423. if (!res)
  424. return -ENODEV;
  425. ftide->base = devm_ioremap_resource(dev, res);
  426. if (IS_ERR(ftide->base))
  427. return PTR_ERR(ftide->base);
  428. ftide->pclk = devm_clk_get(dev, "PCLK");
  429. if (!IS_ERR(ftide->pclk)) {
  430. ret = clk_prepare_enable(ftide->pclk);
  431. if (ret) {
  432. dev_err(dev, "failed to enable PCLK\n");
  433. return ret;
  434. }
  435. }
  436. /* Some special Cortina Gemini init, if needed */
  437. if (of_device_is_compatible(np, "cortina,gemini-pata")) {
  438. /*
  439. * We need to know which instance is probing (the
  440. * Gemini has two instances of FTIDE010) and we do
  441. * this simply by looking at the physical base
  442. * address, which is 0x63400000 for ATA1, else we
  443. * are ATA0. This will also set up the cable types.
  444. */
  445. ret = pata_ftide010_gemini_init(ftide,
  446. &pi,
  447. (res->start == 0x63400000));
  448. if (ret)
  449. goto err_dis_clk;
  450. } else {
  451. /* Else assume we are connected using PATA40 */
  452. ftide->master_cbl = ATA_CBL_PATA40;
  453. ftide->slave_cbl = ATA_CBL_PATA40;
  454. }
  455. ftide->host = ata_host_alloc_pinfo(dev, ppi, 1);
  456. if (!ftide->host) {
  457. ret = -ENOMEM;
  458. goto err_dis_clk;
  459. }
  460. ftide->host->private_data = ftide;
  461. for (i = 0; i < ftide->host->n_ports; i++) {
  462. struct ata_port *ap = ftide->host->ports[i];
  463. struct ata_ioports *ioaddr = &ap->ioaddr;
  464. ioaddr->bmdma_addr = ftide->base + FTIDE010_DMA_REG;
  465. ioaddr->cmd_addr = ftide->base + FTIDE010_CMD_DATA;
  466. ioaddr->ctl_addr = ftide->base + FTIDE010_ALTSTAT_CTRL;
  467. ioaddr->altstatus_addr = ftide->base + FTIDE010_ALTSTAT_CTRL;
  468. ata_sff_std_ports(ioaddr);
  469. }
  470. dev_info(dev, "device ID %08x, irq %d, reg %pR\n",
  471. readl(ftide->base + FTIDE010_IDE_DEVICE_ID), irq, res);
  472. ret = ata_host_activate(ftide->host, irq, ata_bmdma_interrupt,
  473. 0, &pata_ftide010_sht);
  474. if (ret)
  475. goto err_dis_clk;
  476. return 0;
  477. err_dis_clk:
  478. if (!IS_ERR(ftide->pclk))
  479. clk_disable_unprepare(ftide->pclk);
  480. return ret;
  481. }
  482. static int pata_ftide010_remove(struct platform_device *pdev)
  483. {
  484. struct ata_host *host = platform_get_drvdata(pdev);
  485. struct ftide010 *ftide = host->private_data;
  486. ata_host_detach(ftide->host);
  487. if (!IS_ERR(ftide->pclk))
  488. clk_disable_unprepare(ftide->pclk);
  489. return 0;
  490. }
  491. static const struct of_device_id pata_ftide010_of_match[] = {
  492. {
  493. .compatible = "faraday,ftide010",
  494. },
  495. {},
  496. };
  497. static struct platform_driver pata_ftide010_driver = {
  498. .driver = {
  499. .name = DRV_NAME,
  500. .of_match_table = of_match_ptr(pata_ftide010_of_match),
  501. },
  502. .probe = pata_ftide010_probe,
  503. .remove = pata_ftide010_remove,
  504. };
  505. module_platform_driver(pata_ftide010_driver);
  506. MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
  507. MODULE_LICENSE("GPL");
  508. MODULE_ALIAS("platform:" DRV_NAME);