Show
Ignore:
Timestamp:
06/28/02 04:49:46 (11 years ago)
Author:
mds
Message:

add support for ICH4; patch from

Klaus Woltereck <kw42@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/hotplug/p4b_smbus.c

    r1331 r1404  
    55 */ 
    66/* 
    7     Copyright (c) 2002 Ilja Rauhut <IljaRauhut@web.de>, 
     7    Copyright (c) 2002 Ilja Rauhut <IljaRauhut@web.de> and 
     8    Klaus Woltereck <kw42@gmx.net>, 
    89 
    910    Based on the m7101.c hotplug example by: 
     
    3940 * gcc > 2.7.2 or egcs >= 2.95.2.  
    4041 * 
     42 * 
     43 * June 21, 2002, added support for the ICH4, code clean up -- Klaus 
    4144 */ 
    4245 
     
    8588#define SMB_BASE 0x20 
    8689 
     90 
     91/* 
     92 * some shorter definitions for the ICHx PCI device IDs 
     93 */ 
     94 
     95#define ICH2 PCI_DEVICE_ID_INTEL_82801BA_0 
     96#define ICH2_SMBUS PCI_DEVICE_ID_INTEL_82801BA_3 
     97 
     98 
     99#ifndef PCI_DEVICE_ID_INTEL_82801DB_0 
     100#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 
     101#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 
     102#endif 
     103 
     104#define ICH4 PCI_DEVICE_ID_INTEL_82801DB_0 
     105#define ICH4_SMBUS PCI_DEVICE_ID_INTEL_82801DB_3 
     106 
    87107/* status, used to indicate that io space needs to be freed */ 
    88108static struct pci_dev *i801smbus = NULL; 
    89109static int i801smbus_inserted = FALSE; 
    90 extern void cleanup_module(); 
     110extern void cleanup_module(void); 
    91111  
    92112static rwlock_t i801smbus_lock = RW_LOCK_UNLOCKED; 
     
    95115/*  
    96116 * Checks whether SMBus is enabled and turns it on in case they are not.  
    97  * It's done by clearing Bit 8 and 4 in i801 config space F2h, PCI-Device 0x8086:0x2440 
     117 * It's done by clearing Bit 8 and 4 in i801 config space F2h, PCI-Device 0x8086:0x2440(ICH2)/0x24c0(ICH4) 
    98118 */ 
    99119static int 
     
    146166                (*i801smbus)->devfn = devfn; 
    147167                ret = pci_read_config_word(*i801smbus, PCI_DEVICE_ID, &id); 
    148                 if (ret == 0 && 0x2443 == id) { 
     168                if (ret == 0 && (ICH2_SMBUS == id || ICH4_SMBUS == id)) { 
    149169                        pci_read_config_word(*i801smbus, PCI_VENDOR_ID, &vid); 
    150170                        if(vid == 0x8086) 
     
    152172                } 
    153173        } 
    154         if (0x2443 != id) {      
     174        if (!(ICH2_SMBUS == id || ICH4_SMBUS == id)) {   
    155175                DBG("i801smbus: i801smbus not found although i801 present - strange.\n"); 
    156176                return -EACCES; 
     
    164184        (*i801smbus)->vendor = 0x8086; 
    165185        (*i801smbus)->hdr_type = PCI_HEADER_TYPE_NORMAL; 
    166         (*i801smbus)->device = 0x2443; 
     186        (*i801smbus)->device = id; 
    167187  
    168188        return(pci_setup_device(*i801smbus)); 
     
    188208 
    189209        /* We want to be sure that the i801smbus is not present yet. */ 
    190         dev = pci_find_device(0x8086,0x2443, NULL); 
     210        dev = pci_find_device(0x8086, ICH2_SMBUS, NULL); 
    191211 
    192212        if (dev)  
    193213          { 
    194             printk("i801smbus: SMBus already actve\n"); 
     214            printk("i801smbus: SMBus already active\n"); 
     215            return -EPERM; 
     216          } 
     217         
     218        dev = pci_find_device(0x8086, ICH4_SMBUS, NULL); 
     219 
     220        if (dev)  
     221          { 
     222            printk("i801smbus: SMBus already active\n"); 
    195223            return -EPERM; 
    196224          } 
    197225         
    198226        /* Are we operating a i801 chipset */ 
    199         dev = pci_find_device(0x8086,0x2440, NULL); 
     227        dev = pci_find_device(0x8086, ICH2, NULL); 
    200228        if (NULL == dev)  
    201229          { 
    202             printk("INTEL ICH2 type 82801BA not found.\n"); 
    203             return -ENODEV ; 
    204           } 
     230            dev = pci_find_device(0x8086, ICH4, NULL); 
     231            if (NULL == dev)  
     232              { 
     233                printk("INTEL ICH2/4 (82801AB/DB) not found.\n"); 
     234                return -ENODEV ; 
     235              } 
     236            else 
     237              { 
     238                printk("found Intel ICH4 (82801DB).\n"); 
     239              } 
     240          } 
     241        else 
     242          { 
     243            printk("found Intel ICH2 (82801AB).\n"); 
     244          } 
     245 
    205246        /* we need the bus pointer later */ 
    206247        bus = dev->bus; 
     
    230271 
    231272 
    232 void cleanup_module() 
     273void cleanup_module(void) 
    233274{ 
    234275        write_lock_irqsave(i801smbus_lock, i801smbus_lock_flags); 
     
    255296              "Burkhard Kohl <bku@buks.ipn.de>, " 
    256297              "Frank Bauer <frank.bauer@nikocity.de>, " 
    257               "and Mark Studebaker <mdsxyz123@yahoo.com>"); 
     298              "Mark Studebaker <mdsxyz123@yahoo.com>," 
     299              "and Klaus Woltereck <kw42@gmx.net>"); 
    258300MODULE_DESCRIPTION("i801smbus PCI Inserter"); 
    259301