From owner-freebsd-hackers Tue Jul 2 22:52:11 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 36F4937B400 for ; Tue, 2 Jul 2002 22:52:03 -0700 (PDT) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3DACA43E31 for ; Tue, 2 Jul 2002 22:52:02 -0700 (PDT) (envelope-from nsouch@free.fr) Received: from free.fr (nas-cbv-5-62-147-146-108.dial.proxad.net [62.147.146.108]) by postfix3-2.free.fr (Postfix) with ESMTP id 9967417FCA; Wed, 3 Jul 2002 07:51:59 +0200 (CEST) Received: from armor.fastether (localhost.fastether [127.0.0.1]) by free.fr (8.12.3/8.9.3) with ESMTP id g635r34W020236; Wed, 3 Jul 2002 07:53:04 +0200 (CEST) (envelope-from nsouch@perso.free.fr) Received: (from nsouch@localhost) by armor.fastether (8.12.3/8.12.3/Submit) id g635r2rC020235; Wed, 3 Jul 2002 07:53:02 +0200 (CEST) Date: Wed, 3 Jul 2002 07:52:57 +0200 From: Nicolas Souchu To: "Thomas D. Dean" Cc: evantd@hotmail.com, freebsd-hackers@FreeBSD.ORG Subject: Re: AS99127F Hardware Monitor Message-ID: <20020703075257.A20219@armor.fastether> References: <200206172232.g5HMWqfK001804@asus.tddhome> <20020701075958.B6932@armor.fastether> <200207011407.g61E7sCH005717@asus.tddhome> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200207011407.g61E7sCH005717@asus.tddhome>; from tomdean@speakeasy.org on Mon, Jul 01, 2002 at 07:07:54AM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 01, 2002 at 07:07:54AM -0700, Thomas D. Dean wrote: > The ASUS A7N266-E motherboard has the nVidia 420D chipset. Of course, > ASUS and nVidia will not provide datasheets... > > This is not a production machine... So, have you -current installed? Here is the nForce diff from Linux lm_sensors. Do you feel like trying the change by yourself? Otherwise, I'll have to do it... Nicholas -- Nicholas Souchu - nsouch@free.fr - nsouch@FreeBSD.org --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nForce.patch" Index: i2c-amd756.c =================================================================== RCS file: /home/cvs/lm_sensors2/kernel/busses/i2c-amd756.c,v retrieving revision 1.16 retrieving revision 1.19 diff -u -r1.16 -r1.19 --- i2c-amd756.c 2002/05/01 23:17:25 1.16 +++ i2c-amd756.c 2002/05/02 14:44:31 1.19 @@ -2,7 +2,7 @@ amd756.c - Part of lm_sensors, Linux kernel modules for hardware monitoring - Copyright (c) 1999 Merlin Hughes + Copyright (c) 1999-2002 Merlin Hughes Shamelessly ripped from i2c-piix4.c: @@ -25,7 +25,11 @@ */ /* - Supports AMD756, AMD766, and AMD768. + 2002-04-08: Added nForce support. (Csaba Halasz) +*/ + +/* + Supports AMD756, AMD766, AMD768 and nVidia nForce Note: we assume there can only be one device, with one SMBus interface. */ @@ -41,21 +45,31 @@ #include "version.h" #include -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif - #ifndef PCI_DEVICE_ID_AMD_756 #define PCI_DEVICE_ID_AMD_756 0x740B #endif #ifndef PCI_DEVICE_ID_AMD_766 #define PCI_DEVICE_ID_AMD_766 0x7413 #endif +#ifndef PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01B4 +#endif + +struct sd { + const unsigned short vendor; + const unsigned short device; + const unsigned short function; + const char* name; + int amdsetup:1; +}; -static int supported[] = {PCI_DEVICE_ID_AMD_756, - PCI_DEVICE_ID_AMD_766, - 0x7443, /* AMD768 */ - 0 }; +static struct sd supported[] = { + {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_756, 3, "AMD756", 1}, + {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_766, 3, "AMD766", 1}, + {PCI_VENDOR_ID_AMD, 0x7443, 3, "AMD768", 1}, + {PCI_VENDOR_ID_NVIDIA, 0x01B4, 1, "nVidia nForce", 0}, + {0, 0, 0} +}; /* AMD756 SMBus address offsets */ #define SMB_ADDR_OFFSET 0xE0 @@ -141,6 +155,7 @@ }; static int __initdata amd756_initialized; +static struct sd *amd756_sd = NULL; static unsigned short amd756_smba = 0; /* Detect whether a AMD756 can be found, and initialize it, where necessary. @@ -150,7 +165,7 @@ int amd756_setup(void) { unsigned char temp; - int *num = supported; + struct sd *currdev; struct pci_dev *AMD756_dev = NULL; if (pci_present() == 0) { @@ -158,38 +173,41 @@ return(-ENODEV); } - /* Look for the AMD756, function 3 */ - /* Note: we keep on searching until we have found 'function 3' */ - do { - if((AMD756_dev = pci_find_device(PCI_VENDOR_ID_AMD, - *num, AMD756_dev))) { - if(PCI_FUNC(AMD756_dev->devfn) != 3) - continue; - break; + /* Look for a supported chip */ + for(currdev = supported; currdev->vendor; ) { + AMD756_dev = pci_find_device(currdev->vendor, + currdev->device, AMD756_dev); + if (AMD756_dev != NULL) { + if (PCI_FUNC(AMD756_dev->devfn) == currdev->function) + break; + } else { + currdev++; } - num++; - } while (*num != 0); + } if (AMD756_dev == NULL) { printk - ("i2c-amd756.o: Error: Can't detect AMD756, function 3!\n"); + ("i2c-amd756.o: Error: No AMD756 or compatible device detected!\n"); return(-ENODEV); } + printk(KERN_INFO "i2c-amd756.o: Found %s SMBus controller.\n", currdev->name); + if (currdev->amdsetup) + { + pci_read_config_byte(AMD756_dev, SMBGCFG, &temp); + if ((temp & 128) == 0) { + printk("i2c-amd756.o: Error: SMBus controller I/O not enabled!\n"); + return(-ENODEV); + } - pci_read_config_byte(AMD756_dev, SMBGCFG, &temp); - if ((temp & 128) == 0) { - printk - ("i2c-amd756.o: Error: SMBus controller I/O not enabled!\n"); - return(-ENODEV); + /* Determine the address of the SMBus areas */ + /* Technically it is a dword but... */ + pci_read_config_word(AMD756_dev, SMBBA, &amd756_smba); + amd756_smba &= 0xff00; + amd756_smba += SMB_ADDR_OFFSET; + } else { + amd756_smba = 0x5500; } - - /* Determine the address of the SMBus areas */ - /* Technically it is a dword but... */ - pci_read_config_word(AMD756_dev, SMBBA, &amd756_smba); - amd756_smba &= 0xff00; - amd756_smba += SMB_ADDR_OFFSET; - if (check_region(amd756_smba, SMB_IOSIZE)) { printk ("i2c-amd756.o: SMB region 0x%x already in use!\n", @@ -206,6 +224,9 @@ printk("i2c-amd756.o: AMD756_smba = 0x%X\n", amd756_smba); #endif /* DEBUG */ + /* store struct sd * for future reference */ + amd756_sd = currdev; + return 0; } @@ -464,13 +485,13 @@ amd756_initialized = 0; if ((res = amd756_setup())) { printk - ("i2c-amd756.o: AMD756/766 not detected, module not inserted.\n"); + ("i2c-amd756.o: AMD756 or compatible device not detected, module not inserted.\n"); amd756_cleanup(); return res; } amd756_initialized++; - sprintf(amd756_adapter.name, "SMBus AMD7X6 adapter at %04x", - amd756_smba); + sprintf(amd756_adapter.name, "SMBus %s adapter at %04x", + amd756_sd->name, amd756_smba); if ((res = i2c_add_adapter(&amd756_adapter))) { printk ("i2c-amd756.o: Adapter registration failed, module not inserted.\n"); @@ -478,7 +499,8 @@ return res; } amd756_initialized++; - printk("i2c-amd756.o: AMD756/766 bus detected and initialized\n"); + printk("i2c-amd756.o: %s bus detected and initialized\n", + amd756_sd->name); return 0; } @@ -505,7 +527,11 @@ #ifdef MODULE MODULE_AUTHOR("Merlin Hughes "); -MODULE_DESCRIPTION("AMD756/766 SMBus driver"); +MODULE_DESCRIPTION("AMD756/766/768/nVidia nForce SMBus driver"); + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif int init_module(void) { --VS++wcV0S1rZb1Fb-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message