1*8ff6f65dSthorpej /* $NetBSD: g2bus.c,v 1.17 2023/12/20 06:36:03 thorpej Exp $ */
263885cd0Sthorpej
363885cd0Sthorpej /*-
463885cd0Sthorpej * Copyright (c) 2001 Marcus Comstedt
563885cd0Sthorpej * All rights reserved.
663885cd0Sthorpej *
763885cd0Sthorpej * Redistribution and use in source and binary forms, with or without
863885cd0Sthorpej * modification, are permitted provided that the following conditions
963885cd0Sthorpej * are met:
1063885cd0Sthorpej * 1. Redistributions of source code must retain the above copyright
1163885cd0Sthorpej * notice, this list of conditions and the following disclaimer.
1263885cd0Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1363885cd0Sthorpej * notice, this list of conditions and the following disclaimer in the
1463885cd0Sthorpej * documentation and/or other materials provided with the distribution.
1563885cd0Sthorpej * 3. All advertising materials mentioning features or use of this software
1663885cd0Sthorpej * must display the following acknowledgement:
1763885cd0Sthorpej * This product includes software developed by Marcus Comstedt.
1863885cd0Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
1963885cd0Sthorpej * contributors may be used to endorse or promote products derived
2063885cd0Sthorpej * from this software without specific prior written permission.
2163885cd0Sthorpej *
2263885cd0Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2363885cd0Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2463885cd0Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2563885cd0Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2663885cd0Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2763885cd0Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2863885cd0Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2963885cd0Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3063885cd0Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3163885cd0Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3263885cd0Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3363885cd0Sthorpej */
3463885cd0Sthorpej
3514172728Slukem
3614172728Slukem #include <sys/cdefs.h>
37*8ff6f65dSthorpej __KERNEL_RCSID(0, "$NetBSD: g2bus.c,v 1.17 2023/12/20 06:36:03 thorpej Exp $");
3814172728Slukem
3963885cd0Sthorpej #include <sys/param.h>
4063885cd0Sthorpej #include <sys/systm.h>
4163885cd0Sthorpej #include <sys/kernel.h>
4263885cd0Sthorpej #include <sys/conf.h>
4363885cd0Sthorpej #include <sys/device.h>
4463885cd0Sthorpej #include <sys/proc.h>
4563885cd0Sthorpej
4663885cd0Sthorpej #include <dreamcast/dev/g2/g2busvar.h>
4763885cd0Sthorpej
48b1361f43Stsutsui int g2busmatch(device_t, cfdata_t, void *);
49b1361f43Stsutsui void g2busattach(device_t, device_t, void *);
5063885cd0Sthorpej int g2busprint(void *, const char *);
5163885cd0Sthorpej
52b1361f43Stsutsui CFATTACH_DECL_NEW(g2bus, sizeof(struct g2bus_softc),
53bd5bb465Sthorpej g2busmatch, g2busattach, NULL, NULL);
5463885cd0Sthorpej
55b1361f43Stsutsui int g2bussearch(device_t, cfdata_t, const int *, void *);
5663885cd0Sthorpej
5763885cd0Sthorpej int
g2busmatch(device_t parent,cfdata_t cf,void * aux)58b1361f43Stsutsui g2busmatch(device_t parent, cfdata_t cf, void *aux)
5963885cd0Sthorpej {
6063885cd0Sthorpej
61cb6453dbStsutsui return 1;
6263885cd0Sthorpej }
6363885cd0Sthorpej
6463885cd0Sthorpej void
g2busattach(device_t parent,device_t self,void * aux)65b1361f43Stsutsui g2busattach(device_t parent, device_t self, void *aux)
6663885cd0Sthorpej {
67b1361f43Stsutsui struct g2bus_softc *sc = device_private(self);
6863885cd0Sthorpej struct g2bus_attach_args ga;
6963885cd0Sthorpej
70b1361f43Stsutsui sc->sc_dev = self;
7163885cd0Sthorpej printf("\n");
7263885cd0Sthorpej
7363885cd0Sthorpej TAILQ_INIT(&sc->sc_subdevs);
7463885cd0Sthorpej
7563885cd0Sthorpej g2bus_bus_mem_init(sc);
7663885cd0Sthorpej
7763885cd0Sthorpej ga.ga_memt = &sc->sc_memt;
7863885cd0Sthorpej
792685996bSthorpej config_search(self, &ga,
80c7fb772bSthorpej CFARGS(.search = g2bussearch));
8163885cd0Sthorpej }
8263885cd0Sthorpej
8363885cd0Sthorpej int
g2busprint(void * aux,const char * pnp)8463885cd0Sthorpej g2busprint(void *aux, const char *pnp)
8563885cd0Sthorpej {
8663885cd0Sthorpej
87cb6453dbStsutsui return UNCONF;
8863885cd0Sthorpej }
8963885cd0Sthorpej
9063885cd0Sthorpej int
g2bussearch(device_t parent,cfdata_t cf,const int * ldesc,void * aux)91b1361f43Stsutsui g2bussearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
9263885cd0Sthorpej {
9363885cd0Sthorpej
942685996bSthorpej if (config_probe(parent, cf, aux))
95c7fb772bSthorpej config_attach(parent, cf, aux, g2busprint, CFARGS_NONE);
9663885cd0Sthorpej
97cb6453dbStsutsui return 0;
9863885cd0Sthorpej }
99