au1xxx-ide.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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/au1000.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. #ifndef IDE_REG_SHIFT
  44. #define IDE_REG_SHIFT 5
  45. #endif
  46. /* enable the burstmode in the dbdma */
  47. #define IDE_AU1XXX_BURSTMODE 1
  48. static _auide_hwif auide_hwif;
  49. #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
  50. static inline void auide_insw(unsigned long port, void *addr, u32 count)
  51. {
  52. _auide_hwif *ahwif = &auide_hwif;
  53. chan_tab_t *ctp;
  54. au1x_ddma_desc_t *dp;
  55. if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, virt_to_phys(addr),
  56. count << 1, DDMA_FLAGS_NOIE)) {
  57. printk(KERN_ERR "%s failed %d\n", __func__, __LINE__);
  58. return;
  59. }
  60. ctp = *((chan_tab_t **)ahwif->rx_chan);
  61. dp = ctp->cur_ptr;
  62. while (dp->dscr_cmd0 & DSCR_CMD0_V)
  63. ;
  64. ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
  65. }
  66. static inline void auide_outsw(unsigned long port, void *addr, u32 count)
  67. {
  68. _auide_hwif *ahwif = &auide_hwif;
  69. chan_tab_t *ctp;
  70. au1x_ddma_desc_t *dp;
  71. if (!au1xxx_dbdma_put_source(ahwif->tx_chan, virt_to_phys(addr),
  72. count << 1, DDMA_FLAGS_NOIE)) {
  73. printk(KERN_ERR "%s failed %d\n", __func__, __LINE__);
  74. return;
  75. }
  76. ctp = *((chan_tab_t **)ahwif->tx_chan);
  77. dp = ctp->cur_ptr;
  78. while (dp->dscr_cmd0 & DSCR_CMD0_V)
  79. ;
  80. ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
  81. }
  82. static void au1xxx_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
  83. void *buf, unsigned int len)
  84. {
  85. auide_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  86. }
  87. static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
  88. void *buf, unsigned int len)
  89. {
  90. auide_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  91. }
  92. #endif
  93. static void au1xxx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
  94. {
  95. int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
  96. switch (drive->pio_mode - XFER_PIO_0) {
  97. case 0:
  98. mem_sttime = SBC_IDE_TIMING(PIO0);
  99. /* set configuration for RCS2# */
  100. mem_stcfg |= TS_MASK;
  101. mem_stcfg &= ~TCSOE_MASK;
  102. mem_stcfg &= ~TOECS_MASK;
  103. mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS;
  104. break;
  105. case 1:
  106. mem_sttime = SBC_IDE_TIMING(PIO1);
  107. /* set configuration for RCS2# */
  108. mem_stcfg |= TS_MASK;
  109. mem_stcfg &= ~TCSOE_MASK;
  110. mem_stcfg &= ~TOECS_MASK;
  111. mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS;
  112. break;
  113. case 2:
  114. mem_sttime = SBC_IDE_TIMING(PIO2);
  115. /* set configuration for RCS2# */
  116. mem_stcfg &= ~TS_MASK;
  117. mem_stcfg &= ~TCSOE_MASK;
  118. mem_stcfg &= ~TOECS_MASK;
  119. mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS;
  120. break;
  121. case 3:
  122. mem_sttime = SBC_IDE_TIMING(PIO3);
  123. /* set configuration for RCS2# */
  124. mem_stcfg &= ~TS_MASK;
  125. mem_stcfg &= ~TCSOE_MASK;
  126. mem_stcfg &= ~TOECS_MASK;
  127. mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
  128. break;
  129. case 4:
  130. mem_sttime = SBC_IDE_TIMING(PIO4);
  131. /* set configuration for RCS2# */
  132. mem_stcfg &= ~TS_MASK;
  133. mem_stcfg &= ~TCSOE_MASK;
  134. mem_stcfg &= ~TOECS_MASK;
  135. mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
  136. break;
  137. }
  138. au_writel(mem_sttime,MEM_STTIME2);
  139. au_writel(mem_stcfg,MEM_STCFG2);
  140. }
  141. static void auide_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
  142. {
  143. int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
  144. switch (drive->dma_mode) {
  145. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  146. case XFER_MW_DMA_2:
  147. mem_sttime = SBC_IDE_TIMING(MDMA2);
  148. /* set configuration for RCS2# */
  149. mem_stcfg &= ~TS_MASK;
  150. mem_stcfg &= ~TCSOE_MASK;
  151. mem_stcfg &= ~TOECS_MASK;
  152. mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS;
  153. break;
  154. case XFER_MW_DMA_1:
  155. mem_sttime = SBC_IDE_TIMING(MDMA1);
  156. /* set configuration for RCS2# */
  157. mem_stcfg &= ~TS_MASK;
  158. mem_stcfg &= ~TCSOE_MASK;
  159. mem_stcfg &= ~TOECS_MASK;
  160. mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS;
  161. break;
  162. case XFER_MW_DMA_0:
  163. mem_sttime = SBC_IDE_TIMING(MDMA0);
  164. /* set configuration for RCS2# */
  165. mem_stcfg |= TS_MASK;
  166. mem_stcfg &= ~TCSOE_MASK;
  167. mem_stcfg &= ~TOECS_MASK;
  168. mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
  169. break;
  170. #endif
  171. }
  172. au_writel(mem_sttime,MEM_STTIME2);
  173. au_writel(mem_stcfg,MEM_STCFG2);
  174. }
  175. /*
  176. * Multi-Word DMA + DbDMA functions
  177. */
  178. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  179. static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
  180. {
  181. ide_hwif_t *hwif = drive->hwif;
  182. _auide_hwif *ahwif = &auide_hwif;
  183. struct scatterlist *sg;
  184. int i = cmd->sg_nents, count = 0;
  185. int iswrite = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
  186. /* Save for interrupt context */
  187. ahwif->drive = drive;
  188. /* fill the descriptors */
  189. sg = hwif->sg_table;
  190. while (i && sg_dma_len(sg)) {
  191. u32 cur_addr;
  192. u32 cur_len;
  193. cur_addr = sg_dma_address(sg);
  194. cur_len = sg_dma_len(sg);
  195. while (cur_len) {
  196. u32 flags = DDMA_FLAGS_NOIE;
  197. unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
  198. if (++count >= PRD_ENTRIES) {
  199. printk(KERN_WARNING "%s: DMA table too small\n",
  200. drive->name);
  201. return 0;
  202. }
  203. /* Lets enable intr for the last descriptor only */
  204. if (1==i)
  205. flags = DDMA_FLAGS_IE;
  206. else
  207. flags = DDMA_FLAGS_NOIE;
  208. if (iswrite) {
  209. if (!au1xxx_dbdma_put_source(ahwif->tx_chan,
  210. sg_phys(sg), tc, flags)) {
  211. printk(KERN_ERR "%s failed %d\n",
  212. __func__, __LINE__);
  213. }
  214. } else {
  215. if (!au1xxx_dbdma_put_dest(ahwif->rx_chan,
  216. sg_phys(sg), tc, flags)) {
  217. printk(KERN_ERR "%s failed %d\n",
  218. __func__, __LINE__);
  219. }
  220. }
  221. cur_addr += tc;
  222. cur_len -= tc;
  223. }
  224. sg = sg_next(sg);
  225. i--;
  226. }
  227. if (count)
  228. return 1;
  229. return 0; /* revert to PIO for this request */
  230. }
  231. static int auide_dma_end(ide_drive_t *drive)
  232. {
  233. return 0;
  234. }
  235. static void auide_dma_start(ide_drive_t *drive )
  236. {
  237. }
  238. static int auide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
  239. {
  240. if (auide_build_dmatable(drive, cmd) == 0)
  241. return 1;
  242. return 0;
  243. }
  244. static int auide_dma_test_irq(ide_drive_t *drive)
  245. {
  246. /* If dbdma didn't execute the STOP command yet, the
  247. * active bit is still set
  248. */
  249. drive->waiting_for_dma++;
  250. if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
  251. printk(KERN_WARNING "%s: timeout waiting for ddma to complete\n",
  252. drive->name);
  253. return 1;
  254. }
  255. udelay(10);
  256. return 0;
  257. }
  258. static void auide_dma_host_set(ide_drive_t *drive, int on)
  259. {
  260. }
  261. static void auide_ddma_tx_callback(int irq, void *param)
  262. {
  263. }
  264. static void auide_ddma_rx_callback(int irq, void *param)
  265. {
  266. }
  267. #endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
  268. static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize,
  269. u32 devwidth, u32 flags, u32 regbase)
  270. {
  271. dev->dev_id = dev_id;
  272. dev->dev_physaddr = CPHYSADDR(regbase);
  273. dev->dev_intlevel = 0;
  274. dev->dev_intpolarity = 0;
  275. dev->dev_tsize = tsize;
  276. dev->dev_devwidth = devwidth;
  277. dev->dev_flags = flags;
  278. }
  279. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  280. static const struct ide_dma_ops au1xxx_dma_ops = {
  281. .dma_host_set = auide_dma_host_set,
  282. .dma_setup = auide_dma_setup,
  283. .dma_start = auide_dma_start,
  284. .dma_end = auide_dma_end,
  285. .dma_test_irq = auide_dma_test_irq,
  286. .dma_lost_irq = ide_dma_lost_irq,
  287. };
  288. static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  289. {
  290. _auide_hwif *auide = &auide_hwif;
  291. dbdev_tab_t source_dev_tab, target_dev_tab;
  292. u32 dev_id, tsize, devwidth, flags;
  293. dev_id = hwif->ddma_id;
  294. tsize = 8; /* 1 */
  295. devwidth = 32; /* 16 */
  296. #ifdef IDE_AU1XXX_BURSTMODE
  297. flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
  298. #else
  299. flags = DEV_FLAGS_SYNC;
  300. #endif
  301. /* setup dev_tab for tx channel */
  302. auide_init_dbdma_dev(&source_dev_tab, dev_id, tsize, devwidth,
  303. DEV_FLAGS_OUT | flags, auide->regbase);
  304. auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  305. auide_init_dbdma_dev(&source_dev_tab, dev_id, tsize, devwidth,
  306. DEV_FLAGS_IN | flags, auide->regbase);
  307. auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  308. /* We also need to add a target device for the DMA */
  309. auide_init_dbdma_dev(&target_dev_tab, (u32)DSCR_CMD0_ALWAYS, tsize,
  310. devwidth, DEV_FLAGS_ANYUSE, auide->regbase);
  311. auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab);
  312. /* Get a channel for TX */
  313. auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
  314. auide->tx_dev_id,
  315. auide_ddma_tx_callback,
  316. (void*)auide);
  317. /* Get a channel for RX */
  318. auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
  319. auide->target_dev_id,
  320. auide_ddma_rx_callback,
  321. (void*)auide);
  322. auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
  323. NUM_DESCRIPTORS);
  324. auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
  325. NUM_DESCRIPTORS);
  326. /* FIXME: check return value */
  327. (void)ide_allocate_dma_engine(hwif);
  328. au1xxx_dbdma_start( auide->tx_chan );
  329. au1xxx_dbdma_start( auide->rx_chan );
  330. return 0;
  331. }
  332. #else
  333. static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  334. {
  335. _auide_hwif *auide = &auide_hwif;
  336. dbdev_tab_t source_dev_tab;
  337. int flags;
  338. #ifdef IDE_AU1XXX_BURSTMODE
  339. flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
  340. #else
  341. flags = DEV_FLAGS_SYNC;
  342. #endif
  343. /* setup dev_tab for tx channel */
  344. auide_init_dbdma_dev(&source_dev_tab, (u32)DSCR_CMD0_ALWAYS, 8, 32,
  345. DEV_FLAGS_OUT | flags, auide->regbase);
  346. auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  347. auide_init_dbdma_dev(&source_dev_tab, (u32)DSCR_CMD0_ALWAYS, 8, 32,
  348. DEV_FLAGS_IN | flags, auide->regbase);
  349. auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
  350. /* Get a channel for TX */
  351. auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
  352. auide->tx_dev_id,
  353. NULL,
  354. (void*)auide);
  355. /* Get a channel for RX */
  356. auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
  357. DSCR_CMD0_ALWAYS,
  358. NULL,
  359. (void*)auide);
  360. auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
  361. NUM_DESCRIPTORS);
  362. auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
  363. NUM_DESCRIPTORS);
  364. au1xxx_dbdma_start( auide->tx_chan );
  365. au1xxx_dbdma_start( auide->rx_chan );
  366. return 0;
  367. }
  368. #endif
  369. static void auide_setup_ports(struct ide_hw *hw, _auide_hwif *ahwif)
  370. {
  371. int i;
  372. unsigned long *ata_regs = hw->io_ports_array;
  373. /* FIXME? */
  374. for (i = 0; i < 8; i++)
  375. *ata_regs++ = ahwif->regbase + (i << IDE_REG_SHIFT);
  376. /* set the Alternative Status register */
  377. *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT);
  378. }
  379. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
  380. static const struct ide_tp_ops au1xxx_tp_ops = {
  381. .exec_command = ide_exec_command,
  382. .read_status = ide_read_status,
  383. .read_altstatus = ide_read_altstatus,
  384. .write_devctl = ide_write_devctl,
  385. .dev_select = ide_dev_select,
  386. .tf_load = ide_tf_load,
  387. .tf_read = ide_tf_read,
  388. .input_data = au1xxx_input_data,
  389. .output_data = au1xxx_output_data,
  390. };
  391. #endif
  392. static const struct ide_port_ops au1xxx_port_ops = {
  393. .set_pio_mode = au1xxx_set_pio_mode,
  394. .set_dma_mode = auide_set_dma_mode,
  395. };
  396. static const struct ide_port_info au1xxx_port_info = {
  397. .init_dma = auide_ddma_init,
  398. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
  399. .tp_ops = &au1xxx_tp_ops,
  400. #endif
  401. .port_ops = &au1xxx_port_ops,
  402. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  403. .dma_ops = &au1xxx_dma_ops,
  404. #endif
  405. .host_flags = IDE_HFLAG_POST_SET_MODE |
  406. IDE_HFLAG_NO_IO_32BIT |
  407. IDE_HFLAG_UNMASK_IRQS,
  408. .pio_mask = ATA_PIO4,
  409. #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
  410. .mwdma_mask = ATA_MWDMA2,
  411. #endif
  412. .chipset = ide_au1xxx,
  413. };
  414. static int au_ide_probe(struct platform_device *dev)
  415. {
  416. _auide_hwif *ahwif = &auide_hwif;
  417. struct resource *res;
  418. struct ide_host *host;
  419. int ret = 0;
  420. struct ide_hw hw, *hws[] = { &hw };
  421. #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
  422. char *mode = "MWDMA2";
  423. #elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
  424. char *mode = "PIO+DDMA(offload)";
  425. #endif
  426. memset(&auide_hwif, 0, sizeof(_auide_hwif));
  427. ahwif->irq = platform_get_irq(dev, 0);
  428. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  429. if (res == NULL) {
  430. pr_debug("%s %d: no base address\n", DRV_NAME, dev->id);
  431. ret = -ENODEV;
  432. goto out;
  433. }
  434. if (ahwif->irq < 0) {
  435. pr_debug("%s %d: no IRQ\n", DRV_NAME, dev->id);
  436. ret = -ENODEV;
  437. goto out;
  438. }
  439. if (!request_mem_region(res->start, resource_size(res), dev->name)) {
  440. pr_debug("%s: request_mem_region failed\n", DRV_NAME);
  441. ret = -EBUSY;
  442. goto out;
  443. }
  444. ahwif->regbase = (u32)ioremap(res->start, resource_size(res));
  445. if (ahwif->regbase == 0) {
  446. ret = -ENOMEM;
  447. goto out;
  448. }
  449. res = platform_get_resource(dev, IORESOURCE_DMA, 0);
  450. if (!res) {
  451. pr_debug("%s: no DDMA ID resource\n", DRV_NAME);
  452. ret = -ENODEV;
  453. goto out;
  454. }
  455. ahwif->ddma_id = res->start;
  456. memset(&hw, 0, sizeof(hw));
  457. auide_setup_ports(&hw, ahwif);
  458. hw.irq = ahwif->irq;
  459. hw.dev = &dev->dev;
  460. ret = ide_host_add(&au1xxx_port_info, hws, 1, &host);
  461. if (ret)
  462. goto out;
  463. auide_hwif.hwif = host->ports[0];
  464. platform_set_drvdata(dev, host);
  465. printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
  466. out:
  467. return ret;
  468. }
  469. static int au_ide_remove(struct platform_device *dev)
  470. {
  471. struct resource *res;
  472. struct ide_host *host = platform_get_drvdata(dev);
  473. _auide_hwif *ahwif = &auide_hwif;
  474. ide_host_remove(host);
  475. iounmap((void *)ahwif->regbase);
  476. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  477. release_mem_region(res->start, resource_size(res));
  478. return 0;
  479. }
  480. static struct platform_driver au1200_ide_driver = {
  481. .driver = {
  482. .name = "au1200-ide",
  483. },
  484. .probe = au_ide_probe,
  485. .remove = au_ide_remove,
  486. };
  487. module_platform_driver(au1200_ide_driver);
  488. MODULE_LICENSE("GPL");
  489. MODULE_DESCRIPTION("AU1200 IDE driver");