Changeset 1077

Show
Ignore:
Timestamp:
04/21/01 23:57:40 (12 years ago)
Author:
mds
Message:

add support for force_addr to i2c-sis5595.

Also automatically enable ACPI if it was disabled.
Forcing address doesn't work on my test system, but hey,
at least I tried to test it...

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r1076 r1077  
    3737  Module i2c-i801: Chip detection cleanup 
    3838  Module i2c-i810: Fixed i2c_i810_init() not found in patched kernel 
     39  Module i2c-sis5595: Allow force_addr=0xaddr; enable if not enabled. 
    3940  Module lm78: Recognize chipid=0x20 
    4041  Module lm87: Fix in0, in1 (2.5V and Vccp1) calculations 
  • lm-sensors/trunk/kernel/busses/i2c-sis5595.c

    r943 r1077  
    4040#include <linux/init.h> 
    4141 
     42/* Length of ISA address segment */ 
     43#define SIS5595_EXTENT 8 
    4244/* SIS5595 SMBus registers */ 
    4345#define SMB_STS_LO 0x00 
     
    5860#define SMB_INDEX  0x38 
    5961#define SMB_DAT    0x39 
     62#define SIS5595_ENABLE_REG 0x40 
    6063#define ACPI_BASE  0x90 
    6164 
     
    7275 
    7376/* insmod parameters */ 
     77 
     78/* If force_addr is set to anything different from 0, we forcibly enable 
     79   the device at the given address. */ 
     80static int force_addr = 0; 
     81MODULE_PARM(force_addr, "i"); 
     82MODULE_PARM_DESC(force_addr, 
     83                 "Initialize the base address of the i2c controller"); 
    7484 
    7585#ifdef MODULE 
     
    140150int sis5595_setup(void) 
    141151{ 
    142         int error_return = 0; 
    143  
     152        u16 a; 
     153        u8 val; 
    144154        struct pci_dev *SIS5595_dev; 
    145155 
     
    147157        if (pci_present() == 0) { 
    148158                printk("i2c-sis5595.o: Error: No PCI-bus found!\n"); 
    149                 error_return = -ENODEV; 
    150                 goto END; 
     159                return -ENODEV; 
    151160        } 
    152161 
     
    157166                                            SIS5595_dev))) { 
    158167                printk("i2c-sis5595.o: Error: Can't detect SIS5595!\n"); 
    159                 error_return = -ENODEV; 
    160                 goto END; 
     168                return -ENODEV; 
    161169        } 
    162170 
    163171/* Determine the address of the SMBus areas */ 
    164172        pci_read_config_word(SIS5595_dev, ACPI_BASE, &sis5595_base); 
    165         if(sis5595_base == 0) { 
    166                 printk("i2c-sis5595.o: ACPI base address uninitialized - upgrade BIOS?\n"); 
    167                 error_return = -ENODEV; 
    168                 goto END; 
    169         } 
    170  
     173        if(sis5595_base == 0 && force_addr == 0) { 
     174                printk("i2c-sis5595.o: ACPI base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); 
     175                return -ENODEV; 
     176        } 
     177 
     178        if(force_addr) 
     179                sis5595_base = force_addr & ~(SIS5595_EXTENT - 1); 
    171180#ifdef DEBUG 
    172181        printk("ACPI Base address: %04x\n", sis5595_base); 
     
    179188                     sis5595_base + SMB_INDEX, 
    180189                     sis5595_base + SMB_INDEX + 1); 
    181                 error_return = -ENODEV; 
    182                 goto END; 
     190                return -ENODEV; 
     191        } 
     192 
     193        if(force_addr) { 
     194                printk("i2c-sis5595.o: forcing ISA address 0x%04X\n", sis5595_base); 
     195                if (PCIBIOS_SUCCESSFUL != 
     196                    pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base)) 
     197                        return -ENODEV; 
     198                if (PCIBIOS_SUCCESSFUL != 
     199                    pci_read_config_word(SIS5595_dev, ACPI_BASE, &a)) 
     200                        return -ENODEV; 
     201                if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) { 
     202                        /* doesn't work for some chips! */ 
     203                        printk("i2c-sis5595.o: force address failed - not supported?\n"); 
     204                        return -ENODEV; 
     205                } 
     206        } 
     207 
     208        if (PCIBIOS_SUCCESSFUL != 
     209            pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)) 
     210                return -ENODEV; 
     211        if((val & 0x80) == 0) { 
     212                printk("sis5595.o: enabling ACPI\n"); 
     213                if (PCIBIOS_SUCCESSFUL != 
     214                    pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, 
     215                                      val | 0x80)) 
     216                        return -ENODEV; 
     217                if (PCIBIOS_SUCCESSFUL != 
     218                    pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)) 
     219                        return -ENODEV; 
     220                if((val & 0x80) == 0) { /* doesn't work for some chips? */ 
     221                        printk("sis5595.o: ACPI enable failed - not supported?\n"); 
     222                        return -ENODEV; 
     223                } 
    183224        } 
    184225 
    185226        /* Everything is happy, let's grab the memory and set things up. */ 
    186227        request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus"); 
    187  
    188       END: 
    189         return error_return; 
     228        return(0); 
    190229} 
    191230