[BACK]Return to sa1111.c CVS log [TXT][DIR] Up to [local] / sys / arch / arm / sa11x0

Annotation of sys/arch/arm/sa11x0/sa1111.c, Revision 1.2

1.2     ! nbrk        1: /*     $Id: sa1111.c,v 1.1.1.1 2008/03/04 16:05:18 nbrk Exp $  */
1.1       nbrk        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/sa11x0/sa1111_reg.h>
                    104: #include <arm/sa11x0/sa11x0_var.h>
                    105: #include <arm/sa11x0/sa11x1_var.h>
                    106:
1.2     ! nbrk      107: //#include <arm/sa11x0/sa1111_gpiovar.h>
1.1       nbrk      108:
                    109: /* prototypes */
                    110: int    sacc_match(struct device *, void *, void *);
                    111: void   sacc_attach(struct device *, struct device *, void *);
                    112: int    sacc_search(struct device *, void *, void *);
                    113: int    sacc_print(void *, const char *);
1.2     ! nbrk      114: void   sacc_attach_critical(struct sacc_softc *sc);
1.1       nbrk      115:
                    116: /* attach structures */
                    117: struct cfattach sacc_ca = {
                    118:        sizeof(struct sacc_softc), sacc_match, sacc_attach
                    119: };
                    120:
                    121: struct cfdriver sacc_cd = {
                    122:        NULL, "sacc", DV_DULL
                    123: };
                    124:
                    125: struct sacc_softc *sacc_sc;
                    126:
                    127: int
                    128: sacc_match(struct device *parent, void *match, void *aux)
                    129: {
                    130:
                    131:        return 1;
                    132: }
                    133:
                    134: void
                    135: sacc_attach(struct device *parent, struct device *self, void *aux)
                    136: {
                    137:        struct sacc_softc *sc = (struct sacc_softc *)self;
                    138:        struct saip_attach_args *saa = aux;
                    139:        uint32_t        skid;
                    140:
                    141:        sacc_sc = sc;
                    142:        sc->sc_bust = &sa11x1_bs_tag;
1.2     ! nbrk      143:        sc->sc_intr = saa->sai_intr;
1.1       nbrk      144:
                    145:        /* XXX preserve our base addr for sa11x1_bs_map() */
                    146:        sa11x1_bs_tag.bs_cookie = &saa->sai_addr;
                    147:
1.2     ! nbrk      148:        /*
        !           149:         * Map whole I/O space.
        !           150:         */
        !           151:        if (bus_space_map(sc->sc_bust, 0, 128 * 12, 0, &sc->sc_ioh)) {
1.1       nbrk      152:                printf(": can't map i/o space\n");
                    153:                return;
                    154:        }
                    155:
                    156:        /*
                    157:         * Identify chip.
                    158:         */
1.2     ! nbrk      159:        skid = bus_space_read_4(sc->sc_bust, sc->sc_ioh, SACCSBI_SKID);
1.1       nbrk      160:        if ((skid & 0xffffff00) != 0x690cc200) {
                    161:                printf(": incorrect SA-1111 chip ID\n");
1.2     ! nbrk      162:                bus_space_unmap(sc->sc_bust, sc->sc_ioh, 128 * 12);
1.1       nbrk      163:                return;
                    164:        }
                    165:        printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f);
                    166:
                    167:        /*
1.2     ! nbrk      168:         * Attach critical devices.
        !           169:         */
        !           170:        sacc_attach_critical(sc);
        !           171:
        !           172:        /*
        !           173:         * Attach all other devices.
1.1       nbrk      174:         */
                    175:        config_search(sacc_search, self, sc);
                    176: }
                    177:
                    178: int
                    179: sacc_search(struct device *parent, void *c, void *aux)
                    180: {
                    181:        struct sacc_softc *sc = aux;
                    182:        struct sacc_attach_args aa;
                    183:        struct cfdata   *cf = c;
                    184:
                    185:        aa.sac_iot = sc->sc_bust;
                    186:        aa.sac_dmat = sc->sc_dmat;
                    187:
1.2     ! nbrk      188:        aa.sac_xintr = (cf->cf_loc)[0];
1.1       nbrk      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:
1.2     ! nbrk      200:        if (sa->sac_xintr != -1)
        !           201:                 printf(" xintr %d", sa->sac_xintr);
        !           202:
        !           203:        return (UNCONF);
        !           204: }
        !           205:
        !           206: void
        !           207: sacc_attach_critical(struct sacc_softc *sc)
        !           208: {
        !           209:        /*
        !           210:         * Attach Interrupt and GPIO controllers because
        !           211:         * their functionality is needed for the rest of our onboard devices.
        !           212:         */
        !           213:        struct sacc_attach_args saa;
        !           214:
        !           215:        saa.sac_iot = sc->sc_bust;
        !           216:        saa.sac_dmat = sc->sc_dmat;
1.1       nbrk      217:
1.2     ! nbrk      218:        /* XXX sac_xintr is an internal to us interrupt number, but here we use it
        !           219:                        to inform our INTC about which intr line it uses on main INTC.  */
        !           220:        saa.sac_xintr = sc->sc_intr;
        !           221:        saa.sac_typecookie = SACC_TYPE_INTC;
        !           222:        config_found(&sc->sc_dev, &saa, sacc_print);
        !           223:
        !           224: #if 0
        !           225:        saa.sac_xintr = -1;     /* is not widely used, spec defines most of them */
        !           226:        saa.sac_typecookie = SACC_TYPE_GPIO;
        !           227:        config_found(&sc->sc_dev, &saa, sacc_print);
        !           228: #endif
1.1       nbrk      229: }
                    230:

CVSweb