Commit 2fe28ab51d200121b9c39f9b34cf2d132fcf5de1
Committed by
Jean Delvare
1 parent
d216f6809e
Exists in
master
and in
6 other branches
hwmon: (lm63) Support extended lookup table of LM96163
The LM96163 has an extended lookup table with 12 entries instead of 8, add support for that. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Showing 1 changed file with 62 additions and 7 deletions Side-by-side Diff
drivers/hwmon/lm63.c
... | ... | @@ -203,18 +203,19 @@ |
203 | 203 | |
204 | 204 | int update_interval; /* in milliseconds */ |
205 | 205 | int max_convrate_hz; |
206 | + int lut_size; /* 8 or 12 */ | |
206 | 207 | |
207 | 208 | /* registers values */ |
208 | 209 | u8 config, config_fan; |
209 | 210 | u16 fan[2]; /* 0: input |
210 | 211 | 1: low limit */ |
211 | 212 | u8 pwm1_freq; |
212 | - u8 pwm1[9]; /* 0: current output | |
213 | - 1-8: lookup table */ | |
214 | - s8 temp8[11]; /* 0: local input | |
213 | + u8 pwm1[13]; /* 0: current output | |
214 | + 1-12: lookup table */ | |
215 | + s8 temp8[15]; /* 0: local input | |
215 | 216 | 1: local high limit |
216 | 217 | 2: remote critical limit |
217 | - 3-10: lookup table */ | |
218 | + 3-14: lookup table */ | |
218 | 219 | s16 temp11[4]; /* 0: remote input |
219 | 220 | 1: remote low limit |
220 | 221 | 2: remote high limit |
... | ... | @@ -653,6 +654,26 @@ |
653 | 654 | show_lut_temp, NULL, 10); |
654 | 655 | static SENSOR_DEVICE_ATTR(pwm1_auto_point8_temp_hyst, S_IRUGO, |
655 | 656 | show_lut_temp_hyst, NULL, 10); |
657 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point9_pwm, S_IRUGO, show_pwm1, NULL, 9); | |
658 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point9_temp, S_IRUGO, | |
659 | + show_lut_temp, NULL, 11); | |
660 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point9_temp_hyst, S_IRUGO, | |
661 | + show_lut_temp_hyst, NULL, 11); | |
662 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point10_pwm, S_IRUGO, show_pwm1, NULL, 10); | |
663 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point10_temp, S_IRUGO, | |
664 | + show_lut_temp, NULL, 12); | |
665 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point10_temp_hyst, S_IRUGO, | |
666 | + show_lut_temp_hyst, NULL, 12); | |
667 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point11_pwm, S_IRUGO, show_pwm1, NULL, 11); | |
668 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point11_temp, S_IRUGO, | |
669 | + show_lut_temp, NULL, 13); | |
670 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point11_temp_hyst, S_IRUGO, | |
671 | + show_lut_temp_hyst, NULL, 13); | |
672 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point12_pwm, S_IRUGO, show_pwm1, NULL, 12); | |
673 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point12_temp, S_IRUGO, | |
674 | + show_lut_temp, NULL, 14); | |
675 | +static SENSOR_DEVICE_ATTR(pwm1_auto_point12_temp_hyst, S_IRUGO, | |
676 | + show_lut_temp_hyst, NULL, 14); | |
656 | 677 | |
657 | 678 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_local_temp8, NULL, 0); |
658 | 679 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_local_temp8, |
... | ... | @@ -732,6 +753,26 @@ |
732 | 753 | NULL |
733 | 754 | }; |
734 | 755 | |
756 | +static struct attribute *lm63_attributes_extra_lut[] = { | |
757 | + &sensor_dev_attr_pwm1_auto_point9_pwm.dev_attr.attr, | |
758 | + &sensor_dev_attr_pwm1_auto_point9_temp.dev_attr.attr, | |
759 | + &sensor_dev_attr_pwm1_auto_point9_temp_hyst.dev_attr.attr, | |
760 | + &sensor_dev_attr_pwm1_auto_point10_pwm.dev_attr.attr, | |
761 | + &sensor_dev_attr_pwm1_auto_point10_temp.dev_attr.attr, | |
762 | + &sensor_dev_attr_pwm1_auto_point10_temp_hyst.dev_attr.attr, | |
763 | + &sensor_dev_attr_pwm1_auto_point11_pwm.dev_attr.attr, | |
764 | + &sensor_dev_attr_pwm1_auto_point11_temp.dev_attr.attr, | |
765 | + &sensor_dev_attr_pwm1_auto_point11_temp_hyst.dev_attr.attr, | |
766 | + &sensor_dev_attr_pwm1_auto_point12_pwm.dev_attr.attr, | |
767 | + &sensor_dev_attr_pwm1_auto_point12_temp.dev_attr.attr, | |
768 | + &sensor_dev_attr_pwm1_auto_point12_temp_hyst.dev_attr.attr, | |
769 | + NULL | |
770 | +}; | |
771 | + | |
772 | +static const struct attribute_group lm63_group_extra_lut = { | |
773 | + .attrs = lm63_attributes_extra_lut, | |
774 | +}; | |
775 | + | |
735 | 776 | /* |
736 | 777 | * On LM63, temp2_crit can be set only once, which should be job |
737 | 778 | * of the bootloader. |
... | ... | @@ -861,6 +902,11 @@ |
861 | 902 | &dev_attr_temp2_type); |
862 | 903 | if (err) |
863 | 904 | goto exit_remove_files; |
905 | + | |
906 | + err = sysfs_create_group(&new_client->dev.kobj, | |
907 | + &lm63_group_extra_lut); | |
908 | + if (err) | |
909 | + goto exit_remove_files; | |
864 | 910 | } |
865 | 911 | |
866 | 912 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
867 | 913 | |
... | ... | @@ -872,9 +918,13 @@ |
872 | 918 | return 0; |
873 | 919 | |
874 | 920 | exit_remove_files: |
875 | - device_remove_file(&new_client->dev, &dev_attr_temp2_type); | |
876 | 921 | sysfs_remove_group(&new_client->dev.kobj, &lm63_group); |
877 | 922 | sysfs_remove_group(&new_client->dev.kobj, &lm63_group_fan1); |
923 | + if (data->kind == lm96163) { | |
924 | + device_remove_file(&new_client->dev, &dev_attr_temp2_type); | |
925 | + sysfs_remove_group(&new_client->dev.kobj, | |
926 | + &lm63_group_extra_lut); | |
927 | + } | |
878 | 928 | exit_free: |
879 | 929 | kfree(data); |
880 | 930 | exit: |
881 | 931 | |
... | ... | @@ -914,9 +964,11 @@ |
914 | 964 | case lm63: |
915 | 965 | case lm64: |
916 | 966 | data->max_convrate_hz = LM63_MAX_CONVRATE_HZ; |
967 | + data->lut_size = 8; | |
917 | 968 | break; |
918 | 969 | case lm96163: |
919 | 970 | data->max_convrate_hz = LM96163_MAX_CONVRATE_HZ; |
971 | + data->lut_size = 12; | |
920 | 972 | data->trutherm |
921 | 973 | = i2c_smbus_read_byte_data(client, |
922 | 974 | LM96163_REG_TRUTHERM) & 0x02; |
923 | 975 | |
... | ... | @@ -963,9 +1015,12 @@ |
963 | 1015 | struct lm63_data *data = i2c_get_clientdata(client); |
964 | 1016 | |
965 | 1017 | hwmon_device_unregister(data->hwmon_dev); |
966 | - device_remove_file(&client->dev, &dev_attr_temp2_type); | |
967 | 1018 | sysfs_remove_group(&client->dev.kobj, &lm63_group); |
968 | 1019 | sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1); |
1020 | + if (data->kind == lm96163) { | |
1021 | + device_remove_file(&client->dev, &dev_attr_temp2_type); | |
1022 | + sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); | |
1023 | + } | |
969 | 1024 | |
970 | 1025 | kfree(data); |
971 | 1026 | return 0; |
... | ... | @@ -1046,7 +1101,7 @@ |
1046 | 1101 | |
1047 | 1102 | if (time_after(jiffies, data->lut_last_updated + 5 * HZ) || |
1048 | 1103 | !data->lut_valid) { |
1049 | - for (i = 0; i < 8; i++) { | |
1104 | + for (i = 0; i < data->lut_size; i++) { | |
1050 | 1105 | data->pwm1[1 + i] = i2c_smbus_read_byte_data(client, |
1051 | 1106 | LM63_REG_LUT_PWM(i)); |
1052 | 1107 | data->temp8[3 + i] = i2c_smbus_read_byte_data(client, |