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