1/* $NetBSD: ubi.c,v 1.3 2010/12/14 23:44:50 matt Exp $ */ 2/* 3 * Copyright (c) 1999 Ludd, University of Lule}, Sweden. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed at Ludd, University of 17 * Lule}, Sweden and its contributors. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> 34__KERNEL_RCSID(0, "$NetBSD: ubi.c,v 1.3 2010/12/14 23:44:50 matt Exp $"); 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/bus.h> 39#include <sys/cpu.h> 40#include <sys/device.h> 41 42#include <machine/nexus.h> 43#include <machine/sid.h> 44#include <machine/ka730.h> 45 46static int ubi_print(void *, const char *); 47static int ubi_match(device_t, cfdata_t, void *); 48static void ubi_attach(device_t, device_t, void*); 49 50CFATTACH_DECL_NEW(ubi, 0, 51 ubi_match, ubi_attach, NULL, NULL); 52 53int 54ubi_print(void *aux, const char *name) 55{ 56 struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; 57 58 if (name) 59 aprint_normal("unknown device 0x%x at %s", sa->sa_type, name); 60 61 aprint_normal(" tr%d", sa->sa_nexnum); 62 return (UNCONF); 63} 64 65 66int 67ubi_match(device_t parent, cfdata_t cf, void *aux) 68{ 69 if (vax_bustype == VAX_UNIBUS) 70 return 1; 71 return 0; 72} 73 74void 75ubi_attach(device_t parent, device_t self, void *aux) 76{ 77 struct sbi_attach_args sa; 78 79 printf("\n"); 80 81 sa.sa_base = NEX730; 82 83#define NEXPAGES (sizeof(struct nexus) / VAX_NBPG) 84 85#if 0 86 /* 87 * Probe for memory, can be in the first 4 slots. 88 */ 89 90 for (sa.sa_nexnum = 0; sa.sa_nexnum < 4; sa.sa_nexnum++) { 91 sa.sa_ioh = vax_map_physmem(NEX730 + 92 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 93 if (badaddr((caddr_t)sa.sa_ioh, 4)) { 94 vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES); 95 } else { 96 sa.sa_type = NEX_MEM16; 97 config_found(self, (void*)&sa, ubi_print); 98 } 99 } 100#endif 101 102 /* VAX 730 fixed configuration */ 103 104 /* memory */ 105 sa.sa_nexnum = 0; 106 sa.sa_ioh = vax_map_physmem((int)NEX730 + 107 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 108 sa.sa_type = NEX_MEM16; 109 config_found(self, (void*)&sa, ubi_print); 110 111 printf("\n"); 112 113 /* generic UBA */ 114 sa.sa_nexnum = 3; 115 sa.sa_ioh = vax_map_physmem((int)NEX730 + 116 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 117 sa.sa_type = NEX_UBA0; 118 config_found(self, (void*)&sa, ubi_print); 119} 120