aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_jmicron.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_jmicron.c')
-rw-r--r--drivers/ata/pata_jmicron.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 7a635dd326f8..47d0f94fd792 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -202,49 +202,20 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
202 }; 202 };
203 struct ata_port_info *port_info[2] = { &info, &info }; 203 struct ata_port_info *port_info[2] = { &info, &info };
204 204
205 u32 reg;
206
207 /* PATA controller is fn 1, AHCI is fn 0 */
208 if (id->driver_data != 368 && PCI_FUNC(pdev->devfn) != 1)
209 return -ENODEV;
210
211 /* The 365/66 have two PATA channels, redirect the second */
212 if (id->driver_data == 365 || id->driver_data == 366) {
213 pci_read_config_dword(pdev, 0x80, &reg);
214 reg |= (1 << 24); /* IDE1 to PATA IDE secondary */
215 pci_write_config_dword(pdev, 0x80, reg);
216 }
217
218 return ata_pci_init_one(pdev, port_info, 2); 205 return ata_pci_init_one(pdev, port_info, 2);
219} 206}
220 207
221static int jmicron_reinit_one(struct pci_dev *pdev)
222{
223 u32 reg;
224
225 switch(pdev->device) {
226 case PCI_DEVICE_ID_JMICRON_JMB368:
227 break;
228 case PCI_DEVICE_ID_JMICRON_JMB365:
229 case PCI_DEVICE_ID_JMICRON_JMB366:
230 /* Restore mapping or disks swap and boy does it get ugly */
231 pci_read_config_dword(pdev, 0x80, &reg);
232 reg |= (1 << 24); /* IDE1 to PATA IDE secondary */
233 pci_write_config_dword(pdev, 0x80, reg);
234 /* Fall through */
235 default:
236 /* Make sure AHCI is turned back on */
237 pci_write_config_byte(pdev, 0x41, 0xa1);
238 }
239 return ata_pci_device_resume(pdev);
240}
241
242static const struct pci_device_id jmicron_pci_tbl[] = { 208static const struct pci_device_id jmicron_pci_tbl[] = {
243 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361}, 209 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361,
244 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 363}, 210 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 361 },
245 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365), 365}, 211 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363,
246 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366), 366}, 212 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 363 },
247 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368), 368}, 213 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365,
214 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 365 },
215 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366,
216 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 366 },
217 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368,
218 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 368 },
248 219
249 { } /* terminate list */ 220 { } /* terminate list */
250}; 221};
@@ -255,7 +226,7 @@ static struct pci_driver jmicron_pci_driver = {
255 .probe = jmicron_init_one, 226 .probe = jmicron_init_one,
256 .remove = ata_pci_remove_one, 227 .remove = ata_pci_remove_one,
257 .suspend = ata_pci_device_suspend, 228 .suspend = ata_pci_device_suspend,
258 .resume = jmicron_reinit_one, 229 .resume = ata_pci_device_resume,
259}; 230};
260 231
261static int __init jmicron_init(void) 232static int __init jmicron_init(void)