1/*-
2 * Copyright (C) 2012 Margarida Gouveia
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 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * 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#include <sys/cdefs.h>
27__FBSDID("$FreeBSD$");
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/rman.h>
37
38#include <machine/bus.h>
39#include <machine/platform.h>
40#include <machine/intr_machdep.h>
41#include <machine/resource.h>
42
43#include <powerpc/wii/wii_ipcreg.h>
44
45/*
46 * Driver to interface with the Wii's IOS. IOS are small "microkernels" that run
47 * on the Broadway GPU and provide access to system services like USB.
48 */
49static int	wiiipc_probe(device_t);
50static int	wiiipc_attach(device_t);
51
52struct wiiipc_softc {
53};
54
55static device_method_t wiiipc_methods[] = {
56	/* Device interface */
57	DEVMETHOD(device_probe,		wiiipc_probe),
58	DEVMETHOD(device_attach,	wiiipc_attach),
59
60	DEVMETHOD_END
61};
62
63static driver_t wiiipc_driver = {
64	"wiiipc",
65	wiiipc_methods,
66	sizeof(struct wiiipc_softc)
67};
68
69static devclass_t wiiipc_devclass;
70
71DRIVER_MODULE(wiiipc, wiibus, wiiipc_driver, wiiipc_devclass, 0, 0);
72
73static int
74wiiipc_probe(device_t dev)
75{
76        device_set_desc(dev, "Nintendo Wii IOS IPC");
77
78        return (BUS_PROBE_NOWILDCARD);
79}
80
81static int
82wiiipc_attach(device_t dev)
83{
84	struct wiiipc_softc *sc;
85
86	sc = device_get_softc(dev);
87#ifdef notyet
88	sc->sc_dev = dev;
89
90	sc->sc_rrid = 0;
91	sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
92	    &sc->sc_rrid, RF_ACTIVE);
93	if (sc->sc_rres == NULL) {
94		device_printf(dev, "could not alloc mem resource\n");
95		return (ENXIO);
96	}
97	sc->sc_bt = rman_get_bustag(sc->sc_rres);
98	sc->sc_bh = rman_get_bushandle(sc->sc_rres);
99#endif
100
101	return (0);
102}
103