au1xxx-ide.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * AMD Alchemy Au1xxx IDE interface routines over the Static Bus
  4. *
  5. * Copyright (c) 2003-2005 AMD, Personal Connectivity Solutions
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  13. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  14. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
  15. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  16. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  17. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  18. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  19. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  20. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  21. * POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along with
  24. * this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. *
  27. * Note: for more information, please refer "AMD Alchemy Au1200/Au1550 IDE
  28. * Interface and Linux Device Driver" Application Note.
  29. */
  30. #include <linux/types.h>
  31. #include <linux/module.h>
  32. #include <linux/kernel.h>
  33. #include <linux/delay.h>
  34. #include <linux/platform_device.h>
  35. #include <linux/init.h>
  36. #include <linux/ide.h>
  37. #include <linux/scatterlist.h>
  38. #include <asm/mach-au1x00/au1xxx.h>
  39. #include <asm/mach-au1x00/au1xxx_dbdma.h>
  40. #include <asm/mach-au1x00/au1xxx_ide.h>
  41. #define DRV_NAME "au1200-ide"
  42. #define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>"
  43. /* enable the burstmode in the dbdma */
  44. #define IDE_AU1XXX_BURSTMODE 1
  45. static _auide_hwif auide_hwif;
  46. #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
  47. static inline void auide_insw(unsigned long port, void *addr, u32 count)
  48. {
  49. _auide_hwif *ahwif = &auide_hwif;
  50. chan_tab_t *ctp;
  51. au1x_ddma_desc_t *dp;
  52. if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, virt_to_phys(addr),
  53. count << 1, DDMA_FLAGS_NOIE)) {
  54. printk(KERN_ERR "%s failed %d\n", __func__, __LINE__);
  55. return;
  56. }
  57. ctp = *((chan_tab_t **)ahwif->rx_chan);
  58. dp = ctp->cur_ptr;
  59. while (dp->dscr_cmd0 & DSCR_CMD0_V)
  60. ;
  61. ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
  62. }
  63. static inline void auide_outsw(unsigned long port, void *addr, u32 count)
  64. {
  65. _auide_hwif *ahwif = &auide_hwif;
  66. chan_tab_t *ctp;
  67. au1x_ddma_desc_t *dp;
  68. if (!au1xxx_dbdma_put_source(ahwif->tx_chan, virt_to_phys(addr),
  69. count << 1, DDMA_FLAGS_NOIE)) {
  70. printk(KERN_ERR "%s failed %d\n", __func__, __LINE__);
  71. return;
  72. }
  73. ctp = *((chan_tab_t **)ahwif->tx_chan);
  74. dp = ctp->cur_ptr;
  75. while (dp->dscr_cmd0 & DSCR_CMD0_V)
  76. ;
  77. ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
  78. }
  79. static void au1xxx_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
  80. void *buf, unsigned int len)
  81. {
  82. auide_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  83. }
  84. static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
  85. void *buf, unsigned int len)
  86. {
  87. auide_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  88. }
  89. #endif
  90. static void au1xxx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
  91. {
  92. int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
  93. switch (drive->pio_mode - XFER_PIO_0) {
  94. case 0:
  95. mem_sttime = SBC_IDE_TIMING(PIO0);
  96. /* set configuration for RCS2# */
  97. mem_stcfg |= TS_MASK;
  98. mem_stcfg &= ~TCSOE_MASK;
  99. mem_stcfg &= ~TOECS_MASK;
  100. mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS;
  101. break;
  102. case 1:
  103. mem_sttime = SBC_IDE_TIMING(PIO1);
  104. /* set configuration for RCS2# */
  105. mem_stcfg |= TS_MASK;
  106. mem_stcfg &= ~TCSOE_MASK;
  107. mem_stcfg &= ~TOECS_MASK;
  108. mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS;
  109. break;
  110. case 2:
  111. mem_sttime = SBC_IDE_TIMING(PIO2);
  112. /* set configuration for RCS2# */
  113. mem_stcfg &= ~TS_MASK;
  114. mem_stcfg &= ~TCSOE_MASK;
  115. mem_stcfg &= ~TOECS_MASK;
  116. mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS;
  117. break;
  118. case 3:
  119. mem_sttime = SBC_IDE_TIMING(PIO3);
  120. /* set configuration for RCS2# */
  121. mem_stcfg &= ~TS_MASK;
  122. mem_stcfg &= ~TCSOE_MASK;
  123. mem_stcfg &= ~TOECS_MASK;
  124. mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
  125. break;
  126. case 4:
  127. mem_sttime = SBC_IDE_TIMING(PIO4);
  128. /* set configuration for RCS2# */
  129. mem_stcfg &= ~TS_MASK;
  130. mem_stcfg &= ~TCSOE_MASK;
  131. mem_stcfg &= ~TOECS_MASK;
  132. mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
  133. break;
  134. }
  135. au_writel(mem_sttime,MEM_STTIME2);
  136. au_writel(mem_stcfg,MEM_STCFG2);
  137. }
  138. static void auide_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
  139. {
  140. int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
  141. switch (drive->dma_mode) {
  142. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  143. case XFER_MW_DMA_2:
  144. mem_sttime = SBC_IDE_TIMING(MDMA2);
  145. /* set configuration for RCS2# */
  146. mem_stcfg &= ~TS_MASK;
  147. mem_stcfg &= ~TCSOE_MASK;
  148. mem_stcfg &= ~TOECS_MASK;
  149. mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS;
  150. break;
  151. case XFER_MW_DMA_1:
  152. mem_sttime = SBC_IDE_TIMING(MDMA1);
  153. /* set configuration for RCS2# */
  154. mem_stcfg &= ~TS_MASK;
  155. mem_stcfg &= ~TCSOE_MASK;
  156. mem_stcfg &= ~TOECS_MASK;
  157. mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS;
  158. break;
  159. case XFER_MW_DMA_0:
  160. mem_sttime = SBC_IDE_TIMING(MDMA0);
  161. /* set configuration for RCS2# */
  162. mem_stcfg |= TS_MASK;
  163. mem_stcfg &= ~TCSOE_MASK;
  164. mem_stcfg &= ~TOECS_MASK;
  165. mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
  166. break;
  167. #endif
  168. }
  169. au_writel(mem_sttime,MEM_STTIME2);
  170. au_writel(mem_stcfg,MEM_STCFG2);
  171. }
  172. /*
  173. * Multi-Word DMA + DbDMA functions
  174. */
  175. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  176. static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
  177. {
  178. ide_hwif_t *hwif = drive->hwif;
  179. _auide_hwif *ahwif = &auide_hwif;
  180. struct scatterlist *sg;
  181. int i = cmd->sg_nents, count = 0;
  182. int iswrite = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
  183. /* Save for interrupt context */
  184. ahwif->drive = drive;
  185. /* fill the descriptors */
  186. sg = hwif->sg_table;
  187. while (i && sg_dma_len(sg)) {
  188. u32 cur_addr;
  189. u32 cur_len;
  190. cur_addr = sg_dma_address(sg);
  191. cur_len = sg_dma_len(sg);
  192. while (cur_len) {
  193. u32 flags = DDMA_FLAGS_NOIE;
  194. unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
  195. if (++count >= PRD_ENTRIES) {
  196. printk(KERN_WARNING "%s: DMA table too small\n",
  197. drive->name);
  198. return 0;
  199. }
  200. /* Lets enable intr for the last descriptor only */
  201. if (1==i)
  202. flags = DDMA_FLAGS_IE;
  203. else
  204. flags = DDMA_FLAGS_NOIE;
  205. if (iswrite) {
  206. if (!au1xxx_dbdma_put_source(ahwif->tx_chan,
  207. sg_phys(sg), tc, flags)) {
  208. printk(KERN_ERR "%s failed %d\n",
  209. __func__, __LINE__);
  210. }
  211. } else {
  212. if (!au1xxx_dbdma_put_dest(ahwif->rx_chan,
  213. sg_phys(sg), tc, flags)) {
  214. printk(KERN_ERR "%s failed %d\n",
  215. __func__, __LINE__);
  216. }
  217. }
  218. cur_addr += tc;
  219. cur_len -= tc;
  220. }
  221. sg = sg_next(sg);
  222. i--;
  223. }
  224. if (count)
  225. return 1;
  226. return 0; /* revert to PIO for this request */
  227. }
  228. static int auide_dma_end(ide_drive_t *drive)
  229. {
  230. return 0;
  231. }
  232. static void auide_dma_start(ide_drive_t *drive )
  233. {
  234. }
  235. static int auide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
  236. {
  237. if (auide_build_dmatable(drive, cmd) == 0)
  238. return 1;
  239. return 0;
  240. }
  241. static int auide_dma_test_irq(ide_drive_t *drive)
  242. {
  243. /* If dbdma didn't execute the STOP command yet, the
  244. * active bit is still set
  245. */
  246. drive->waiting_for_dma++;
  247. if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
  248. printk(KERN_WARNING "%s: timeout waiting for ddma to complete\n",
  249. drive->name);
  250. return 1;
  251. }
  252. udelay(10);
  253. return 0;
  254. }
  255. static void auide_dma_host_set(ide_drive_t *drive, int on)
  256. {
  257. }
  258. static void auide_ddma_tx_callback(int irq, void *param)
  259. {
  260. }
  261. static void auide_ddma_rx_callback(int irq, void *param)
  262. {
  263. }
  264. #endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
  265. static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 devwidth, u32 flags)
  266. {
  267. dev->dev_id = dev_id;
  268. dev->dev_physaddr = (u32)IDE_PHYS_ADDR;
  269. dev->dev_intlevel = 0;
  270. dev->dev_intpolarity = 0;
  271. dev->dev_tsize = tsize;
  272. dev->dev_devwidth = devwidth;
  273. dev->dev_flags = flags;
  274. }
  275. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  276. static const struct ide_dma_ops au1xxx_dma_ops = {
  277. .dma_host_set = auide_dma_host_set,
  278. .dma_setup = auide_dma_setup,
  279. .dma_start = auide_dma_start,
  280. .dma_end = auide_dma_end,
  281. .dma_test_irq = auide_dma_test_irq,
  282. .dma_lost_irq = ide_dma_lost_irq,
  283. };
  284. static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  285. {
  286. _auide_hwif *auide = &auide_hwif;
  287. dbdev_tab_t source_dev_tab, target_dev_tab;
  288. u32 dev_id, tsize, devwidth, flags;
  289. dev_id = IDE_DDMA_REQ;
  290. tsize = 8; /* 1 */
  291. devwidth = 32; /* 16 */
  292. #ifdef IDE_AU1XXX_BURSTMODE
  293. flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
  294. #else
  295. flags = DEV_FLAGS_SYNC;
  296. #endif
  297. /* setup dev_tab for tx channel */
  298. auide_init_dbdma_dev( &source_dev_tab,
  299. dev_id,
  300. tsize, devwidth, DEV_FLAGS_OUT | flags);
  301. auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  302. auide_init_dbdma_dev( &source_dev_tab,
  303. dev_id,
  304. tsize, devwidth, DEV_FLAGS_IN | flags);
  305. auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  306. /* We also need to add a target device for the DMA */
  307. auide_init_dbdma_dev( &target_dev_tab,
  308. (u32)DSCR_CMD0_ALWAYS,
  309. tsize, devwidth, DEV_FLAGS_ANYUSE);
  310. auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab);
  311. /* Get a channel for TX */
  312. auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
  313. auide->tx_dev_id,
  314. auide_ddma_tx_callback,
  315. (void*)auide);
  316. /* Get a channel for RX */
  317. auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
  318. auide->target_dev_id,
  319. auide_ddma_rx_callback,
  320. (void*)auide);
  321. auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
  322. NUM_DESCRIPTORS);
  323. auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
  324. NUM_DESCRIPTORS);
  325. /* FIXME: check return value */
  326. (void)ide_allocate_dma_engine(hwif);
  327. au1xxx_dbdma_start( auide->tx_chan );
  328. au1xxx_dbdma_start( auide->rx_chan );
  329. return 0;
  330. }
  331. #else
  332. static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  333. {
  334. _auide_hwif *auide = &auide_hwif;
  335. dbdev_tab_t source_dev_tab;
  336. int flags;
  337. #ifdef IDE_AU1XXX_BURSTMODE
  338. flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
  339. #else
  340. flags = DEV_FLAGS_SYNC;
  341. #endif
  342. /* setup dev_tab for tx channel */
  343. auide_init_dbdma_dev( &source_dev_tab,
  344. (u32)DSCR_CMD0_ALWAYS,
  345. 8, 32, DEV_FLAGS_OUT | flags);
  346. auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  347. auide_init_dbdma_dev( &source_dev_tab,
  348. (u32)DSCR_CMD0_ALWAYS,
  349. 8, 32, DEV_FLAGS_IN | flags);
  350. auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  351. /* Get a channel for TX */
  352. auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
  353. auide->tx_dev_id,
  354. NULL,
  355. (void*)auide);
  356. /* Get a channel for RX */
  357. auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
  358. DSCR_CMD0_ALWAYS,
  359. NULL,
  360. (void*)auide);
  361. auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
  362. NUM_DESCRIPTORS);
  363. auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
  364. NUM_DESCRIPTORS);
  365. au1xxx_dbdma_start( auide->tx_chan );
  366. au1xxx_dbdma_start( auide->rx_chan );
  367. return 0;
  368. }
  369. #endif
  370. static void auide_setup_ports(struct ide_hw *hw, _auide_hwif *ahwif)
  371. {
  372. int i;
  373. unsigned long *ata_regs = hw->io_ports_array;
  374. /* FIXME? */
  375. for (i = 0; i < 8; i++)
  376. *ata_regs++ = ahwif->regbase + (i << IDE_REG_SHIFT);
  377. /* set the Alternative Status register */
  378. *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT);
  379. }
  380. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
  381. static const struct ide_tp_ops au1xxx_tp_ops = {
  382. .exec_command = ide_exec_command,
  383. .read_status = ide_read_status,
  384. .read_altstatus = ide_read_altstatus,
  385. .write_devctl = ide_write_devctl,
  386. .dev_select = ide_dev_select,
  387. .tf_load = ide_tf_load,
  388. .tf_read = ide_tf_read,
  389. .input_data = au1xxx_input_data,
  390. .output_data = au1xxx_output_data,
  391. };
  392. #endif
  393. static const struct ide_port_ops au1xxx_port_ops = {
  394. .set_pio_mode = au1xxx_set_pio_mode,
  395. .set_dma_mode = auide_set_dma_mode,
  396. };
  397. static const struct ide_port_info au1xxx_port_info = {
  398. .init_dma = auide_ddma_init,
  399. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
  400. .tp_ops = &au1xxx_tp_ops,
  401. #endif
  402. .port_ops = &au1xxx_port_ops,
  403. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  404. .dma_ops = &au1xxx_dma_ops,
  405. #endif
  406. .host_flags = IDE_HFLAG_POST_SET_MODE |
  407. IDE_HFLAG_NO_IO_32BIT |
  408. IDE_HFLAG_UNMASK_IRQS,
  409. .pio_mask = ATA_PIO4,
  410. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  411. .mwdma_mask = ATA_MWDMA2,
  412. #endif
  413. .chipset = ide_au1xxx,
  414. };
  415. static int au_ide_probe(struct platform_device *dev)
  416. {
  417. _auide_hwif *ahwif = &auide_hwif;
  418. struct resource *res;
  419. struct ide_host *host;
  420. int ret = 0;
  421. struct ide_hw hw, *hws[] = { &hw };
  422. #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
  423. char *mode = "MWDMA2";
  424. #elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
  425. char *mode = "PIO+DDMA(offload)";
  426. #endif
  427. memset(&auide_hwif, 0, sizeof(_auide_hwif));
  428. ahwif->irq = platform_get_irq(dev, 0);
  429. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  430. if (res == NULL) {
  431. pr_debug("%s %d: no base address\n", DRV_NAME, dev->id);
  432. ret = -ENODEV;
  433. goto out;
  434. }
  435. if (ahwif->irq < 0) {
  436. pr_debug("%s %d: no IRQ\n", DRV_NAME, dev->id);
  437. ret = -ENODEV;
  438. goto out;
  439. }
  440. if (!request_mem_region(res->start, resource_size(res), dev->name)) {
  441. pr_debug("%s: request_mem_region failed\n", DRV_NAME);
  442. ret = -EBUSY;
  443. goto out;
  444. }
  445. ahwif->regbase = (u32)ioremap(res->start, resource_size(res));
  446. if (ahwif->regbase == 0) {
  447. ret = -ENOMEM;
  448. goto out;
  449. }
  450. memset(&hw, 0, sizeof(hw));
  451. auide_setup_ports(&hw, ahwif);
  452. hw.irq = ahwif->irq;
  453. hw.dev = &dev->dev;
  454. ret = ide_host_add(&au1xxx_port_info, hws, 1, &host);
  455. if (ret)
  456. goto out;
  457. auide_hwif.hwif = host->ports[0];
  458. platform_set_drvdata(dev, host);
  459. printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
  460. out:
  461. return ret;
  462. }
  463. static int au_ide_remove(struct platform_device *dev)
  464. {
  465. struct resource *res;
  466. struct ide_host *host = platform_get_drvdata(dev);
  467. _auide_hwif *ahwif = &auide_hwif;
  468. ide_host_remove(host);
  469. iounmap((void *)ahwif->regbase);
  470. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  471. release_mem_region(res->start, resource_size(res));
  472. return 0;
  473. }
  474. static struct platform_driver au1200_ide_driver = {
  475. .driver = {
  476. .name = "au1200-ide",
  477. .owner = THIS_MODULE,
  478. },
  479. .probe = au_ide_probe,
  480. .remove = au_ide_remove,
  481. };
  482. static int __init au_ide_init(void)
  483. {
  484. return platform_driver_register(&au1200_ide_driver);
  485. }
  486. static void __exit au_ide_exit(void)
  487. {
  488. platform_driver_unregister(&au1200_ide_driver);
  489. }
  490. MODULE_LICENSE("GPL");
  491. MODULE_DESCRIPTION("AU1200 IDE driver");
  492. module_init(au_ide_init);
  493. module_exit(au_ide_exit);