[BACK]Return to omapl1x_tipb.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / arm / omap

Annotation of src/sys/arch/arm/omap/omapl1x_tipb.c, Revision 1.1.4.2

1.1.4.2 ! rmind       1:
        !             2: /*
        !             3:  * Autoconfiguration support for the Texas Instruments OMAP TIPB.
        !             4:  * Based on arm/xscale/pxa2x0.c which in turn was derived from
        !             5:  * arm/sa11x0/sa11x0.c.  The code to do the early attach was initially derived
        !             6:  * from arch/sparc/dev/obio.c.
        !             7:  *
        !             8:  * Copyright (c) 2002, 2005  Genetec Corporation.  All rights reserved.
        !             9:  * Written by Hiroyuki Bessho for Genetec Corporation.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  * 3. All advertising materials mentioning features or use of this software
        !            20:  *    must display the following acknowledgement:
        !            21:  *     This product includes software developed for the NetBSD Project by
        !            22:  *     Genetec Corporation.
        !            23:  * 4. The name of Genetec Corporation may not be used to endorse or
        !            24:  *    promote products derived from this software without specific prior
        !            25:  *    written permission.
        !            26:  *
        !            27:  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
        !            28:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
        !            31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            37:  * POSSIBILITY OF SUCH DAMAGE.
        !            38:  *
        !            39:  * Copyright (c) 1997, 1998, 2001, The NetBSD Foundation, Inc.
        !            40:  * All rights reserved.
        !            41:  *
        !            42:  * This code is derived from software contributed to The NetBSD Foundation
        !            43:  * by IWAMOTO Toshihiro, Ichiro FUKUHARA and Paul Kranenburg.
        !            44:  *
        !            45:  * Redistribution and use in source and binary forms, with or without
        !            46:  * modification, are permitted provided that the following conditions
        !            47:  * are met:
        !            48:  * 1. Redistributions of source code must retain the above copyright
        !            49:  *    notice, this list of conditions and the following disclaimer.
        !            50:  * 2. Redistributions in binary form must reproduce the above copyright
        !            51:  *    notice, this list of conditions and the following disclaimer in the
        !            52:  *    documentation and/or other materials provided with the distribution.
        !            53:  *
        !            54:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            55:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            56:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            57:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            58:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            59:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            60:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            61:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            62:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            63:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            64:  * POSSIBILITY OF SUCH DAMAGE.
        !            65:  *
        !            66:  * Copyright (c) 1999
        !            67:  *         Shin Takemura and PocketBSD Project. All rights reserved.
        !            68:  *
        !            69:  * Redistribution and use in source and binary forms, with or without
        !            70:  * modification, are permitted provided that the following conditions
        !            71:  * are met:
        !            72:  * 1. Redistributions of source code must retain the above copyright
        !            73:  *    notice, this list of conditions and the following disclaimer.
        !            74:  * 2. Redistributions in binary form must reproduce the above copyright
        !            75:  *    notice, this list of conditions and the following disclaimer in the
        !            76:  *    documentation and/or other materials provided with the distribution.
        !            77:  * 3. All advertising materials mentioning features or use of this software
        !            78:  *    must display the following acknowledgement:
        !            79:  *     This product includes software developed by the PocketBSD project
        !            80:  *     and its contributors.
        !            81:  * 4. Neither the name of the project nor the names of its contributors
        !            82:  *    may be used to endorse or promote products derived from this software
        !            83:  *    without specific prior written permission.
        !            84:  *
        !            85:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            86:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            87:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            88:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            89:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            90:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            91:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            92:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            93:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            94:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            95:  * SUCH DAMAGE.
        !            96:  */
        !            97:
        !            98: #include <sys/cdefs.h>
        !            99:
        !           100: __KERNEL_RCSID(0, "$NetBSD$");
        !           101:
        !           102: #include "locators.h"
        !           103:
        !           104: #include <sys/param.h>
        !           105: #include <sys/systm.h>
        !           106: #include <sys/device.h>
        !           107: #include <sys/kernel.h>
        !           108: #include <sys/reboot.h>
        !           109: #include <sys/bus.h>
        !           110:
        !           111: #include <machine/cpu.h>
        !           112:
        !           113:
        !           114: #include <arm/cpufunc.h>
        !           115: #include <arm/mainbus/mainbus.h>
        !           116: /*
        !           117:  * XXX. Do we really need this ? #include <arm/omap/omap_reg.h>
        !           118:  * Atleast commenting this makes it more generic.
        !           119:  */
        !           120: #include <arm/omap/omap_tipb.h>
        !           121: #include <arm/omap/omap_var.h>
        !           122:
        !           123: struct tipb_softc {
        !           124:        struct device sc_dev;
        !           125:        bus_dma_tag_t sc_dmac;
        !           126: };
        !           127:
        !           128: /* prototypes */
        !           129: static int     tipb_match(struct device *, struct cfdata *, void *);
        !           130: static void    tipb_attach(struct device *, struct device *, void *);
        !           131: static int     tipb_search(struct device *, struct cfdata *,
        !           132:                             const int *, void *);
        !           133: static int     tipb_print(void *, const char *);
        !           134:
        !           135: /* attach structures */
        !           136: CFATTACH_DECL_NEW(tipb, sizeof(struct tipb_softc),
        !           137:     tipb_match, tipb_attach, NULL, NULL);
        !           138:
        !           139: static int tipb_attached;
        !           140:
        !           141: extern struct arm32_bus_dma_tag omapl1x_bus_dma_tag;
        !           142:
        !           143: /*
        !           144:  * There are some devices that need to be set up before all the others.  The
        !           145:  * earlies array contains their names.  tipb_attach() and tipb_search() work
        !           146:  * together to attach these devices in the order they appear in this array
        !           147:  * before any other TIPB devices are attached.
        !           148:  */
        !           149: static const char * const earlies[] = {
        !           150:        OMAP_INTC_DEVICE,
        !           151:        "omapl1xtimer",
        !           152:        "omapl1xpsc",
        !           153:        NULL
        !           154: };
        !           155:
        !           156: static int
        !           157: tipb_match(struct device *parent, struct cfdata *match, void *aux)
        !           158: {
        !           159:        if (tipb_attached)
        !           160:                return 0;
        !           161:        return 1;
        !           162: }
        !           163:
        !           164: static void
        !           165: tipb_attach(struct device *parent, struct device *self, void *aux)
        !           166: {
        !           167:        struct tipb_softc *sc = (struct tipb_softc *)self;
        !           168:
        !           169:        tipb_attached = 1;
        !           170:
        !           171: #if NOMAPDMAC > 0
        !           172: #error DMA not implemented
        !           173:        sc->sc_dmac = &omap_bus_dma_tag;
        !           174: #else
        !           175:        sc->sc_dmac = omap_bus_dma_init(&omapl1x_bus_dma_tag);
        !           176: #endif
        !           177:
        !           178:        aprint_normal(": OMAP L1X Texas Instruments Peripheral Bus\n");
        !           179:        aprint_naive("\n");
        !           180:
        !           181:        /*
        !           182:         * There are some devices that need to be set up before all the
        !           183:         * others.  The earlies array contains their names.  Find them and
        !           184:         * attach them in the order they appear in the array.
        !           185:         */
        !           186:        const char *const *earlyp;
        !           187:        for (earlyp = earlies; *earlyp != NULL; earlyp++)
        !           188:                /*
        !           189:                 * The bus search function is passed an aux argument that
        !           190:                 * "describes the device that has been found".  The type of it
        !           191:                 * is void *.  However, I want to pass a constant string, so
        !           192:                 * use __UNCONST to convince the compiler that this is ok.
        !           193:                 */
        !           194:                config_search_ia(tipb_search, self, "tipb",
        !           195:                                 __UNCONST(*earlyp));
        !           196:
        !           197:        /*
        !           198:         * Attach all other devices
        !           199:         */
        !           200:        config_search_ia(tipb_search, self, "tipb", NULL);
        !           201: }
        !           202:
        !           203: static int
        !           204: tipb_search(struct device *parent, struct cfdata *cf,
        !           205:             const int *ldesc, void *aux)
        !           206: {
        !           207:        struct tipb_softc *sc = (struct tipb_softc *)parent;
        !           208:        struct tipb_attach_args aa;
        !           209:        const char *const name = (const char *const)aux;
        !           210:
        !           211:        /* Check whether we're looking for a specifically named device */
        !           212:        if (name != NULL && strcmp(name, cf->cf_name) != 0)
        !           213:                return (0);
        !           214:
        !           215:        switch (cf->cf_loc[TIPBCF_MULT]) {
        !           216:        case 1:
        !           217:                aa.tipb_iot = &omap_bs_tag;
        !           218:                break;
        !           219:        case 2:
        !           220:                aa.tipb_iot = &omap_a2x_bs_tag;
        !           221:                break;
        !           222:        case 4:
        !           223:                aa.tipb_iot = &omap_a4x_bs_tag;
        !           224:                break;
        !           225:        default:
        !           226:                panic("Unsupported TIPB multiplier.");
        !           227:                break;
        !           228:        }
        !           229:        aa.tipb_dmac = sc->sc_dmac;
        !           230:        aa.tipb_addr = cf->cf_loc[TIPBCF_ADDR];
        !           231:        aa.tipb_size = cf->cf_loc[TIPBCF_SIZE];
        !           232:        aa.tipb_intr = cf->cf_loc[TIPBCF_INTR];
        !           233:        aa.tipb_mult = cf->cf_loc[TIPBCF_MULT];
        !           234:
        !           235:        if (config_match(parent, cf, &aa))
        !           236:                config_attach(parent, cf, &aa, tipb_print);
        !           237:
        !           238:        return 0;
        !           239: }
        !           240:
        !           241: static int
        !           242: tipb_print(void *aux, const char *name)
        !           243: {
        !           244:        struct tipb_attach_args *sa = (struct tipb_attach_args*)aux;
        !           245:
        !           246:        if (sa->tipb_addr != TIPBCF_ADDR_DEFAULT) {
        !           247:                aprint_normal(" addr 0x%08lx", sa->tipb_addr);
        !           248:                if (sa->tipb_size > TIPBCF_SIZE_DEFAULT)
        !           249:                        aprint_normal("-0x%08lx", sa->tipb_addr + sa->tipb_size-1);
        !           250:        }
        !           251:        if (sa->tipb_intr != TIPBCF_INTR_DEFAULT)
        !           252:                aprint_normal(" intr %d", sa->tipb_intr);
        !           253:
        !           254:        return (UNCONF);
        !           255: }

CVSweb <webmaster@jp.NetBSD.org>