Show
Ignore:
Timestamp:
04/20/04 19:42:48 (9 years ago)
Author:
khali
Message:

(Axel Thimm) Support 82801BAM and 82801DBM.

Some fixes and cleanups.

Files:
1 modified

Legend:

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

    r1975 r2459  
    22 * p4b_smbus.c 
    33 * 
    4  * Initialize the I801SMBus device on ASUS P4B Bords 
     4 * Initialize the SMBus device on ICH2/2-M/4/4-M (82801BA/BAM/DB/DBM) 
    55 */ 
    66/* 
     
    4242 * 
    4343 * June 21, 2002, added support for the ICH4, code clean up -- Klaus 
     44 * 
     45 * Apr 13, 2004, modified for ICH4-M (82801DBM) -- Axel Thimm <Axel.Thimm@ATrpms.net> 
     46 *               bugfix: register F2/bit 8 on ICH2* is bit 0 on ICH4* 
    4447 */ 
    4548 
     
    8891 
    8992#define ICH2 0x2440 
     93#define ICH2_M 0x244c 
    9094#define ICH2_SMBUS 0x2443 
    9195 
    9296#define ICH4 0x24c0 
     97#define ICH4_M 0x24cc 
    9398#define ICH4_SMBUS 0x24c3 
    9499 
     
    103108/*  
    104109 * Checks whether SMBus is enabled and turns it on in case they are not.  
    105  * It's done by clearing Bit 8 and 3 in i801 config space F2h, PCI-Device 0x8086:0x2440(ICH2)/0x24c0(ICH4) 
     110 * It's done by modifying the i801 function disable register, F2h. 
     111 * ICH2(-M): PCI-Device 0x8086:0x2440(0x244c) 
     112 *           Bit 3: Disables SMBus Host Controller function. 
     113 *           Bit 8: allows SMBus I/O space to be accessible when Bit 3 is set. 
     114 * ICH4(-M): PCI-Device 0x8086:0x24c0(0x24cc) 
     115 *           Bit 3: Disables SMBus Host Controller function. 
     116 *           Bit 0: allows SMBus I/O space to be accessible when Bit 3 is set. 
    106117 */ 
    107118static int 
    108 i801smbus_enable(struct pci_dev *dev){ 
     119i801smbus_enable(struct pci_dev *dev, u16 testmask, u16 mask){ 
    109120        u16  val   = 0; 
    110121 
    111122        pci_read_config_word(dev, 0xF2, &val); 
    112123        DBG("i801smbus: i801smbus config byte reading 0x%X.\n", val); 
    113         if (val & 0x008) { 
    114                 pci_write_config_word(dev, 0xF2, val & 0xfef7); 
     124        if (val & testmask) { 
     125                pci_write_config_word(dev, 0xF2, val & mask); 
    115126                pci_read_config_word(dev, 0xF2, &val); 
    116                 if(val & 0x008)  
     127                if(val & testmask)  
    117128                  { 
    118129                    DBG("i801smbus: i801smbus config byte locked:-(\n"); 
     
    186197        struct pci_dev *dev = NULL; 
    187198        int ret = 0; 
     199        u16 testmask = 0, mask = 0; 
    188200 
    189201        DBG("i801smbus: init_module().\n"); 
     
    213225         
    214226        /* Are we operating a i801 chipset */ 
    215         dev = pci_find_device(0x8086, ICH2, NULL); 
    216         if (NULL == dev)  
    217           { 
    218             dev = pci_find_device(0x8086, ICH4, NULL); 
    219             if (NULL == dev)  
    220               { 
    221                 printk("i801smbus: INTEL ICH2/4 (82801AB/DB) not found.\n"); 
    222                 return -ENODEV ; 
    223               } 
    224             else 
    225               { 
    226                 printk("i801smbus: found Intel ICH4 (82801DB).\n"); 
    227               } 
     227        if ((dev = pci_find_device(0x8086, ICH2, NULL)) != 0) 
     228          { 
     229            printk("i801smbus: found Intel ICH2 (82801BA).\n"); 
     230            testmask = 0x008; 
     231            mask = 0xfef7; 
     232          } 
     233        else if ((dev = pci_find_device(0x8086, ICH2_M, NULL)) != 0) 
     234          { 
     235            printk("i801smbus: found Intel ICH2-M (82801BAM).\n"); 
     236            testmask = 0x008; 
     237            mask = 0xfef7; 
     238          } 
     239        else if ((dev = pci_find_device(0x8086, ICH4, NULL)) != 0) 
     240          { 
     241            printk("i801smbus: found Intel ICH4 (82801DB).\n"); 
     242            testmask = 0x008; 
     243            mask = 0xfff6; 
     244          } 
     245        else if ((dev = pci_find_device(0x8086, ICH4_M, NULL)) != 0) 
     246          { 
     247            printk("i801smbus: found Intel ICH4-M (82801DBM).\n"); 
     248            testmask = 0x008; 
     249            mask = 0xfff6; 
    228250          } 
    229251        else 
    230252          { 
    231             printk("i801smbus: found Intel ICH2 (82801AB).\n"); 
     253            printk("i801smbus: INTEL ICH2/2-M/4/4-M (82801BA/BAM/DB/DBM) not found.\n"); 
     254            return -ENODEV ; 
    232255          } 
    233256 
     
    236259 
    237260 
    238         if ( (ret = i801smbus_enable(dev)) )  
     261        if ( (ret = i801smbus_enable(dev, testmask, mask)) )  
    239262          { 
    240263            printk("i801smbus: Unable to turn on i801smbus device - sorry!\n");