From c06bb5d49d8b240876c7c5019197e6a7bd33bcf7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 30 Jan 2007 14:36:09 -0800 Subject: [PATCH] Fix VIA quirks Fix VIA quirks that were recently broken by Alan Cox in the upstream kernel (commit 1597cacbe39802d86656d1f2e6329895bd2ef531). My understanding is that pci_find_present() doesn't work yet at the time the quirks are run. So I used a two-step quirk as is done for some other quirks already. First we detect the VIA south bridges and set the right low and high device limits, then we are ready to actually run the quirks on the affected devices. Signed-off-by: Jean Delvare Acked-by: Alan Cox Acked-by: Nick Piggin Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pci/quirks.c | 78 ++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'drivers/pci/quirks.c') diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index ef882a8a094e..16945c2ba2ca 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -654,19 +654,40 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vi * VIA bridges which have VLink */ -static const struct pci_device_id via_vlink_fixup_tbl[] = { - /* Internal devices need IRQ line routing, pre VLink */ - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686), 0 }, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8231), 17 }, - /* Devices with VLink */ - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233_0), 17}, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233A), 17 }, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233C_0), 17 }, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8235), 16 }, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237), 15 }, - { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237A), 15 }, - { 0, }, -}; +static int via_vlink_dev_lo = -1, via_vlink_dev_hi = 18; + +static void quirk_via_bridge(struct pci_dev *dev) +{ + /* See what bridge we have and find the device ranges */ + switch (dev->device) { + case PCI_DEVICE_ID_VIA_82C686: + /* 82C686 is special */ + via_vlink_dev_lo = 7; + via_vlink_dev_hi = 7; + break; + case PCI_DEVICE_ID_VIA_8237: + case PCI_DEVICE_ID_VIA_8237A: + via_vlink_dev_lo = 15; + break; + case PCI_DEVICE_ID_VIA_8235: + via_vlink_dev_lo = 16; + break; + case PCI_DEVICE_ID_VIA_8231: + case PCI_DEVICE_ID_VIA_8233_0: + case PCI_DEVICE_ID_VIA_8233A: + case PCI_DEVICE_ID_VIA_8233C_0: + via_vlink_dev_lo = 17; + break; + } +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_0, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233A, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233C_0, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_bridge); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237A, quirk_via_bridge); /** * quirk_via_vlink - VIA VLink IRQ number update @@ -675,35 +696,20 @@ static const struct pci_device_id via_vlink_fixup_tbl[] = { * If the device we are dealing with is on a PIC IRQ we need to * ensure that the IRQ line register which usually is not relevant * for PCI cards, is actually written so that interrupts get sent - * to the right place + * to the right place. + * We only do this on systems where a VIA south bridge was detected, + * and only for VIA devices on the motherboard (see quirk_via_bridge + * above). */ static void quirk_via_vlink(struct pci_dev *dev) { - const struct pci_device_id *via_vlink_fixup; - static int dev_lo = -1, dev_hi = 18; u8 irq, new_irq; - /* Check if we have VLink and cache the result */ - - /* Checked already - no */ - if (dev_lo == -2) + /* Check if we have VLink at all */ + if (via_vlink_dev_lo == -1) return; - /* Not checked - see what bridge we have and find the device - ranges */ - - if (dev_lo == -1) { - via_vlink_fixup = pci_find_present(via_vlink_fixup_tbl); - if (via_vlink_fixup == NULL) { - dev_lo = -2; - return; - } - dev_lo = via_vlink_fixup->driver_data; - /* 82C686 is special - 0/0 */ - if (dev_lo == 0) - dev_hi = 0; - } new_irq = dev->irq; /* Don't quirk interrupts outside the legacy IRQ range */ @@ -711,8 +717,8 @@ static void quirk_via_vlink(struct pci_dev *dev) return; /* Internal device ? */ - if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) > dev_hi || - PCI_SLOT(dev->devfn) < dev_lo) + if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) > via_vlink_dev_hi || + PCI_SLOT(dev->devfn) < via_vlink_dev_lo) return; /* This is an internal VLink device on a PIC interrupt. The BIOS -- cgit v1.2.3 From cb7468ef4cce8f240604b80b82ac157fa9930e94 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 31 Jan 2007 23:48:12 -0800 Subject: [PATCH] via quirk update Add special handling for the VT82C686. Signed-off-by: Jean Delvare Cc: Alan Cox Cc: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pci/quirks.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/pci/quirks.c') diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 16945c2ba2ca..dcc0c1ab95ed 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -661,9 +661,11 @@ static void quirk_via_bridge(struct pci_dev *dev) /* See what bridge we have and find the device ranges */ switch (dev->device) { case PCI_DEVICE_ID_VIA_82C686: - /* 82C686 is special */ - via_vlink_dev_lo = 7; - via_vlink_dev_hi = 7; + /* The VT82C686 is special, it attaches to PCI and can have + any device number. All its subdevices are functions of + that single device. */ + via_vlink_dev_lo = PCI_SLOT(dev->devfn); + via_vlink_dev_hi = PCI_SLOT(dev->devfn); break; case PCI_DEVICE_ID_VIA_8237: case PCI_DEVICE_ID_VIA_8237A: -- cgit v1.2.3 From 77280989673ee1ef736a92617f52e2be45651833 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 2 Feb 2007 14:51:09 +0900 Subject: ahci/pata_jmicron: fix JMicron quirk For all JMicrons except for 361 and 368, AHCI mode enable bits in the Control(1) should be set. This used to be done in both ahci and pata_jmicron but while moving programming to PCI quirk, it was removed from ahci part while still left in pata_jmicron. The implemented JMicron PCI quirk was incorrect in that it didn't program AHCI mode enable bits. If pata_jmicron is loaded first and programs those bits, the ahci ports work; otherwise, ahci device detection fails miserably. This patch makes JMicron PCI quirk clear SATA IDE mode bits and set AHCI mode bits and remove the respective part from pata_jmicron. Tested on JMB361, 363 and 368. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/pata_jmicron.c | 18 +++++------------- drivers/pci/quirks.c | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'drivers/pci/quirks.c') diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 2d661cb4df3c..d50264af2848 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c @@ -204,20 +204,12 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i u32 reg; - if (id->driver_data != 368) { - /* Put the controller into AHCI mode in case the AHCI driver - has not yet been loaded. This can be done with either - function present */ + /* PATA controller is fn 1, AHCI is fn 0 */ + if (id->driver_data != 368 && PCI_FUNC(pdev->devfn) != 1) + return -ENODEV; - /* FIXME: We may want a way to override this in future */ - pci_write_config_byte(pdev, 0x41, 0xa1); - - /* PATA controller is fn 1, AHCI is fn 0 */ - if (PCI_FUNC(pdev->devfn) != 1) - return -ENODEV; - } - if ( id->driver_data == 365 || id->driver_data == 366) { - /* The 365/66 have two PATA channels, redirect the second */ + /* The 365/66 have two PATA channels, redirect the second */ + if (id->driver_data == 365 || id->driver_data == 366) { pci_read_config_dword(pdev, 0x80, ®); reg |= (1 << 24); /* IDE1 to PATA IDE secondary */ pci_write_config_dword(pdev, 0x80, reg); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dcc0c1ab95ed..c913ea4e545c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1262,8 +1262,8 @@ static void quirk_jmicron_dualfn(struct pci_dev *pdev) pci_read_config_dword(pdev, 0x40, &conf); /* Enable dual function mode, AHCI on fn 0, IDE fn1 */ /* Set the class codes correctly and then direct IDE 0 */ - conf &= ~0x000F0200; /* Clear bit 9 and 16-19 */ - conf |= 0x00C20002; /* Set bit 1, 17, 22, 23 */ + conf &= ~0x000FF200; /* Clear bit 9 and 12-19 */ + conf |= 0x00C2A102; /* Set 1, 8, 13, 15, 17, 22, 23 */ pci_write_config_dword(pdev, 0x40, conf); /* Reconfigure so that the PCI scanner discovers the -- cgit v1.2.3