diff options
author | Constantine Shulyupin <const@MakeLinux.com> | 2015-07-27 18:01:07 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-08-09 16:44:27 -0400 |
commit | 1c6e8f6ba89c59270db223284d47e3c928c6fbfc (patch) | |
tree | 25eb3f1342b074d6775f0a0db3bf4ced0023b8c7 /drivers/hwmon/nct7802.c | |
parent | a1dc86ebd2f2eb6652c8be9311c16acccd1708f8 (diff) |
hwmon: (nct7802) Add auto_point attributes
Introduced REG_PWM, pwm[1..3]_auto_point[1..5]_temp,
pwm[1..3]_auto_point[1..5]_pwm, nct7802_auto_point_attrs,
nct7802_auto_point_group, updated nct7802_regmap_is_volatile
Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/nct7802.c')
-rw-r--r-- | drivers/hwmon/nct7802.c | 130 |
1 files changed, 126 insertions, 4 deletions
diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c index f4908bb228b8..3ce33d244cc0 100644 --- a/drivers/hwmon/nct7802.c +++ b/drivers/hwmon/nct7802.c | |||
@@ -53,6 +53,7 @@ static const u8 REG_VOLTAGE_LIMIT_MSB_SHIFT[2][5] = { | |||
53 | #define REG_PECI_ENABLE 0x23 | 53 | #define REG_PECI_ENABLE 0x23 |
54 | #define REG_FAN_ENABLE 0x24 | 54 | #define REG_FAN_ENABLE 0x24 |
55 | #define REG_VMON_ENABLE 0x25 | 55 | #define REG_VMON_ENABLE 0x25 |
56 | #define REG_PWM(x) (0x60 + (x)) | ||
56 | #define REG_SMARTFAN_EN(x) (0x64 + (x) / 2) | 57 | #define REG_SMARTFAN_EN(x) (0x64 + (x) / 2) |
57 | #define SMARTFAN_EN_SHIFT(x) ((x) % 2 * 4) | 58 | #define SMARTFAN_EN_SHIFT(x) ((x) % 2 * 4) |
58 | #define REG_VENDOR_ID 0xfd | 59 | #define REG_VENDOR_ID 0xfd |
@@ -130,6 +131,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | |||
130 | unsigned int val; | 131 | unsigned int val; |
131 | int ret; | 132 | int ret; |
132 | 133 | ||
134 | if (!attr->index) | ||
135 | return sprintf(buf, "255\n"); | ||
136 | |||
133 | ret = regmap_read(data->regmap, attr->index, &val); | 137 | ret = regmap_read(data->regmap, attr->index, &val); |
134 | if (ret < 0) | 138 | if (ret < 0) |
135 | return ret; | 139 | return ret; |
@@ -826,9 +830,12 @@ static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); | |||
826 | static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); | 830 | static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); |
827 | 831 | ||
828 | /* 7.2.91... Fan Control Output Value */ | 832 | /* 7.2.91... Fan Control Output Value */ |
829 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x60); | 833 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, |
830 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x61); | 834 | REG_PWM(0)); |
831 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x62); | 835 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, |
836 | REG_PWM(1)); | ||
837 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_pwm, | ||
838 | REG_PWM(2)); | ||
832 | 839 | ||
833 | /* 7.2.95... Temperature to Fan mapping Relationships Register */ | 840 | /* 7.2.95... Temperature to Fan mapping Relationships Register */ |
834 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 841 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
@@ -893,11 +900,125 @@ static struct attribute_group nct7802_pwm_group = { | |||
893 | .attrs = nct7802_pwm_attrs, | 900 | .attrs = nct7802_pwm_attrs, |
894 | }; | 901 | }; |
895 | 902 | ||
903 | /* 7.2.115... 0x80-0x83, 0x84 Temperature (X-axis) transition */ | ||
904 | static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR, | ||
905 | show_temp, store_temp, 0x80, 0); | ||
906 | static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR, | ||
907 | show_temp, store_temp, 0x81, 0); | ||
908 | static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR, | ||
909 | show_temp, store_temp, 0x82, 0); | ||
910 | static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_temp, S_IRUGO | S_IWUSR, | ||
911 | show_temp, store_temp, 0x83, 0); | ||
912 | static SENSOR_DEVICE_ATTR_2(pwm1_auto_point5_temp, S_IRUGO | S_IWUSR, | ||
913 | show_temp, store_temp, 0x84, 0); | ||
914 | |||
915 | /* 7.2.120... 0x85-0x88 PWM (Y-axis) transition */ | ||
916 | static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, | ||
917 | show_pwm, store_pwm, 0x85); | ||
918 | static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, | ||
919 | show_pwm, store_pwm, 0x86); | ||
920 | static SENSOR_DEVICE_ATTR(pwm1_auto_point3_pwm, S_IRUGO | S_IWUSR, | ||
921 | show_pwm, store_pwm, 0x87); | ||
922 | static SENSOR_DEVICE_ATTR(pwm1_auto_point4_pwm, S_IRUGO | S_IWUSR, | ||
923 | show_pwm, store_pwm, 0x88); | ||
924 | static SENSOR_DEVICE_ATTR(pwm1_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); | ||
925 | |||
926 | /* 7.2.124 Table 2 X-axis Transition Point 1 Register */ | ||
927 | static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR, | ||
928 | show_temp, store_temp, 0x90, 0); | ||
929 | static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR, | ||
930 | show_temp, store_temp, 0x91, 0); | ||
931 | static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR, | ||
932 | show_temp, store_temp, 0x92, 0); | ||
933 | static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_temp, S_IRUGO | S_IWUSR, | ||
934 | show_temp, store_temp, 0x93, 0); | ||
935 | static SENSOR_DEVICE_ATTR_2(pwm2_auto_point5_temp, S_IRUGO | S_IWUSR, | ||
936 | show_temp, store_temp, 0x94, 0); | ||
937 | |||
938 | /* 7.2.129 Table 2 Y-axis Transition Point 1 Register */ | ||
939 | static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, | ||
940 | show_pwm, store_pwm, 0x95); | ||
941 | static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, | ||
942 | show_pwm, store_pwm, 0x96); | ||
943 | static SENSOR_DEVICE_ATTR(pwm2_auto_point3_pwm, S_IRUGO | S_IWUSR, | ||
944 | show_pwm, store_pwm, 0x97); | ||
945 | static SENSOR_DEVICE_ATTR(pwm2_auto_point4_pwm, S_IRUGO | S_IWUSR, | ||
946 | show_pwm, store_pwm, 0x98); | ||
947 | static SENSOR_DEVICE_ATTR(pwm2_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); | ||
948 | |||
949 | /* 7.2.133 Table 3 X-axis Transition Point 1 Register */ | ||
950 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR, | ||
951 | show_temp, store_temp, 0xA0, 0); | ||
952 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR, | ||
953 | show_temp, store_temp, 0xA1, 0); | ||
954 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR, | ||
955 | show_temp, store_temp, 0xA2, 0); | ||
956 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_temp, S_IRUGO | S_IWUSR, | ||
957 | show_temp, store_temp, 0xA3, 0); | ||
958 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point5_temp, S_IRUGO | S_IWUSR, | ||
959 | show_temp, store_temp, 0xA4, 0); | ||
960 | |||
961 | /* 7.2.138 Table 3 Y-axis Transition Point 1 Register */ | ||
962 | static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, | ||
963 | show_pwm, store_pwm, 0xA5); | ||
964 | static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, | ||
965 | show_pwm, store_pwm, 0xA6); | ||
966 | static SENSOR_DEVICE_ATTR(pwm3_auto_point3_pwm, S_IRUGO | S_IWUSR, | ||
967 | show_pwm, store_pwm, 0xA7); | ||
968 | static SENSOR_DEVICE_ATTR(pwm3_auto_point4_pwm, S_IRUGO | S_IWUSR, | ||
969 | show_pwm, store_pwm, 0xA8); | ||
970 | static SENSOR_DEVICE_ATTR(pwm3_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); | ||
971 | |||
972 | static struct attribute *nct7802_auto_point_attrs[] = { | ||
973 | &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr, | ||
974 | &sensor_dev_attr_pwm1_auto_point2_temp.dev_attr.attr, | ||
975 | &sensor_dev_attr_pwm1_auto_point3_temp.dev_attr.attr, | ||
976 | &sensor_dev_attr_pwm1_auto_point4_temp.dev_attr.attr, | ||
977 | &sensor_dev_attr_pwm1_auto_point5_temp.dev_attr.attr, | ||
978 | |||
979 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | ||
980 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | ||
981 | &sensor_dev_attr_pwm1_auto_point3_pwm.dev_attr.attr, | ||
982 | &sensor_dev_attr_pwm1_auto_point4_pwm.dev_attr.attr, | ||
983 | &sensor_dev_attr_pwm1_auto_point5_pwm.dev_attr.attr, | ||
984 | |||
985 | &sensor_dev_attr_pwm2_auto_point1_temp.dev_attr.attr, | ||
986 | &sensor_dev_attr_pwm2_auto_point2_temp.dev_attr.attr, | ||
987 | &sensor_dev_attr_pwm2_auto_point3_temp.dev_attr.attr, | ||
988 | &sensor_dev_attr_pwm2_auto_point4_temp.dev_attr.attr, | ||
989 | &sensor_dev_attr_pwm2_auto_point5_temp.dev_attr.attr, | ||
990 | |||
991 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
992 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
993 | &sensor_dev_attr_pwm2_auto_point3_pwm.dev_attr.attr, | ||
994 | &sensor_dev_attr_pwm2_auto_point4_pwm.dev_attr.attr, | ||
995 | &sensor_dev_attr_pwm2_auto_point5_pwm.dev_attr.attr, | ||
996 | |||
997 | &sensor_dev_attr_pwm3_auto_point1_temp.dev_attr.attr, | ||
998 | &sensor_dev_attr_pwm3_auto_point2_temp.dev_attr.attr, | ||
999 | &sensor_dev_attr_pwm3_auto_point3_temp.dev_attr.attr, | ||
1000 | &sensor_dev_attr_pwm3_auto_point4_temp.dev_attr.attr, | ||
1001 | &sensor_dev_attr_pwm3_auto_point5_temp.dev_attr.attr, | ||
1002 | |||
1003 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | ||
1004 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | ||
1005 | &sensor_dev_attr_pwm3_auto_point3_pwm.dev_attr.attr, | ||
1006 | &sensor_dev_attr_pwm3_auto_point4_pwm.dev_attr.attr, | ||
1007 | &sensor_dev_attr_pwm3_auto_point5_pwm.dev_attr.attr, | ||
1008 | |||
1009 | NULL | ||
1010 | }; | ||
1011 | |||
1012 | static struct attribute_group nct7802_auto_point_group = { | ||
1013 | .attrs = nct7802_auto_point_attrs, | ||
1014 | }; | ||
1015 | |||
896 | static const struct attribute_group *nct7802_groups[] = { | 1016 | static const struct attribute_group *nct7802_groups[] = { |
897 | &nct7802_temp_group, | 1017 | &nct7802_temp_group, |
898 | &nct7802_in_group, | 1018 | &nct7802_in_group, |
899 | &nct7802_fan_group, | 1019 | &nct7802_fan_group, |
900 | &nct7802_pwm_group, | 1020 | &nct7802_pwm_group, |
1021 | &nct7802_auto_point_group, | ||
901 | NULL | 1022 | NULL |
902 | }; | 1023 | }; |
903 | 1024 | ||
@@ -945,7 +1066,8 @@ static int nct7802_detect(struct i2c_client *client, | |||
945 | 1066 | ||
946 | static bool nct7802_regmap_is_volatile(struct device *dev, unsigned int reg) | 1067 | static bool nct7802_regmap_is_volatile(struct device *dev, unsigned int reg) |
947 | { | 1068 | { |
948 | return reg != REG_BANK && reg <= 0x20; | 1069 | return (reg != REG_BANK && reg <= 0x20) || |
1070 | (reg >= REG_PWM(0) && reg <= REG_PWM(2)); | ||
949 | } | 1071 | } |
950 | 1072 | ||
951 | static const struct regmap_config nct7802_regmap_config = { | 1073 | static const struct regmap_config nct7802_regmap_config = { |