| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: smsc.c,v 1.10 2011/06/20 18:12:54 pgoyette Exp $ */ | | 1 | /* $NetBSD: smsc.c,v 1.11 2011/07/31 16:18:54 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Brett Lymn. | | 8 | * by Brett Lymn. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -30,31 +30,32 @@ | | | @@ -30,31 +30,32 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * This is a driver for the Standard Microsystems Corp (SMSC) | | 33 | * This is a driver for the Standard Microsystems Corp (SMSC) |
34 | * LPC47B397 "super i/o" chip. This driver only handles the environment | | 34 | * LPC47B397 "super i/o" chip. This driver only handles the environment |
35 | * monitoring capabilities of the chip, the other functions will be | | 35 | * monitoring capabilities of the chip, the other functions will be |
36 | * probed/matched as "normal" PC hardware devices (serial ports, fdc, so on). | | 36 | * probed/matched as "normal" PC hardware devices (serial ports, fdc, so on). |
37 | * SMSC has not deigned to release a datasheet for this particular chip | | 37 | * SMSC has not deigned to release a datasheet for this particular chip |
38 | * (though they do for others they make) so this driver was written from | | 38 | * (though they do for others they make) so this driver was written from |
39 | * information contained in the comment block for the Linux driver. | | 39 | * information contained in the comment block for the Linux driver. |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: smsc.c,v 1.10 2011/06/20 18:12:54 pgoyette Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: smsc.c,v 1.11 2011/07/31 16:18:54 jmcneill Exp $"); |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/systm.h> | | 46 | #include <sys/systm.h> |
47 | #include <sys/device.h> | | 47 | #include <sys/device.h> |
| | | 48 | #include <sys/module.h> |
48 | #include <sys/bus.h> | | 49 | #include <sys/bus.h> |
49 | | | 50 | |
50 | #include <dev/isa/isareg.h> | | 51 | #include <dev/isa/isareg.h> |
51 | #include <dev/isa/isavar.h> | | 52 | #include <dev/isa/isavar.h> |
52 | | | 53 | |
53 | #include <dev/sysmon/sysmonvar.h> | | 54 | #include <dev/sysmon/sysmonvar.h> |
54 | #include <dev/isa/smscvar.h> | | 55 | #include <dev/isa/smscvar.h> |
55 | | | 56 | |
56 | #if defined(LMDEBUG) | | 57 | #if defined(LMDEBUG) |
57 | #define DPRINTF(x) do { printf x; } while (0) | | 58 | #define DPRINTF(x) do { printf x; } while (0) |
58 | #else | | 59 | #else |
59 | #define DPRINTF(x) | | 60 | #define DPRINTF(x) |
60 | #endif | | 61 | #endif |
| @@ -331,13 +332,42 @@ smsc_refresh(struct sysmon_envsys *sme, | | | @@ -331,13 +332,42 @@ smsc_refresh(struct sysmon_envsys *sme, |
331 | edata->value_cur = | | 332 | edata->value_cur = |
332 | smsc_temp2muk(smsc_readreg(sc->sc_iot, sc->sc_ioh, reg)); | | 333 | smsc_temp2muk(smsc_readreg(sc->sc_iot, sc->sc_ioh, reg)); |
333 | break; | | 334 | break; |
334 | | | 335 | |
335 | case ENVSYS_SFANRPM: | | 336 | case ENVSYS_SFANRPM: |
336 | /* reading lsb first locks msb... */ | | 337 | /* reading lsb first locks msb... */ |
337 | lsb = smsc_readreg(sc->sc_iot, sc->sc_ioh, reg); | | 338 | lsb = smsc_readreg(sc->sc_iot, sc->sc_ioh, reg); |
338 | msb = smsc_readreg(sc->sc_iot, sc->sc_ioh, reg + 1); | | 339 | msb = smsc_readreg(sc->sc_iot, sc->sc_ioh, reg + 1); |
339 | rpm = (msb << 8) | lsb; | | 340 | rpm = (msb << 8) | lsb; |
340 | edata->value_cur = smsc_reg2rpm(rpm); | | 341 | edata->value_cur = smsc_reg2rpm(rpm); |
341 | break; | | 342 | break; |
342 | } | | 343 | } |
343 | } | | 344 | } |
| | | 345 | |
| | | 346 | MODULE(MODULE_CLASS_DRIVER, smsc, NULL); |
| | | 347 | |
| | | 348 | #ifdef _MODULE |
| | | 349 | #include "ioconf.c" |
| | | 350 | #endif |
| | | 351 | |
| | | 352 | static int |
| | | 353 | smsc_modcmd(modcmd_t cmd, void *opaque) |
| | | 354 | { |
| | | 355 | int error = 0; |
| | | 356 | |
| | | 357 | switch (cmd) { |
| | | 358 | case MODULE_CMD_INIT: |
| | | 359 | #ifdef _MODULE |
| | | 360 | error = config_init_component(cfdriver_ioconf_smsc, |
| | | 361 | cfattach_ioconf_smsc, cfdata_ioconf_smsc); |
| | | 362 | #endif |
| | | 363 | return error; |
| | | 364 | case MODULE_CMD_FINI: |
| | | 365 | #ifdef _MODULE |
| | | 366 | error = config_fini_component(cfdriver_ioconf_smsc, |
| | | 367 | cfattach_ioconf_smsc, cfdata_ioconf_smsc); |
| | | 368 | #endif |
| | | 369 | return error; |
| | | 370 | default: |
| | | 371 | return ENOTTY; |
| | | 372 | } |
| | | 373 | } |