2003-10-08 18:55:04 +04:00
|
|
|
/* $NetBSD: ixp425_com.c,v 1.14 2003/10/08 14:55:04 scw Exp $ */
|
|
|
|
|
2003-05-23 04:57:23 +04:00
|
|
|
/*
|
2003-10-08 18:55:04 +04:00
|
|
|
* Copyright 2003 Wasabi Systems, Inc.
|
2003-05-23 04:57:23 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2003-10-08 18:55:04 +04:00
|
|
|
* Written by Steve C. Woodford for Wasabi Systems, Inc.
|
|
|
|
*
|
2003-05-23 04:57:23 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
2003-10-08 18:55:04 +04:00
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
2003-05-23 04:57:23 +04:00
|
|
|
*
|
2003-10-08 18:55:04 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2003-05-23 04:57:23 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2003-10-08 18:55:04 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ixp425_com.c,v 1.14 2003/10/08 14:55:04 scw Exp $");
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
#include "opt_com.h"
|
|
|
|
#ifndef COM_PXA2X0
|
|
|
|
#error "You must use options COM_PXA2X0 to get IXP425 serial port support"
|
2003-05-23 04:57:23 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/systm.h>
|
2003-10-08 18:55:04 +04:00
|
|
|
#include <sys/param.h>
|
2003-05-23 04:57:23 +04:00
|
|
|
#include <sys/device.h>
|
2003-10-08 18:55:04 +04:00
|
|
|
#include <sys/termios.h>
|
2003-05-23 04:57:23 +04:00
|
|
|
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
#include <dev/ic/comreg.h>
|
|
|
|
#include <dev/ic/comvar.h>
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
#include <arm/xscale/ixp425reg.h>
|
|
|
|
#include <arm/xscale/ixp425var.h>
|
|
|
|
#include <arm/xscale/ixp425_sipvar.h>
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
static int ixsipcom_match(struct device *, struct cfdata *, void *);
|
|
|
|
static void ixsipcom_attach(struct device *, struct device *, void *);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
CFATTACH_DECL(ixsipcom, sizeof(struct com_softc),
|
|
|
|
ixsipcom_match, ixsipcom_attach, NULL, NULL);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
static const int uart_irq[] = {IXP425_INT_UART0, IXP425_INT_UART1};
|
2003-07-02 14:40:46 +04:00
|
|
|
|
2003-05-23 04:57:23 +04:00
|
|
|
static int
|
2003-10-08 18:55:04 +04:00
|
|
|
ixsipcom_match(struct device *parent, struct cfdata *match, void *aux)
|
2003-05-23 04:57:23 +04:00
|
|
|
{
|
2003-10-08 18:55:04 +04:00
|
|
|
struct ixpsip_attach_args *sa = aux;
|
|
|
|
bus_space_tag_t bt = &ixp425_a4x_bs_tag;
|
|
|
|
bus_space_handle_t bh;
|
|
|
|
int rv;
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
if (strcmp(match->cf_name, "ixsipcom") == 0)
|
|
|
|
return 1;
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
if (com_is_console(bt, sa->sa_addr, NULL))
|
|
|
|
return (1);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
if (bus_space_map(bt, sa->sa_addr, sa->sa_size, 0, &bh))
|
2003-05-23 04:57:23 +04:00
|
|
|
return (0);
|
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
/* Make sure the UART is enabled */
|
|
|
|
bus_space_write_1(bt, bh, com_ier, IER_EUART);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
rv = comprobe1(bt, bh);
|
|
|
|
bus_space_unmap(bt, bh, sa->sa_size);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
return (rv);
|
2003-05-23 04:57:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-08 18:55:04 +04:00
|
|
|
ixsipcom_attach(struct device *parent, struct device *self, void *aux)
|
2003-05-23 04:57:23 +04:00
|
|
|
{
|
2003-10-08 18:55:04 +04:00
|
|
|
struct com_softc *sc = (struct com_softc *)self;
|
|
|
|
struct ixpsip_attach_args *sa = aux;
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
sc->sc_iot = &ixp425_a4x_bs_tag;
|
|
|
|
sc->sc_iobase = sa->sa_addr;
|
|
|
|
sc->sc_frequency = IXP425_UART_FREQ;
|
|
|
|
sc->sc_type = COM_TYPE_PXA2x0;
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
if (com_is_console(sc->sc_iot, sc->sc_iobase, &sc->sc_ioh) == 0 &&
|
|
|
|
bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0,
|
|
|
|
&sc->sc_ioh)) {
|
|
|
|
printf(": can't map registers\n");
|
2003-05-23 04:57:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2003-07-02 14:40:46 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
com_attach_subr(sc);
|
2003-05-23 04:57:23 +04:00
|
|
|
|
2003-10-08 18:55:04 +04:00
|
|
|
ixp425_intr_establish(uart_irq[sa->sa_index], IPL_SERIAL, comintr, sc);
|
2003-05-23 04:57:23 +04:00
|
|
|
}
|