Deleted Added
full compact
iiconf.c (59760) iiconf.c (93023)
1/*-
2 * Copyright (c) 1998 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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 *
1/*-
2 * Copyright (c) 1998 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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/dev/iicbus/iiconf.c 59760 2000-04-29 15:36:14Z phk $
26 * $FreeBSD: head/sys/dev/iicbus/iiconf.c 93023 2002-03-23 15:49:15Z nsouch $
27 *
28 */
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33
34#include <dev/iicbus/iiconf.h>

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

45
46 /* call owner's intr routine */
47 if (sc->owner)
48 IICBUS_INTR(sc->owner, event, buf);
49
50 return;
51}
52
27 *
28 */
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33
34#include <dev/iicbus/iiconf.h>

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

45
46 /* call owner's intr routine */
47 if (sc->owner)
48 IICBUS_INTR(sc->owner, event, buf);
49
50 return;
51}
52
53/*
54 * iicbus_alloc_bus()
55 *
56 * Allocate a new bus connected to the given parent device
57 */
58device_t
59iicbus_alloc_bus(device_t parent)
60{
61 device_t child;
62
63 /* add the bus to the parent */
64 child = device_add_child(parent, "iicbus", -1);
65
66 return (child);
67}
68
69static int
70iicbus_poll(struct iicbus_softc *sc, int how)
71{
72 int error;
73
74 switch (how) {
75 case (IIC_WAIT | IIC_INTR):
76 error = tsleep(sc, IICPRI|PCATCH, "iicreq", 0);

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

341 return (error);
342
343 error = iicbus_read(bus, buf, len, read, IIC_LAST_READ, 0);
344
345 iicbus_stop(bus);
346
347 return (error);
348}
53static int
54iicbus_poll(struct iicbus_softc *sc, int how)
55{
56 int error;
57
58 switch (how) {
59 case (IIC_WAIT | IIC_INTR):
60 error = tsleep(sc, IICPRI|PCATCH, "iicreq", 0);

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

325 return (error);
326
327 error = iicbus_read(bus, buf, len, read, IIC_LAST_READ, 0);
328
329 iicbus_stop(bus);
330
331 return (error);
332}
349
350/*
351 * iicbus_get_addr()
352 *
353 * Get the I2C 7 bits address of the device
354 */
355u_char
356iicbus_get_addr(device_t dev)
357{
358 uintptr_t addr;
359 device_t parent = device_get_parent(dev);
360
361 BUS_READ_IVAR(parent, dev, IICBUS_IVAR_ADDR, &addr);
362
363 return ((u_char)addr);
364}
365