[BACK]Return to obio.c CVS log [TXT][DIR] Up to [local] / sys / arch / armish / dev

Annotation of sys/arch/armish/dev/obio.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: obio.c,v 1.3 2006/06/01 17:06:16 drahn Exp $  */
        !             2: /*     $NetBSD: obio.c,v 1.14 2005/12/11 12:17:09 christos Exp $       */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms, with or without
        !            11:  * modification, are permitted provided that the following conditions
        !            12:  * are met:
        !            13:  * 1. Redistributions of source code must retain the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer.
        !            15:  * 2. Redistributions in binary form must reproduce the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer in the
        !            17:  *    documentation and/or other materials provided with the distribution.
        !            18:  * 3. All advertising materials mentioning features or use of this software
        !            19:  *    must display the following acknowledgement:
        !            20:  *     This product includes software developed for the NetBSD Project by
        !            21:  *     Wasabi Systems, Inc.
        !            22:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
        !            23:  *    or promote products derived from this software without specific prior
        !            24:  *    written permission.
        !            25:  *
        !            26:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
        !            27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
        !            30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            36:  * POSSIBILITY OF SUCH DAMAGE.
        !            37:  */
        !            38:
        !            39: /*
        !            40:  * On-board device autoconfiguration support for Intel IQ80321
        !            41:  * evaluation boards.
        !            42:  */
        !            43:
        !            44: #include <sys/param.h>
        !            45: #include <sys/systm.h>
        !            46: #include <sys/device.h>
        !            47:
        !            48: #include <machine/bus.h>
        !            49:
        !            50: #include <arm/mainbus/mainbus.h>
        !            51: #include <arm/xscale/i80321reg.h>
        !            52: #include <armish/dev/iq80321reg.h>
        !            53: #include <armish/dev/iq80321var.h>
        !            54: #include <armish/dev/obiovar.h>
        !            55:
        !            56: int    obio_match(struct device *, void *, void *);
        !            57: void   obio_attach(struct device *, struct device *, void *);
        !            58:
        !            59: struct cfattach obio_ca = {
        !            60:        sizeof(struct device), obio_match, obio_attach
        !            61: };
        !            62:
        !            63: struct cfdriver obio_cd = {
        !            64:        NULL, "obio", DV_DULL
        !            65: };
        !            66:
        !            67: int    obio_print(void *, const char *);
        !            68: int    obio_search(struct device *, void *, void *);
        !            69:
        !            70: /* there can be only one */
        !            71: int    obio_found;
        !            72:
        !            73: int
        !            74: obio_match(struct device *parent, void *match, void *aux)
        !            75: {
        !            76:        struct mainbus_attach_args *ma = aux;
        !            77:        struct cfdata *cf = match;
        !            78:
        !            79:        if (obio_found)
        !            80:                return (0);
        !            81:
        !            82:        if (strcmp(cf->cf_driver->cd_name, ma->ma_name) == 0)
        !            83:                return (1);
        !            84:
        !            85:        return (0);
        !            86: }
        !            87:
        !            88: void
        !            89: obio_attach(struct device *parent, struct device *self, void *aux)
        !            90: {
        !            91:         struct device *sc = self;
        !            92:
        !            93:
        !            94:        obio_found = 1;
        !            95:
        !            96:        printf("\n");
        !            97:
        !            98:        /*
        !            99:         * Attach all the on-board devices as described in the kernel
        !           100:         * configuration file.
        !           101:         */
        !           102:        config_search(obio_search, self, sc);
        !           103: }
        !           104:
        !           105: int
        !           106: obio_print(void *aux, const char *pnp)
        !           107: {
        !           108:        struct obio_attach_args *oba = aux;
        !           109:
        !           110:        printf(" addr 0x%08lx", oba->oba_addr);
        !           111:
        !           112:         if (oba->oba_irq != -1)
        !           113:                 printf(" intr %d", oba->oba_irq);
        !           114:
        !           115:
        !           116:        return (UNCONF);
        !           117: }
        !           118:
        !           119: int
        !           120: obio_search(struct device *parent, void *v, void *aux)
        !           121: {
        !           122:        struct obio_attach_args oba;
        !           123:        struct cfdata   *cf = v;
        !           124:
        !           125:        oba.oba_st = &obio_bs_tag;
        !           126:        oba.oba_addr = cf->cf_loc[0];
        !           127:        oba.oba_size = cf->cf_loc[1];
        !           128:        oba.oba_width = cf->cf_loc[2];
        !           129:        if (cf->cf_loc[3] != -1)
        !           130:                oba.oba_irq = ICU_INT_XINT(cf->cf_loc[3]);
        !           131:        else
        !           132:                oba.oba_irq = -1;
        !           133:
        !           134:        config_found(parent, &oba, obio_print);
        !           135:
        !           136:
        !           137:        return (0);
        !           138: }

CVSweb