ide: delete filenames/versions from comments
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / ide / pci / delkin_cb.c
CommitLineData
78281c53 1/*
78281c53
ML
2 * Created 20 Oct 2004 by Mark Lord
3 *
4 * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
5 *
6 * Modeled after the 16-bit PCMCIA driver: ide-cs.c
7 *
8 * This is slightly peculiar, in that it is a PCI driver,
9 * but is NOT an IDE PCI driver -- the IDE layer does not directly
10 * support hot insertion/removal of PCI interfaces, so this driver
11 * is unable to use the IDE PCI interfaces. Instead, it uses the
12 * same interfaces as the ide-cs (PCMCIA) driver uses.
13 * On the plus side, the driver is also smaller/simpler this way.
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file COPYING in the main directory of this archive for
17 * more details.
18 */
19#include <linux/autoconf.h>
20#include <linux/types.h>
21#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/blkdev.h>
24#include <linux/hdreg.h>
25#include <linux/ide.h>
26#include <linux/init.h>
27#include <linux/pci.h>
28#include <asm/io.h>
29
30/*
31 * No chip documentation has yet been found,
32 * so these configuration values were pulled from
33 * a running Win98 system using "debug".
34 * This gives around 3MByte/second read performance,
35 * which is about 2/3 of what the chip is capable of.
36 *
37 * There is also a 4KByte mmio region on the card,
38 * but its purpose has yet to be reverse-engineered.
39 */
40static const u8 setup[] = {
41 0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
42 0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
45};
46
47static int __devinit
48delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
49{
50 unsigned long base;
51 hw_regs_t hw;
52 ide_hwif_t *hwif = NULL;
53 ide_drive_t *drive;
54 int i, rc;
55
56 rc = pci_enable_device(dev);
57 if (rc) {
58 printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
59 return rc;
60 }
61 rc = pci_request_regions(dev, "delkin_cb");
62 if (rc) {
63 printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
64 pci_disable_device(dev);
65 return rc;
66 }
67 base = pci_resource_start(dev, 0);
68 outb(0x02, base + 0x1e); /* set nIEN to block interrupts */
69 inb(base + 0x17); /* read status to clear interrupts */
70 for (i = 0; i < sizeof(setup); ++i) {
71 if (setup[i])
72 outb(setup[i], base + i);
73 }
74 pci_release_regions(dev); /* IDE layer handles regions itself */
75
76 memset(&hw, 0, sizeof(hw));
77 ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
78 hw.irq = dev->irq;
79 hw.chipset = ide_pci; /* this enables IRQ sharing */
80
cbb010c1 81 rc = ide_register_hw(&hw, &ide_undecoded_slave, &hwif);
78281c53
ML
82 if (rc < 0) {
83 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
84 pci_disable_device(dev);
85 return -ENODEV;
86 }
87 pci_set_drvdata(dev, hwif);
36501650 88 hwif->dev = &dev->dev;
78281c53
ML
89 drive = &hwif->drives[0];
90 if (drive->present) {
91 drive->io_32bit = 1;
92 drive->unmask = 1;
93 }
94 return 0;
95}
96
97static void
98delkin_cb_remove (struct pci_dev *dev)
99{
100 ide_hwif_t *hwif = pci_get_drvdata(dev);
101
102 if (hwif)
103 ide_unregister(hwif->index);
104 pci_disable_device(dev);
105}
106
107static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
108 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2571b16d 109 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
78281c53
ML
110 { 0, },
111};
112MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
113
114static struct pci_driver driver = {
115 .name = "Delkin-ASKA-Workbit Cardbus IDE",
116 .id_table = delkin_cb_pci_tbl,
117 .probe = delkin_cb_probe,
118 .remove = delkin_cb_remove,
119};
120
121static int
122delkin_cb_init (void)
123{
e76ecf86 124 return pci_register_driver(&driver);
78281c53
ML
125}
126
127static void
128delkin_cb_exit (void)
129{
130 pci_unregister_driver(&driver);
131}
132
133module_init(delkin_cb_init);
134module_exit(delkin_cb_exit);
135
136MODULE_AUTHOR("Mark Lord");
137MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
138MODULE_LICENSE("GPL");
139