Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 2 | * lm85.c - Part of lm_sensors, Linux kernel modules for hardware |
| 3 | * monitoring |
| 4 | * Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
| 5 | * Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> |
| 6 | * Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> |
| 7 | * Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> |
Jean Delvare | 590e853 | 2014-06-11 18:35:56 +0200 | [diff] [blame] | 8 | * Copyright (C) 2007--2014 Jean Delvare <jdelvare@suse.de> |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 9 | * |
| 10 | * Chip details at <http://www.national.com/ds/LM/LM85.pdf> |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 25 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/module.h> |
Javier Martinez Canillas | 00c0f9d | 2017-02-24 10:13:03 -0300 | [diff] [blame] | 28 | #include <linux/of_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/init.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/jiffies.h> |
| 32 | #include <linux/i2c.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 33 | #include <linux/hwmon.h> |
Jean Delvare | 303760b | 2005-07-31 21:52:01 +0200 | [diff] [blame] | 34 | #include <linux/hwmon-vid.h> |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 35 | #include <linux/hwmon-sysfs.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 36 | #include <linux/err.h> |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 37 | #include <linux/mutex.h> |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 38 | #include <linux/util_macros.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /* Addresses to scan */ |
Mark M. Hoffman | 25e9c86 | 2008-02-17 22:28:03 -0500 | [diff] [blame] | 41 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Jean Delvare | e5e9f44 | 2009-12-14 21:17:27 +0100 | [diff] [blame] | 43 | enum chips { |
Jean Delvare | 590e853 | 2014-06-11 18:35:56 +0200 | [diff] [blame] | 44 | lm85, |
Jean Delvare | e5e9f44 | 2009-12-14 21:17:27 +0100 | [diff] [blame] | 45 | adm1027, adt7463, adt7468, |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 46 | emc6d100, emc6d102, emc6d103, emc6d103s |
Jean Delvare | e5e9f44 | 2009-12-14 21:17:27 +0100 | [diff] [blame] | 47 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | /* The LM85 registers */ |
| 50 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 51 | #define LM85_REG_IN(nr) (0x20 + (nr)) |
| 52 | #define LM85_REG_IN_MIN(nr) (0x44 + (nr) * 2) |
| 53 | #define LM85_REG_IN_MAX(nr) (0x45 + (nr) * 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 55 | #define LM85_REG_TEMP(nr) (0x25 + (nr)) |
| 56 | #define LM85_REG_TEMP_MIN(nr) (0x4e + (nr) * 2) |
| 57 | #define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* Fan speeds are LSB, MSB (2 bytes) */ |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 60 | #define LM85_REG_FAN(nr) (0x28 + (nr) * 2) |
| 61 | #define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 63 | #define LM85_REG_PWM(nr) (0x30 + (nr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 65 | #define LM85_REG_COMPANY 0x3e |
| 66 | #define LM85_REG_VERSTEP 0x3f |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 67 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 68 | #define ADT7468_REG_CFG5 0x7c |
| 69 | #define ADT7468_OFF64 (1 << 0) |
| 70 | #define ADT7468_HFPWM (1 << 1) |
| 71 | #define IS_ADT7468_OFF64(data) \ |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 72 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64)) |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 73 | #define IS_ADT7468_HFPWM(data) \ |
Jean Delvare | f6c61cf | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 74 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_HFPWM)) |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | /* These are the recognized values for the above regs */ |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 77 | #define LM85_COMPANY_NATIONAL 0x01 |
| 78 | #define LM85_COMPANY_ANALOG_DEV 0x41 |
| 79 | #define LM85_COMPANY_SMSC 0x5c |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 80 | #define LM85_VERSTEP_LM85C 0x60 |
| 81 | #define LM85_VERSTEP_LM85B 0x62 |
| 82 | #define LM85_VERSTEP_LM96000_1 0x68 |
| 83 | #define LM85_VERSTEP_LM96000_2 0x69 |
| 84 | #define LM85_VERSTEP_ADM1027 0x60 |
| 85 | #define LM85_VERSTEP_ADT7463 0x62 |
| 86 | #define LM85_VERSTEP_ADT7463C 0x6A |
| 87 | #define LM85_VERSTEP_ADT7468_1 0x71 |
| 88 | #define LM85_VERSTEP_ADT7468_2 0x72 |
| 89 | #define LM85_VERSTEP_EMC6D100_A0 0x60 |
| 90 | #define LM85_VERSTEP_EMC6D100_A1 0x61 |
| 91 | #define LM85_VERSTEP_EMC6D102 0x65 |
| 92 | #define LM85_VERSTEP_EMC6D103_A0 0x68 |
| 93 | #define LM85_VERSTEP_EMC6D103_A1 0x69 |
| 94 | #define LM85_VERSTEP_EMC6D103S 0x6A /* Also known as EMC6D103:A2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 96 | #define LM85_REG_CONFIG 0x40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 98 | #define LM85_REG_ALARM1 0x41 |
| 99 | #define LM85_REG_ALARM2 0x42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 101 | #define LM85_REG_VID 0x43 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | /* Automated FAN control */ |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 104 | #define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr)) |
| 105 | #define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr)) |
| 106 | #define LM85_REG_AFAN_SPIKE1 0x62 |
| 107 | #define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr)) |
| 108 | #define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr)) |
| 109 | #define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr)) |
| 110 | #define LM85_REG_AFAN_HYST1 0x6d |
| 111 | #define LM85_REG_AFAN_HYST2 0x6e |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 113 | #define ADM1027_REG_EXTEND_ADC1 0x76 |
| 114 | #define ADM1027_REG_EXTEND_ADC2 0x77 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | #define EMC6D100_REG_ALARM3 0x7d |
| 117 | /* IN5, IN6 and IN7 */ |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 118 | #define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5)) |
| 119 | #define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2) |
| 120 | #define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2) |
| 121 | #define EMC6D102_REG_EXTEND_ADC1 0x85 |
| 122 | #define EMC6D102_REG_EXTEND_ADC2 0x86 |
| 123 | #define EMC6D102_REG_EXTEND_ADC3 0x87 |
| 124 | #define EMC6D102_REG_EXTEND_ADC4 0x88 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 126 | /* |
| 127 | * Conversions. Rounding and limit checking is only done on the TO_REG |
| 128 | * variants. Note that you should be a bit careful with which arguments |
| 129 | * these macros are called: arguments may be evaluated more than once. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | */ |
| 131 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 132 | /* IN are scaled according to built-in resistors */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 133 | static const int lm85_scaling[] = { /* .001 Volts */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 134 | 2500, 2250, 3300, 5000, 12000, |
| 135 | 3300, 1500, 1800 /*EMC6D100*/ |
| 136 | }; |
| 137 | #define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 139 | #define INS_TO_REG(n, val) \ |
Guenter Roeck | 67b2003 | 2016-12-04 18:16:48 -0800 | [diff] [blame] | 140 | SCALE(clamp_val(val, 0, 255 * lm85_scaling[n] / 192), \ |
| 141 | lm85_scaling[n], 192) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 143 | #define INSEXT_FROM_REG(n, val, ext) \ |
Jean Delvare | 5a4d3ef | 2007-07-05 20:38:32 +0200 | [diff] [blame] | 144 | SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 146 | #define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | /* FAN speed is measured using 90kHz clock */ |
Jean Delvare | 63f281a | 2007-07-05 20:39:40 +0200 | [diff] [blame] | 149 | static inline u16 FAN_TO_REG(unsigned long val) |
| 150 | { |
| 151 | if (!val) |
| 152 | return 0xffff; |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 153 | return clamp_val(5400000 / val, 1, 0xfffe); |
Jean Delvare | 63f281a | 2007-07-05 20:39:40 +0200 | [diff] [blame] | 154 | } |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 155 | #define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \ |
| 156 | 5400000 / (val)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
| 158 | /* Temperature is reported in .001 degC increments */ |
| 159 | #define TEMP_TO_REG(val) \ |
Guenter Roeck | 3248c3b | 2014-07-29 22:23:12 -0700 | [diff] [blame] | 160 | DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 161 | #define TEMPEXT_FROM_REG(val, ext) \ |
Jean Delvare | 5a4d3ef | 2007-07-05 20:38:32 +0200 | [diff] [blame] | 162 | SCALE(((val) << 4) + (ext), 16, 1000) |
| 163 | #define TEMP_FROM_REG(val) ((val) * 1000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 165 | #define PWM_TO_REG(val) clamp_val(val, 0, 255) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #define PWM_FROM_REG(val) (val) |
| 167 | |
| 168 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 169 | /* |
| 170 | * ZONEs have the following parameters: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | * Limit (low) temp, 1. degC |
| 172 | * Hysteresis (below limit), 1. degC (0-15) |
| 173 | * Range of speed control, .1 degC (2-80) |
| 174 | * Critical (high) temp, 1. degC |
| 175 | * |
| 176 | * FAN PWMs have the following parameters: |
| 177 | * Reference Zone, 1, 2, 3, etc. |
| 178 | * Spinup time, .05 sec |
| 179 | * PWM value at limit/low temp, 1 count |
| 180 | * PWM Frequency, 1. Hz |
| 181 | * PWM is Min or OFF below limit, flag |
| 182 | * Invert PWM output, flag |
| 183 | * |
| 184 | * Some chips filter the temp, others the fan. |
| 185 | * Filter constant (or disabled) .1 seconds |
| 186 | */ |
| 187 | |
| 188 | /* These are the zone temperature range encodings in .001 degree C */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 189 | static const int lm85_range_map[] = { |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 190 | 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000, |
| 191 | 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000 |
| 192 | }; |
| 193 | |
Guenter Roeck | 3248c3b | 2014-07-29 22:23:12 -0700 | [diff] [blame] | 194 | static int RANGE_TO_REG(long range) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 196 | return find_closest(range, lm85_range_map, ARRAY_SIZE(lm85_range_map)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 198 | #define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | /* These are the PWM frequency encodings */ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 201 | static const int lm85_freq_map[8] = { /* 1 Hz */ |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 202 | 10, 15, 23, 30, 38, 47, 61, 94 |
| 203 | }; |
| 204 | static const int adm1027_freq_map[8] = { /* 1 Hz */ |
| 205 | 11, 15, 22, 29, 35, 44, 59, 88 |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 206 | }; |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 207 | #define FREQ_MAP_LEN 8 |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 208 | |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 209 | static int FREQ_TO_REG(const int *map, |
| 210 | unsigned int map_size, unsigned long freq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 212 | return find_closest(freq, map, map_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | } |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 214 | |
| 215 | static int FREQ_FROM_REG(const int *map, u8 reg) |
| 216 | { |
| 217 | return map[reg & 0x07]; |
| 218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 220 | /* |
| 221 | * Since we can't use strings, I'm abusing these numbers |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | * to stand in for the following meanings: |
| 223 | * 1 -- PWM responds to Zone 1 |
| 224 | * 2 -- PWM responds to Zone 2 |
| 225 | * 3 -- PWM responds to Zone 3 |
| 226 | * 23 -- PWM responds to the higher temp of Zone 2 or 3 |
| 227 | * 123 -- PWM responds to highest of Zone 1, 2, or 3 |
| 228 | * 0 -- PWM is always at 0% (ie, off) |
| 229 | * -1 -- PWM is always at 100% |
| 230 | * -2 -- PWM responds to manual control |
| 231 | */ |
| 232 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 233 | static const int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; |
| 234 | #define ZONE_FROM_REG(val) lm85_zone_map[(val) >> 5] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 236 | static int ZONE_TO_REG(int zone) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { |
| 238 | int i; |
| 239 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 240 | for (i = 0; i <= 7; ++i) |
| 241 | if (zone == lm85_zone_map[i]) |
| 242 | break; |
| 243 | if (i > 7) /* Not found. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | i = 3; /* Always 100% */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 245 | return i << 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 248 | #define HYST_TO_REG(val) clamp_val(((val) + 500) / 1000, 0, 15) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 249 | #define HYST_FROM_REG(val) ((val) * 1000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 251 | /* |
| 252 | * Chip sampling rates |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | * |
| 254 | * Some sensors are not updated more frequently than once per second |
| 255 | * so it doesn't make sense to read them more often than that. |
| 256 | * We cache the results and return the saved data if the driver |
| 257 | * is called again before a second has elapsed. |
| 258 | * |
| 259 | * Also, there is significant configuration data for this chip |
| 260 | * given the automatic PWM fan control that is possible. There |
| 261 | * are about 47 bytes of config data to only 22 bytes of actual |
| 262 | * readings. So, we keep the config data up to date in the cache |
| 263 | * when it is written and only sample it once every 1 *minute* |
| 264 | */ |
| 265 | #define LM85_DATA_INTERVAL (HZ + HZ / 2) |
| 266 | #define LM85_CONFIG_INTERVAL (1 * 60 * HZ) |
| 267 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 268 | /* |
| 269 | * LM85 can automatically adjust fan speeds based on temperature |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | * This structure encapsulates an entire Zone config. There are |
| 271 | * three zones (one for each temperature input) on the lm85 |
| 272 | */ |
| 273 | struct lm85_zone { |
| 274 | s8 limit; /* Low temp limit */ |
| 275 | u8 hyst; /* Low limit hysteresis. (0-15) */ |
| 276 | u8 range; /* Temp range, encoded */ |
| 277 | s8 critical; /* "All fans ON" temp limit */ |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 278 | u8 max_desired; /* |
| 279 | * Actual "max" temperature specified. Preserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | * to prevent "drift" as other autofan control |
| 281 | * values change. |
| 282 | */ |
| 283 | }; |
| 284 | |
| 285 | struct lm85_autofan { |
| 286 | u8 config; /* Register value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | u8 min_pwm; /* Minimum PWM value, encoded */ |
| 288 | u8 min_off; /* Min PWM or OFF below "limit", flag */ |
| 289 | }; |
| 290 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 291 | /* |
| 292 | * For each registered chip, we need to keep some data in memory. |
| 293 | * The structure is dynamically allocated. |
| 294 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | struct lm85_data { |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 296 | struct i2c_client *client; |
| 297 | const struct attribute_group *groups[6]; |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 298 | const int *freq_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | enum chips type; |
| 300 | |
Guenter Roeck | de24880 | 2011-02-25 08:19:42 -0800 | [diff] [blame] | 301 | bool has_vid5; /* true if VID5 is configured for ADT7463 or ADT7468 */ |
| 302 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 303 | struct mutex update_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | int valid; /* !=0 if following fields are valid */ |
| 305 | unsigned long last_reading; /* In jiffies */ |
| 306 | unsigned long last_config; /* In jiffies */ |
| 307 | |
| 308 | u8 in[8]; /* Register value */ |
| 309 | u8 in_max[8]; /* Register value */ |
| 310 | u8 in_min[8]; /* Register value */ |
| 311 | s8 temp[3]; /* Register value */ |
| 312 | s8 temp_min[3]; /* Register value */ |
| 313 | s8 temp_max[3]; /* Register value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | u16 fan[4]; /* Register value */ |
| 315 | u16 fan_min[4]; /* Register value */ |
| 316 | u8 pwm[3]; /* Register value */ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 317 | u8 pwm_freq[3]; /* Register encoding */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | u8 temp_ext[3]; /* Decoded values */ |
| 319 | u8 in_ext[8]; /* Decoded values */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | u8 vid; /* Register value */ |
| 321 | u8 vrm; /* VRM version */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | u32 alarms; /* Register encoding, combined */ |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 323 | u8 cfg5; /* Config Register 5 on ADT7468 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | struct lm85_autofan autofan[3]; |
| 325 | struct lm85_zone zone[3]; |
| 326 | }; |
| 327 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 328 | static int lm85_read_value(struct i2c_client *client, u8 reg) |
| 329 | { |
| 330 | int res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 332 | /* What size location is it? */ |
| 333 | switch (reg) { |
| 334 | case LM85_REG_FAN(0): /* Read WORD data */ |
| 335 | case LM85_REG_FAN(1): |
| 336 | case LM85_REG_FAN(2): |
| 337 | case LM85_REG_FAN(3): |
| 338 | case LM85_REG_FAN_MIN(0): |
| 339 | case LM85_REG_FAN_MIN(1): |
| 340 | case LM85_REG_FAN_MIN(2): |
| 341 | case LM85_REG_FAN_MIN(3): |
| 342 | case LM85_REG_ALARM1: /* Read both bytes at once */ |
| 343 | res = i2c_smbus_read_byte_data(client, reg) & 0xff; |
| 344 | res |= i2c_smbus_read_byte_data(client, reg + 1) << 8; |
| 345 | break; |
| 346 | default: /* Read BYTE data */ |
| 347 | res = i2c_smbus_read_byte_data(client, reg); |
| 348 | break; |
| 349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 351 | return res; |
| 352 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 354 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value) |
| 355 | { |
| 356 | switch (reg) { |
| 357 | case LM85_REG_FAN(0): /* Write WORD data */ |
| 358 | case LM85_REG_FAN(1): |
| 359 | case LM85_REG_FAN(2): |
| 360 | case LM85_REG_FAN(3): |
| 361 | case LM85_REG_FAN_MIN(0): |
| 362 | case LM85_REG_FAN_MIN(1): |
| 363 | case LM85_REG_FAN_MIN(2): |
| 364 | case LM85_REG_FAN_MIN(3): |
| 365 | /* NOTE: ALARM is read only, so not included here */ |
| 366 | i2c_smbus_write_byte_data(client, reg, value & 0xff); |
| 367 | i2c_smbus_write_byte_data(client, reg + 1, value >> 8); |
| 368 | break; |
| 369 | default: /* Write BYTE data */ |
| 370 | i2c_smbus_write_byte_data(client, reg, value); |
| 371 | break; |
| 372 | } |
| 373 | } |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 374 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 375 | static struct lm85_data *lm85_update_device(struct device *dev) |
| 376 | { |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 377 | struct lm85_data *data = dev_get_drvdata(dev); |
| 378 | struct i2c_client *client = data->client; |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 379 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 381 | mutex_lock(&data->update_lock); |
| 382 | |
| 383 | if (!data->valid || |
| 384 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL)) { |
| 385 | /* Things that change quickly */ |
| 386 | dev_dbg(&client->dev, "Reading sensor values\n"); |
| 387 | |
| 388 | /* |
| 389 | * Have to read extended bits first to "freeze" the |
| 390 | * more significant bits that are read later. |
| 391 | * There are 2 additional resolution bits per channel and we |
| 392 | * have room for 4, so we shift them to the left. |
| 393 | */ |
| 394 | if (data->type == adm1027 || data->type == adt7463 || |
| 395 | data->type == adt7468) { |
| 396 | int ext1 = lm85_read_value(client, |
| 397 | ADM1027_REG_EXTEND_ADC1); |
| 398 | int ext2 = lm85_read_value(client, |
| 399 | ADM1027_REG_EXTEND_ADC2); |
| 400 | int val = (ext1 << 8) + ext2; |
| 401 | |
| 402 | for (i = 0; i <= 4; i++) |
| 403 | data->in_ext[i] = |
| 404 | ((val >> (i * 2)) & 0x03) << 2; |
| 405 | |
| 406 | for (i = 0; i <= 2; i++) |
| 407 | data->temp_ext[i] = |
| 408 | (val >> ((i + 4) * 2)) & 0x0c; |
| 409 | } |
| 410 | |
| 411 | data->vid = lm85_read_value(client, LM85_REG_VID); |
| 412 | |
| 413 | for (i = 0; i <= 3; ++i) { |
| 414 | data->in[i] = |
| 415 | lm85_read_value(client, LM85_REG_IN(i)); |
| 416 | data->fan[i] = |
| 417 | lm85_read_value(client, LM85_REG_FAN(i)); |
| 418 | } |
| 419 | |
| 420 | if (!data->has_vid5) |
| 421 | data->in[4] = lm85_read_value(client, LM85_REG_IN(4)); |
| 422 | |
| 423 | if (data->type == adt7468) |
| 424 | data->cfg5 = lm85_read_value(client, ADT7468_REG_CFG5); |
| 425 | |
| 426 | for (i = 0; i <= 2; ++i) { |
| 427 | data->temp[i] = |
| 428 | lm85_read_value(client, LM85_REG_TEMP(i)); |
| 429 | data->pwm[i] = |
| 430 | lm85_read_value(client, LM85_REG_PWM(i)); |
| 431 | |
| 432 | if (IS_ADT7468_OFF64(data)) |
| 433 | data->temp[i] -= 64; |
| 434 | } |
| 435 | |
| 436 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); |
| 437 | |
| 438 | if (data->type == emc6d100) { |
| 439 | /* Three more voltage sensors */ |
| 440 | for (i = 5; i <= 7; ++i) { |
| 441 | data->in[i] = lm85_read_value(client, |
| 442 | EMC6D100_REG_IN(i)); |
| 443 | } |
| 444 | /* More alarm bits */ |
| 445 | data->alarms |= lm85_read_value(client, |
| 446 | EMC6D100_REG_ALARM3) << 16; |
| 447 | } else if (data->type == emc6d102 || data->type == emc6d103 || |
| 448 | data->type == emc6d103s) { |
| 449 | /* |
| 450 | * Have to read LSB bits after the MSB ones because |
| 451 | * the reading of the MSB bits has frozen the |
| 452 | * LSBs (backward from the ADM1027). |
| 453 | */ |
| 454 | int ext1 = lm85_read_value(client, |
| 455 | EMC6D102_REG_EXTEND_ADC1); |
| 456 | int ext2 = lm85_read_value(client, |
| 457 | EMC6D102_REG_EXTEND_ADC2); |
| 458 | int ext3 = lm85_read_value(client, |
| 459 | EMC6D102_REG_EXTEND_ADC3); |
| 460 | int ext4 = lm85_read_value(client, |
| 461 | EMC6D102_REG_EXTEND_ADC4); |
| 462 | data->in_ext[0] = ext3 & 0x0f; |
| 463 | data->in_ext[1] = ext4 & 0x0f; |
| 464 | data->in_ext[2] = ext4 >> 4; |
| 465 | data->in_ext[3] = ext3 >> 4; |
| 466 | data->in_ext[4] = ext2 >> 4; |
| 467 | |
| 468 | data->temp_ext[0] = ext1 & 0x0f; |
| 469 | data->temp_ext[1] = ext2 & 0x0f; |
| 470 | data->temp_ext[2] = ext1 >> 4; |
| 471 | } |
| 472 | |
| 473 | data->last_reading = jiffies; |
| 474 | } /* last_reading */ |
| 475 | |
| 476 | if (!data->valid || |
| 477 | time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) { |
| 478 | /* Things that don't change often */ |
| 479 | dev_dbg(&client->dev, "Reading config values\n"); |
| 480 | |
| 481 | for (i = 0; i <= 3; ++i) { |
| 482 | data->in_min[i] = |
| 483 | lm85_read_value(client, LM85_REG_IN_MIN(i)); |
| 484 | data->in_max[i] = |
| 485 | lm85_read_value(client, LM85_REG_IN_MAX(i)); |
| 486 | data->fan_min[i] = |
| 487 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); |
| 488 | } |
| 489 | |
| 490 | if (!data->has_vid5) { |
| 491 | data->in_min[4] = lm85_read_value(client, |
| 492 | LM85_REG_IN_MIN(4)); |
| 493 | data->in_max[4] = lm85_read_value(client, |
| 494 | LM85_REG_IN_MAX(4)); |
| 495 | } |
| 496 | |
| 497 | if (data->type == emc6d100) { |
| 498 | for (i = 5; i <= 7; ++i) { |
| 499 | data->in_min[i] = lm85_read_value(client, |
| 500 | EMC6D100_REG_IN_MIN(i)); |
| 501 | data->in_max[i] = lm85_read_value(client, |
| 502 | EMC6D100_REG_IN_MAX(i)); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | for (i = 0; i <= 2; ++i) { |
| 507 | int val; |
| 508 | |
| 509 | data->temp_min[i] = |
| 510 | lm85_read_value(client, LM85_REG_TEMP_MIN(i)); |
| 511 | data->temp_max[i] = |
| 512 | lm85_read_value(client, LM85_REG_TEMP_MAX(i)); |
| 513 | |
| 514 | data->autofan[i].config = |
| 515 | lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); |
| 516 | val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); |
| 517 | data->pwm_freq[i] = val & 0x07; |
| 518 | data->zone[i].range = val >> 4; |
| 519 | data->autofan[i].min_pwm = |
| 520 | lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); |
| 521 | data->zone[i].limit = |
| 522 | lm85_read_value(client, LM85_REG_AFAN_LIMIT(i)); |
| 523 | data->zone[i].critical = |
| 524 | lm85_read_value(client, LM85_REG_AFAN_CRITICAL(i)); |
| 525 | |
| 526 | if (IS_ADT7468_OFF64(data)) { |
| 527 | data->temp_min[i] -= 64; |
| 528 | data->temp_max[i] -= 64; |
| 529 | data->zone[i].limit -= 64; |
| 530 | data->zone[i].critical -= 64; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | if (data->type != emc6d103s) { |
| 535 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
| 536 | data->autofan[0].min_off = (i & 0x20) != 0; |
| 537 | data->autofan[1].min_off = (i & 0x40) != 0; |
| 538 | data->autofan[2].min_off = (i & 0x80) != 0; |
| 539 | |
| 540 | i = lm85_read_value(client, LM85_REG_AFAN_HYST1); |
| 541 | data->zone[0].hyst = i >> 4; |
| 542 | data->zone[1].hyst = i & 0x0f; |
| 543 | |
| 544 | i = lm85_read_value(client, LM85_REG_AFAN_HYST2); |
| 545 | data->zone[2].hyst = i >> 4; |
| 546 | } |
| 547 | |
| 548 | data->last_config = jiffies; |
| 549 | } /* last_config */ |
| 550 | |
| 551 | data->valid = 1; |
| 552 | |
| 553 | mutex_unlock(&data->update_lock); |
| 554 | |
| 555 | return data; |
| 556 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | /* 4 Fans */ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 559 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
| 560 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 562 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 564 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 566 | |
| 567 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
| 568 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 570 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 572 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 574 | |
| 575 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
| 576 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 578 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 579 | struct lm85_data *data = dev_get_drvdata(dev); |
| 580 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 581 | unsigned long val; |
| 582 | int err; |
| 583 | |
| 584 | err = kstrtoul(buf, 10, &val); |
| 585 | if (err) |
| 586 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 588 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | data->fan_min[nr] = FAN_TO_REG(val); |
| 590 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 591 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | return count; |
| 593 | } |
| 594 | |
| 595 | #define show_fan_offset(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 596 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
| 597 | show_fan, NULL, offset - 1); \ |
| 598 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
| 599 | show_fan_min, set_fan_min, offset - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
| 601 | show_fan_offset(1); |
| 602 | show_fan_offset(2); |
| 603 | show_fan_offset(3); |
| 604 | show_fan_offset(4); |
| 605 | |
| 606 | /* vid, vrm, alarms */ |
| 607 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 608 | static ssize_t cpu0_vid_show(struct device *dev, |
| 609 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | { |
| 611 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 612 | int vid; |
| 613 | |
Guenter Roeck | de24880 | 2011-02-25 08:19:42 -0800 | [diff] [blame] | 614 | if (data->has_vid5) { |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 615 | /* 6-pin VID (VRM 10) */ |
| 616 | vid = vid_from_reg(data->vid & 0x3f, data->vrm); |
| 617 | } else { |
| 618 | /* 5-pin VID (VRM 9) */ |
| 619 | vid = vid_from_reg(data->vid & 0x1f, data->vrm); |
| 620 | } |
| 621 | |
| 622 | return sprintf(buf, "%d\n", vid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 625 | static DEVICE_ATTR_RO(cpu0_vid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 627 | static ssize_t vrm_show(struct device *dev, struct device_attribute *attr, |
| 628 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | { |
Jean Delvare | 90d6619 | 2007-10-08 18:24:35 +0200 | [diff] [blame] | 630 | struct lm85_data *data = dev_get_drvdata(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | return sprintf(buf, "%ld\n", (long) data->vrm); |
| 632 | } |
| 633 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 634 | static ssize_t vrm_store(struct device *dev, struct device_attribute *attr, |
| 635 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | { |
Jean Delvare | 8f74efe | 2007-12-01 11:25:33 +0100 | [diff] [blame] | 637 | struct lm85_data *data = dev_get_drvdata(dev); |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 638 | unsigned long val; |
| 639 | int err; |
| 640 | |
| 641 | err = kstrtoul(buf, 10, &val); |
| 642 | if (err) |
| 643 | return err; |
| 644 | |
Guenter Roeck | 3248c3b | 2014-07-29 22:23:12 -0700 | [diff] [blame] | 645 | if (val > 255) |
| 646 | return -EINVAL; |
| 647 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 648 | data->vrm = val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | return count; |
| 650 | } |
| 651 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 652 | static DEVICE_ATTR_RW(vrm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 654 | static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, |
| 655 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
| 657 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 68188ba | 2005-05-16 18:52:38 +0200 | [diff] [blame] | 658 | return sprintf(buf, "%u\n", data->alarms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | } |
| 660 | |
Julia Lawall | d0ed69d | 2016-12-22 13:04:52 +0100 | [diff] [blame] | 661 | static DEVICE_ATTR_RO(alarms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 663 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
| 664 | char *buf) |
| 665 | { |
| 666 | int nr = to_sensor_dev_attr(attr)->index; |
| 667 | struct lm85_data *data = lm85_update_device(dev); |
| 668 | return sprintf(buf, "%u\n", (data->alarms >> nr) & 1); |
| 669 | } |
| 670 | |
| 671 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
| 672 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
| 673 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
| 674 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); |
| 675 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); |
| 676 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 18); |
| 677 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 16); |
| 678 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 17); |
| 679 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); |
| 680 | static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); |
| 681 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); |
| 682 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 6); |
| 683 | static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15); |
| 684 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10); |
| 685 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11); |
| 686 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 12); |
| 687 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 13); |
| 688 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | /* pwm */ |
| 690 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 691 | static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
| 692 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 694 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 696 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 698 | |
| 699 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
| 700 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 702 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 703 | struct lm85_data *data = dev_get_drvdata(dev); |
| 704 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 705 | unsigned long val; |
| 706 | int err; |
| 707 | |
| 708 | err = kstrtoul(buf, 10, &val); |
| 709 | if (err) |
| 710 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 712 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | data->pwm[nr] = PWM_TO_REG(val); |
| 714 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 715 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | return count; |
| 717 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 718 | |
| 719 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute |
| 720 | *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 722 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 4b4df95 | 2007-12-03 23:23:21 +0100 | [diff] [blame] | 724 | int pwm_zone, enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
| 726 | pwm_zone = ZONE_FROM_REG(data->autofan[nr].config); |
Jean Delvare | 4b4df95 | 2007-12-03 23:23:21 +0100 | [diff] [blame] | 727 | switch (pwm_zone) { |
| 728 | case -1: /* PWM is always at 100% */ |
| 729 | enable = 0; |
| 730 | break; |
| 731 | case 0: /* PWM is always at 0% */ |
| 732 | case -2: /* PWM responds to manual control */ |
| 733 | enable = 1; |
| 734 | break; |
| 735 | default: /* PWM in automatic mode */ |
| 736 | enable = 2; |
| 737 | } |
| 738 | return sprintf(buf, "%d\n", enable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | } |
| 740 | |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 741 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute |
| 742 | *attr, const char *buf, size_t count) |
| 743 | { |
| 744 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 745 | struct lm85_data *data = dev_get_drvdata(dev); |
| 746 | struct i2c_client *client = data->client; |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 747 | u8 config; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 748 | unsigned long val; |
| 749 | int err; |
| 750 | |
| 751 | err = kstrtoul(buf, 10, &val); |
| 752 | if (err) |
| 753 | return err; |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 754 | |
| 755 | switch (val) { |
| 756 | case 0: |
| 757 | config = 3; |
| 758 | break; |
| 759 | case 1: |
| 760 | config = 7; |
| 761 | break; |
| 762 | case 2: |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 763 | /* |
| 764 | * Here we have to choose arbitrarily one of the 5 possible |
| 765 | * configurations; I go for the safest |
| 766 | */ |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 767 | config = 6; |
| 768 | break; |
| 769 | default: |
| 770 | return -EINVAL; |
| 771 | } |
| 772 | |
| 773 | mutex_lock(&data->update_lock); |
| 774 | data->autofan[nr].config = lm85_read_value(client, |
| 775 | LM85_REG_AFAN_CONFIG(nr)); |
| 776 | data->autofan[nr].config = (data->autofan[nr].config & ~0xe0) |
| 777 | | (config << 5); |
| 778 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
| 779 | data->autofan[nr].config); |
| 780 | mutex_unlock(&data->update_lock); |
| 781 | return count; |
| 782 | } |
| 783 | |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 784 | static ssize_t show_pwm_freq(struct device *dev, |
| 785 | struct device_attribute *attr, char *buf) |
| 786 | { |
| 787 | int nr = to_sensor_dev_attr(attr)->index; |
| 788 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | f6c61cf | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 789 | int freq; |
| 790 | |
| 791 | if (IS_ADT7468_HFPWM(data)) |
| 792 | freq = 22500; |
| 793 | else |
| 794 | freq = FREQ_FROM_REG(data->freq_map, data->pwm_freq[nr]); |
| 795 | |
| 796 | return sprintf(buf, "%d\n", freq); |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | static ssize_t set_pwm_freq(struct device *dev, |
| 800 | struct device_attribute *attr, const char *buf, size_t count) |
| 801 | { |
| 802 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 803 | struct lm85_data *data = dev_get_drvdata(dev); |
| 804 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 805 | unsigned long val; |
| 806 | int err; |
| 807 | |
| 808 | err = kstrtoul(buf, 10, &val); |
| 809 | if (err) |
| 810 | return err; |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 811 | |
| 812 | mutex_lock(&data->update_lock); |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 813 | /* |
| 814 | * The ADT7468 has a special high-frequency PWM output mode, |
Jean Delvare | f6c61cf | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 815 | * where all PWM outputs are driven by a 22.5 kHz clock. |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 816 | * This might confuse the user, but there's not much we can do. |
| 817 | */ |
Jean Delvare | f6c61cf | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 818 | if (data->type == adt7468 && val >= 11300) { /* High freq. mode */ |
| 819 | data->cfg5 &= ~ADT7468_HFPWM; |
| 820 | lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5); |
| 821 | } else { /* Low freq. mode */ |
Bartosz Golaszewski | 0f3721c | 2015-04-16 12:43:36 -0700 | [diff] [blame] | 822 | data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, |
| 823 | FREQ_MAP_LEN, val); |
Jean Delvare | f6c61cf | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 824 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 825 | (data->zone[nr].range << 4) |
| 826 | | data->pwm_freq[nr]); |
| 827 | if (data->type == adt7468) { |
| 828 | data->cfg5 |= ADT7468_HFPWM; |
| 829 | lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5); |
| 830 | } |
| 831 | } |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 832 | mutex_unlock(&data->update_lock); |
| 833 | return count; |
| 834 | } |
| 835 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | #define show_pwm_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 837 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
| 838 | show_pwm, set_pwm, offset - 1); \ |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 839 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 840 | show_pwm_enable, set_pwm_enable, offset - 1); \ |
| 841 | static SENSOR_DEVICE_ATTR(pwm##offset##_freq, S_IRUGO | S_IWUSR, \ |
| 842 | show_pwm_freq, set_pwm_freq, offset - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
| 844 | show_pwm_reg(1); |
| 845 | show_pwm_reg(2); |
| 846 | show_pwm_reg(3); |
| 847 | |
| 848 | /* Voltages */ |
| 849 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 850 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
| 851 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 853 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 855 | return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr], |
| 856 | data->in_ext[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 858 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 859 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 860 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 862 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 864 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 866 | |
| 867 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
| 868 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 870 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 871 | struct lm85_data *data = dev_get_drvdata(dev); |
| 872 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 873 | long val; |
| 874 | int err; |
| 875 | |
| 876 | err = kstrtol(buf, 10, &val); |
| 877 | if (err) |
| 878 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 880 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | data->in_min[nr] = INS_TO_REG(nr, val); |
| 882 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 883 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | return count; |
| 885 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 886 | |
| 887 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
| 888 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 890 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 892 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 894 | |
| 895 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
| 896 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 898 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 899 | struct lm85_data *data = dev_get_drvdata(dev); |
| 900 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 901 | long val; |
| 902 | int err; |
| 903 | |
| 904 | err = kstrtol(buf, 10, &val); |
| 905 | if (err) |
| 906 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 908 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | data->in_max[nr] = INS_TO_REG(nr, val); |
| 910 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 911 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | return count; |
| 913 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 914 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | #define show_in_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 916 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
| 917 | show_in, NULL, offset); \ |
| 918 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
| 919 | show_in_min, set_in_min, offset); \ |
| 920 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
| 921 | show_in_max, set_in_max, offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | |
| 923 | show_in_reg(0); |
| 924 | show_in_reg(1); |
| 925 | show_in_reg(2); |
| 926 | show_in_reg(3); |
| 927 | show_in_reg(4); |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 928 | show_in_reg(5); |
| 929 | show_in_reg(6); |
| 930 | show_in_reg(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | |
| 932 | /* Temps */ |
| 933 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 934 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
| 935 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 937 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 939 | return sprintf(buf, "%d\n", TEMPEXT_FROM_REG(data->temp[nr], |
| 940 | data->temp_ext[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 942 | |
| 943 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
| 944 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 946 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 948 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 950 | |
| 951 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
| 952 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 954 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 955 | struct lm85_data *data = dev_get_drvdata(dev); |
| 956 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 957 | long val; |
| 958 | int err; |
| 959 | |
| 960 | err = kstrtol(buf, 10, &val); |
| 961 | if (err) |
| 962 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 964 | if (IS_ADT7468_OFF64(data)) |
| 965 | val += 64; |
| 966 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 967 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | data->temp_min[nr] = TEMP_TO_REG(val); |
| 969 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 970 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | return count; |
| 972 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 973 | |
| 974 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
| 975 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 977 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 979 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 981 | |
| 982 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
| 983 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 985 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 986 | struct lm85_data *data = dev_get_drvdata(dev); |
| 987 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 988 | long val; |
| 989 | int err; |
| 990 | |
| 991 | err = kstrtol(buf, 10, &val); |
| 992 | if (err) |
| 993 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 995 | if (IS_ADT7468_OFF64(data)) |
| 996 | val += 64; |
| 997 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 998 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | data->temp_max[nr] = TEMP_TO_REG(val); |
| 1000 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1001 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | return count; |
| 1003 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1004 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | #define show_temp_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1006 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
| 1007 | show_temp, NULL, offset - 1); \ |
| 1008 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
| 1009 | show_temp_min, set_temp_min, offset - 1); \ |
| 1010 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
| 1011 | show_temp_max, set_temp_max, offset - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
| 1013 | show_temp_reg(1); |
| 1014 | show_temp_reg(2); |
| 1015 | show_temp_reg(3); |
| 1016 | |
| 1017 | |
| 1018 | /* Automatic PWM control */ |
| 1019 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1020 | static ssize_t show_pwm_auto_channels(struct device *dev, |
| 1021 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1023 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1025 | return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1027 | |
| 1028 | static ssize_t set_pwm_auto_channels(struct device *dev, |
| 1029 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1031 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1032 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1033 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1034 | long val; |
| 1035 | int err; |
| 1036 | |
| 1037 | err = kstrtol(buf, 10, &val); |
| 1038 | if (err) |
| 1039 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1041 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1043 | | ZONE_TO_REG(val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
| 1045 | data->autofan[nr].config); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1046 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | return count; |
| 1048 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1049 | |
| 1050 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, |
| 1051 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1053 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1055 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1057 | |
| 1058 | static ssize_t set_pwm_auto_pwm_min(struct device *dev, |
| 1059 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1061 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1062 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1063 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1064 | unsigned long val; |
| 1065 | int err; |
| 1066 | |
| 1067 | err = kstrtoul(buf, 10, &val); |
| 1068 | if (err) |
| 1069 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1071 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | data->autofan[nr].min_pwm = PWM_TO_REG(val); |
| 1073 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), |
| 1074 | data->autofan[nr].min_pwm); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1075 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | return count; |
| 1077 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1078 | |
| 1079 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, |
| 1080 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1082 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1084 | return sprintf(buf, "%d\n", data->autofan[nr].min_off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1086 | |
| 1087 | static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, |
| 1088 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1090 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1091 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1092 | struct i2c_client *client = data->client; |
Jean Delvare | 7133e56 | 2008-04-12 19:56:35 +0200 | [diff] [blame] | 1093 | u8 tmp; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1094 | long val; |
| 1095 | int err; |
| 1096 | |
| 1097 | err = kstrtol(buf, 10, &val); |
| 1098 | if (err) |
| 1099 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1101 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | data->autofan[nr].min_off = val; |
Jean Delvare | 7133e56 | 2008-04-12 19:56:35 +0200 | [diff] [blame] | 1103 | tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
| 1104 | tmp &= ~(0x20 << nr); |
| 1105 | if (data->autofan[nr].min_off) |
| 1106 | tmp |= 0x20 << nr; |
| 1107 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1108 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | return count; |
| 1110 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | #define pwm_auto(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1113 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels, \ |
| 1114 | S_IRUGO | S_IWUSR, show_pwm_auto_channels, \ |
| 1115 | set_pwm_auto_channels, offset - 1); \ |
| 1116 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_min, \ |
| 1117 | S_IRUGO | S_IWUSR, show_pwm_auto_pwm_min, \ |
| 1118 | set_pwm_auto_pwm_min, offset - 1); \ |
| 1119 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, \ |
| 1120 | S_IRUGO | S_IWUSR, show_pwm_auto_pwm_minctl, \ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1121 | set_pwm_auto_pwm_minctl, offset - 1) |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | pwm_auto(1); |
| 1124 | pwm_auto(2); |
| 1125 | pwm_auto(3); |
| 1126 | |
| 1127 | /* Temperature settings for automatic PWM control */ |
| 1128 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1129 | static ssize_t show_temp_auto_temp_off(struct device *dev, |
| 1130 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1132 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1134 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | HYST_FROM_REG(data->zone[nr].hyst)); |
| 1136 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1137 | |
| 1138 | static ssize_t set_temp_auto_temp_off(struct device *dev, |
| 1139 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1141 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1142 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1143 | struct i2c_client *client = data->client; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | int min; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1145 | long val; |
| 1146 | int err; |
| 1147 | |
| 1148 | err = kstrtol(buf, 10, &val); |
| 1149 | if (err) |
| 1150 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1152 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | min = TEMP_FROM_REG(data->zone[nr].limit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1155 | if (nr == 0 || nr == 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | lm85_write_value(client, LM85_REG_AFAN_HYST1, |
| 1157 | (data->zone[0].hyst << 4) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1158 | | data->zone[1].hyst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | } else { |
| 1160 | lm85_write_value(client, LM85_REG_AFAN_HYST2, |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1161 | (data->zone[2].hyst << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | } |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1163 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | return count; |
| 1165 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1166 | |
| 1167 | static ssize_t show_temp_auto_temp_min(struct device *dev, |
| 1168 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1170 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1172 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1174 | |
| 1175 | static ssize_t set_temp_auto_temp_min(struct device *dev, |
| 1176 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1178 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1179 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1180 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1181 | long val; |
| 1182 | int err; |
| 1183 | |
| 1184 | err = kstrtol(buf, 10, &val); |
| 1185 | if (err) |
| 1186 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1188 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | data->zone[nr].limit = TEMP_TO_REG(val); |
| 1190 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), |
| 1191 | data->zone[nr].limit); |
| 1192 | |
| 1193 | /* Update temp_auto_max and temp_auto_range */ |
| 1194 | data->zone[nr].range = RANGE_TO_REG( |
| 1195 | TEMP_FROM_REG(data->zone[nr].max_desired) - |
| 1196 | TEMP_FROM_REG(data->zone[nr].limit)); |
| 1197 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 1198 | ((data->zone[nr].range & 0x0f) << 4) |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1199 | | (data->pwm_freq[nr] & 0x07)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1201 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | return count; |
| 1203 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1204 | |
| 1205 | static ssize_t show_temp_auto_temp_max(struct device *dev, |
| 1206 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1208 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1210 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | RANGE_FROM_REG(data->zone[nr].range)); |
| 1212 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1213 | |
| 1214 | static ssize_t set_temp_auto_temp_max(struct device *dev, |
| 1215 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1217 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1218 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1219 | struct i2c_client *client = data->client; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | int min; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1221 | long val; |
| 1222 | int err; |
| 1223 | |
| 1224 | err = kstrtol(buf, 10, &val); |
| 1225 | if (err) |
| 1226 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1228 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | min = TEMP_FROM_REG(data->zone[nr].limit); |
| 1230 | data->zone[nr].max_desired = TEMP_TO_REG(val); |
| 1231 | data->zone[nr].range = RANGE_TO_REG( |
| 1232 | val - min); |
| 1233 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 1234 | ((data->zone[nr].range & 0x0f) << 4) |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1235 | | (data->pwm_freq[nr] & 0x07)); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1236 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | return count; |
| 1238 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1239 | |
| 1240 | static ssize_t show_temp_auto_temp_crit(struct device *dev, |
| 1241 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1243 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1245 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1247 | |
| 1248 | static ssize_t set_temp_auto_temp_crit(struct device *dev, |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1249 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1250 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1251 | int nr = to_sensor_dev_attr(attr)->index; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1252 | struct lm85_data *data = dev_get_drvdata(dev); |
| 1253 | struct i2c_client *client = data->client; |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1254 | long val; |
| 1255 | int err; |
| 1256 | |
| 1257 | err = kstrtol(buf, 10, &val); |
| 1258 | if (err) |
| 1259 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1261 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | data->zone[nr].critical = TEMP_TO_REG(val); |
| 1263 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), |
| 1264 | data->zone[nr].critical); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1265 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | return count; |
| 1267 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | #define temp_auto(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1270 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_off, \ |
| 1271 | S_IRUGO | S_IWUSR, show_temp_auto_temp_off, \ |
| 1272 | set_temp_auto_temp_off, offset - 1); \ |
| 1273 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_min, \ |
| 1274 | S_IRUGO | S_IWUSR, show_temp_auto_temp_min, \ |
| 1275 | set_temp_auto_temp_min, offset - 1); \ |
| 1276 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_max, \ |
| 1277 | S_IRUGO | S_IWUSR, show_temp_auto_temp_max, \ |
| 1278 | set_temp_auto_temp_max, offset - 1); \ |
| 1279 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_crit, \ |
| 1280 | S_IRUGO | S_IWUSR, show_temp_auto_temp_crit, \ |
| 1281 | set_temp_auto_temp_crit, offset - 1); |
| 1282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | temp_auto(1); |
| 1284 | temp_auto(2); |
| 1285 | temp_auto(3); |
| 1286 | |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1287 | static struct attribute *lm85_attributes[] = { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1288 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
| 1289 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
| 1290 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
| 1291 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
| 1292 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
| 1293 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
| 1294 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
| 1295 | &sensor_dev_attr_fan4_min.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1296 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
| 1297 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
| 1298 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
| 1299 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1300 | |
| 1301 | &sensor_dev_attr_pwm1.dev_attr.attr, |
| 1302 | &sensor_dev_attr_pwm2.dev_attr.attr, |
| 1303 | &sensor_dev_attr_pwm3.dev_attr.attr, |
| 1304 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
| 1305 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
| 1306 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1307 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
| 1308 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
| 1309 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1310 | |
| 1311 | &sensor_dev_attr_in0_input.dev_attr.attr, |
| 1312 | &sensor_dev_attr_in1_input.dev_attr.attr, |
| 1313 | &sensor_dev_attr_in2_input.dev_attr.attr, |
| 1314 | &sensor_dev_attr_in3_input.dev_attr.attr, |
| 1315 | &sensor_dev_attr_in0_min.dev_attr.attr, |
| 1316 | &sensor_dev_attr_in1_min.dev_attr.attr, |
| 1317 | &sensor_dev_attr_in2_min.dev_attr.attr, |
| 1318 | &sensor_dev_attr_in3_min.dev_attr.attr, |
| 1319 | &sensor_dev_attr_in0_max.dev_attr.attr, |
| 1320 | &sensor_dev_attr_in1_max.dev_attr.attr, |
| 1321 | &sensor_dev_attr_in2_max.dev_attr.attr, |
| 1322 | &sensor_dev_attr_in3_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1323 | &sensor_dev_attr_in0_alarm.dev_attr.attr, |
| 1324 | &sensor_dev_attr_in1_alarm.dev_attr.attr, |
| 1325 | &sensor_dev_attr_in2_alarm.dev_attr.attr, |
| 1326 | &sensor_dev_attr_in3_alarm.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1327 | |
| 1328 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 1329 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
| 1330 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
| 1331 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
| 1332 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
| 1333 | &sensor_dev_attr_temp3_min.dev_attr.attr, |
| 1334 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
| 1335 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
| 1336 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1337 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, |
| 1338 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
| 1339 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, |
| 1340 | &sensor_dev_attr_temp1_fault.dev_attr.attr, |
| 1341 | &sensor_dev_attr_temp3_fault.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1342 | |
| 1343 | &sensor_dev_attr_pwm1_auto_channels.dev_attr.attr, |
| 1344 | &sensor_dev_attr_pwm2_auto_channels.dev_attr.attr, |
| 1345 | &sensor_dev_attr_pwm3_auto_channels.dev_attr.attr, |
| 1346 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, |
| 1347 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, |
| 1348 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1349 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1350 | &sensor_dev_attr_temp1_auto_temp_min.dev_attr.attr, |
| 1351 | &sensor_dev_attr_temp2_auto_temp_min.dev_attr.attr, |
| 1352 | &sensor_dev_attr_temp3_auto_temp_min.dev_attr.attr, |
| 1353 | &sensor_dev_attr_temp1_auto_temp_max.dev_attr.attr, |
| 1354 | &sensor_dev_attr_temp2_auto_temp_max.dev_attr.attr, |
| 1355 | &sensor_dev_attr_temp3_auto_temp_max.dev_attr.attr, |
| 1356 | &sensor_dev_attr_temp1_auto_temp_crit.dev_attr.attr, |
| 1357 | &sensor_dev_attr_temp2_auto_temp_crit.dev_attr.attr, |
| 1358 | &sensor_dev_attr_temp3_auto_temp_crit.dev_attr.attr, |
| 1359 | |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1360 | &dev_attr_vrm.attr, |
| 1361 | &dev_attr_cpu0_vid.attr, |
| 1362 | &dev_attr_alarms.attr, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1363 | NULL |
| 1364 | }; |
| 1365 | |
| 1366 | static const struct attribute_group lm85_group = { |
| 1367 | .attrs = lm85_attributes, |
| 1368 | }; |
| 1369 | |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1370 | static struct attribute *lm85_attributes_minctl[] = { |
| 1371 | &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr, |
| 1372 | &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr, |
| 1373 | &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr, |
Jean Delvare | 5f441e2 | 2011-04-29 16:33:36 +0200 | [diff] [blame] | 1374 | NULL |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1375 | }; |
| 1376 | |
| 1377 | static const struct attribute_group lm85_group_minctl = { |
| 1378 | .attrs = lm85_attributes_minctl, |
| 1379 | }; |
| 1380 | |
| 1381 | static struct attribute *lm85_attributes_temp_off[] = { |
| 1382 | &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr, |
| 1383 | &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr, |
| 1384 | &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr, |
Jean Delvare | 5f441e2 | 2011-04-29 16:33:36 +0200 | [diff] [blame] | 1385 | NULL |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1386 | }; |
| 1387 | |
| 1388 | static const struct attribute_group lm85_group_temp_off = { |
| 1389 | .attrs = lm85_attributes_temp_off, |
| 1390 | }; |
| 1391 | |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1392 | static struct attribute *lm85_attributes_in4[] = { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1393 | &sensor_dev_attr_in4_input.dev_attr.attr, |
| 1394 | &sensor_dev_attr_in4_min.dev_attr.attr, |
| 1395 | &sensor_dev_attr_in4_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1396 | &sensor_dev_attr_in4_alarm.dev_attr.attr, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1397 | NULL |
| 1398 | }; |
| 1399 | |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1400 | static const struct attribute_group lm85_group_in4 = { |
| 1401 | .attrs = lm85_attributes_in4, |
| 1402 | }; |
| 1403 | |
| 1404 | static struct attribute *lm85_attributes_in567[] = { |
| 1405 | &sensor_dev_attr_in5_input.dev_attr.attr, |
| 1406 | &sensor_dev_attr_in6_input.dev_attr.attr, |
| 1407 | &sensor_dev_attr_in7_input.dev_attr.attr, |
| 1408 | &sensor_dev_attr_in5_min.dev_attr.attr, |
| 1409 | &sensor_dev_attr_in6_min.dev_attr.attr, |
| 1410 | &sensor_dev_attr_in7_min.dev_attr.attr, |
| 1411 | &sensor_dev_attr_in5_max.dev_attr.attr, |
| 1412 | &sensor_dev_attr_in6_max.dev_attr.attr, |
| 1413 | &sensor_dev_attr_in7_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1414 | &sensor_dev_attr_in5_alarm.dev_attr.attr, |
| 1415 | &sensor_dev_attr_in6_alarm.dev_attr.attr, |
| 1416 | &sensor_dev_attr_in7_alarm.dev_attr.attr, |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1417 | NULL |
| 1418 | }; |
| 1419 | |
| 1420 | static const struct attribute_group lm85_group_in567 = { |
| 1421 | .attrs = lm85_attributes_in567, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1422 | }; |
| 1423 | |
Jean Delvare | 5f4475947 | 2008-06-25 09:10:30 -0400 | [diff] [blame] | 1424 | static void lm85_init_client(struct i2c_client *client) |
| 1425 | { |
| 1426 | int value; |
| 1427 | |
| 1428 | /* Start monitoring if needed */ |
| 1429 | value = lm85_read_value(client, LM85_REG_CONFIG); |
| 1430 | if (!(value & 0x01)) { |
| 1431 | dev_info(&client->dev, "Starting monitoring\n"); |
| 1432 | lm85_write_value(client, LM85_REG_CONFIG, value | 0x01); |
| 1433 | } |
| 1434 | |
| 1435 | /* Warn about unusual configuration bits */ |
| 1436 | if (value & 0x02) |
| 1437 | dev_warn(&client->dev, "Device configuration is locked\n"); |
| 1438 | if (!(value & 0x04)) |
| 1439 | dev_warn(&client->dev, "Device is not ready\n"); |
| 1440 | } |
| 1441 | |
Jean Delvare | 5cfaf33 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 1442 | static int lm85_is_fake(struct i2c_client *client) |
| 1443 | { |
| 1444 | /* |
| 1445 | * Differenciate between real LM96000 and Winbond WPCD377I. The latter |
| 1446 | * emulate the former except that it has no hardware monitoring function |
| 1447 | * so the readings are always 0. |
| 1448 | */ |
| 1449 | int i; |
| 1450 | u8 in_temp, fan; |
| 1451 | |
| 1452 | for (i = 0; i < 8; i++) { |
| 1453 | in_temp = i2c_smbus_read_byte_data(client, 0x20 + i); |
| 1454 | fan = i2c_smbus_read_byte_data(client, 0x28 + i); |
| 1455 | if (in_temp != 0x00 || fan != 0xff) |
| 1456 | return 0; |
| 1457 | } |
| 1458 | |
| 1459 | return 1; |
| 1460 | } |
| 1461 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1462 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
Jean Delvare | 310ec79 | 2009-12-14 21:17:23 +0100 | [diff] [blame] | 1463 | static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | { |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1465 | struct i2c_adapter *adapter = client->adapter; |
| 1466 | int address = client->addr; |
Jean Delvare | 590e853 | 2014-06-11 18:35:56 +0200 | [diff] [blame] | 1467 | const char *type_name = NULL; |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1468 | int company, verstep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1470 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | /* We need to be able to do byte I/O */ |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1472 | return -ENODEV; |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1473 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1475 | /* Determine the chip type */ |
| 1476 | company = lm85_read_value(client, LM85_REG_COMPANY); |
| 1477 | verstep = lm85_read_value(client, LM85_REG_VERSTEP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | |
Guenter Roeck | b55f375 | 2013-01-10 10:01:24 -0800 | [diff] [blame] | 1479 | dev_dbg(&adapter->dev, |
| 1480 | "Detecting device at 0x%02x with COMPANY: 0x%02x and VERSTEP: 0x%02x\n", |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1481 | address, company, verstep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1483 | if (company == LM85_COMPANY_NATIONAL) { |
| 1484 | switch (verstep) { |
| 1485 | case LM85_VERSTEP_LM85C: |
| 1486 | type_name = "lm85c"; |
| 1487 | break; |
| 1488 | case LM85_VERSTEP_LM85B: |
| 1489 | type_name = "lm85b"; |
| 1490 | break; |
| 1491 | case LM85_VERSTEP_LM96000_1: |
| 1492 | case LM85_VERSTEP_LM96000_2: |
| 1493 | /* Check for Winbond WPCD377I */ |
| 1494 | if (lm85_is_fake(client)) { |
| 1495 | dev_dbg(&adapter->dev, |
| 1496 | "Found Winbond WPCD377I, ignoring\n"); |
| 1497 | return -ENODEV; |
| 1498 | } |
Jean Delvare | 590e853 | 2014-06-11 18:35:56 +0200 | [diff] [blame] | 1499 | type_name = "lm85"; |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1500 | break; |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1501 | } |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1502 | } else if (company == LM85_COMPANY_ANALOG_DEV) { |
| 1503 | switch (verstep) { |
| 1504 | case LM85_VERSTEP_ADM1027: |
| 1505 | type_name = "adm1027"; |
| 1506 | break; |
| 1507 | case LM85_VERSTEP_ADT7463: |
| 1508 | case LM85_VERSTEP_ADT7463C: |
| 1509 | type_name = "adt7463"; |
| 1510 | break; |
| 1511 | case LM85_VERSTEP_ADT7468_1: |
| 1512 | case LM85_VERSTEP_ADT7468_2: |
| 1513 | type_name = "adt7468"; |
| 1514 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | } |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1516 | } else if (company == LM85_COMPANY_SMSC) { |
| 1517 | switch (verstep) { |
| 1518 | case LM85_VERSTEP_EMC6D100_A0: |
| 1519 | case LM85_VERSTEP_EMC6D100_A1: |
| 1520 | /* Note: we can't tell a '100 from a '101 */ |
| 1521 | type_name = "emc6d100"; |
| 1522 | break; |
| 1523 | case LM85_VERSTEP_EMC6D102: |
| 1524 | type_name = "emc6d102"; |
| 1525 | break; |
Jan Beulich | f065a93 | 2011-02-18 03:18:26 -0500 | [diff] [blame] | 1526 | case LM85_VERSTEP_EMC6D103_A0: |
| 1527 | case LM85_VERSTEP_EMC6D103_A1: |
| 1528 | type_name = "emc6d103"; |
| 1529 | break; |
Jan Beulich | f065a93 | 2011-02-18 03:18:26 -0500 | [diff] [blame] | 1530 | case LM85_VERSTEP_EMC6D103S: |
| 1531 | type_name = "emc6d103s"; |
| 1532 | break; |
Jean Delvare | d42a2eb | 2009-12-09 20:35:53 +0100 | [diff] [blame] | 1533 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | } |
| 1535 | |
Jean Delvare | 590e853 | 2014-06-11 18:35:56 +0200 | [diff] [blame] | 1536 | if (!type_name) |
| 1537 | return -ENODEV; |
| 1538 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1539 | strlcpy(info->type, type_name, I2C_NAME_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1541 | return 0; |
| 1542 | } |
| 1543 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1544 | static int lm85_probe(struct i2c_client *client, const struct i2c_device_id *id) |
Guenter Roeck | bc6db2b | 2011-02-25 08:26:47 -0800 | [diff] [blame] | 1545 | { |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1546 | struct device *dev = &client->dev; |
| 1547 | struct device *hwmon_dev; |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1548 | struct lm85_data *data; |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1549 | int idx = 0; |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1550 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1551 | data = devm_kzalloc(dev, sizeof(struct lm85_data), GFP_KERNEL); |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1552 | if (!data) |
| 1553 | return -ENOMEM; |
| 1554 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1555 | data->client = client; |
Javier Martinez Canillas | 00c0f9d | 2017-02-24 10:13:03 -0300 | [diff] [blame] | 1556 | if (client->dev.of_node) |
| 1557 | data->type = (enum chips)of_device_get_match_data(&client->dev); |
| 1558 | else |
| 1559 | data->type = id->driver_data; |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1560 | mutex_init(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1562 | /* Fill in the chip specific driver values */ |
| 1563 | switch (data->type) { |
| 1564 | case adm1027: |
| 1565 | case adt7463: |
Jean Delvare | fa7a579 | 2010-10-28 20:31:50 +0200 | [diff] [blame] | 1566 | case adt7468: |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1567 | case emc6d100: |
| 1568 | case emc6d102: |
Jan Beulich | f065a93 | 2011-02-18 03:18:26 -0500 | [diff] [blame] | 1569 | case emc6d103: |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1570 | case emc6d103s: |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1571 | data->freq_map = adm1027_freq_map; |
| 1572 | break; |
| 1573 | default: |
| 1574 | data->freq_map = lm85_freq_map; |
| 1575 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | |
| 1577 | /* Set the VRM version */ |
Jean Delvare | 303760b | 2005-07-31 21:52:01 +0200 | [diff] [blame] | 1578 | data->vrm = vid_which_vrm(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1579 | |
| 1580 | /* Initialize the LM85 chip */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1581 | lm85_init_client(client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1583 | /* sysfs hooks */ |
| 1584 | data->groups[idx++] = &lm85_group; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1586 | /* minctl and temp_off exist on all chips except emc6d103s */ |
| 1587 | if (data->type != emc6d103s) { |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1588 | data->groups[idx++] = &lm85_group_minctl; |
| 1589 | data->groups[idx++] = &lm85_group_temp_off; |
Guenter Roeck | 06923f8 | 2011-02-19 08:27:47 -0800 | [diff] [blame] | 1590 | } |
| 1591 | |
Guenter Roeck | 09770b26 | 2012-01-14 20:47:36 -0800 | [diff] [blame] | 1592 | /* |
| 1593 | * The ADT7463/68 have an optional VRM 10 mode where pin 21 is used |
| 1594 | * as a sixth digital VID input rather than an analog input. |
| 1595 | */ |
Guenter Roeck | de24880 | 2011-02-25 08:19:42 -0800 | [diff] [blame] | 1596 | if (data->type == adt7463 || data->type == adt7468) { |
| 1597 | u8 vid = lm85_read_value(client, LM85_REG_VID); |
| 1598 | if (vid & 0x80) |
| 1599 | data->has_vid5 = true; |
| 1600 | } |
| 1601 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1602 | if (!data->has_vid5) |
| 1603 | data->groups[idx++] = &lm85_group_in4; |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1604 | |
| 1605 | /* The EMC6D100 has 3 additional voltage inputs */ |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1606 | if (data->type == emc6d100) |
| 1607 | data->groups[idx++] = &lm85_group_in567; |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1608 | |
Axel Lin | 746f688 | 2014-07-23 12:29:11 +0800 | [diff] [blame] | 1609 | hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, |
| 1610 | data, data->groups); |
| 1611 | return PTR_ERR_OR_ZERO(hwmon_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1612 | } |
| 1613 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 1614 | static const struct i2c_device_id lm85_id[] = { |
| 1615 | { "adm1027", adm1027 }, |
| 1616 | { "adt7463", adt7463 }, |
| 1617 | { "adt7468", adt7468 }, |
| 1618 | { "lm85", lm85 }, |
| 1619 | { "lm85b", lm85 }, |
| 1620 | { "lm85c", lm85 }, |
| 1621 | { "emc6d100", emc6d100 }, |
| 1622 | { "emc6d101", emc6d100 }, |
| 1623 | { "emc6d102", emc6d102 }, |
| 1624 | { "emc6d103", emc6d103 }, |
| 1625 | { "emc6d103s", emc6d103s }, |
| 1626 | { } |
| 1627 | }; |
| 1628 | MODULE_DEVICE_TABLE(i2c, lm85_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | |
Javier Martinez Canillas | 00c0f9d | 2017-02-24 10:13:03 -0300 | [diff] [blame] | 1630 | static const struct of_device_id lm85_of_match[] = { |
| 1631 | { |
| 1632 | .compatible = "adi,adm1027", |
| 1633 | .data = (void *)adm1027 |
| 1634 | }, |
| 1635 | { |
| 1636 | .compatible = "adi,adt7463", |
| 1637 | .data = (void *)adt7463 |
| 1638 | }, |
| 1639 | { |
| 1640 | .compatible = "adi,adt7468", |
| 1641 | .data = (void *)adt7468 |
| 1642 | }, |
| 1643 | { |
| 1644 | .compatible = "national,lm85", |
| 1645 | .data = (void *)lm85 |
| 1646 | }, |
| 1647 | { |
| 1648 | .compatible = "national,lm85b", |
| 1649 | .data = (void *)lm85 |
| 1650 | }, |
| 1651 | { |
| 1652 | .compatible = "national,lm85c", |
| 1653 | .data = (void *)lm85 |
| 1654 | }, |
| 1655 | { |
| 1656 | .compatible = "smsc,emc6d100", |
| 1657 | .data = (void *)emc6d100 |
| 1658 | }, |
| 1659 | { |
| 1660 | .compatible = "smsc,emc6d101", |
| 1661 | .data = (void *)emc6d100 |
| 1662 | }, |
| 1663 | { |
| 1664 | .compatible = "smsc,emc6d102", |
| 1665 | .data = (void *)emc6d102 |
| 1666 | }, |
| 1667 | { |
| 1668 | .compatible = "smsc,emc6d103", |
| 1669 | .data = (void *)emc6d103 |
| 1670 | }, |
| 1671 | { |
| 1672 | .compatible = "smsc,emc6d103s", |
| 1673 | .data = (void *)emc6d103s |
| 1674 | }, |
| 1675 | { }, |
| 1676 | }; |
| 1677 | MODULE_DEVICE_TABLE(of, lm85_of_match); |
| 1678 | |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 1679 | static struct i2c_driver lm85_driver = { |
| 1680 | .class = I2C_CLASS_HWMON, |
| 1681 | .driver = { |
| 1682 | .name = "lm85", |
Javier Martinez Canillas | 00c0f9d | 2017-02-24 10:13:03 -0300 | [diff] [blame] | 1683 | .of_match_table = of_match_ptr(lm85_of_match), |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 1684 | }, |
| 1685 | .probe = lm85_probe, |
Axel Lin | 6fd5dd5 | 2014-07-23 12:27:39 +0800 | [diff] [blame] | 1686 | .id_table = lm85_id, |
| 1687 | .detect = lm85_detect, |
| 1688 | .address_list = normal_i2c, |
| 1689 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | |
Axel Lin | f0967ee | 2012-01-20 15:38:18 +0800 | [diff] [blame] | 1691 | module_i2c_driver(lm85_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | MODULE_LICENSE("GPL"); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1694 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " |
| 1695 | "Margit Schubert-While <margitsw@t-online.de>, " |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1696 | "Justin Thiessen <jthiessen@penguincomputing.com>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | MODULE_DESCRIPTION("LM85-B, LM85-C driver"); |