From 0ed4b1e3f3e952fbaba64c9e9bf6bd1d7c1326b4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 23 Jun 2006 15:53:26 +0000 Subject: [PATCH] Add support for the new nForce4 MCP51 (also known as nForce 410 or 430) and nForce4 MCP55 to the i2c-nforce2 driver. Some code changes were required because the base I/O address registers have changed in these versions. Standard BARs are now being used, while the original nForce2 chips used non-standard ones. (2.6 backport) git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4054 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + doc/busses/i2c-nforce2 | 2 ++ kernel/busses/i2c-nforce2.c | 47 ++++++++++++++++++++++++++----------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 8ac5b083..fd310423 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ lm_sensors CHANGES file (2.6 backport) Module i2c-i801: Disable PEC mode after every transaction (2.6 backport) Add ICH8 support (2.6 backport) + Module i2c-nforce2: Add nForce4 MCP51, MCP55 support (2.6 backport) Module i2c-piix4: Add ServerWorks HT-1000 support (2.6 backport) Add ATI IXP200, IXP300, IXP400 support (2.6 backport) Drop the fix_hstcfg parameter (2.6 backport) diff --git a/doc/busses/i2c-nforce2 b/doc/busses/i2c-nforce2 index 6884ea53..17abfde6 100644 --- a/doc/busses/i2c-nforce2 +++ b/doc/busses/i2c-nforce2 @@ -18,6 +18,8 @@ Supported adapters: * nVidia nForce4 SMBus PCI interface (10de:0052, included in nForce4 MCP) (10de:0034, included in nForce4 MCP-04) + (10de:0264, included in nForce4 MCP51) + (10de:0368, included in nForce4 MCP55) Datasheet: same as for nForce2 SMBus PCI interface Author: Hans-Frieder Vogt diff --git a/kernel/busses/i2c-nforce2.c b/kernel/busses/i2c-nforce2.c index 7135bb47..4f976fba 100644 --- a/kernel/busses/i2c-nforce2.c +++ b/kernel/busses/i2c-nforce2.c @@ -29,6 +29,8 @@ nForce3 250Gb MCP 00E4 nForce4 MCP 0052 nForce4 MCP-04 0034 + nForce4 MCP51 0264 + nForce4 MCP55 0368 This driver supports the 2 SMBuses that are included in the MCP of the nForce2/3/4 chipsets. @@ -74,9 +76,9 @@ MODULE_DESCRIPTION("nForce2 SMBus driver"); #define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052 #endif -#ifndef PCI_DEVICE_ID_NVIDIA_NFORCE_MPC04_SMBUS -#define PCI_DEVICE_ID_NVIDIA_NFORCE_MPC04_SMBUS 0x0034 -#endif +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS 0x0264 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS 0x0368 struct nforce2_smbus { @@ -89,6 +91,7 @@ struct nforce2_smbus { /* * nVidia nForce2 SMBus control register definitions + * (Newer incarnations use standard BARs 4 and 5 instead) */ #define NFORCE_PCI_SMB1 0x50 #define NFORCE_PCI_SMB2 0x54 @@ -301,24 +304,39 @@ static struct pci_device_id nforce2_ids[] = { PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MPC04_SMBUS, + { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0 } }; -static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg, struct nforce2_smbus *smbus, char *name) +static int __devinit nforce2_probe_smb(struct pci_dev *dev, int bar, + int alt_reg, struct nforce2_smbus *smbus, char *name) { - u16 iobase; int error; - if (pci_read_config_word(dev, reg, &iobase) != PCIBIOS_SUCCESSFUL) { - printk (KERN_ERR "i2c-nforce2.o: Error reading PCI config for %s\n", name); - return -1; + smbus->base = pci_resource_start(dev, bar); + if (smbus->base) { + smbus->size = pci_resource_len(dev, bar); + } else { + /* Older incarnations of the device used non-standard BARs */ + u16 iobase; + + if (pci_read_config_word(dev, alt_reg, &iobase) + != PCIBIOS_SUCCESSFUL) { + printk(KERN_ERR "i2c-nforce2.o: Error reading PCI " + "config for %s\n", name); + return -1; + } + + smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; + smbus->size = 8; } - smbus->dev = dev; - smbus->base = iobase & 0xfffc; - smbus->size = 8; + smbus->dev = dev; if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { printk (KERN_ERR "i2c-nforce2.o: Error requesting region %02x .. %02X for %s\n", smbus->base, smbus->base+smbus->size-1, name); @@ -355,12 +373,13 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ pci_set_drvdata(dev, smbuses); /* SMBus adapter 1 */ - res1 = nforce2_probe_smb (dev, NFORCE_PCI_SMB1, &smbuses[0], "SMB1"); + res1 = nforce2_probe_smb(dev, 4, NFORCE_PCI_SMB1, &smbuses[0], "SMB1"); if (res1 < 0) { printk (KERN_ERR "i2c-nforce2.o: Error probing SMB1.\n"); smbuses[0].base = 0; /* to have a check value */ } - res2 = nforce2_probe_smb (dev, NFORCE_PCI_SMB2, &smbuses[1], "SMB2"); + /* SMBus adapter 2 */ + res2 = nforce2_probe_smb(dev, 5, NFORCE_PCI_SMB2, &smbuses[1], "SMB2"); if (res2 < 0) { printk (KERN_ERR "i2c-nforce2.o: Error probing SMB2.\n"); smbuses[1].base = 0; /* to have a check value */