Lines Matching refs:ix

61 /* Voltages (in) numbered 0-5 (ix) */
62 #define VT1211_REG_IN(ix) (0x21 + (ix))
63 #define VT1211_REG_IN_MIN(ix) ((ix) == 0 ? 0x3e : 0x2a + 2 * (ix))
64 #define VT1211_REG_IN_MAX(ix) ((ix) == 0 ? 0x3d : 0x29 + 2 * (ix))
66 /* Temperatures (temp) numbered 0-6 (ix) */
71 /* Fans numbered 0-1 (ix) */
72 #define VT1211_REG_FAN(ix) (0x29 + (ix))
73 #define VT1211_REG_FAN_MIN(ix) (0x3b + (ix))
76 /* PWMs numbered 0-1 (ix) */
78 #define VT1211_REG_PWM(ix) (0x60 + (ix))
82 #define VT1211_REG_PWM_AUTO_PWM(ix, ap) (0x58 + 2 * (ix) - (ap))
133 /* ix = [0-5] */
134 #define ISVOLT(ix, uch_config) ((ix) > 4 ? 1 : \
135 !(((uch_config) >> ((ix) + 2)) & 1))
137 /* ix = [0-6] */
138 #define ISTEMP(ix, uch_config) ((ix) < 2 ? 1 : \
139 ((uch_config) >> (ix)) & 1)
142 * in5 (ix = 5) is special. It's the internal 3.3V so it's scaled in the
145 #define IN_FROM_REG(ix, reg) ((reg) < 3 ? 0 : (ix) == 5 ? \
148 #define IN_TO_REG(ix, val) (clamp_val((ix) == 5 ? \
153 * temp1 (ix = 0) is an intel thermal diode which is scaled in user space.
154 * temp2 (ix = 1) is the internal temp diode so it's scaled in the driver
159 #define TEMP_FROM_REG(ix, reg) ((ix) == 0 ? (reg) * 1000 : \
160 (ix) == 1 ? (reg) < 51 ? 0 : \
163 #define TEMP_TO_REG(ix, val) clamp_val( \
164 ((ix) == 0 ? ((val) + 500) / 1000 : \
165 (ix) == 1 ? ((val) + 500) / 1000 + 51 : \
250 int ix, val;
260 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) {
261 if (ISVOLT(ix, data->uch_config)) {
262 data->in[ix] = vt1211_read8(data,
263 VT1211_REG_IN(ix));
264 data->in_min[ix] = vt1211_read8(data,
265 VT1211_REG_IN_MIN(ix));
266 data->in_max[ix] = vt1211_read8(data,
267 VT1211_REG_IN_MAX(ix));
272 for (ix = 0; ix < ARRAY_SIZE(data->temp); ix++) {
273 if (ISTEMP(ix, data->uch_config)) {
274 data->temp[ix] = vt1211_read8(data,
275 regtemp[ix]);
276 data->temp_max[ix] = vt1211_read8(data,
277 regtempmax[ix]);
278 data->temp_hyst[ix] = vt1211_read8(data,
279 regtemphyst[ix]);
284 for (ix = 0; ix < ARRAY_SIZE(data->fan); ix++) {
285 data->fan[ix] = vt1211_read8(data,
286 VT1211_REG_FAN(ix));
287 data->fan_min[ix] = vt1211_read8(data,
288 VT1211_REG_FAN_MIN(ix));
289 data->pwm[ix] = vt1211_read8(data,
290 VT1211_REG_PWM(ix));
312 for (ix = 0; ix < ARRAY_SIZE(data->pwm_auto_temp); ix++) {
313 data->pwm_auto_temp[ix] = vt1211_read8(data,
314 VT1211_REG_PWM_AUTO_TEMP(ix));
332 * ix = [0-5]
346 int ix = sensor_attr_2->index;
352 res = IN_FROM_REG(ix, data->in[ix]);
355 res = IN_FROM_REG(ix, data->in_min[ix]);
358 res = IN_FROM_REG(ix, data->in_max[ix]);
361 res = (data->alarms >> bitalarmin[ix]) & 1;
377 int ix = sensor_attr_2->index;
389 data->in_min[ix] = IN_TO_REG(ix, val);
390 vt1211_write8(data, VT1211_REG_IN_MIN(ix), data->in_min[ix]);
393 data->in_max[ix] = IN_TO_REG(ix, val);
394 vt1211_write8(data, VT1211_REG_IN_MAX(ix), data->in_max[ix]);
406 * ix = [0-6]
420 int ix = sensor_attr_2->index;
426 res = TEMP_FROM_REG(ix, data->temp[ix]);
429 res = TEMP_FROM_REG(ix, data->temp_max[ix]);
432 res = TEMP_FROM_REG(ix, data->temp_hyst[ix]);
435 res = (data->alarms >> bitalarmtemp[ix]) & 1;
451 int ix = sensor_attr_2->index;
463 data->temp_max[ix] = TEMP_TO_REG(ix, val);
464 vt1211_write8(data, regtempmax[ix],
465 data->temp_max[ix]);
468 data->temp_hyst[ix] = TEMP_TO_REG(ix, val);
469 vt1211_write8(data, regtemphyst[ix],
470 data->temp_hyst[ix]);
482 * ix = [0-1]
496 int ix = sensor_attr_2->index;
502 res = RPM_FROM_REG(data->fan[ix], data->fan_div[ix]);
505 res = RPM_FROM_REG(data->fan_min[ix], data->fan_div[ix]);
508 res = DIV_FROM_REG(data->fan_div[ix]);
511 res = (data->alarms >> bitalarmfan[ix]) & 1;
527 int ix = sensor_attr_2->index;
547 data->fan_min[ix] = RPM_TO_REG(val, data->fan_div[ix]);
548 vt1211_write8(data, VT1211_REG_FAN_MIN(ix),
549 data->fan_min[ix]);
554 data->fan_div[ix] = 0;
557 data->fan_div[ix] = 1;
560 data->fan_div[ix] = 2;
563 data->fan_div[ix] = 3;
588 * ix = [0-1]
602 int ix = sensor_attr_2->index;
608 res = data->pwm[ix];
611 res = ((data->pwm_ctl[ix] >> 3) & 1) ? 2 : 0;
617 res = (data->pwm_ctl[ix] & 7) + 1;
633 int ix = sensor_attr_2->index;
657 data->pwm_ctl[ix] &= 7;
662 if ((data->pwm_ctl[ix ^ 1] & 1) == 0)
666 data->pwm_ctl[ix] |= 8;
713 data->pwm_ctl[ix] = (data->pwm_ctl[ix] & 8) | (val - 1);
728 * ix = [0-1]
733 * pwm[ix+1]_auto_point[ap+1]_temp mapping table:
738 * ix ap : description
757 int ix = sensor_attr_2->index;
760 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->pwm_ctl[ix] & 7,
771 int ix = sensor_attr_2->index;
789 data->pwm_auto_temp[ap] = TEMP_TO_REG(data->pwm_ctl[ix] & 7, val);
798 * pwm[ix+1]_auto_point[ap+1]_pwm mapping table:
802 * ix ap : description
821 int ix = sensor_attr_2->index;
824 return sprintf(buf, "%d\n", data->pwm_auto_pwm[ix][ap]);
834 int ix = sensor_attr_2->index;
844 data->pwm_auto_pwm[ix][ap] = clamp_val(val, 0, 255);
845 vt1211_write8(data, VT1211_REG_PWM_AUTO_PWM(ix, ap),
846 data->pwm_auto_pwm[ix][ap]);
911 #define SENSOR_ATTR_IN(ix) \
912 { SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \
913 show_in, NULL, SHOW_IN_INPUT, ix), \
914 SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \
915 show_in, set_in, SHOW_SET_IN_MIN, ix), \
916 SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \
917 show_in, set_in, SHOW_SET_IN_MAX, ix), \
918 SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \
919 show_in, NULL, SHOW_IN_ALARM, ix) \
957 #define SENSOR_ATTR_TEMP(ix) \
958 { SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \
959 show_temp, NULL, SHOW_TEMP_INPUT, ix-1), \
960 SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \
961 show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1), \
962 SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \
963 show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1), \
964 SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \
965 show_temp, NULL, SHOW_TEMP_ALARM, ix-1) \
1006 #define SENSOR_ATTR_FAN(ix) \
1007 SENSOR_ATTR_2(fan##ix##_input, S_IRUGO, \
1008 show_fan, NULL, SHOW_FAN_INPUT, ix-1), \
1009 SENSOR_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
1010 show_fan, set_fan, SHOW_SET_FAN_MIN, ix-1), \
1011 SENSOR_ATTR_2(fan##ix##_div, S_IRUGO | S_IWUSR, \
1012 show_fan, set_fan, SHOW_SET_FAN_DIV, ix-1), \
1013 SENSOR_ATTR_2(fan##ix##_alarm, S_IRUGO, \
1014 show_fan, NULL, SHOW_FAN_ALARM, ix-1)
1016 #define SENSOR_ATTR_PWM(ix) \
1017 SENSOR_ATTR_2(pwm##ix, S_IRUGO, \
1018 show_pwm, NULL, SHOW_PWM, ix-1), \
1019 SENSOR_ATTR_2(pwm##ix##_enable, S_IRUGO | S_IWUSR, \
1020 show_pwm, set_pwm, SHOW_SET_PWM_ENABLE, ix-1), \
1021 SENSOR_ATTR_2(pwm##ix##_auto_channels_temp, S_IRUGO | S_IWUSR, \
1022 show_pwm, set_pwm, SHOW_SET_PWM_AUTO_CHANNELS_TEMP, ix-1)
1024 #define SENSOR_ATTR_PWM_FREQ(ix) \
1025 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \
1026 show_pwm, set_pwm, SHOW_SET_PWM_FREQ, ix-1)
1028 #define SENSOR_ATTR_PWM_FREQ_RO(ix) \
1029 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1030 show_pwm, NULL, SHOW_SET_PWM_FREQ, ix-1)
1032 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP(ix, ap) \
1033 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO | S_IWUSR, \
1035 ap-1, ix-1)
1037 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(ix, ap) \
1038 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO, \
1040 ap-1, ix-1)
1042 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM(ix, ap) \
1043 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO | S_IWUSR, \
1045 ap-1, ix-1)
1047 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(ix, ap) \
1048 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO, \
1050 ap-1, ix-1)