Home | History | Annotate | Line # | Download | only in tsarm
epcom_ts.c revision 1.9
      1 /*	$NetBSD: epcom_ts.c,v 1.9 2023/12/20 13:55:18 thorpej Exp $ */
      2 /*
      3  * Copyright (c) 2002
      4  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #include <sys/cdefs.h>
     30 __KERNEL_RCSID(0, "$NetBSD: epcom_ts.c,v 1.9 2023/12/20 13:55:18 thorpej Exp $");
     31 
     32 /* Front-end of epcom */
     33 
     34 #include <sys/types.h>
     35 #include <sys/device.h>
     36 #include <sys/systm.h>
     37 #include <sys/param.h>
     38 
     39 #include <sys/termios.h>
     40 
     41 #include <machine/intr.h>
     42 #include <sys/bus.h>
     43 
     44 #include <arm/ep93xx/epcomreg.h>
     45 #include <arm/ep93xx/epcomvar.h>
     46 #include <arm/ep93xx/ep93xxreg.h>
     47 #include <arm/ep93xx/ep93xxvar.h>
     48 #include <arm/ep93xx/epsocvar.h>
     49 
     50 #include <evbarm/tsarm/epcom_tsvar.h>
     51 
     52 static int	epcom_ts_match(device_t, cfdata_t, void *);
     53 static void	epcom_ts_attach(device_t, device_t, void *);
     54 
     55 CFATTACH_DECL_NEW(epcom_ts, sizeof(struct epcom_ts_softc),
     56     epcom_ts_match, epcom_ts_attach, NULL, NULL);
     57 
     58 static int
     59 epcom_ts_match(device_t parent, cfdata_t match, void *aux)
     60 {
     61 	if (strcmp(match->cf_name, "epcom") == 0)
     62 		return 1;
     63 	return 0;
     64 }
     65 
     66 static void
     67 epcom_ts_attach(device_t parent, device_t self, void *aux)
     68 {
     69 	struct epcom_ts_softc *esc = device_private(self);
     70 	struct epcom_softc *sc = &esc->sc_epcom;
     71 	struct epsoc_attach_args *sa = aux;
     72 	uint32_t pwrcnt;
     73 	bus_space_handle_t ioh;
     74 
     75 	sc->sc_dev = self;
     76 	esc->sc_iot = sa->sa_iot;
     77 	sc->sc_iot = sa->sa_iot;
     78 	sc->sc_hwbase = sa->sa_addr;
     79 
     80 	aprint_normal("\n");
     81 
     82 	bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh);
     83 
     84 	bus_space_map(sa->sa_iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON,
     85 		EP93XX_APB_SYSCON_SIZE, 0, &ioh);
     86 	pwrcnt = bus_space_read_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt);
     87 	pwrcnt &= ~(PwrCnt_UARTBAUD);
     88 	bus_space_write_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt, pwrcnt);
     89 	bus_space_unmap(sa->sa_iot, ioh, EP93XX_APB_SYSCON_SIZE);
     90 
     91 	epcom_attach_subr(sc);
     92 	ep93xx_intr_establish(sa->sa_intr, IPL_SERIAL, epcomintr, sc);
     93 }
     94