Deleted Added
full compact
smbus.c (153618) smbus.c (162234)
1/*-
2 * Copyright (c) 1998, 2001 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 *
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998, 2001 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/smbus/smbus.c 153618 2005-12-21 15:49:51Z ru $");
30__FBSDID("$FreeBSD: head/sys/dev/smbus/smbus.c 162234 2006-09-11 20:52:41Z jhb $");
31#include <sys/param.h>
32#include <sys/systm.h>
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
33#include <sys/lock.h>
34#include <sys/module.h>
34#include <sys/module.h>
35#include <sys/mutex.h>
35#include <sys/bus.h>
36
37#include <dev/smbus/smbconf.h>
38#include <dev/smbus/smbus.h>
39
40/*
36#include <sys/bus.h>
37
38#include <dev/smbus/smbconf.h>
39#include <dev/smbus/smbus.h>
40
41/*
41 * Autoconfiguration and support routines for the Philips serial I2C bus
42 * Autoconfiguration and support routines for System Management bus
42 */
43
43 */
44
44#define DEVTOSMBUS(dev) ((struct smbus_device*)device_get_ivars(dev))
45
46static devclass_t smbus_devclass;
47
48/*
49 * Device methods
50 */
51static int smbus_probe(device_t);
52static int smbus_attach(device_t);
45/*
46 * Device methods
47 */
48static int smbus_probe(device_t);
49static int smbus_attach(device_t);
50static int smbus_detach(device_t);
53
54static device_method_t smbus_methods[] = {
55 /* device interface */
56 DEVMETHOD(device_probe, smbus_probe),
57 DEVMETHOD(device_attach, smbus_attach),
51
52static device_method_t smbus_methods[] = {
53 /* device interface */
54 DEVMETHOD(device_probe, smbus_probe),
55 DEVMETHOD(device_attach, smbus_attach),
58 DEVMETHOD(device_detach, bus_generic_detach),
56 DEVMETHOD(device_detach, smbus_detach),
59
60 /* bus interface */
61 DEVMETHOD(bus_print_child, bus_generic_print_child),
62
63 { 0, 0 }
64};
65
57
58 /* bus interface */
59 DEVMETHOD(bus_print_child, bus_generic_print_child),
60
61 { 0, 0 }
62};
63
66static driver_t smbus_driver = {
64driver_t smbus_driver = {
67 "smbus",
68 smbus_methods,
69 sizeof(struct smbus_softc),
70};
71
65 "smbus",
66 smbus_methods,
67 sizeof(struct smbus_softc),
68};
69
70devclass_t smbus_devclass;
71
72/*
73 * At 'probe' time, we add all the devices which we know about to the
74 * bus. The generic attach routine will probe and attach them if they
75 * are alive.
76 */
77static int
78smbus_probe(device_t dev)
79{
72/*
73 * At 'probe' time, we add all the devices which we know about to the
74 * bus. The generic attach routine will probe and attach them if they
75 * are alive.
76 */
77static int
78smbus_probe(device_t dev)
79{
80
80 device_set_desc(dev, "System Management Bus");
81
82 return (0);
83}
84
85static int
86smbus_attach(device_t dev)
87{
81 device_set_desc(dev, "System Management Bus");
82
83 return (0);
84}
85
86static int
87smbus_attach(device_t dev)
88{
88 device_add_child(dev, NULL, -1);
89 struct smbus_softc *sc = device_get_softc(dev);
90
91 mtx_init(&sc->lock, device_get_nameunit(dev), "smbus", MTX_DEF);
92 bus_generic_probe(dev);
89 bus_generic_attach(dev);
90
91 return (0);
92}
93
93 bus_generic_attach(dev);
94
95 return (0);
96}
97
98static int
99smbus_detach(device_t dev)
100{
101 struct smbus_softc *sc = device_get_softc(dev);
102 int error;
103
104 error = bus_generic_detach(dev);
105 if (error)
106 return (error);
107 mtx_destroy(&sc->lock);
108
109 return (0);
110}
111
94void
95smbus_generic_intr(device_t dev, u_char devaddr, char low, char high)
96{
112void
113smbus_generic_intr(device_t dev, u_char devaddr, char low, char high)
114{
97 return;
98}
99
115}
116
100DRIVER_MODULE(smbus, iicsmb, smbus_driver, smbus_devclass, 0, 0);
101DRIVER_MODULE(smbus, bktr, smbus_driver, smbus_devclass, 0, 0);
102DRIVER_MODULE(smbus, intsmb, smbus_driver, smbus_devclass, 0, 0);
103DRIVER_MODULE(smbus, alpm, smbus_driver, smbus_devclass, 0, 0);
104DRIVER_MODULE(smbus, ichsmb, smbus_driver, smbus_devclass, 0, 0);
105DRIVER_MODULE(smbus, amdpm, smbus_driver, smbus_devclass, 0, 0);
106DRIVER_MODULE(smbus, amdsmb, smbus_driver, smbus_devclass, 0, 0);
107DRIVER_MODULE(smbus, nfsmb, smbus_driver, smbus_devclass, 0, 0);
108DRIVER_MODULE(smbus, viapropm, smbus_driver, smbus_devclass, 0, 0);
109MODULE_VERSION(smbus, SMBUS_MODVER);
117MODULE_VERSION(smbus, SMBUS_MODVER);