Lines Matching refs:val
612 int val; in lm90_update_limits() local
614 val = lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT); in lm90_update_limits()
615 if (val < 0) in lm90_update_limits()
616 return val; in lm90_update_limits()
617 data->temp8[LOCAL_CRIT] = val; in lm90_update_limits()
619 val = lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT); in lm90_update_limits()
620 if (val < 0) in lm90_update_limits()
621 return val; in lm90_update_limits()
622 data->temp8[REMOTE_CRIT] = val; in lm90_update_limits()
624 val = lm90_read_reg(client, LM90_REG_R_TCRIT_HYST); in lm90_update_limits()
625 if (val < 0) in lm90_update_limits()
626 return val; in lm90_update_limits()
627 data->temp_hyst = val; in lm90_update_limits()
629 val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); in lm90_update_limits()
630 if (val < 0) in lm90_update_limits()
631 return val; in lm90_update_limits()
632 data->temp11[REMOTE_LOW] = val << 8; in lm90_update_limits()
635 val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL); in lm90_update_limits()
636 if (val < 0) in lm90_update_limits()
637 return val; in lm90_update_limits()
638 data->temp11[REMOTE_LOW] |= val; in lm90_update_limits()
641 val = lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH); in lm90_update_limits()
642 if (val < 0) in lm90_update_limits()
643 return val; in lm90_update_limits()
644 data->temp11[REMOTE_HIGH] = val << 8; in lm90_update_limits()
647 val = lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL); in lm90_update_limits()
648 if (val < 0) in lm90_update_limits()
649 return val; in lm90_update_limits()
650 data->temp11[REMOTE_HIGH] |= val; in lm90_update_limits()
654 val = lm90_read16(client, LM90_REG_R_REMOTE_OFFSH, in lm90_update_limits()
656 if (val < 0) in lm90_update_limits()
657 return val; in lm90_update_limits()
658 data->temp11[REMOTE_OFFSET] = val; in lm90_update_limits()
662 val = lm90_read_reg(client, MAX6659_REG_R_LOCAL_EMERG); in lm90_update_limits()
663 if (val < 0) in lm90_update_limits()
664 return val; in lm90_update_limits()
665 data->temp8[LOCAL_EMERG] = val; in lm90_update_limits()
667 val = lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG); in lm90_update_limits()
668 if (val < 0) in lm90_update_limits()
669 return val; in lm90_update_limits()
670 data->temp8[REMOTE_EMERG] = val; in lm90_update_limits()
674 val = lm90_select_remote_channel(client, data, 1); in lm90_update_limits()
675 if (val < 0) in lm90_update_limits()
676 return val; in lm90_update_limits()
678 val = lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT); in lm90_update_limits()
679 if (val < 0) in lm90_update_limits()
680 return val; in lm90_update_limits()
681 data->temp8[REMOTE2_CRIT] = val; in lm90_update_limits()
683 val = lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG); in lm90_update_limits()
684 if (val < 0) in lm90_update_limits()
685 return val; in lm90_update_limits()
686 data->temp8[REMOTE2_EMERG] = val; in lm90_update_limits()
688 val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); in lm90_update_limits()
689 if (val < 0) in lm90_update_limits()
690 return val; in lm90_update_limits()
691 data->temp11[REMOTE2_LOW] = val << 8; in lm90_update_limits()
693 val = lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH); in lm90_update_limits()
694 if (val < 0) in lm90_update_limits()
695 return val; in lm90_update_limits()
696 data->temp11[REMOTE2_HIGH] = val << 8; in lm90_update_limits()
709 int val; in lm90_update_device() local
712 val = lm90_update_limits(dev); in lm90_update_device()
713 if (val < 0) in lm90_update_device()
714 return val; in lm90_update_device()
724 val = lm90_read_reg(client, LM90_REG_R_LOCAL_LOW); in lm90_update_device()
725 if (val < 0) in lm90_update_device()
726 return val; in lm90_update_device()
727 data->temp8[LOCAL_LOW] = val; in lm90_update_device()
729 val = lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH); in lm90_update_device()
730 if (val < 0) in lm90_update_device()
731 return val; in lm90_update_device()
732 data->temp8[LOCAL_HIGH] = val; in lm90_update_device()
735 val = lm90_read16(client, LM90_REG_R_LOCAL_TEMP, in lm90_update_device()
737 if (val < 0) in lm90_update_device()
738 return val; in lm90_update_device()
739 data->temp11[LOCAL_TEMP] = val; in lm90_update_device()
741 val = lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP); in lm90_update_device()
742 if (val < 0) in lm90_update_device()
743 return val; in lm90_update_device()
744 data->temp11[LOCAL_TEMP] = val << 8; in lm90_update_device()
746 val = lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, in lm90_update_device()
748 if (val < 0) in lm90_update_device()
749 return val; in lm90_update_device()
750 data->temp11[REMOTE_TEMP] = val; in lm90_update_device()
752 val = lm90_read_reg(client, LM90_REG_R_STATUS); in lm90_update_device()
753 if (val < 0) in lm90_update_device()
754 return val; in lm90_update_device()
755 data->alarms = val; /* lower 8 bit of alarms */ in lm90_update_device()
758 val = lm90_select_remote_channel(client, data, 1); in lm90_update_device()
759 if (val < 0) in lm90_update_device()
760 return val; in lm90_update_device()
762 val = lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, in lm90_update_device()
764 if (val < 0) { in lm90_update_device()
766 return val; in lm90_update_device()
768 data->temp11[REMOTE2_TEMP] = val; in lm90_update_device()
772 val = lm90_read_reg(client, MAX6696_REG_R_STATUS2); in lm90_update_device()
773 if (val < 0) in lm90_update_device()
774 return val; in lm90_update_device()
775 data->alarms |= val << 8; in lm90_update_device()
784 val = lm90_read_reg(client, LM90_REG_R_CONFIG1); in lm90_update_device()
785 if (val < 0) in lm90_update_device()
786 return val; in lm90_update_device()
788 if (val & 0x80) { in lm90_update_device()
792 val & ~0x80); in lm90_update_device()
812 static inline int temp_from_s8(s8 val) in temp_from_s8() argument
814 return val * 1000; in temp_from_s8()
817 static inline int temp_from_u8(u8 val) in temp_from_u8() argument
819 return val * 1000; in temp_from_u8()
822 static inline int temp_from_s16(s16 val) in temp_from_s16() argument
824 return val / 32 * 125; in temp_from_s16()
827 static inline int temp_from_u16(u16 val) in temp_from_u16() argument
829 return val / 32 * 125; in temp_from_u16()
832 static s8 temp_to_s8(long val) in temp_to_s8() argument
834 if (val <= -128000) in temp_to_s8()
836 if (val >= 127000) in temp_to_s8()
838 if (val < 0) in temp_to_s8()
839 return (val - 500) / 1000; in temp_to_s8()
840 return (val + 500) / 1000; in temp_to_s8()
843 static u8 temp_to_u8(long val) in temp_to_u8() argument
845 if (val <= 0) in temp_to_u8()
847 if (val >= 255000) in temp_to_u8()
849 return (val + 500) / 1000; in temp_to_u8()
852 static s16 temp_to_s16(long val) in temp_to_s16() argument
854 if (val <= -128000) in temp_to_s16()
856 if (val >= 127875) in temp_to_s16()
858 if (val < 0) in temp_to_s16()
859 return (val - 62) / 125 * 32; in temp_to_s16()
860 return (val + 62) / 125 * 32; in temp_to_s16()
863 static u8 hyst_to_reg(long val) in hyst_to_reg() argument
865 if (val <= 0) in hyst_to_reg()
867 if (val >= 30500) in hyst_to_reg()
869 return (val + 500) / 1000; in hyst_to_reg()
880 static inline int temp_from_u8_adt7461(struct lm90_data *data, u8 val) in temp_from_u8_adt7461() argument
883 return (val - 64) * 1000; in temp_from_u8_adt7461()
884 return temp_from_s8(val); in temp_from_u8_adt7461()
887 static inline int temp_from_u16_adt7461(struct lm90_data *data, u16 val) in temp_from_u16_adt7461() argument
890 return (val - 0x4000) / 64 * 250; in temp_from_u16_adt7461()
891 return temp_from_s16(val); in temp_from_u16_adt7461()
894 static u8 temp_to_u8_adt7461(struct lm90_data *data, long val) in temp_to_u8_adt7461() argument
897 if (val <= -64000) in temp_to_u8_adt7461()
899 if (val >= 191000) in temp_to_u8_adt7461()
901 return (val + 500 + 64000) / 1000; in temp_to_u8_adt7461()
903 if (val <= 0) in temp_to_u8_adt7461()
905 if (val >= 127000) in temp_to_u8_adt7461()
907 return (val + 500) / 1000; in temp_to_u8_adt7461()
910 static u16 temp_to_u16_adt7461(struct lm90_data *data, long val) in temp_to_u16_adt7461() argument
913 if (val <= -64000) in temp_to_u16_adt7461()
915 if (val >= 191750) in temp_to_u16_adt7461()
917 return (val + 64000 + 125) / 250 * 64; in temp_to_u16_adt7461()
919 if (val <= 0) in temp_to_u16_adt7461()
921 if (val >= 127750) in temp_to_u16_adt7461()
923 return (val + 125) / 250 * 64; in temp_to_u16_adt7461()
939 long val; in pec_store() local
942 err = kstrtol(buf, 10, &val); in pec_store()
946 switch (val) { in pec_store()
981 static int lm90_set_temp11(struct lm90_data *data, int index, long val) in lm90_set_temp11() argument
999 val -= 16000; in lm90_set_temp11()
1002 data->temp11[index] = temp_to_u16_adt7461(data, val); in lm90_set_temp11()
1004 data->temp11[index] = temp_to_u8(val) << 8; in lm90_set_temp11()
1006 data->temp11[index] = temp_to_s16(val); in lm90_set_temp11()
1008 data->temp11[index] = temp_to_s8(val) << 8; in lm90_set_temp11()
1042 static int lm90_set_temp8(struct lm90_data *data, int index, long val) in lm90_set_temp8() argument
1059 val -= 16000; in lm90_set_temp8()
1062 data->temp8[index] = temp_to_u8_adt7461(data, val); in lm90_set_temp8()
1064 data->temp8[index] = temp_to_u8(val); in lm90_set_temp8()
1066 data->temp8[index] = temp_to_s8(val); in lm90_set_temp8()
1093 static int lm90_set_temphyst(struct lm90_data *data, long val) in lm90_set_temphyst() argument
1106 data->temp_hyst = hyst_to_reg(temp - val); in lm90_set_temphyst()
1138 static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val) in lm90_temp_read() argument
1151 *val = lm90_get_temp11(data, lm90_temp_index[channel]); in lm90_temp_read()
1154 *val = (data->alarms >> lm90_min_alarm_bits[channel]) & 1; in lm90_temp_read()
1157 *val = (data->alarms >> lm90_max_alarm_bits[channel]) & 1; in lm90_temp_read()
1160 *val = (data->alarms >> lm90_crit_alarm_bits[channel]) & 1; in lm90_temp_read()
1163 *val = (data->alarms >> lm90_emergency_alarm_bits[channel]) & 1; in lm90_temp_read()
1166 *val = (data->alarms >> lm90_fault_bits[channel]) & 1; in lm90_temp_read()
1170 *val = lm90_get_temp8(data, in lm90_temp_read()
1173 *val = lm90_get_temp11(data, in lm90_temp_read()
1178 *val = lm90_get_temp8(data, in lm90_temp_read()
1181 *val = lm90_get_temp11(data, in lm90_temp_read()
1185 *val = lm90_get_temp8(data, lm90_temp_crit_index[channel]); in lm90_temp_read()
1188 *val = lm90_get_temphyst(data, lm90_temp_crit_index[channel]); in lm90_temp_read()
1191 *val = lm90_get_temp8(data, lm90_temp_emerg_index[channel]); in lm90_temp_read()
1194 *val = lm90_get_temphyst(data, lm90_temp_emerg_index[channel]); in lm90_temp_read()
1197 *val = lm90_get_temp11(data, REMOTE_OFFSET); in lm90_temp_read()
1205 static int lm90_temp_write(struct device *dev, u32 attr, int channel, long val) in lm90_temp_write() argument
1221 val); in lm90_temp_write()
1225 val); in lm90_temp_write()
1231 val); in lm90_temp_write()
1235 val); in lm90_temp_write()
1238 err = lm90_set_temp8(data, lm90_temp_crit_index[channel], val); in lm90_temp_write()
1241 err = lm90_set_temphyst(data, val); in lm90_temp_write()
1244 err = lm90_set_temp8(data, lm90_temp_emerg_index[channel], val); in lm90_temp_write()
1247 err = lm90_set_temp11(data, REMOTE_OFFSET, val); in lm90_temp_write()
1285 static int lm90_chip_read(struct device *dev, u32 attr, int channel, long *val) in lm90_chip_read() argument
1298 *val = data->update_interval; in lm90_chip_read()
1301 *val = data->alarms; in lm90_chip_read()
1310 static int lm90_chip_write(struct device *dev, u32 attr, int channel, long val) in lm90_chip_write() argument
1325 clamp_val(val, 0, 100000)); in lm90_chip_write()
1350 u32 attr, int channel, long *val) in lm90_read() argument
1354 return lm90_chip_read(dev, attr, channel, val); in lm90_read()
1356 return lm90_temp_read(dev, attr, channel, val); in lm90_read()
1363 u32 attr, int channel, long val) in lm90_write() argument
1367 return lm90_chip_write(dev, attr, channel, val); in lm90_write()
1369 return lm90_temp_write(dev, attr, channel, val); in lm90_write()