c496efda6fc5038e3c68c857586277a9bb4aab8f
[linux-flexiantxendom0-3.2.10.git] / drivers / ide / pci / pdcadma.c
1 /*
2  * linux/drivers/ide/pci/pdcadma.c              Version 0.05    Sept 10, 2002
3  *
4  * Copyright (C) 1999-2000              Andre Hedrick <andre@linux-ide.org>
5  * May be copied or modified under the terms of the GNU General Public License
6  *
7  */
8
9 #include <linux/config.h>
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/delay.h>
13 #include <linux/timer.h>
14 #include <linux/mm.h>
15 #include <linux/ioport.h>
16 #include <linux/blkdev.h>
17 #include <linux/hdreg.h>
18
19 #include <linux/interrupt.h>
20 #include <linux/init.h>
21 #include <linux/pci.h>
22 #include <linux/ide.h>
23
24 #include <asm/io.h>
25 #include <asm/irq.h>
26
27 #include "ide_modes.h"
28 #include "pdcadma.h"
29
30 #if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
31 #include <linux/stat.h>
32 #include <linux/proc_fs.h>
33
34 static u8 pdcadma_proc = 0;
35 #define PDC_MAX_DEVS            5
36 static struct pci_dev *pdc_devs[PDC_MAX_DEVS];
37 static int n_pdc_devs;
38
39 static int pdcadma_get_info (char *buffer, char **addr, off_t offset, int count)
40 {
41         char *p = buffer;
42         int i;
43
44         for (i = 0; i < n_pdc_devs; i++) {
45                 struct pci_dev *dev     = pdc_devs[i];
46                 unsigned long bibma = pci_resource_start(dev, 4);
47
48                 p += sprintf(p, "\n                                "
49                         "PDC ADMA %04X Chipset.\n", dev->device);
50                 p += sprintf(p, "UDMA\n");
51                 p += sprintf(p, "PIO\n");
52
53         }
54         return p-buffer;        /* => must be less than 4k! */
55 }
56 #endif  /* defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS) */
57
58 /*
59  * pdcadma_dma functions() initiates/aborts (U)DMA read/write
60  * operations on a drive.
61  */
62 #if 0
63         int (*ide_dma_read)(ide_drive_t *drive);
64         int (*ide_dma_write)(ide_drive_t *drive);
65         int (*ide_dma_begin)(ide_drive_t *drive);
66         int (*ide_dma_end)(ide_drive_t *drive);
67         int (*ide_dma_check)(ide_drive_t *drive);
68         int (*ide_dma_on)(ide_drive_t *drive);
69         int (*ide_dma_off)(ide_drive_t *drive);
70         int (*ide_dma_off_quietly)(ide_drive_t *drive);
71         int (*ide_dma_test_irq)(ide_drive_t *drive);
72         int (*ide_dma_host_on)(ide_drive_t *drive);
73         int (*ide_dma_host_off)(ide_drive_t *drive);
74         int (*ide_dma_bad_drive)(ide_drive_t *drive);
75         int (*ide_dma_good_drive)(ide_drive_t *drive);
76         int (*ide_dma_count)(ide_drive_t *drive);
77         int (*ide_dma_verbose)(ide_drive_t *drive);
78         int (*ide_dma_retune)(ide_drive_t *drive);
79         int (*ide_dma_lostirq)(ide_drive_t *drive);
80         int (*ide_dma_timeout)(ide_drive_t *drive);
81
82 #endif
83
84 static unsigned int __init init_chipset_pdcadma (struct pci_dev *dev, const char *name)
85 {
86 #if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
87         pdc_devs[n_pdc_devs++] = dev;
88
89         if (!pdcadma_proc) {
90                 pdcadma_proc = 1;
91                 ide_pci_register_host_proc(&pdcadma_procs[0]);
92         }
93 #endif /* DISPLAY_PDCADMA_TIMINGS && CONFIG_PROC_FS */
94         return 0;
95 }
96
97 static void __init init_hwif_pdcadma (ide_hwif_t *hwif)
98 {
99         hwif->autodma = 0;
100         hwif->dma_base = 0;
101
102 //      hwif->tuneproc = &pdcadma_tune_drive;
103 //      hwif->speedproc = &pdcadma_tune_chipset;
104
105 //      if (hwif->dma_base) {
106 //              hwif->autodma = 1;
107 //      }
108
109         hwif->udma_four = 1;
110
111 //      hwif->atapi_dma = 1;
112 //      hwif->ultra_mask = 0x7f;
113 //      hwif->mwdma_mask = 0x07;
114 //      hwif->swdma_mask = 0x07;
115
116 }
117
118 static void __init init_dma_pdcadma (ide_hwif_t *hwif, unsigned long dmabase)
119 {
120 #if 0
121         ide_setup_dma(hwif, dmabase, 8);
122 #endif
123 }
124
125 extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
126
127 static int __devinit pdcadma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
128 {
129         ide_pci_device_t *d = &pdcadma_chipsets[id->driver_data];
130         if (dev->device != d->device)
131                 BUG();
132         ide_setup_pci_device(dev, d);
133         MOD_INC_USE_COUNT;
134         return 1;
135 }
136
137 static struct pci_device_id pdcadma_pci_tbl[] __devinitdata = {
138         { PCI_VENDOR_ID_PDC, PCI_DEVICE_ID_PDC_1841, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
139         { 0, },
140 };
141
142 static struct pci_driver driver = {
143         .name           = "PDCADMA-IDE",
144         .id_table       = pdcadma_pci_tbl,
145         .probe          = pdcadma_init_one,
146 };
147
148 static int pdcadma_ide_init(void)
149 {
150         return ide_pci_register_driver(&driver);
151 }
152
153 static void pdcadma_ide_exit(void)
154 {
155         ide_pci_unregister_driver(&driver);
156 }
157
158 module_init(pdcadma_ide_init);
159 module_exit(pdcadma_ide_exit);
160
161 MODULE_AUTHOR("Andre Hedrick");
162 MODULE_DESCRIPTION("PCI driver module for PDCADMA IDE");
163 MODULE_LICENSE("GPL");