Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/ide/arm/rapide.c |
| 3 | * |
| 4 | * Copyright (c) 1996-2002 Russell King. |
| 5 | */ |
| 6 | |
| 7 | #include <linux/module.h> |
| 8 | #include <linux/slab.h> |
| 9 | #include <linux/blkdev.h> |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/ide.h> |
| 12 | #include <linux/init.h> |
| 13 | |
| 14 | #include <asm/ecard.h> |
| 15 | |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 16 | static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, |
| 17 | void __iomem *ctrl, unsigned int sz, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | { |
| 19 | unsigned long port = (unsigned long)base; |
Bartlomiej Zolnierkiewicz | baa8f3e | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 20 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 23 | hw->io_ports[i] = port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | port += sz; |
| 25 | } |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 26 | hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; |
| 27 | hw->irq = irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static int __devinit |
| 31 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) |
| 32 | { |
| 33 | ide_hwif_t *hwif; |
| 34 | void __iomem *base; |
| 35 | int ret; |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 36 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 37 | hw_regs_t 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 | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 49 | hwif = ide_find_port((unsigned long)base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | if (hwif) { |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 51 | memset(&hw, 0, sizeof(hw)); |
| 52 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); |
| 53 | hw.chipset = ide_generic; |
| 54 | hw.dev = &ec->dev; |
| 55 | |
| 56 | ide_init_port_hw(hwif, &hw); |
| 57 | |
| 58 | hwif->mmio = 1; |
| 59 | default_hwif_mmiops(hwif); |
| 60 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 61 | idx[0] = hwif->index; |
| 62 | |
| 63 | ide_device_add(idx); |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | ecard_set_drvdata(ec, hwif); |
| 66 | goto out; |
| 67 | } |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | release: |
| 70 | ecard_release_resources(ec); |
| 71 | out: |
| 72 | return ret; |
| 73 | } |
| 74 | |
| 75 | static void __devexit rapide_remove(struct expansion_card *ec) |
| 76 | { |
| 77 | ide_hwif_t *hwif = ecard_get_drvdata(ec); |
| 78 | |
| 79 | ecard_set_drvdata(ec, NULL); |
| 80 | |
Bartlomiej Zolnierkiewicz | fadd11c | 2008-02-01 23:09:33 +0100 | [diff] [blame^] | 81 | ide_unregister(hwif->index); |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | ecard_release_resources(ec); |
| 84 | } |
| 85 | |
| 86 | static struct ecard_id rapide_ids[] = { |
| 87 | { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 }, |
| 88 | { 0xffff, 0xffff } |
| 89 | }; |
| 90 | |
| 91 | static struct ecard_driver rapide_driver = { |
| 92 | .probe = rapide_probe, |
| 93 | .remove = __devexit_p(rapide_remove), |
| 94 | .id_table = rapide_ids, |
| 95 | .drv = { |
| 96 | .name = "rapide", |
| 97 | }, |
| 98 | }; |
| 99 | |
| 100 | static int __init rapide_init(void) |
| 101 | { |
| 102 | return ecard_register_driver(&rapide_driver); |
| 103 | } |
| 104 | |
| 105 | MODULE_LICENSE("GPL"); |
| 106 | MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); |
| 107 | |
| 108 | module_init(rapide_init); |