Lines Matching refs:ix
74 #define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) : \ argument
75 (ix) < 7 ? 0x94 + (ix) : \
77 #define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \ argument
78 : 0x91 + (ix) * 2)
79 #define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \ argument
80 : 0x92 + (ix) * 2)
83 #define DME1737_REG_TEMP(ix) (0x25 + (ix)) argument
84 #define DME1737_REG_TEMP_MIN(ix) (0x4e + (ix) * 2) argument
85 #define DME1737_REG_TEMP_MAX(ix) (0x4f + (ix) * 2) argument
86 #define DME1737_REG_TEMP_OFFSET(ix) ((ix) == 0 ? 0x1f \ argument
87 : 0x1c + (ix))
99 #define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix)) argument
106 #define DME1737_REG_FAN(ix) ((ix) < 4 ? 0x28 + (ix) * 2 \ argument
107 : 0xa1 + (ix) * 2)
108 #define DME1737_REG_FAN_MIN(ix) ((ix) < 4 ? 0x54 + (ix) * 2 \ argument
109 : 0xa5 + (ix) * 2)
110 #define DME1737_REG_FAN_OPT(ix) ((ix) < 4 ? 0x90 + (ix) \ argument
111 : 0xb2 + (ix))
112 #define DME1737_REG_FAN_MAX(ix) (0xb4 + (ix)) /* only for fan[4-5] */ argument
115 #define DME1737_REG_PWM(ix) ((ix) < 3 ? 0x30 + (ix) \ argument
116 : 0xa1 + (ix))
117 #define DME1737_REG_PWM_CONFIG(ix) (0x5c + (ix)) /* only for pwm[0-2] */ argument
118 #define DME1737_REG_PWM_MIN(ix) (0x64 + (ix)) /* only for pwm[0-2] */ argument
119 #define DME1737_REG_PWM_FREQ(ix) ((ix) < 3 ? 0x5f + (ix) \ argument
120 : 0xa3 + (ix))
127 #define DME1737_REG_PWM_RR(ix) (0x62 + (ix)) /* only for pwm[0-2] */ argument
130 #define DME1737_REG_ZONE_LOW(ix) (0x67 + (ix)) argument
131 #define DME1737_REG_ZONE_ABS(ix) (0x6a + (ix)) argument
138 #define DME1737_REG_ZONE_HYST(ix) (0x6d + (ix)) argument
191 #define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ argument
192 #define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ argument
318 static inline int TEMP_HYST_FROM_REG(int reg, int ix) in TEMP_HYST_FROM_REG() argument
320 return (((ix == 1) ? reg : reg >> 4) & 0x0f) * 1000; in TEMP_HYST_FROM_REG()
323 static inline int TEMP_HYST_TO_REG(int temp, long hyst, int ix, int reg) in TEMP_HYST_TO_REG() argument
328 return (ix == 1) ? (reg & 0xf0) | hyst : (reg & 0x0f) | (hyst << 4); in TEMP_HYST_TO_REG()
496 static inline int PWM_RR_FROM_REG(int reg, int ix) in PWM_RR_FROM_REG() argument
498 int rr = (ix == 1) ? reg >> 4 : reg; in PWM_RR_FROM_REG()
503 static int PWM_RR_TO_REG(long val, int ix, int reg) in PWM_RR_TO_REG() argument
512 return (ix == 1) ? (reg & 0x8f) | (i << 4) : (reg & 0xf8) | i; in PWM_RR_TO_REG()
516 static inline int PWM_RR_EN_FROM_REG(int reg, int ix) in PWM_RR_EN_FROM_REG() argument
518 return PWM_RR_FROM_REG(reg, ix) ? 1 : 0; in PWM_RR_EN_FROM_REG()
521 static inline int PWM_RR_EN_TO_REG(long val, int ix, int reg) in PWM_RR_EN_TO_REG() argument
523 int en = (ix == 1) ? 0x80 : 0x08; in PWM_RR_EN_TO_REG()
533 static inline int PWM_OFF_FROM_REG(int reg, int ix) in PWM_OFF_FROM_REG() argument
535 return (reg >> (ix + 5)) & 0x01; in PWM_OFF_FROM_REG()
538 static inline int PWM_OFF_TO_REG(int val, int ix, int reg) in PWM_OFF_TO_REG() argument
540 return (reg & ~(1 << (ix + 5))) | ((val & 0x01) << (ix + 5)); in PWM_OFF_TO_REG()
597 int ix; in dme1737_update_device() local
617 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { in dme1737_update_device()
623 if (ix == 7 && !(data->has_features & HAS_IN7)) in dme1737_update_device()
625 data->in[ix] = dme1737_read(data, in dme1737_update_device()
626 DME1737_REG_IN(ix)) << 8; in dme1737_update_device()
627 data->in_min[ix] = dme1737_read(data, in dme1737_update_device()
628 DME1737_REG_IN_MIN(ix)); in dme1737_update_device()
629 data->in_max[ix] = dme1737_read(data, in dme1737_update_device()
630 DME1737_REG_IN_MAX(ix)); in dme1737_update_device()
634 for (ix = 0; ix < ARRAY_SIZE(data->temp); ix++) { in dme1737_update_device()
642 data->temp[ix] = dme1737_read(data, in dme1737_update_device()
643 DME1737_REG_TEMP(ix)) << 8; in dme1737_update_device()
644 data->temp_min[ix] = dme1737_read(data, in dme1737_update_device()
645 DME1737_REG_TEMP_MIN(ix)); in dme1737_update_device()
646 data->temp_max[ix] = dme1737_read(data, in dme1737_update_device()
647 DME1737_REG_TEMP_MAX(ix)); in dme1737_update_device()
649 data->temp_offset[ix] = dme1737_read(data, in dme1737_update_device()
650 DME1737_REG_TEMP_OFFSET(ix)); in dme1737_update_device()
660 for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) { in dme1737_update_device()
661 if (ix == 5 && !(data->has_features & HAS_IN7)) in dme1737_update_device()
663 lsb[ix] = dme1737_read(data, in dme1737_update_device()
664 DME1737_REG_IN_TEMP_LSB(ix)); in dme1737_update_device()
666 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { in dme1737_update_device()
667 if (ix == 7 && !(data->has_features & HAS_IN7)) in dme1737_update_device()
669 data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] << in dme1737_update_device()
670 DME1737_REG_IN_LSB_SHL[ix]) & 0xf0; in dme1737_update_device()
672 for (ix = 0; ix < ARRAY_SIZE(data->temp); ix++) { in dme1737_update_device()
673 data->temp[ix] |= (lsb[DME1737_REG_TEMP_LSB[ix]] << in dme1737_update_device()
674 DME1737_REG_TEMP_LSB_SHL[ix]) & 0xf0; in dme1737_update_device()
678 for (ix = 0; ix < ARRAY_SIZE(data->fan); ix++) { in dme1737_update_device()
683 if (!(data->has_features & HAS_FAN(ix))) in dme1737_update_device()
685 data->fan[ix] = dme1737_read(data, in dme1737_update_device()
686 DME1737_REG_FAN(ix)); in dme1737_update_device()
687 data->fan[ix] |= dme1737_read(data, in dme1737_update_device()
688 DME1737_REG_FAN(ix) + 1) << 8; in dme1737_update_device()
689 data->fan_min[ix] = dme1737_read(data, in dme1737_update_device()
690 DME1737_REG_FAN_MIN(ix)); in dme1737_update_device()
691 data->fan_min[ix] |= dme1737_read(data, in dme1737_update_device()
692 DME1737_REG_FAN_MIN(ix) + 1) << 8; in dme1737_update_device()
693 data->fan_opt[ix] = dme1737_read(data, in dme1737_update_device()
694 DME1737_REG_FAN_OPT(ix)); in dme1737_update_device()
696 if (ix > 3) { in dme1737_update_device()
697 data->fan_max[ix - 4] = dme1737_read(data, in dme1737_update_device()
698 DME1737_REG_FAN_MAX(ix)); in dme1737_update_device()
703 for (ix = 0; ix < ARRAY_SIZE(data->pwm); ix++) { in dme1737_update_device()
708 if (!(data->has_features & HAS_PWM(ix))) in dme1737_update_device()
710 data->pwm[ix] = dme1737_read(data, in dme1737_update_device()
711 DME1737_REG_PWM(ix)); in dme1737_update_device()
712 data->pwm_freq[ix] = dme1737_read(data, in dme1737_update_device()
713 DME1737_REG_PWM_FREQ(ix)); in dme1737_update_device()
715 if (ix < 3) { in dme1737_update_device()
716 data->pwm_config[ix] = dme1737_read(data, in dme1737_update_device()
717 DME1737_REG_PWM_CONFIG(ix)); in dme1737_update_device()
718 data->pwm_min[ix] = dme1737_read(data, in dme1737_update_device()
719 DME1737_REG_PWM_MIN(ix)); in dme1737_update_device()
722 for (ix = 0; ix < ARRAY_SIZE(data->pwm_rr); ix++) { in dme1737_update_device()
723 data->pwm_rr[ix] = dme1737_read(data, in dme1737_update_device()
724 DME1737_REG_PWM_RR(ix)); in dme1737_update_device()
728 for (ix = 0; ix < ARRAY_SIZE(data->zone_low); ix++) { in dme1737_update_device()
730 if ((ix == 2) && !(data->has_features & HAS_ZONE3)) in dme1737_update_device()
733 if ((ix == 1) && (data->type == sch5127)) { in dme1737_update_device()
739 data->zone_low[ix] = dme1737_read(data, in dme1737_update_device()
740 DME1737_REG_ZONE_LOW(ix)); in dme1737_update_device()
741 data->zone_abs[ix] = dme1737_read(data, in dme1737_update_device()
742 DME1737_REG_ZONE_ABS(ix)); in dme1737_update_device()
746 for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { in dme1737_update_device()
747 data->zone_hyst[ix] = dme1737_read(data, in dme1737_update_device()
748 DME1737_REG_ZONE_HYST(ix)); in dme1737_update_device()
805 int ix = sensor_attr_2->index; in show_in() local
811 res = IN_FROM_REG(data->in[ix], data->in_nominal[ix], 16); in show_in()
814 res = IN_FROM_REG(data->in_min[ix], data->in_nominal[ix], 8); in show_in()
817 res = IN_FROM_REG(data->in_max[ix], data->in_nominal[ix], 8); in show_in()
820 res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; in show_in()
836 int ix = sensor_attr_2->index; in set_in() local
848 data->in_min[ix] = IN_TO_REG(val, data->in_nominal[ix]); in set_in()
849 dme1737_write(data, DME1737_REG_IN_MIN(ix), in set_in()
850 data->in_min[ix]); in set_in()
853 data->in_max[ix] = IN_TO_REG(val, data->in_nominal[ix]); in set_in()
854 dme1737_write(data, DME1737_REG_IN_MAX(ix), in set_in()
855 data->in_max[ix]); in set_in()
883 int ix = sensor_attr_2->index; in show_temp() local
889 res = TEMP_FROM_REG(data->temp[ix], 16); in show_temp()
892 res = TEMP_FROM_REG(data->temp_min[ix], 8); in show_temp()
895 res = TEMP_FROM_REG(data->temp_max[ix], 8); in show_temp()
898 res = TEMP_FROM_REG(data->temp_offset[ix], 8); in show_temp()
901 res = (data->alarms >> DME1737_BIT_ALARM_TEMP[ix]) & 0x01; in show_temp()
904 res = (((u16)data->temp[ix] & 0xff00) == 0x8000); in show_temp()
920 int ix = sensor_attr_2->index; in set_temp() local
932 data->temp_min[ix] = TEMP_TO_REG(val); in set_temp()
933 dme1737_write(data, DME1737_REG_TEMP_MIN(ix), in set_temp()
934 data->temp_min[ix]); in set_temp()
937 data->temp_max[ix] = TEMP_TO_REG(val); in set_temp()
938 dme1737_write(data, DME1737_REG_TEMP_MAX(ix), in set_temp()
939 data->temp_max[ix]); in set_temp()
942 data->temp_offset[ix] = TEMP_TO_REG(val); in set_temp()
943 dme1737_write(data, DME1737_REG_TEMP_OFFSET(ix), in set_temp()
944 data->temp_offset[ix]); in set_temp()
971 int ix = sensor_attr_2->index; in show_zone() local
978 if ((ix == 1) && (data->config2 & 0x02)) in show_zone()
981 res = 1 << ix; in show_zone()
984 res = TEMP_FROM_REG(data->zone_low[ix], 8) - in show_zone()
985 TEMP_HYST_FROM_REG(data->zone_hyst[ix == 2], ix); in show_zone()
988 res = TEMP_FROM_REG(data->zone_low[ix], 8); in show_zone()
992 res = TEMP_FROM_REG(data->zone_low[ix], 8) + in show_zone()
993 TEMP_RANGE_FROM_REG(data->pwm_freq[ix]); in show_zone()
996 res = TEMP_FROM_REG(data->zone_abs[ix], 8); in show_zone()
1012 int ix = sensor_attr_2->index; in set_zone() local
1027 data->zone_low[ix] = dme1737_read(data, in set_zone()
1028 DME1737_REG_ZONE_LOW(ix)); in set_zone()
1030 temp = TEMP_FROM_REG(data->zone_low[ix], 8); in set_zone()
1031 reg = dme1737_read(data, DME1737_REG_ZONE_HYST(ix == 2)); in set_zone()
1032 data->zone_hyst[ix == 2] = TEMP_HYST_TO_REG(temp, val, ix, reg); in set_zone()
1033 dme1737_write(data, DME1737_REG_ZONE_HYST(ix == 2), in set_zone()
1034 data->zone_hyst[ix == 2]); in set_zone()
1037 data->zone_low[ix] = TEMP_TO_REG(val); in set_zone()
1038 dme1737_write(data, DME1737_REG_ZONE_LOW(ix), in set_zone()
1039 data->zone_low[ix]); in set_zone()
1043 data->zone_low[ix] = dme1737_read(data, in set_zone()
1044 DME1737_REG_ZONE_LOW(ix)); in set_zone()
1049 temp = TEMP_FROM_REG(data->zone_low[ix], 8); in set_zone()
1051 reg = dme1737_read(data, DME1737_REG_PWM_FREQ(ix)); in set_zone()
1052 data->pwm_freq[ix] = TEMP_RANGE_TO_REG(val - temp, reg); in set_zone()
1053 dme1737_write(data, DME1737_REG_PWM_FREQ(ix), in set_zone()
1054 data->pwm_freq[ix]); in set_zone()
1057 data->zone_abs[ix] = TEMP_TO_REG(val); in set_zone()
1058 dme1737_write(data, DME1737_REG_ZONE_ABS(ix), in set_zone()
1059 data->zone_abs[ix]); in set_zone()
1086 int ix = sensor_attr_2->index; in show_fan() local
1092 res = FAN_FROM_REG(data->fan[ix], in show_fan()
1093 ix < 4 ? 0 : in show_fan()
1094 FAN_TPC_FROM_REG(data->fan_opt[ix])); in show_fan()
1097 res = FAN_FROM_REG(data->fan_min[ix], in show_fan()
1098 ix < 4 ? 0 : in show_fan()
1099 FAN_TPC_FROM_REG(data->fan_opt[ix])); in show_fan()
1103 res = FAN_MAX_FROM_REG(data->fan_max[ix - 4]); in show_fan()
1106 res = (data->alarms >> DME1737_BIT_ALARM_FAN[ix]) & 0x01; in show_fan()
1110 res = FAN_TYPE_FROM_REG(data->fan_opt[ix]); in show_fan()
1126 int ix = sensor_attr_2->index; in set_fan() local
1138 if (ix < 4) { in set_fan()
1139 data->fan_min[ix] = FAN_TO_REG(val, 0); in set_fan()
1142 data->fan_opt[ix] = dme1737_read(data, in set_fan()
1143 DME1737_REG_FAN_OPT(ix)); in set_fan()
1145 data->fan_min[ix] = FAN_TO_REG(val, in set_fan()
1146 FAN_TPC_FROM_REG(data->fan_opt[ix])); in set_fan()
1148 dme1737_write(data, DME1737_REG_FAN_MIN(ix), in set_fan()
1149 data->fan_min[ix] & 0xff); in set_fan()
1150 dme1737_write(data, DME1737_REG_FAN_MIN(ix) + 1, in set_fan()
1151 data->fan_min[ix] >> 8); in set_fan()
1155 data->fan_max[ix - 4] = FAN_MAX_TO_REG(val); in set_fan()
1156 dme1737_write(data, DME1737_REG_FAN_MAX(ix), in set_fan()
1157 data->fan_max[ix - 4]); in set_fan()
1168 data->fan_opt[ix] = FAN_TYPE_TO_REG(val, dme1737_read(data, in set_fan()
1169 DME1737_REG_FAN_OPT(ix))); in set_fan()
1170 dme1737_write(data, DME1737_REG_FAN_OPT(ix), in set_fan()
1171 data->fan_opt[ix]); in set_fan()
1202 int ix = sensor_attr_2->index; in show_pwm() local
1208 if (PWM_EN_FROM_REG(data->pwm_config[ix]) == 0) in show_pwm()
1211 res = data->pwm[ix]; in show_pwm()
1214 res = PWM_FREQ_FROM_REG(data->pwm_freq[ix]); in show_pwm()
1217 if (ix >= 3) in show_pwm()
1220 res = PWM_EN_FROM_REG(data->pwm_config[ix]); in show_pwm()
1224 res = PWM_RR_FROM_REG(data->pwm_rr[ix > 0], ix); in show_pwm()
1228 if (PWM_EN_FROM_REG(data->pwm_config[ix]) == 2) in show_pwm()
1229 res = PWM_ACZ_FROM_REG(data->pwm_config[ix]); in show_pwm()
1231 res = data->pwm_acz[ix]; in show_pwm()
1235 if (PWM_OFF_FROM_REG(data->pwm_rr[0], ix)) in show_pwm()
1236 res = data->pwm_min[ix]; in show_pwm()
1242 res = data->pwm_min[ix]; in show_pwm()
1265 int ix = sensor_attr_2->index; in set_pwm() local
1277 data->pwm[ix] = clamp_val(val, 0, 255); in set_pwm()
1278 dme1737_write(data, DME1737_REG_PWM(ix), data->pwm[ix]); in set_pwm()
1281 data->pwm_freq[ix] = PWM_FREQ_TO_REG(val, dme1737_read(data, in set_pwm()
1282 DME1737_REG_PWM_FREQ(ix))); in set_pwm()
1283 dme1737_write(data, DME1737_REG_PWM_FREQ(ix), in set_pwm()
1284 data->pwm_freq[ix]); in set_pwm()
1296 data->pwm_config[ix] = dme1737_read(data, in set_pwm()
1297 DME1737_REG_PWM_CONFIG(ix)); in set_pwm()
1298 if (val == PWM_EN_FROM_REG(data->pwm_config[ix])) { in set_pwm()
1303 if (PWM_EN_FROM_REG(data->pwm_config[ix]) == 2) { in set_pwm()
1305 data->pwm_acz[ix] = PWM_ACZ_FROM_REG( in set_pwm()
1306 data->pwm_config[ix]); in set_pwm()
1308 data->pwm_rr[ix > 0] = dme1737_read(data, in set_pwm()
1309 DME1737_REG_PWM_RR(ix > 0)); in set_pwm()
1310 data->pwm_rr_en &= ~(1 << ix); in set_pwm()
1311 if (PWM_RR_EN_FROM_REG(data->pwm_rr[ix > 0], ix)) { in set_pwm()
1312 data->pwm_rr_en |= (1 << ix); in set_pwm()
1313 data->pwm_rr[ix > 0] = PWM_RR_EN_TO_REG(0, ix, in set_pwm()
1314 data->pwm_rr[ix > 0]); in set_pwm()
1316 DME1737_REG_PWM_RR(ix > 0), in set_pwm()
1317 data->pwm_rr[ix > 0]); in set_pwm()
1324 dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], in set_pwm()
1327 data->pwm_config[ix] = PWM_EN_TO_REG(0, in set_pwm()
1328 data->pwm_config[ix]); in set_pwm()
1329 dme1737_write(data, DME1737_REG_PWM_CONFIG(ix), in set_pwm()
1330 data->pwm_config[ix]); in set_pwm()
1334 data->pwm_config[ix] = PWM_EN_TO_REG(1, in set_pwm()
1335 data->pwm_config[ix]); in set_pwm()
1336 dme1737_write(data, DME1737_REG_PWM_CONFIG(ix), in set_pwm()
1337 data->pwm_config[ix]); in set_pwm()
1339 dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], in set_pwm()
1344 dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], in set_pwm()
1350 data->pwm_config[ix] = PWM_ACZ_TO_REG( in set_pwm()
1351 data->pwm_acz[ix], in set_pwm()
1352 data->pwm_config[ix]); in set_pwm()
1353 dme1737_write(data, DME1737_REG_PWM_CONFIG(ix), in set_pwm()
1354 data->pwm_config[ix]); in set_pwm()
1356 if (data->pwm_rr_en & (1 << ix)) { in set_pwm()
1357 data->pwm_rr[ix > 0] = PWM_RR_EN_TO_REG(1, ix, in set_pwm()
1359 DME1737_REG_PWM_RR(ix > 0))); in set_pwm()
1361 DME1737_REG_PWM_RR(ix > 0), in set_pwm()
1362 data->pwm_rr[ix > 0]); in set_pwm()
1370 data->pwm_config[ix] = dme1737_read(data, in set_pwm()
1371 DME1737_REG_PWM_CONFIG(ix)); in set_pwm()
1372 data->pwm_rr[ix > 0] = dme1737_read(data, in set_pwm()
1373 DME1737_REG_PWM_RR(ix > 0)); in set_pwm()
1376 data->pwm_rr[ix > 0] = PWM_RR_TO_REG(val, ix, in set_pwm()
1377 data->pwm_rr[ix > 0]); in set_pwm()
1383 if (PWM_EN_FROM_REG(data->pwm_config[ix]) == 2) { in set_pwm()
1384 data->pwm_rr[ix > 0] = PWM_RR_EN_TO_REG(val > 0, ix, in set_pwm()
1385 data->pwm_rr[ix > 0]); in set_pwm()
1387 dme1737_write(data, DME1737_REG_PWM_RR(ix > 0), in set_pwm()
1388 data->pwm_rr[ix > 0]); in set_pwm()
1401 data->pwm_config[ix] = dme1737_read(data, in set_pwm()
1402 DME1737_REG_PWM_CONFIG(ix)); in set_pwm()
1403 if (PWM_EN_FROM_REG(data->pwm_config[ix]) == 2) { in set_pwm()
1408 data->pwm_config[ix] = PWM_ACZ_TO_REG(val, in set_pwm()
1409 data->pwm_config[ix]); in set_pwm()
1410 dme1737_write(data, DME1737_REG_PWM_CONFIG(ix), in set_pwm()
1411 data->pwm_config[ix]); in set_pwm()
1417 data->pwm_acz[ix] = val; in set_pwm()
1423 data->pwm_min[ix] = dme1737_read(data, in set_pwm()
1424 DME1737_REG_PWM_MIN(ix)); in set_pwm()
1431 if (val > ((data->pwm_min[ix] + 1) / 2)) { in set_pwm()
1432 data->pwm_rr[0] = PWM_OFF_TO_REG(1, ix, in set_pwm()
1436 data->pwm_rr[0] = PWM_OFF_TO_REG(0, ix, in set_pwm()
1445 data->pwm_min[ix] = clamp_val(val, 0, 255); in set_pwm()
1446 dme1737_write(data, DME1737_REG_PWM_MIN(ix), in set_pwm()
1447 data->pwm_min[ix]); in set_pwm()
1511 #define SENSOR_DEVICE_ATTR_IN(ix) \ argument
1512 static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \
1513 show_in, NULL, SYS_IN_INPUT, ix); \
1514 static SENSOR_DEVICE_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \
1515 show_in, set_in, SYS_IN_MIN, ix); \
1516 static SENSOR_DEVICE_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \
1517 show_in, set_in, SYS_IN_MAX, ix); \
1518 static SENSOR_DEVICE_ATTR_2(in##ix##_alarm, S_IRUGO, \
1519 show_in, NULL, SYS_IN_ALARM, ix)
1532 #define SENSOR_DEVICE_ATTR_TEMP(ix) \ argument
1533 static SENSOR_DEVICE_ATTR_2(temp##ix##_input, S_IRUGO, \
1534 show_temp, NULL, SYS_TEMP_INPUT, ix-1); \
1535 static SENSOR_DEVICE_ATTR_2(temp##ix##_min, S_IRUGO | S_IWUSR, \
1536 show_temp, set_temp, SYS_TEMP_MIN, ix-1); \
1537 static SENSOR_DEVICE_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \
1538 show_temp, set_temp, SYS_TEMP_MAX, ix-1); \
1539 static SENSOR_DEVICE_ATTR_2(temp##ix##_offset, S_IRUGO, \
1540 show_temp, set_temp, SYS_TEMP_OFFSET, ix-1); \
1541 static SENSOR_DEVICE_ATTR_2(temp##ix##_alarm, S_IRUGO, \
1542 show_temp, NULL, SYS_TEMP_ALARM, ix-1); \
1543 static SENSOR_DEVICE_ATTR_2(temp##ix##_fault, S_IRUGO, \
1544 show_temp, NULL, SYS_TEMP_FAULT, ix-1)
1552 #define SENSOR_DEVICE_ATTR_ZONE(ix) \ argument
1553 static SENSOR_DEVICE_ATTR_2(zone##ix##_auto_channels_temp, S_IRUGO, \
1554 show_zone, NULL, SYS_ZONE_AUTO_CHANNELS_TEMP, ix-1); \
1555 static SENSOR_DEVICE_ATTR_2(zone##ix##_auto_point1_temp_hyst, S_IRUGO, \
1556 show_zone, set_zone, SYS_ZONE_AUTO_POINT1_TEMP_HYST, ix-1); \
1557 static SENSOR_DEVICE_ATTR_2(zone##ix##_auto_point1_temp, S_IRUGO, \
1558 show_zone, set_zone, SYS_ZONE_AUTO_POINT1_TEMP, ix-1); \
1559 static SENSOR_DEVICE_ATTR_2(zone##ix##_auto_point2_temp, S_IRUGO, \
1560 show_zone, set_zone, SYS_ZONE_AUTO_POINT2_TEMP, ix-1); \
1561 static SENSOR_DEVICE_ATTR_2(zone##ix##_auto_point3_temp, S_IRUGO, \
1562 show_zone, set_zone, SYS_ZONE_AUTO_POINT3_TEMP, ix-1)
1570 #define SENSOR_DEVICE_ATTR_FAN_1TO4(ix) \ argument
1571 static SENSOR_DEVICE_ATTR_2(fan##ix##_input, S_IRUGO, \
1572 show_fan, NULL, SYS_FAN_INPUT, ix-1); \
1573 static SENSOR_DEVICE_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
1574 show_fan, set_fan, SYS_FAN_MIN, ix-1); \
1575 static SENSOR_DEVICE_ATTR_2(fan##ix##_alarm, S_IRUGO, \
1576 show_fan, NULL, SYS_FAN_ALARM, ix-1); \
1577 static SENSOR_DEVICE_ATTR_2(fan##ix##_type, S_IRUGO | S_IWUSR, \
1578 show_fan, set_fan, SYS_FAN_TYPE, ix-1)
1587 #define SENSOR_DEVICE_ATTR_FAN_5TO6(ix) \ argument
1588 static SENSOR_DEVICE_ATTR_2(fan##ix##_input, S_IRUGO, \
1589 show_fan, NULL, SYS_FAN_INPUT, ix-1); \
1590 static SENSOR_DEVICE_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
1591 show_fan, set_fan, SYS_FAN_MIN, ix-1); \
1592 static SENSOR_DEVICE_ATTR_2(fan##ix##_alarm, S_IRUGO, \
1593 show_fan, NULL, SYS_FAN_ALARM, ix-1); \
1594 static SENSOR_DEVICE_ATTR_2(fan##ix##_max, S_IRUGO | S_IWUSR, \
1595 show_fan, set_fan, SYS_FAN_MAX, ix-1)
1602 #define SENSOR_DEVICE_ATTR_PWM_1TO3(ix) \ argument
1603 static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO, \
1604 show_pwm, set_pwm, SYS_PWM, ix-1); \
1605 static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1606 show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \
1607 static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \
1608 show_pwm, set_pwm, SYS_PWM_ENABLE, ix-1); \
1609 static SENSOR_DEVICE_ATTR_2(pwm##ix##_ramp_rate, S_IRUGO, \
1610 show_pwm, set_pwm, SYS_PWM_RAMP_RATE, ix-1); \
1611 static SENSOR_DEVICE_ATTR_2(pwm##ix##_auto_channels_zone, S_IRUGO, \
1612 show_pwm, set_pwm, SYS_PWM_AUTO_CHANNELS_ZONE, ix-1); \
1613 static SENSOR_DEVICE_ATTR_2(pwm##ix##_auto_pwm_min, S_IRUGO, \
1614 show_pwm, set_pwm, SYS_PWM_AUTO_PWM_MIN, ix-1); \
1615 static SENSOR_DEVICE_ATTR_2(pwm##ix##_auto_point1_pwm, S_IRUGO, \
1616 show_pwm, set_pwm, SYS_PWM_AUTO_POINT1_PWM, ix-1); \
1617 static SENSOR_DEVICE_ATTR_2(pwm##ix##_auto_point2_pwm, S_IRUGO, \
1618 show_pwm, NULL, SYS_PWM_AUTO_POINT2_PWM, ix-1)
1626 #define SENSOR_DEVICE_ATTR_PWM_5TO6(ix) \ argument
1627 static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO, \
1628 show_pwm, set_pwm, SYS_PWM, ix-1); \
1629 static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1630 show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \
1631 static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \
1632 show_pwm, NULL, SYS_PWM_ENABLE, ix-1)
2065 int ix; in dme1737_remove_files() local
2067 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { in dme1737_remove_files()
2068 if (data->has_features & HAS_FAN(ix)) { in dme1737_remove_files()
2070 &dme1737_fan_group[ix]); in dme1737_remove_files()
2074 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { in dme1737_remove_files()
2075 if (data->has_features & HAS_PWM(ix)) { in dme1737_remove_files()
2077 &dme1737_pwm_group[ix]); in dme1737_remove_files()
2078 if ((data->has_features & HAS_PWM_MIN) && ix < 3) { in dme1737_remove_files()
2080 dme1737_auto_pwm_min_attr[ix]); in dme1737_remove_files()
2104 int err, ix; in dme1737_create_files() local
2147 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { in dme1737_create_files()
2148 if (data->has_features & HAS_FAN(ix)) { in dme1737_create_files()
2150 &dme1737_fan_group[ix]); in dme1737_create_files()
2157 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { in dme1737_create_files()
2158 if (data->has_features & HAS_PWM(ix)) { in dme1737_create_files()
2160 &dme1737_pwm_group[ix]); in dme1737_create_files()
2163 if ((data->has_features & HAS_PWM_MIN) && (ix < 3)) { in dme1737_create_files()
2165 dme1737_auto_pwm_min_attr[ix]); in dme1737_create_files()
2199 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_chmod_group); ix++) { in dme1737_create_files()
2200 if (data->has_features & HAS_PWM(ix)) { in dme1737_create_files()
2202 &dme1737_pwm_chmod_group[ix], in dme1737_create_files()
2205 ix < 3) { in dme1737_create_files()
2207 dme1737_auto_pwm_min_attr[ix], in dme1737_create_files()
2214 for (ix = 0; ix < 3; ix++) { in dme1737_create_files()
2215 if ((data->has_features & HAS_PWM(ix)) && in dme1737_create_files()
2216 (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { in dme1737_create_files()
2218 dme1737_pwm_chmod_attr[ix], in dme1737_create_files()
2236 int ix; in dme1737_init_device() local
2346 for (ix = 0; ix < 3; ix++) { in dme1737_init_device()
2347 data->pwm_config[ix] = dme1737_read(data, in dme1737_init_device()
2348 DME1737_REG_PWM_CONFIG(ix)); in dme1737_init_device()
2349 if ((data->has_features & HAS_PWM(ix)) && in dme1737_init_device()
2350 (PWM_EN_FROM_REG(data->pwm_config[ix]) == -1)) { in dme1737_init_device()
2353 ix + 1); in dme1737_init_device()
2354 data->pwm_config[ix] = PWM_EN_TO_REG(1, in dme1737_init_device()
2355 data->pwm_config[ix]); in dme1737_init_device()
2356 dme1737_write(data, DME1737_REG_PWM(ix), 0); in dme1737_init_device()
2358 DME1737_REG_PWM_CONFIG(ix), in dme1737_init_device()
2359 data->pwm_config[ix]); in dme1737_init_device()