Changeset 1133

Show
Ignore:
Timestamp:
06/17/01 23:11:59 (12 years ago)
Author:
mds
Message:

add force_addr to i2c-ali15x3

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r1131 r1133  
    1717 
    1818----------------------------------------------------------------------------- 
     19 
     202.6.1 (2001????) 
     21  Module i2c-ali15x3: Allow force_addr=0xaddr; enable if not enabled. 
    1922 
    20232.6.0 (20010612) 
  • lm-sensors/trunk/kernel/busses/i2c-ali15x3.c

    r949 r1133  
    125125#define ALI15X3_STS_ERR         0xE0    /* all the bad error bits */ 
    126126 
     127 
     128/* If force_addr is set to anything different from 0, we forcibly enable 
     129   the device at the given address. */ 
     130static int force_addr = 0; 
     131MODULE_PARM(force_addr, "i"); 
     132MODULE_PARM_DESC(force_addr, 
     133                 "Initialize the base address of the i2c controller"); 
    127134 
    128135#ifdef MODULE 
     
    181188int ali15x3_setup(void) 
    182189{ 
    183         int error_return = 0; 
     190        u16 a; 
    184191        unsigned char temp; 
    185192 
     
    189196        if (pci_present() == 0) { 
    190197                printk("i2c-ali15x3.o: Error: No PCI-bus found!\n"); 
    191                 error_return = -ENODEV; 
    192                 goto END; 
     198                return -ENODEV; 
    193199        } 
    194200 
     
    199205        if (ALI15X3_dev == NULL) { 
    200206                printk("i2c-ali15x3.o: Error: Can't detect ali15x3!\n"); 
    201                 error_return = -ENODEV; 
    202                 goto END; 
     207                return -ENODEV; 
    203208        } 
    204209 
     
    223228        pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba); 
    224229        ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1)); 
    225         if (ali15x3_smba == 0) { 
    226                 printk 
    227                     ("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS?\n"); 
    228                 error_return = -ENODEV; 
    229         } 
    230  
    231         if (error_return == -ENODEV) 
    232                 goto END; 
     230        if (ali15x3_smba == 0 && force_addr == 0) { 
     231                printk 
     232                    ("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); 
     233                return -ENODEV; 
     234        } 
     235 
     236        if(force_addr) 
     237                ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); 
    233238 
    234239        if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) { 
     
    236241                    ("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n", 
    237242                     ali15x3_smba); 
    238                 error_return = -ENODEV; 
    239         } 
    240  
    241         if (error_return == -ENODEV) 
    242                 goto END; 
    243  
     243                return -ENODEV; 
     244        } 
     245 
     246        if(force_addr) { 
     247                printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba); 
     248                if (PCIBIOS_SUCCESSFUL != 
     249                    pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba)) 
     250                        return -ENODEV; 
     251                if (PCIBIOS_SUCCESSFUL != 
     252                    pci_read_config_word(ALI15X3_dev, SMBBA, &a)) 
     253                        return -ENODEV; 
     254                if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { 
     255                        /* make sure it works */ 
     256                        printk("i2c-ali15x3.o: force address failed - not supported?\n"); 
     257                        return -ENODEV; 
     258                } 
     259        } 
    244260/* check if whole device is enabled */ 
    245261        pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp); 
    246262        if ((temp & 1) == 0) { 
    247                 printk 
    248                     ("SMBUS: Error: SMB device not enabled - upgrade BIOS?\n"); 
    249                 error_return = -ENODEV; 
    250                 goto END; 
     263                printk("i2c-ali15x3: enabling SMBus device\n"); 
     264                pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01); 
    251265        } 
    252266 
     
    254268        pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp); 
    255269        if ((temp & 1) == 0) { 
    256                 printk 
    257                     ("SMBUS: Error: Host SMBus controller not enabled - upgrade BIOS?\n"); 
    258                 error_return = -ENODEV; 
    259                 goto END; 
     270                printk("i2c-ali15x3: enabling SMBus controller\n"); 
     271                pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01); 
    260272        } 
    261273 
     
    279291#endif                          /* DEBUG */ 
    280292 
    281       END: 
    282         return error_return; 
     293        return 0; 
    283294} 
    284295