1c3e2dc6bSNicolas Souchu /*-
24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni *
4c17d4340SNicolas Souchu * Copyright (c) 1998, 2001 Nicolas Souchu
5c3e2dc6bSNicolas Souchu * All rights reserved.
6c3e2dc6bSNicolas Souchu *
7c3e2dc6bSNicolas Souchu * Redistribution and use in source and binary forms, with or without
8c3e2dc6bSNicolas Souchu * modification, are permitted provided that the following conditions
9c3e2dc6bSNicolas Souchu * are met:
10c3e2dc6bSNicolas Souchu * 1. Redistributions of source code must retain the above copyright
11c3e2dc6bSNicolas Souchu * notice, this list of conditions and the following disclaimer.
12c3e2dc6bSNicolas Souchu * 2. Redistributions in binary form must reproduce the above copyright
13c3e2dc6bSNicolas Souchu * notice, this list of conditions and the following disclaimer in the
14c3e2dc6bSNicolas Souchu * documentation and/or other materials provided with the distribution.
15c3e2dc6bSNicolas Souchu *
16c3e2dc6bSNicolas Souchu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17c3e2dc6bSNicolas Souchu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18c3e2dc6bSNicolas Souchu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19c3e2dc6bSNicolas Souchu * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20c3e2dc6bSNicolas Souchu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21c3e2dc6bSNicolas Souchu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22c3e2dc6bSNicolas Souchu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23c3e2dc6bSNicolas Souchu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24c3e2dc6bSNicolas Souchu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25c3e2dc6bSNicolas Souchu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26c3e2dc6bSNicolas Souchu * SUCH DAMAGE.
27c3e2dc6bSNicolas Souchu */
28c3e2dc6bSNicolas Souchu
29aad970f1SDavid E. O'Brien #include <sys/cdefs.h>
30c3e2dc6bSNicolas Souchu /*
31c3e2dc6bSNicolas Souchu * Autoconfiguration and support routines for the Philips serial I2C bus
32c3e2dc6bSNicolas Souchu */
33c3e2dc6bSNicolas Souchu
34c3e2dc6bSNicolas Souchu #include <sys/param.h>
35c3e2dc6bSNicolas Souchu #include <sys/systm.h>
36c3e2dc6bSNicolas Souchu #include <sys/kernel.h>
37ddfc9c4cSWarner Losh #include <sys/bus.h>
38313f8941SJohn Baldwin #include <sys/lock.h>
39d4fa6840SWarner Losh #include <sys/malloc.h>
40c3e2dc6bSNicolas Souchu #include <sys/module.h>
41313f8941SJohn Baldwin #include <sys/mutex.h>
423bb6bf47SLuiz Otavio O Souza #include <sys/rman.h>
43ddfc9c4cSWarner Losh #include <sys/sbuf.h>
44844aff82SIan Lepore #include <sys/sysctl.h>
45c3e2dc6bSNicolas Souchu
46c3e2dc6bSNicolas Souchu #include <dev/iicbus/iiconf.h>
47c3e2dc6bSNicolas Souchu #include <dev/iicbus/iicbus.h>
48c3e2dc6bSNicolas Souchu
49c3e2dc6bSNicolas Souchu #include "iicbus_if.h"
50c3e2dc6bSNicolas Souchu
5102331230SJoerg Wunsch /* See comments below for why auto-scanning is a bad idea. */
5202331230SJoerg Wunsch #define SCAN_IICBUS 0
5302331230SJoerg Wunsch
54e7fe5d60SAndriy Gapon SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c controls");
55e7fe5d60SAndriy Gapon
56c3e2dc6bSNicolas Souchu static int
iicbus_probe(device_t dev)57c3e2dc6bSNicolas Souchu iicbus_probe(device_t dev)
58c3e2dc6bSNicolas Souchu {
59bf896bd0SNicolas Souchu
60d7fac973SWarner Losh device_set_desc(dev, "Philips I2C bus");
61789c4b9dSNathan Whitehorn
62789c4b9dSNathan Whitehorn /* Allow other subclasses to override this driver. */
63f5a78b2fSNathan Whitehorn return (BUS_PROBE_GENERIC);
6404f89a63SNicolas Souchu }
65c3e2dc6bSNicolas Souchu
6602331230SJoerg Wunsch #if SCAN_IICBUS
6704f89a63SNicolas Souchu static int
iic_probe_device(device_t dev,u_char addr)6804f89a63SNicolas Souchu iic_probe_device(device_t dev, u_char addr)
6904f89a63SNicolas Souchu {
7004f89a63SNicolas Souchu int count;
7104f89a63SNicolas Souchu char byte;
72c3e2dc6bSNicolas Souchu
7304f89a63SNicolas Souchu if ((addr & 1) == 0) {
7404f89a63SNicolas Souchu /* is device writable? */
7504f89a63SNicolas Souchu if (!iicbus_start(dev, (u_char)addr, 0)) {
76c3e2dc6bSNicolas Souchu iicbus_stop(dev);
7704f89a63SNicolas Souchu return (1);
78c3e2dc6bSNicolas Souchu }
7904f89a63SNicolas Souchu } else {
8004f89a63SNicolas Souchu /* is device readable? */
8104f89a63SNicolas Souchu if (!iicbus_block_read(dev, (u_char)addr, &byte, 1, &count))
8204f89a63SNicolas Souchu return (1);
83c3e2dc6bSNicolas Souchu }
84c3e2dc6bSNicolas Souchu
85c3e2dc6bSNicolas Souchu return (0);
86c3e2dc6bSNicolas Souchu }
87bf896bd0SNicolas Souchu #endif
88c3e2dc6bSNicolas Souchu
8904f89a63SNicolas Souchu /*
9004f89a63SNicolas Souchu * We add all the devices which we know about.
9104f89a63SNicolas Souchu * The generic attach routine will attach them if they are alive.
9204f89a63SNicolas Souchu */
939b7938dcSVladimir Kondratyev int
iicbus_attach_common(device_t dev,u_int bus_freq)949b7938dcSVladimir Kondratyev iicbus_attach_common(device_t dev, u_int bus_freq)
95c3e2dc6bSNicolas Souchu {
9602331230SJoerg Wunsch #if SCAN_IICBUS
9702331230SJoerg Wunsch unsigned char addr;
9802331230SJoerg Wunsch #endif
99d4fa6840SWarner Losh struct iicbus_softc *sc = IICBUS_SOFTC(dev);
1009844b3b3SAdrian Chadd int strict;
10102331230SJoerg Wunsch
102d4fa6840SWarner Losh sc->dev = dev;
103313f8941SJohn Baldwin mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF);
1049b7938dcSVladimir Kondratyev iicbus_init_frequency(dev, bus_freq);
10504f89a63SNicolas Souchu iicbus_reset(dev, IIC_FASTEST, 0, NULL);
1069844b3b3SAdrian Chadd if (resource_int_value(device_get_name(dev),
1079844b3b3SAdrian Chadd device_get_unit(dev), "strict", &strict) == 0)
1089844b3b3SAdrian Chadd sc->strict = strict;
1099844b3b3SAdrian Chadd else
1109844b3b3SAdrian Chadd sc->strict = 1;
11104f89a63SNicolas Souchu
112bf896bd0SNicolas Souchu /* device probing is meaningless since the bus is supposed to be
113bf896bd0SNicolas Souchu * hot-plug. Moreover, some I2C chips do not appreciate random
114bf896bd0SNicolas Souchu * accesses like stop after start to fast, reads for less than
115bf896bd0SNicolas Souchu * x bytes...
116bf896bd0SNicolas Souchu */
11702331230SJoerg Wunsch #if SCAN_IICBUS
11804f89a63SNicolas Souchu printf("Probing for devices on iicbus%d:", device_get_unit(dev));
11904f89a63SNicolas Souchu
12004f89a63SNicolas Souchu /* probe any devices */
12102331230SJoerg Wunsch for (addr = 16; addr < 240; addr++) {
12204f89a63SNicolas Souchu if (iic_probe_device(dev, (u_char)addr)) {
12304f89a63SNicolas Souchu printf(" <%x>", addr);
12404f89a63SNicolas Souchu }
12504f89a63SNicolas Souchu }
12604f89a63SNicolas Souchu printf("\n");
127bf896bd0SNicolas Souchu #endif
128723da5d9SJohn Baldwin bus_identify_children(dev);
129d4fa6840SWarner Losh bus_enumerate_hinted_children(dev);
13018250ec6SJohn Baldwin bus_attach_children(dev);
131c17d4340SNicolas Souchu return (0);
13204f89a63SNicolas Souchu }
13304f89a63SNicolas Souchu
134c17d4340SNicolas Souchu static int
iicbus_attach(device_t dev)1359b7938dcSVladimir Kondratyev iicbus_attach(device_t dev)
1369b7938dcSVladimir Kondratyev {
1379b7938dcSVladimir Kondratyev
1389b7938dcSVladimir Kondratyev return (iicbus_attach_common(dev, 0));
1399b7938dcSVladimir Kondratyev }
1409b7938dcSVladimir Kondratyev
1419b7938dcSVladimir Kondratyev int
iicbus_detach(device_t dev)142c17d4340SNicolas Souchu iicbus_detach(device_t dev)
143c17d4340SNicolas Souchu {
144313f8941SJohn Baldwin struct iicbus_softc *sc = IICBUS_SOFTC(dev);
1457c280087SIan Lepore int err;
146d7fac973SWarner Losh
147*3ddaf820SJohn Baldwin if ((err = bus_generic_detach(dev)) != 0)
1487c280087SIan Lepore return (err);
149c17d4340SNicolas Souchu iicbus_reset(dev, IIC_FASTEST, 0, NULL);
150313f8941SJohn Baldwin mtx_destroy(&sc->lock);
151c17d4340SNicolas Souchu return (0);
15204f89a63SNicolas Souchu }
153c17d4340SNicolas Souchu
154c17d4340SNicolas Souchu static int
iicbus_print_child(device_t dev,device_t child)155d4fa6840SWarner Losh iicbus_print_child(device_t dev, device_t child)
156d4fa6840SWarner Losh {
157d4fa6840SWarner Losh struct iicbus_ivar *devi = IICBUS_IVAR(child);
158d4fa6840SWarner Losh int retval = 0;
159d4fa6840SWarner Losh
160d4fa6840SWarner Losh retval += bus_print_child_header(dev, child);
161d4fa6840SWarner Losh if (devi->addr != 0)
162d4fa6840SWarner Losh retval += printf(" at addr %#x", devi->addr);
163f8fd3fb5SJustin Hibbits resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%jd");
164d4fa6840SWarner Losh retval += bus_print_child_footer(dev, child);
165d4fa6840SWarner Losh
166d4fa6840SWarner Losh return (retval);
167d4fa6840SWarner Losh }
168d4fa6840SWarner Losh
1699b7938dcSVladimir Kondratyev void
iicbus_probe_nomatch(device_t bus,device_t child)170d4fa6840SWarner Losh iicbus_probe_nomatch(device_t bus, device_t child)
171d4fa6840SWarner Losh {
172d4fa6840SWarner Losh struct iicbus_ivar *devi = IICBUS_IVAR(child);
173d4fa6840SWarner Losh
1741b53f6c5SLuiz Otavio O Souza device_printf(bus, "<unknown card> at addr %#x\n", devi->addr);
175d4fa6840SWarner Losh }
176d4fa6840SWarner Losh
1779b7938dcSVladimir Kondratyev int
iicbus_child_location(device_t bus,device_t child,struct sbuf * sb)178ddfc9c4cSWarner Losh iicbus_child_location(device_t bus, device_t child, struct sbuf *sb)
179d4fa6840SWarner Losh {
180d4fa6840SWarner Losh struct iicbus_ivar *devi = IICBUS_IVAR(child);
181d4fa6840SWarner Losh
182ddfc9c4cSWarner Losh sbuf_printf(sb, "addr=%#x", devi->addr);
183d4fa6840SWarner Losh return (0);
184d4fa6840SWarner Losh }
185d4fa6840SWarner Losh
1869b7938dcSVladimir Kondratyev int
iicbus_child_pnpinfo(device_t bus,device_t child,struct sbuf * sb)187ddfc9c4cSWarner Losh iicbus_child_pnpinfo(device_t bus, device_t child, struct sbuf *sb)
188d4fa6840SWarner Losh {
189d4fa6840SWarner Losh return (0);
190d4fa6840SWarner Losh }
191d4fa6840SWarner Losh
1929b7938dcSVladimir Kondratyev int
iicbus_read_ivar(device_t bus,device_t child,int which,uintptr_t * result)193b23193a5SWarner Losh iicbus_read_ivar(device_t bus, device_t child, int which, uintptr_t *result)
194d4fa6840SWarner Losh {
195d4fa6840SWarner Losh struct iicbus_ivar *devi = IICBUS_IVAR(child);
196d4fa6840SWarner Losh
197d4fa6840SWarner Losh switch (which) {
198d4fa6840SWarner Losh default:
199d4fa6840SWarner Losh return (EINVAL);
200d4fa6840SWarner Losh case IICBUS_IVAR_ADDR:
201517524ecSNathan Whitehorn *result = devi->addr;
202d4fa6840SWarner Losh break;
203604d83bdSWarner Losh }
204604d83bdSWarner Losh return (0);
205604d83bdSWarner Losh }
206604d83bdSWarner Losh
2079b7938dcSVladimir Kondratyev int
iicbus_write_ivar(device_t bus,device_t child,int which,uintptr_t value)208604d83bdSWarner Losh iicbus_write_ivar(device_t bus, device_t child, int which, uintptr_t value)
209604d83bdSWarner Losh {
210604d83bdSWarner Losh struct iicbus_ivar *devi = IICBUS_IVAR(child);
211604d83bdSWarner Losh
212604d83bdSWarner Losh switch (which) {
213604d83bdSWarner Losh default:
214604d83bdSWarner Losh return (EINVAL);
215604d83bdSWarner Losh case IICBUS_IVAR_ADDR:
216448897d3SAndriy Gapon if (devi->addr != 0)
217604d83bdSWarner Losh return (EINVAL);
218448897d3SAndriy Gapon devi->addr = value;
219d4fa6840SWarner Losh }
220d4fa6840SWarner Losh return (0);
221d4fa6840SWarner Losh }
222d4fa6840SWarner Losh
2239b7938dcSVladimir Kondratyev device_t
iicbus_add_child_common(device_t dev,u_int order,const char * name,int unit,size_t ivars_size)2249b7938dcSVladimir Kondratyev iicbus_add_child_common(device_t dev, u_int order, const char *name, int unit,
2259b7938dcSVladimir Kondratyev size_t ivars_size)
226c17d4340SNicolas Souchu {
227d4fa6840SWarner Losh device_t child;
228d4fa6840SWarner Losh struct iicbus_ivar *devi;
229d7fac973SWarner Losh
230d4fa6840SWarner Losh child = device_add_child_ordered(dev, order, name, unit);
231d4fa6840SWarner Losh if (child == NULL)
232d4fa6840SWarner Losh return (child);
2339b7938dcSVladimir Kondratyev devi = malloc(ivars_size, M_DEVBUF, M_NOWAIT | M_ZERO);
234d4fa6840SWarner Losh if (devi == NULL) {
235d4fa6840SWarner Losh device_delete_child(dev, child);
236c3e2dc6bSNicolas Souchu return (0);
237c3e2dc6bSNicolas Souchu }
2383bb6bf47SLuiz Otavio O Souza resource_list_init(&devi->rl);
239d4fa6840SWarner Losh device_set_ivars(child, devi);
240d4fa6840SWarner Losh return (child);
241d4fa6840SWarner Losh }
242d4fa6840SWarner Losh
2439b7938dcSVladimir Kondratyev static device_t
iicbus_add_child(device_t dev,u_int order,const char * name,int unit)2449b7938dcSVladimir Kondratyev iicbus_add_child(device_t dev, u_int order, const char *name, int unit)
2459b7938dcSVladimir Kondratyev {
2469b7938dcSVladimir Kondratyev
2479b7938dcSVladimir Kondratyev return (iicbus_add_child_common(
2489b7938dcSVladimir Kondratyev dev, order, name, unit, sizeof(struct iicbus_ivar)));
2499b7938dcSVladimir Kondratyev }
2509b7938dcSVladimir Kondratyev
251d4fa6840SWarner Losh static void
iicbus_child_deleted(device_t dev,device_t child)2529c99ba9aSJohn Baldwin iicbus_child_deleted(device_t dev, device_t child)
2539c99ba9aSJohn Baldwin {
2549c99ba9aSJohn Baldwin struct iicbus_ivar *devi;
2559c99ba9aSJohn Baldwin
2569c99ba9aSJohn Baldwin devi = device_get_ivars(child);
2579c99ba9aSJohn Baldwin if (devi == NULL)
2589c99ba9aSJohn Baldwin return;
2599c99ba9aSJohn Baldwin resource_list_free(&devi->rl);
2609c99ba9aSJohn Baldwin free(devi, M_DEVBUF);
2619c99ba9aSJohn Baldwin }
2629c99ba9aSJohn Baldwin
2639c99ba9aSJohn Baldwin static void
iicbus_hinted_child(device_t bus,const char * dname,int dunit)264d4fa6840SWarner Losh iicbus_hinted_child(device_t bus, const char *dname, int dunit)
265d4fa6840SWarner Losh {
266d4fa6840SWarner Losh device_t child;
2673bb6bf47SLuiz Otavio O Souza int irq;
268d4fa6840SWarner Losh struct iicbus_ivar *devi;
269d4fa6840SWarner Losh
270d4fa6840SWarner Losh child = BUS_ADD_CHILD(bus, 0, dname, dunit);
271d4fa6840SWarner Losh devi = IICBUS_IVAR(child);
272d4fa6840SWarner Losh resource_int_value(dname, dunit, "addr", &devi->addr);
2733bb6bf47SLuiz Otavio O Souza if (resource_int_value(dname, dunit, "irq", &irq) == 0) {
2743bb6bf47SLuiz Otavio O Souza if (bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1) != 0)
2753bb6bf47SLuiz Otavio O Souza device_printf(bus,
2763bb6bf47SLuiz Otavio O Souza "warning: bus_set_resource() failed\n");
2773bb6bf47SLuiz Otavio O Souza }
2783bb6bf47SLuiz Otavio O Souza }
2793bb6bf47SLuiz Otavio O Souza
2803bb6bf47SLuiz Otavio O Souza static struct resource_list *
iicbus_get_resource_list(device_t bus __unused,device_t child)2813bb6bf47SLuiz Otavio O Souza iicbus_get_resource_list(device_t bus __unused, device_t child)
2823bb6bf47SLuiz Otavio O Souza {
2833bb6bf47SLuiz Otavio O Souza struct iicbus_ivar *devi;
2843bb6bf47SLuiz Otavio O Souza
2853bb6bf47SLuiz Otavio O Souza devi = IICBUS_IVAR(child);
2863bb6bf47SLuiz Otavio O Souza return (&devi->rl);
287d4fa6840SWarner Losh }
288c3e2dc6bSNicolas Souchu
289c3e2dc6bSNicolas Souchu int
iicbus_generic_intr(device_t dev,int event,char * buf)290c3e2dc6bSNicolas Souchu iicbus_generic_intr(device_t dev, int event, char *buf)
291c3e2dc6bSNicolas Souchu {
292d7fac973SWarner Losh
293c3e2dc6bSNicolas Souchu return (0);
294c3e2dc6bSNicolas Souchu }
295c3e2dc6bSNicolas Souchu
29604f89a63SNicolas Souchu int
iicbus_null_callback(device_t dev,int index,caddr_t data)29704f89a63SNicolas Souchu iicbus_null_callback(device_t dev, int index, caddr_t data)
29804f89a63SNicolas Souchu {
299d7fac973SWarner Losh
30004f89a63SNicolas Souchu return (0);
30104f89a63SNicolas Souchu }
30204f89a63SNicolas Souchu
30304f89a63SNicolas Souchu int
iicbus_null_repeated_start(device_t dev,u_char addr)30404f89a63SNicolas Souchu iicbus_null_repeated_start(device_t dev, u_char addr)
30504f89a63SNicolas Souchu {
306d7fac973SWarner Losh
30704f89a63SNicolas Souchu return (IIC_ENOTSUPP);
30804f89a63SNicolas Souchu }
30904f89a63SNicolas Souchu
310844aff82SIan Lepore void
iicbus_init_frequency(device_t dev,u_int bus_freq)311844aff82SIan Lepore iicbus_init_frequency(device_t dev, u_int bus_freq)
312844aff82SIan Lepore {
313844aff82SIan Lepore struct iicbus_softc *sc = IICBUS_SOFTC(dev);
314844aff82SIan Lepore
315844aff82SIan Lepore /*
316844aff82SIan Lepore * If a bus frequency value was passed in, use it. Otherwise initialize
317844aff82SIan Lepore * it first to the standard i2c 100KHz frequency, then override that
318844aff82SIan Lepore * from a hint if one exists.
319844aff82SIan Lepore */
320844aff82SIan Lepore if (bus_freq > 0)
321844aff82SIan Lepore sc->bus_freq = bus_freq;
322844aff82SIan Lepore else {
323844aff82SIan Lepore sc->bus_freq = 100000;
324844aff82SIan Lepore resource_int_value(device_get_name(dev), device_get_unit(dev),
325844aff82SIan Lepore "frequency", (int *)&sc->bus_freq);
326844aff82SIan Lepore }
327844aff82SIan Lepore /*
328844aff82SIan Lepore * Set up the sysctl that allows the bus frequency to be changed.
329844aff82SIan Lepore * It is flagged as a tunable so that the user can set the value in
330844aff82SIan Lepore * loader(8), and that will override any other setting from any source.
331844aff82SIan Lepore * The sysctl tunable/value is the one most directly controlled by the
332844aff82SIan Lepore * user and thus the one that always takes precedence.
333844aff82SIan Lepore */
334844aff82SIan Lepore SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev),
335844aff82SIan Lepore SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
336deac4c7fSZhenlei Huang OID_AUTO, "frequency", CTLFLAG_RWTUN, &sc->bus_freq,
337844aff82SIan Lepore sc->bus_freq, "Bus frequency in Hz");
338844aff82SIan Lepore }
339844aff82SIan Lepore
340844aff82SIan Lepore static u_int
iicbus_get_frequency(device_t dev,u_char speed)341844aff82SIan Lepore iicbus_get_frequency(device_t dev, u_char speed)
342844aff82SIan Lepore {
343844aff82SIan Lepore struct iicbus_softc *sc = IICBUS_SOFTC(dev);
344844aff82SIan Lepore
345844aff82SIan Lepore /*
346844aff82SIan Lepore * If the frequency has not been configured for the bus, or the request
347844aff82SIan Lepore * is specifically for SLOW speed, use the standard 100KHz rate, else
348844aff82SIan Lepore * use the configured bus speed.
349844aff82SIan Lepore */
350844aff82SIan Lepore if (sc->bus_freq == 0 || speed == IIC_SLOW)
351844aff82SIan Lepore return (100000);
352844aff82SIan Lepore return (sc->bus_freq);
353844aff82SIan Lepore }
354844aff82SIan Lepore
355d4fa6840SWarner Losh static device_method_t iicbus_methods[] = {
356d4fa6840SWarner Losh /* device interface */
357d4fa6840SWarner Losh DEVMETHOD(device_probe, iicbus_probe),
358d4fa6840SWarner Losh DEVMETHOD(device_attach, iicbus_attach),
359d4fa6840SWarner Losh DEVMETHOD(device_detach, iicbus_detach),
360db7caa2eSVladimir Kondratyev DEVMETHOD(device_suspend, bus_generic_suspend),
361db7caa2eSVladimir Kondratyev DEVMETHOD(device_resume, bus_generic_resume),
362d4fa6840SWarner Losh
363d4fa6840SWarner Losh /* bus interface */
3643bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
3653bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
3663bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
3673bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
3683bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
3691b53f6c5SLuiz Otavio O Souza DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource),
3703bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
3711b53f6c5SLuiz Otavio O Souza DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
3721b53f6c5SLuiz Otavio O Souza DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
3733bb6bf47SLuiz Otavio O Souza DEVMETHOD(bus_get_resource_list, iicbus_get_resource_list),
374d4fa6840SWarner Losh DEVMETHOD(bus_add_child, iicbus_add_child),
3759c99ba9aSJohn Baldwin DEVMETHOD(bus_child_deleted, iicbus_child_deleted),
376d4fa6840SWarner Losh DEVMETHOD(bus_print_child, iicbus_print_child),
377d4fa6840SWarner Losh DEVMETHOD(bus_probe_nomatch, iicbus_probe_nomatch),
378d4fa6840SWarner Losh DEVMETHOD(bus_read_ivar, iicbus_read_ivar),
379604d83bdSWarner Losh DEVMETHOD(bus_write_ivar, iicbus_write_ivar),
380ddfc9c4cSWarner Losh DEVMETHOD(bus_child_pnpinfo, iicbus_child_pnpinfo),
381ddfc9c4cSWarner Losh DEVMETHOD(bus_child_location, iicbus_child_location),
382d4fa6840SWarner Losh DEVMETHOD(bus_hinted_child, iicbus_hinted_child),
383d4fa6840SWarner Losh
384d4fa6840SWarner Losh /* iicbus interface */
385d4fa6840SWarner Losh DEVMETHOD(iicbus_transfer, iicbus_transfer),
386844aff82SIan Lepore DEVMETHOD(iicbus_get_frequency, iicbus_get_frequency),
387d4fa6840SWarner Losh
3884b7ec270SMarius Strobl DEVMETHOD_END
389d4fa6840SWarner Losh };
390d4fa6840SWarner Losh
391d4fa6840SWarner Losh driver_t iicbus_driver = {
392d4fa6840SWarner Losh "iicbus",
393d4fa6840SWarner Losh iicbus_methods,
394d4fa6840SWarner Losh sizeof(struct iicbus_softc),
395d4fa6840SWarner Losh };
396d4fa6840SWarner Losh
397c17d4340SNicolas Souchu MODULE_VERSION(iicbus, IICBUS_MODVER);
398676ea8e1SJohn Baldwin DRIVER_MODULE(iicbus, iichb, iicbus_driver, 0, 0);
399