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

Annotation of sys/arch/hp300/dev/sgc.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: sgc.c,v 1.5 2007/01/06 20:10:57 miod Exp $    */
                      2:
                      3: /*
                      4:  * Copyright (c) 2005, Miodrag Vallat
                      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:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     18:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
                     19:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     20:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     23:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                     24:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     25:  * POSSIBILITY OF SUCH DAMAGE.
                     26:  *
                     27:  */
                     28:
                     29: /*
                     30:  * SGC bus attachment and mapping glue.
                     31:  */
                     32:
                     33: #include <sys/param.h>
                     34: #include <sys/systm.h>
                     35: #include <sys/device.h>
                     36: #include <sys/kernel.h>
                     37:
                     38: #include <machine/autoconf.h>
                     39: #include <machine/bus.h>
                     40: #include <machine/cpu.h>
                     41: #include <machine/hp300spu.h>
                     42:
                     43: #include <hp300/dev/sgcreg.h>
                     44: #include <hp300/dev/sgcvar.h>
                     45:
                     46: int    sgcmatch(struct device *, void *, void *);
                     47: void   sgcattach(struct device *, struct device *, void *);
                     48: int    sgcprint(void *, const char *);
                     49:
                     50: struct cfattach sgc_ca = {
                     51:        sizeof(struct device), sgcmatch, sgcattach
                     52: };
                     53:
                     54: struct cfdriver sgc_cd = {
                     55:        NULL, "sgc", DV_DULL
                     56: };
                     57:
                     58: int
                     59: sgcmatch(parent, match, aux)
                     60:        struct device *parent;
                     61:        void *match, *aux;
                     62: {
                     63: static int sgc_matched = 0;
                     64:
                     65:        /* Allow only one instance. */
                     66:        if (sgc_matched)
                     67:                return (0);
                     68:
                     69:        /*
                     70:         * Leave out machines which can not have an SGC bus.
                     71:         */
                     72:
                     73:        if (machineid != HP_400 && machineid != HP_425 &&
                     74:            machineid != HP_433)
                     75:                return (0);
                     76:
                     77:        return (sgc_matched = 1);
                     78: }
                     79:
                     80: void
                     81: sgcattach(parent, self, aux)
                     82:        struct device *parent, *self;
                     83:        void *aux;
                     84: {
                     85:        struct sgc_attach_args saa;
                     86:        caddr_t pa, va;
                     87:        int slot, rv;
                     88:        extern struct hp300_bus_space_tag hp300_mem_tag;
                     89:
                     90:        printf("\n");
                     91:
                     92:        for (slot = 0; slot < SGC_NSLOTS; slot++) {
                     93:                pa = sgc_slottopa(slot);
                     94:                va = iomap(pa, PAGE_SIZE);
                     95:                if (va == NULL) {
                     96:                        printf("%s: can't map slot %d\n", self->dv_xname, slot);
                     97:                        continue;
                     98:                }
                     99:
                    100:                /* Check for hardware. */
                    101:                rv = badaddr(va);
                    102:                iounmap(va, PAGE_SIZE);
                    103:
                    104:                if (rv != 0)
                    105:                        continue;
                    106:
                    107:                bzero(&saa, sizeof(saa));
                    108:                saa.saa_slot = slot;
                    109:                saa.saa_iot = &hp300_mem_tag;
                    110:
                    111:                /* Attach matching device. */
                    112:                config_found(self, &saa, sgcprint);
                    113:        }
                    114: }
                    115:
                    116: int
                    117: sgcprint(aux, pnp)
                    118:        void *aux;
                    119:        const char *pnp;
                    120: {
                    121:        struct sgc_attach_args *saa = aux;
                    122:
                    123:        if (pnp)
                    124:                printf("unknown SGC card at %s", pnp);
                    125:        printf(" slot %d", saa->saa_slot);
                    126:        return (UNCONF);
                    127: }
                    128:
                    129: /*
                    130:  * Convert a slot number to a system physical address.
                    131:  * This is needed for bus_space.
                    132:  */
                    133: void *
                    134: sgc_slottopa(int slot)
                    135: {
                    136:        u_long rval;
                    137:
                    138:        if (slot < 0 || slot >= SGC_NSLOTS)
                    139:                rval = 0;
                    140:        else
                    141:                rval = SGC_BASE + (slot * SGC_DEVSIZE);
                    142:
                    143:        return ((void *)rval);
                    144: }

CVSweb