Changeset 2479

Show
Ignore:
Timestamp:
04/26/04 18:58:52 (9 years ago)
Author:
khali
Message:

Retrieve fans configuration from Super-I/O space; export

pwm_enable (read-only); handle fan invert.
Fix temp_crit being read from temp_min register.

Files:
1 modified

Legend:

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

    r2477 r2479  
    4646static u8 devid; 
    4747static unsigned int extra_isa[] = { 0x0000, 0x0000, 0x0000 }; 
     48static u16 fanconf[2]; 
    4849 
    4950SENSORS_INSMOD_5(pc87360, pc87363, pc87364, pc87365, pc87366); 
     
    106107#define FAN_STATUS_FROM_REG(val)        ((val) & 0x07) 
    107108 
     109#define FAN_CONFIG_MONITOR(val,nr)      (((val) >> (2 + nr * 3)) & 1) 
     110#define FAN_CONFIG_CONTROL(val,nr)      (((val) >> (3 + nr * 3)) & 1) 
     111#define FAN_CONFIG_INVERT(val,nr)       (((val) >> (4 + nr * 3)) & 1) 
     112 
     113#define PWM_FROM_REG(val,inv)           ((inv) ? 255 - (val) : (val)) 
     114#define PWM_TO_REG(val,inv)             (((val) < 0) ? ((inv) ? 255 : 0) : \ 
     115                                         ((val) > 255) ? ((inv) ? 0 : 255) : \ 
     116                                         (inv) ? 255 - (val) : (val)) 
     117 
    108118/* 
    109119 * Voltage registers and conversions 
     
    135145#define PC87365_REG_TEMP_MIN            0x0D 
    136146#define PC87365_REG_TEMP_MAX            0x0C 
    137 #define PC87365_REG_TEMP_CRIT           0x0D 
     147#define PC87365_REG_TEMP_CRIT           0x0E 
    138148#define PC87365_REG_TEMP_STATUS         0x0A 
    139149#define PC87365_REG_TEMP_ALARMS         0x00 
    140150 
    141 #define TEMP_FROM_REG(val)              ((val)&0x80 ? (val) : (val) - 128) 
    142 #define TEMP_TO_REG(val)                ((val)<-128?0x80:(val)>127?0x7F: \ 
    143                                          (val)<0?(val)+0x80:(val)) 
     151#define TEMP_FROM_REG(val)              ((val)&0x80 ? (val) - 0x100 : (val)) 
     152#define TEMP_TO_REG(val)                ((val)<-55 ? 201 : (val)>127 ? 0x7F : \ 
     153                                         (val)<0 ? (val) + 0x100 : (val)) 
    144154#define TEMP_STATUS_FROM_REG(val)       ((val) & 0xFF) 
    145155 
     
    160170        u8 fan_status[3];       /* Register value */ 
    161171        u8 pwm[3];              /* Register value */ 
     172        u16 fan_conf[2];        /* Configuration register values, combined */ 
    162173 
    163174        u8 in[11];              /* Register value */ 
     
    438449                address[i] = val; 
    439450 
     451                if (i==0) { /* Fans */ 
     452                        fanconf[0] = superio_inb(0x70) 
     453                                   | (superio_inb(0x71) << 8); 
     454                         
    440455#ifdef DEBUG 
    441                 if (i==0) { /* Fans */ 
    442                         val = superio_inb(0x70) 
    443                             | (superio_inb(0x71) << 8); 
    444                          
    445456                        printk(KERN_DEBUG "pc87360.o: Fan 1: mon=%d " 
    446                                "ctrl=%d inv=%d\n", (val>>2)&1, (val>>3)&1, 
    447                                (val>>4)&1); 
     457                               "ctrl=%d inv=%d\n", (fanconf[0]>>2)&1, 
     458                               (fanconf[0]>>3)&1, (fanconf[0]>>4)&1); 
    448459                        printk(KERN_DEBUG "pc87360.o: Fan 2: mon=%d " 
    449                                "ctrl=%d inv=%d\n", (val>>5)&1, (val>>6)&1, 
    450                                (val>>7)&1); 
     460                               "ctrl=%d inv=%d\n", (fanconf[0]>>5)&1, 
     461                               (fanconf[0]>>6)&1, (fanconf[0]>>7)&1); 
    451462                        printk(KERN_DEBUG "pc87360.o: Fan 3: mon=%d " 
    452                                "ctrl=%d inv=%d\n", (val>>8)&1, (val>>9)&1, 
    453                                (val>>10)&1); 
     463                               "ctrl=%d inv=%d\n", (fanconf[0]>>8)&1, 
     464                               (fanconf[0]>>9)&1, (fanconf[0]>>10)&1); 
    454465                } 
    455466#endif 
     
    526537        } 
    527538 
     539        /* Retrieve the fans configuration from Super-I/O space */ 
     540        data->fan_conf[0] = fanconf[0]; 
     541 
    528542        for (i = 0; i < 3; i++) { 
    529543                if ((data->address[i] = extra_isa[i])) { 
     
    771785        else if (operation == SENSORS_PROC_REAL_READ) { 
    772786                pc87360_update_client(client); 
    773                 results[0] = data->pwm[nr]; 
    774                 *nrels_mag = 1; 
     787                results[0] = PWM_FROM_REG(data->pwm[nr], 
     788                             FAN_CONFIG_INVERT(data->fan_conf[0], nr)); 
     789                results[1] = FAN_CONFIG_CONTROL(data->fan_conf[0], nr); 
     790                *nrels_mag = 2; 
    775791        } 
    776792        else if (operation == SENSORS_PROC_REAL_WRITE) { 
    777793                if (*nrels_mag >= 1) 
    778794                { 
    779                         data->pwm[nr] = SENSORS_LIMIT(results[0], 0, 255); 
     795                        data->pwm[nr] = PWM_TO_REG(results[0], 
     796                                        FAN_CONFIG_INVERT(data->fan_conf[0], nr)); 
    780797                        pc87360_write_value(data, 0, PC87360_REG_PWM(nr), 
    781798                                            data->pwm[nr]);