Changeset 314
- Timestamp:
- 03/14/99 22:53:22 (14 years ago)
- Location:
- lm-sensors/trunk/kernel
- Files:
-
- 2 modified
-
chips/w83781d.c (modified) (9 diffs)
-
include/sensors.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/w83781d.c
r313 r314 29 29 w83783s 5-6 3 2 1-2 0x40 yes no 30 30 31 To do:32 782d/783s PWM enable, clock select, duty cycle33 782d beep 3 register34 782d programmable pins35 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 location38 than 781d/782d, not implemented yet.39 31 */ 40 32 … … 104 96 #define W83781D_REG_PIN 0x4B 105 97 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 105 const u8 regpwm[] = {W83781D_REG_PWM1, W83781D_REG_PWM2, W83781D_REG_PWM3, W83781D_REG_PWM4}; 106 #define W83781D_REG_PWM(nr) (regpwm[(nr) - 1]) 107 106 108 #define W83781D_WCHIPID 0x10 107 109 #define W83782D_WCHIPID 0x30 … … 126 128 (val)>=0x06?0:205-(val)*5) 127 129 #define ALARMS_FROM_REG(val) (val) 130 #define PWM_FROM_REG(val) (val) 131 #define PWM_TO_REG(val) ((val) & 0xff) 128 132 #define BEEPS_FROM_REG(val) (val) 129 133 #define BEEPS_TO_REG(val) ((val) & 0xffff) … … 282 286 u8 beep_enable; /* Boolean */ 283 287 u8 wchipid; /* Register value */ 288 u8 pwm[4]; /* Register value */ 284 289 }; 285 290 … … 325 330 static void w83781d_fan_div(struct i2c_client *client, int operation, 326 331 int ctl_name, int *nrels_mag, long *results); 332 static void w83781d_pwm(struct i2c_client *client, int operation, 333 int ctl_name, int *nrels_mag, long *results); 327 334 328 335 /* I choose here for semi-static W83781D allocation. Complete dynamic … … 431 438 { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, 432 439 &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 }, 433 448 { 0 } 434 449 }; … … 466 481 { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, 467 482 &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 }, 468 487 { 0 } 469 488 }; … … 1033 1052 data->fan_min[i-1] = w83781d_read_value(client,W83781D_REG_FAN_MIN(i)); 1034 1053 } 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 } 1035 1061 data->temp = w83781d_read_value(client,W83781D_REG_TEMP); 1036 1062 data->temp_over = w83781d_read_value(client,W83781D_REG_TEMP_OVER); … … 1274 1300 } 1275 1301 1302 void 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 1276 1322 int w83781d_init(void) 1277 1323 { -
lm-sensors/trunk/kernel/include/sensors.h
r311 r314 163 163 #define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ 164 164 #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 165 169 #define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ 166 170 #define W83781D_SYSCTL_ALARMS 2001 /* bitvector */
