Home | History | Annotate | Line # | Download | only in obio
obio.c revision 1.13.8.1
      1  1.13.8.1     skrll /*	$NetBSD: obio.c,v 1.13.8.1 2009/04/28 07:34:26 skrll Exp $	*/
      2       1.1       wdk 
      3       1.1       wdk /*-
      4       1.1       wdk  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5       1.1       wdk  * All rights reserved.
      6       1.1       wdk  *
      7       1.1       wdk  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1       wdk  * by Wayne Knowles
      9       1.1       wdk  *
     10       1.1       wdk  * Redistribution and use in source and binary forms, with or without
     11       1.1       wdk  * modification, are permitted provided that the following conditions
     12       1.1       wdk  * are met:
     13       1.1       wdk  * 1. Redistributions of source code must retain the above copyright
     14       1.1       wdk  *    notice, this list of conditions and the following disclaimer.
     15       1.1       wdk  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1       wdk  *    notice, this list of conditions and the following disclaimer in the
     17       1.1       wdk  *    documentation and/or other materials provided with the distribution.
     18       1.1       wdk  *
     19       1.1       wdk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1       wdk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1       wdk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1       wdk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1       wdk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1       wdk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1       wdk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1       wdk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1       wdk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1       wdk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1       wdk  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1       wdk  */
     31       1.8     lukem 
     32       1.8     lukem #include <sys/cdefs.h>
     33  1.13.8.1     skrll __KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.13.8.1 2009/04/28 07:34:26 skrll Exp $");
     34       1.9       chs 
     35       1.9       chs #include "locators.h"
     36       1.1       wdk 
     37       1.1       wdk #include <sys/param.h>
     38       1.1       wdk #include <sys/systm.h>
     39       1.1       wdk #include <sys/device.h>
     40       1.1       wdk 
     41       1.1       wdk #include <machine/autoconf.h>
     42       1.1       wdk #include <machine/mainboard.h>
     43       1.1       wdk #include <machine/bus.h>
     44       1.2       wdk #include <machine/sysconf.h>
     45       1.1       wdk 
     46  1.13.8.1     skrll static int	obio_match(struct device *, struct cfdata *, void *);
     47  1.13.8.1     skrll static void	obio_attach(struct device *, struct device *, void *);
     48  1.13.8.1     skrll static int	obio_search(struct device *, struct cfdata *,
     49  1.13.8.1     skrll 				 const int *, void *);
     50  1.13.8.1     skrll static int	obio_print(void *, const char *);
     51  1.13.8.1     skrll static void	obio_intr_establish(bus_space_tag_t, int, int, int,
     52  1.13.8.1     skrll 					  int (*)(void *), void *);
     53       1.1       wdk 
     54       1.6   thorpej CFATTACH_DECL(obio, sizeof(struct device),
     55       1.6   thorpej     obio_match, obio_attach, NULL, NULL);
     56       1.1       wdk 
     57       1.1       wdk extern struct cfdriver obio_cd;
     58       1.1       wdk 
     59       1.1       wdk struct mipsco_bus_space obio_bustag;
     60       1.1       wdk struct mipsco_bus_dma_tag obio_dmatag;
     61       1.1       wdk 
     62       1.1       wdk static int
     63  1.13.8.1     skrll obio_match(struct device *parent, struct cfdata *cf, void *aux)
     64       1.1       wdk {
     65       1.1       wdk 	struct confargs *ca = aux;
     66       1.1       wdk 
     67       1.1       wdk 	if (strcmp(ca->ca_name, obio_cd.cd_name) != 0)
     68       1.1       wdk 		return 0;
     69       1.1       wdk 
     70       1.1       wdk 	return 1;
     71       1.1       wdk }
     72       1.1       wdk 
     73       1.1       wdk static void
     74  1.13.8.1     skrll obio_attach(struct device *parent, struct device *self, void *aux)
     75       1.1       wdk {
     76       1.1       wdk 	struct confargs *ca = aux;
     77       1.1       wdk 
     78       1.1       wdk 	/* PIZAZZ (Mips 3000 Magnum)  Address Map */
     79       1.1       wdk 	mipsco_bus_space_init(&obio_bustag, "obio",
     80       1.1       wdk 			      0x18000000, 0xb8000000,
     81       1.1       wdk 			      0xb8000000, 0x08000000);
     82       1.1       wdk 
     83       1.1       wdk 	_bus_dma_tag_init(&obio_dmatag);
     84       1.2       wdk 	obio_bustag.bs_intr_establish = obio_intr_establish; /* XXX */
     85       1.2       wdk 
     86       1.1       wdk 	ca->ca_bustag = &obio_bustag;
     87       1.1       wdk 	ca->ca_dmatag = &obio_dmatag;
     88       1.1       wdk 
     89       1.1       wdk 	printf("\n");
     90      1.10  drochner 	config_search_ia(obio_search, self, "obio", ca);
     91       1.1       wdk }
     92       1.1       wdk 
     93       1.1       wdk static int
     94  1.13.8.1     skrll obio_search(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux)
     95       1.1       wdk {
     96       1.1       wdk 	struct confargs *ca = aux;
     97       1.1       wdk 
     98       1.1       wdk 	ca->ca_addr = cf->cf_addr;
     99       1.3   thorpej 	ca->ca_name = cf->cf_name;
    100       1.1       wdk 
    101       1.4   thorpej 	if (config_match(parent, cf, ca) != 0)
    102       1.1       wdk 		config_attach(parent, cf, ca, obio_print);
    103       1.1       wdk 
    104       1.1       wdk 	return 0;
    105       1.1       wdk }
    106       1.1       wdk 
    107       1.1       wdk /*
    108       1.1       wdk  * Print out the confargs.  The (parent) name is non-NULL
    109       1.1       wdk  * when there was no match found by config_found().
    110       1.1       wdk  */
    111       1.1       wdk static int
    112  1.13.8.1     skrll obio_print(void *args, const char *name)
    113       1.1       wdk {
    114       1.1       wdk 	struct confargs *ca = args;
    115       1.1       wdk 
    116       1.1       wdk 	if (name)
    117       1.1       wdk 		return(QUIET);
    118       1.1       wdk 
    119       1.1       wdk 	if (ca->ca_addr != -1)
    120       1.7   thorpej 		aprint_normal(" addr 0x%x", ca->ca_addr);
    121       1.1       wdk 
    122       1.1       wdk 	return(UNCONF);
    123       1.1       wdk }
    124       1.1       wdk 
    125       1.2       wdk void
    126  1.13.8.1     skrll obio_intr_establish(bus_space_tag_t bst, int level, int pri, int flags, int (*func)(void *), void *arg)
    127       1.2       wdk {
    128       1.2       wdk 	(*platform.intr_establish)(level, func, arg);
    129       1.2       wdk }
    130