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

Annotation of sys/arch/arm/xscale/pxa2x0_com.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: pxa2x0_com.c,v 1.7 2005/07/18 00:50:19 uwe Exp $ */
        !             2: /*     $NetBSD: pxa2x0_com.c,v 1.4 2003/07/15 00:24:55 lukem Exp $     */
        !             3:
        !             4: /*
        !             5:  * Copyright 2003 Wasabi Systems, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Written by Steve C. Woodford 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: #include <sys/cdefs.h>
        !            40: /*
        !            41: __KERNEL_RCSID(0, "$NetBSD: pxa2x0_com.c,v 1.4 2003/07/15 00:24:55 lukem Exp $");
        !            42: */
        !            43:
        !            44: #ifndef COM_PXA2X0
        !            45: #error "You must use options COM_PXA2X0 to get PXA2x0 serial port support"
        !            46: #endif
        !            47:
        !            48: #include <sys/param.h>
        !            49: #include <sys/systm.h>
        !            50: #include <sys/device.h>
        !            51: #include <sys/tty.h>
        !            52:
        !            53: #include <machine/intr.h>
        !            54: #include <machine/bus.h>
        !            55:
        !            56: #include <dev/ic/comreg.h>
        !            57: #include <dev/ic/comvar.h>
        !            58:
        !            59: #define com_isr 8
        !            60: #define ISR_RECV       (ISR_RXPL | ISR_XMODE | ISR_RCVEIR)
        !            61:
        !            62: #include <arm/xscale/pxa2x0reg.h>
        !            63: #include <arm/xscale/pxa2x0var.h>
        !            64:
        !            65: #ifdef __zaurus__
        !            66: #include <zaurus/dev/zaurus_scoopvar.h>
        !            67: #endif
        !            68:
        !            69: int    pxauart_match(struct device *, void *, void *);
        !            70: void   pxauart_attach(struct device *, struct device *, void *);
        !            71: void   pxauart_power(int why, void *);
        !            72:
        !            73: struct cfattach com_pxaip_ca = {
        !            74:         sizeof (struct com_softc), pxauart_match, pxauart_attach
        !            75: };
        !            76:
        !            77: int
        !            78: pxauart_match(struct device *parent, void *cf, void *aux)
        !            79: {
        !            80:        struct pxaip_attach_args *pxa = aux;
        !            81:        bus_space_tag_t bt = &pxa2x0_a4x_bs_tag;        /* XXX: This sucks */
        !            82:        bus_space_handle_t bh;
        !            83:        int rv;
        !            84:
        !            85:        switch (pxa->pxa_addr) {
        !            86:        case PXA2X0_FFUART_BASE:
        !            87:                if (pxa->pxa_intr != PXA2X0_INT_FFUART)
        !            88:                        return (0);
        !            89:                break;
        !            90:
        !            91:        case PXA2X0_STUART_BASE:
        !            92:                if (pxa->pxa_intr != PXA2X0_INT_STUART)
        !            93:                        return (0);
        !            94:                break;
        !            95:
        !            96:        case PXA2X0_BTUART_BASE:        /* XXX: Config file option ... */
        !            97:                if (pxa->pxa_intr != PXA2X0_INT_BTUART)
        !            98:                        return (0);
        !            99:                break;
        !           100:
        !           101:        default:
        !           102:                return (0);
        !           103:        }
        !           104:
        !           105:        pxa->pxa_size = 0x20;
        !           106:
        !           107:        {
        !           108:                extern bus_addr_t comconsaddr;
        !           109:
        !           110:                if (comconsaddr == pxa->pxa_addr)
        !           111:                        return (1);
        !           112:        }
        !           113:
        !           114:        if (bus_space_map(bt, pxa->pxa_addr, pxa->pxa_size, 0, &bh))
        !           115:                return (0);
        !           116:
        !           117:        /* Make sure the UART is enabled */
        !           118:        bus_space_write_1(bt, bh, com_ier, IER_EUART);
        !           119:
        !           120:        rv = comprobe1(bt, bh);
        !           121:        bus_space_unmap(bt, bh, pxa->pxa_size);
        !           122:
        !           123:        return (rv);
        !           124: }
        !           125:
        !           126: void
        !           127: pxauart_attach(struct device *parent, struct device *self, void *aux)
        !           128: {
        !           129:        struct com_softc *sc = (struct com_softc *)self;
        !           130:        struct pxaip_attach_args *pxa = aux;
        !           131:
        !           132:        sc->sc_iot = &pxa2x0_a4x_bs_tag;        /* XXX: This sucks */
        !           133:        sc->sc_iobase = pxa->pxa_addr;
        !           134:        sc->sc_frequency = PXA2X0_COM_FREQ;
        !           135:        sc->sc_uarttype = COM_UART_PXA2X0;
        !           136:
        !           137: #if 0
        !           138:        if (com_is_console(sc->sc_iot, sc->sc_iobase, &sc->sc_ioh) == 0 &&
        !           139:            bus_space_map(sc->sc_iot, sc->sc_iobase, pxa->pxa_size, 0,
        !           140:                          &sc->sc_ioh)) {
        !           141:                printf(": can't map registers\n");
        !           142:                return;
        !           143:        }
        !           144: #endif
        !           145:        bus_space_map(sc->sc_iot, sc->sc_iobase, pxa->pxa_size, 0, &sc->sc_ioh);
        !           146:
        !           147:        com_attach_subr(sc);
        !           148:
        !           149:        (void)pxa2x0_intr_establish(pxa->pxa_intr, IPL_TTY, comintr,
        !           150:            sc, sc->sc_dev.dv_xname);
        !           151:
        !           152:        (void)powerhook_establish(&pxauart_power, sc);
        !           153: }
        !           154:
        !           155: void
        !           156: pxauart_power(int why, void *arg)
        !           157: {
        !           158:        struct com_softc *sc = arg;
        !           159:        bus_space_tag_t iot = sc->sc_iot;
        !           160:        bus_space_handle_t ioh = sc->sc_ioh;
        !           161:        struct tty *tp = sc->sc_tty;
        !           162:
        !           163:        switch (why) {
        !           164:        case PWR_SUSPEND:
        !           165:        case PWR_STANDBY:
        !           166:                if (sc->enabled && ISSET(sc->sc_hwflags, COM_HW_SIR))
        !           167:                        scoop_set_irled(0);
        !           168:                break;
        !           169:        case PWR_RESUME:
        !           170:                if (sc->enabled) {
        !           171:                        sc->sc_initialize = 1;
        !           172:                        comparam(tp, &tp->t_termios);
        !           173:                        bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);
        !           174:
        !           175:                        if (ISSET(sc->sc_hwflags, COM_HW_SIR)) {
        !           176:                                scoop_set_irled(1);
        !           177:                                bus_space_write_1(iot, ioh, com_isr,
        !           178:                                    ISR_RECV);
        !           179:                        }
        !           180:                }
        !           181:                break;
        !           182:        }
        !           183: }

CVSweb