blob: 9262a9174b4eafad27b3810ce3bdd8df17392fa7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
3 * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * For the avoidance of doubt the "preferred form" of this code is one which
16 * is in an open non patent encumbered format. Where cryptographic key signing
17 * forms part of the process of creating an executable the information
18 * including keys needed to generate an equivalently functional executable
19 * are deemed to be part of the source code.
20 */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/types.h>
23#include <linux/module.h>
24#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/hdreg.h>
26#include <linux/pci.h>
27#include <linux/ide.h>
28#include <linux/init.h>
29
Alan Coxb1893462005-06-27 15:24:26 -070030static int ide_generic_all; /* Set to claim all devices */
31
Adrian Bunk3c5473f2006-10-21 10:24:06 -070032/*
33 * the module_param_named() was added for the modular case
34 * the __setup() is left as compatibility for existing setups
35 */
36#ifndef MODULE
37static int __init ide_generic_all_on(char *unused)
38{
39 ide_generic_all = 1;
Sergey Vlasov2b52c952006-10-29 22:46:44 -080040 printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n");
Adrian Bunk3c5473f2006-10-21 10:24:06 -070041 return 1;
42}
Bartlomiej Zolnierkiewiczd5271be2007-10-26 20:31:15 +020043const __setup("all-generic-ide", ide_generic_all_on);
Adrian Bunk3c5473f2006-10-21 10:24:06 -070044#endif
Patrick Jeffersona4bea102006-10-03 01:14:34 -070045module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
46MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers.");
Alan Coxb1893462005-06-27 15:24:26 -070047
Bartlomiej Zolnierkiewicz8acf28c2007-10-20 00:32:30 +020048#define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Bartlomiej Zolnierkiewicz8acf28c2007-10-20 00:32:30 +020050#define DECLARE_GENERIC_PCI_DEV(name_str, extra_flags) \
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020051 { \
52 .name = name_str, \
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +020053 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \
Bartlomiej Zolnierkiewicz8acf28c2007-10-20 00:32:30 +020054 extra_flags | \
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +020055 IDE_HFLAG_BOOTABLE, \
Bartlomiej Zolnierkiewicz5f8b6c32007-10-19 00:30:07 +020056 .swdma_mask = ATA_SWDMA2, \
57 .mwdma_mask = ATA_MWDMA2, \
58 .udma_mask = ATA_UDMA6, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Bartlomiej Zolnierkiewicz85620432007-10-20 00:32:34 +020061static const struct ide_port_info generic_chipsets[] __devinitdata = {
Bartlomiej Zolnierkiewicz47b68782007-10-19 00:30:06 +020062 /* 0 */ DECLARE_GENERIC_PCI_DEV("Unknown", 0),
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020063
64 { /* 1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 .name = "NS87410",
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}},
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +020067 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
68 IDE_HFLAG_BOOTABLE,
Bartlomiej Zolnierkiewicz5f8b6c32007-10-19 00:30:07 +020069 .swdma_mask = ATA_SWDMA2,
70 .mwdma_mask = ATA_MWDMA2,
71 .udma_mask = ATA_UDMA6,
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020072 },
73
Bartlomiej Zolnierkiewicz47b68782007-10-19 00:30:06 +020074 /* 2 */ DECLARE_GENERIC_PCI_DEV("SAMURAI", 0),
75 /* 3 */ DECLARE_GENERIC_PCI_DEV("HT6565", 0),
Bartlomiej Zolnierkiewicz8acf28c2007-10-20 00:32:30 +020076 /* 4 */ DECLARE_GENERIC_PCI_DEV("UM8673F", IDE_HFLAGS_UMC),
77 /* 5 */ DECLARE_GENERIC_PCI_DEV("UM8886A", IDE_HFLAGS_UMC),
78 /* 6 */ DECLARE_GENERIC_PCI_DEV("UM8886BF", IDE_HFLAGS_UMC),
Bartlomiej Zolnierkiewicz47b68782007-10-19 00:30:06 +020079 /* 7 */ DECLARE_GENERIC_PCI_DEV("HINT_IDE", 0),
80 /* 8 */ DECLARE_GENERIC_PCI_DEV("VIA_IDE", IDE_HFLAG_NO_AUTODMA),
81 /* 9 */ DECLARE_GENERIC_PCI_DEV("OPTI621V", IDE_HFLAG_NO_AUTODMA),
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020082
83 { /* 10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 .name = "VIA8237SATA",
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +020085 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
86 IDE_HFLAG_OFF_BOARD,
Bartlomiej Zolnierkiewicz5f8b6c32007-10-19 00:30:07 +020087 .swdma_mask = ATA_SWDMA2,
88 .mwdma_mask = ATA_MWDMA2,
89 .udma_mask = ATA_UDMA6,
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020090 },
91
Bartlomiej Zolnierkiewicz47b68782007-10-19 00:30:06 +020092 /* 11 */ DECLARE_GENERIC_PCI_DEV("Piccolo0102", IDE_HFLAG_NO_AUTODMA),
93 /* 12 */ DECLARE_GENERIC_PCI_DEV("Piccolo0103", IDE_HFLAG_NO_AUTODMA),
94 /* 13 */ DECLARE_GENERIC_PCI_DEV("Piccolo0105", IDE_HFLAG_NO_AUTODMA),
Bartlomiej Zolnierkiewicz1c3dd322007-10-19 00:30:06 +020095
96 { /* 14 */
Matt Gillette2f09a7f2005-08-18 22:27:07 +020097 .name = "Revolution",
Bartlomiej Zolnierkiewicz8ac2b422008-02-01 23:09:30 +010098 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
99 IDE_HFLAG_TRUST_BIOS_FOR_DMA |
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +0200100 IDE_HFLAG_OFF_BOARD,
Bartlomiej Zolnierkiewicz5f8b6c32007-10-19 00:30:07 +0200101 .swdma_mask = ATA_SWDMA2,
102 .mwdma_mask = ATA_MWDMA2,
103 .udma_mask = ATA_UDMA6,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105};
106
107/**
108 * generic_init_one - called when a PIIX is found
109 * @dev: the generic device
110 * @id: the matching pci id
111 *
112 * Called when the PCI registration layer (or the IDE initialization)
113 * finds a device matching our IDE device tables.
114 */
115
116static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
117{
Bartlomiej Zolnierkiewicz85620432007-10-20 00:32:34 +0200118 const struct ide_port_info *d = &generic_chipsets[id->driver_data];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 int ret = -ENODEV;
120
Alan Coxb1893462005-06-27 15:24:26 -0700121 /* Don't use the generic entry unless instructed to do so */
122 if (id->driver_data == 0 && ide_generic_all == 0)
123 goto out;
124
Jiri Slabyea307592007-06-08 15:14:31 +0200125 switch (dev->vendor) {
126 case PCI_VENDOR_ID_UMC:
127 if (dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
128 !(PCI_FUNC(dev->devfn) & 1))
129 goto out; /* UM8886A/BF pair */
130 break;
131 case PCI_VENDOR_ID_OPTI:
132 if (dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
133 !(PCI_FUNC(dev->devfn) & 1))
Alan Coxc3335262006-10-28 10:38:57 -0700134 goto out;
Jiri Slabyea307592007-06-08 15:14:31 +0200135 break;
136 case PCI_VENDOR_ID_JMICRON:
137 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 &&
138 PCI_FUNC(dev->devfn) != 1)
139 goto out;
140 break;
141 case PCI_VENDOR_ID_NS:
142 if (dev->device == PCI_DEVICE_ID_NS_87410 &&
143 (dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
144 goto out;
145 break;
Alan Coxc3335262006-10-28 10:38:57 -0700146 }
Alan Cox15e0c692006-07-12 15:05:41 +0100147
Alan Cox3719bc52006-10-11 01:21:47 -0700148 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
Jiri Slabyea307592007-06-08 15:14:31 +0200149 u16 command;
Alan Cox3719bc52006-10-11 01:21:47 -0700150 pci_read_config_word(dev, PCI_COMMAND, &command);
151 if (!(command & PCI_COMMAND_IO)) {
Jiri Slabyea307592007-06-08 15:14:31 +0200152 printk(KERN_INFO "Skipping disabled %s IDE "
153 "controller.\n", d->name);
Alan Cox3719bc52006-10-11 01:21:47 -0700154 goto out;
155 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 }
157 ret = ide_setup_pci_device(dev, d);
158out:
159 return ret;
160}
161
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +0200162static const struct pci_device_id generic_pci_tbl[] = {
163 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 },
164 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 },
165 { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 3 },
166 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 4 },
167 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 5 },
168 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 6 },
169 { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 7 },
170 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 8 },
171 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 9 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172#ifdef CONFIG_BLK_DEV_IDE_SATA
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +0200173 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 10 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174#endif
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +0200175 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 11 },
176 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 12 },
177 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 13 },
178 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 14 },
179 /*
180 * Must come last. If you add entries adjust
181 * this table and generic_chipsets[] appropriately.
182 */
183 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 { 0, },
185};
186MODULE_DEVICE_TABLE(pci, generic_pci_tbl);
187
188static struct pci_driver driver = {
189 .name = "PCI_IDE",
190 .id_table = generic_pci_tbl,
191 .probe = generic_init_one,
192};
193
Bartlomiej Zolnierkiewicz82ab1ee2007-01-27 13:46:56 +0100194static int __init generic_ide_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
196 return ide_pci_register_driver(&driver);
197}
198
199module_init(generic_ide_init);
200
201MODULE_AUTHOR("Andre Hedrick");
202MODULE_DESCRIPTION("PCI driver module for generic PCI IDE");
203MODULE_LICENSE("GPL");