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 : \
244 int ix, val;
254 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) {
255 if (ISVOLT(ix, data->uch_config)) {
256 data->in[ix] = vt1211_read8(data,
257 VT1211_REG_IN(ix));
258 data->in_min[ix] = vt1211_read8(data,
259 VT1211_REG_IN_MIN(ix));
260 data->in_max[ix] = vt1211_read8(data,
261 VT1211_REG_IN_MAX(ix));
266 for (ix = 0; ix < ARRAY_SIZE(data->temp); ix++) {
267 if (ISTEMP(ix, data->uch_config)) {
268 data->temp[ix] = vt1211_read8(data,
269 regtemp[ix]);
270 data->temp_max[ix] = vt1211_read8(data,
271 regtempmax[ix]);
272 data->temp_hyst[ix] = vt1211_read8(data,
273 regtemphyst[ix]);
278 for (ix = 0; ix < ARRAY_SIZE(data->fan); ix++) {
279 data->fan[ix] = vt1211_read8(data,
280 VT1211_REG_FAN(ix));
281 data->fan_min[ix] = vt1211_read8(data,
282 VT1211_REG_FAN_MIN(ix));
283 data->pwm[ix] = vt1211_read8(data,
284 VT1211_REG_PWM(ix));
306 for (ix = 0; ix < ARRAY_SIZE(data->pwm_auto_temp); ix++) {
307 data->pwm_auto_temp[ix] = vt1211_read8(data,
308 VT1211_REG_PWM_AUTO_TEMP(ix));
326 * ix = [0-5]
340 int ix = sensor_attr_2->index;
346 res = IN_FROM_REG(ix, data->in[ix]);
349 res = IN_FROM_REG(ix, data->in_min[ix]);
352 res = IN_FROM_REG(ix, data->in_max[ix]);
355 res = (data->alarms >> bitalarmin[ix]) & 1;
371 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;
457 data->temp_max[ix] = TEMP_TO_REG(ix, val);
458 vt1211_write8(data, regtempmax[ix],
459 data->temp_max[ix]);
462 data->temp_hyst[ix] = TEMP_TO_REG(ix, val);
463 vt1211_write8(data, regtemphyst[ix],
464 data->temp_hyst[ix]);
476 * ix = [0-1]
490 int ix = sensor_attr_2->index;
496 res = RPM_FROM_REG(data->fan[ix], data->fan_div[ix]);
499 res = RPM_FROM_REG(data->fan_min[ix], data->fan_div[ix]);
502 res = DIV_FROM_REG(data->fan_div[ix]);
505 res = (data->alarms >> bitalarmfan[ix]) & 1;
521 int ix = sensor_attr_2->index;
541 data->fan_min[ix] = RPM_TO_REG(val, data->fan_div[ix]);
542 vt1211_write8(data, VT1211_REG_FAN_MIN(ix),
543 data->fan_min[ix]);
548 data->fan_div[ix] = 0;
551 data->fan_div[ix] = 1;
554 data->fan_div[ix] = 2;
557 data->fan_div[ix] = 3;
582 * ix = [0-1]
596 int ix = sensor_attr_2->index;
602 res = data->pwm[ix];
605 res = ((data->pwm_ctl[ix] >> 3) & 1) ? 2 : 0;
611 res = (data->pwm_ctl[ix] & 7) + 1;
627 int ix = sensor_attr_2->index;
651 data->pwm_ctl[ix] &= 7;
656 if ((data->pwm_ctl[ix ^ 1] & 1) == 0)
660 data->pwm_ctl[ix] |= 8;
707 data->pwm_ctl[ix] = (data->pwm_ctl[ix] & 8) | (val - 1);
722 * ix = [0-1]
727 * pwm[ix+1]_auto_point[ap+1]_temp mapping table:
732 * ix ap : description
751 int ix = sensor_attr_2->index;
754 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->pwm_ctl[ix] & 7,
765 int ix = sensor_attr_2->index;
783 data->pwm_auto_temp[ap] = TEMP_TO_REG(data->pwm_ctl[ix] & 7, val);
792 * pwm[ix+1]_auto_point[ap+1]_pwm mapping table:
796 * ix ap : description
815 int ix = sensor_attr_2->index;
818 return sprintf(buf, "%d\n", data->pwm_auto_pwm[ix][ap]);
828 int ix = sensor_attr_2->index;
838 data->pwm_auto_pwm[ix][ap] = clamp_val(val, 0, 255);
839 vt1211_write8(data, VT1211_REG_PWM_AUTO_PWM(ix, ap),
840 data->pwm_auto_pwm[ix][ap]);
905 #define SENSOR_ATTR_IN(ix) \
906 { SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \
907 show_in, NULL, SHOW_IN_INPUT, ix), \
908 SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \
909 show_in, set_in, SHOW_SET_IN_MIN, ix), \
910 SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \
911 show_in, set_in, SHOW_SET_IN_MAX, ix), \
912 SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \
913 show_in, NULL, SHOW_IN_ALARM, ix) \
951 #define SENSOR_ATTR_TEMP(ix) \
952 { SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \
953 show_temp, NULL, SHOW_TEMP_INPUT, ix-1), \
954 SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \
955 show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1), \
956 SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \
957 show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1), \
958 SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \
959 show_temp, NULL, SHOW_TEMP_ALARM, ix-1) \
1000 #define SENSOR_ATTR_FAN(ix) \
1001 SENSOR_ATTR_2(fan##ix##_input, S_IRUGO, \
1002 show_fan, NULL, SHOW_FAN_INPUT, ix-1), \
1003 SENSOR_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
1004 show_fan, set_fan, SHOW_SET_FAN_MIN, ix-1), \
1005 SENSOR_ATTR_2(fan##ix##_div, S_IRUGO | S_IWUSR, \
1006 show_fan, set_fan, SHOW_SET_FAN_DIV, ix-1), \
1007 SENSOR_ATTR_2(fan##ix##_alarm, S_IRUGO, \
1008 show_fan, NULL, SHOW_FAN_ALARM, ix-1)
1010 #define SENSOR_ATTR_PWM(ix) \
1011 SENSOR_ATTR_2(pwm##ix, S_IRUGO, \
1012 show_pwm, NULL, SHOW_PWM, ix-1), \
1013 SENSOR_ATTR_2(pwm##ix##_enable, S_IRUGO | S_IWUSR, \
1014 show_pwm, set_pwm, SHOW_SET_PWM_ENABLE, ix-1), \
1015 SENSOR_ATTR_2(pwm##ix##_auto_channels_temp, S_IRUGO | S_IWUSR, \
1016 show_pwm, set_pwm, SHOW_SET_PWM_AUTO_CHANNELS_TEMP, ix-1)
1018 #define SENSOR_ATTR_PWM_FREQ(ix) \
1019 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \
1020 show_pwm, set_pwm, SHOW_SET_PWM_FREQ, ix-1)
1022 #define SENSOR_ATTR_PWM_FREQ_RO(ix) \
1023 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1024 show_pwm, NULL, SHOW_SET_PWM_FREQ, ix-1)
1026 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP(ix, ap) \
1027 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO | S_IWUSR, \
1029 ap-1, ix-1)
1031 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(ix, ap) \
1032 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO, \
1034 ap-1, ix-1)
1036 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM(ix, ap) \
1037 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO | S_IWUSR, \
1039 ap-1, ix-1)
1041 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(ix, ap) \
1042 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO, \
1044 ap-1, ix-1)