sbdio.c revision 1.1
1/* $NetBSD: sbdio.c,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */ 2 3/*- 4 * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by UCHIYAMA Yasushi. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39#include <sys/cdefs.h> 40__KERNEL_RCSID(0, "$NetBSD: sbdio.c,v 1.1 2005/12/29 15:20:09 tsutsui Exp $"); 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/device.h> 45 46#include <machine/autoconf.h> 47#define _EWS4800MIPS_BUS_DMA_PRIVATE 48#include <machine/bus.h> 49#include <machine/sbdvar.h> 50#include <machine/sbdiovar.h> 51 52#include "ioconf.h" 53 54struct sbdio_softc { 55 struct device sc_dev; 56 struct ews4800mips_bus_space sc_bus_tag; 57 struct ews4800mips_bus_dma_tag sc_dma_tag; 58}; 59 60int sbdio_match(struct device *, struct cfdata *, void *); 61void sbdio_attach(struct device *, struct device *, void *); 62int sbdio_print(void *, const char *); 63 64CFATTACH_DECL(sbdio, sizeof(struct sbdio_softc), 65 sbdio_match, sbdio_attach, NULL, NULL); 66 67static int sbdio_found; 68 69int 70sbdio_match(struct device *parent, struct cfdata *match, void *aux) 71{ 72 struct mainbus_attach_args *ma = aux; 73 74 if (sbdio_found != 0) 75 return 0; 76 77 if (strcmp(ma->ma_name, sbdio_cd.cd_name) != 0) 78 return 0; 79 80 if (platform.sbdiodevs == NULL) 81 return 0; 82 83 return 1; 84} 85 86void 87sbdio_attach(struct device *parent, struct device *self, void *aux) 88{ 89 struct sbdio_softc *sc = (void *)self; 90 struct sbdio_attach_args sa; 91 const struct sbdiodevdesc *sd; 92 93 sbdio_found = 1; 94 95 printf("\n"); 96 97 /* structure assignment */ 98 sc->sc_dma_tag = ews4800mips_default_bus_dma_tag; 99 100 bus_space_create(&sc->sc_bus_tag, sc->sc_dev.dv_xname, 101 MIPS_KSEG1_START, MIPS_KSEG2_START - MIPS_KSEG1_START); /* XXX */ 102 103 for (sd = platform.sbdiodevs; sd->sd_name != NULL; sd++) { 104 sa.sa_name = sd->sd_name; 105 sa.sa_bust = &sc->sc_bus_tag; 106 sa.sa_dmat = &sc->sc_dma_tag; 107 sa.sa_addr1 = sd->sd_addr1; 108 sa.sa_addr2 = sd->sd_addr2; 109 sa.sa_irq = sd->sd_irq; 110 sa.sa_flags = sd->sd_flags; 111 config_found(self, &sa, sbdio_print); 112 } 113} 114 115int 116sbdio_print(void *aux, const char *pnp) 117{ 118 119 return pnp ? QUIET : UNCONF; 120} 121