Loading...
1/*
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 <torben.mathiasen@hp.com>
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 publicly available.
26 */
27
28#include <linux/types.h>
29#include <linux/module.h>
30#include <linux/kernel.h>
31#include <linux/pci.h>
32#include <linux/ide.h>
33#include <linux/init.h>
34
35#define DRV_NAME "triflex"
36
37static void triflex_set_mode(ide_hwif_t *hwif, ide_drive_t *drive)
38{
39 struct pci_dev *dev = to_pci_dev(hwif->dev);
40 u32 triflex_timings = 0;
41 u16 timing = 0;
42 u8 channel_offset = hwif->channel ? 0x74 : 0x70, unit = drive->dn & 1;
43
44 pci_read_config_dword(dev, channel_offset, &triflex_timings);
45
46 switch (drive->dma_mode) {
47 case XFER_MW_DMA_2:
48 timing = 0x0103;
49 break;
50 case XFER_MW_DMA_1:
51 timing = 0x0203;
52 break;
53 case XFER_MW_DMA_0:
54 timing = 0x0808;
55 break;
56 case XFER_SW_DMA_2:
57 case XFER_SW_DMA_1:
58 case XFER_SW_DMA_0:
59 timing = 0x0f0f;
60 break;
61 case XFER_PIO_4:
62 timing = 0x0202;
63 break;
64 case XFER_PIO_3:
65 timing = 0x0204;
66 break;
67 case XFER_PIO_2:
68 timing = 0x0404;
69 break;
70 case XFER_PIO_1:
71 timing = 0x0508;
72 break;
73 case XFER_PIO_0:
74 timing = 0x0808;
75 break;
76 }
77
78 triflex_timings &= ~(0xFFFF << (16 * unit));
79 triflex_timings |= (timing << (16 * unit));
80
81 pci_write_config_dword(dev, channel_offset, triflex_timings);
82}
83
84static void triflex_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
85{
86 drive->dma_mode = drive->pio_mode;
87 triflex_set_mode(hwif, drive);
88}
89
90static const struct ide_port_ops triflex_port_ops = {
91 .set_pio_mode = triflex_set_pio_mode,
92 .set_dma_mode = triflex_set_mode,
93};
94
95static const struct ide_port_info triflex_device __devinitdata = {
96 .name = DRV_NAME,
97 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
98 .port_ops = &triflex_port_ops,
99 .pio_mask = ATA_PIO4,
100 .swdma_mask = ATA_SWDMA2,
101 .mwdma_mask = ATA_MWDMA2,
102};
103
104static int __devinit triflex_init_one(struct pci_dev *dev,
105 const struct pci_device_id *id)
106{
107 return ide_pci_init_one(dev, &triflex_device, NULL);
108}
109
110static const struct pci_device_id triflex_pci_tbl[] = {
111 { PCI_VDEVICE(COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE), 0 },
112 { 0, },
113};
114MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
115
116static struct pci_driver triflex_pci_driver = {
117 .name = "TRIFLEX_IDE",
118 .id_table = triflex_pci_tbl,
119 .probe = triflex_init_one,
120 .remove = ide_pci_remove,
121 .suspend = ide_pci_suspend,
122 .resume = ide_pci_resume,
123};
124
125static int __init triflex_ide_init(void)
126{
127 return ide_pci_register_driver(&triflex_pci_driver);
128}
129
130static void __exit triflex_ide_exit(void)
131{
132 pci_unregister_driver(&triflex_pci_driver);
133}
134
135module_init(triflex_ide_init);
136module_exit(triflex_ide_exit);
137
138MODULE_AUTHOR("Torben Mathiasen");
139MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE");
140MODULE_LICENSE("GPL");
141
142
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * IDE Chipset driver for the Compaq TriFlex IDE controller.
4 *
5 * Known to work with the Compaq Workstation 5x00 series.
6 *
7 * Copyright (C) 2002 Hewlett-Packard Development Group, L.P.
8 * Author: Torben Mathiasen <torben.mathiasen@hp.com>
9 *
10 * Loosely based on the piix & svwks drivers.
11 *
12 * Documentation:
13 * Not publicly available.
14 */
15
16#include <linux/types.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/pci.h>
20#include <linux/ide.h>
21#include <linux/init.h>
22
23#define DRV_NAME "triflex"
24
25static void triflex_set_mode(ide_hwif_t *hwif, ide_drive_t *drive)
26{
27 struct pci_dev *dev = to_pci_dev(hwif->dev);
28 u32 triflex_timings = 0;
29 u16 timing = 0;
30 u8 channel_offset = hwif->channel ? 0x74 : 0x70, unit = drive->dn & 1;
31
32 pci_read_config_dword(dev, channel_offset, &triflex_timings);
33
34 switch (drive->dma_mode) {
35 case XFER_MW_DMA_2:
36 timing = 0x0103;
37 break;
38 case XFER_MW_DMA_1:
39 timing = 0x0203;
40 break;
41 case XFER_MW_DMA_0:
42 timing = 0x0808;
43 break;
44 case XFER_SW_DMA_2:
45 case XFER_SW_DMA_1:
46 case XFER_SW_DMA_0:
47 timing = 0x0f0f;
48 break;
49 case XFER_PIO_4:
50 timing = 0x0202;
51 break;
52 case XFER_PIO_3:
53 timing = 0x0204;
54 break;
55 case XFER_PIO_2:
56 timing = 0x0404;
57 break;
58 case XFER_PIO_1:
59 timing = 0x0508;
60 break;
61 case XFER_PIO_0:
62 timing = 0x0808;
63 break;
64 }
65
66 triflex_timings &= ~(0xFFFF << (16 * unit));
67 triflex_timings |= (timing << (16 * unit));
68
69 pci_write_config_dword(dev, channel_offset, triflex_timings);
70}
71
72static void triflex_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
73{
74 drive->dma_mode = drive->pio_mode;
75 triflex_set_mode(hwif, drive);
76}
77
78static const struct ide_port_ops triflex_port_ops = {
79 .set_pio_mode = triflex_set_pio_mode,
80 .set_dma_mode = triflex_set_mode,
81};
82
83static const struct ide_port_info triflex_device = {
84 .name = DRV_NAME,
85 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
86 .port_ops = &triflex_port_ops,
87 .pio_mask = ATA_PIO4,
88 .swdma_mask = ATA_SWDMA2,
89 .mwdma_mask = ATA_MWDMA2,
90};
91
92static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
93{
94 return ide_pci_init_one(dev, &triflex_device, NULL);
95}
96
97static const struct pci_device_id triflex_pci_tbl[] = {
98 { PCI_VDEVICE(COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE), 0 },
99 { 0, },
100};
101MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
102
103#ifdef CONFIG_PM
104static int triflex_ide_pci_suspend(struct pci_dev *dev, pm_message_t state)
105{
106 /*
107 * We must not disable or powerdown the device.
108 * APM bios refuses to suspend if IDE is not accessible.
109 */
110 pci_save_state(dev);
111 return 0;
112}
113#else
114#define triflex_ide_pci_suspend NULL
115#endif
116
117static struct pci_driver triflex_pci_driver = {
118 .name = "TRIFLEX_IDE",
119 .id_table = triflex_pci_tbl,
120 .probe = triflex_init_one,
121 .remove = ide_pci_remove,
122 .suspend = triflex_ide_pci_suspend,
123 .resume = ide_pci_resume,
124};
125
126static int __init triflex_ide_init(void)
127{
128 return ide_pci_register_driver(&triflex_pci_driver);
129}
130
131static void __exit triflex_ide_exit(void)
132{
133 pci_unregister_driver(&triflex_pci_driver);
134}
135
136module_init(triflex_ide_init);
137module_exit(triflex_ide_exit);
138
139MODULE_AUTHOR("Torben Mathiasen");
140MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE");
141MODULE_LICENSE("GPL");
142
143