[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.4

1.4     ! nbrk        1: /*     $Id: sa1111.c,v 1.3 2008/03/05 13:35:45 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:         */
1.4     ! nbrk      151: //     if (bus_space_map(sc->sc_bust, 0, 128 * 12, 0, &sc->sc_ioh)) {
        !           152:        if (bus_space_map(sc->sc_bust, 0, saa->sai_size, 0, &sc->sc_ioh)) {
1.1       nbrk      153:                printf(": can't map i/o space\n");
                    154:                return;
                    155:        }
                    156:
                    157:        /*
                    158:         * Identify chip.
                    159:         */
1.2       nbrk      160:        skid = bus_space_read_4(sc->sc_bust, sc->sc_ioh, SACCSBI_SKID);
1.1       nbrk      161:        if ((skid & 0xffffff00) != 0x690cc200) {
                    162:                printf(": incorrect SA-1111 chip ID\n");
1.2       nbrk      163:                bus_space_unmap(sc->sc_bust, sc->sc_ioh, 128 * 12);
1.1       nbrk      164:                return;
                    165:        }
                    166:        printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f);
                    167:
                    168:        /*
1.4     ! nbrk      169:         * Attach critical devices (GPIO and Interrupt controllers).
1.2       nbrk      170:         */
                    171:        sacc_attach_critical(sc);
                    172:
                    173:        /*
                    174:         * Attach all other devices.
1.1       nbrk      175:         */
                    176:        config_search(sacc_search, self, sc);
                    177: }
                    178:
                    179: int
                    180: sacc_search(struct device *parent, void *c, void *aux)
                    181: {
                    182:        struct sacc_softc *sc = aux;
                    183:        struct sacc_attach_args aa;
                    184:        struct cfdata   *cf = c;
                    185:
                    186:        aa.sac_iot = sc->sc_bust;
                    187:        aa.sac_dmat = sc->sc_dmat;
1.3       nbrk      188:        aa.sac_bush = sc->sc_ioh;
1.1       nbrk      189:
1.2       nbrk      190:        aa.sac_xintr = (cf->cf_loc)[0];
1.1       nbrk      191:
                    192:        config_found(parent, &aa, sacc_print);
                    193:
                    194:        return 0;
                    195: }
                    196:
                    197: int
                    198: sacc_print(void *aux, const char *name)
                    199: {
                    200:        struct sacc_attach_args *sa = (struct sacc_attach_args*)aux;
                    201:
1.2       nbrk      202:        if (sa->sac_xintr != -1)
                    203:                 printf(" xintr %d", sa->sac_xintr);
                    204:
                    205:        return (UNCONF);
                    206: }
                    207:
                    208: void
                    209: sacc_attach_critical(struct sacc_softc *sc)
                    210: {
                    211:        /*
                    212:         * Attach Interrupt and GPIO controllers because
                    213:         * their functionality is needed for the rest of our onboard devices.
                    214:         */
                    215:        struct sacc_attach_args saa;
                    216:
                    217:        saa.sac_iot = sc->sc_bust;
                    218:        saa.sac_dmat = sc->sc_dmat;
1.3       nbrk      219:        saa.sac_bush = sc->sc_ioh;
1.1       nbrk      220:
1.2       nbrk      221:        /* XXX sac_xintr is an internal to us interrupt number, but here we use it
                    222:                        to inform our INTC about which intr line it uses on main INTC.  */
                    223:        saa.sac_xintr = sc->sc_intr;
                    224:        saa.sac_typecookie = SACC_TYPE_INTC;
                    225:        config_found(&sc->sc_dev, &saa, sacc_print);
                    226:
                    227:        saa.sac_xintr = -1;     /* is not widely used, spec defines most of them */
                    228:        saa.sac_typecookie = SACC_TYPE_GPIO;
                    229:        config_found(&sc->sc_dev, &saa, sacc_print);
1.1       nbrk      230: }
                    231:

CVSweb