Home | History | Annotate | Line # | Download | only in gsc
      1 /*	$NetBSD: gscbus.c,v 1.4 2022/09/29 06:39:58 skrll Exp $	*/
      2 
      3 /*	$OpenBSD: gscbus.c,v 1.13 2001/08/01 20:32:04 miod Exp $	*/
      4 
      5 /*
      6  * Copyright (c) 1998 Michael Shalayeff
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     24  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     28  * THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /*
     32  * Sample IO layouts:
     33  * 712:
     34  *
     35  * f0100000 -- lasi0
     36  * f0102000 -- lpt0
     37  * f0104000 -- audio0
     38  * f0105000 -- com0
     39  * f0106000 -- siop0
     40  * f0107000 -- ie0
     41  * f0108000 -- kbd0
     42  * f0108100 -- pms0
     43  * f010a000 -- fdc0
     44  * f010c000 -- *lasi0
     45  * f0200000 -- wax0
     46  * f8000000 -- sti0
     47  * fffbe000 -- cpu0
     48  * fffbf000 -- mem0
     49  *
     50  * 725/50:
     51  *
     52  * f0820000 -- dma
     53  * f0821000 -- hil
     54  * f0822000 -- com1
     55  * f0823000 -- com0
     56  * f0824000 -- lpt0
     57  * f0825000 -- siop0
     58  * f0826000 -- ie0
     59  * f0827000 -- dma reset
     60  * f0828000 -- timers
     61  * f0829000 -- domain kbd
     62  * f082f000 -- asp0
     63  * f1000000 -- audio0
     64  * fc000000 -- eisa0
     65  * fffbe000 -- cpu0
     66  * fffbf000 -- mem0
     67  *
     68  */
     69 
     70 #include <sys/cdefs.h>
     71 __KERNEL_RCSID(0, "$NetBSD: gscbus.c,v 1.4 2022/09/29 06:39:58 skrll Exp $");
     72 
     73 #define GSCDEBUG
     74 
     75 #include "opt_kgdb.h"
     76 
     77 #include <sys/param.h>
     78 #include <sys/systm.h>
     79 #include <sys/device.h>
     80 #include <sys/mbuf.h>
     81 #include <sys/reboot.h>
     82 
     83 #include <machine/iomod.h>
     84 #include <machine/autoconf.h>
     85 #include <machine/cpufunc.h>
     86 
     87 #include <hppa/gsc/gscbusvar.h>
     88 #include <hppa/hppa/machdep.h>
     89 
     90 int	gscmatch(device_t, cfdata_t, void *);
     91 void	gscattach(device_t, device_t, void *);
     92 
     93 struct gsc_softc {
     94 	device_t sc_dev;
     95 	struct gsc_attach_args sc_ga;
     96 	void *sc_ih;
     97 };
     98 
     99 CFATTACH_DECL_NEW(gsc, sizeof(struct gsc_softc),
    100     gscmatch, gscattach, NULL, NULL);
    101 
    102 /*
    103  * pdc_scanbus calls this function back with each module
    104  * it finds on the GSC bus.  We call the IC-specific function
    105  * to fix up the module's attach arguments, then we match
    106  * and attach it.
    107  */
    108 static device_t gsc_module_callback(device_t, struct confargs *);
    109 static device_t
    110 gsc_module_callback(device_t self, struct confargs *ca)
    111 {
    112 	struct gsc_softc *sc = device_private(self);
    113 	struct gsc_attach_args ga;
    114 
    115 	/* Make the GSC attach args. */
    116 	ga = sc->sc_ga;
    117 	ga.ga_ca = *ca;
    118 	ga.ga_iot = sc->sc_ga.ga_iot;
    119 	ga.ga_dmatag = sc->sc_ga.ga_dmatag;
    120 	(*sc->sc_ga.ga_fix_args)(sc->sc_ga.ga_fix_args_cookie, &ga);
    121 
    122 	return config_found(self, &ga, mbprint,
    123 	    CFARGS(.submatch = mbsubmatch));
    124 }
    125 
    126 int
    127 gscmatch(device_t parent, cfdata_t cf, void *aux)
    128 {
    129 	struct gsc_attach_args *ga = aux;
    130 
    131 	return !strcmp(ga->ga_name, "gsc");
    132 }
    133 
    134 void
    135 gscattach(device_t parent, device_t self, void *aux)
    136 {
    137 	struct gsc_softc *sc = device_private(self);
    138 	struct gsc_attach_args *ga = aux;
    139 	struct cpu_info *ci = &cpus[0];
    140 
    141 	sc->sc_dev = self;
    142 	sc->sc_ga = *ga;
    143 
    144 #ifdef USELEDS
    145 	if (machine_ledaddr)
    146 		aprint_normal(": %sleds", machine_ledword? "word" : "");
    147 #endif
    148 
    149 	aprint_normal("\n");
    150 
    151 	/* Add the I/O subsystem's interrupt register. */
    152 	ga->ga_ir->ir_name = device_xname(self);
    153 	sc->sc_ih = hppa_intr_establish(IPL_NONE, NULL, ga->ga_ir,
    154 	    &ci->ci_ir, ga->ga_irq);
    155 
    156 	ga->ga_ca.ca_nmodules = MAXMODBUS;
    157 	ga->ga_ca.ca_hpabase = 0;
    158 	pdc_scanbus(self, &ga->ga_ca, gsc_module_callback);
    159 }
    160 
    161 int
    162 gscprint(void *aux, const char *pnp)
    163 {
    164 
    165 	return (UNCONF);
    166 }
    167