Changeset 2427

Show
Ignore:
Timestamp:
04/09/04 20:41:30 (5 years ago)
Author:
khali
Message:

The pc87360 driver now support the PC87365 and PC87366 as well,

and can write to registers. Untested.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/doc/chips/SUMMARY

    r2403 r2427  
    150150        pc87363         -       -       2       2 pwm   no      yes (LPC) 
    151151        pc87364         -       -       3       3 pwm   no      yes (LPC) 
     152        pc87365         -       -       3       3 pwm   no      yes (LPC) 
     153        pc87366         -       -       3       3 pwm   no      yes (LPC) 
    152154 
    153155sis5595 
  • lm-sensors/trunk/doc/chips/pc87360

    r2420 r2427  
    4141the readings more range or accuracy. Not all RPM values can accurately be 
    4242represented, so some rounding is done. With a divider of 2, the lowest 
    43 representable value is around 2600 RPM
     43representable value is around 1900 RPM. See doc/fan-divisors for details
    4444 
    4545A different alarm is also triggered if the fan speed is too low to be 
     
    5959----------- 
    6060 
    61 This driver is read-only at the moment, and only supports fans. Since I 
    62 don't own a supported chip for testing, and the datasheet suggests that 
    63 you shouldn't change values once the monitoring has started (this is 
    64 normally done by the BIOS at boot time), I decided to play it safe. 
     61This driver only supports fans at the moment. 
     62 
     63The datasheets suggests that some values (fan mins, fan divisors) 
     64shouldn't be changed once the monitoring has started, but we ignore that 
     65recommendation. We'll reconsider if it actually causes trouble. 
  • lm-sensors/trunk/kernel/chips/pc87360.c

    r2420 r2427  
    103103#define FAN_FROM_REG(val,div)   ((val)==0?-1:(val)==255?0: \ 
    104104                                 960000/((val)*(div))) 
     105#define FAN_TO_REG(val,div)     ((val)<=0?255: \ 
     106                                 960000/((val)*(div))) 
    105107#define FAN_DIV_FROM_REG(val)   (1 << ((val >> 5) & 0x03)) 
    106 #define PWM_FROM_REG(val)      (val
     108#define FAN_DIV_TO_REG(val)    ((val)==8?0x60:(val)==4?0x40:(val)==1?0x00:0x20
    107109#define ALARM_FROM_REG(val)     ((val) & 0x07) 
    108110 
     
    130132 
    131133static int pc87360_read_value(struct i2c_client *client, u8 register); 
    132 #if 0 
    133134static int pc87360_write_value(struct i2c_client *client, u8 register, 
    134135                               u8 value); 
    135 #endif 
    136136static void pc87360_update_client(struct i2c_client *client); 
    137137static void pc87360_init_client(struct i2c_client *client); 
     
    178178 
    179179static ctl_table pc87360_dir_table_template[] = { /* PC87363 too */ 
    180         {PC87360_SYSCTL_FAN1, "fan1", NULL, 0, 0444, NULL, 
     180        {PC87360_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, 
    181181         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan}, 
    182         {PC87360_SYSCTL_FAN2, "fan2", NULL, 0, 0444, NULL, 
     182        {PC87360_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, 
    183183         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan}, 
    184         {PC87360_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0444, NULL, 
     184        {PC87360_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, 
    185185         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan_div}, 
    186186        {PC87360_SYSCTL_FAN1_STATUS, "fan1_status", NULL, 0, 0444, NULL, 
     
    188188        {PC87360_SYSCTL_FAN2_STATUS, "fan2_status", NULL, 0, 0444, NULL, 
    189189         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan_status}, 
    190         {PC87360_SYSCTL_PWM1, "pwm1", NULL, 0, 0444, NULL, 
     190        {PC87360_SYSCTL_PWM1, "pwm1", NULL, 0, 0644, NULL, 
    191191         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_pwm}, 
    192         {PC87360_SYSCTL_PWM2, "pwm2", NULL, 0, 0444, NULL, 
     192        {PC87360_SYSCTL_PWM2, "pwm2", NULL, 0, 0644, NULL, 
    193193         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_pwm}, 
    194194        {0} 
     
    196196 
    197197static ctl_table pc87364_dir_table_template[] = { /* PC87365 and PC87366 too */ 
    198         {PC87360_SYSCTL_FAN1, "fan1", NULL, 0, 0444, NULL, 
     198        {PC87360_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, 
    199199         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan}, 
    200         {PC87360_SYSCTL_FAN2, "fan2", NULL, 0, 0444, NULL, 
     200        {PC87360_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, 
    201201         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan}, 
    202         {PC87360_SYSCTL_FAN3, "fan3", NULL, 0, 0444, NULL, 
     202        {PC87360_SYSCTL_FAN3, "fan3", NULL, 0, 0644, NULL, 
    203203         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan}, 
    204         {PC87360_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0444, NULL, 
     204        {PC87360_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, 
    205205         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan_div}, 
    206206        {PC87360_SYSCTL_FAN1_STATUS, "fan1_status", NULL, 0, 0444, NULL, 
     
    210210        {PC87360_SYSCTL_FAN3_STATUS, "fan3_status", NULL, 0, 0444, NULL, 
    211211         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_fan_status}, 
    212         {PC87360_SYSCTL_PWM1, "pwm1", NULL, 0, 0444, NULL, 
     212        {PC87360_SYSCTL_PWM1, "pwm1", NULL, 0, 0644, NULL, 
    213213         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_pwm}, 
    214         {PC87360_SYSCTL_PWM2, "pwm2", NULL, 0, 0444, NULL, 
     214        {PC87360_SYSCTL_PWM2, "pwm2", NULL, 0, 0644, NULL, 
    215215         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_pwm}, 
    216         {PC87360_SYSCTL_PWM3, "pwm3", NULL, 0, 0444, NULL, 
     216        {PC87360_SYSCTL_PWM3, "pwm3", NULL, 0, 0644, NULL, 
    217217         &i2c_proc_real, &i2c_sysctl_real, NULL, &pc87360_pwm}, 
    218218        {0} 
     
    357357} 
    358358 
    359 #if 0 
    360359static int pc87360_write_value(struct i2c_client *client, u8 reg, u8 value) 
    361360{ 
     
    363362        return 0; 
    364363} 
    365 #endif 
    366364 
    367365static void pc87360_init_client(struct i2c_client *client) 
     
    410408                *nrels_mag = 2; 
    411409        } 
    412 
    413  
     410        /* We ignore National's recommendation */ 
     411        else if (operation == SENSORS_PROC_REAL_WRITE) { 
     412                if (*nrels_mag >= 1) { 
     413                        data->fan_min[nr] = FAN_TO_REG(results[0], 
     414                                                       FAN_DIV_FROM_REG(data->fan_status[nr])); 
     415                        pc87360_write_value(client, PC87360_REG_FAN_MIN(nr), 
     416                                            data->fan_min[nr]); 
     417                } 
     418        } 
     419
    414420 
    415421void pc87360_fan_div(struct i2c_client *client, int operation, 
     
    428434                *nrels_mag = data->fannr; 
    429435        } 
     436        /* We ignore National's recommendation */ 
     437        else if (operation == SENSORS_PROC_REAL_WRITE) { 
     438                for (i = 0; i < data->fannr && i < *nrels_mag; i++) { 
     439                        /* Preserve fan min */ 
     440                        int fan_min = FAN_FROM_REG(data->fan_min[i], 
     441                                                   FAN_DIV_FROM_REG(data->fan_status[i])); 
     442                        data->fan_status[i] = (data->fan_status[i] & 0x9F) 
     443                                            | FAN_DIV_TO_REG(results[i]); 
     444                        pc87360_write_value(client, PC87360_REG_FAN_STATUS(i), 
     445                                            data->fan_status[i]); 
     446                        data->fan_min[i] = FAN_TO_REG(fan_min, 
     447                                                      FAN_DIV_FROM_REG(data->fan_status[i])); 
     448                        pc87360_write_value(client, PC87360_REG_FAN_MIN(i), 
     449                                            data->fan_min[i]); 
     450                } 
     451        } 
    430452} 
    431453 
     
    440462        else if (operation == SENSORS_PROC_REAL_READ) { 
    441463                pc87360_update_client(client); 
    442                 results[0] = PWM_FROM_REG(data->pwm[nr])
     464                results[0] = data->pwm[nr]
    443465                *nrels_mag = 1; 
     466        } 
     467        else if (operation == SENSORS_PROC_REAL_WRITE) { 
     468                if (*nrels_mag >= 1) 
     469                { 
     470                        data->pwm[nr] = SENSORS_LIMIT(results[0], 0, 255); 
     471                        pc87360_write_value(client, PC87360_REG_PWM(nr), 
     472                                            data->pwm[nr]); 
     473                } 
    444474        } 
    445475} 
  • lm-sensors/trunk/lib/chips.c

    r2422 r2427  
    42594259                PC87360_SYSCTL_FAN2, VALUE(2), 0 }, 
    42604260    { SENSORS_PC87360_FAN1_MIN, "fan1_min", SENSORS_PC87360_FAN1, 
    4261                 SENSORS_PC87360_FAN1, R, PC87360_SYSCTL_FAN1, 
     4261                SENSORS_PC87360_FAN1, RW, PC87360_SYSCTL_FAN1, 
    42624262                VALUE(1), 0 }, 
    42634263    { SENSORS_PC87360_FAN2_MIN, "fan2_min", SENSORS_PC87360_FAN2, 
    4264                 SENSORS_PC87360_FAN2, R, PC87360_SYSCTL_FAN2, 
     4264                SENSORS_PC87360_FAN2, RW, PC87360_SYSCTL_FAN2, 
    42654265                VALUE(1), 0 }, 
    42664266    { SENSORS_PC87360_FAN1_DIV, "fan1_div", SENSORS_PC87360_FAN1, 
    4267                 NOMAP, R, PC87360_SYSCTL_FAN_DIV, VALUE(1), 0 }, 
     4267                NOMAP, RW, PC87360_SYSCTL_FAN_DIV, VALUE(1), 0 }, 
    42684268    { SENSORS_PC87360_FAN2_DIV, "fan2_div", SENSORS_PC87360_FAN2, 
    4269                 NOMAP, R, PC87360_SYSCTL_FAN_DIV, VALUE(2), 0 }, 
     4269                NOMAP, RW, PC87360_SYSCTL_FAN_DIV, VALUE(2), 0 }, 
    42704270    { SENSORS_PC87360_FAN1_STATUS, "fan1_status", SENSORS_PC87360_FAN1, 
    42714271                NOMAP, R, PC87360_SYSCTL_FAN1_STATUS, VALUE(1), 0 }, 
     
    42844284                PC87360_SYSCTL_FAN3, VALUE(2), 0 }, 
    42854285    { SENSORS_PC87360_FAN1_MIN, "fan1_min", SENSORS_PC87360_FAN1, 
    4286                 SENSORS_PC87360_FAN1, R, PC87360_SYSCTL_FAN1, 
     4286                SENSORS_PC87360_FAN1, RW, PC87360_SYSCTL_FAN1, 
    42874287                VALUE(1), 0 }, 
    42884288    { SENSORS_PC87360_FAN2_MIN, "fan2_min", SENSORS_PC87360_FAN2, 
    4289                 SENSORS_PC87360_FAN2, R, PC87360_SYSCTL_FAN2, 
     4289                SENSORS_PC87360_FAN2, RW, PC87360_SYSCTL_FAN2, 
    42904290                VALUE(1), 0 }, 
    42914291    { SENSORS_PC87360_FAN3_MIN, "fan3_min", SENSORS_PC87360_FAN3, 
    4292                 SENSORS_PC87360_FAN3, R, PC87360_SYSCTL_FAN3, 
     4292                SENSORS_PC87360_FAN3, RW, PC87360_SYSCTL_FAN3, 
    42934293                VALUE(1), 0 }, 
    42944294    { SENSORS_PC87360_FAN1_DIV, "fan1_div", SENSORS_PC87360_FAN1, 
    4295                 NOMAP, R, PC87360_SYSCTL_FAN_DIV, VALUE(1), 0 }, 
     4295                NOMAP, RW, PC87360_SYSCTL_FAN_DIV, VALUE(1), 0 }, 
    42964296    { SENSORS_PC87360_FAN2_DIV, "fan2_div", SENSORS_PC87360_FAN2, 
    4297                 NOMAP, R, PC87360_SYSCTL_FAN_DIV, VALUE(2), 0 }, 
     4297                NOMAP, RW, PC87360_SYSCTL_FAN_DIV, VALUE(2), 0 }, 
    42984298    { SENSORS_PC87360_FAN3_DIV, "fan3_div", SENSORS_PC87360_FAN3, 
    4299                 NOMAP, R, PC87360_SYSCTL_FAN_DIV, VALUE(2), 0 }, 
     4299                NOMAP, RW, PC87360_SYSCTL_FAN_DIV, VALUE(3), 0 }, 
    43004300    { SENSORS_PC87360_FAN1_STATUS, "fan1_status", SENSORS_PC87360_FAN1, 
    43014301                NOMAP, R, PC87360_SYSCTL_FAN1_STATUS, VALUE(1), 0 }, 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r2419 r2427  
    13741374      { 
    13751375        name => "Nat. Semi. PC87365 Super IO Sensors", 
    1376         driver => "to-be-written", 
     1376        driver => "pc87360", 
    13771377        devid => 0xe5, 
    13781378        logdev => 0x09, # fans; voltages at 0x0d; temps at 0x0e 
     
    13801380      { 
    13811381        name => "Nat. Semi. PC87366 Super IO Sensors", 
    1382         driver => "to-be-written", 
     1382        driver => "pc87360", 
    13831383        devid => 0xe9, 
    13841384        logdev => 0x09, # fans; voltages at 0x0d; temps at 0x0e