Changeset 2507

Show
Ignore:
Timestamp:
05/08/04 12:14:51 (9 years ago)
Author:
khali
Message:

Do not include SENSORS_INSMOD stuff.

Rework chip initialization.
New module parameter: init.
Honor pwm invert bits again.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/pc87360.c

    r2506 r2507  
    4444static unsigned int normal_isa[] = { 0x0000, SENSORS_ISA_END }; 
    4545static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; 
     46static struct i2c_force_data forces[] = {{NULL}}; 
    4647static u8 devid; 
    4748static unsigned int extra_isa[] = { 0x0000, 0x0000, 0x0000 }; 
    4849static u16 fanconf[2]; 
    4950 
    50 SENSORS_INSMOD_5(pc87360, pc87363, pc87364, pc87365, pc87366); 
     51enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; 
     52static struct i2c_address_data addr_data = { 
     53        .normal_i2c             = normal_i2c, 
     54        .normal_i2c_range       = normal_i2c_range, 
     55        .normal_isa             = normal_isa, 
     56        .normal_isa_range       = normal_isa_range, 
     57        .probe                  = normal_i2c,           /* cheat */ 
     58        .probe_range            = normal_i2c_range,     /* cheat */ 
     59        .ignore                 = normal_i2c,           /* cheat */ 
     60        .ignore_range           = normal_i2c_range,     /* cheat */ 
     61        .forces                 = forces, 
     62}; 
     63 
     64static int init = 1; 
     65MODULE_PARM(init, "i"); 
     66MODULE_PARM_DESC(init, 
     67        "Chip initialization level:\n" 
     68        " 0: None\n" 
     69        "*1: Forcibly enable internal voltage and temperature channels, except in9\n" 
     70        " 2: Forcibly enable all voltage and temperature channels, except in9\n" 
     71        " 3: Forcibly enable all voltage and temperature channels, including in9"); 
    5172 
    5273/* 
     
    108129#define PC87360_REG_FAN_STATUS(nr)      (0x08 + 3 * (nr)) 
    109130 
    110 #define FAN_FROM_REG(val,div)           ((val)==0?-1:(val)==255?0: \ 
     131#define FAN_FROM_REG(val,div)           ((val)==0?0: \ 
    111132                                         480000/((val)*(div))) 
    112133#define FAN_TO_REG(val,div)             ((val)<=0?255: \ 
     
    121142#define FAN_CONFIG_INVERT(val,nr)       (((val) >> (4 + nr * 3)) & 1) 
    122143 
    123 #define PWM_FROM_REG(val)               (val) 
    124 #define PWM_TO_REG(val)                 ((val) < 0 ? 0 : \ 
    125                                          (val) > 255 ? 255 : (val)) 
     144#define PWM_FROM_REG(val,inv)           ((inv) ? 255 - (val) : (val)) 
     145static inline u8 PWM_TO_REG(int val, int inv) 
     146{ 
     147        if (inv) 
     148                val = 255 - val; 
     149        if (val < 0) 
     150                return 0; 
     151        if (val > 255) 
     152                return 255; 
     153        return val; 
     154} 
    126155 
    127156/* 
     
    574603        } 
    575604 
    576         pc87360_init_client(new_client); 
     605        if (init >= 0) 
     606                pc87360_init_client(new_client); 
    577607 
    578608        if ((i = i2c_register_entry((struct i2c_client *) new_client, 
     
    650680{ 
    651681        struct pc87360_data *data = client->data; 
     682        int i; 
     683        const u8 init_in[11] = { 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 1 }; 
     684        const u8 init_temp[3] = { 2, 2, 1 }; 
    652685        u8 reg; 
    653686 
    654         if (data->innr >= 10) { 
    655                 /* Forcibly enable in7 (Vsb) */ 
    656                 reg = pc87360_read_value(data, LD_IN, 7, 
    657                                          PC87365_REG_IN_STATUS); 
    658                 if (!(reg & 0x01)) { 
     687        for (i=0; i<data->innr; i++) { 
     688                if (init >= init_in[i]) { 
     689                        /* Forcibly enable voltage channel */ 
     690                        reg = pc87360_read_value(data, LD_IN, i, 
     691                                                 PC87365_REG_IN_STATUS); 
     692                        if (!(reg & 0x01)) { 
    659693#ifdef DEBUG 
    660                         printk(KERN_DEBUG "pc87360.o: Forcibly enabling " 
    661                                "in7 (Vsb)\n"); 
     694                                printk(KERN_DEBUG "pc87360.o: Forcibly " 
     695                                       "enabling in%d\n", i); 
    662696#endif 
    663                         pc87360_write_value(data, LD_IN, 7, 
    664                                             PC87365_REG_IN_STATUS, 
    665                                             (reg & 0x68) | 0x87); 
    666                 } 
    667                 /* Forcibly enable in8 (Vdd) */ 
    668                 reg = pc87360_read_value(data, LD_IN, 8, 
    669                                          PC87365_REG_IN_STATUS); 
    670                 if (!(reg & 0x01)) { 
    671                         pc87360_write_value(data, LD_IN, 8, 
    672                                             PC87365_REG_IN_STATUS, 
    673                                             (reg & 0x68) | 0x87); 
     697                                pc87360_write_value(data, LD_IN, i, 
     698                                                    PC87365_REG_IN_STATUS, 
     699                                                    (reg & 0x68) | 0x87); 
     700                        } 
     701 
     702                } 
     703        } 
     704 
     705        for (i=0; i<data->tempnr; i++) { 
     706                if (init >= init_temp[i]) { 
     707                        /* Forcibly enable temperature channel */ 
     708                        reg = pc87360_read_value(data, LD_TEMP, i, 
     709                                                 PC87365_REG_TEMP_STATUS); 
     710                        if (!(reg & 0x01)) { 
    674711#ifdef DEBUG 
    675                         printk(KERN_DEBUG "pc87360.o: Forcibly enabling " 
    676                                "in8 (Vdd)\n"); 
     712                                printk(KERN_DEBUG "pc87360.o: Forcibly " 
     713                                       "enabling temp%d\n", i+1); 
    677714#endif 
    678                 } 
    679                 /* Forcibly enable in10 (AVdd) */ 
    680                 reg = pc87360_read_value(data, LD_IN, 10, 
    681                                          PC87365_REG_IN_STATUS); 
    682                 if (!(reg & 0x01)) { 
    683                         pc87360_write_value(data, LD_IN, 10, 
    684                                             PC87365_REG_IN_STATUS, 
    685                                             (reg & 0x68) | 0x87); 
    686 #ifdef DEBUG 
    687                         printk(KERN_DEBUG "pc87360.o: Forcibly enabling " 
    688                                "in10 (AVdd)\n"); 
    689 #endif 
    690                 } 
    691         } 
    692         if (data->tempnr >= 3) { 
    693                 /* Forcibly enable temp3 (PC87366 temperature) */ 
    694                 reg = pc87360_read_value(data, LD_TEMP, 2, 
    695                                          PC87365_REG_TEMP_STATUS); 
    696                 if (!(reg & 0x01)) { 
    697                         pc87360_write_value(data, LD_TEMP, 2, 
    698                                             PC87365_REG_TEMP_STATUS, 0xCF); 
    699 #ifdef DEBUG 
    700                         printk(KERN_DEBUG "pc87360.o: Forcibly enabling " 
    701                                "temp3 (PC87366 temperature)\n"); 
    702 #endif 
     715                                pc87360_write_value(data, LD_TEMP, i, 
     716                                                    PC87365_REG_TEMP_STATUS, 
     717                                                    0xCF); 
     718                        } 
    703719                } 
    704720        } 
     
    893909        else if (operation == SENSORS_PROC_REAL_READ) { 
    894910                pc87360_update_client(client); 
    895                 results[0] = PWM_FROM_REG(data->pwm[nr]); 
     911                results[0] = PWM_FROM_REG(data->pwm[nr], 
     912                             FAN_CONFIG_INVERT(data->fan_conf[0], nr)); 
    896913                results[1] = FAN_CONFIG_CONTROL(data->fan_conf[0], nr); 
    897914                *nrels_mag = 2; 
     
    906923                               nr+1, results[0]); 
    907924#endif 
    908                         data->pwm[nr] = PWM_TO_REG(results[0]); 
     925                        data->pwm[nr] = PWM_TO_REG(results[0], 
     926                                        FAN_CONFIG_INVERT(data->fan_conf[0], nr)); 
    909927#ifdef DEBUG 
    910928                        printk(KERN_DEBUG "pc87360.o: Writing %u to register %u\n",