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

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

1.1       nbrk        1: /*      $NetBSD: sa11x1_pcic.c,v 1.16 2007/10/17 19:53:43 garbled Exp $        */
                      2:
                      3: /*-
                      4:  * Copyright (c) 2001 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by IWAMOTO Toshihiro.
                      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 by the NetBSD
                     21:  *        Foundation, Inc. and its contributors.
                     22:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     23:  *    contributors may be used to endorse or promote products derived
                     24:  *    from this software without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     27:  * ``AS IS'' AND 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 THE FOUNDATION OR CONTRIBUTORS
                     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: #include <sys/cdefs.h>
                     40:
                     41: #include <sys/param.h>
                     42: #include <sys/systm.h>
                     43: #include <sys/types.h>
                     44: #include <sys/conf.h>
                     45: #include <sys/file.h>
                     46: #include <sys/device.h>
                     47: #include <sys/kernel.h>
                     48: #include <sys/kthread.h>
                     49: #include <sys/malloc.h>
1.2     ! nbrk       50: #include <sys/mutex.h>
1.1       nbrk       51:
                     52: #include <machine/bus.h>
                     53:
                     54: #include <dev/pcmcia/pcmciachip.h>
                     55: #include <dev/pcmcia/pcmciavar.h>
                     56: #include <arm/sa11x0/sa11x0_reg.h>
                     57: #include <arm/sa11x0/sa11x0_var.h>
                     58: #include <arm/sa11x0/sa1111_reg.h>
1.2     ! nbrk       59: #include <arm/sa11x0/sa11x1_var.h>
1.1       nbrk       60: #include <arm/sa11x0/sa11x1_pcicreg.h>
                     61: #include <arm/sa11x0/sa11xx_pcicvar.h>
                     62: #include <arm/sa11x0/sa11x1_pcicvar.h>
1.2     ! nbrk       63: #include <arm/sa11x0/sa1111_intr.h>
1.1       nbrk       64:
1.2     ! nbrk       65: //#include "sacpcic.h"
1.1       nbrk       66:
                     67: static int     sacpcic_print(void *, const char *);
                     68:
1.2     ! nbrk       69: struct cfdriver        sacpcic_cd = {
        !            70:        NULL,
        !            71:        "sacpcic",
        !            72:        DV_DULL
        !            73: };
        !            74:
        !            75:
1.1       nbrk       76: void
                     77: sacpcic_attach_common(struct sacc_softc *psc, struct sacpcic_softc *sc,
                     78:     void *aux, void (* socket_setup_hook)(struct sapcic_socket *))
                     79: {
                     80:        int i;
                     81:        struct pcmciabus_attach_args paa;
                     82:
1.2     ! nbrk       83:        printf(": SA-11x1 CF/PCMCIA controller\n");
1.1       nbrk       84:
1.2     ! nbrk       85:        sc->sc_pc.sc_iot = psc->sc_bust;
1.1       nbrk       86:        sc->sc_ioh = psc->sc_ioh;
                     87:
                     88:        for (i = 0; i < 2; i++) {
                     89:                sc->sc_socket[i].sc = (struct sapcic_softc *)sc;
                     90:                sc->sc_socket[i].socket = i;
                     91:                sc->sc_socket[i].pcictag_cookie = psc;
                     92:                sc->sc_socket[i].pcictag = NULL;
1.2     ! nbrk       93: //             sc->sc_socket[i].event_thread = NULL;
1.1       nbrk       94:                sc->sc_socket[i].event = 0;
                     95:                sc->sc_socket[i].laststatus = SAPCIC_CARD_INVALID;
                     96:                sc->sc_socket[i].shutdown = 0;
                     97:
                     98:                socket_setup_hook(&sc->sc_socket[i]);
                     99:
                    100:                paa.paa_busname = "pcmcia";
                    101:                paa.pct = (pcmcia_chipset_tag_t)&sa11x0_pcmcia_functions;
                    102:                paa.pch = (pcmcia_chipset_handle_t)&sc->sc_socket[i];
                    103:                paa.iobase = 0;
                    104:                paa.iosize = 0x4000000;
                    105:
                    106:                sc->sc_socket[i].pcmcia =
1.2     ! nbrk      107:                    config_found(&sc->sc_pc.sc_dev, &paa,
1.1       nbrk      108:                                    sacpcic_print);
                    109:
1.2     ! nbrk      110: //             sa11x1_intr_establish(i ? IRQ_S1_CDVALID : IRQ_S0_CDVALID, IST_EDGE_RISING, sapcic_intr, &sc->sc_socket[i], "sapcicsock");
1.1       nbrk      111:
                    112:                /* create kthread */
                    113:                sapcic_kthread_create(&sc->sc_socket[i]);
                    114: #if 0 /* XXX */
                    115:                /* establish_intr should be after creating the kthread */
                    116:                config_interrupt(&sc->sc_socket[i], sapcic_config_intr);
                    117: #endif
                    118:        }
                    119: }
                    120:
                    121: int
                    122: sacpcic_print(void *aux, const char *name)
                    123: {
                    124:
                    125:        return UNCONF;
                    126: }
                    127:
                    128: int
                    129: sacpcic_read(struct sapcic_socket *so, int reg)
                    130: {
                    131:        int cr, bit;
                    132:        struct sacpcic_softc *sc = (struct sacpcic_softc *)so->sc;
                    133:
                    134:        cr = bus_space_read_4(sc->sc_pc.sc_iot, sc->sc_ioh, SACPCIC_SR);
                    135:
                    136:        switch (reg) {
                    137:        case SAPCIC_STATUS_CARD:
                    138:                bit = (so->socket ? SR_S1_CARDDETECT : SR_S0_CARDDETECT) & cr;
                    139:                if (bit)
                    140:                        return SAPCIC_CARD_INVALID;
                    141:                else
                    142:                        return SAPCIC_CARD_VALID;
                    143:
                    144:        case SAPCIC_STATUS_VS1:
                    145:                bit = (so->socket ? SR_S1_VS1 : SR_S0_VS1);
                    146:                return (bit & cr);
                    147:
                    148:        case SAPCIC_STATUS_VS2:
                    149:                bit = (so->socket ? SR_S1_VS2 : SR_S0_VS2);
                    150:                return (bit & cr);
                    151:
                    152:        case SAPCIC_STATUS_READY:
                    153:                bit = (so->socket ? SR_S1_READY : SR_S0_READY);
                    154:                return (bit & cr);
                    155:
                    156:        default:
                    157:                panic("sacpcic_read: bogus register");
                    158:        }
                    159: }
                    160:
                    161: void
                    162: sacpcic_write(struct sapcic_socket *so, int reg, int arg)
                    163: {
                    164:        int s, oldvalue, newvalue, mask;
                    165:        struct sacpcic_softc *sc = (struct sacpcic_softc *)so->sc;
                    166:
                    167:        s = splhigh();
                    168:        oldvalue = bus_space_read_4(sc->sc_pc.sc_iot, sc->sc_ioh, SACPCIC_CR);
                    169:
                    170:        switch (reg) {
                    171:        case SAPCIC_CONTROL_RESET:
                    172:                mask = so->socket ? CR_S1_RST : CR_S0_RST;
                    173:
                    174:                newvalue = (oldvalue & ~mask) | (arg ? mask : 0);
                    175:                break;
                    176:
                    177:        case SAPCIC_CONTROL_LINEENABLE:
                    178:                mask = so->socket ? CR_S1_FLT : CR_S0_FLT;
                    179:
                    180:                newvalue = (oldvalue & ~mask) | (arg ? mask : 0);
                    181:                break;
                    182:
                    183:        case SAPCIC_CONTROL_WAITENABLE:
                    184:                mask = so->socket ? CR_S1_PWAITEN : CR_S0_PWAITEN;
                    185:
                    186:                newvalue = (oldvalue & ~mask) | (arg ? mask : 0);
                    187:                break;
                    188:
                    189:        case SAPCIC_CONTROL_POWERSELECT:
                    190:                mask = so->socket ? CR_S1_PSE : CR_S0_PSE;
                    191:                newvalue = oldvalue & ~mask;
                    192:
                    193:                switch (arg) {
                    194:                case SAPCIC_POWER_3V:
                    195:                        break;
                    196:                case SAPCIC_POWER_5V:
                    197:                        newvalue |= mask;
                    198:                        break;
                    199:                default:
                    200:                        splx(s);
                    201:                        panic("sacpcic_write: bogus arg");
                    202:                }
                    203:                break;
                    204:
                    205:        default:
                    206:                splx(s);
                    207:                panic("sacpcic_write: bogus register");
                    208:        }
                    209:        bus_space_write_4(sc->sc_pc.sc_iot, sc->sc_ioh, SACPCIC_CR, newvalue);
                    210:        splx(s);
                    211: }
                    212:
                    213: void
                    214: sacpcic_clear_intr(int arg)
                    215: {
                    216:        /* sacc_intr_dispatch takes care of intr status */
                    217: }
                    218:
                    219: void *
                    220: sacpcic_intr_establish(struct sapcic_socket *so, int level,
                    221:     int (*ih_fun)(void *), void *ih_arg)
                    222: {
                    223:        int irq;
                    224:
                    225:        irq = so->socket ? IRQ_S1_READY : IRQ_S0_READY;
1.2     ! nbrk      226: //     return sa11x1_intr_establish(irq, IST_EDGE_FALLING, ih_fun, ih_arg, "sapcicchil");
        !           227:        return NULL;
1.1       nbrk      228: }
                    229:
                    230: void
                    231: sacpcic_intr_disestablish(struct sapcic_socket *so, void *ih)
                    232: {
1.2     ! nbrk      233:        sa11x1_intr_disestablish(ih);
1.1       nbrk      234: }

CVSweb