Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> * |
Hans de Goede | 44c4dc5 | 2011-03-09 20:57:07 +0100 | [diff] [blame] | 4 | * Copyright (C) 2007-2011 Hans de Goede <hdegoede@redhat.com> * |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 5 | * * |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 6 | ***************************************************************************/ |
| 7 | |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 9 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 10 | #include <linux/module.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/jiffies.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/hwmon.h> |
| 16 | #include <linux/hwmon-sysfs.h> |
| 17 | #include <linux/err.h> |
| 18 | #include <linux/mutex.h> |
Mark van Doesburg | 77a4a3e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 19 | #include <linux/io.h> |
Jean Delvare | b9acb64 | 2009-01-07 16:37:35 +0100 | [diff] [blame] | 20 | #include <linux/acpi.h> |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 21 | |
| 22 | #define DRVNAME "f71882fg" |
| 23 | |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 24 | #define SIO_F71858FG_LD_HWM 0x02 /* Hardware monitor logical device */ |
Mark van Doesburg | 77a4a3e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 25 | #define SIO_F71882FG_LD_HWM 0x04 /* Hardware monitor logical device */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 26 | #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ |
Hans de Goede | 14a4019 | 2011-03-13 13:50:32 +0100 | [diff] [blame] | 27 | #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 28 | |
| 29 | #define SIO_REG_LDSEL 0x07 /* Logical device select */ |
| 30 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ |
| 31 | #define SIO_REG_DEVREV 0x22 /* Device revision */ |
| 32 | #define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ |
| 33 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ |
| 34 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ |
| 35 | |
| 36 | #define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 37 | #define SIO_F71808E_ID 0x0901 /* Chipset ID */ |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 38 | #define SIO_F71808A_ID 0x1001 /* Chipset ID */ |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 39 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 40 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 41 | #define SIO_F71868_ID 0x1106 /* Chipset ID */ |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 42 | #define SIO_F71869_ID 0x0814 /* Chipset ID */ |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 43 | #define SIO_F71869A_ID 0x1007 /* Chipset ID */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 44 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ |
Hans de Goede | 7669896 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 45 | #define SIO_F71889_ID 0x0723 /* Chipset ID */ |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 46 | #define SIO_F71889E_ID 0x0909 /* Chipset ID */ |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 47 | #define SIO_F71889A_ID 0x1005 /* Chipset ID */ |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 48 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 49 | #define SIO_F81768D_ID 0x1210 /* Chipset ID */ |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 50 | #define SIO_F81865_ID 0x0704 /* Chipset ID */ |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 51 | #define SIO_F81866_ID 0x1010 /* Chipset ID */ |
Menghui Wu | df29307 | 2021-11-17 10:43:20 +0800 | [diff] [blame] | 52 | #define SIO_F81966_ID 0x1502 /* Chipset ID */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 53 | |
| 54 | #define REGION_LENGTH 8 |
| 55 | #define ADDR_REG_OFFSET 5 |
| 56 | #define DATA_REG_OFFSET 6 |
| 57 | |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 58 | #define F71882FG_REG_IN_STATUS 0x12 /* f7188x only */ |
| 59 | #define F71882FG_REG_IN_BEEP 0x13 /* f7188x only */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 60 | #define F71882FG_REG_IN(nr) (0x20 + (nr)) |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 61 | #define F71882FG_REG_IN1_HIGH 0x32 /* f7188x only */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 62 | |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 63 | #define F81866_REG_IN_STATUS 0x16 /* F81866 only */ |
| 64 | #define F81866_REG_IN_BEEP 0x17 /* F81866 only */ |
| 65 | #define F81866_REG_IN1_HIGH 0x3a /* F81866 only */ |
| 66 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 67 | #define F71882FG_REG_FAN(nr) (0xA0 + (16 * (nr))) |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 68 | #define F71882FG_REG_FAN_TARGET(nr) (0xA2 + (16 * (nr))) |
| 69 | #define F71882FG_REG_FAN_FULL_SPEED(nr) (0xA4 + (16 * (nr))) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 70 | #define F71882FG_REG_FAN_STATUS 0x92 |
| 71 | #define F71882FG_REG_FAN_BEEP 0x93 |
| 72 | |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 73 | #define F71882FG_REG_TEMP(nr) (0x70 + 2 * (nr)) |
| 74 | #define F71882FG_REG_TEMP_OVT(nr) (0x80 + 2 * (nr)) |
| 75 | #define F71882FG_REG_TEMP_HIGH(nr) (0x81 + 2 * (nr)) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 76 | #define F71882FG_REG_TEMP_STATUS 0x62 |
| 77 | #define F71882FG_REG_TEMP_BEEP 0x63 |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 78 | #define F71882FG_REG_TEMP_CONFIG 0x69 |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 79 | #define F71882FG_REG_TEMP_HYST(nr) (0x6C + (nr)) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 80 | #define F71882FG_REG_TEMP_TYPE 0x6B |
| 81 | #define F71882FG_REG_TEMP_DIODE_OPEN 0x6F |
| 82 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 83 | #define F71882FG_REG_PWM(nr) (0xA3 + (16 * (nr))) |
| 84 | #define F71882FG_REG_PWM_TYPE 0x94 |
| 85 | #define F71882FG_REG_PWM_ENABLE 0x96 |
| 86 | |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 87 | #define F71882FG_REG_FAN_HYST(nr) (0x98 + (nr)) |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 88 | |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 89 | #define F71882FG_REG_FAN_FAULT_T 0x9F |
| 90 | #define F71882FG_FAN_NEG_TEMP_EN 0x20 |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 91 | #define F71882FG_FAN_PROG_SEL 0x80 |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 92 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 93 | #define F71882FG_REG_POINT_PWM(pwm, point) (0xAA + (point) + (16 * (pwm))) |
| 94 | #define F71882FG_REG_POINT_TEMP(pwm, point) (0xA6 + (point) + (16 * (pwm))) |
| 95 | #define F71882FG_REG_POINT_MAPPING(nr) (0xAF + 16 * (nr)) |
| 96 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 97 | #define F71882FG_REG_START 0x01 |
| 98 | |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 99 | #define F71882FG_MAX_INS 11 |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 100 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 101 | #define FAN_MIN_DETECT 366 /* Lowest detectable fanspeed */ |
| 102 | |
Jean Delvare | 67b671b | 2007-12-06 23:13:42 +0100 | [diff] [blame] | 103 | static unsigned short force_id; |
| 104 | module_param(force_id, ushort, 0); |
| 105 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
| 106 | |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 107 | enum chips { f71808e, f71808a, f71858fg, f71862fg, f71868a, f71869, f71869a, |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 108 | f71882fg, f71889fg, f71889ed, f71889a, f8000, f81768d, f81865f, |
| 109 | f81866a}; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 110 | |
Frans Meulenbroeks | 1dc3708 | 2012-01-08 19:34:10 +0100 | [diff] [blame] | 111 | static const char *const f71882fg_names[] = { |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 112 | "f71808e", |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 113 | "f71808a", |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 114 | "f71858fg", |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 115 | "f71862fg", |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 116 | "f71868a", |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 117 | "f71869", /* Both f71869f and f71869e, reg. compatible and same id */ |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 118 | "f71869a", |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 119 | "f71882fg", |
Jean Delvare | 5d7f77b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 120 | "f71889fg", /* f81801u too, same id */ |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 121 | "f71889ed", |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 122 | "f71889a", |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 123 | "f8000", |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 124 | "f81768d", |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 125 | "f81865f", |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 126 | "f81866a", |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 127 | }; |
| 128 | |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 129 | static const char f71882fg_has_in[][F71882FG_MAX_INS] = { |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 130 | [f71808e] = { 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0 }, |
| 131 | [f71808a] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0 }, |
| 132 | [f71858fg] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 133 | [f71862fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 134 | [f71868a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, |
| 135 | [f71869] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 136 | [f71869a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 137 | [f71882fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 138 | [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 139 | [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 140 | [f71889a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, |
| 141 | [f8000] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 142 | [f81768d] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 143 | [f81865f] = { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, |
| 144 | [f81866a] = { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 145 | }; |
| 146 | |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 147 | static const char f71882fg_has_in1_alarm[] = { |
| 148 | [f71808e] = 0, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 149 | [f71808a] = 0, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 150 | [f71858fg] = 0, |
| 151 | [f71862fg] = 0, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 152 | [f71868a] = 0, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 153 | [f71869] = 0, |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 154 | [f71869a] = 0, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 155 | [f71882fg] = 1, |
| 156 | [f71889fg] = 1, |
| 157 | [f71889ed] = 1, |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 158 | [f71889a] = 1, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 159 | [f8000] = 0, |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 160 | [f81768d] = 1, |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 161 | [f81865f] = 1, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 162 | [f81866a] = 1, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 165 | static const char f71882fg_fan_has_beep[] = { |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 166 | [f71808e] = 0, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 167 | [f71808a] = 0, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 168 | [f71858fg] = 0, |
| 169 | [f71862fg] = 1, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 170 | [f71868a] = 1, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 171 | [f71869] = 1, |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 172 | [f71869a] = 1, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 173 | [f71882fg] = 1, |
| 174 | [f71889fg] = 1, |
| 175 | [f71889ed] = 1, |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 176 | [f71889a] = 1, |
Jean Delvare | 2740c60 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 177 | [f8000] = 0, |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 178 | [f81768d] = 1, |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 179 | [f81865f] = 1, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 180 | [f81866a] = 1, |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 181 | }; |
| 182 | |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 183 | static const char f71882fg_nr_fans[] = { |
| 184 | [f71808e] = 3, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 185 | [f71808a] = 2, /* +1 fan which is monitor + simple pwm only */ |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 186 | [f71858fg] = 3, |
| 187 | [f71862fg] = 3, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 188 | [f71868a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 189 | [f71869] = 3, |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 190 | [f71869a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 191 | [f71882fg] = 4, |
| 192 | [f71889fg] = 3, |
| 193 | [f71889ed] = 3, |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 194 | [f71889a] = 3, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 195 | [f8000] = 3, /* +1 fan which is monitor only */ |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 196 | [f81768d] = 3, |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 197 | [f81865f] = 2, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 198 | [f81866a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 199 | }; |
| 200 | |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 201 | static const char f71882fg_temp_has_beep[] = { |
| 202 | [f71808e] = 0, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 203 | [f71808a] = 1, |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 204 | [f71858fg] = 0, |
| 205 | [f71862fg] = 1, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 206 | [f71868a] = 1, |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 207 | [f71869] = 1, |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 208 | [f71869a] = 1, |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 209 | [f71882fg] = 1, |
| 210 | [f71889fg] = 1, |
| 211 | [f71889ed] = 1, |
| 212 | [f71889a] = 1, |
| 213 | [f8000] = 0, |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 214 | [f81768d] = 1, |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 215 | [f81865f] = 1, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 216 | [f81866a] = 1, |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 217 | }; |
| 218 | |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 219 | static const char f71882fg_nr_temps[] = { |
| 220 | [f71808e] = 2, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 221 | [f71808a] = 2, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 222 | [f71858fg] = 3, |
| 223 | [f71862fg] = 3, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 224 | [f71868a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 225 | [f71869] = 3, |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 226 | [f71869a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 227 | [f71882fg] = 3, |
| 228 | [f71889fg] = 3, |
| 229 | [f71889ed] = 3, |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 230 | [f71889a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 231 | [f8000] = 3, |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 232 | [f81768d] = 3, |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 233 | [f81865f] = 2, |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 234 | [f81866a] = 3, |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 235 | }; |
| 236 | |
Mark van Doesburg | 77a4a3e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 237 | static struct platform_device *f71882fg_pdev; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 238 | |
| 239 | /* Super-I/O Function prototypes */ |
| 240 | static inline int superio_inb(int base, int reg); |
| 241 | static inline int superio_inw(int base, int reg); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 242 | static inline int superio_enter(int base); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 243 | static inline void superio_select(int base, int ld); |
| 244 | static inline void superio_exit(int base); |
| 245 | |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 246 | struct f71882fg_sio_data { |
| 247 | enum chips type; |
| 248 | }; |
| 249 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 250 | struct f71882fg_data { |
| 251 | unsigned short addr; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 252 | enum chips type; |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 253 | struct device *hwmon_dev; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 254 | |
| 255 | struct mutex update_lock; |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 256 | int temp_start; /* temp numbering start (0 or 1) */ |
Paul Fertser | 952a11c | 2021-09-24 22:52:02 +0300 | [diff] [blame] | 257 | bool valid; /* true if following fields are valid */ |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 258 | char auto_point_temp_signed; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 259 | unsigned long last_updated; /* In jiffies */ |
| 260 | unsigned long last_limits; /* In jiffies */ |
| 261 | |
| 262 | /* Register Values */ |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 263 | u8 in[F71882FG_MAX_INS]; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 264 | u8 in1_max; |
| 265 | u8 in_status; |
| 266 | u8 in_beep; |
| 267 | u16 fan[4]; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 268 | u16 fan_target[4]; |
| 269 | u16 fan_full_speed[4]; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 270 | u8 fan_status; |
| 271 | u8 fan_beep; |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 272 | /* |
| 273 | * Note: all models have max 3 temperature channels, but on some |
| 274 | * they are addressed as 0-2 and on others as 1-3, so for coding |
| 275 | * convenience we reserve space for 4 channels |
| 276 | */ |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 277 | u16 temp[4]; |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 278 | u8 temp_ovt[4]; |
| 279 | u8 temp_high[4]; |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 280 | u8 temp_hyst[2]; /* 2 hysts stored per reg */ |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 281 | u8 temp_type[4]; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 282 | u8 temp_status; |
| 283 | u8 temp_beep; |
| 284 | u8 temp_diode_open; |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 285 | u8 temp_config; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 286 | u8 pwm[4]; |
| 287 | u8 pwm_enable; |
| 288 | u8 pwm_auto_point_hyst[2]; |
| 289 | u8 pwm_auto_point_mapping[4]; |
| 290 | u8 pwm_auto_point_pwm[4][5]; |
Hans de Goede | 7669896 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 291 | s8 pwm_auto_point_temp[4][4]; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 292 | }; |
| 293 | |
Mark van Doesburg | 77a4a3e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 294 | /* Sysfs in */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 295 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
| 296 | char *buf); |
| 297 | static ssize_t show_in_max(struct device *dev, struct device_attribute |
| 298 | *devattr, char *buf); |
| 299 | static ssize_t store_in_max(struct device *dev, struct device_attribute |
| 300 | *devattr, const char *buf, size_t count); |
| 301 | static ssize_t show_in_beep(struct device *dev, struct device_attribute |
| 302 | *devattr, char *buf); |
| 303 | static ssize_t store_in_beep(struct device *dev, struct device_attribute |
| 304 | *devattr, const char *buf, size_t count); |
| 305 | static ssize_t show_in_alarm(struct device *dev, struct device_attribute |
| 306 | *devattr, char *buf); |
| 307 | /* Sysfs Fan */ |
| 308 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
| 309 | char *buf); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 310 | static ssize_t show_fan_full_speed(struct device *dev, |
| 311 | struct device_attribute *devattr, char *buf); |
| 312 | static ssize_t store_fan_full_speed(struct device *dev, |
| 313 | struct device_attribute *devattr, const char *buf, size_t count); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 314 | static ssize_t show_fan_beep(struct device *dev, struct device_attribute |
| 315 | *devattr, char *buf); |
| 316 | static ssize_t store_fan_beep(struct device *dev, struct device_attribute |
| 317 | *devattr, const char *buf, size_t count); |
| 318 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute |
| 319 | *devattr, char *buf); |
| 320 | /* Sysfs Temp */ |
| 321 | static ssize_t show_temp(struct device *dev, struct device_attribute |
| 322 | *devattr, char *buf); |
| 323 | static ssize_t show_temp_max(struct device *dev, struct device_attribute |
| 324 | *devattr, char *buf); |
| 325 | static ssize_t store_temp_max(struct device *dev, struct device_attribute |
| 326 | *devattr, const char *buf, size_t count); |
| 327 | static ssize_t show_temp_max_hyst(struct device *dev, struct device_attribute |
| 328 | *devattr, char *buf); |
| 329 | static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute |
| 330 | *devattr, const char *buf, size_t count); |
| 331 | static ssize_t show_temp_crit(struct device *dev, struct device_attribute |
| 332 | *devattr, char *buf); |
| 333 | static ssize_t store_temp_crit(struct device *dev, struct device_attribute |
| 334 | *devattr, const char *buf, size_t count); |
| 335 | static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute |
| 336 | *devattr, char *buf); |
| 337 | static ssize_t show_temp_type(struct device *dev, struct device_attribute |
| 338 | *devattr, char *buf); |
| 339 | static ssize_t show_temp_beep(struct device *dev, struct device_attribute |
| 340 | *devattr, char *buf); |
| 341 | static ssize_t store_temp_beep(struct device *dev, struct device_attribute |
| 342 | *devattr, const char *buf, size_t count); |
| 343 | static ssize_t show_temp_alarm(struct device *dev, struct device_attribute |
| 344 | *devattr, char *buf); |
| 345 | static ssize_t show_temp_fault(struct device *dev, struct device_attribute |
| 346 | *devattr, char *buf); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 347 | /* PWM and Auto point control */ |
| 348 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, |
| 349 | char *buf); |
| 350 | static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr, |
| 351 | const char *buf, size_t count); |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 352 | static ssize_t show_simple_pwm(struct device *dev, |
| 353 | struct device_attribute *devattr, char *buf); |
| 354 | static ssize_t store_simple_pwm(struct device *dev, |
| 355 | struct device_attribute *devattr, const char *buf, size_t count); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 356 | static ssize_t show_pwm_enable(struct device *dev, |
| 357 | struct device_attribute *devattr, char *buf); |
| 358 | static ssize_t store_pwm_enable(struct device *dev, |
| 359 | struct device_attribute *devattr, const char *buf, size_t count); |
| 360 | static ssize_t show_pwm_interpolate(struct device *dev, |
| 361 | struct device_attribute *devattr, char *buf); |
| 362 | static ssize_t store_pwm_interpolate(struct device *dev, |
| 363 | struct device_attribute *devattr, const char *buf, size_t count); |
| 364 | static ssize_t show_pwm_auto_point_channel(struct device *dev, |
| 365 | struct device_attribute *devattr, char *buf); |
| 366 | static ssize_t store_pwm_auto_point_channel(struct device *dev, |
| 367 | struct device_attribute *devattr, const char *buf, size_t count); |
| 368 | static ssize_t show_pwm_auto_point_temp_hyst(struct device *dev, |
| 369 | struct device_attribute *devattr, char *buf); |
| 370 | static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev, |
| 371 | struct device_attribute *devattr, const char *buf, size_t count); |
| 372 | static ssize_t show_pwm_auto_point_pwm(struct device *dev, |
| 373 | struct device_attribute *devattr, char *buf); |
| 374 | static ssize_t store_pwm_auto_point_pwm(struct device *dev, |
| 375 | struct device_attribute *devattr, const char *buf, size_t count); |
| 376 | static ssize_t show_pwm_auto_point_temp(struct device *dev, |
| 377 | struct device_attribute *devattr, char *buf); |
| 378 | static ssize_t store_pwm_auto_point_temp(struct device *dev, |
| 379 | struct device_attribute *devattr, const char *buf, size_t count); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 380 | /* Sysfs misc */ |
Julia Lawall | f2620e7 | 2016-12-22 13:04:39 +0100 | [diff] [blame] | 381 | static ssize_t name_show(struct device *dev, struct device_attribute *devattr, |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 382 | char *buf); |
| 383 | |
Bill Pemberton | 6c931ae | 2012-11-19 13:22:35 -0500 | [diff] [blame] | 384 | static int f71882fg_probe(struct platform_device *pdev); |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 385 | static int f71882fg_remove(struct platform_device *pdev); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 386 | |
| 387 | static struct platform_driver f71882fg_driver = { |
| 388 | .driver = { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 389 | .name = DRVNAME, |
| 390 | }, |
| 391 | .probe = f71882fg_probe, |
Jean Delvare | cd659fd | 2009-06-15 18:39:45 +0200 | [diff] [blame] | 392 | .remove = f71882fg_remove, |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 393 | }; |
| 394 | |
Julia Lawall | f2620e7 | 2016-12-22 13:04:39 +0100 | [diff] [blame] | 395 | static DEVICE_ATTR_RO(name); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 396 | |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 397 | /* |
| 398 | * Temp attr for the f71858fg, the f71858fg is special as it has its |
| 399 | * temperature indexes start at 0 (the others start at 1) |
| 400 | */ |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 401 | static struct sensor_device_attribute_2 f71858fg_temp_attr[] = { |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 402 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0), |
| 403 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, |
| 404 | store_temp_max, 0, 0), |
| 405 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
| 406 | store_temp_max_hyst, 0, 0), |
| 407 | SENSOR_ATTR_2(temp1_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 0), |
| 408 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
| 409 | store_temp_crit, 0, 0), |
| 410 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
| 411 | 0, 0), |
| 412 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4), |
| 413 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 0), |
| 414 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), |
| 415 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, |
| 416 | store_temp_max, 0, 1), |
| 417 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
| 418 | store_temp_max_hyst, 0, 1), |
| 419 | SENSOR_ATTR_2(temp2_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), |
| 420 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
| 421 | store_temp_crit, 0, 1), |
| 422 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
| 423 | 0, 1), |
| 424 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 425 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), |
| 426 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), |
| 427 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, |
| 428 | store_temp_max, 0, 2), |
| 429 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
| 430 | store_temp_max_hyst, 0, 2), |
| 431 | SENSOR_ATTR_2(temp3_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), |
| 432 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
| 433 | store_temp_crit, 0, 2), |
| 434 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
| 435 | 0, 2), |
| 436 | SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), |
| 437 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
| 438 | }; |
| 439 | |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 440 | /* Temp attr for the standard models */ |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 441 | static struct sensor_device_attribute_2 fxxxx_temp_attr[3][9] = { { |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 442 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 443 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 444 | store_temp_max, 0, 1), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 445 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 446 | store_temp_max_hyst, 0, 1), |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 447 | /* |
| 448 | * Should really be temp1_max_alarm, but older versions did not handle |
| 449 | * the max and crit alarms separately and lm_sensors v2 depends on the |
| 450 | * presence of temp#_alarm files. The same goes for temp2/3 _alarm. |
| 451 | */ |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 452 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 453 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 454 | store_temp_crit, 0, 1), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 455 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 456 | 0, 1), |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 457 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 458 | SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 1), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 459 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), |
Hans de Goede | 60d2b37 | 2011-03-09 20:57:11 +0100 | [diff] [blame] | 460 | }, { |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 461 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 2), |
| 462 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 463 | store_temp_max, 0, 2), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 464 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 465 | store_temp_max_hyst, 0, 2), |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 466 | /* Should be temp2_max_alarm, see temp1_alarm note */ |
| 467 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 468 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 469 | store_temp_crit, 0, 2), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 470 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 471 | 0, 2), |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 472 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 473 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 474 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
Hans de Goede | 60d2b37 | 2011-03-09 20:57:11 +0100 | [diff] [blame] | 475 | }, { |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 476 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 3), |
| 477 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, |
| 478 | store_temp_max, 0, 3), |
| 479 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
| 480 | store_temp_max_hyst, 0, 3), |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 481 | /* Should be temp3_max_alarm, see temp1_alarm note */ |
| 482 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 3), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 483 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
| 484 | store_temp_crit, 0, 3), |
| 485 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
| 486 | 0, 3), |
Hans de Goede | 754a5907b | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 487 | SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 7), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 488 | SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 3), |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 489 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), |
Hans de Goede | 60d2b37 | 2011-03-09 20:57:11 +0100 | [diff] [blame] | 490 | } }; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 491 | |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 492 | /* Temp attr for models which can beep on temp alarm */ |
| 493 | static struct sensor_device_attribute_2 fxxxx_temp_beep_attr[3][2] = { { |
| 494 | SENSOR_ATTR_2(temp1_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 495 | store_temp_beep, 0, 1), |
| 496 | SENSOR_ATTR_2(temp1_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 497 | store_temp_beep, 0, 5), |
| 498 | }, { |
| 499 | SENSOR_ATTR_2(temp2_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 500 | store_temp_beep, 0, 2), |
| 501 | SENSOR_ATTR_2(temp2_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 502 | store_temp_beep, 0, 6), |
| 503 | }, { |
| 504 | SENSOR_ATTR_2(temp3_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 505 | store_temp_beep, 0, 3), |
| 506 | SENSOR_ATTR_2(temp3_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 507 | store_temp_beep, 0, 7), |
| 508 | } }; |
| 509 | |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 510 | static struct sensor_device_attribute_2 f81866_temp_beep_attr[3][2] = { { |
| 511 | SENSOR_ATTR_2(temp1_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 512 | store_temp_beep, 0, 0), |
| 513 | SENSOR_ATTR_2(temp1_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 514 | store_temp_beep, 0, 4), |
| 515 | }, { |
| 516 | SENSOR_ATTR_2(temp2_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 517 | store_temp_beep, 0, 1), |
| 518 | SENSOR_ATTR_2(temp2_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 519 | store_temp_beep, 0, 5), |
| 520 | }, { |
| 521 | SENSOR_ATTR_2(temp3_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 522 | store_temp_beep, 0, 2), |
| 523 | SENSOR_ATTR_2(temp3_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
| 524 | store_temp_beep, 0, 6), |
| 525 | } }; |
| 526 | |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 527 | /* |
| 528 | * Temp attr for the f8000 |
| 529 | * Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max) |
| 530 | * is used as hysteresis value to clear alarms |
| 531 | * Also like the f71858fg its temperature indexes start at 0 |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 532 | */ |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 533 | static struct sensor_device_attribute_2 f8000_temp_attr[] = { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 534 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0), |
| 535 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_crit, |
| 536 | store_temp_crit, 0, 0), |
| 537 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, |
| 538 | store_temp_max, 0, 0), |
| 539 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4), |
Hans de Goede | b6858bc | 2009-06-15 18:39:51 +0200 | [diff] [blame] | 540 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 0), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 541 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), |
| 542 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_crit, |
| 543 | store_temp_crit, 0, 1), |
| 544 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, |
| 545 | store_temp_max, 0, 1), |
| 546 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), |
Hans de Goede | b6858bc | 2009-06-15 18:39:51 +0200 | [diff] [blame] | 547 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 548 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), |
| 549 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_crit, |
| 550 | store_temp_crit, 0, 2), |
| 551 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, |
| 552 | store_temp_max, 0, 2), |
| 553 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), |
Hans de Goede | b6858bc | 2009-06-15 18:39:51 +0200 | [diff] [blame] | 554 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 555 | }; |
| 556 | |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 557 | /* in attr for all models */ |
| 558 | static struct sensor_device_attribute_2 fxxxx_in_attr[] = { |
| 559 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
| 560 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), |
| 561 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), |
| 562 | SENSOR_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 0, 3), |
| 563 | SENSOR_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 0, 4), |
| 564 | SENSOR_ATTR_2(in5_input, S_IRUGO, show_in, NULL, 0, 5), |
| 565 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6), |
| 566 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7), |
| 567 | SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8), |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 568 | SENSOR_ATTR_2(in9_input, S_IRUGO, show_in, NULL, 0, 9), |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 569 | SENSOR_ATTR_2(in10_input, S_IRUGO, show_in, NULL, 0, 10), |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 570 | }; |
| 571 | |
| 572 | /* For models with in1 alarm capability */ |
| 573 | static struct sensor_device_attribute_2 fxxxx_in1_alarm_attr[] = { |
| 574 | SENSOR_ATTR_2(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max, |
| 575 | 0, 1), |
| 576 | SENSOR_ATTR_2(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep, |
| 577 | 0, 1), |
| 578 | SENSOR_ATTR_2(in1_alarm, S_IRUGO, show_in_alarm, NULL, 0, 1), |
| 579 | }; |
| 580 | |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 581 | /* Fan / PWM attr common to all models */ |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 582 | static struct sensor_device_attribute_2 fxxxx_fan_attr[4][6] = { { |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 583 | SENSOR_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0), |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 584 | SENSOR_ATTR_2(fan1_full_speed, S_IRUGO|S_IWUSR, |
| 585 | show_fan_full_speed, |
| 586 | store_fan_full_speed, 0, 0), |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 587 | SENSOR_ATTR_2(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 0), |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 588 | SENSOR_ATTR_2(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 0), |
| 589 | SENSOR_ATTR_2(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
| 590 | store_pwm_enable, 0, 0), |
| 591 | SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR, |
| 592 | show_pwm_interpolate, store_pwm_interpolate, 0, 0), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 593 | }, { |
| 594 | SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1), |
| 595 | SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR, |
| 596 | show_fan_full_speed, |
| 597 | store_fan_full_speed, 0, 1), |
| 598 | SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1), |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 599 | SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1), |
| 600 | SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
| 601 | store_pwm_enable, 0, 1), |
| 602 | SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR, |
| 603 | show_pwm_interpolate, store_pwm_interpolate, 0, 1), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 604 | }, { |
| 605 | SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2), |
| 606 | SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR, |
| 607 | show_fan_full_speed, |
| 608 | store_fan_full_speed, 0, 2), |
| 609 | SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2), |
Hans de Goede | 3fc7838 | 2009-06-15 18:39:50 +0200 | [diff] [blame] | 610 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), |
| 611 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
| 612 | store_pwm_enable, 0, 2), |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 613 | SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, |
| 614 | show_pwm_interpolate, store_pwm_interpolate, 0, 2), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 615 | }, { |
| 616 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), |
| 617 | SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR, |
| 618 | show_fan_full_speed, |
| 619 | store_fan_full_speed, 0, 3), |
| 620 | SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3), |
| 621 | SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3), |
| 622 | SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
| 623 | store_pwm_enable, 0, 3), |
| 624 | SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR, |
| 625 | show_pwm_interpolate, store_pwm_interpolate, 0, 3), |
| 626 | } }; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 627 | |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 628 | /* Attr for the third fan of the f71808a, which only has manual pwm */ |
| 629 | static struct sensor_device_attribute_2 f71808a_fan3_attr[] = { |
| 630 | SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2), |
| 631 | SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2), |
| 632 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, |
| 633 | show_simple_pwm, store_simple_pwm, 0, 2), |
| 634 | }; |
| 635 | |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 636 | /* Attr for models which can beep on Fan alarm */ |
| 637 | static struct sensor_device_attribute_2 fxxxx_fan_beep_attr[] = { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 638 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
| 639 | store_fan_beep, 0, 0), |
| 640 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
| 641 | store_fan_beep, 0, 1), |
| 642 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
| 643 | store_fan_beep, 0, 2), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 644 | SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
| 645 | store_fan_beep, 0, 3), |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 646 | }; |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 647 | |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 648 | /* |
| 649 | * PWM attr for the f71862fg, fewer pwms and fewer zones per pwm than the |
| 650 | * standard models |
| 651 | */ |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 652 | static struct sensor_device_attribute_2 f71862fg_auto_pwm_attr[3][7] = { { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 653 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 654 | show_pwm_auto_point_channel, |
| 655 | store_pwm_auto_point_channel, 0, 0), |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 656 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 657 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 658 | 1, 0), |
| 659 | SENSOR_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 660 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 661 | 4, 0), |
| 662 | SENSOR_ATTR_2(pwm1_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 663 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 664 | 0, 0), |
| 665 | SENSOR_ATTR_2(pwm1_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 666 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 667 | 3, 0), |
| 668 | SENSOR_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 669 | show_pwm_auto_point_temp_hyst, |
| 670 | store_pwm_auto_point_temp_hyst, |
| 671 | 0, 0), |
| 672 | SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO, |
| 673 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 674 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 675 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 676 | show_pwm_auto_point_channel, |
| 677 | store_pwm_auto_point_channel, 0, 1), |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 678 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 679 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 680 | 1, 1), |
| 681 | SENSOR_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 682 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 683 | 4, 1), |
| 684 | SENSOR_ATTR_2(pwm2_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 685 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 686 | 0, 1), |
| 687 | SENSOR_ATTR_2(pwm2_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 688 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 689 | 3, 1), |
| 690 | SENSOR_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 691 | show_pwm_auto_point_temp_hyst, |
| 692 | store_pwm_auto_point_temp_hyst, |
| 693 | 0, 1), |
| 694 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, |
| 695 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 696 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 697 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 698 | show_pwm_auto_point_channel, |
| 699 | store_pwm_auto_point_channel, 0, 2), |
Hans de Goede | 4901062 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 700 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 701 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 702 | 1, 2), |
| 703 | SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 704 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 705 | 4, 2), |
| 706 | SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 707 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 708 | 0, 2), |
| 709 | SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 710 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 711 | 3, 2), |
| 712 | SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 713 | show_pwm_auto_point_temp_hyst, |
| 714 | store_pwm_auto_point_temp_hyst, |
| 715 | 0, 2), |
| 716 | SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO, |
| 717 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 718 | } }; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 719 | |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 720 | /* |
| 721 | * PWM attr for the f71808e/f71869, almost identical to the f71862fg, but the |
| 722 | * pwm setting when the temperature is above the pwmX_auto_point1_temp can be |
| 723 | * programmed instead of being hardcoded to 0xff |
| 724 | */ |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 725 | static struct sensor_device_attribute_2 f71869_auto_pwm_attr[3][8] = { { |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 726 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 727 | show_pwm_auto_point_channel, |
| 728 | store_pwm_auto_point_channel, 0, 0), |
| 729 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 730 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 731 | 0, 0), |
| 732 | SENSOR_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 733 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 734 | 1, 0), |
| 735 | SENSOR_ATTR_2(pwm1_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 736 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 737 | 4, 0), |
| 738 | SENSOR_ATTR_2(pwm1_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 739 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 740 | 0, 0), |
| 741 | SENSOR_ATTR_2(pwm1_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 742 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 743 | 3, 0), |
| 744 | SENSOR_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 745 | show_pwm_auto_point_temp_hyst, |
| 746 | store_pwm_auto_point_temp_hyst, |
| 747 | 0, 0), |
| 748 | SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO, |
| 749 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 750 | }, { |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 751 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 752 | show_pwm_auto_point_channel, |
| 753 | store_pwm_auto_point_channel, 0, 1), |
| 754 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 755 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 756 | 0, 1), |
| 757 | SENSOR_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 758 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 759 | 1, 1), |
| 760 | SENSOR_ATTR_2(pwm2_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 761 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 762 | 4, 1), |
| 763 | SENSOR_ATTR_2(pwm2_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 764 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 765 | 0, 1), |
| 766 | SENSOR_ATTR_2(pwm2_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 767 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 768 | 3, 1), |
| 769 | SENSOR_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 770 | show_pwm_auto_point_temp_hyst, |
| 771 | store_pwm_auto_point_temp_hyst, |
| 772 | 0, 1), |
| 773 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, |
| 774 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 775 | }, { |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 776 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 777 | show_pwm_auto_point_channel, |
| 778 | store_pwm_auto_point_channel, 0, 2), |
| 779 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 780 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 781 | 0, 2), |
| 782 | SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 783 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 784 | 1, 2), |
| 785 | SENSOR_ATTR_2(pwm3_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 786 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 787 | 4, 2), |
| 788 | SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 789 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 790 | 0, 2), |
| 791 | SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 792 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 793 | 3, 2), |
| 794 | SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 795 | show_pwm_auto_point_temp_hyst, |
| 796 | store_pwm_auto_point_temp_hyst, |
| 797 | 0, 2), |
| 798 | SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO, |
| 799 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 800 | } }; |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 801 | |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 802 | /* PWM attr for the standard models */ |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 803 | static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[4][14] = { { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 804 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 805 | show_pwm_auto_point_channel, |
| 806 | store_pwm_auto_point_channel, 0, 0), |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 807 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 808 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 809 | 0, 0), |
| 810 | SENSOR_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 811 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 812 | 1, 0), |
| 813 | SENSOR_ATTR_2(pwm1_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 814 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 815 | 2, 0), |
| 816 | SENSOR_ATTR_2(pwm1_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 817 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 818 | 3, 0), |
| 819 | SENSOR_ATTR_2(pwm1_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 820 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 821 | 4, 0), |
| 822 | SENSOR_ATTR_2(pwm1_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 823 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 824 | 0, 0), |
| 825 | SENSOR_ATTR_2(pwm1_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 826 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 827 | 1, 0), |
| 828 | SENSOR_ATTR_2(pwm1_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 829 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 830 | 2, 0), |
| 831 | SENSOR_ATTR_2(pwm1_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 832 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 833 | 3, 0), |
| 834 | SENSOR_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 835 | show_pwm_auto_point_temp_hyst, |
| 836 | store_pwm_auto_point_temp_hyst, |
| 837 | 0, 0), |
| 838 | SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO, |
| 839 | show_pwm_auto_point_temp_hyst, NULL, 1, 0), |
| 840 | SENSOR_ATTR_2(pwm1_auto_point3_temp_hyst, S_IRUGO, |
| 841 | show_pwm_auto_point_temp_hyst, NULL, 2, 0), |
| 842 | SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO, |
| 843 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 844 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 845 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 846 | show_pwm_auto_point_channel, |
| 847 | store_pwm_auto_point_channel, 0, 1), |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 848 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 849 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 850 | 0, 1), |
| 851 | SENSOR_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 852 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 853 | 1, 1), |
| 854 | SENSOR_ATTR_2(pwm2_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 855 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 856 | 2, 1), |
| 857 | SENSOR_ATTR_2(pwm2_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 858 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 859 | 3, 1), |
| 860 | SENSOR_ATTR_2(pwm2_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 861 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 862 | 4, 1), |
| 863 | SENSOR_ATTR_2(pwm2_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 864 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 865 | 0, 1), |
| 866 | SENSOR_ATTR_2(pwm2_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 867 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 868 | 1, 1), |
| 869 | SENSOR_ATTR_2(pwm2_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 870 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 871 | 2, 1), |
| 872 | SENSOR_ATTR_2(pwm2_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 873 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 874 | 3, 1), |
| 875 | SENSOR_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 876 | show_pwm_auto_point_temp_hyst, |
| 877 | store_pwm_auto_point_temp_hyst, |
| 878 | 0, 1), |
| 879 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, |
| 880 | show_pwm_auto_point_temp_hyst, NULL, 1, 1), |
| 881 | SENSOR_ATTR_2(pwm2_auto_point3_temp_hyst, S_IRUGO, |
| 882 | show_pwm_auto_point_temp_hyst, NULL, 2, 1), |
| 883 | SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, |
| 884 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 885 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 886 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 887 | show_pwm_auto_point_channel, |
| 888 | store_pwm_auto_point_channel, 0, 2), |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 889 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 890 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 891 | 0, 2), |
| 892 | SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 893 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 894 | 1, 2), |
| 895 | SENSOR_ATTR_2(pwm3_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 896 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 897 | 2, 2), |
| 898 | SENSOR_ATTR_2(pwm3_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 899 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 900 | 3, 2), |
| 901 | SENSOR_ATTR_2(pwm3_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 902 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 903 | 4, 2), |
| 904 | SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 905 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 906 | 0, 2), |
| 907 | SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 908 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 909 | 1, 2), |
| 910 | SENSOR_ATTR_2(pwm3_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 911 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 912 | 2, 2), |
| 913 | SENSOR_ATTR_2(pwm3_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 914 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 915 | 3, 2), |
| 916 | SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 917 | show_pwm_auto_point_temp_hyst, |
| 918 | store_pwm_auto_point_temp_hyst, |
| 919 | 0, 2), |
| 920 | SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO, |
| 921 | show_pwm_auto_point_temp_hyst, NULL, 1, 2), |
| 922 | SENSOR_ATTR_2(pwm3_auto_point3_temp_hyst, S_IRUGO, |
| 923 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), |
| 924 | SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO, |
| 925 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 926 | }, { |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 927 | SENSOR_ATTR_2(pwm4_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 928 | show_pwm_auto_point_channel, |
| 929 | store_pwm_auto_point_channel, 0, 3), |
| 930 | SENSOR_ATTR_2(pwm4_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 931 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 932 | 0, 3), |
| 933 | SENSOR_ATTR_2(pwm4_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 934 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 935 | 1, 3), |
| 936 | SENSOR_ATTR_2(pwm4_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 937 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 938 | 2, 3), |
| 939 | SENSOR_ATTR_2(pwm4_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 940 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 941 | 3, 3), |
| 942 | SENSOR_ATTR_2(pwm4_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 943 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 944 | 4, 3), |
| 945 | SENSOR_ATTR_2(pwm4_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 946 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 947 | 0, 3), |
| 948 | SENSOR_ATTR_2(pwm4_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 949 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 950 | 1, 3), |
| 951 | SENSOR_ATTR_2(pwm4_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 952 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 953 | 2, 3), |
| 954 | SENSOR_ATTR_2(pwm4_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 955 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 956 | 3, 3), |
| 957 | SENSOR_ATTR_2(pwm4_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 958 | show_pwm_auto_point_temp_hyst, |
| 959 | store_pwm_auto_point_temp_hyst, |
| 960 | 0, 3), |
| 961 | SENSOR_ATTR_2(pwm4_auto_point2_temp_hyst, S_IRUGO, |
| 962 | show_pwm_auto_point_temp_hyst, NULL, 1, 3), |
| 963 | SENSOR_ATTR_2(pwm4_auto_point3_temp_hyst, S_IRUGO, |
| 964 | show_pwm_auto_point_temp_hyst, NULL, 2, 3), |
| 965 | SENSOR_ATTR_2(pwm4_auto_point4_temp_hyst, S_IRUGO, |
| 966 | show_pwm_auto_point_temp_hyst, NULL, 3, 3), |
Hans de Goede | b69b039 | 2009-12-09 20:36:00 +0100 | [diff] [blame] | 967 | } }; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 968 | |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 969 | /* Fan attr specific to the f8000 (4th fan input can only measure speed) */ |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 970 | static struct sensor_device_attribute_2 f8000_fan_attr[] = { |
| 971 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 972 | }; |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 973 | |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 974 | /* |
| 975 | * PWM attr for the f8000, zones mapped to temp instead of to pwm! |
| 976 | * Also the register block at offset A0 maps to TEMP1 (so our temp2, as the |
| 977 | * F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 |
| 978 | */ |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 979 | static struct sensor_device_attribute_2 f8000_auto_pwm_attr[3][14] = { { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 980 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 981 | show_pwm_auto_point_channel, |
| 982 | store_pwm_auto_point_channel, 0, 0), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 983 | SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 984 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 985 | 0, 2), |
| 986 | SENSOR_ATTR_2(temp1_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 987 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 988 | 1, 2), |
| 989 | SENSOR_ATTR_2(temp1_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 990 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 991 | 2, 2), |
| 992 | SENSOR_ATTR_2(temp1_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 993 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 994 | 3, 2), |
| 995 | SENSOR_ATTR_2(temp1_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 996 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 997 | 4, 2), |
| 998 | SENSOR_ATTR_2(temp1_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 999 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1000 | 0, 2), |
| 1001 | SENSOR_ATTR_2(temp1_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 1002 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1003 | 1, 2), |
| 1004 | SENSOR_ATTR_2(temp1_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 1005 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1006 | 2, 2), |
| 1007 | SENSOR_ATTR_2(temp1_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 1008 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1009 | 3, 2), |
| 1010 | SENSOR_ATTR_2(temp1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 1011 | show_pwm_auto_point_temp_hyst, |
| 1012 | store_pwm_auto_point_temp_hyst, |
| 1013 | 0, 2), |
| 1014 | SENSOR_ATTR_2(temp1_auto_point2_temp_hyst, S_IRUGO, |
| 1015 | show_pwm_auto_point_temp_hyst, NULL, 1, 2), |
| 1016 | SENSOR_ATTR_2(temp1_auto_point3_temp_hyst, S_IRUGO, |
| 1017 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), |
| 1018 | SENSOR_ATTR_2(temp1_auto_point4_temp_hyst, S_IRUGO, |
| 1019 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 1020 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 1021 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 1022 | show_pwm_auto_point_channel, |
| 1023 | store_pwm_auto_point_channel, 0, 1), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1024 | SENSOR_ATTR_2(temp2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 1025 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1026 | 0, 0), |
| 1027 | SENSOR_ATTR_2(temp2_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 1028 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1029 | 1, 0), |
| 1030 | SENSOR_ATTR_2(temp2_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 1031 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1032 | 2, 0), |
| 1033 | SENSOR_ATTR_2(temp2_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 1034 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1035 | 3, 0), |
| 1036 | SENSOR_ATTR_2(temp2_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 1037 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1038 | 4, 0), |
| 1039 | SENSOR_ATTR_2(temp2_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 1040 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1041 | 0, 0), |
| 1042 | SENSOR_ATTR_2(temp2_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 1043 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1044 | 1, 0), |
| 1045 | SENSOR_ATTR_2(temp2_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 1046 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1047 | 2, 0), |
| 1048 | SENSOR_ATTR_2(temp2_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 1049 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1050 | 3, 0), |
| 1051 | SENSOR_ATTR_2(temp2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 1052 | show_pwm_auto_point_temp_hyst, |
| 1053 | store_pwm_auto_point_temp_hyst, |
| 1054 | 0, 0), |
| 1055 | SENSOR_ATTR_2(temp2_auto_point2_temp_hyst, S_IRUGO, |
| 1056 | show_pwm_auto_point_temp_hyst, NULL, 1, 0), |
| 1057 | SENSOR_ATTR_2(temp2_auto_point3_temp_hyst, S_IRUGO, |
| 1058 | show_pwm_auto_point_temp_hyst, NULL, 2, 0), |
| 1059 | SENSOR_ATTR_2(temp2_auto_point4_temp_hyst, S_IRUGO, |
| 1060 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 1061 | }, { |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 1062 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, |
| 1063 | show_pwm_auto_point_channel, |
| 1064 | store_pwm_auto_point_channel, 0, 2), |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1065 | SENSOR_ATTR_2(temp3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
| 1066 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1067 | 0, 1), |
| 1068 | SENSOR_ATTR_2(temp3_auto_point2_pwm, S_IRUGO|S_IWUSR, |
| 1069 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1070 | 1, 1), |
| 1071 | SENSOR_ATTR_2(temp3_auto_point3_pwm, S_IRUGO|S_IWUSR, |
| 1072 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1073 | 2, 1), |
| 1074 | SENSOR_ATTR_2(temp3_auto_point4_pwm, S_IRUGO|S_IWUSR, |
| 1075 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1076 | 3, 1), |
| 1077 | SENSOR_ATTR_2(temp3_auto_point5_pwm, S_IRUGO|S_IWUSR, |
| 1078 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
| 1079 | 4, 1), |
| 1080 | SENSOR_ATTR_2(temp3_auto_point1_temp, S_IRUGO|S_IWUSR, |
| 1081 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1082 | 0, 1), |
| 1083 | SENSOR_ATTR_2(temp3_auto_point2_temp, S_IRUGO|S_IWUSR, |
| 1084 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1085 | 1, 1), |
| 1086 | SENSOR_ATTR_2(temp3_auto_point3_temp, S_IRUGO|S_IWUSR, |
| 1087 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1088 | 2, 1), |
| 1089 | SENSOR_ATTR_2(temp3_auto_point4_temp, S_IRUGO|S_IWUSR, |
| 1090 | show_pwm_auto_point_temp, store_pwm_auto_point_temp, |
| 1091 | 3, 1), |
| 1092 | SENSOR_ATTR_2(temp3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR, |
| 1093 | show_pwm_auto_point_temp_hyst, |
| 1094 | store_pwm_auto_point_temp_hyst, |
| 1095 | 0, 1), |
| 1096 | SENSOR_ATTR_2(temp3_auto_point2_temp_hyst, S_IRUGO, |
| 1097 | show_pwm_auto_point_temp_hyst, NULL, 1, 1), |
| 1098 | SENSOR_ATTR_2(temp3_auto_point3_temp_hyst, S_IRUGO, |
| 1099 | show_pwm_auto_point_temp_hyst, NULL, 2, 1), |
| 1100 | SENSOR_ATTR_2(temp3_auto_point4_temp_hyst, S_IRUGO, |
| 1101 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 1102 | } }; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1103 | |
| 1104 | /* Super I/O functions */ |
| 1105 | static inline int superio_inb(int base, int reg) |
| 1106 | { |
| 1107 | outb(reg, base); |
| 1108 | return inb(base + 1); |
| 1109 | } |
| 1110 | |
| 1111 | static int superio_inw(int base, int reg) |
| 1112 | { |
| 1113 | int val; |
Giel van Schijndel | bd328ac | 2010-05-27 19:58:42 +0200 | [diff] [blame] | 1114 | val = superio_inb(base, reg) << 8; |
| 1115 | val |= superio_inb(base, reg + 1); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1116 | return val; |
| 1117 | } |
| 1118 | |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 1119 | static inline int superio_enter(int base) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1120 | { |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 1121 | /* Don't step on other drivers' I/O space by accident */ |
| 1122 | if (!request_muxed_region(base, 2, DRVNAME)) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 1123 | pr_err("I/O address 0x%04x already in use\n", base); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 1124 | return -EBUSY; |
| 1125 | } |
| 1126 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1127 | /* according to the datasheet the key must be send twice! */ |
Giel van Schijndel | 162bb59 | 2010-05-27 19:58:40 +0200 | [diff] [blame] | 1128 | outb(SIO_UNLOCK_KEY, base); |
| 1129 | outb(SIO_UNLOCK_KEY, base); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 1130 | |
| 1131 | return 0; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1132 | } |
| 1133 | |
Giel van Schijndel | 162bb59 | 2010-05-27 19:58:40 +0200 | [diff] [blame] | 1134 | static inline void superio_select(int base, int ld) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1135 | { |
| 1136 | outb(SIO_REG_LDSEL, base); |
| 1137 | outb(ld, base + 1); |
| 1138 | } |
| 1139 | |
| 1140 | static inline void superio_exit(int base) |
| 1141 | { |
| 1142 | outb(SIO_LOCK_KEY, base); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 1143 | release_region(base, 2); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1144 | } |
| 1145 | |
Hans de Goede | 2f65063 | 2009-01-07 16:37:31 +0100 | [diff] [blame] | 1146 | static inline int fan_from_reg(u16 reg) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1147 | { |
| 1148 | return reg ? (1500000 / reg) : 0; |
| 1149 | } |
| 1150 | |
Hans de Goede | 2f65063 | 2009-01-07 16:37:31 +0100 | [diff] [blame] | 1151 | static inline u16 fan_to_reg(int fan) |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1152 | { |
| 1153 | return fan ? (1500000 / fan) : 0; |
| 1154 | } |
| 1155 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1156 | static u8 f71882fg_read8(struct f71882fg_data *data, u8 reg) |
| 1157 | { |
| 1158 | u8 val; |
| 1159 | |
| 1160 | outb(reg, data->addr + ADDR_REG_OFFSET); |
| 1161 | val = inb(data->addr + DATA_REG_OFFSET); |
| 1162 | |
| 1163 | return val; |
| 1164 | } |
| 1165 | |
| 1166 | static u16 f71882fg_read16(struct f71882fg_data *data, u8 reg) |
| 1167 | { |
| 1168 | u16 val; |
| 1169 | |
Giel van Schijndel | bd328ac | 2010-05-27 19:58:42 +0200 | [diff] [blame] | 1170 | val = f71882fg_read8(data, reg) << 8; |
| 1171 | val |= f71882fg_read8(data, reg + 1); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1172 | |
| 1173 | return val; |
| 1174 | } |
| 1175 | |
| 1176 | static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val) |
| 1177 | { |
| 1178 | outb(reg, data->addr + ADDR_REG_OFFSET); |
| 1179 | outb(val, data->addr + DATA_REG_OFFSET); |
| 1180 | } |
| 1181 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1182 | static void f71882fg_write16(struct f71882fg_data *data, u8 reg, u16 val) |
| 1183 | { |
Giel van Schijndel | bd328ac | 2010-05-27 19:58:42 +0200 | [diff] [blame] | 1184 | f71882fg_write8(data, reg, val >> 8); |
| 1185 | f71882fg_write8(data, reg + 1, val & 0xff); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1186 | } |
| 1187 | |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1188 | static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr) |
| 1189 | { |
| 1190 | if (data->type == f71858fg) |
| 1191 | return f71882fg_read16(data, F71882FG_REG_TEMP(nr)); |
| 1192 | else |
| 1193 | return f71882fg_read8(data, F71882FG_REG_TEMP(nr)); |
| 1194 | } |
| 1195 | |
Mark van Doesburg | 77a4a3e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1196 | static struct f71882fg_data *f71882fg_update_device(struct device *dev) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1197 | { |
| 1198 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 1199 | int nr_fans = f71882fg_nr_fans[data->type]; |
| 1200 | int nr_temps = f71882fg_nr_temps[data->type]; |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1201 | int nr, reg, point; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1202 | |
| 1203 | mutex_lock(&data->update_lock); |
| 1204 | |
| 1205 | /* Update once every 60 seconds */ |
Giel van Schijndel | 162bb59 | 2010-05-27 19:58:40 +0200 | [diff] [blame] | 1206 | if (time_after(jiffies, data->last_limits + 60 * HZ) || |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1207 | !data->valid) { |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 1208 | if (f71882fg_has_in1_alarm[data->type]) { |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1209 | if (data->type == f81866a) { |
| 1210 | data->in1_max = |
| 1211 | f71882fg_read8(data, |
| 1212 | F81866_REG_IN1_HIGH); |
| 1213 | data->in_beep = |
| 1214 | f71882fg_read8(data, |
| 1215 | F81866_REG_IN_BEEP); |
| 1216 | } else { |
| 1217 | data->in1_max = |
| 1218 | f71882fg_read8(data, |
| 1219 | F71882FG_REG_IN1_HIGH); |
| 1220 | data->in_beep = |
| 1221 | f71882fg_read8(data, |
| 1222 | F71882FG_REG_IN_BEEP); |
| 1223 | } |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1224 | } |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1225 | |
| 1226 | /* Get High & boundary temps*/ |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1227 | for (nr = data->temp_start; nr < nr_temps + data->temp_start; |
| 1228 | nr++) { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1229 | data->temp_ovt[nr] = f71882fg_read8(data, |
| 1230 | F71882FG_REG_TEMP_OVT(nr)); |
| 1231 | data->temp_high[nr] = f71882fg_read8(data, |
| 1232 | F71882FG_REG_TEMP_HIGH(nr)); |
| 1233 | } |
| 1234 | |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1235 | if (data->type != f8000) { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1236 | data->temp_hyst[0] = f71882fg_read8(data, |
| 1237 | F71882FG_REG_TEMP_HYST(0)); |
| 1238 | data->temp_hyst[1] = f71882fg_read8(data, |
| 1239 | F71882FG_REG_TEMP_HYST(1)); |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1240 | } |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 1241 | /* All but the f71858fg / f8000 have this register */ |
| 1242 | if ((data->type != f71858fg) && (data->type != f8000)) { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1243 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); |
Hans de Goede | 44c4dc5 | 2011-03-09 20:57:07 +0100 | [diff] [blame] | 1244 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1245 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; |
| 1246 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; |
| 1247 | } |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1248 | |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1249 | if (f71882fg_fan_has_beep[data->type]) |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 1250 | data->fan_beep = f71882fg_read8(data, |
| 1251 | F71882FG_REG_FAN_BEEP); |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1252 | |
| 1253 | if (f71882fg_temp_has_beep[data->type]) |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 1254 | data->temp_beep = f71882fg_read8(data, |
| 1255 | F71882FG_REG_TEMP_BEEP); |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 1256 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1257 | data->pwm_enable = f71882fg_read8(data, |
| 1258 | F71882FG_REG_PWM_ENABLE); |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 1259 | data->pwm_auto_point_hyst[0] = |
| 1260 | f71882fg_read8(data, F71882FG_REG_FAN_HYST(0)); |
| 1261 | data->pwm_auto_point_hyst[1] = |
| 1262 | f71882fg_read8(data, F71882FG_REG_FAN_HYST(1)); |
| 1263 | |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1264 | for (nr = 0; nr < nr_fans; nr++) { |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1265 | data->pwm_auto_point_mapping[nr] = |
| 1266 | f71882fg_read8(data, |
| 1267 | F71882FG_REG_POINT_MAPPING(nr)); |
| 1268 | |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1269 | switch (data->type) { |
| 1270 | default: |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1271 | for (point = 0; point < 5; point++) { |
| 1272 | data->pwm_auto_point_pwm[nr][point] = |
| 1273 | f71882fg_read8(data, |
| 1274 | F71882FG_REG_POINT_PWM |
| 1275 | (nr, point)); |
| 1276 | } |
| 1277 | for (point = 0; point < 4; point++) { |
| 1278 | data->pwm_auto_point_temp[nr][point] = |
| 1279 | f71882fg_read8(data, |
| 1280 | F71882FG_REG_POINT_TEMP |
| 1281 | (nr, point)); |
| 1282 | } |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1283 | break; |
| 1284 | case f71808e: |
| 1285 | case f71869: |
| 1286 | data->pwm_auto_point_pwm[nr][0] = |
| 1287 | f71882fg_read8(data, |
| 1288 | F71882FG_REG_POINT_PWM(nr, 0)); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1289 | fallthrough; |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1290 | case f71862fg: |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1291 | data->pwm_auto_point_pwm[nr][1] = |
| 1292 | f71882fg_read8(data, |
| 1293 | F71882FG_REG_POINT_PWM |
| 1294 | (nr, 1)); |
| 1295 | data->pwm_auto_point_pwm[nr][4] = |
| 1296 | f71882fg_read8(data, |
| 1297 | F71882FG_REG_POINT_PWM |
| 1298 | (nr, 4)); |
| 1299 | data->pwm_auto_point_temp[nr][0] = |
| 1300 | f71882fg_read8(data, |
| 1301 | F71882FG_REG_POINT_TEMP |
| 1302 | (nr, 0)); |
| 1303 | data->pwm_auto_point_temp[nr][3] = |
| 1304 | f71882fg_read8(data, |
| 1305 | F71882FG_REG_POINT_TEMP |
| 1306 | (nr, 3)); |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1307 | break; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1308 | } |
| 1309 | } |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1310 | data->last_limits = jiffies; |
| 1311 | } |
| 1312 | |
| 1313 | /* Update every second */ |
Mark M. Hoffman | 8afb104 | 2007-08-21 23:10:46 -0400 | [diff] [blame] | 1314 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1315 | data->temp_status = f71882fg_read8(data, |
| 1316 | F71882FG_REG_TEMP_STATUS); |
| 1317 | data->temp_diode_open = f71882fg_read8(data, |
| 1318 | F71882FG_REG_TEMP_DIODE_OPEN); |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 1319 | for (nr = data->temp_start; nr < nr_temps + data->temp_start; |
| 1320 | nr++) |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1321 | data->temp[nr] = f71882fg_read_temp(data, nr); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1322 | |
| 1323 | data->fan_status = f71882fg_read8(data, |
| 1324 | F71882FG_REG_FAN_STATUS); |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1325 | for (nr = 0; nr < nr_fans; nr++) { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1326 | data->fan[nr] = f71882fg_read16(data, |
| 1327 | F71882FG_REG_FAN(nr)); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1328 | data->fan_target[nr] = |
| 1329 | f71882fg_read16(data, F71882FG_REG_FAN_TARGET(nr)); |
| 1330 | data->fan_full_speed[nr] = |
| 1331 | f71882fg_read16(data, |
| 1332 | F71882FG_REG_FAN_FULL_SPEED(nr)); |
| 1333 | data->pwm[nr] = |
| 1334 | f71882fg_read8(data, F71882FG_REG_PWM(nr)); |
| 1335 | } |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1336 | /* Some models have 1 more fan with limited capabilities */ |
| 1337 | if (data->type == f71808a) { |
| 1338 | data->fan[2] = f71882fg_read16(data, |
| 1339 | F71882FG_REG_FAN(2)); |
| 1340 | data->pwm[2] = f71882fg_read8(data, |
| 1341 | F71882FG_REG_PWM(2)); |
| 1342 | } |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1343 | if (data->type == f8000) |
| 1344 | data->fan[3] = f71882fg_read16(data, |
| 1345 | F71882FG_REG_FAN(3)); |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 1346 | |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1347 | if (f71882fg_has_in1_alarm[data->type]) { |
| 1348 | if (data->type == f81866a) |
| 1349 | data->in_status = f71882fg_read8(data, |
| 1350 | F81866_REG_IN_STATUS); |
| 1351 | |
| 1352 | else |
| 1353 | data->in_status = f71882fg_read8(data, |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1354 | F71882FG_REG_IN_STATUS); |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1355 | } |
| 1356 | |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 1357 | for (nr = 0; nr < F71882FG_MAX_INS; nr++) |
| 1358 | if (f71882fg_has_in[data->type][nr]) |
| 1359 | data->in[nr] = f71882fg_read8(data, |
| 1360 | F71882FG_REG_IN(nr)); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1361 | |
| 1362 | data->last_updated = jiffies; |
Paul Fertser | 952a11c | 2021-09-24 22:52:02 +0300 | [diff] [blame] | 1363 | data->valid = true; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1364 | } |
| 1365 | |
| 1366 | mutex_unlock(&data->update_lock); |
| 1367 | |
| 1368 | return data; |
| 1369 | } |
| 1370 | |
| 1371 | /* Sysfs Interface */ |
| 1372 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
| 1373 | char *buf) |
| 1374 | { |
| 1375 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1376 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1377 | int speed = fan_from_reg(data->fan[nr]); |
| 1378 | |
| 1379 | if (speed == FAN_MIN_DETECT) |
| 1380 | speed = 0; |
| 1381 | |
| 1382 | return sprintf(buf, "%d\n", speed); |
| 1383 | } |
| 1384 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1385 | static ssize_t show_fan_full_speed(struct device *dev, |
| 1386 | struct device_attribute *devattr, char *buf) |
| 1387 | { |
| 1388 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1389 | int nr = to_sensor_dev_attr_2(devattr)->index; |
| 1390 | int speed = fan_from_reg(data->fan_full_speed[nr]); |
| 1391 | return sprintf(buf, "%d\n", speed); |
| 1392 | } |
| 1393 | |
| 1394 | static ssize_t store_fan_full_speed(struct device *dev, |
| 1395 | struct device_attribute *devattr, |
| 1396 | const char *buf, size_t count) |
| 1397 | { |
| 1398 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1399 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1400 | long val; |
| 1401 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1402 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1403 | if (err) |
| 1404 | return err; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1405 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1406 | val = clamp_val(val, 23, 1500000); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1407 | val = fan_to_reg(val); |
| 1408 | |
| 1409 | mutex_lock(&data->update_lock); |
Hans de Goede | 4c82c38 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1410 | f71882fg_write16(data, F71882FG_REG_FAN_FULL_SPEED(nr), val); |
| 1411 | data->fan_full_speed[nr] = val; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1412 | mutex_unlock(&data->update_lock); |
| 1413 | |
| 1414 | return count; |
| 1415 | } |
| 1416 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1417 | static ssize_t show_fan_beep(struct device *dev, struct device_attribute |
| 1418 | *devattr, char *buf) |
| 1419 | { |
| 1420 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1421 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1422 | |
| 1423 | if (data->fan_beep & (1 << nr)) |
| 1424 | return sprintf(buf, "1\n"); |
| 1425 | else |
| 1426 | return sprintf(buf, "0\n"); |
| 1427 | } |
| 1428 | |
| 1429 | static ssize_t store_fan_beep(struct device *dev, struct device_attribute |
| 1430 | *devattr, const char *buf, size_t count) |
| 1431 | { |
| 1432 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1433 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1434 | unsigned long val; |
| 1435 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1436 | err = kstrtoul(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1437 | if (err) |
| 1438 | return err; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1439 | |
| 1440 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1441 | data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1442 | if (val) |
| 1443 | data->fan_beep |= 1 << nr; |
| 1444 | else |
| 1445 | data->fan_beep &= ~(1 << nr); |
| 1446 | |
| 1447 | f71882fg_write8(data, F71882FG_REG_FAN_BEEP, data->fan_beep); |
| 1448 | mutex_unlock(&data->update_lock); |
| 1449 | |
| 1450 | return count; |
| 1451 | } |
| 1452 | |
| 1453 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute |
| 1454 | *devattr, char *buf) |
| 1455 | { |
| 1456 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1457 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1458 | |
| 1459 | if (data->fan_status & (1 << nr)) |
| 1460 | return sprintf(buf, "1\n"); |
| 1461 | else |
| 1462 | return sprintf(buf, "0\n"); |
| 1463 | } |
| 1464 | |
| 1465 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
| 1466 | char *buf) |
| 1467 | { |
| 1468 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1469 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1470 | |
| 1471 | return sprintf(buf, "%d\n", data->in[nr] * 8); |
| 1472 | } |
| 1473 | |
| 1474 | static ssize_t show_in_max(struct device *dev, struct device_attribute |
| 1475 | *devattr, char *buf) |
| 1476 | { |
| 1477 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1478 | |
| 1479 | return sprintf(buf, "%d\n", data->in1_max * 8); |
| 1480 | } |
| 1481 | |
| 1482 | static ssize_t store_in_max(struct device *dev, struct device_attribute |
| 1483 | *devattr, const char *buf, size_t count) |
| 1484 | { |
| 1485 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1486 | int err; |
| 1487 | long val; |
| 1488 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1489 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1490 | if (err) |
| 1491 | return err; |
| 1492 | |
| 1493 | val /= 8; |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1494 | val = clamp_val(val, 0, 255); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1495 | |
| 1496 | mutex_lock(&data->update_lock); |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1497 | if (data->type == f81866a) |
| 1498 | f71882fg_write8(data, F81866_REG_IN1_HIGH, val); |
| 1499 | else |
| 1500 | f71882fg_write8(data, F71882FG_REG_IN1_HIGH, val); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1501 | data->in1_max = val; |
| 1502 | mutex_unlock(&data->update_lock); |
| 1503 | |
| 1504 | return count; |
| 1505 | } |
| 1506 | |
| 1507 | static ssize_t show_in_beep(struct device *dev, struct device_attribute |
| 1508 | *devattr, char *buf) |
| 1509 | { |
| 1510 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1511 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1512 | |
| 1513 | if (data->in_beep & (1 << nr)) |
| 1514 | return sprintf(buf, "1\n"); |
| 1515 | else |
| 1516 | return sprintf(buf, "0\n"); |
| 1517 | } |
| 1518 | |
| 1519 | static ssize_t store_in_beep(struct device *dev, struct device_attribute |
| 1520 | *devattr, const char *buf, size_t count) |
| 1521 | { |
| 1522 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1523 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1524 | unsigned long val; |
| 1525 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1526 | err = kstrtoul(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1527 | if (err) |
| 1528 | return err; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1529 | |
| 1530 | mutex_lock(&data->update_lock); |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1531 | if (data->type == f81866a) |
| 1532 | data->in_beep = f71882fg_read8(data, F81866_REG_IN_BEEP); |
| 1533 | else |
| 1534 | data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP); |
| 1535 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1536 | if (val) |
| 1537 | data->in_beep |= 1 << nr; |
| 1538 | else |
| 1539 | data->in_beep &= ~(1 << nr); |
| 1540 | |
Peter Hung | 3e40b86 | 2015-07-07 16:22:38 +0800 | [diff] [blame] | 1541 | if (data->type == f81866a) |
| 1542 | f71882fg_write8(data, F81866_REG_IN_BEEP, data->in_beep); |
| 1543 | else |
| 1544 | f71882fg_write8(data, F71882FG_REG_IN_BEEP, data->in_beep); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1545 | mutex_unlock(&data->update_lock); |
| 1546 | |
| 1547 | return count; |
| 1548 | } |
| 1549 | |
| 1550 | static ssize_t show_in_alarm(struct device *dev, struct device_attribute |
| 1551 | *devattr, char *buf) |
| 1552 | { |
| 1553 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1554 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1555 | |
| 1556 | if (data->in_status & (1 << nr)) |
| 1557 | return sprintf(buf, "1\n"); |
| 1558 | else |
| 1559 | return sprintf(buf, "0\n"); |
| 1560 | } |
| 1561 | |
| 1562 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
| 1563 | char *buf) |
| 1564 | { |
| 1565 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1566 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1567 | int sign, temp; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1568 | |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1569 | if (data->type == f71858fg) { |
| 1570 | /* TEMP_TABLE_SEL 1 or 3 ? */ |
| 1571 | if (data->temp_config & 1) { |
| 1572 | sign = data->temp[nr] & 0x0001; |
| 1573 | temp = (data->temp[nr] >> 5) & 0x7ff; |
| 1574 | } else { |
| 1575 | sign = data->temp[nr] & 0x8000; |
| 1576 | temp = (data->temp[nr] >> 5) & 0x3ff; |
| 1577 | } |
| 1578 | temp *= 125; |
| 1579 | if (sign) |
| 1580 | temp -= 128000; |
| 1581 | } else |
| 1582 | temp = data->temp[nr] * 1000; |
| 1583 | |
| 1584 | return sprintf(buf, "%d\n", temp); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | static ssize_t show_temp_max(struct device *dev, struct device_attribute |
| 1588 | *devattr, char *buf) |
| 1589 | { |
| 1590 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1591 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1592 | |
| 1593 | return sprintf(buf, "%d\n", data->temp_high[nr] * 1000); |
| 1594 | } |
| 1595 | |
| 1596 | static ssize_t store_temp_max(struct device *dev, struct device_attribute |
| 1597 | *devattr, const char *buf, size_t count) |
| 1598 | { |
| 1599 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1600 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1601 | long val; |
| 1602 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1603 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1604 | if (err) |
| 1605 | return err; |
| 1606 | |
| 1607 | val /= 1000; |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1608 | val = clamp_val(val, 0, 255); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1609 | |
| 1610 | mutex_lock(&data->update_lock); |
| 1611 | f71882fg_write8(data, F71882FG_REG_TEMP_HIGH(nr), val); |
| 1612 | data->temp_high[nr] = val; |
| 1613 | mutex_unlock(&data->update_lock); |
| 1614 | |
| 1615 | return count; |
| 1616 | } |
| 1617 | |
| 1618 | static ssize_t show_temp_max_hyst(struct device *dev, struct device_attribute |
| 1619 | *devattr, char *buf) |
| 1620 | { |
| 1621 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1622 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1623 | int temp_max_hyst; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1624 | |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1625 | mutex_lock(&data->update_lock); |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 1626 | if (nr & 1) |
| 1627 | temp_max_hyst = data->temp_hyst[nr / 2] >> 4; |
| 1628 | else |
| 1629 | temp_max_hyst = data->temp_hyst[nr / 2] & 0x0f; |
| 1630 | temp_max_hyst = (data->temp_high[nr] - temp_max_hyst) * 1000; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1631 | mutex_unlock(&data->update_lock); |
| 1632 | |
| 1633 | return sprintf(buf, "%d\n", temp_max_hyst); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1634 | } |
| 1635 | |
| 1636 | static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute |
| 1637 | *devattr, const char *buf, size_t count) |
| 1638 | { |
| 1639 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1640 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1641 | ssize_t ret = count; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1642 | u8 reg; |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1643 | long val; |
| 1644 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1645 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1646 | if (err) |
| 1647 | return err; |
| 1648 | |
| 1649 | val /= 1000; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1650 | |
| 1651 | mutex_lock(&data->update_lock); |
| 1652 | |
| 1653 | /* convert abs to relative and check */ |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1654 | data->temp_high[nr] = f71882fg_read8(data, F71882FG_REG_TEMP_HIGH(nr)); |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1655 | val = clamp_val(val, data->temp_high[nr] - 15, data->temp_high[nr]); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1656 | val = data->temp_high[nr] - val; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1657 | |
| 1658 | /* convert value to register contents */ |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 1659 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_HYST(nr / 2)); |
| 1660 | if (nr & 1) |
| 1661 | reg = (reg & 0x0f) | (val << 4); |
| 1662 | else |
| 1663 | reg = (reg & 0xf0) | val; |
| 1664 | f71882fg_write8(data, F71882FG_REG_TEMP_HYST(nr / 2), reg); |
| 1665 | data->temp_hyst[nr / 2] = reg; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1666 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1667 | mutex_unlock(&data->update_lock); |
| 1668 | return ret; |
| 1669 | } |
| 1670 | |
| 1671 | static ssize_t show_temp_crit(struct device *dev, struct device_attribute |
| 1672 | *devattr, char *buf) |
| 1673 | { |
| 1674 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1675 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1676 | |
| 1677 | return sprintf(buf, "%d\n", data->temp_ovt[nr] * 1000); |
| 1678 | } |
| 1679 | |
| 1680 | static ssize_t store_temp_crit(struct device *dev, struct device_attribute |
| 1681 | *devattr, const char *buf, size_t count) |
| 1682 | { |
| 1683 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1684 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1685 | long val; |
| 1686 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1687 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1688 | if (err) |
| 1689 | return err; |
| 1690 | |
| 1691 | val /= 1000; |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1692 | val = clamp_val(val, 0, 255); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1693 | |
| 1694 | mutex_lock(&data->update_lock); |
| 1695 | f71882fg_write8(data, F71882FG_REG_TEMP_OVT(nr), val); |
| 1696 | data->temp_ovt[nr] = val; |
| 1697 | mutex_unlock(&data->update_lock); |
| 1698 | |
| 1699 | return count; |
| 1700 | } |
| 1701 | |
| 1702 | static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute |
| 1703 | *devattr, char *buf) |
| 1704 | { |
| 1705 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1706 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1707 | int temp_crit_hyst; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1708 | |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1709 | mutex_lock(&data->update_lock); |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 1710 | if (nr & 1) |
| 1711 | temp_crit_hyst = data->temp_hyst[nr / 2] >> 4; |
| 1712 | else |
| 1713 | temp_crit_hyst = data->temp_hyst[nr / 2] & 0x0f; |
| 1714 | temp_crit_hyst = (data->temp_ovt[nr] - temp_crit_hyst) * 1000; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1715 | mutex_unlock(&data->update_lock); |
| 1716 | |
| 1717 | return sprintf(buf, "%d\n", temp_crit_hyst); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1718 | } |
| 1719 | |
| 1720 | static ssize_t show_temp_type(struct device *dev, struct device_attribute |
| 1721 | *devattr, char *buf) |
| 1722 | { |
| 1723 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1724 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1725 | |
| 1726 | return sprintf(buf, "%d\n", data->temp_type[nr]); |
| 1727 | } |
| 1728 | |
| 1729 | static ssize_t show_temp_beep(struct device *dev, struct device_attribute |
| 1730 | *devattr, char *buf) |
| 1731 | { |
| 1732 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1733 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1734 | |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1735 | if (data->temp_beep & (1 << nr)) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1736 | return sprintf(buf, "1\n"); |
| 1737 | else |
| 1738 | return sprintf(buf, "0\n"); |
| 1739 | } |
| 1740 | |
| 1741 | static ssize_t store_temp_beep(struct device *dev, struct device_attribute |
| 1742 | *devattr, const char *buf, size_t count) |
| 1743 | { |
| 1744 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1745 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1746 | unsigned long val; |
| 1747 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1748 | err = kstrtoul(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1749 | if (err) |
| 1750 | return err; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1751 | |
| 1752 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1753 | data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1754 | if (val) |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1755 | data->temp_beep |= 1 << nr; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1756 | else |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1757 | data->temp_beep &= ~(1 << nr); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1758 | |
| 1759 | f71882fg_write8(data, F71882FG_REG_TEMP_BEEP, data->temp_beep); |
| 1760 | mutex_unlock(&data->update_lock); |
| 1761 | |
| 1762 | return count; |
| 1763 | } |
| 1764 | |
| 1765 | static ssize_t show_temp_alarm(struct device *dev, struct device_attribute |
| 1766 | *devattr, char *buf) |
| 1767 | { |
| 1768 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1769 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1770 | |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1771 | if (data->temp_status & (1 << nr)) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1772 | return sprintf(buf, "1\n"); |
| 1773 | else |
| 1774 | return sprintf(buf, "0\n"); |
| 1775 | } |
| 1776 | |
| 1777 | static ssize_t show_temp_fault(struct device *dev, struct device_attribute |
| 1778 | *devattr, char *buf) |
| 1779 | { |
| 1780 | struct f71882fg_data *data = f71882fg_update_device(dev); |
Mark van Doesburg | bc37ae7 | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1781 | int nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1782 | |
Hans de Goede | 7567a04 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1783 | if (data->temp_diode_open & (1 << nr)) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 1784 | return sprintf(buf, "1\n"); |
| 1785 | else |
| 1786 | return sprintf(buf, "0\n"); |
| 1787 | } |
| 1788 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1789 | static ssize_t show_pwm(struct device *dev, |
| 1790 | struct device_attribute *devattr, char *buf) |
| 1791 | { |
| 1792 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1793 | int val, nr = to_sensor_dev_attr_2(devattr)->index; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1794 | mutex_lock(&data->update_lock); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1795 | if (data->pwm_enable & (1 << (2 * nr))) |
| 1796 | /* PWM mode */ |
| 1797 | val = data->pwm[nr]; |
| 1798 | else { |
| 1799 | /* RPM mode */ |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1800 | val = 255 * fan_from_reg(data->fan_target[nr]) |
| 1801 | / fan_from_reg(data->fan_full_speed[nr]); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1802 | } |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1803 | mutex_unlock(&data->update_lock); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1804 | return sprintf(buf, "%d\n", val); |
| 1805 | } |
| 1806 | |
| 1807 | static ssize_t store_pwm(struct device *dev, |
| 1808 | struct device_attribute *devattr, const char *buf, |
| 1809 | size_t count) |
| 1810 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1811 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1812 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1813 | long val; |
| 1814 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1815 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1816 | if (err) |
| 1817 | return err; |
| 1818 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1819 | val = clamp_val(val, 0, 255); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1820 | |
| 1821 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1822 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1823 | if ((data->type == f8000 && ((data->pwm_enable >> 2 * nr) & 3) != 2) || |
| 1824 | (data->type != f8000 && !((data->pwm_enable >> 2 * nr) & 2))) { |
| 1825 | count = -EROFS; |
| 1826 | goto leave; |
| 1827 | } |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1828 | if (data->pwm_enable & (1 << (2 * nr))) { |
| 1829 | /* PWM mode */ |
| 1830 | f71882fg_write8(data, F71882FG_REG_PWM(nr), val); |
| 1831 | data->pwm[nr] = val; |
| 1832 | } else { |
| 1833 | /* RPM mode */ |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1834 | int target, full_speed; |
| 1835 | full_speed = f71882fg_read16(data, |
| 1836 | F71882FG_REG_FAN_FULL_SPEED(nr)); |
| 1837 | target = fan_to_reg(val * fan_from_reg(full_speed) / 255); |
| 1838 | f71882fg_write16(data, F71882FG_REG_FAN_TARGET(nr), target); |
| 1839 | data->fan_target[nr] = target; |
| 1840 | data->fan_full_speed[nr] = full_speed; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1841 | } |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1842 | leave: |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1843 | mutex_unlock(&data->update_lock); |
| 1844 | |
| 1845 | return count; |
| 1846 | } |
| 1847 | |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1848 | static ssize_t show_simple_pwm(struct device *dev, |
| 1849 | struct device_attribute *devattr, char *buf) |
| 1850 | { |
| 1851 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1852 | int val, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1853 | |
| 1854 | val = data->pwm[nr]; |
| 1855 | return sprintf(buf, "%d\n", val); |
| 1856 | } |
| 1857 | |
| 1858 | static ssize_t store_simple_pwm(struct device *dev, |
| 1859 | struct device_attribute *devattr, |
| 1860 | const char *buf, size_t count) |
| 1861 | { |
| 1862 | struct f71882fg_data *data = dev_get_drvdata(dev); |
| 1863 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1864 | long val; |
| 1865 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1866 | err = kstrtol(buf, 10, &val); |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1867 | if (err) |
| 1868 | return err; |
| 1869 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1870 | val = clamp_val(val, 0, 255); |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 1871 | |
| 1872 | mutex_lock(&data->update_lock); |
| 1873 | f71882fg_write8(data, F71882FG_REG_PWM(nr), val); |
| 1874 | data->pwm[nr] = val; |
| 1875 | mutex_unlock(&data->update_lock); |
| 1876 | |
| 1877 | return count; |
| 1878 | } |
| 1879 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1880 | static ssize_t show_pwm_enable(struct device *dev, |
| 1881 | struct device_attribute *devattr, char *buf) |
| 1882 | { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1883 | int result = 0; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1884 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1885 | int nr = to_sensor_dev_attr_2(devattr)->index; |
| 1886 | |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1887 | switch ((data->pwm_enable >> 2 * nr) & 3) { |
| 1888 | case 0: |
| 1889 | case 1: |
| 1890 | result = 2; /* Normal auto mode */ |
| 1891 | break; |
| 1892 | case 2: |
| 1893 | result = 1; /* Manual mode */ |
| 1894 | break; |
| 1895 | case 3: |
| 1896 | if (data->type == f8000) |
| 1897 | result = 3; /* Thermostat mode */ |
| 1898 | else |
| 1899 | result = 1; /* Manual mode */ |
| 1900 | break; |
| 1901 | } |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1902 | |
| 1903 | return sprintf(buf, "%d\n", result); |
| 1904 | } |
| 1905 | |
| 1906 | static ssize_t store_pwm_enable(struct device *dev, struct device_attribute |
| 1907 | *devattr, const char *buf, size_t count) |
| 1908 | { |
| 1909 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1910 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 1911 | long val; |
| 1912 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1913 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1914 | if (err) |
| 1915 | return err; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1916 | |
Hans de Goede | 3fc7838 | 2009-06-15 18:39:50 +0200 | [diff] [blame] | 1917 | /* Special case for F8000 pwm channel 3 which only does auto mode */ |
| 1918 | if (data->type == f8000 && nr == 2 && val != 2) |
| 1919 | return -EINVAL; |
| 1920 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1921 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1922 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1923 | /* Special case for F8000 auto PWM mode / Thermostat mode */ |
| 1924 | if (data->type == f8000 && ((data->pwm_enable >> 2 * nr) & 1)) { |
| 1925 | switch (val) { |
| 1926 | case 2: |
| 1927 | data->pwm_enable &= ~(2 << (2 * nr)); |
| 1928 | break; /* Normal auto mode */ |
| 1929 | case 3: |
| 1930 | data->pwm_enable |= 2 << (2 * nr); |
| 1931 | break; /* Thermostat mode */ |
| 1932 | default: |
| 1933 | count = -EINVAL; |
| 1934 | goto leave; |
| 1935 | } |
| 1936 | } else { |
| 1937 | switch (val) { |
| 1938 | case 1: |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 1939 | /* The f71858fg does not support manual RPM mode */ |
| 1940 | if (data->type == f71858fg && |
| 1941 | ((data->pwm_enable >> (2 * nr)) & 1)) { |
| 1942 | count = -EINVAL; |
| 1943 | goto leave; |
| 1944 | } |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1945 | data->pwm_enable |= 2 << (2 * nr); |
| 1946 | break; /* Manual */ |
| 1947 | case 2: |
| 1948 | data->pwm_enable &= ~(2 << (2 * nr)); |
| 1949 | break; /* Normal auto mode */ |
| 1950 | default: |
| 1951 | count = -EINVAL; |
| 1952 | goto leave; |
| 1953 | } |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1954 | } |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1955 | f71882fg_write8(data, F71882FG_REG_PWM_ENABLE, data->pwm_enable); |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 1956 | leave: |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1957 | mutex_unlock(&data->update_lock); |
| 1958 | |
| 1959 | return count; |
| 1960 | } |
| 1961 | |
| 1962 | static ssize_t show_pwm_auto_point_pwm(struct device *dev, |
| 1963 | struct device_attribute *devattr, |
| 1964 | char *buf) |
| 1965 | { |
| 1966 | int result; |
| 1967 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 1968 | int pwm = to_sensor_dev_attr_2(devattr)->index; |
| 1969 | int point = to_sensor_dev_attr_2(devattr)->nr; |
| 1970 | |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1971 | mutex_lock(&data->update_lock); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1972 | if (data->pwm_enable & (1 << (2 * pwm))) { |
| 1973 | /* PWM mode */ |
| 1974 | result = data->pwm_auto_point_pwm[pwm][point]; |
| 1975 | } else { |
| 1976 | /* RPM mode */ |
| 1977 | result = 32 * 255 / (32 + data->pwm_auto_point_pwm[pwm][point]); |
| 1978 | } |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1979 | mutex_unlock(&data->update_lock); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1980 | |
| 1981 | return sprintf(buf, "%d\n", result); |
| 1982 | } |
| 1983 | |
| 1984 | static ssize_t store_pwm_auto_point_pwm(struct device *dev, |
| 1985 | struct device_attribute *devattr, |
| 1986 | const char *buf, size_t count) |
| 1987 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 1988 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1989 | int err, pwm = to_sensor_dev_attr_2(devattr)->index; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1990 | int point = to_sensor_dev_attr_2(devattr)->nr; |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1991 | long val; |
| 1992 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 1993 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 1994 | if (err) |
| 1995 | return err; |
| 1996 | |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 1997 | val = clamp_val(val, 0, 255); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 1998 | |
| 1999 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2000 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2001 | if (data->pwm_enable & (1 << (2 * pwm))) { |
| 2002 | /* PWM mode */ |
| 2003 | } else { |
| 2004 | /* RPM mode */ |
| 2005 | if (val < 29) /* Prevent negative numbers */ |
| 2006 | val = 255; |
| 2007 | else |
| 2008 | val = (255 - val) * 32 / val; |
| 2009 | } |
| 2010 | f71882fg_write8(data, F71882FG_REG_POINT_PWM(pwm, point), val); |
| 2011 | data->pwm_auto_point_pwm[pwm][point] = val; |
| 2012 | mutex_unlock(&data->update_lock); |
| 2013 | |
| 2014 | return count; |
| 2015 | } |
| 2016 | |
| 2017 | static ssize_t show_pwm_auto_point_temp_hyst(struct device *dev, |
| 2018 | struct device_attribute *devattr, |
| 2019 | char *buf) |
| 2020 | { |
| 2021 | int result = 0; |
| 2022 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 2023 | int nr = to_sensor_dev_attr_2(devattr)->index; |
| 2024 | int point = to_sensor_dev_attr_2(devattr)->nr; |
| 2025 | |
| 2026 | mutex_lock(&data->update_lock); |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 2027 | if (nr & 1) |
| 2028 | result = data->pwm_auto_point_hyst[nr / 2] >> 4; |
| 2029 | else |
| 2030 | result = data->pwm_auto_point_hyst[nr / 2] & 0x0f; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2031 | result = 1000 * (data->pwm_auto_point_temp[nr][point] - result); |
| 2032 | mutex_unlock(&data->update_lock); |
| 2033 | |
| 2034 | return sprintf(buf, "%d\n", result); |
| 2035 | } |
| 2036 | |
| 2037 | static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev, |
| 2038 | struct device_attribute *devattr, |
| 2039 | const char *buf, size_t count) |
| 2040 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2041 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2042 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2043 | int point = to_sensor_dev_attr_2(devattr)->nr; |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 2044 | u8 reg; |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2045 | long val; |
| 2046 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 2047 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2048 | if (err) |
| 2049 | return err; |
| 2050 | |
| 2051 | val /= 1000; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2052 | |
| 2053 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2054 | data->pwm_auto_point_temp[nr][point] = |
| 2055 | f71882fg_read8(data, F71882FG_REG_POINT_TEMP(nr, point)); |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 2056 | val = clamp_val(val, data->pwm_auto_point_temp[nr][point] - 15, |
| 2057 | data->pwm_auto_point_temp[nr][point]); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2058 | val = data->pwm_auto_point_temp[nr][point] - val; |
| 2059 | |
Hans de Goede | bc27490 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 2060 | reg = f71882fg_read8(data, F71882FG_REG_FAN_HYST(nr / 2)); |
| 2061 | if (nr & 1) |
| 2062 | reg = (reg & 0x0f) | (val << 4); |
| 2063 | else |
| 2064 | reg = (reg & 0xf0) | val; |
| 2065 | |
| 2066 | f71882fg_write8(data, F71882FG_REG_FAN_HYST(nr / 2), reg); |
| 2067 | data->pwm_auto_point_hyst[nr / 2] = reg; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2068 | mutex_unlock(&data->update_lock); |
| 2069 | |
| 2070 | return count; |
| 2071 | } |
| 2072 | |
| 2073 | static ssize_t show_pwm_interpolate(struct device *dev, |
| 2074 | struct device_attribute *devattr, char *buf) |
| 2075 | { |
| 2076 | int result; |
| 2077 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 2078 | int nr = to_sensor_dev_attr_2(devattr)->index; |
| 2079 | |
| 2080 | result = (data->pwm_auto_point_mapping[nr] >> 4) & 1; |
| 2081 | |
| 2082 | return sprintf(buf, "%d\n", result); |
| 2083 | } |
| 2084 | |
| 2085 | static ssize_t store_pwm_interpolate(struct device *dev, |
| 2086 | struct device_attribute *devattr, |
| 2087 | const char *buf, size_t count) |
| 2088 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2089 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2090 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 2091 | unsigned long val; |
| 2092 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 2093 | err = kstrtoul(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2094 | if (err) |
| 2095 | return err; |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2096 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2097 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2098 | data->pwm_auto_point_mapping[nr] = |
| 2099 | f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr)); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2100 | if (val) |
| 2101 | val = data->pwm_auto_point_mapping[nr] | (1 << 4); |
| 2102 | else |
| 2103 | val = data->pwm_auto_point_mapping[nr] & (~(1 << 4)); |
| 2104 | f71882fg_write8(data, F71882FG_REG_POINT_MAPPING(nr), val); |
| 2105 | data->pwm_auto_point_mapping[nr] = val; |
| 2106 | mutex_unlock(&data->update_lock); |
| 2107 | |
| 2108 | return count; |
| 2109 | } |
| 2110 | |
| 2111 | static ssize_t show_pwm_auto_point_channel(struct device *dev, |
| 2112 | struct device_attribute *devattr, |
| 2113 | char *buf) |
| 2114 | { |
| 2115 | int result; |
| 2116 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 2117 | int nr = to_sensor_dev_attr_2(devattr)->index; |
| 2118 | |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2119 | result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - |
| 2120 | data->temp_start); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2121 | |
| 2122 | return sprintf(buf, "%d\n", result); |
| 2123 | } |
| 2124 | |
| 2125 | static ssize_t store_pwm_auto_point_channel(struct device *dev, |
| 2126 | struct device_attribute *devattr, |
| 2127 | const char *buf, size_t count) |
| 2128 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2129 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2130 | int err, nr = to_sensor_dev_attr_2(devattr)->index; |
| 2131 | long val; |
| 2132 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 2133 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2134 | if (err) |
| 2135 | return err; |
Hans de Goede | 3045301 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2136 | |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2137 | switch (val) { |
| 2138 | case 1: |
Hans de Goede | 3045301 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2139 | val = 0; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2140 | break; |
| 2141 | case 2: |
Hans de Goede | 3045301 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2142 | val = 1; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2143 | break; |
| 2144 | case 4: |
Hans de Goede | 3045301 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2145 | val = 2; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2146 | break; |
| 2147 | default: |
| 2148 | return -EINVAL; |
| 2149 | } |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2150 | val += data->temp_start; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2151 | mutex_lock(&data->update_lock); |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2152 | data->pwm_auto_point_mapping[nr] = |
| 2153 | f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr)); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2154 | val = (data->pwm_auto_point_mapping[nr] & 0xfc) | val; |
| 2155 | f71882fg_write8(data, F71882FG_REG_POINT_MAPPING(nr), val); |
| 2156 | data->pwm_auto_point_mapping[nr] = val; |
| 2157 | mutex_unlock(&data->update_lock); |
| 2158 | |
| 2159 | return count; |
| 2160 | } |
| 2161 | |
| 2162 | static ssize_t show_pwm_auto_point_temp(struct device *dev, |
| 2163 | struct device_attribute *devattr, |
| 2164 | char *buf) |
| 2165 | { |
| 2166 | int result; |
| 2167 | struct f71882fg_data *data = f71882fg_update_device(dev); |
| 2168 | int pwm = to_sensor_dev_attr_2(devattr)->index; |
| 2169 | int point = to_sensor_dev_attr_2(devattr)->nr; |
| 2170 | |
| 2171 | result = data->pwm_auto_point_temp[pwm][point]; |
| 2172 | return sprintf(buf, "%d\n", 1000 * result); |
| 2173 | } |
| 2174 | |
| 2175 | static ssize_t store_pwm_auto_point_temp(struct device *dev, |
| 2176 | struct device_attribute *devattr, |
| 2177 | const char *buf, size_t count) |
| 2178 | { |
Hans de Goede | ce0bfa5 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2179 | struct f71882fg_data *data = dev_get_drvdata(dev); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2180 | int err, pwm = to_sensor_dev_attr_2(devattr)->index; |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2181 | int point = to_sensor_dev_attr_2(devattr)->nr; |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2182 | long val; |
| 2183 | |
Frans Meulenbroeks | 179c4fd | 2012-01-04 20:58:52 +0100 | [diff] [blame] | 2184 | err = kstrtol(buf, 10, &val); |
Giel van Schijndel | e8a4eac | 2010-05-27 19:58:41 +0200 | [diff] [blame] | 2185 | if (err) |
| 2186 | return err; |
| 2187 | |
| 2188 | val /= 1000; |
Hans de Goede | 7669896 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2189 | |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2190 | if (data->auto_point_temp_signed) |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 2191 | val = clamp_val(val, -128, 127); |
Hans de Goede | 7669896 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2192 | else |
Guenter Roeck | 2a844c1 | 2013-01-09 08:09:34 -0800 | [diff] [blame] | 2193 | val = clamp_val(val, 0, 127); |
Mark van Doesburg | 9ab796e | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2194 | |
| 2195 | mutex_lock(&data->update_lock); |
| 2196 | f71882fg_write8(data, F71882FG_REG_POINT_TEMP(pwm, point), val); |
| 2197 | data->pwm_auto_point_temp[pwm][point] = val; |
| 2198 | mutex_unlock(&data->update_lock); |
| 2199 | |
| 2200 | return count; |
| 2201 | } |
| 2202 | |
Julia Lawall | f2620e7 | 2016-12-22 13:04:39 +0100 | [diff] [blame] | 2203 | static ssize_t name_show(struct device *dev, struct device_attribute *devattr, |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2204 | char *buf) |
| 2205 | { |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2206 | struct f71882fg_data *data = dev_get_drvdata(dev); |
| 2207 | return sprintf(buf, "%s\n", f71882fg_names[data->type]); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2208 | } |
| 2209 | |
Bill Pemberton | 6c931ae | 2012-11-19 13:22:35 -0500 | [diff] [blame] | 2210 | static int f71882fg_create_sysfs_files(struct platform_device *pdev, |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2211 | struct sensor_device_attribute_2 *attr, int count) |
| 2212 | { |
| 2213 | int err, i; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2214 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2215 | for (i = 0; i < count; i++) { |
| 2216 | err = device_create_file(&pdev->dev, &attr[i].dev_attr); |
| 2217 | if (err) |
| 2218 | return err; |
| 2219 | } |
| 2220 | return 0; |
| 2221 | } |
| 2222 | |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2223 | static void f71882fg_remove_sysfs_files(struct platform_device *pdev, |
| 2224 | struct sensor_device_attribute_2 *attr, int count) |
| 2225 | { |
| 2226 | int i; |
| 2227 | |
| 2228 | for (i = 0; i < count; i++) |
| 2229 | device_remove_file(&pdev->dev, &attr[i].dev_attr); |
| 2230 | } |
| 2231 | |
Bill Pemberton | 6c931ae | 2012-11-19 13:22:35 -0500 | [diff] [blame] | 2232 | static int f71882fg_create_fan_sysfs_files( |
Hans de Goede | 6543439 | 2011-09-09 12:12:35 +0200 | [diff] [blame] | 2233 | struct platform_device *pdev, int idx) |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2234 | { |
| 2235 | struct f71882fg_data *data = platform_get_drvdata(pdev); |
| 2236 | int err; |
| 2237 | |
Hans de Goede | 6543439 | 2011-09-09 12:12:35 +0200 | [diff] [blame] | 2238 | /* Sanity check the pwm setting */ |
| 2239 | err = 0; |
| 2240 | switch (data->type) { |
| 2241 | case f71858fg: |
| 2242 | if (((data->pwm_enable >> (idx * 2)) & 3) == 3) |
| 2243 | err = 1; |
| 2244 | break; |
| 2245 | case f71862fg: |
| 2246 | if (((data->pwm_enable >> (idx * 2)) & 1) != 1) |
| 2247 | err = 1; |
| 2248 | break; |
| 2249 | case f8000: |
| 2250 | if (idx == 2) |
| 2251 | err = data->pwm_enable & 0x20; |
| 2252 | break; |
| 2253 | default: |
| 2254 | break; |
| 2255 | } |
| 2256 | if (err) { |
| 2257 | dev_err(&pdev->dev, |
| 2258 | "Invalid (reserved) pwm settings: 0x%02x, " |
| 2259 | "skipping fan %d\n", |
| 2260 | (data->pwm_enable >> (idx * 2)) & 3, idx + 1); |
| 2261 | return 0; /* This is a non fatal condition */ |
| 2262 | } |
| 2263 | |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2264 | err = f71882fg_create_sysfs_files(pdev, &fxxxx_fan_attr[idx][0], |
| 2265 | ARRAY_SIZE(fxxxx_fan_attr[0])); |
| 2266 | if (err) |
| 2267 | return err; |
| 2268 | |
| 2269 | if (f71882fg_fan_has_beep[data->type]) { |
| 2270 | err = f71882fg_create_sysfs_files(pdev, |
| 2271 | &fxxxx_fan_beep_attr[idx], |
| 2272 | 1); |
| 2273 | if (err) |
| 2274 | return err; |
| 2275 | } |
| 2276 | |
Hans de Goede | 6543439 | 2011-09-09 12:12:35 +0200 | [diff] [blame] | 2277 | dev_info(&pdev->dev, "Fan: %d is in %s mode\n", idx + 1, |
| 2278 | (data->pwm_enable & (1 << (2 * idx))) ? "duty-cycle" : "RPM"); |
| 2279 | |
| 2280 | /* Check for unsupported auto pwm settings */ |
| 2281 | switch (data->type) { |
| 2282 | case f71808e: |
| 2283 | case f71808a: |
| 2284 | case f71869: |
| 2285 | case f71869a: |
| 2286 | case f71889fg: |
| 2287 | case f71889ed: |
| 2288 | case f71889a: |
| 2289 | data->pwm_auto_point_mapping[idx] = |
| 2290 | f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(idx)); |
| 2291 | if ((data->pwm_auto_point_mapping[idx] & 0x80) || |
| 2292 | (data->pwm_auto_point_mapping[idx] & 3) == 0) { |
| 2293 | dev_warn(&pdev->dev, |
| 2294 | "Auto pwm controlled by raw digital " |
| 2295 | "data, disabling pwm auto_point " |
| 2296 | "sysfs attributes for fan %d\n", idx + 1); |
| 2297 | return 0; /* This is a non fatal condition */ |
| 2298 | } |
| 2299 | break; |
| 2300 | default: |
| 2301 | break; |
| 2302 | } |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2303 | |
| 2304 | switch (data->type) { |
| 2305 | case f71862fg: |
| 2306 | err = f71882fg_create_sysfs_files(pdev, |
| 2307 | &f71862fg_auto_pwm_attr[idx][0], |
| 2308 | ARRAY_SIZE(f71862fg_auto_pwm_attr[0])); |
| 2309 | break; |
| 2310 | case f71808e: |
| 2311 | case f71869: |
| 2312 | err = f71882fg_create_sysfs_files(pdev, |
| 2313 | &f71869_auto_pwm_attr[idx][0], |
| 2314 | ARRAY_SIZE(f71869_auto_pwm_attr[0])); |
| 2315 | break; |
| 2316 | case f8000: |
| 2317 | err = f71882fg_create_sysfs_files(pdev, |
| 2318 | &f8000_auto_pwm_attr[idx][0], |
| 2319 | ARRAY_SIZE(f8000_auto_pwm_attr[0])); |
| 2320 | break; |
| 2321 | default: |
| 2322 | err = f71882fg_create_sysfs_files(pdev, |
| 2323 | &fxxxx_auto_pwm_attr[idx][0], |
| 2324 | ARRAY_SIZE(fxxxx_auto_pwm_attr[0])); |
| 2325 | } |
| 2326 | |
| 2327 | return err; |
| 2328 | } |
| 2329 | |
Bill Pemberton | 6c931ae | 2012-11-19 13:22:35 -0500 | [diff] [blame] | 2330 | static int f71882fg_probe(struct platform_device *pdev) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2331 | { |
| 2332 | struct f71882fg_data *data; |
Jingoo Han | a8b3a3a | 2013-07-30 17:13:06 +0900 | [diff] [blame] | 2333 | struct f71882fg_sio_data *sio_data = dev_get_platdata(&pdev->dev); |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 2334 | int nr_fans = f71882fg_nr_fans[sio_data->type]; |
| 2335 | int nr_temps = f71882fg_nr_temps[sio_data->type]; |
| 2336 | int err, i; |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2337 | int size; |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2338 | u8 start_reg, reg; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2339 | |
Guenter Roeck | 33cd66e | 2012-06-02 09:58:05 -0700 | [diff] [blame] | 2340 | data = devm_kzalloc(&pdev->dev, sizeof(struct f71882fg_data), |
| 2341 | GFP_KERNEL); |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2342 | if (!data) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2343 | return -ENOMEM; |
| 2344 | |
| 2345 | data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2346 | data->type = sio_data->type; |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2347 | data->temp_start = |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2348 | (data->type == f71858fg || data->type == f8000 || |
| 2349 | data->type == f81866a) ? 0 : 1; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2350 | mutex_init(&data->update_lock); |
| 2351 | platform_set_drvdata(pdev, data); |
| 2352 | |
Hans de Goede | 3cc7475 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2353 | start_reg = f71882fg_read8(data, F71882FG_REG_START); |
Hans de Goede | 12d66e8 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 2354 | if (start_reg & 0x04) { |
| 2355 | dev_warn(&pdev->dev, "Hardware monitor is powered down\n"); |
Guenter Roeck | 33cd66e | 2012-06-02 09:58:05 -0700 | [diff] [blame] | 2356 | return -ENODEV; |
Hans de Goede | 12d66e8 | 2009-01-07 16:37:29 +0100 | [diff] [blame] | 2357 | } |
Hans de Goede | 3cc7475 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2358 | if (!(start_reg & 0x03)) { |
| 2359 | dev_warn(&pdev->dev, "Hardware monitoring not activated\n"); |
Guenter Roeck | 33cd66e | 2012-06-02 09:58:05 -0700 | [diff] [blame] | 2360 | return -ENODEV; |
Hans de Goede | 3cc7475 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2361 | } |
| 2362 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2363 | /* Register sysfs interface files */ |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2364 | err = device_create_file(&pdev->dev, &dev_attr_name); |
| 2365 | if (err) |
| 2366 | goto exit_unregister_sysfs; |
| 2367 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2368 | if (start_reg & 0x01) { |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2369 | switch (data->type) { |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2370 | case f71858fg: |
| 2371 | data->temp_config = |
| 2372 | f71882fg_read8(data, F71882FG_REG_TEMP_CONFIG); |
| 2373 | if (data->temp_config & 0x10) |
Guenter Roeck | 20eaf72 | 2012-01-19 11:02:17 -0800 | [diff] [blame] | 2374 | /* |
| 2375 | * The f71858fg temperature alarms behave as |
| 2376 | * the f8000 alarms in this mode |
| 2377 | */ |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2378 | err = f71882fg_create_sysfs_files(pdev, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2379 | f8000_temp_attr, |
| 2380 | ARRAY_SIZE(f8000_temp_attr)); |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2381 | else |
| 2382 | err = f71882fg_create_sysfs_files(pdev, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2383 | f71858fg_temp_attr, |
| 2384 | ARRAY_SIZE(f71858fg_temp_attr)); |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2385 | break; |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2386 | case f8000: |
| 2387 | err = f71882fg_create_sysfs_files(pdev, |
| 2388 | f8000_temp_attr, |
| 2389 | ARRAY_SIZE(f8000_temp_attr)); |
| 2390 | break; |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2391 | case f81866a: |
| 2392 | err = f71882fg_create_sysfs_files(pdev, |
| 2393 | f71858fg_temp_attr, |
| 2394 | ARRAY_SIZE(f71858fg_temp_attr)); |
| 2395 | break; |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2396 | default: |
| 2397 | err = f71882fg_create_sysfs_files(pdev, |
Hans de Goede | 60d2b37 | 2011-03-09 20:57:11 +0100 | [diff] [blame] | 2398 | &fxxxx_temp_attr[0][0], |
| 2399 | ARRAY_SIZE(fxxxx_temp_attr[0]) * nr_temps); |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2400 | } |
| 2401 | if (err) |
| 2402 | goto exit_unregister_sysfs; |
| 2403 | |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2404 | if (f71882fg_temp_has_beep[data->type]) { |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2405 | if (data->type == f81866a) { |
| 2406 | size = ARRAY_SIZE(f81866_temp_beep_attr[0]); |
| 2407 | err = f71882fg_create_sysfs_files(pdev, |
| 2408 | &f81866_temp_beep_attr[0][0], |
| 2409 | size * nr_temps); |
| 2410 | |
| 2411 | } else { |
| 2412 | size = ARRAY_SIZE(fxxxx_temp_beep_attr[0]); |
| 2413 | err = f71882fg_create_sysfs_files(pdev, |
| 2414 | &fxxxx_temp_beep_attr[0][0], |
| 2415 | size * nr_temps); |
| 2416 | } |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 2417 | if (err) |
| 2418 | goto exit_unregister_sysfs; |
| 2419 | } |
| 2420 | |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2421 | for (i = 0; i < F71882FG_MAX_INS; i++) { |
| 2422 | if (f71882fg_has_in[data->type][i]) { |
| 2423 | err = device_create_file(&pdev->dev, |
| 2424 | &fxxxx_in_attr[i].dev_attr); |
| 2425 | if (err) |
| 2426 | goto exit_unregister_sysfs; |
| 2427 | } |
| 2428 | } |
| 2429 | if (f71882fg_has_in1_alarm[data->type]) { |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2430 | err = f71882fg_create_sysfs_files(pdev, |
Hans de Goede | 66344aa | 2009-12-09 20:35:59 +0100 | [diff] [blame] | 2431 | fxxxx_in1_alarm_attr, |
| 2432 | ARRAY_SIZE(fxxxx_in1_alarm_attr)); |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2433 | if (err) |
| 2434 | goto exit_unregister_sysfs; |
| 2435 | } |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2436 | } |
| 2437 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2438 | if (start_reg & 0x02) { |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2439 | switch (data->type) { |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 2440 | case f71808e: |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2441 | case f71808a: |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 2442 | case f71869: |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 2443 | case f71869a: |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 2444 | /* These always have signed auto point temps */ |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 2445 | data->auto_point_temp_signed = 1; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 2446 | fallthrough; /* to select correct fan/pwm reg bank! */ |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2447 | case f71889fg: |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 2448 | case f71889ed: |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 2449 | case f71889a: |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2450 | reg = f71882fg_read8(data, F71882FG_REG_FAN_FAULT_T); |
| 2451 | if (reg & F71882FG_FAN_NEG_TEMP_EN) |
| 2452 | data->auto_point_temp_signed = 1; |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 2453 | /* Ensure banked pwm registers point to right bank */ |
| 2454 | reg &= ~F71882FG_FAN_PROG_SEL; |
| 2455 | f71882fg_write8(data, F71882FG_REG_FAN_FAULT_T, reg); |
Hans de Goede | 98f7ba1 | 2011-03-09 20:57:09 +0100 | [diff] [blame] | 2456 | break; |
| 2457 | default: |
| 2458 | break; |
| 2459 | } |
| 2460 | |
Hans de Goede | 996cadb | 2009-06-15 18:39:51 +0200 | [diff] [blame] | 2461 | data->pwm_enable = |
| 2462 | f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); |
| 2463 | |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2464 | for (i = 0; i < nr_fans; i++) { |
Hans de Goede | 6543439 | 2011-09-09 12:12:35 +0200 | [diff] [blame] | 2465 | err = f71882fg_create_fan_sysfs_files(pdev, i); |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2466 | if (err) |
| 2467 | goto exit_unregister_sysfs; |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2468 | } |
| 2469 | |
| 2470 | /* Some types have 1 extra fan with limited functionality */ |
Hans de Goede | e48a7f1 | 2011-03-09 20:57:13 +0100 | [diff] [blame] | 2471 | switch (data->type) { |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2472 | case f71808a: |
| 2473 | err = f71882fg_create_sysfs_files(pdev, |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2474 | f71808a_fan3_attr, |
| 2475 | ARRAY_SIZE(f71808a_fan3_attr)); |
| 2476 | break; |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2477 | case f8000: |
| 2478 | err = f71882fg_create_sysfs_files(pdev, |
| 2479 | f8000_fan_attr, |
| 2480 | ARRAY_SIZE(f8000_fan_attr)); |
| 2481 | break; |
Hans de Goede | e48a7f1 | 2011-03-09 20:57:13 +0100 | [diff] [blame] | 2482 | default: |
Hans de Goede | 9af0794 | 2011-09-09 12:12:34 +0200 | [diff] [blame] | 2483 | break; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2484 | } |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2485 | if (err) |
| 2486 | goto exit_unregister_sysfs; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2487 | } |
| 2488 | |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 2489 | data->hwmon_dev = hwmon_device_register(&pdev->dev); |
| 2490 | if (IS_ERR(data->hwmon_dev)) { |
| 2491 | err = PTR_ERR(data->hwmon_dev); |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2492 | data->hwmon_dev = NULL; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2493 | goto exit_unregister_sysfs; |
| 2494 | } |
| 2495 | |
| 2496 | return 0; |
| 2497 | |
| 2498 | exit_unregister_sysfs: |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2499 | f71882fg_remove(pdev); /* Will unregister the sysfs files for us */ |
Hans de Goede | 3cc7475 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2500 | return err; /* f71882fg_remove() also frees our data */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2501 | } |
| 2502 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2503 | static int f71882fg_remove(struct platform_device *pdev) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2504 | { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2505 | struct f71882fg_data *data = platform_get_drvdata(pdev); |
Jean Delvare | f27def0 | 2011-03-26 10:45:01 +0100 | [diff] [blame] | 2506 | int nr_fans = f71882fg_nr_fans[data->type]; |
| 2507 | int nr_temps = f71882fg_nr_temps[data->type]; |
| 2508 | int i; |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2509 | u8 start_reg = f71882fg_read8(data, F71882FG_REG_START); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2510 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2511 | if (data->hwmon_dev) |
| 2512 | hwmon_device_unregister(data->hwmon_dev); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2513 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2514 | device_remove_file(&pdev->dev, &dev_attr_name); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2515 | |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2516 | if (start_reg & 0x01) { |
| 2517 | switch (data->type) { |
| 2518 | case f71858fg: |
| 2519 | if (data->temp_config & 0x10) |
| 2520 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2521 | f8000_temp_attr, |
| 2522 | ARRAY_SIZE(f8000_temp_attr)); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2523 | else |
| 2524 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2525 | f71858fg_temp_attr, |
| 2526 | ARRAY_SIZE(f71858fg_temp_attr)); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2527 | break; |
| 2528 | case f8000: |
| 2529 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2530 | f8000_temp_attr, |
| 2531 | ARRAY_SIZE(f8000_temp_attr)); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2532 | break; |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2533 | case f81866a: |
| 2534 | f71882fg_remove_sysfs_files(pdev, |
| 2535 | f71858fg_temp_attr, |
| 2536 | ARRAY_SIZE(f71858fg_temp_attr)); |
| 2537 | break; |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2538 | default: |
| 2539 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 60d2b37 | 2011-03-09 20:57:11 +0100 | [diff] [blame] | 2540 | &fxxxx_temp_attr[0][0], |
| 2541 | ARRAY_SIZE(fxxxx_temp_attr[0]) * nr_temps); |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2542 | } |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2543 | if (f71882fg_temp_has_beep[data->type]) { |
Peter Hung | dcd956f | 2015-07-07 16:22:37 +0800 | [diff] [blame] | 2544 | if (data->type == f81866a) |
| 2545 | f71882fg_remove_sysfs_files(pdev, |
| 2546 | &f81866_temp_beep_attr[0][0], |
| 2547 | ARRAY_SIZE(f81866_temp_beep_attr[0]) |
| 2548 | * nr_temps); |
| 2549 | else |
| 2550 | f71882fg_remove_sysfs_files(pdev, |
| 2551 | &fxxxx_temp_beep_attr[0][0], |
| 2552 | ARRAY_SIZE(fxxxx_temp_beep_attr[0]) |
| 2553 | * nr_temps); |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 2554 | } |
| 2555 | |
Hans de Goede | 0bae640 | 2011-03-09 20:57:10 +0100 | [diff] [blame] | 2556 | for (i = 0; i < F71882FG_MAX_INS; i++) { |
| 2557 | if (f71882fg_has_in[data->type][i]) { |
| 2558 | device_remove_file(&pdev->dev, |
| 2559 | &fxxxx_in_attr[i].dev_attr); |
| 2560 | } |
| 2561 | } |
| 2562 | if (f71882fg_has_in1_alarm[data->type]) { |
| 2563 | f71882fg_remove_sysfs_files(pdev, |
| 2564 | fxxxx_in1_alarm_attr, |
| 2565 | ARRAY_SIZE(fxxxx_in1_alarm_attr)); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2566 | } |
| 2567 | } |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2568 | |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2569 | if (start_reg & 0x02) { |
| 2570 | f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0], |
| 2571 | ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2572 | |
Hans de Goede | 4d53811 | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2573 | if (f71882fg_fan_has_beep[data->type]) { |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2574 | f71882fg_remove_sysfs_files(pdev, |
| 2575 | fxxxx_fan_beep_attr, nr_fans); |
Hans de Goede | 78aa4f7 | 2011-03-09 20:57:12 +0100 | [diff] [blame] | 2576 | } |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2577 | |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2578 | switch (data->type) { |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2579 | case f71808a: |
| 2580 | f71882fg_remove_sysfs_files(pdev, |
| 2581 | &fxxxx_auto_pwm_attr[0][0], |
| 2582 | ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); |
| 2583 | f71882fg_remove_sysfs_files(pdev, |
| 2584 | f71808a_fan3_attr, |
| 2585 | ARRAY_SIZE(f71808a_fan3_attr)); |
| 2586 | break; |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2587 | case f71862fg: |
| 2588 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 2589 | &f71862fg_auto_pwm_attr[0][0], |
| 2590 | ARRAY_SIZE(f71862fg_auto_pwm_attr[0]) * |
| 2591 | nr_fans); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2592 | break; |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 2593 | case f71808e: |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 2594 | case f71869: |
| 2595 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 2596 | &f71869_auto_pwm_attr[0][0], |
| 2597 | ARRAY_SIZE(f71869_auto_pwm_attr[0]) * nr_fans); |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 2598 | break; |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2599 | case f8000: |
| 2600 | f71882fg_remove_sysfs_files(pdev, |
| 2601 | f8000_fan_attr, |
| 2602 | ARRAY_SIZE(f8000_fan_attr)); |
| 2603 | f71882fg_remove_sysfs_files(pdev, |
Hans de Goede | 5584014 | 2011-09-09 12:12:33 +0200 | [diff] [blame] | 2604 | &f8000_auto_pwm_attr[0][0], |
| 2605 | ARRAY_SIZE(f8000_auto_pwm_attr[0]) * nr_fans); |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2606 | break; |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 2607 | default: |
Hans de Goede | fc16c56 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2608 | f71882fg_remove_sysfs_files(pdev, |
| 2609 | &fxxxx_auto_pwm_attr[0][0], |
| 2610 | ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); |
| 2611 | } |
| 2612 | } |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2613 | return 0; |
| 2614 | } |
| 2615 | |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2616 | static int __init f71882fg_find(int sioaddr, struct f71882fg_sio_data *sio_data) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2617 | { |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2618 | u16 devid; |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2619 | unsigned short address; |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 2620 | int err = superio_enter(sioaddr); |
| 2621 | if (err) |
| 2622 | return err; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2623 | |
| 2624 | devid = superio_inw(sioaddr, SIO_REG_MANID); |
| 2625 | if (devid != SIO_FINTEK_ID) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2626 | pr_debug("Not a Fintek device\n"); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 2627 | err = -ENODEV; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2628 | goto exit; |
| 2629 | } |
| 2630 | |
Jean Delvare | 67b671b | 2007-12-06 23:13:42 +0100 | [diff] [blame] | 2631 | devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2632 | switch (devid) { |
Hans de Goede | e5e713c | 2011-03-10 08:54:02 +0100 | [diff] [blame] | 2633 | case SIO_F71808E_ID: |
| 2634 | sio_data->type = f71808e; |
| 2635 | break; |
Hans de Goede | 629c58b | 2011-05-25 20:43:32 +0200 | [diff] [blame] | 2636 | case SIO_F71808A_ID: |
| 2637 | sio_data->type = f71808a; |
| 2638 | break; |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2639 | case SIO_F71858_ID: |
| 2640 | sio_data->type = f71858fg; |
| 2641 | break; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2642 | case SIO_F71862_ID: |
| 2643 | sio_data->type = f71862fg; |
| 2644 | break; |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 2645 | case SIO_F71868_ID: |
| 2646 | sio_data->type = f71868a; |
| 2647 | break; |
Hans de Goede | c11bb99 | 2011-03-09 20:57:15 +0100 | [diff] [blame] | 2648 | case SIO_F71869_ID: |
| 2649 | sio_data->type = f71869; |
| 2650 | break; |
Hans de Goede | 5da556e | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 2651 | case SIO_F71869A_ID: |
| 2652 | sio_data->type = f71869a; |
| 2653 | break; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2654 | case SIO_F71882_ID: |
| 2655 | sio_data->type = f71882fg; |
| 2656 | break; |
Hans de Goede | 7669896 | 2009-12-09 20:36:01 +0100 | [diff] [blame] | 2657 | case SIO_F71889_ID: |
| 2658 | sio_data->type = f71889fg; |
| 2659 | break; |
Hans de Goede | 3cad402 | 2011-03-09 20:57:14 +0100 | [diff] [blame] | 2660 | case SIO_F71889E_ID: |
| 2661 | sio_data->type = f71889ed; |
| 2662 | break; |
Hans de Goede | a66c108 | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 2663 | case SIO_F71889A_ID: |
| 2664 | sio_data->type = f71889a; |
| 2665 | break; |
Hans de Goede | ed4f7c2 | 2009-01-07 16:37:30 +0100 | [diff] [blame] | 2666 | case SIO_F8000_ID: |
| 2667 | sio_data->type = f8000; |
| 2668 | break; |
George Joseph | d8363bb | 2015-07-07 19:16:53 -0600 | [diff] [blame] | 2669 | case SIO_F81768D_ID: |
| 2670 | sio_data->type = f81768d; |
| 2671 | break; |
Jean Delvare | 383586b | 2011-03-26 10:45:02 +0100 | [diff] [blame] | 2672 | case SIO_F81865_ID: |
| 2673 | sio_data->type = f81865f; |
| 2674 | break; |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 2675 | case SIO_F81866_ID: |
Menghui Wu | df29307 | 2021-11-17 10:43:20 +0800 | [diff] [blame] | 2676 | case SIO_F81966_ID: |
Peter Hung | 2725fe2 | 2015-07-07 16:22:36 +0800 | [diff] [blame] | 2677 | sio_data->type = f81866a; |
| 2678 | break; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2679 | default: |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2680 | pr_info("Unsupported Fintek device: %04x\n", |
| 2681 | (unsigned int)devid); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 2682 | err = -ENODEV; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2683 | goto exit; |
| 2684 | } |
| 2685 | |
Hans de Goede | 09475d3 | 2009-06-15 18:39:52 +0200 | [diff] [blame] | 2686 | if (sio_data->type == f71858fg) |
| 2687 | superio_select(sioaddr, SIO_F71858FG_LD_HWM); |
| 2688 | else |
| 2689 | superio_select(sioaddr, SIO_F71882FG_LD_HWM); |
| 2690 | |
Mark M. Hoffman | 8afb104 | 2007-08-21 23:10:46 -0400 | [diff] [blame] | 2691 | if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2692 | pr_warn("Device not activated\n"); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 2693 | err = -ENODEV; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2694 | goto exit; |
| 2695 | } |
| 2696 | |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2697 | address = superio_inw(sioaddr, SIO_REG_ADDR); |
| 2698 | if (address == 0) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2699 | pr_warn("Base address not set\n"); |
Giel van Schijndel | cadb865 | 2010-10-03 08:09:49 -0400 | [diff] [blame] | 2700 | err = -ENODEV; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2701 | goto exit; |
| 2702 | } |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2703 | address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2704 | |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2705 | err = address; |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2706 | pr_info("Found %s chip at %#x, revision %d\n", |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2707 | f71882fg_names[sio_data->type], (unsigned int)address, |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2708 | (int)superio_inb(sioaddr, SIO_REG_DEVREV)); |
| 2709 | exit: |
| 2710 | superio_exit(sioaddr); |
| 2711 | return err; |
| 2712 | } |
| 2713 | |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2714 | static int __init f71882fg_device_add(int address, |
| 2715 | const struct f71882fg_sio_data *sio_data) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2716 | { |
| 2717 | struct resource res = { |
| 2718 | .start = address, |
| 2719 | .end = address + REGION_LENGTH - 1, |
| 2720 | .flags = IORESOURCE_IO, |
| 2721 | }; |
| 2722 | int err; |
| 2723 | |
| 2724 | f71882fg_pdev = platform_device_alloc(DRVNAME, address); |
Mark M. Hoffman | 8afb104 | 2007-08-21 23:10:46 -0400 | [diff] [blame] | 2725 | if (!f71882fg_pdev) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2726 | return -ENOMEM; |
| 2727 | |
| 2728 | res.name = f71882fg_pdev->name; |
Jean Delvare | b9acb64 | 2009-01-07 16:37:35 +0100 | [diff] [blame] | 2729 | err = acpi_check_resource_conflict(&res); |
| 2730 | if (err) |
Hans de Goede | 18632f8 | 2009-02-17 19:59:54 +0100 | [diff] [blame] | 2731 | goto exit_device_put; |
Jean Delvare | b9acb64 | 2009-01-07 16:37:35 +0100 | [diff] [blame] | 2732 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2733 | err = platform_device_add_resources(f71882fg_pdev, &res, 1); |
Mark M. Hoffman | 8afb104 | 2007-08-21 23:10:46 -0400 | [diff] [blame] | 2734 | if (err) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2735 | pr_err("Device resource addition failed\n"); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2736 | goto exit_device_put; |
| 2737 | } |
| 2738 | |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2739 | err = platform_device_add_data(f71882fg_pdev, sio_data, |
| 2740 | sizeof(struct f71882fg_sio_data)); |
| 2741 | if (err) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2742 | pr_err("Platform data allocation failed\n"); |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2743 | goto exit_device_put; |
| 2744 | } |
| 2745 | |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2746 | err = platform_device_add(f71882fg_pdev); |
Mark M. Hoffman | 8afb104 | 2007-08-21 23:10:46 -0400 | [diff] [blame] | 2747 | if (err) { |
Joe Perches | 22d3b41 | 2010-10-20 06:51:34 +0000 | [diff] [blame] | 2748 | pr_err("Device addition failed\n"); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2749 | goto exit_device_put; |
| 2750 | } |
| 2751 | |
| 2752 | return 0; |
| 2753 | |
| 2754 | exit_device_put: |
| 2755 | platform_device_put(f71882fg_pdev); |
| 2756 | |
| 2757 | return err; |
| 2758 | } |
| 2759 | |
| 2760 | static int __init f71882fg_init(void) |
| 2761 | { |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2762 | int err; |
| 2763 | int address; |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2764 | struct f71882fg_sio_data sio_data; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2765 | |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2766 | memset(&sio_data, 0, sizeof(sio_data)); |
| 2767 | |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2768 | address = f71882fg_find(0x2e, &sio_data); |
| 2769 | if (address < 0) |
| 2770 | address = f71882fg_find(0x4e, &sio_data); |
| 2771 | if (address < 0) |
| 2772 | return address; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2773 | |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2774 | err = platform_driver_register(&f71882fg_driver); |
| 2775 | if (err) |
Guenter Roeck | 0038389 | 2012-08-04 09:46:36 -0700 | [diff] [blame] | 2776 | return err; |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2777 | |
Hans de Goede | 498be96 | 2009-01-07 16:37:28 +0100 | [diff] [blame] | 2778 | err = f71882fg_device_add(address, &sio_data); |
Hans de Goede | c13548c | 2009-01-07 16:37:27 +0100 | [diff] [blame] | 2779 | if (err) |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2780 | goto exit_driver; |
| 2781 | |
| 2782 | return 0; |
| 2783 | |
| 2784 | exit_driver: |
| 2785 | platform_driver_unregister(&f71882fg_driver); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2786 | return err; |
| 2787 | } |
| 2788 | |
| 2789 | static void __exit f71882fg_exit(void) |
| 2790 | { |
| 2791 | platform_device_unregister(f71882fg_pdev); |
| 2792 | platform_driver_unregister(&f71882fg_driver); |
| 2793 | } |
| 2794 | |
| 2795 | MODULE_DESCRIPTION("F71882FG Hardware Monitoring Driver"); |
Hans de Goede | 7958e3b | 2011-07-03 13:32:53 +0200 | [diff] [blame] | 2796 | MODULE_AUTHOR("Hans Edgington, Hans de Goede <hdegoede@redhat.com>"); |
Hans de Goede | 45fb366 | 2007-07-13 14:34:19 +0200 | [diff] [blame] | 2797 | MODULE_LICENSE("GPL"); |
| 2798 | |
| 2799 | module_init(f71882fg_init); |
| 2800 | module_exit(f71882fg_exit); |