Home | History | Annotate | Line # | Download | only in eb7500atx
      1  1.12   thorpej /* $NetBSD: rsbus.c,v 1.12 2021/08/07 16:18:40 thorpej Exp $ */
      2   1.1     chris 
      3   1.1     chris /*
      4   1.1     chris  * Copyright (c) 2002
      5   1.1     chris  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      6   1.1     chris  * All rights reserved.
      7   1.1     chris  *
      8   1.1     chris  * Redistribution and use in source and binary forms, with or without
      9   1.1     chris  * modification, are permitted provided that the following conditions
     10   1.1     chris  * are met:
     11   1.1     chris  * 1. Redistributions of source code must retain the above copyright
     12   1.1     chris  *    notice, this list of conditions and the following disclaimer.
     13   1.1     chris  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1     chris  *    notice, this list of conditions and the following disclaimer in the
     15   1.1     chris  *    documentation and/or other materials provided with the distribution.
     16   1.1     chris  *
     17   1.1     chris  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     18   1.1     chris  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19   1.1     chris  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20   1.1     chris  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     21   1.1     chris  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22   1.1     chris  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23   1.1     chris  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24   1.1     chris  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25   1.1     chris  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26   1.1     chris  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27   1.1     chris  * SUCH DAMAGE.
     28   1.1     chris  */
     29   1.1     chris 
     30   1.5   hubertf #include <sys/cdefs.h>
     31   1.1     chris 
     32  1.12   thorpej __KERNEL_RCSID(0, "$NetBSD: rsbus.c,v 1.12 2021/08/07 16:18:40 thorpej Exp $");
     33   1.1     chris 
     34   1.1     chris #include <sys/param.h>
     35   1.1     chris #include <sys/systm.h>
     36   1.1     chris #include <sys/device.h>
     37   1.9    dyoung #include <sys/bus.h>
     38   1.1     chris 
     39   1.1     chris #include <acorn32/eb7500atx/rsbus.h>
     40   1.1     chris 
     41   1.1     chris #include "locators.h"
     42   1.1     chris 
     43   1.1     chris extern struct bus_space rsbus_bs_tag;
     44   1.1     chris 
     45   1.1     chris /* Declare prototypes */
     46   1.1     chris 
     47   1.8      matt static int	rsbus_match(device_t, cfdata_t, void *);
     48   1.8      matt static void	rsbus_attach(device_t, device_t, void *);
     49   1.1     chris static int	rsbus_print(void *, const char *);
     50   1.8      matt static int	rsbus_search(device_t, cfdata_t,
     51   1.3  drochner 			     const int *, void *);
     52   1.1     chris 
     53  1.10       chs CFATTACH_DECL_NEW(rsbus, sizeof(struct rsbus_softc),
     54   1.1     chris     rsbus_match, rsbus_attach, NULL, NULL);
     55   1.1     chris 
     56   1.1     chris static int
     57   1.8      matt rsbus_match(device_t parent, cfdata_t cf, void *aux)
     58   1.1     chris {
     59   1.1     chris 	return(1);
     60   1.1     chris }
     61   1.1     chris 
     62   1.1     chris static void
     63   1.8      matt rsbus_attach(device_t parent, device_t self, void *aux)
     64   1.1     chris {
     65   1.8      matt 	struct rsbus_softc *sc = device_private(self);
     66   1.1     chris 	sc->sc_iot = &rsbus_bs_tag;
     67   1.1     chris 
     68   1.1     chris 	printf("\n");
     69   1.1     chris 
     70   1.1     chris 	/*
     71   1.1     chris 	 *  Attach each devices
     72   1.1     chris 	 */
     73  1.11   thorpej 	config_search(self, NULL,
     74  1.12   thorpej 	    CFARGS(.search = rsbus_search));
     75   1.1     chris }
     76   1.1     chris 
     77   1.1     chris static int
     78   1.8      matt rsbus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
     79   1.1     chris {
     80   1.8      matt 	struct rsbus_softc *sc = device_private(parent);
     81   1.1     chris 	struct rsbus_attach_args sa;
     82   1.1     chris 
     83   1.1     chris 	sa.sa_iot = sc->sc_iot;
     84   1.1     chris 	sa.sa_addr = cf->cf_loc[RSBUSCF_ADDR];
     85   1.1     chris 	sa.sa_size = cf->cf_loc[RSBUSCF_SIZE];
     86   1.1     chris 	sa.sa_intr = cf->cf_loc[RSBUSCF_IRQ];
     87   1.1     chris 
     88  1.11   thorpej 	if (config_probe(parent, cf, &sa))
     89  1.12   thorpej 		config_attach(parent, cf, &sa, rsbus_print, CFARGS_NONE);
     90   1.1     chris 
     91   1.1     chris 	return (0);
     92   1.1     chris }
     93   1.1     chris 
     94   1.1     chris static int
     95   1.6       dsl rsbus_print(void *aux, const char *name)
     96   1.1     chris {
     97   1.8      matt         struct rsbus_attach_args *sa = aux;
     98   1.1     chris 
     99   1.1     chris 	if (sa->sa_size)
    100   1.1     chris 		aprint_normal(" addr 0x%lx", sa->sa_addr);
    101   1.1     chris 	if (sa->sa_size > 1)
    102   1.1     chris 		aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
    103   1.1     chris 	if (sa->sa_intr > 1)
    104   1.1     chris 		aprint_normal(" irq %d", sa->sa_intr);
    105   1.1     chris 
    106   1.1     chris 	return (UNCONF);
    107   1.1     chris }
    108