]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * IDE Chipset driver for the Compaq TriFlex IDE controller. |
3 | * | |
4 | * Known to work with the Compaq Workstation 5x00 series. | |
5 | * | |
6 | * Copyright (C) 2002 Hewlett-Packard Development Group, L.P. | |
7 | * Author: Torben Mathiasen <[email protected]> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | * | |
22 | * Loosely based on the piix & svwks drivers. | |
23 | * | |
24 | * Documentation: | |
25 | * Not publically available. | |
26 | */ | |
27 | ||
1da177e4 LT |
28 | #include <linux/types.h> |
29 | #include <linux/module.h> | |
30 | #include <linux/kernel.h> | |
1da177e4 LT |
31 | #include <linux/hdreg.h> |
32 | #include <linux/pci.h> | |
33 | #include <linux/ide.h> | |
34 | #include <linux/init.h> | |
35 | ||
ced3ec8a BZ |
36 | #define DRV_NAME "triflex" |
37 | ||
88b2b32b | 38 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) |
1da177e4 LT |
39 | { |
40 | ide_hwif_t *hwif = HWIF(drive); | |
36501650 | 41 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1da177e4 LT |
42 | u8 channel_offset = hwif->channel ? 0x74 : 0x70; |
43 | u16 timing = 0; | |
44 | u32 triflex_timings = 0; | |
45 | u8 unit = (drive->select.b.unit & 0x01); | |
1da177e4 LT |
46 | |
47 | pci_read_config_dword(dev, channel_offset, &triflex_timings); | |
48 | ||
49 | switch(speed) { | |
50 | case XFER_MW_DMA_2: | |
51 | timing = 0x0103; | |
52 | break; | |
53 | case XFER_MW_DMA_1: | |
54 | timing = 0x0203; | |
55 | break; | |
56 | case XFER_MW_DMA_0: | |
57 | timing = 0x0808; | |
58 | break; | |
59 | case XFER_SW_DMA_2: | |
60 | case XFER_SW_DMA_1: | |
61 | case XFER_SW_DMA_0: | |
62 | timing = 0x0f0f; | |
63 | break; | |
64 | case XFER_PIO_4: | |
65 | timing = 0x0202; | |
66 | break; | |
67 | case XFER_PIO_3: | |
68 | timing = 0x0204; | |
69 | break; | |
70 | case XFER_PIO_2: | |
71 | timing = 0x0404; | |
72 | break; | |
73 | case XFER_PIO_1: | |
74 | timing = 0x0508; | |
75 | break; | |
76 | case XFER_PIO_0: | |
77 | timing = 0x0808; | |
78 | break; | |
1da177e4 LT |
79 | } |
80 | ||
81 | triflex_timings &= ~(0xFFFF << (16 * unit)); | |
82 | triflex_timings |= (timing << (16 * unit)); | |
83 | ||
84 | pci_write_config_dword(dev, channel_offset, triflex_timings); | |
1da177e4 LT |
85 | } |
86 | ||
26bcb879 | 87 | static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) |
1da177e4 | 88 | { |
88b2b32b | 89 | triflex_set_mode(drive, XFER_PIO_0 + pio); |
1da177e4 LT |
90 | } |
91 | ||
ac95beed BZ |
92 | static const struct ide_port_ops triflex_port_ops = { |
93 | .set_pio_mode = triflex_set_pio_mode, | |
94 | .set_dma_mode = triflex_set_mode, | |
95 | }; | |
1da177e4 | 96 | |
85620436 | 97 | static const struct ide_port_info triflex_device __devinitdata = { |
ced3ec8a | 98 | .name = DRV_NAME, |
1da177e4 | 99 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, |
ac95beed | 100 | .port_ops = &triflex_port_ops, |
4099d143 | 101 | .pio_mask = ATA_PIO4, |
5f8b6c34 BZ |
102 | .swdma_mask = ATA_SWDMA2, |
103 | .mwdma_mask = ATA_MWDMA2, | |
1da177e4 LT |
104 | }; |
105 | ||
106 | static int __devinit triflex_init_one(struct pci_dev *dev, | |
107 | const struct pci_device_id *id) | |
108 | { | |
6cdf6eb3 | 109 | return ide_pci_init_one(dev, &triflex_device, NULL); |
1da177e4 LT |
110 | } |
111 | ||
9cbcc5e3 BZ |
112 | static const struct pci_device_id triflex_pci_tbl[] = { |
113 | { PCI_VDEVICE(COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE), 0 }, | |
1da177e4 LT |
114 | { 0, }, |
115 | }; | |
116 | MODULE_DEVICE_TABLE(pci, triflex_pci_tbl); | |
117 | ||
118 | static struct pci_driver driver = { | |
119 | .name = "TRIFLEX_IDE", | |
120 | .id_table = triflex_pci_tbl, | |
121 | .probe = triflex_init_one, | |
29d72f2d | 122 | .remove = ide_pci_remove, |
1da177e4 LT |
123 | }; |
124 | ||
82ab1eec | 125 | static int __init triflex_ide_init(void) |
1da177e4 LT |
126 | { |
127 | return ide_pci_register_driver(&driver); | |
128 | } | |
129 | ||
29d72f2d BZ |
130 | static void __exit triflex_ide_exit(void) |
131 | { | |
132 | pci_unregister_driver(&driver); | |
133 | } | |
134 | ||
1da177e4 | 135 | module_init(triflex_ide_init); |
29d72f2d | 136 | module_exit(triflex_ide_exit); |
1da177e4 LT |
137 | |
138 | MODULE_AUTHOR("Torben Mathiasen"); | |
139 | MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE"); | |
140 | MODULE_LICENSE("GPL"); | |
141 | ||
142 |