Deleted Added
full compact
iicbb.c (256281) iicbb.c (266105)
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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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#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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/10/sys/dev/iicbus/iicbb.c 232365 2012-03-01 20:58:20Z kan $");
28__FBSDID("$FreeBSD: stable/10/sys/dev/iicbus/iicbb.c 266105 2014-05-15 01:27:53Z loos $");
29
30/*
31 * Generic I2C bit-banging code
32 *
33 * Example:
34 *
35 * iicbus
36 * / \
37 * iicbb pcf
38 * | \
39 * bti2c lpbb
40 *
41 * From Linux I2C generic interface
42 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
43 *
44 */
45
29
30/*
31 * Generic I2C bit-banging code
32 *
33 * Example:
34 *
35 * iicbus
36 * / \
37 * iicbb pcf
38 * | \
39 * bti2c lpbb
40 *
41 * From Linux I2C generic interface
42 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
43 *
44 */
45
46#include "opt_platform.h"
47
46#include <sys/param.h>
47#include <sys/kernel.h>
48#include <sys/systm.h>
49#include <sys/module.h>
50#include <sys/bus.h>
51#include <sys/uio.h>
52
48#include <sys/param.h>
49#include <sys/kernel.h>
50#include <sys/systm.h>
51#include <sys/module.h>
52#include <sys/bus.h>
53#include <sys/uio.h>
54
55#ifdef FDT
56#include <dev/ofw/ofw_bus.h>
57#include <dev/ofw/ofw_bus_subr.h>
58#include <dev/fdt/fdt_common.h>
59#endif
53
54#include <dev/iicbus/iiconf.h>
55#include <dev/iicbus/iicbus.h>
56
57#include <dev/smbus/smbconf.h>
58
59#include "iicbus_if.h"
60#include "iicbb_if.h"

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

72
73static int iicbb_callback(device_t, int, caddr_t);
74static int iicbb_start(device_t, u_char, int);
75static int iicbb_stop(device_t);
76static int iicbb_write(device_t, const char *, int, int *, int);
77static int iicbb_read(device_t, char *, int, int *, int, int);
78static int iicbb_reset(device_t, u_char, u_char, u_char *);
79static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs);
60
61#include <dev/iicbus/iiconf.h>
62#include <dev/iicbus/iicbus.h>
63
64#include <dev/smbus/smbconf.h>
65
66#include "iicbus_if.h"
67#include "iicbb_if.h"

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

79
80static int iicbb_callback(device_t, int, caddr_t);
81static int iicbb_start(device_t, u_char, int);
82static int iicbb_stop(device_t);
83static int iicbb_write(device_t, const char *, int, int *, int);
84static int iicbb_read(device_t, char *, int, int *, int, int);
85static int iicbb_reset(device_t, u_char, u_char, u_char *);
86static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs);
87#ifdef FDT
88static phandle_t iicbb_get_node(device_t, device_t);
89#endif
80
81static device_method_t iicbb_methods[] = {
82 /* device interface */
83 DEVMETHOD(device_probe, iicbb_probe),
84 DEVMETHOD(device_attach, iicbb_attach),
85 DEVMETHOD(device_detach, iicbb_detach),
86
87 /* bus interface */

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

93 DEVMETHOD(iicbus_start, iicbb_start),
94 DEVMETHOD(iicbus_repeated_start, iicbb_start),
95 DEVMETHOD(iicbus_stop, iicbb_stop),
96 DEVMETHOD(iicbus_write, iicbb_write),
97 DEVMETHOD(iicbus_read, iicbb_read),
98 DEVMETHOD(iicbus_reset, iicbb_reset),
99 DEVMETHOD(iicbus_transfer, iicbb_transfer),
100
90
91static device_method_t iicbb_methods[] = {
92 /* device interface */
93 DEVMETHOD(device_probe, iicbb_probe),
94 DEVMETHOD(device_attach, iicbb_attach),
95 DEVMETHOD(device_detach, iicbb_detach),
96
97 /* bus interface */

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

103 DEVMETHOD(iicbus_start, iicbb_start),
104 DEVMETHOD(iicbus_repeated_start, iicbb_start),
105 DEVMETHOD(iicbus_stop, iicbb_stop),
106 DEVMETHOD(iicbus_write, iicbb_write),
107 DEVMETHOD(iicbus_read, iicbb_read),
108 DEVMETHOD(iicbus_reset, iicbb_reset),
109 DEVMETHOD(iicbus_transfer, iicbb_transfer),
110
111#ifdef FDT
112 /* ofw_bus interface */
113 DEVMETHOD(ofw_bus_get_node, iicbb_get_node),
114#endif
115
101 { 0, 0 }
102};
103
104driver_t iicbb_driver = {
105 "iicbb",
106 iicbb_methods,
107 sizeof(struct iicbb_softc),
108};

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

149 child = sc->iicbus;
150 bus_generic_detach(dev);
151 if (child)
152 device_delete_child(dev, child);
153
154 return (0);
155}
156
116 { 0, 0 }
117};
118
119driver_t iicbb_driver = {
120 "iicbb",
121 iicbb_methods,
122 sizeof(struct iicbb_softc),
123};

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

164 child = sc->iicbus;
165 bus_generic_detach(dev);
166 if (child)
167 device_delete_child(dev, child);
168
169 return (0);
170}
171
172#ifdef FDT
173static phandle_t
174iicbb_get_node(device_t bus, device_t dev)
175{
176
177 /* We only have one child, the I2C bus, which needs our own node. */
178 return (ofw_bus_get_node(bus));
179}
180#endif
181
157static void
158iicbb_child_detached( device_t dev, device_t child )
159{
160 struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev);
161
162 if (child == sc->iicbus)
163 sc->iicbus = NULL;
164}

--- 282 unchanged lines hidden ---
182static void
183iicbb_child_detached( device_t dev, device_t child )
184{
185 struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev);
186
187 if (child == sc->iicbus)
188 sc->iicbus = NULL;
189}

--- 282 unchanged lines hidden ---