xref: /dragonfly/sys/dev/powermng/uguru/uguru.c (revision 5d302545)
1b7609e3dSSascha Wildner /*	$OpenBSD: uguru.c,v 1.4 2010/06/03 17:48:24 deraadt Exp $	*/
2b7609e3dSSascha Wildner 
3b7609e3dSSascha Wildner /*
4b7609e3dSSascha Wildner  * Copyright (c) 2010 Mikko Tolmunen <oskari@sefirosu.org>
5b7609e3dSSascha Wildner  *
6b7609e3dSSascha Wildner  * Permission to use, copy, modify, and distribute this software for any
7b7609e3dSSascha Wildner  * purpose with or without fee is hereby granted, provided that the above
8b7609e3dSSascha Wildner  * copyright notice and this permission notice appear in all copies.
9b7609e3dSSascha Wildner  *
10b7609e3dSSascha Wildner  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11b7609e3dSSascha Wildner  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12b7609e3dSSascha Wildner  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13b7609e3dSSascha Wildner  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14b7609e3dSSascha Wildner  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15b7609e3dSSascha Wildner  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16b7609e3dSSascha Wildner  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17b7609e3dSSascha Wildner  */
18b7609e3dSSascha Wildner 
19b7609e3dSSascha Wildner #include <sys/param.h>
20b7609e3dSSascha Wildner #include <sys/bus.h>
21b7609e3dSSascha Wildner #include <sys/device.h>
22b7609e3dSSascha Wildner #include <sys/rman.h>
23b7609e3dSSascha Wildner #include <sys/sensors.h>
24b7609e3dSSascha Wildner #include <sys/systm.h>
25b7609e3dSSascha Wildner 
26b7609e3dSSascha Wildner #include <bus/isa/isareg.h>
27b7609e3dSSascha Wildner #include <bus/isa/isavar.h>
28b7609e3dSSascha Wildner 
29b7609e3dSSascha Wildner #ifdef UGURU_DEBUG
30b7609e3dSSascha Wildner int	uguru_dbg = 0;
31b7609e3dSSascha Wildner #define DPRINTF(lvl, fmt...)	\
32b7609e3dSSascha Wildner 	if (uguru_dbg >= lvl)	\
33b7609e3dSSascha Wildner 		kprintf(fmt);
34b7609e3dSSascha Wildner #else
35b7609e3dSSascha Wildner #define DPRINTF(lvl, fmt...)
36b7609e3dSSascha Wildner #endif
37b7609e3dSSascha Wildner 
38b7609e3dSSascha Wildner #define UGURU_READ(iot, ioh, reg)	\
39b7609e3dSSascha Wildner     bus_space_read_1((iot), (ioh), (reg))
40b7609e3dSSascha Wildner #define UGURU_WRITE(iot, ioh, reg, val) \
41b7609e3dSSascha Wildner     bus_space_write_1((iot), (ioh), (reg), (val))
42b7609e3dSSascha Wildner 
43b7609e3dSSascha Wildner #define UGURU_DATA		0x00	/* configuration data register */
44b7609e3dSSascha Wildner #define UGURU_INDEX		0x04	/* configuration index register */
45b7609e3dSSascha Wildner #define UGURU_IOSIZE		0x08
46b7609e3dSSascha Wildner 
47b7609e3dSSascha Wildner #define UGURU_DUMMY		0x00	/* dummy zero bit */
48b7609e3dSSascha Wildner #define UGURU_ITM_DATA		0x21	/* temp/volt readings */
49b7609e3dSSascha Wildner #define UGURU_ITM_CTRL		0x22	/* temp/volt settings */
50b7609e3dSSascha Wildner #define UGURU_FAN_DATA		0x26	/* fan readings */
51b7609e3dSSascha Wildner #define UGURU_FAN_CTRL		0x27	/* fan settings */
52b7609e3dSSascha Wildner #define UGURU_PRODID		0x44	/* product ID */
53b7609e3dSSascha Wildner 
54b7609e3dSSascha Wildner #define UGURU_VENDID_ABIT	0x147b	/* ABIT */
55b7609e3dSSascha Wildner #define UGURU_DEVID1		0x2003	/* AC2003 */
56b7609e3dSSascha Wildner #define UGURU_DEVID2		0x2005	/* AC2005 */
57b7609e3dSSascha Wildner 
58b7609e3dSSascha Wildner #define ABIT_SYSID_KV01		0x0301
59b7609e3dSSascha Wildner #define ABIT_SYSID_AI01		0x0302
60b7609e3dSSascha Wildner #define ABIT_SYSID_AN01		0x0303
61b7609e3dSSascha Wildner #define ABIT_SYSID_AA01		0x0304
62b7609e3dSSascha Wildner #define ABIT_SYSID_AG01		0x0305
63b7609e3dSSascha Wildner #define ABIT_SYSID_AV01		0x0306
64b7609e3dSSascha Wildner #define ABIT_SYSID_KVP1		0x0307
65b7609e3dSSascha Wildner #define ABIT_SYSID_AS01		0x0308
66b7609e3dSSascha Wildner #define ABIT_SYSID_AX01		0x0309
67b7609e3dSSascha Wildner #define ABIT_SYSID_M401		0x030a
68b7609e3dSSascha Wildner #define ABIT_SYSID_AN02		0x030b
69b7609e3dSSascha Wildner #define ABIT_SYSID_AU01		0x050c
70b7609e3dSSascha Wildner #define ABIT_SYSID_AW01		0x050d
71b7609e3dSSascha Wildner #define ABIT_SYSID_AL01		0x050e
72b7609e3dSSascha Wildner #define ABIT_SYSID_BL01		0x050f
73b7609e3dSSascha Wildner #define ABIT_SYSID_NI01		0x0510
74b7609e3dSSascha Wildner #define ABIT_SYSID_AT01		0x0511
75b7609e3dSSascha Wildner #define ABIT_SYSID_AN03		0x0512
76b7609e3dSSascha Wildner #define ABIT_SYSID_AW02		0x0513
77b7609e3dSSascha Wildner #define ABIT_SYSID_AB01		0x0514
78b7609e3dSSascha Wildner #define ABIT_SYSID_AN04		0x0515
79b7609e3dSSascha Wildner #define ABIT_SYSID_AW03		0x0516
80b7609e3dSSascha Wildner #define ABIT_SYSID_AT02		0x0517
81b7609e3dSSascha Wildner #define ABIT_SYSID_AB02		0x0518
82b7609e3dSSascha Wildner #define ABIT_SYSID_IN01		0x0519
83b7609e3dSSascha Wildner #define ABIT_SYSID_IP01		0x051a
84b7609e3dSSascha Wildner #define ABIT_SYSID_IX01		0x051b
85b7609e3dSSascha Wildner #define ABIT_SYSID_IX02		0x051c
86b7609e3dSSascha Wildner 
87b7609e3dSSascha Wildner #define UGURU_INTERVAL		5
88b7609e3dSSascha Wildner #define UGURU_MAX_SENSORS	27
89b7609e3dSSascha Wildner 
90b7609e3dSSascha Wildner #define RFACT_NONE		13700
91b7609e3dSSascha Wildner #define RFACT_NONE2		10000
92b7609e3dSSascha Wildner #define RFACT(x, y)		(RFACT_NONE * ((x) + (y)) / (y))
93b7609e3dSSascha Wildner #define RFACT2(x, y)		(RFACT_NONE2 * ((x) + (y)) / (y))
94b7609e3dSSascha Wildner 
95b7609e3dSSascha Wildner struct uguru_softc {
96*5d302545SFrançois Tigeot 	device_t		 sc_dev;
97b7609e3dSSascha Wildner 
98b7609e3dSSascha Wildner 	struct resource		*sc_iores;
99b7609e3dSSascha Wildner 	int			 sc_iorid;
100b7609e3dSSascha Wildner 
101b7609e3dSSascha Wildner 	bus_space_tag_t		 sc_iot;
102b7609e3dSSascha Wildner 	bus_space_handle_t	 sc_ioh;
103b7609e3dSSascha Wildner 
104b7609e3dSSascha Wildner 	struct ksensor		 sc_sensors[UGURU_MAX_SENSORS];
105b7609e3dSSascha Wildner 	struct ksensordev	 sc_sensordev;
106b7609e3dSSascha Wildner 	int			 sc_numsensors;
107b7609e3dSSascha Wildner 	struct uguru_sensor	*uguru_sensors;
108b7609e3dSSascha Wildner 	struct {
109b7609e3dSSascha Wildner 		uint8_t		 reading;
110b7609e3dSSascha Wildner /*		uint8_t		 flags; */
111b7609e3dSSascha Wildner 		uint8_t		 lower;
112b7609e3dSSascha Wildner 		uint8_t		 upper;
113b7609e3dSSascha Wildner 	} cs;
114b7609e3dSSascha Wildner 	int			(*read)(struct uguru_softc *, int);
115b7609e3dSSascha Wildner };
116b7609e3dSSascha Wildner 
117b7609e3dSSascha Wildner struct uguru_sensor {
118b7609e3dSSascha Wildner 	char			*desc;
119b7609e3dSSascha Wildner 	enum sensor_type	 type;
120b7609e3dSSascha Wildner 	void			(*refresh)(struct uguru_softc *, int);
121b7609e3dSSascha Wildner 	uint8_t			 reg;
122b7609e3dSSascha Wildner 	int			 rfact;
123b7609e3dSSascha Wildner };
124b7609e3dSSascha Wildner 
125b7609e3dSSascha Wildner static void	 uguru_refresh_temp(struct uguru_softc *, int);
126b7609e3dSSascha Wildner static void	 uguru_refresh_volt(struct uguru_softc *, int);
127b7609e3dSSascha Wildner static void	 uguru_refresh_fan(struct uguru_softc *, int);
128b7609e3dSSascha Wildner 
129b7609e3dSSascha Wildner #define UGURU_R_TEMP	uguru_refresh_temp
130b7609e3dSSascha Wildner #define UGURU_R_VOLT	uguru_refresh_volt
131b7609e3dSSascha Wildner #define UGURU_R_FAN	uguru_refresh_fan
132b7609e3dSSascha Wildner 
133b7609e3dSSascha Wildner struct uguru_sensor abitkv_sensors[] = {
134b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
135b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
136b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
137b7609e3dSSascha Wildner 
138b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
139b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
140b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
141b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT(2800, 887) },
142b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
143b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
144b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
145b7609e3dSSascha Wildner 
146b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
147b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
148b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
149b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
150b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
151b7609e3dSSascha Wildner 
152b7609e3dSSascha Wildner 	{ NULL }
153b7609e3dSSascha Wildner };
154b7609e3dSSascha Wildner 
155b7609e3dSSascha Wildner struct uguru_sensor abitaa_sensors[] = {
156b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
157b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
158b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
159b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x0c },
160b7609e3dSSascha Wildner 
161b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
162b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
163b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
164b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT(2800, 888) },
165b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
166b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
167b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
168b7609e3dSSascha Wildner 	{ "FSBVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE },
169b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE },
170b7609e3dSSascha Wildner 	{ "NB +2.5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT_NONE },
171b7609e3dSSascha Wildner 
172b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
173b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
174b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
175b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
176b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
177b7609e3dSSascha Wildner 
178b7609e3dSSascha Wildner 	{ NULL }
179b7609e3dSSascha Wildner };
180b7609e3dSSascha Wildner 
181b7609e3dSSascha Wildner struct uguru_sensor abitav_sensors[] = {
182b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
183b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
184b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
185b7609e3dSSascha Wildner 
186b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
187b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
188b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
189b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
190b7609e3dSSascha Wildner 	{ "+3.3VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT(100, 402) },
191b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
192b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
193b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT_NONE },
194b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE },
195b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE },
196b7609e3dSSascha Wildner 	{ "AGP", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT_NONE },
197b7609e3dSSascha Wildner 
198b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
199b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
200b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
201b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
202b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
203b7609e3dSSascha Wildner 
204b7609e3dSSascha Wildner 	{ NULL }
205b7609e3dSSascha Wildner };
206b7609e3dSSascha Wildner 
207b7609e3dSSascha Wildner struct uguru_sensor abitas_sensors[] = {
208b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
209b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
210b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
211b7609e3dSSascha Wildner 
212b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
213b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
214b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
215b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT(2800, 884) },
216b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
217b7609e3dSSascha Wildner 	{ "+3.3VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT(100, 402) },
218b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
219b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
220b7609e3dSSascha Wildner 	{ "FSBVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE },
221b7609e3dSSascha Wildner 	{ "NB/AGP", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE },
222b7609e3dSSascha Wildner 	{ "GMCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT_NONE },
223b7609e3dSSascha Wildner 
224b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
225b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
226b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
227b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
228b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
229b7609e3dSSascha Wildner 
230b7609e3dSSascha Wildner 	{ NULL }
231b7609e3dSSascha Wildner };
232b7609e3dSSascha Wildner 
233b7609e3dSSascha Wildner struct uguru_sensor abitax_sensors[] = {
234b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
235b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
236b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
237b7609e3dSSascha Wildner 
238b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
239b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
240b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
241b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT(2800, 888) },
242b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
243b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
244b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
245b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT_NONE },
246b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE },
247b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE },
248b7609e3dSSascha Wildner 
249b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
250b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
251b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
252b7609e3dSSascha Wildner 	{ "AUX", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
253b7609e3dSSascha Wildner 
254b7609e3dSSascha Wildner 	{ NULL }
255b7609e3dSSascha Wildner };
256b7609e3dSSascha Wildner 
257b7609e3dSSascha Wildner struct uguru_sensor abitm4_sensors[] = {
258b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
259b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
260b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x02 },
261b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x03 },
262b7609e3dSSascha Wildner 	{ "PWM3", SENSOR_TEMP, UGURU_R_TEMP, 0x04 },
263b7609e3dSSascha Wildner 	{ "PWM4", SENSOR_TEMP, UGURU_R_TEMP, 0x05 },
264b7609e3dSSascha Wildner 
265b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT_NONE },
266b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x13, RFACT(100, 402) },
267b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x12, RFACT(442, 560) },
268b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x11, RFACT(2800, 884) },
269b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x10, RFACT(442, 560) },
270b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT_NONE },
271b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
272b7609e3dSSascha Wildner 	{ "FSBVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT_NONE },
273b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT_NONE },
274b7609e3dSSascha Wildner 	{ "NB +2.5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0c, RFACT_NONE },
275b7609e3dSSascha Wildner 
276b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
277b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
278b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
279b7609e3dSSascha Wildner 	{ "OTES1", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
280b7609e3dSSascha Wildner 	{ "OTES2", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
281b7609e3dSSascha Wildner 
282b7609e3dSSascha Wildner 	{ NULL }
283b7609e3dSSascha Wildner };
284b7609e3dSSascha Wildner 
285b7609e3dSSascha Wildner struct uguru_sensor abitan_sensors[] = {
286b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x00 },
287b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x01 },
288b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x0f },
289b7609e3dSSascha Wildner 
290b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE },
291b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT(100, 402) },
292b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT(442, 560) },
293b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT(2800, 844) },
294b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT(442, 560) },
295b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE },
296b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT_NONE },
297b7609e3dSSascha Wildner 	{ "CPUVDDA", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE },
298b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE },
299b7609e3dSSascha Wildner 	{ "MCP", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT_NONE },
300b7609e3dSSascha Wildner 	{ "MCP SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT_NONE },
301b7609e3dSSascha Wildner 
302b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x00 },
303b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x01 },
304b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x02 },
305b7609e3dSSascha Wildner 	{ "AUX", SENSOR_FANRPM, UGURU_R_FAN, 0x05 },
306b7609e3dSSascha Wildner 	{ "OTES1", SENSOR_FANRPM, UGURU_R_FAN, 0x04 },
307b7609e3dSSascha Wildner 	{ "OTES2", SENSOR_FANRPM, UGURU_R_FAN, 0x03 },
308b7609e3dSSascha Wildner 
309b7609e3dSSascha Wildner 	{ NULL }
310b7609e3dSSascha Wildner };
311b7609e3dSSascha Wildner 
312b7609e3dSSascha Wildner struct uguru_sensor abital_sensors[] = {
313b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
314b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
315b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
316b7609e3dSSascha Wildner 
317b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
318b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
319b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
320b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
321b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
322b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
323b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT_NONE2 },
324b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
325b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
326b7609e3dSSascha Wildner 	{ "MCH/PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
327b7609e3dSSascha Wildner 	{ "MCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT2(34, 34) },
328b7609e3dSSascha Wildner 	{ "ICH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
329b7609e3dSSascha Wildner 
330b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
331b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
332b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
333b7609e3dSSascha Wildner 	{ "AUX", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
334b7609e3dSSascha Wildner 
335b7609e3dSSascha Wildner 	{ NULL }
336b7609e3dSSascha Wildner };
337b7609e3dSSascha Wildner 
338b7609e3dSSascha Wildner struct uguru_sensor abitaw_sensors[] = {
339b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
340b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
341b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
342b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
343b7609e3dSSascha Wildner 	{ "PWM3", SENSOR_TEMP, UGURU_R_TEMP, 0x1c },
344b7609e3dSSascha Wildner 	{ "PWM4", SENSOR_TEMP, UGURU_R_TEMP, 0x1d },
345b7609e3dSSascha Wildner 
346b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
347b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
348b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
349b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
350b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
351b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
352b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT_NONE2 },
353b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
354b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
355b7609e3dSSascha Wildner 	{ "MCH/PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
356b7609e3dSSascha Wildner 	{ "MCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT2(34, 34) },
357b7609e3dSSascha Wildner 	{ "ICH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
358b7609e3dSSascha Wildner 
359b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
360b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
361b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
362b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
363b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
364b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
365b7609e3dSSascha Wildner 	{ "AUX4", SENSOR_FANRPM, UGURU_R_FAN, 0x26 },
366b7609e3dSSascha Wildner 	{ "AUX5", SENSOR_FANRPM, UGURU_R_FAN, 0x27 },
367b7609e3dSSascha Wildner 
368b7609e3dSSascha Wildner 	{ NULL }
369b7609e3dSSascha Wildner };
370b7609e3dSSascha Wildner 
371b7609e3dSSascha Wildner struct uguru_sensor abitni_sensors[] = {
372b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
373b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
374b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
375b7609e3dSSascha Wildner 
376b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
377b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
378b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
379b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
380b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
381b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
382b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT_NONE2 },
383b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
384b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
385b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
386b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
387b7609e3dSSascha Wildner 
388b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
389b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
390b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
391b7609e3dSSascha Wildner 	{ "AUX", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
392b7609e3dSSascha Wildner 	{ "OTES1", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
393b7609e3dSSascha Wildner 	{ "OTES2", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
394b7609e3dSSascha Wildner 
395b7609e3dSSascha Wildner 	{ NULL }
396b7609e3dSSascha Wildner };
397b7609e3dSSascha Wildner 
398b7609e3dSSascha Wildner struct uguru_sensor abitat_sensors[] = {
399b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
400b7609e3dSSascha Wildner 	{ "NB", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
401b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
402b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
403b7609e3dSSascha Wildner 
404b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
405b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
406b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
407b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
408b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
409b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
410b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
411b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
412b7609e3dSSascha Wildner 	{ "CPUVDDA", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT2(34, 34) },
413b7609e3dSSascha Wildner 	{ "PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0c, RFACT_NONE2 },
414b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
415b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT_NONE2 },
416b7609e3dSSascha Wildner 	{ "NB +1.8V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
417b7609e3dSSascha Wildner 	{ "NB +1.8V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT_NONE2 },
418b7609e3dSSascha Wildner 
419b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
420b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
421b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
422b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
423b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
424b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
425b7609e3dSSascha Wildner 
426b7609e3dSSascha Wildner 	{ NULL }
427b7609e3dSSascha Wildner };
428b7609e3dSSascha Wildner 
429b7609e3dSSascha Wildner struct uguru_sensor abitan2_sensors[] = {
430b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
431b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
432b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
433b7609e3dSSascha Wildner 
434b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
435b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
436b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
437b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
438b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
439b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
440b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
441b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
442b7609e3dSSascha Wildner 	{ "CPUVDDA", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT2(34, 34) },
443b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
444b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
445b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
446b7609e3dSSascha Wildner 
447b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
448b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
449b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
450b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
451b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
452b7609e3dSSascha Wildner 
453b7609e3dSSascha Wildner 	{ NULL }
454b7609e3dSSascha Wildner };
455b7609e3dSSascha Wildner 
456b7609e3dSSascha Wildner struct uguru_sensor abitab_sensors[] = {
457b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
458b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
459b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
460b7609e3dSSascha Wildner 
461b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
462b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
463b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
464b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
465b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
466b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
467b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT_NONE2 },
468b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
469b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
470b7609e3dSSascha Wildner 	{ "ICHIO", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT_NONE2 },
471b7609e3dSSascha Wildner 	{ "ICH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
472b7609e3dSSascha Wildner 	{ "MCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
473b7609e3dSSascha Wildner 
474b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
475b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
476b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
477b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
478b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
479b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
480b7609e3dSSascha Wildner 
481b7609e3dSSascha Wildner 	{ NULL }
482b7609e3dSSascha Wildner };
483b7609e3dSSascha Wildner 
484b7609e3dSSascha Wildner struct uguru_sensor abitan3_sensors[] = {
485b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
486b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
487b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
488b7609e3dSSascha Wildner 
489b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
490b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
491b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
492b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
493b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
494b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
495b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
496b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
497b7609e3dSSascha Wildner 	{ "CPUVDDA", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT2(34, 34) },
498b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
499b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
500b7609e3dSSascha Wildner 	{ "NB/PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE2 },
501b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
502b7609e3dSSascha Wildner 
503b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
504b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
505b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
506b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
507b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
508b7609e3dSSascha Wildner 	{ "AUX4", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
509b7609e3dSSascha Wildner 
510b7609e3dSSascha Wildner 	{ NULL }
511b7609e3dSSascha Wildner };
512b7609e3dSSascha Wildner 
513b7609e3dSSascha Wildner struct uguru_sensor abitaw2_sensors[] = {
514b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
515b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
516b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
517b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
518b7609e3dSSascha Wildner 	{ "PWM3", SENSOR_TEMP, UGURU_R_TEMP, 0x1c },
519b7609e3dSSascha Wildner 	{ "PWM4", SENSOR_TEMP, UGURU_R_TEMP, 0x1d },
520b7609e3dSSascha Wildner 
521b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
522b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
523b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
524b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
525b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
526b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
527b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
528b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
529b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
530b7609e3dSSascha Wildner 	{ "MCH/PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
531b7609e3dSSascha Wildner 	{ "MCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT2(34, 34) },
532b7609e3dSSascha Wildner 	{ "ICH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
533b7609e3dSSascha Wildner 
534b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
535b7609e3dSSascha Wildner 	{ "NB", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
536b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
537b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
538b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
539b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
540b7609e3dSSascha Wildner 	{ "OTES1", SENSOR_FANRPM, UGURU_R_FAN, 0x26 },
541b7609e3dSSascha Wildner 	{ "OTES2", SENSOR_FANRPM, UGURU_R_FAN, 0x27 },
542b7609e3dSSascha Wildner 
543b7609e3dSSascha Wildner 	{ NULL }
544b7609e3dSSascha Wildner };
545b7609e3dSSascha Wildner 
546b7609e3dSSascha Wildner struct uguru_sensor abitat2_sensors[] = {
547b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
548b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
549b7609e3dSSascha Wildner 	{ "PWM", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
550b7609e3dSSascha Wildner 
551b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
552b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
553b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
554b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
555b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
556b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
557b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
558b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
559b7609e3dSSascha Wildner 	{ "CPUVDDA", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT2(34, 34) },
560b7609e3dSSascha Wildner 	{ "PCIE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0c, RFACT_NONE2 },
561b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
562b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT_NONE2 },
563b7609e3dSSascha Wildner 	{ "NB +1.8V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
564b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT_NONE2 },
565b7609e3dSSascha Wildner 
566b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
567b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
568b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
569b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
570b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
571b7609e3dSSascha Wildner 	{ "AUX4", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
572b7609e3dSSascha Wildner 
573b7609e3dSSascha Wildner 	{ NULL }
574b7609e3dSSascha Wildner };
575b7609e3dSSascha Wildner 
576b7609e3dSSascha Wildner struct uguru_sensor abitab2_sensors[] = {
577b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
578b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
579b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
580b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
581b7609e3dSSascha Wildner 	{ "PWM3", SENSOR_TEMP, UGURU_R_TEMP, 0x1c },
582b7609e3dSSascha Wildner 	{ "PWM4", SENSOR_TEMP, UGURU_R_TEMP, 0x1d },
583b7609e3dSSascha Wildner 	{ "PWM5", SENSOR_TEMP, UGURU_R_TEMP, 0x1e },
584b7609e3dSSascha Wildner 
585b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x00, RFACT_NONE2 },
586b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
587b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
588b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT2(50, 10) },
589b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
590b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
591b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x01, RFACT2(34, 34) },
592b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x02, RFACT_NONE2 },
593b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
594b7609e3dSSascha Wildner 	{ "ICHIO", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT_NONE2 },
595b7609e3dSSascha Wildner 	{ "ICH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
596b7609e3dSSascha Wildner 	{ "MCH", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
597b7609e3dSSascha Wildner 
598b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
599b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
600b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
601b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
602b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
603b7609e3dSSascha Wildner 	{ "AUX4", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
604b7609e3dSSascha Wildner 
605b7609e3dSSascha Wildner 	{ NULL }
606b7609e3dSSascha Wildner };
607b7609e3dSSascha Wildner 
608b7609e3dSSascha Wildner struct uguru_sensor abitin_sensors[] = {
609b7609e3dSSascha Wildner 	{ "CPU", SENSOR_TEMP, UGURU_R_TEMP, 0x18 },
610b7609e3dSSascha Wildner 	{ "SYS", SENSOR_TEMP, UGURU_R_TEMP, 0x19 },
611b7609e3dSSascha Wildner 	{ "PWM1", SENSOR_TEMP, UGURU_R_TEMP, 0x1a },
612b7609e3dSSascha Wildner 	{ "PWM2", SENSOR_TEMP, UGURU_R_TEMP, 0x1b },
613b7609e3dSSascha Wildner 	{ "PWM3", SENSOR_TEMP, UGURU_R_TEMP, 0x1c },
614b7609e3dSSascha Wildner 	{ "PWM4", SENSOR_TEMP, UGURU_R_TEMP, 0x1d },
615b7609e3dSSascha Wildner 	{ "PWM5", SENSOR_TEMP, UGURU_R_TEMP, 0x1e },
616b7609e3dSSascha Wildner 
617b7609e3dSSascha Wildner 	{ "VCORE", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x07, RFACT_NONE2 },
618b7609e3dSSascha Wildner 	{ "+3.3V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0a, RFACT2(34, 34) },
619b7609e3dSSascha Wildner 	{ "+5V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x09, RFACT2(120, 60) },
620b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0c, RFACT2(50, 10) },
621b7609e3dSSascha Wildner 	{ "+12V", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x08, RFACT2(50, 10) },
622b7609e3dSSascha Wildner 	{ "+5VSB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0b, RFACT2(120, 60) },
623b7609e3dSSascha Wildner 	{ "DDR", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0d, RFACT2(34, 34) },
624b7609e3dSSascha Wildner 	{ "DDRVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x0e, RFACT_NONE2 },
625b7609e3dSSascha Wildner 	{ "CPUVTT", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x03, RFACT_NONE2 },
626b7609e3dSSascha Wildner 	{ "HTV", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x05, RFACT_NONE2 },
627b7609e3dSSascha Wildner 	{ "NB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x04, RFACT_NONE2 },
628b7609e3dSSascha Wildner 	{ "SB", SENSOR_VOLTS_DC, UGURU_R_VOLT, 0x06, RFACT_NONE2 },
629b7609e3dSSascha Wildner 
630b7609e3dSSascha Wildner 	{ "CPU", SENSOR_FANRPM, UGURU_R_FAN, 0x20 },
631b7609e3dSSascha Wildner 	{ "SYS", SENSOR_FANRPM, UGURU_R_FAN, 0x22 },
632b7609e3dSSascha Wildner 	{ "AUX1", SENSOR_FANRPM, UGURU_R_FAN, 0x21 },
633b7609e3dSSascha Wildner 	{ "AUX2", SENSOR_FANRPM, UGURU_R_FAN, 0x23 },
634b7609e3dSSascha Wildner 	{ "AUX3", SENSOR_FANRPM, UGURU_R_FAN, 0x24 },
635b7609e3dSSascha Wildner 	{ "AUX4", SENSOR_FANRPM, UGURU_R_FAN, 0x25 },
636b7609e3dSSascha Wildner 
637b7609e3dSSascha Wildner 	{ NULL }
638b7609e3dSSascha Wildner };
639b7609e3dSSascha Wildner 
640*5d302545SFrançois Tigeot static void	 uguru_identify(driver_t *driver, device_t parent);
641*5d302545SFrançois Tigeot static int	 uguru_match(device_t);
642*5d302545SFrançois Tigeot static int	 uguru_attach(device_t);
643*5d302545SFrançois Tigeot static int	 uguru_detach(device_t dev);
644b7609e3dSSascha Wildner static void	 uguru_refresh(void *);
645b7609e3dSSascha Wildner static int	 uguru_read_sensor(struct uguru_softc *, int);
646b7609e3dSSascha Wildner static int	 uguru_ac5_read_sensor(struct uguru_softc *, int);
647b7609e3dSSascha Wildner static int	 uguru_ac5_read(bus_space_tag_t, bus_space_handle_t,
648b7609e3dSSascha Wildner 		     uint16_t, void *, int);
649b7609e3dSSascha Wildner static int	 uguru_write_multi(bus_space_tag_t, bus_space_handle_t,
650b7609e3dSSascha Wildner 		     uint8_t, void *, int);
651b7609e3dSSascha Wildner static int	 uguru_read_multi(bus_space_tag_t, bus_space_handle_t, void *,
652b7609e3dSSascha Wildner 		     int);
653b7609e3dSSascha Wildner 
654b7609e3dSSascha Wildner static device_method_t uguru_methods[] = {
655b7609e3dSSascha Wildner 	DEVMETHOD(device_identify,	uguru_identify),
656b7609e3dSSascha Wildner 	DEVMETHOD(device_probe,		uguru_match),
657b7609e3dSSascha Wildner 	DEVMETHOD(device_attach, 	uguru_attach),
658b7609e3dSSascha Wildner 	DEVMETHOD(device_detach,	uguru_detach),
659b7609e3dSSascha Wildner 
660b7609e3dSSascha Wildner 	{ NULL, NULL}
661b7609e3dSSascha Wildner };
662b7609e3dSSascha Wildner 
663b7609e3dSSascha Wildner static driver_t uguru_driver = {
664b7609e3dSSascha Wildner 	"uguru",
665b7609e3dSSascha Wildner 	uguru_methods,
666b7609e3dSSascha Wildner 	sizeof(struct uguru_softc)
667b7609e3dSSascha Wildner };
668b7609e3dSSascha Wildner 
669b7609e3dSSascha Wildner static devclass_t uguru_devclass;
670b7609e3dSSascha Wildner 
671b7609e3dSSascha Wildner DRIVER_MODULE(uguru, isa, uguru_driver, uguru_devclass, NULL, NULL);
672b7609e3dSSascha Wildner 
673b7609e3dSSascha Wildner static void
uguru_identify(driver_t * driver,device_t parent)674*5d302545SFrançois Tigeot uguru_identify(driver_t *driver, device_t parent)
675b7609e3dSSascha Wildner {
676b7609e3dSSascha Wildner #ifdef KLD_MODULE
677*5d302545SFrançois Tigeot 	device_t child;
678b7609e3dSSascha Wildner 	const int port = 0xe0;
679b7609e3dSSascha Wildner 
680b7609e3dSSascha Wildner 	child = device_find_child(parent, driver->name, 0);
681b7609e3dSSascha Wildner 	if (child == NULL)
682b7609e3dSSascha Wildner 		child = BUS_ADD_CHILD(parent, parent, ISA_ORDER_PNP,
683b7609e3dSSascha Wildner 		    driver->name, 0);
684b47b3275SSepherosa Ziehau 	if (bus_set_resource(child, SYS_RES_IOPORT, 0, port, UGURU_IOSIZE, -1))
685b7609e3dSSascha Wildner 		kprintf("%s: cannot set resource for child\n", __func__);
686b7609e3dSSascha Wildner #endif
687b7609e3dSSascha Wildner }
688b7609e3dSSascha Wildner 
689b7609e3dSSascha Wildner static int
uguru_match(device_t dev)690*5d302545SFrançois Tigeot uguru_match(device_t dev)
691b7609e3dSSascha Wildner {
692b7609e3dSSascha Wildner 	struct resource *iores;
693b7609e3dSSascha Wildner 	int iorid = 0;
694b7609e3dSSascha Wildner 	bus_space_tag_t iot;
695b7609e3dSSascha Wildner 	bus_space_handle_t ioh;
696b7609e3dSSascha Wildner 	uint8_t data[9];
697b7609e3dSSascha Wildner 	uint16_t vendid, devid;
698b7609e3dSSascha Wildner 	int ret = 1;
699b7609e3dSSascha Wildner 
700b7609e3dSSascha Wildner 	iores = bus_alloc_resource(dev, SYS_RES_IOPORT, &iorid,
701b7609e3dSSascha Wildner 	    0ul, ~0ul, 8, RF_ACTIVE);
702b7609e3dSSascha Wildner 	if (iores == NULL)
703b7609e3dSSascha Wildner 		return ENXIO;
704b7609e3dSSascha Wildner 	iot = rman_get_bustag(iores);
705b7609e3dSSascha Wildner 	ioh = rman_get_bushandle(iores);
706b7609e3dSSascha Wildner 
707b7609e3dSSascha Wildner 	UGURU_WRITE(iot, ioh, UGURU_INDEX, UGURU_PRODID);
708b7609e3dSSascha Wildner 	if (!uguru_read_multi(iot, ioh, &data, sizeof(data)) ||
709b7609e3dSSascha Wildner 	    !uguru_ac5_read(iot, ioh, 0x0904, &data, sizeof(data))) {
710b7609e3dSSascha Wildner 		vendid = data[0] << 8 | data[1];
711b7609e3dSSascha Wildner 		devid = data[2] << 8 | data[3];
712b7609e3dSSascha Wildner 
713b7609e3dSSascha Wildner 		if (vendid == UGURU_VENDID_ABIT &&
714b7609e3dSSascha Wildner 		    (devid == UGURU_DEVID1 ||
715b7609e3dSSascha Wildner 		     devid == UGURU_DEVID2)) {
716b7609e3dSSascha Wildner 			ret = 0;
717b7609e3dSSascha Wildner 		}
718b7609e3dSSascha Wildner 	}
719b7609e3dSSascha Wildner 	bus_release_resource(dev, SYS_RES_IOPORT, iorid, iores);
720b7609e3dSSascha Wildner 	return (ret);
721b7609e3dSSascha Wildner }
722b7609e3dSSascha Wildner 
723b7609e3dSSascha Wildner static int
uguru_attach(device_t dev)724*5d302545SFrançois Tigeot uguru_attach(device_t dev)
725b7609e3dSSascha Wildner {
726b7609e3dSSascha Wildner 	struct uguru_softc *sc = device_get_softc(dev);
727b7609e3dSSascha Wildner 	struct uguru_sensor *sensors;
728b7609e3dSSascha Wildner 	uint8_t data[9];
729b7609e3dSSascha Wildner 	uint16_t vendid, devid, sysid;
730b7609e3dSSascha Wildner 	int i;
731b7609e3dSSascha Wildner 	const char *desc = NULL;
732b7609e3dSSascha Wildner 	char fulldesc[64];
733b7609e3dSSascha Wildner 
734b7609e3dSSascha Wildner 	sc->sc_dev = dev;
735b7609e3dSSascha Wildner 	sc->sc_iores = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->sc_iorid,
736b7609e3dSSascha Wildner 	    0ul, ~0ul, 8, RF_ACTIVE);
737b7609e3dSSascha Wildner 	if (sc->sc_iores == NULL) {
738b7609e3dSSascha Wildner 		device_printf(dev, "can't map i/o space\n");
739b7609e3dSSascha Wildner 		return ENXIO;
740b7609e3dSSascha Wildner 	}
741b7609e3dSSascha Wildner 	sc->sc_iot = rman_get_bustag(sc->sc_iores);
742b7609e3dSSascha Wildner 	sc->sc_ioh = rman_get_bushandle(sc->sc_iores);
743b7609e3dSSascha Wildner 
744b7609e3dSSascha Wildner 	UGURU_WRITE(sc->sc_iot, sc->sc_ioh, UGURU_INDEX, UGURU_PRODID);
745b7609e3dSSascha Wildner 	if (!uguru_read_multi(sc->sc_iot, sc->sc_ioh, &data, sizeof(data))) {
746b7609e3dSSascha Wildner 		sc->read = uguru_read_sensor;
747b7609e3dSSascha Wildner 		goto done;
748b7609e3dSSascha Wildner 	}
749b7609e3dSSascha Wildner 
750b7609e3dSSascha Wildner 	/* AC2005 product ID */
751b7609e3dSSascha Wildner 	if (!uguru_ac5_read(sc->sc_iot, sc->sc_ioh,
752b7609e3dSSascha Wildner 	    0x0904, &data, sizeof(data))) {
753b7609e3dSSascha Wildner 		sc->read = uguru_ac5_read_sensor;
754b7609e3dSSascha Wildner 		goto done;
755b7609e3dSSascha Wildner 	}
756b7609e3dSSascha Wildner 
757b7609e3dSSascha Wildner 	return ENXIO;
758b7609e3dSSascha Wildner 
759b7609e3dSSascha Wildner done:
760b7609e3dSSascha Wildner 	DPRINTF(5, ": %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x",
761b7609e3dSSascha Wildner 	    data[0], data[1], data[2], data[3], data[4],
762b7609e3dSSascha Wildner 	    data[5], data[6], data[7], data[8]);
763b7609e3dSSascha Wildner 
764b7609e3dSSascha Wildner 	vendid = data[0] << 8 | data[1];
765b7609e3dSSascha Wildner 	devid = data[2] << 8 | data[3];
766b7609e3dSSascha Wildner 	sysid = data[3] << 8 | data[7];
767b7609e3dSSascha Wildner 
768b7609e3dSSascha Wildner 	if (vendid != UGURU_VENDID_ABIT ||
769b7609e3dSSascha Wildner 	    (devid != UGURU_DEVID1 &&
770b7609e3dSSascha Wildner 	     devid != UGURU_DEVID2)) {
771b7609e3dSSascha Wildner 		device_printf(dev, "attach failed\n");
772b7609e3dSSascha Wildner 		return ENXIO;
773b7609e3dSSascha Wildner 	}
774b7609e3dSSascha Wildner 
775b7609e3dSSascha Wildner 	switch(sysid) {
776b7609e3dSSascha Wildner 	case ABIT_SYSID_KV01:
777b7609e3dSSascha Wildner 	case ABIT_SYSID_AI01:
778b7609e3dSSascha Wildner 	case ABIT_SYSID_AN01:
779b7609e3dSSascha Wildner 		desc = "KV1";
780b7609e3dSSascha Wildner 		sensors = abitkv_sensors;
781b7609e3dSSascha Wildner 		break;
782b7609e3dSSascha Wildner 	case ABIT_SYSID_AA01:
783b7609e3dSSascha Wildner 	case ABIT_SYSID_AG01:
784b7609e3dSSascha Wildner 		desc = "AA1";
785b7609e3dSSascha Wildner 		sensors = abitaa_sensors;
786b7609e3dSSascha Wildner 		break;
787b7609e3dSSascha Wildner 	case ABIT_SYSID_AV01:
788b7609e3dSSascha Wildner 	case ABIT_SYSID_KVP1:
789b7609e3dSSascha Wildner 		desc = "AV1";
790b7609e3dSSascha Wildner 		sensors = abitav_sensors;
791b7609e3dSSascha Wildner 		break;
792b7609e3dSSascha Wildner 	case ABIT_SYSID_AS01:
793b7609e3dSSascha Wildner 		desc = "AS1";
794b7609e3dSSascha Wildner 		sensors = abitas_sensors;
795b7609e3dSSascha Wildner 		break;
796b7609e3dSSascha Wildner 	case ABIT_SYSID_AX01:
797b7609e3dSSascha Wildner 		desc = "AX1";
798b7609e3dSSascha Wildner 		sensors = abitax_sensors;
799b7609e3dSSascha Wildner 		break;
800b7609e3dSSascha Wildner 	case ABIT_SYSID_M401:
801b7609e3dSSascha Wildner 		desc = "M41";
802b7609e3dSSascha Wildner 		sensors = abitm4_sensors;
803b7609e3dSSascha Wildner 		break;
804b7609e3dSSascha Wildner 	case ABIT_SYSID_AN02:
805b7609e3dSSascha Wildner 		desc = "AN1";
806b7609e3dSSascha Wildner 		sensors = abitan_sensors;
807b7609e3dSSascha Wildner 		break;
808b7609e3dSSascha Wildner 	case ABIT_SYSID_AU01:
809b7609e3dSSascha Wildner 	case ABIT_SYSID_AL01:
810b7609e3dSSascha Wildner 	case ABIT_SYSID_BL01:
811b7609e3dSSascha Wildner 		desc = "AL1";
812b7609e3dSSascha Wildner 		sensors = abital_sensors;
813b7609e3dSSascha Wildner 		break;
814b7609e3dSSascha Wildner 	case ABIT_SYSID_AW01:
815b7609e3dSSascha Wildner 	case ABIT_SYSID_AW02:
816b7609e3dSSascha Wildner 		desc = "AW1";
817b7609e3dSSascha Wildner 		sensors = abitaw_sensors;
818b7609e3dSSascha Wildner 		break;
819b7609e3dSSascha Wildner 	case ABIT_SYSID_NI01:
820b7609e3dSSascha Wildner 		desc = "NI1";
821b7609e3dSSascha Wildner 		sensors = abitni_sensors;
822b7609e3dSSascha Wildner 		break;
823b7609e3dSSascha Wildner 	case ABIT_SYSID_AT01:
824b7609e3dSSascha Wildner 		desc = "AT1";
825b7609e3dSSascha Wildner 		sensors = abitat_sensors;
826b7609e3dSSascha Wildner 		break;
827b7609e3dSSascha Wildner 	case ABIT_SYSID_AN03:
828b7609e3dSSascha Wildner 		desc = "AN2";
829b7609e3dSSascha Wildner 		sensors = abitan2_sensors;
830b7609e3dSSascha Wildner 		break;
831b7609e3dSSascha Wildner 	case ABIT_SYSID_AB01:
832b7609e3dSSascha Wildner 		desc = "AB1";
833b7609e3dSSascha Wildner 		sensors = abitab_sensors;
834b7609e3dSSascha Wildner 		break;
835b7609e3dSSascha Wildner 	case ABIT_SYSID_AN04:
836b7609e3dSSascha Wildner 		desc = "AN3";
837b7609e3dSSascha Wildner 		sensors = abitan3_sensors;
838b7609e3dSSascha Wildner 		break;
839b7609e3dSSascha Wildner 	case ABIT_SYSID_AW03:
840b7609e3dSSascha Wildner 		desc = "AW2";
841b7609e3dSSascha Wildner 		sensors = abitaw2_sensors;
842b7609e3dSSascha Wildner 		break;
843b7609e3dSSascha Wildner 	case ABIT_SYSID_AT02:
844b7609e3dSSascha Wildner 		desc = "AT2";
845b7609e3dSSascha Wildner 		sensors = abitat2_sensors;
846b7609e3dSSascha Wildner 		break;
847b7609e3dSSascha Wildner 	case ABIT_SYSID_AB02:
848b7609e3dSSascha Wildner 	case ABIT_SYSID_IP01:
849b7609e3dSSascha Wildner 	case ABIT_SYSID_IX01:
850b7609e3dSSascha Wildner 	case ABIT_SYSID_IX02:
851b7609e3dSSascha Wildner 		desc = "AB2";
852b7609e3dSSascha Wildner 		sensors = abitab2_sensors;
853b7609e3dSSascha Wildner 		break;
854b7609e3dSSascha Wildner 	case ABIT_SYSID_IN01:
855b7609e3dSSascha Wildner 		desc = "IN1";
856b7609e3dSSascha Wildner 		sensors = abitin_sensors;
857b7609e3dSSascha Wildner 		break;
858b7609e3dSSascha Wildner 	default:
859b7609e3dSSascha Wildner 		kprintf(" unknown system (ID 0x%.4x)\n", sysid);
860b7609e3dSSascha Wildner 		return ENXIO;
861b7609e3dSSascha Wildner 	}
862b7609e3dSSascha Wildner 
863b7609e3dSSascha Wildner 	strlcpy(sc->sc_sensordev.xname,
864b7609e3dSSascha Wildner 	    device_get_nameunit(sc->sc_dev),
865b7609e3dSSascha Wildner 	    sizeof(sc->sc_sensordev.xname));
866b7609e3dSSascha Wildner 
867b7609e3dSSascha Wildner 	for (i = 0; sensors[i].desc != NULL; i++) {
868b7609e3dSSascha Wildner 		strlcpy(sc->sc_sensors[i].desc,
869b7609e3dSSascha Wildner 		    sensors[i].desc, sizeof(sc->sc_sensors[i].desc));
870b7609e3dSSascha Wildner 		sc->sc_sensors[i].type = sensors[i].type;
871b7609e3dSSascha Wildner 		sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]);
872b7609e3dSSascha Wildner 		sc->sc_numsensors++;
873b7609e3dSSascha Wildner 	}
874b7609e3dSSascha Wildner 	sc->uguru_sensors = sensors;
875b7609e3dSSascha Wildner 
8761bedd63aSSepherosa Ziehau 	sensor_task_register(sc, uguru_refresh, UGURU_INTERVAL);
877b7609e3dSSascha Wildner 	sensordev_install(&sc->sc_sensordev);
878b7609e3dSSascha Wildner 
879b7609e3dSSascha Wildner 	ksnprintf(fulldesc, sizeof(fulldesc),
880b7609e3dSSascha Wildner 	    "ABIT AC%x %s I/O port driver", devid, desc);
881b7609e3dSSascha Wildner 	device_set_desc_copy(dev, fulldesc);
882b7609e3dSSascha Wildner 	return 0;
883b7609e3dSSascha Wildner }
884b7609e3dSSascha Wildner 
885b7609e3dSSascha Wildner static int
uguru_detach(device_t dev)886*5d302545SFrançois Tigeot uguru_detach(device_t dev)
887b7609e3dSSascha Wildner {
888b7609e3dSSascha Wildner 	struct uguru_softc *sc = device_get_softc(dev);
889b7609e3dSSascha Wildner 
890963fe5f3SSascha Wildner 	sensordev_deinstall(&sc->sc_sensordev);
891963fe5f3SSascha Wildner 	sensor_task_unregister(sc);
892963fe5f3SSascha Wildner 
893b7609e3dSSascha Wildner 	return bus_release_resource(dev, SYS_RES_IOPORT,
894b7609e3dSSascha Wildner 	    sc->sc_iorid, sc->sc_iores);
895b7609e3dSSascha Wildner }
896b7609e3dSSascha Wildner 
897b7609e3dSSascha Wildner static void
uguru_refresh(void * arg)898b7609e3dSSascha Wildner uguru_refresh(void *arg)
899b7609e3dSSascha Wildner {
900b7609e3dSSascha Wildner 	struct uguru_softc *sc = (struct uguru_softc *)arg;
901b7609e3dSSascha Wildner 	int i;
902b7609e3dSSascha Wildner 
903b7609e3dSSascha Wildner 	for (i = 0; i < sc->sc_numsensors; i++)
904b7609e3dSSascha Wildner 		sc->uguru_sensors[i].refresh(sc, i);
905b7609e3dSSascha Wildner }
906b7609e3dSSascha Wildner 
907b7609e3dSSascha Wildner static void
uguru_refresh_temp(struct uguru_softc * sc,int n)908b7609e3dSSascha Wildner uguru_refresh_temp(struct uguru_softc *sc, int n)
909b7609e3dSSascha Wildner {
910b7609e3dSSascha Wildner 	struct ksensor *sensor = &sc->sc_sensors[n];
911b7609e3dSSascha Wildner 	int status = SENSOR_S_OK;
912b7609e3dSSascha Wildner 	int ret;
913b7609e3dSSascha Wildner 
914b7609e3dSSascha Wildner 	ret = sc->read(sc, n);
915b7609e3dSSascha Wildner 	if (sc->cs.reading == 0x00) {
916b7609e3dSSascha Wildner 		sensor->flags |= SENSOR_FINVALID;
917b7609e3dSSascha Wildner 		sensor->value = 0;
918b7609e3dSSascha Wildner 		return;
919b7609e3dSSascha Wildner 	}
920b7609e3dSSascha Wildner 	sensor->flags &= ~SENSOR_FINVALID;
921b7609e3dSSascha Wildner 	sensor->value = sc->cs.reading * 1000000 + 273150000;
922b7609e3dSSascha Wildner 
923b7609e3dSSascha Wildner 	if (ret)
924b7609e3dSSascha Wildner 		status = SENSOR_S_UNSPEC;
925b7609e3dSSascha Wildner 	else {
926b7609e3dSSascha Wildner 		if (sc->cs.reading >= sc->cs.lower)
927b7609e3dSSascha Wildner 			status = SENSOR_S_WARN;
928b7609e3dSSascha Wildner 		if (sc->cs.reading >= sc->cs.upper)
929b7609e3dSSascha Wildner 			status = SENSOR_S_CRIT;
930b7609e3dSSascha Wildner 	}
931b7609e3dSSascha Wildner 	sensor->status = status;
932b7609e3dSSascha Wildner }
933b7609e3dSSascha Wildner 
934b7609e3dSSascha Wildner static void
uguru_refresh_volt(struct uguru_softc * sc,int n)935b7609e3dSSascha Wildner uguru_refresh_volt(struct uguru_softc *sc, int n)
936b7609e3dSSascha Wildner {
937b7609e3dSSascha Wildner 	int status = SENSOR_S_OK;
938b7609e3dSSascha Wildner 
939b7609e3dSSascha Wildner 	if (sc->read(sc, n))
940b7609e3dSSascha Wildner 		status = SENSOR_S_UNSPEC;
941b7609e3dSSascha Wildner 	else
942b7609e3dSSascha Wildner 		if (sc->cs.reading <= sc->cs.lower ||
943b7609e3dSSascha Wildner 		    sc->cs.reading >= sc->cs.upper)
944b7609e3dSSascha Wildner 			status = SENSOR_S_CRIT;
945b7609e3dSSascha Wildner 
946b7609e3dSSascha Wildner 	sc->sc_sensors[n].value =
947b7609e3dSSascha Wildner 	    sc->cs.reading * sc->uguru_sensors[n].rfact;
948b7609e3dSSascha Wildner 	sc->sc_sensors[n].status = status;
949b7609e3dSSascha Wildner }
950b7609e3dSSascha Wildner 
951b7609e3dSSascha Wildner static void
uguru_refresh_fan(struct uguru_softc * sc,int n)952b7609e3dSSascha Wildner uguru_refresh_fan(struct uguru_softc *sc, int n)
953b7609e3dSSascha Wildner {
954b7609e3dSSascha Wildner 	struct ksensor *sensor = &sc->sc_sensors[n];
955b7609e3dSSascha Wildner 	int ret;
956b7609e3dSSascha Wildner 
957b7609e3dSSascha Wildner 	ret = sc->read(sc, n);
958b7609e3dSSascha Wildner 	if (sc->cs.reading == 0x00) {
959b7609e3dSSascha Wildner 		sensor->flags |= SENSOR_FINVALID;
960b7609e3dSSascha Wildner 		sensor->value = 0;
961b7609e3dSSascha Wildner 		return;
962b7609e3dSSascha Wildner 	}
963b7609e3dSSascha Wildner 	sensor->flags &= ~SENSOR_FINVALID;
964b7609e3dSSascha Wildner 	sensor->value = sc->cs.reading * 60;
965b7609e3dSSascha Wildner 
966b7609e3dSSascha Wildner 	if (ret)
967b7609e3dSSascha Wildner 		sensor->status = SENSOR_S_UNSPEC;
968b7609e3dSSascha Wildner 	else
969b7609e3dSSascha Wildner 		if (sc->cs.reading <= sc->cs.lower)
970b7609e3dSSascha Wildner 			sensor->status = SENSOR_S_CRIT;
971b7609e3dSSascha Wildner 		else
972b7609e3dSSascha Wildner 			sensor->status = SENSOR_S_OK;
973b7609e3dSSascha Wildner }
974b7609e3dSSascha Wildner 
975b7609e3dSSascha Wildner static int
uguru_read_sensor(struct uguru_softc * sc,int n)976b7609e3dSSascha Wildner uguru_read_sensor(struct uguru_softc *sc, int n)
977b7609e3dSSascha Wildner {
978b7609e3dSSascha Wildner 	struct ksensor *sensor = &sc->sc_sensors[n];
979b7609e3dSSascha Wildner 	bus_space_tag_t iot = sc->sc_iot;
980b7609e3dSSascha Wildner 	bus_space_handle_t ioh = sc->sc_ioh;
981b7609e3dSSascha Wildner 	uint8_t reg = sc->uguru_sensors[n].reg;
982b7609e3dSSascha Wildner 	uint8_t idx, data[3];
983b7609e3dSSascha Wildner 	uint8_t val = 0x00;
984b7609e3dSSascha Wildner 	int count, ret = 0;
985b7609e3dSSascha Wildner 
986b7609e3dSSascha Wildner 	if (sensor->type == SENSOR_FANRPM)
987b7609e3dSSascha Wildner 		idx = UGURU_FAN_DATA;
988b7609e3dSSascha Wildner 	else
989b7609e3dSSascha Wildner 		idx = UGURU_ITM_DATA;
990b7609e3dSSascha Wildner 
991b7609e3dSSascha Wildner 	/* sensor value */
992b7609e3dSSascha Wildner 	if (uguru_write_multi(iot, ioh, idx, &reg, sizeof(reg)) ||
993b7609e3dSSascha Wildner 	    uguru_read_multi(iot, ioh, &val, sizeof(val)))
994b7609e3dSSascha Wildner 		++ret;
995b7609e3dSSascha Wildner 
996b7609e3dSSascha Wildner 	/* sensor status */
997b7609e3dSSascha Wildner 	bzero(&data, sizeof(data));
998b7609e3dSSascha Wildner 	count = sensor->type == SENSOR_FANRPM ? 2 : 3;
999b7609e3dSSascha Wildner 
1000b7609e3dSSascha Wildner 	if (uguru_write_multi(iot, ioh, idx + 1, &reg, sizeof(reg)) ||
1001b7609e3dSSascha Wildner 	    uguru_read_multi(iot, ioh, &data, count))
1002b7609e3dSSascha Wildner 		++ret;
1003b7609e3dSSascha Wildner 
1004b7609e3dSSascha Wildner 	/* fill in current sensor structure */
1005b7609e3dSSascha Wildner 	sc->cs.reading = val;
1006b7609e3dSSascha Wildner /*	sc->cs.flags = data[0]; */
1007b7609e3dSSascha Wildner 	sc->cs.lower = data[1];
1008b7609e3dSSascha Wildner 	sc->cs.upper = data[2];
1009b7609e3dSSascha Wildner 
1010b7609e3dSSascha Wildner 	DPRINTF(50, "0x%.2x: 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
1011b7609e3dSSascha Wildner 	    idx, reg, val, data[0], data[1], data[2]);
1012b7609e3dSSascha Wildner 
1013b7609e3dSSascha Wildner 	return (ret);
1014b7609e3dSSascha Wildner }
1015b7609e3dSSascha Wildner 
1016b7609e3dSSascha Wildner static int
uguru_ac5_read_sensor(struct uguru_softc * sc,int n)1017b7609e3dSSascha Wildner uguru_ac5_read_sensor(struct uguru_softc *sc, int n)
1018b7609e3dSSascha Wildner {
1019b7609e3dSSascha Wildner 	uint16_t reg;
1020b7609e3dSSascha Wildner 	uint8_t val = 0x00;
1021b7609e3dSSascha Wildner 	int ret = 1;
1022b7609e3dSSascha Wildner 
1023b7609e3dSSascha Wildner 	reg = sc->uguru_sensors[n].reg | 0x0880;
1024b7609e3dSSascha Wildner 	if (uguru_ac5_read(sc->sc_iot, sc->sc_ioh, reg, &val, sizeof(val)))
1025b7609e3dSSascha Wildner 		++ret;
1026b7609e3dSSascha Wildner 
1027b7609e3dSSascha Wildner 	sc->cs.reading = val;
1028b7609e3dSSascha Wildner 	return (ret);
1029b7609e3dSSascha Wildner }
1030b7609e3dSSascha Wildner 
1031b7609e3dSSascha Wildner static int
uguru_ac5_read(bus_space_tag_t iot,bus_space_handle_t ioh,uint16_t reg,void * data,int count)1032b7609e3dSSascha Wildner uguru_ac5_read(bus_space_tag_t iot, bus_space_handle_t ioh,
1033b7609e3dSSascha Wildner     uint16_t reg, void *data, int count)
1034b7609e3dSSascha Wildner {
1035b7609e3dSSascha Wildner 	uint8_t buf[3];
1036b7609e3dSSascha Wildner 
1037b7609e3dSSascha Wildner 	buf[0] = reg >> 8;
1038b7609e3dSSascha Wildner 	buf[1] = reg & 0xff;
1039b7609e3dSSascha Wildner 	buf[2] = count;
1040b7609e3dSSascha Wildner 
1041b7609e3dSSascha Wildner 	if (!uguru_write_multi(iot, ioh, 0x1a, &buf, sizeof(buf)) &&
1042b7609e3dSSascha Wildner 	    !uguru_read_multi(iot, ioh, data, count))
1043b7609e3dSSascha Wildner 		return 0;
1044b7609e3dSSascha Wildner 
1045b7609e3dSSascha Wildner 	DPRINTF(0, "uguru_ac5_read: timeout 0x%.2x 0x%.2x 0x%.2x\n",
1046b7609e3dSSascha Wildner 	    buf[0], buf[1], buf[2]);
1047b7609e3dSSascha Wildner 
1048b7609e3dSSascha Wildner 	return 1;
1049b7609e3dSSascha Wildner }
1050b7609e3dSSascha Wildner 
1051b7609e3dSSascha Wildner static int
uguru_write_multi(bus_space_tag_t iot,bus_space_handle_t ioh,uint8_t idx,void * data,int count)1052b7609e3dSSascha Wildner uguru_write_multi(bus_space_tag_t iot, bus_space_handle_t ioh,
1053b7609e3dSSascha Wildner     uint8_t idx, void *data, int count)
1054b7609e3dSSascha Wildner {
1055b7609e3dSSascha Wildner 	uint8_t *inbuf = data;
1056b7609e3dSSascha Wildner 	int i, ntries;
1057b7609e3dSSascha Wildner 
1058b7609e3dSSascha Wildner 	UGURU_WRITE(iot, ioh, UGURU_INDEX, idx);
1059b7609e3dSSascha Wildner 
1060b7609e3dSSascha Wildner 	for (i = 0; i < count; ++i) {
1061b7609e3dSSascha Wildner 		/*
1062b7609e3dSSascha Wildner 		 * wait for non-busy status before write
1063b7609e3dSSascha Wildner 		 * to the data port.
1064b7609e3dSSascha Wildner 		 */
1065b7609e3dSSascha Wildner 		ntries = 0;
1066b7609e3dSSascha Wildner 		while (UGURU_READ(iot, ioh, UGURU_INDEX) >> 1 & 1) {
1067b7609e3dSSascha Wildner 			if (++ntries > 65)
1068b7609e3dSSascha Wildner 				goto timeout;
1069b7609e3dSSascha Wildner 			DELAY(5);
1070b7609e3dSSascha Wildner 		}
1071b7609e3dSSascha Wildner 		/* dummy read to flush the internal buffer */
1072b7609e3dSSascha Wildner 		if (i == 0)
1073b7609e3dSSascha Wildner 			UGURU_READ(iot, ioh, UGURU_DATA);
1074b7609e3dSSascha Wildner 
1075b7609e3dSSascha Wildner 		UGURU_WRITE(iot, ioh, UGURU_DATA, *inbuf++);
1076b7609e3dSSascha Wildner 	}
1077b7609e3dSSascha Wildner 	return 0;
1078b7609e3dSSascha Wildner 
1079b7609e3dSSascha Wildner timeout:
1080b7609e3dSSascha Wildner 	DPRINTF(0, "uguru_write_multi: timeout 0x%.2x\n", idx);
1081b7609e3dSSascha Wildner 	return 1;
1082b7609e3dSSascha Wildner }
1083b7609e3dSSascha Wildner 
1084b7609e3dSSascha Wildner static int
uguru_read_multi(bus_space_tag_t iot,bus_space_handle_t ioh,void * data,int count)1085b7609e3dSSascha Wildner uguru_read_multi(bus_space_tag_t iot, bus_space_handle_t ioh,
1086b7609e3dSSascha Wildner     void *data, int count)
1087b7609e3dSSascha Wildner {
1088b7609e3dSSascha Wildner 	uint8_t *outbuf = data;
1089b7609e3dSSascha Wildner 	int i, ntries;
1090b7609e3dSSascha Wildner 
1091b7609e3dSSascha Wildner 	for (i = 0; i < count; ++i) {
1092b7609e3dSSascha Wildner 		/*
1093b7609e3dSSascha Wildner 		 * wait for valid status before read
1094b7609e3dSSascha Wildner 		 * from the data port.
1095b7609e3dSSascha Wildner 		 */
1096b7609e3dSSascha Wildner 		ntries = 0;
1097b7609e3dSSascha Wildner 		while (!(UGURU_READ(iot, ioh, UGURU_INDEX) & 1)) {
1098b7609e3dSSascha Wildner 			if (++ntries > 40) {
1099b7609e3dSSascha Wildner 				DPRINTF(0, "uguru_read_multi: timeout\n");
1100b7609e3dSSascha Wildner 				return 1;
1101b7609e3dSSascha Wildner 			}
1102b7609e3dSSascha Wildner 			DELAY(35);
1103b7609e3dSSascha Wildner 		}
1104b7609e3dSSascha Wildner 		*outbuf++ = UGURU_READ(iot, ioh, UGURU_DATA);
1105b7609e3dSSascha Wildner 	}
1106b7609e3dSSascha Wildner 	return 0;
1107b7609e3dSSascha Wildner }
1108