1 // SPDX-License-Identifier: GPL-2.0-only
3 * IDE Chipset driver for the Compaq TriFlex IDE controller.
5 * Known to work with the Compaq Workstation 5x00 series.
7 * Copyright (C) 2002 Hewlett-Packard Development Group, L.P.
8 * Author: Torben Mathiasen <torben.mathiasen@hp.com>
10 * Loosely based on the piix & svwks drivers.
13 * Not publicly available.
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>
23 #define DRV_NAME "triflex"
25 static void triflex_set_mode(ide_hwif_t
*hwif
, ide_drive_t
*drive
)
27 struct pci_dev
*dev
= to_pci_dev(hwif
->dev
);
28 u32 triflex_timings
= 0;
30 u8 channel_offset
= hwif
->channel
? 0x74 : 0x70, unit
= drive
->dn
& 1;
32 pci_read_config_dword(dev
, channel_offset
, &triflex_timings
);
34 switch (drive
->dma_mode
) {
66 triflex_timings
&= ~(0xFFFF << (16 * unit
));
67 triflex_timings
|= (timing
<< (16 * unit
));
69 pci_write_config_dword(dev
, channel_offset
, triflex_timings
);
72 static void triflex_set_pio_mode(ide_hwif_t
*hwif
, ide_drive_t
*drive
)
74 drive
->dma_mode
= drive
->pio_mode
;
75 triflex_set_mode(hwif
, drive
);
78 static const struct ide_port_ops triflex_port_ops
= {
79 .set_pio_mode
= triflex_set_pio_mode
,
80 .set_dma_mode
= triflex_set_mode
,
83 static const struct ide_port_info triflex_device
= {
85 .enablebits
= {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
86 .port_ops
= &triflex_port_ops
,
88 .swdma_mask
= ATA_SWDMA2
,
89 .mwdma_mask
= ATA_MWDMA2
,
92 static int triflex_init_one(struct pci_dev
*dev
, const struct pci_device_id
*id
)
94 return ide_pci_init_one(dev
, &triflex_device
, NULL
);
97 static const struct pci_device_id triflex_pci_tbl
[] = {
98 { PCI_VDEVICE(COMPAQ
, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE
), 0 },
101 MODULE_DEVICE_TABLE(pci
, triflex_pci_tbl
);
104 static int triflex_ide_pci_suspend(struct pci_dev
*dev
, pm_message_t state
)
107 * We must not disable or powerdown the device.
108 * APM bios refuses to suspend if IDE is not accessible.
114 #define triflex_ide_pci_suspend NULL
117 static 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
,
126 static int __init
triflex_ide_init(void)
128 return ide_pci_register_driver(&triflex_pci_driver
);
131 static void __exit
triflex_ide_exit(void)
133 pci_unregister_driver(&triflex_pci_driver
);
136 module_init(triflex_ide_init
);
137 module_exit(triflex_ide_exit
);
139 MODULE_AUTHOR("Torben Mathiasen");
140 MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE");
141 MODULE_LICENSE("GPL");