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