Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (c) 1996-2002 Russell King. |
| 3 | */ |
| 4 | |
| 5 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <linux/blkdev.h> |
| 7 | #include <linux/errno.h> |
| 8 | #include <linux/ide.h> |
| 9 | #include <linux/init.h> |
| 10 | |
| 11 | #include <asm/ecard.h> |
| 12 | |
Al Viro | 1137fb6 | 2008-10-26 05:40:26 +0000 | [diff] [blame] | 13 | static const struct ide_port_info rapide_port_info = { |
Bartlomiej Zolnierkiewicz | 9a5ae1f | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 14 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, |
Bartlomiej Zolnierkiewicz | 29e52cf | 2009-05-17 19:12:22 +0200 | [diff] [blame] | 15 | .chipset = ide_generic, |
Bartlomiej Zolnierkiewicz | 9a5ae1f | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 16 | }; |
| 17 | |
Bartlomiej Zolnierkiewicz | 9f36d31 | 2009-05-17 19:12:25 +0200 | [diff] [blame] | 18 | static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base, |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 19 | void __iomem *ctrl, unsigned int sz, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | { |
| 21 | unsigned long port = (unsigned long)base; |
Bartlomiej Zolnierkiewicz | baa8f3e | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 22 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Bartlomiej Zolnierkiewicz | 4c3032d | 2008-04-27 15:38:32 +0200 | [diff] [blame] | 24 | for (i = 0; i <= 7; i++) { |
| 25 | hw->io_ports_array[i] = port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | port += sz; |
| 27 | } |
Bartlomiej Zolnierkiewicz | 4c3032d | 2008-04-27 15:38:32 +0200 | [diff] [blame] | 28 | hw->io_ports.ctl_addr = (unsigned long)ctrl; |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 29 | hw->irq = irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Greg Kroah-Hartman | fe31edc | 2012-12-21 13:21:03 -0800 | [diff] [blame] | 32 | static int rapide_probe(struct expansion_card *ec, const struct ecard_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | void __iomem *base; |
Bartlomiej Zolnierkiewicz | 48c3c10 | 2008-07-23 19:55:57 +0200 | [diff] [blame] | 35 | struct ide_host *host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | int ret; |
Bartlomiej Zolnierkiewicz | 9f36d31 | 2009-05-17 19:12:25 +0200 | [diff] [blame] | 37 | struct ide_hw hw, *hws[] = { &hw }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | ret = ecard_request_resources(ec); |
| 40 | if (ret) |
| 41 | goto out; |
| 42 | |
Russell King | 10bdaaa | 2007-05-10 18:40:51 +0100 | [diff] [blame] | 43 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | if (!base) { |
| 45 | ret = -ENOMEM; |
| 46 | goto release; |
| 47 | } |
| 48 | |
Bartlomiej Zolnierkiewicz | 47bc7e7 | 2008-07-16 20:33:44 +0200 | [diff] [blame] | 49 | memset(&hw, 0, sizeof(hw)); |
| 50 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); |
Bartlomiej Zolnierkiewicz | 47bc7e7 | 2008-07-16 20:33:44 +0200 | [diff] [blame] | 51 | hw.dev = &ec->dev; |
| 52 | |
Bartlomiej Zolnierkiewicz | dca3983 | 2009-05-17 19:12:24 +0200 | [diff] [blame] | 53 | ret = ide_host_add(&rapide_port_info, hws, 1, &host); |
Bartlomiej Zolnierkiewicz | 6f904d0 | 2008-07-23 19:55:57 +0200 | [diff] [blame] | 54 | if (ret) |
Bartlomiej Zolnierkiewicz | 47bc7e7 | 2008-07-16 20:33:44 +0200 | [diff] [blame] | 55 | goto release; |
Bartlomiej Zolnierkiewicz | 47bc7e7 | 2008-07-16 20:33:44 +0200 | [diff] [blame] | 56 | |
Bartlomiej Zolnierkiewicz | 48c3c10 | 2008-07-23 19:55:57 +0200 | [diff] [blame] | 57 | ecard_set_drvdata(ec, host); |
Bartlomiej Zolnierkiewicz | 47bc7e7 | 2008-07-16 20:33:44 +0200 | [diff] [blame] | 58 | goto out; |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | release: |
| 61 | ecard_release_resources(ec); |
| 62 | out: |
| 63 | return ret; |
| 64 | } |
| 65 | |
Greg Kroah-Hartman | fe31edc | 2012-12-21 13:21:03 -0800 | [diff] [blame] | 66 | static void rapide_remove(struct expansion_card *ec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
Bartlomiej Zolnierkiewicz | 48c3c10 | 2008-07-23 19:55:57 +0200 | [diff] [blame] | 68 | struct ide_host *host = ecard_get_drvdata(ec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | ecard_set_drvdata(ec, NULL); |
| 71 | |
Bartlomiej Zolnierkiewicz | 48c3c10 | 2008-07-23 19:55:57 +0200 | [diff] [blame] | 72 | ide_host_remove(host); |
Bartlomiej Zolnierkiewicz | fadd11c | 2008-02-01 23:09:33 +0100 | [diff] [blame] | 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | ecard_release_resources(ec); |
| 75 | } |
| 76 | |
| 77 | static struct ecard_id rapide_ids[] = { |
| 78 | { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 }, |
| 79 | { 0xffff, 0xffff } |
| 80 | }; |
| 81 | |
| 82 | static struct ecard_driver rapide_driver = { |
| 83 | .probe = rapide_probe, |
Greg Kroah-Hartman | fe31edc | 2012-12-21 13:21:03 -0800 | [diff] [blame] | 84 | .remove = rapide_remove, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | .id_table = rapide_ids, |
| 86 | .drv = { |
| 87 | .name = "rapide", |
| 88 | }, |
| 89 | }; |
| 90 | |
| 91 | static int __init rapide_init(void) |
| 92 | { |
| 93 | return ecard_register_driver(&rapide_driver); |
| 94 | } |
| 95 | |
Bartlomiej Zolnierkiewicz | 37c5ef5 | 2008-07-24 22:53:27 +0200 | [diff] [blame] | 96 | static void __exit rapide_exit(void) |
| 97 | { |
Al Viro | 1137fb6 | 2008-10-26 05:40:26 +0000 | [diff] [blame] | 98 | ecard_remove_driver(&rapide_driver); |
Bartlomiej Zolnierkiewicz | 37c5ef5 | 2008-07-24 22:53:27 +0200 | [diff] [blame] | 99 | } |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | MODULE_LICENSE("GPL"); |
| 102 | MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); |
| 103 | |
| 104 | module_init(rapide_init); |
Bartlomiej Zolnierkiewicz | 37c5ef5 | 2008-07-24 22:53:27 +0200 | [diff] [blame] | 105 | module_exit(rapide_exit); |