Lines Matching refs:ix
72 /* Voltages (in) numbered 0-5 (ix) */
73 #define VT1211_REG_IN(ix) (0x21 + (ix))
74 #define VT1211_REG_IN_MIN(ix) ((ix) == 0 ? 0x3e : 0x2a + 2 * (ix))
75 #define VT1211_REG_IN_MAX(ix) ((ix) == 0 ? 0x3d : 0x29 + 2 * (ix))
77 /* Temperatures (temp) numbered 0-6 (ix) */
82 /* Fans numbered 0-1 (ix) */
83 #define VT1211_REG_FAN(ix) (0x29 + (ix))
84 #define VT1211_REG_FAN_MIN(ix) (0x3b + (ix))
87 /* PWMs numbered 0-1 (ix) */
89 #define VT1211_REG_PWM(ix) (0x60 + (ix))
93 #define VT1211_REG_PWM_AUTO_PWM(ix, ap) (0x58 + 2 * (ix) - (ap))
144 /* ix = [0-5] */
145 #define ISVOLT(ix, uch_config) ((ix) > 4 ? 1 : \
146 !(((uch_config) >> ((ix) + 2)) & 1))
148 /* ix = [0-6] */
149 #define ISTEMP(ix, uch_config) ((ix) < 2 ? 1 : \
150 ((uch_config) >> (ix)) & 1)
152 /* in5 (ix = 5) is special. It's the internal 3.3V so it's scaled in the
154 #define IN_FROM_REG(ix, reg) ((reg) < 3 ? 0 : (ix) == 5 ? \
157 #define IN_TO_REG(ix, val) (SENSORS_LIMIT((ix) == 5 ? \
161 /* temp1 (ix = 0) is an intel thermal diode which is scaled in user space.
162 temp2 (ix = 1) is the internal temp diode so it's scaled in the driver
166 #define TEMP_FROM_REG(ix, reg) ((ix) == 0 ? (reg) * 1000 : \
167 (ix) == 1 ? (reg) < 51 ? 0 : \
170 #define TEMP_TO_REG(ix, val) SENSORS_LIMIT( \
171 ((ix) == 0 ? ((val) + 500) / 1000 : \
172 (ix) == 1 ? ((val) + 500) / 1000 + 51 : \
249 int ix, val;
259 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) {
260 if (ISVOLT(ix, data->uch_config)) {
261 data->in[ix] = vt1211_read8(data,
262 VT1211_REG_IN(ix));
263 data->in_min[ix] = vt1211_read8(data,
264 VT1211_REG_IN_MIN(ix));
265 data->in_max[ix] = vt1211_read8(data,
266 VT1211_REG_IN_MAX(ix));
271 for (ix = 0; ix < ARRAY_SIZE(data->temp); ix++) {
272 if (ISTEMP(ix, data->uch_config)) {
273 data->temp[ix] = vt1211_read8(data,
274 regtemp[ix]);
275 data->temp_max[ix] = vt1211_read8(data,
276 regtempmax[ix]);
277 data->temp_hyst[ix] = vt1211_read8(data,
278 regtemphyst[ix]);
283 for (ix = 0; ix < ARRAY_SIZE(data->fan); ix++) {
284 data->fan[ix] = vt1211_read8(data,
285 VT1211_REG_FAN(ix));
286 data->fan_min[ix] = vt1211_read8(data,
287 VT1211_REG_FAN_MIN(ix));
288 data->pwm[ix] = vt1211_read8(data,
289 VT1211_REG_PWM(ix));
311 for (ix = 0; ix < ARRAY_SIZE(data->pwm_auto_temp); ix++) {
312 data->pwm_auto_temp[ix] = vt1211_read8(data,
313 VT1211_REG_PWM_AUTO_TEMP(ix));
331 * ix = [0-5]
345 int ix = sensor_attr_2->index;
351 res = IN_FROM_REG(ix, data->in[ix]);
354 res = IN_FROM_REG(ix, data->in_min[ix]);
357 res = IN_FROM_REG(ix, data->in_max[ix]);
360 res = (data->alarms >> bitalarmin[ix]) & 1;
376 int ix = sensor_attr_2->index;
383 data->in_min[ix] = IN_TO_REG(ix, val);
384 vt1211_write8(data, VT1211_REG_IN_MIN(ix), data->in_min[ix]);
387 data->in_max[ix] = IN_TO_REG(ix, val);
388 vt1211_write8(data, VT1211_REG_IN_MAX(ix), data->in_max[ix]);
400 * ix = [0-6]
414 int ix = sensor_attr_2->index;
420 res = TEMP_FROM_REG(ix, data->temp[ix]);
423 res = TEMP_FROM_REG(ix, data->temp_max[ix]);
426 res = TEMP_FROM_REG(ix, data->temp_hyst[ix]);
429 res = (data->alarms >> bitalarmtemp[ix]) & 1;
445 int ix = sensor_attr_2->index;
452 data->temp_max[ix] = TEMP_TO_REG(ix, val);
453 vt1211_write8(data, regtempmax[ix],
454 data->temp_max[ix]);
457 data->temp_hyst[ix] = TEMP_TO_REG(ix, val);
458 vt1211_write8(data, regtemphyst[ix],
459 data->temp_hyst[ix]);
471 * ix = [0-1]
485 int ix = sensor_attr_2->index;
491 res = RPM_FROM_REG(data->fan[ix], data->fan_div[ix]);
494 res = RPM_FROM_REG(data->fan_min[ix], data->fan_div[ix]);
497 res = DIV_FROM_REG(data->fan_div[ix]);
500 res = (data->alarms >> bitalarmfan[ix]) & 1;
516 int ix = sensor_attr_2->index;
531 data->fan_min[ix] = RPM_TO_REG(val, data->fan_div[ix]);
532 vt1211_write8(data, VT1211_REG_FAN_MIN(ix),
533 data->fan_min[ix]);
537 case 1: data->fan_div[ix] = 0; break;
538 case 2: data->fan_div[ix] = 1; break;
539 case 4: data->fan_div[ix] = 2; break;
540 case 8: data->fan_div[ix] = 3; break;
564 * ix = [0-1]
578 int ix = sensor_attr_2->index;
584 res = data->pwm[ix];
587 res = ((data->pwm_ctl[ix] >> 3) & 1) ? 2 : 0;
593 res = (data->pwm_ctl[ix] & 7) + 1;
609 int ix = sensor_attr_2->index;
628 data->pwm_ctl[ix] &= 7;
631 if ((data->pwm_ctl[ix ^ 1] & 1) == 0) {
636 data->pwm_ctl[ix] |= 8;
682 data->pwm_ctl[ix] = (data->pwm_ctl[ix] & 8) | (val - 1);
697 * ix = [0-1]
702 * pwm[ix+1]_auto_point[ap+1]_temp mapping table:
707 * ix ap : description
726 int ix = sensor_attr_2->index;
729 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->pwm_ctl[ix] & 7,
740 int ix = sensor_attr_2->index;
752 data->pwm_auto_temp[ap] = TEMP_TO_REG(data->pwm_ctl[ix] & 7, val);
761 * pwm[ix+1]_auto_point[ap+1]_pwm mapping table:
765 * ix ap : description
784 int ix = sensor_attr_2->index;
787 return sprintf(buf, "%d\n", data->pwm_auto_pwm[ix][ap]);
797 int ix = sensor_attr_2->index;
808 data->pwm_auto_pwm[ix][ap] = val;
809 vt1211_write8(data, VT1211_REG_PWM_AUTO_PWM(ix, ap),
810 data->pwm_auto_pwm[ix][ap]);
867 #define SENSOR_ATTR_IN_INPUT(ix) \
868 SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \
869 show_in, NULL, SHOW_IN_INPUT, ix)
880 #define SENSOR_ATTR_IN_MIN(ix) \
881 SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \
882 show_in, set_in, SHOW_SET_IN_MIN, ix)
893 #define SENSOR_ATTR_IN_MAX(ix) \
894 SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \
895 show_in, set_in, SHOW_SET_IN_MAX, ix)
906 #define SENSOR_ATTR_IN_ALARM(ix) \
907 SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \
908 show_in, NULL, SHOW_IN_ALARM, ix)
919 #define SENSOR_ATTR_TEMP_INPUT(ix) \
920 SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \
921 show_temp, NULL, SHOW_TEMP_INPUT, ix-1)
933 #define SENSOR_ATTR_TEMP_MAX(ix) \
934 SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \
935 show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1)
947 #define SENSOR_ATTR_TEMP_MAX_HYST(ix) \
948 SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \
949 show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1)
961 #define SENSOR_ATTR_TEMP_ALARM(ix) \
962 SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \
963 show_temp, NULL, SHOW_TEMP_ALARM, ix-1)
975 #define SENSOR_ATTR_FAN(ix) \
976 SENSOR_ATTR_2(fan##ix##_input, S_IRUGO, \
977 show_fan, NULL, SHOW_FAN_INPUT, ix-1), \
978 SENSOR_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
979 show_fan, set_fan, SHOW_SET_FAN_MIN, ix-1), \
980 SENSOR_ATTR_2(fan##ix##_div, S_IRUGO | S_IWUSR, \
981 show_fan, set_fan, SHOW_SET_FAN_DIV, ix-1), \
982 SENSOR_ATTR_2(fan##ix##_alarm, S_IRUGO, \
983 show_fan, NULL, SHOW_FAN_ALARM, ix-1)
985 #define SENSOR_ATTR_PWM(ix) \
986 SENSOR_ATTR_2(pwm##ix, S_IRUGO, \
987 show_pwm, NULL, SHOW_PWM, ix-1), \
988 SENSOR_ATTR_2(pwm##ix##_enable, S_IRUGO | S_IWUSR, \
989 show_pwm, set_pwm, SHOW_SET_PWM_ENABLE, ix-1), \
990 SENSOR_ATTR_2(pwm##ix##_auto_channels_temp, S_IRUGO | S_IWUSR, \
991 show_pwm, set_pwm, SHOW_SET_PWM_AUTO_CHANNELS_TEMP, ix-1)
993 #define SENSOR_ATTR_PWM_FREQ(ix) \
994 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \
995 show_pwm, set_pwm, SHOW_SET_PWM_FREQ, ix-1)
997 #define SENSOR_ATTR_PWM_FREQ_RO(ix) \
998 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO, \
999 show_pwm, NULL, SHOW_SET_PWM_FREQ, ix-1)
1001 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP(ix, ap) \
1002 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO | S_IWUSR, \
1004 ap-1, ix-1)
1006 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(ix, ap) \
1007 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO, \
1009 ap-1, ix-1)
1011 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM(ix, ap) \
1012 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO | S_IWUSR, \
1014 ap-1, ix-1)
1016 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(ix, ap) \
1017 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO, \
1019 ap-1, ix-1)