1210677Snwhitehorn/*-
2210677Snwhitehorn * Copyright 2008 by Nathan Whitehorn. All rights reserved.
3210677Snwhitehorn *
4210677Snwhitehorn * Redistribution and use in source and binary forms, with or without
5210677Snwhitehorn * modification, are permitted provided that the following conditions
6210677Snwhitehorn * are met:
7210677Snwhitehorn * 1. Redistributions of source code must retain the above copyright
8210677Snwhitehorn *    notice, this list of conditions and the following disclaimer.
9210677Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
10210677Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
11210677Snwhitehorn *    documentation and/or other materials provided with the distribution.
12210677Snwhitehorn *
13210677Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14210677Snwhitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15210677Snwhitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16210677Snwhitehorn * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17210677Snwhitehorn * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18210677Snwhitehorn * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19210677Snwhitehorn * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
20210677Snwhitehorn * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21210677Snwhitehorn * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22210677Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23210677Snwhitehorn * SUCH DAMAGE.
24210677Snwhitehorn *
25210677Snwhitehorn */
26210677Snwhitehorn
27210677Snwhitehorn#include <sys/cdefs.h>
28210677Snwhitehorn__FBSDID("$FreeBSD: releng/11.0/sys/powerpc/mambo/mambo.c 261513 2014-02-05 14:44:22Z nwhitehorn $");
29210677Snwhitehorn
30210677Snwhitehorn#include <sys/param.h>
31210677Snwhitehorn#include <sys/systm.h>
32210677Snwhitehorn#include <sys/module.h>
33210677Snwhitehorn#include <sys/bus.h>
34210677Snwhitehorn#include <sys/conf.h>
35210677Snwhitehorn#include <sys/kernel.h>
36210677Snwhitehorn
37210677Snwhitehorn#include <dev/ofw/ofw_bus.h>
38210677Snwhitehorn#include <dev/ofw/openfirm.h>
39210677Snwhitehorn
40210677Snwhitehorn#include <machine/bus.h>
41210677Snwhitehorn
42210677Snwhitehorn#include <vm/vm.h>
43210677Snwhitehorn#include <vm/pmap.h>
44210677Snwhitehorn
45210677Snwhitehorn#include <sys/rman.h>
46210677Snwhitehorn
47210677Snwhitehorn/*
48210677Snwhitehorn * Mambo interface
49210677Snwhitehorn */
50210677Snwhitehornstatic int	mambobus_probe(device_t);
51210677Snwhitehornstatic int	mambobus_attach(device_t);
52210677Snwhitehorn
53210677Snwhitehornstatic device_method_t  mambobus_methods[] = {
54210677Snwhitehorn	/* Device interface */
55210677Snwhitehorn	DEVMETHOD(device_probe,		mambobus_probe),
56210677Snwhitehorn	DEVMETHOD(device_attach,	mambobus_attach),
57210677Snwhitehorn
58210677Snwhitehorn	/* Bus interface */
59210677Snwhitehorn	DEVMETHOD(bus_add_child,	bus_generic_add_child),
60210677Snwhitehorn	DEVMETHOD(bus_read_ivar,	bus_generic_read_ivar),
61210677Snwhitehorn	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
62210677Snwhitehorn	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
63210677Snwhitehorn	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
64210677Snwhitehorn	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
65210677Snwhitehorn	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
66210677Snwhitehorn
67227843Smarius	DEVMETHOD_END
68210677Snwhitehorn};
69210677Snwhitehorn
70210677Snwhitehornstatic driver_t mambobus_driver = {
71210677Snwhitehorn	"mambo",
72210677Snwhitehorn	mambobus_methods,
73210677Snwhitehorn	0
74210677Snwhitehorn};
75210677Snwhitehorn
76210677Snwhitehornstatic devclass_t mambobus_devclass;
77210677Snwhitehorn
78261513SnwhitehornDRIVER_MODULE(mambo, ofwbus, mambobus_driver, mambobus_devclass, 0, 0);
79210677Snwhitehorn
80210677Snwhitehornstatic int
81210677Snwhitehornmambobus_probe(device_t dev)
82210677Snwhitehorn{
83210677Snwhitehorn	const char *name = ofw_bus_get_name(dev);
84210677Snwhitehorn
85210677Snwhitehorn	if (name && !strcmp(name, "mambo")) {
86210677Snwhitehorn		device_set_desc(dev, "Mambo Simulator");
87210677Snwhitehorn		return (0);
88210677Snwhitehorn	}
89210677Snwhitehorn
90210677Snwhitehorn	return (ENXIO);
91210677Snwhitehorn}
92210677Snwhitehorn
93210677Snwhitehornstatic int
94210677Snwhitehornmambobus_attach(device_t dev)
95210677Snwhitehorn{
96210677Snwhitehorn	bus_generic_probe(dev);
97210677Snwhitehorn	return (bus_generic_attach(dev));
98210677Snwhitehorn}
99210677Snwhitehorn
100