smsc.c revision 1.2.12.3 1 1.2.12.3 yamt /* $NetBSD: smsc.c,v 1.2.12.3 2007/10/27 11:31:56 yamt Exp $ */
2 1.2.12.2 yamt
3 1.2.12.2 yamt /*-
4 1.2.12.2 yamt * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 1.2.12.2 yamt * All rights reserved.
6 1.2.12.2 yamt *
7 1.2.12.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.2.12.2 yamt * by Brett Lymn.
9 1.2.12.2 yamt *
10 1.2.12.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.2.12.2 yamt * modification, are permitted provided that the following conditions
12 1.2.12.2 yamt * are met:
13 1.2.12.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.2.12.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.2.12.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.12.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.2.12.2 yamt * documentation and/or other materials provided with the distribution.
18 1.2.12.2 yamt * 3. All advertising materials mentioning features or use of this software
19 1.2.12.2 yamt * must display the following acknowledgement:
20 1.2.12.2 yamt * This product includes software developed by the NetBSD
21 1.2.12.2 yamt * Foundation, Inc. and its contributors.
22 1.2.12.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2.12.2 yamt * contributors may be used to endorse or promote products derived
24 1.2.12.2 yamt * from this software without specific prior written permission.
25 1.2.12.2 yamt *
26 1.2.12.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2.12.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2.12.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2.12.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2.12.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2.12.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2.12.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2.12.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2.12.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2.12.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2.12.2 yamt * POSSIBILITY OF SUCH DAMAGE.
37 1.2.12.2 yamt */
38 1.2.12.2 yamt
39 1.2.12.2 yamt /*
40 1.2.12.2 yamt * This is a driver for the Standard Microsystems Corp (SMSC)
41 1.2.12.2 yamt * LPC47B397 "super i/o" chip. This driver only handles the environment
42 1.2.12.2 yamt * monitoring capabilities of the chip, the other functions will be
43 1.2.12.2 yamt * probed/matched as "normal" PC hardware devices (serial ports, fdc, so on).
44 1.2.12.2 yamt * SMSC has not deigned to release a datasheet for this particular chip
45 1.2.12.2 yamt * (though they do for others they make) so this driver was written from
46 1.2.12.2 yamt * information contained in the comment block for the Linux driver.
47 1.2.12.2 yamt */
48 1.2.12.2 yamt
49 1.2.12.2 yamt #include <sys/cdefs.h>
50 1.2.12.3 yamt __KERNEL_RCSID(0, "$NetBSD: smsc.c,v 1.2.12.3 2007/10/27 11:31:56 yamt Exp $");
51 1.2.12.2 yamt
52 1.2.12.2 yamt #include <sys/param.h>
53 1.2.12.2 yamt #include <sys/systm.h>
54 1.2.12.2 yamt #include <sys/kernel.h>
55 1.2.12.2 yamt #include <sys/malloc.h>
56 1.2.12.2 yamt #include <sys/proc.h>
57 1.2.12.2 yamt #include <sys/device.h>
58 1.2.12.2 yamt #include <sys/conf.h>
59 1.2.12.2 yamt #include <sys/time.h>
60 1.2.12.2 yamt
61 1.2.12.3 yamt #include <sys/bus.h>
62 1.2.12.2 yamt
63 1.2.12.2 yamt #include <dev/isa/isareg.h>
64 1.2.12.2 yamt #include <dev/isa/isavar.h>
65 1.2.12.2 yamt
66 1.2.12.2 yamt #include <dev/sysmon/sysmonvar.h>
67 1.2.12.2 yamt
68 1.2.12.2 yamt #include <dev/isa/smscvar.h>
69 1.2.12.2 yamt
70 1.2.12.3 yamt #include <sys/intr.h>
71 1.2.12.2 yamt
72 1.2.12.2 yamt #if defined(LMDEBUG)
73 1.2.12.2 yamt #define DPRINTF(x) do { printf x; } while (0)
74 1.2.12.2 yamt #else
75 1.2.12.2 yamt #define DPRINTF(x)
76 1.2.12.2 yamt #endif
77 1.2.12.2 yamt
78 1.2.12.2 yamt int smsc_probe(struct device *, struct cfdata *, void *);
79 1.2.12.2 yamt void smsc_attach(struct device *, struct device *, void *);
80 1.2.12.3 yamt int smsc_detach(struct device *, int);
81 1.2.12.2 yamt static uint8_t smsc_readreg(struct smsc_softc *, int);
82 1.2.12.2 yamt /*static void smsc_writereg(struct smsc_softc *, int, int);*/
83 1.2.12.2 yamt void smsc_setup(struct smsc_softc *);
84 1.2.12.2 yamt
85 1.2.12.2 yamt static int smsc_gtredata(struct sysmon_envsys *, envsys_data_t *);
86 1.2.12.2 yamt
87 1.2.12.2 yamt CFATTACH_DECL(smsc, sizeof(struct smsc_softc),
88 1.2.12.3 yamt smsc_probe, smsc_attach, smsc_detach, NULL);
89 1.2.12.2 yamt
90 1.2.12.2 yamt struct smsc_sysmon {
91 1.2.12.2 yamt struct sysmon_envsys sme;
92 1.2.12.2 yamt struct smsc_softc *sc;
93 1.2.12.2 yamt envsys_data_t smsc_sensor[];
94 1.2.12.2 yamt };
95 1.2.12.2 yamt
96 1.2.12.2 yamt /*
97 1.2.12.2 yamt * Probe for the SMSC Super I/O chip
98 1.2.12.2 yamt */
99 1.2.12.2 yamt int
100 1.2.12.2 yamt smsc_probe(struct device *parent, struct cfdata *match, void *aux)
101 1.2.12.2 yamt {
102 1.2.12.2 yamt bus_space_handle_t ioh;
103 1.2.12.2 yamt struct isa_attach_args *ia = aux;
104 1.2.12.2 yamt int rv;
105 1.2.12.2 yamt uint8_t cr;
106 1.2.12.2 yamt
107 1.2.12.2 yamt /* Must supply an address */
108 1.2.12.2 yamt if (ia->ia_nio < 1)
109 1.2.12.2 yamt return 0;
110 1.2.12.2 yamt
111 1.2.12.2 yamt if (ISA_DIRECT_CONFIG(ia))
112 1.2.12.2 yamt return 0;
113 1.2.12.2 yamt
114 1.2.12.2 yamt if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
115 1.2.12.2 yamt return 0;
116 1.2.12.2 yamt
117 1.2.12.2 yamt if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 2, 0, &ioh))
118 1.2.12.2 yamt return 0;
119 1.2.12.2 yamt
120 1.2.12.2 yamt /* To get the device ID we must enter config mode... */
121 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_START);
122 1.2.12.2 yamt
123 1.2.12.2 yamt /* Then select the device id register */
124 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_DEVICE_ID);
125 1.2.12.2 yamt
126 1.2.12.2 yamt /* Finally, read the id from the chip */
127 1.2.12.2 yamt cr = bus_space_read_1(ia->ia_iot, ioh, SMSC_DATA);
128 1.2.12.2 yamt
129 1.2.12.2 yamt /* Exit config mode, apparently this is important to do */
130 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_END);
131 1.2.12.2 yamt
132 1.2.12.2 yamt if (cr == SMSC_ID)
133 1.2.12.2 yamt rv = 1;
134 1.2.12.2 yamt else
135 1.2.12.2 yamt rv = 0;
136 1.2.12.2 yamt
137 1.2.12.2 yamt DPRINTF(("smsc: rv = %d, cr = %x\n", rv, cr));
138 1.2.12.2 yamt
139 1.2.12.2 yamt bus_space_unmap(ia->ia_iot, ioh, 2);
140 1.2.12.2 yamt
141 1.2.12.2 yamt if (rv) {
142 1.2.12.2 yamt ia->ia_nio = 1;
143 1.2.12.2 yamt ia->ia_io[0].ir_size = 2;
144 1.2.12.2 yamt
145 1.2.12.2 yamt ia->ia_niomem = 0;
146 1.2.12.2 yamt ia->ia_nirq = 0;
147 1.2.12.2 yamt ia->ia_ndrq = 0;
148 1.2.12.2 yamt }
149 1.2.12.2 yamt
150 1.2.12.2 yamt return rv;
151 1.2.12.2 yamt }
152 1.2.12.2 yamt
153 1.2.12.2 yamt /*
154 1.2.12.2 yamt * Get the base address for the monitoring registers and set up the
155 1.2.12.2 yamt * env sysmon framework.
156 1.2.12.2 yamt */
157 1.2.12.2 yamt void
158 1.2.12.2 yamt smsc_attach(struct device *parent, struct device *self, void *aux)
159 1.2.12.2 yamt {
160 1.2.12.2 yamt struct smsc_softc *smsc_sc = (void *)self;
161 1.2.12.2 yamt struct isa_attach_args *ia = aux;
162 1.2.12.2 yamt bus_space_handle_t ioh;
163 1.2.12.2 yamt uint8_t rev, msb, lsb;
164 1.2.12.2 yamt unsigned address;
165 1.2.12.2 yamt
166 1.2.12.2 yamt smsc_sc->smsc_iot = ia->ia_iot;
167 1.2.12.2 yamt
168 1.2.12.2 yamt /* To attach we need to find the actual i/o register space,
169 1.2.12.2 yamt map the base registers in first. */
170 1.2.12.2 yamt if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 2, 0,
171 1.2.12.2 yamt &ioh)) {
172 1.2.12.2 yamt aprint_error(": can't map base i/o space\n");
173 1.2.12.2 yamt return;
174 1.2.12.2 yamt }
175 1.2.12.2 yamt
176 1.2.12.2 yamt /* Enter config mode. */
177 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_START);
178 1.2.12.2 yamt
179 1.2.12.2 yamt /* While we have the base registers mapped, grab the chip revision */
180 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_DEVICE_REVISION);
181 1.2.12.2 yamt rev = bus_space_read_1(ia->ia_iot, ioh, SMSC_DATA);
182 1.2.12.2 yamt
183 1.2.12.2 yamt /* Select the correct logical device */
184 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_LOGICAL_DEV_SEL);
185 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_DATA, SMSC_LOGICAL_DEVICE);
186 1.2.12.2 yamt
187 1.2.12.2 yamt /* Read the base address for the registers. */
188 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_IO_BASE_MSB);
189 1.2.12.2 yamt msb = bus_space_read_1(ia->ia_iot, ioh, SMSC_DATA);
190 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_IO_BASE_LSB);
191 1.2.12.2 yamt lsb = bus_space_read_1(ia->ia_iot, ioh, SMSC_DATA);
192 1.2.12.2 yamt address = (msb << 8) | lsb;
193 1.2.12.2 yamt
194 1.2.12.2 yamt /* Exit config mode */
195 1.2.12.2 yamt bus_space_write_1(ia->ia_iot, ioh, SMSC_ADDR, SMSC_CONFIG_END);
196 1.2.12.2 yamt
197 1.2.12.2 yamt bus_space_unmap(ia->ia_iot, ioh, 2);
198 1.2.12.2 yamt
199 1.2.12.2 yamt /* Map the i/o space for the registers. */
200 1.2.12.2 yamt if (bus_space_map(ia->ia_iot, address, 2, 0, &smsc_sc->smsc_ioh)) {
201 1.2.12.2 yamt aprint_error(": can't map register i/o space\n");
202 1.2.12.2 yamt return;
203 1.2.12.2 yamt }
204 1.2.12.2 yamt
205 1.2.12.2 yamt aprint_normal(": monitor registers at 0x%04x (rev. %u)\n",
206 1.2.12.2 yamt address, rev);
207 1.2.12.2 yamt
208 1.2.12.2 yamt smsc_setup(smsc_sc);
209 1.2.12.2 yamt }
210 1.2.12.2 yamt
211 1.2.12.3 yamt int
212 1.2.12.3 yamt smsc_detach(struct device *self, int flags)
213 1.2.12.3 yamt {
214 1.2.12.3 yamt struct smsc_softc *sc = device_private(self);
215 1.2.12.3 yamt
216 1.2.12.3 yamt sysmon_envsys_unregister(sc->smsc_sysmon);
217 1.2.12.3 yamt bus_space_unmap(sc->smsc_iot, sc->smsc_ioh, 2);
218 1.2.12.3 yamt return 0;
219 1.2.12.3 yamt }
220 1.2.12.2 yamt
221 1.2.12.2 yamt /*
222 1.2.12.2 yamt * Read the value of the given register
223 1.2.12.2 yamt */
224 1.2.12.2 yamt static uint8_t
225 1.2.12.2 yamt smsc_readreg(struct smsc_softc *sc, int reg)
226 1.2.12.2 yamt {
227 1.2.12.2 yamt bus_space_write_1(sc->smsc_iot, sc->smsc_ioh, SMSC_ADDR, reg);
228 1.2.12.2 yamt return bus_space_read_1(sc->smsc_iot, sc->smsc_ioh, SMSC_DATA);
229 1.2.12.2 yamt }
230 1.2.12.2 yamt
231 1.2.12.2 yamt
232 1.2.12.2 yamt /*
233 1.2.12.2 yamt * Write the given value to the given register - here just for completeness
234 1.2.12.2 yamt * it is unused in the current code.
235 1.2.12.2 yamt
236 1.2.12.2 yamt static void
237 1.2.12.2 yamt smsc_writereg (struct smsc_softc *sc, int reg, int val)
238 1.2.12.2 yamt {
239 1.2.12.2 yamt bus_space_write_1(sc->smsc_iot, sc->smsc_ioh, SMSC_ADDR, reg);
240 1.2.12.2 yamt bus_space_write_1(sc->smsc_iot, sc->smsc_ioh, SMSC_DATA, val);
241 1.2.12.2 yamt } */
242 1.2.12.2 yamt
243 1.2.12.2 yamt /* convert temperature read from the chip to micro kelvin */
244 1.2.12.2 yamt static inline int
245 1.2.12.2 yamt smsc_temp2muk(uint8_t t)
246 1.2.12.2 yamt {
247 1.2.12.2 yamt int temp=t;
248 1.2.12.2 yamt
249 1.2.12.2 yamt return temp * 1000000 + 273150000U;
250 1.2.12.2 yamt }
251 1.2.12.2 yamt
252 1.2.12.2 yamt /*
253 1.2.12.2 yamt * convert register value read from chip into rpm using:
254 1.2.12.2 yamt *
255 1.2.12.2 yamt * RPM = 60/(Count * 11.111us)
256 1.2.12.2 yamt *
257 1.2.12.2 yamt * 1/1.1111us = 90kHz
258 1.2.12.2 yamt *
259 1.2.12.2 yamt */
260 1.2.12.2 yamt static inline int
261 1.2.12.2 yamt smsc_reg2rpm(unsigned int r)
262 1.2.12.2 yamt {
263 1.2.12.2 yamt unsigned long rpm;
264 1.2.12.2 yamt
265 1.2.12.2 yamt if (r == 0x0)
266 1.2.12.2 yamt return 0;
267 1.2.12.2 yamt
268 1.2.12.2 yamt rpm = (90000 * 60) / ((unsigned long) r);
269 1.2.12.2 yamt return (int) rpm;
270 1.2.12.2 yamt }
271 1.2.12.2 yamt
272 1.2.12.2 yamt /* min and max temperatures in uK */
273 1.2.12.2 yamt #define SMSC_MIN_TEMP_UK ((-127 * 1000000) + 273150000)
274 1.2.12.2 yamt #define SMSC_MAX_TEMP_UK ((127 * 1000000) + 273150000)
275 1.2.12.2 yamt
276 1.2.12.2 yamt /*
277 1.2.12.2 yamt * Set up the environment monitoring framework for all the devices
278 1.2.12.2 yamt * that we monitor.
279 1.2.12.2 yamt */
280 1.2.12.2 yamt void
281 1.2.12.2 yamt smsc_setup(struct smsc_softc *sc)
282 1.2.12.2 yamt {
283 1.2.12.2 yamt struct smsc_sysmon *datap;
284 1.2.12.2 yamt int error, i;
285 1.2.12.2 yamt char label[8];
286 1.2.12.2 yamt envsys_data_t *edata;
287 1.2.12.2 yamt
288 1.2.12.2 yamt datap = malloc(sizeof(struct sysmon_envsys) + SMSC_MAX_SENSORS *
289 1.2.12.2 yamt sizeof(envsys_data_t) + sizeof(void *),
290 1.2.12.2 yamt M_DEVBUF, M_WAITOK | M_ZERO);
291 1.2.12.2 yamt
292 1.2.12.2 yamt for (i = 0; i < 4; i++) {
293 1.2.12.2 yamt edata = &datap->smsc_sensor[i];
294 1.2.12.2 yamt sprintf(label, "Temp-%d", i + 1);
295 1.2.12.2 yamt strlcpy(edata->desc, label, sizeof(edata->desc));
296 1.2.12.2 yamt edata->units = ENVSYS_STEMP;
297 1.2.12.2 yamt edata->sensor = i;
298 1.2.12.2 yamt edata->state = ENVSYS_SVALID;
299 1.2.12.2 yamt switch (i) {
300 1.2.12.2 yamt case 0:
301 1.2.12.2 yamt sc->regs[i] = SMSC_TEMP1;
302 1.2.12.2 yamt break;
303 1.2.12.2 yamt
304 1.2.12.2 yamt case 1:
305 1.2.12.2 yamt sc->regs[i] = SMSC_TEMP2;
306 1.2.12.2 yamt break;
307 1.2.12.2 yamt
308 1.2.12.2 yamt case 2:
309 1.2.12.2 yamt sc->regs[i] = SMSC_TEMP3;
310 1.2.12.2 yamt break;
311 1.2.12.2 yamt
312 1.2.12.2 yamt case 3:
313 1.2.12.2 yamt sc->regs[i] = SMSC_TEMP4;
314 1.2.12.2 yamt break;
315 1.2.12.2 yamt }
316 1.2.12.2 yamt
317 1.2.12.2 yamt }
318 1.2.12.2 yamt
319 1.2.12.2 yamt for (i = 4; i < SMSC_MAX_SENSORS; i++) {
320 1.2.12.2 yamt edata = &datap->smsc_sensor[i];
321 1.2.12.2 yamt sprintf(label, "Fan-%d", i - 3);
322 1.2.12.2 yamt strlcpy(edata->desc, label, sizeof(edata->desc));
323 1.2.12.2 yamt edata->units = ENVSYS_SFANRPM;
324 1.2.12.2 yamt edata->sensor = i;
325 1.2.12.2 yamt edata->units = ENVSYS_SFANRPM;
326 1.2.12.2 yamt edata->state = ENVSYS_SVALID;
327 1.2.12.2 yamt
328 1.2.12.2 yamt switch (i) {
329 1.2.12.2 yamt case 4:
330 1.2.12.2 yamt sc->regs[i] = SMSC_FAN1_LSB;
331 1.2.12.2 yamt break;
332 1.2.12.2 yamt
333 1.2.12.2 yamt case 5:
334 1.2.12.2 yamt sc->regs[i] = SMSC_FAN2_LSB;
335 1.2.12.2 yamt break;
336 1.2.12.2 yamt
337 1.2.12.2 yamt case 6:
338 1.2.12.2 yamt sc->regs[i] = SMSC_FAN3_LSB;
339 1.2.12.2 yamt break;
340 1.2.12.2 yamt
341 1.2.12.2 yamt case 7:
342 1.2.12.2 yamt sc->regs[i] = SMSC_FAN4_LSB;
343 1.2.12.2 yamt break;
344 1.2.12.2 yamt
345 1.2.12.2 yamt default:
346 1.2.12.2 yamt aprint_error(": more fans than expected");
347 1.2.12.2 yamt break;
348 1.2.12.2 yamt }
349 1.2.12.2 yamt }
350 1.2.12.2 yamt
351 1.2.12.2 yamt sc->smsc_sysmon = &datap->sme;
352 1.2.12.2 yamt datap->sme.sme_nsensors = SMSC_MAX_SENSORS;
353 1.2.12.2 yamt datap->sme.sme_sensor_data = datap->smsc_sensor;
354 1.2.12.2 yamt datap->sme.sme_name = sc->sc_dev.dv_xname;
355 1.2.12.2 yamt datap->sme.sme_cookie = sc;
356 1.2.12.2 yamt datap->sme.sme_gtredata = smsc_gtredata;
357 1.2.12.2 yamt
358 1.2.12.2 yamt if ((error = sysmon_envsys_register(&datap->sme)) != 0) {
359 1.2.12.2 yamt aprint_error("%s: unable to register with sysmon (%d)\n",
360 1.2.12.2 yamt sc->sc_dev.dv_xname, error);
361 1.2.12.2 yamt return;
362 1.2.12.2 yamt }
363 1.2.12.2 yamt
364 1.2.12.2 yamt }
365 1.2.12.2 yamt
366 1.2.12.2 yamt /*
367 1.2.12.2 yamt * Get the data for the requested sensor, update the sysmon structure
368 1.2.12.2 yamt * with the retrieved value.
369 1.2.12.2 yamt */
370 1.2.12.2 yamt static int
371 1.2.12.2 yamt smsc_gtredata(struct sysmon_envsys *sme, envsys_data_t *edata)
372 1.2.12.2 yamt {
373 1.2.12.2 yamt struct smsc_softc *sc = sme->sme_cookie;
374 1.2.12.2 yamt int i, reg;
375 1.2.12.2 yamt unsigned int rpm;
376 1.2.12.2 yamt uint8_t msb, lsb;
377 1.2.12.2 yamt
378 1.2.12.2 yamt i = edata->sensor;
379 1.2.12.2 yamt reg = sc->regs[i];
380 1.2.12.2 yamt
381 1.2.12.2 yamt switch (edata->units) {
382 1.2.12.2 yamt case ENVSYS_STEMP:
383 1.2.12.2 yamt edata->value_cur = smsc_temp2muk(smsc_readreg(sc, reg));
384 1.2.12.2 yamt break;
385 1.2.12.2 yamt
386 1.2.12.2 yamt case ENVSYS_SFANRPM:
387 1.2.12.2 yamt /* reading lsb first locks msb... */
388 1.2.12.2 yamt lsb = smsc_readreg(sc, reg);
389 1.2.12.2 yamt msb = smsc_readreg(sc, reg + 1); /* XXX note explicit
390 1.2.12.2 yamt assumption that msb is
391 1.2.12.2 yamt the next register along */
392 1.2.12.2 yamt rpm = (msb << 8) | lsb;
393 1.2.12.2 yamt edata->value_cur = smsc_reg2rpm(rpm);
394 1.2.12.2 yamt break;
395 1.2.12.2 yamt }
396 1.2.12.2 yamt
397 1.2.12.2 yamt edata->state = ENVSYS_SVALID;
398 1.2.12.2 yamt return 0;
399 1.2.12.2 yamt }
400