17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/pci.h>
28 #define DRV_NAME "pata_hpt366"
29 #define DRV_VERSION "0.6.11"
57 static const struct hpt_clock hpt366_40[] = {
76 static const struct hpt_clock hpt366_33[] = {
95 static const struct hpt_clock hpt366_25[] = {
123 static u32 hpt36x_find_mode(
struct ata_port *ap,
int speed)
136 static const char *
const bad_ata33[] = {
137 "Maxtor 92720U8",
"Maxtor 92040U6",
"Maxtor 91360U4",
"Maxtor 91020U3",
138 "Maxtor 90845U3",
"Maxtor 90650U2",
139 "Maxtor 91360D8",
"Maxtor 91190D7",
"Maxtor 91020D6",
"Maxtor 90845D5",
140 "Maxtor 90680D4",
"Maxtor 90510D3",
"Maxtor 90340D2",
141 "Maxtor 91152D8",
"Maxtor 91008D7",
"Maxtor 90845D6",
"Maxtor 90840D6",
142 "Maxtor 90720D5",
"Maxtor 90648D5",
"Maxtor 90576D4",
144 "Maxtor 90432D3",
"Maxtor 90288D2",
"Maxtor 90256D2",
145 "Maxtor 91000D8",
"Maxtor 90910D8",
"Maxtor 90875D7",
"Maxtor 90840D7",
146 "Maxtor 90750D6",
"Maxtor 90625D5",
"Maxtor 90500D4",
147 "Maxtor 91728D8",
"Maxtor 91512D7",
"Maxtor 91303D6",
"Maxtor 91080D5",
148 "Maxtor 90845D4",
"Maxtor 90680D4",
"Maxtor 90648D3",
"Maxtor 90432D2",
152 static const char *
const bad_ata66_4[] = {
171 static const char *
const bad_ata66_3[] = {
176 static int hpt_dma_blacklisted(
const struct ata_device *
dev,
char *modestr,
177 const char *
const list[])
184 while (list[i] !=
NULL) {
185 if (!
strcmp(list[i], model_num)) {
186 pr_warn(
"%s is not supported for %s\n",
202 static unsigned long hpt366_filter(
struct ata_device *adev,
unsigned long mask)
205 if (hpt_dma_blacklisted(adev,
"UDMA", bad_ata33))
207 if (hpt_dma_blacklisted(adev,
"UDMA3", bad_ata66_3))
209 if (hpt_dma_blacklisted(adev,
"UDMA4", bad_ata66_4))
217 static int hpt36x_cable_detect(
struct ata_port *ap)
226 pci_read_config_byte(pdev, 0x5A, &ata66);
247 t = hpt36x_find_mode(ap, mode);
254 pci_read_config_dword(pdev, addr, ®);
255 reg = ((reg & ~mask) | (t & mask)) & ~0xc0000000;
256 pci_write_config_dword(pdev, addr, reg);
269 hpt366_set_mode(ap, adev, adev->
pio_mode);
283 hpt366_set_mode(ap, adev, adev->
dma_mode);
295 .inherits = &ata_bmdma_port_ops,
296 .cable_detect = hpt36x_cable_detect,
297 .mode_filter = hpt366_filter,
298 .set_piomode = hpt366_set_piomode,
299 .set_dmamode = hpt366_set_dmamode,
310 static void hpt36x_init_chipset(
struct pci_dev *dev)
319 pci_read_config_byte(dev, 0x51, &drive_fast);
320 if (drive_fast & 0x80)
321 pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
352 .port_ops = &hpt366_port_ops
369 hpt36x_init_chipset(dev);
371 pci_read_config_dword(dev, 0x40, ®1);
375 switch ((reg1 & 0x700) >> 8) {
387 return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0);
391 static int hpt36x_reinit_one(
struct pci_dev *dev)
396 rc = ata_pci_device_do_resume(dev);
399 hpt36x_init_chipset(dev);
400 ata_host_resume(host);
410 static struct pci_driver hpt36x_pci_driver = {
413 .probe = hpt36x_init_one,
414 .remove = ata_pci_remove_one,
416 .suspend = ata_pci_device_suspend,
417 .resume = hpt36x_reinit_one,