Annotation of sys/arch/arm/sa11x0/sa1111.c, Revision 1.1
1.1 ! nbrk 1: /* $Id$ */
! 2: /*
! 3: * Copyright (c) 2002 Genetec Corporation. All rights reserved.
! 4: * Written by Hiroyuki Bessho for Genetec Corporation.
! 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 for the NetBSD Project by
! 17: * Genetec Corporation.
! 18: * 4. The name of Genetec Corporation may not be used to endorse or
! 19: * promote products derived from this software without specific prior
! 20: * written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
! 23: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 24: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 25: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
! 26: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 27: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 28: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 29: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 30: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 31: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 32: * POSSIBILITY OF SUCH DAMAGE.
! 33: *
! 34: */
! 35:
! 36: /*-
! 37: * Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved.
! 38: *
! 39: * This code is derived from software contributed to The NetBSD Foundation
! 40: * by IWAMOTO Toshihiro and Ichiro FUKUHARA.
! 41: *
! 42: * Redistribution and use in source and binary forms, with or without
! 43: * modification, are permitted provided that the following conditions
! 44: * are met:
! 45: * 1. Redistributions of source code must retain the above copyright
! 46: * notice, this list of conditions and the following disclaimer.
! 47: * 2. Redistributions in binary form must reproduce the above copyright
! 48: * notice, this list of conditions and the following disclaimer in the
! 49: * documentation and/or other materials provided with the distribution.
! 50: * 3. All advertising materials mentioning features or use of this software
! 51: * must display the following acknowledgement:
! 52: * This product includes software developed by the NetBSD
! 53: * Foundation, Inc. and its contributors.
! 54: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 55: * contributors may be used to endorse or promote products derived
! 56: * from this software without specific prior written permission.
! 57: */
! 58: /*-
! 59: * Copyright (c) 1999
! 60: * Shin Takemura and PocketBSD Project. All rights reserved.
! 61: *
! 62: * Redistribution and use in source and binary forms, with or without
! 63: * modification, are permitted provided that the following conditions
! 64: * are met:
! 65: * 1. Redistributions of source code must retain the above copyright
! 66: * notice, this list of conditions and the following disclaimer.
! 67: * 2. Redistributions in binary form must reproduce the above copyright
! 68: * notice, this list of conditions and the following disclaimer in the
! 69: * documentation and/or other materials provided with the distribution.
! 70: * 3. All advertising materials mentioning features or use of this software
! 71: * must display the following acknowledgement:
! 72: * This product includes software developed by the PocketBSD project
! 73: * and its contributors.
! 74: * 4. Neither the name of the project nor the names of its contributors
! 75: * may be used to endorse or promote products derived from this software
! 76: * without specific prior written permission.
! 77: *
! 78: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 79: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 80: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 81: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 82: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 83: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 84: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 85: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 86: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 87: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 88: * SUCH DAMAGE.
! 89: *
! 90: */
! 91:
! 92: #include <sys/cdefs.h>
! 93:
! 94: #include <sys/param.h>
! 95: #include <sys/systm.h>
! 96: #include <sys/device.h>
! 97: #include <sys/kernel.h>
! 98: #include <sys/reboot.h>
! 99:
! 100: #include <machine/cpu.h>
! 101: #include <machine/bus.h>
! 102:
! 103: //#include <arm/mainbus/mainbus.h>
! 104:
! 105: #include <arm/sa11x0/sa1111_reg.h>
! 106: #include <arm/sa11x0/sa11x0_var.h>
! 107: #include <arm/sa11x0/sa11x1_var.h>
! 108:
! 109: struct sacc_softc {
! 110: struct device sc_dev;
! 111: bus_space_tag_t sc_bust;
! 112: bus_dma_tag_t sc_dmat;
! 113: };
! 114:
! 115: /* prototypes */
! 116: int sacc_match(struct device *, void *, void *);
! 117: void sacc_attach(struct device *, struct device *, void *);
! 118: int sacc_search(struct device *, void *, void *);
! 119: int sacc_print(void *, const char *);
! 120:
! 121: /* attach structures */
! 122: struct cfattach sacc_ca = {
! 123: sizeof(struct sacc_softc), sacc_match, sacc_attach
! 124: };
! 125:
! 126: struct cfdriver sacc_cd = {
! 127: NULL, "sacc", DV_DULL
! 128: };
! 129:
! 130: struct sacc_softc *sacc_sc;
! 131:
! 132: int
! 133: sacc_match(struct device *parent, void *match, void *aux)
! 134: {
! 135:
! 136: return 1;
! 137: }
! 138:
! 139: void
! 140: sacc_attach(struct device *parent, struct device *self, void *aux)
! 141: {
! 142: struct sacc_softc *sc = (struct sacc_softc *)self;
! 143: struct saip_attach_args *saa = aux;
! 144: bus_space_handle_t sbih;
! 145: uint32_t skid;
! 146:
! 147: sacc_sc = sc;
! 148: sc->sc_bust = &sa11x1_bs_tag;
! 149:
! 150: /* XXX preserve our base addr for sa11x1_bs_map() */
! 151: sa11x1_bs_tag.bs_cookie = &saa->sai_addr;
! 152:
! 153: /* map SBI module */
! 154: if (bus_space_map(sc->sc_bust, 0 /* SACCSBI_BASE */, 3 /* SACCSBI_SIZE */, 0, &sbih)) {
! 155: printf(": can't map i/o space\n");
! 156: return;
! 157: }
! 158:
! 159: /*
! 160: * Identify chip.
! 161: */
! 162: skid = bus_space_read_4(sc->sc_bust, sbih, SACCSBI_SKID);
! 163: bus_space_unmap(sc->sc_bust, sbih, 3 /* SACCSBI_SIZE */);
! 164: if ((skid & 0xffffff00) != 0x690cc200) {
! 165: printf(": incorrect SA-1111 chip ID\n");
! 166: return;
! 167: }
! 168: printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f);
! 169:
! 170: /*
! 171: * Attach all other devices
! 172: */
! 173: config_search(sacc_search, self, sc);
! 174: }
! 175:
! 176: int
! 177: sacc_search(struct device *parent, void *c, void *aux)
! 178: {
! 179: struct sacc_softc *sc = aux;
! 180: struct sacc_attach_args aa;
! 181: struct cfdata *cf = c;
! 182:
! 183: aa.sac_iot = sc->sc_bust;
! 184: aa.sac_dmat = sc->sc_dmat;
! 185:
! 186: aa.sac_addr = (cf->cf_loc)[0];
! 187: aa.sac_size = (cf->cf_loc)[1];
! 188: aa.sac_intr = (cf->cf_loc)[2];
! 189:
! 190: config_found(parent, &aa, sacc_print);
! 191:
! 192: return 0;
! 193: }
! 194:
! 195: int
! 196: sacc_print(void *aux, const char *name)
! 197: {
! 198: struct sacc_attach_args *sa = (struct sacc_attach_args*)aux;
! 199:
! 200: if (sa->sac_addr != -1) {
! 201: printf(" addr 0x%lx", sa->sac_addr);
! 202: if (sa->sac_size > -1)
! 203: printf("-0x%lx", sa->sac_addr + sa->sac_size-1);
! 204: }
! 205: if (sa->sac_intr != -1)
! 206: printf(" xintr %d", sa->sac_intr);
! 207:
! 208: return (UNCONF);
! 209: }
! 210:
CVSweb