Changeset 314

Show
Ignore:
Timestamp:
03/14/99 22:53:22 (14 years ago)
Author:
mds
Message:

added pwm1-4 for 782d, pwm1-2 for 783s. untested.

Location:
lm-sensors/trunk/kernel
Files:
2 modified

Legend:

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

    r313 r314  
    2929    w83783s     5-6     3       2       1-2     0x40    yes     no 
    3030 
    31     To do: 
    32      782d/783s PWM enable, clock select, duty cycle 
    33      782d beep 3 register 
    34      782d programmable pins 
    35      783s pin is programmable for -5V or temp1; defaults to -5V, 
    36           no control in driver so temp1 doesn't work. 
    37      783s temp2 (labeled as temp1 in data sheet) at different location 
    38           than 781d/782d, not implemented yet. 
    3931*/ 
    4032 
     
    10496#define W83781D_REG_PIN 0x4B 
    10597 
     98/* PWM 782D (1-4) and 783S (1-2) only */ 
     99#define W83781D_REG_PWM1 0x5B           /* 782d and 783s datasheets disagree on which is which. */ 
     100#define W83781D_REG_PWM2 0x5A           /* We follow 782d datasheet convention here */ 
     101#define W83781D_REG_PWM3 0x5E 
     102#define W83781D_REG_PWM4 0x5F 
     103#define W83781D_REG_PWMCLK12 0x5C 
     104#define W83781D_REG_PWMCLK34 0x45C 
     105const u8 regpwm[] = {W83781D_REG_PWM1, W83781D_REG_PWM2, W83781D_REG_PWM3, W83781D_REG_PWM4}; 
     106#define W83781D_REG_PWM(nr) (regpwm[(nr) - 1]) 
     107 
    106108#define W83781D_WCHIPID 0x10 
    107109#define W83782D_WCHIPID 0x30 
     
    126128                           (val)>=0x06?0:205-(val)*5) 
    127129#define ALARMS_FROM_REG(val) (val) 
     130#define PWM_FROM_REG(val) (val) 
     131#define PWM_TO_REG(val) ((val) & 0xff) 
    128132#define BEEPS_FROM_REG(val) (val) 
    129133#define BEEPS_TO_REG(val) ((val) & 0xffff) 
     
    282286         u8 beep_enable;             /* Boolean */ 
    283287         u8 wchipid;                 /* Register value */ 
     288         u8 pwm[4];                  /* Register value */                                
    284289}; 
    285290 
     
    325330static void w83781d_fan_div(struct i2c_client *client, int operation, 
    326331                            int ctl_name, int *nrels_mag, long *results); 
     332static void w83781d_pwm(struct i2c_client *client, int operation, 
     333                        int ctl_name, int *nrels_mag, long *results); 
    327334 
    328335/* I choose here for semi-static W83781D allocation. Complete dynamic 
     
    431438  { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, 
    432439    &sensors_sysctl_real, NULL, &w83781d_beep }, 
     440  { W83781D_SYSCTL_PWM1, "pwm1", NULL, 0, 0644, NULL, &sensors_proc_real, 
     441    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
     442  { W83781D_SYSCTL_PWM2, "pwm2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     443    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
     444  { W83781D_SYSCTL_PWM3, "pwm3", NULL, 0, 0644, NULL, &sensors_proc_real, 
     445    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
     446  { W83781D_SYSCTL_PWM4, "pwm4", NULL, 0, 0644, NULL, &sensors_proc_real, 
     447    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
    433448  { 0 } 
    434449}; 
     
    466481  { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, 
    467482    &sensors_sysctl_real, NULL, &w83781d_beep }, 
     483  { W83781D_SYSCTL_PWM1, "pwm1", NULL, 0, 0644, NULL, &sensors_proc_real, 
     484    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
     485  { W83781D_SYSCTL_PWM2, "pwm2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     486    &sensors_sysctl_real, NULL, &w83781d_pwm }, 
    468487  { 0 } 
    469488}; 
     
    10331052      data->fan_min[i-1] = w83781d_read_value(client,W83781D_REG_FAN_MIN(i)); 
    10341053    } 
     1054    if(data->wchipid != W83781D_WCHIPID) { 
     1055      for (i = 1; i <= 4; i++) { 
     1056        data->pwm[i-1] = w83781d_read_value(client,W83781D_REG_PWM(i)); 
     1057        if(data->wchipid == W83783S_WCHIPID  &&  i == 2) 
     1058          break; 
     1059      } 
     1060    } 
    10351061    data->temp = w83781d_read_value(client,W83781D_REG_TEMP); 
    10361062    data->temp_over = w83781d_read_value(client,W83781D_REG_TEMP_OVER); 
     
    12741300} 
    12751301 
     1302void w83781d_pwm(struct i2c_client *client, int operation, int ctl_name, 
     1303                 int *nrels_mag, long *results) 
     1304{ 
     1305  struct w83781d_data *data = client->data; 
     1306  int nr = 1 + ctl_name - W83781D_SYSCTL_PWM1; 
     1307 
     1308  if (operation == SENSORS_PROC_REAL_INFO) 
     1309    *nrels_mag = 0; 
     1310  else if (operation == SENSORS_PROC_REAL_READ) { 
     1311    w83781d_update_client(client); 
     1312    results[0] = PWM_FROM_REG(data->pwm[nr-1]); 
     1313    *nrels_mag = 1; 
     1314  } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     1315    if (*nrels_mag >= 1) { 
     1316      data->pwm[nr-1] = PWM_TO_REG(results[0]); 
     1317      w83781d_write_value(client,W83781D_REG_PWM(nr),data->pwm[nr-1]); 
     1318    } 
     1319  } 
     1320} 
     1321 
    12761322int w83781d_init(void) 
    12771323{ 
  • lm-sensors/trunk/kernel/include/sensors.h

    r311 r314  
    163163#define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ 
    164164#define W83781D_SYSCTL_VID 1300 /* Volts * 100 */ 
     165#define W83781D_SYSCTL_PWM1 1401 
     166#define W83781D_SYSCTL_PWM2 1402 
     167#define W83781D_SYSCTL_PWM3 1403 
     168#define W83781D_SYSCTL_PWM4 1404 
    165169#define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ 
    166170#define W83781D_SYSCTL_ALARMS 2001 /* bitvector */