1*6d487047Sthorpej /* $NetBSD: com_mace.c,v 1.12 2018/12/08 17:46:12 thorpej Exp $ */
263b59c4dSsekiya
363b59c4dSsekiya /*
463b59c4dSsekiya * Copyright (c) 2000 Soren S. Jorvang
563b59c4dSsekiya * All rights reserved.
663b59c4dSsekiya *
763b59c4dSsekiya * Redistribution and use in source and binary forms, with or without
863b59c4dSsekiya * modification, are permitted provided that the following conditions
963b59c4dSsekiya * are met:
1063b59c4dSsekiya * 1. Redistributions of source code must retain the above copyright
1163b59c4dSsekiya * notice, this list of conditions and the following disclaimer.
1263b59c4dSsekiya * 2. Redistributions in binary form must reproduce the above copyright
1363b59c4dSsekiya * notice, this list of conditions and the following disclaimer in the
1463b59c4dSsekiya * documentation and/or other materials provided with the distribution.
1563b59c4dSsekiya * 3. All advertising materials mentioning features or use of this software
1663b59c4dSsekiya * must display the following acknowledgement:
1763b59c4dSsekiya * This product includes software developed for the
1863b59c4dSsekiya * NetBSD Project. See http://www.NetBSD.org/ for
1963b59c4dSsekiya * information about NetBSD.
2063b59c4dSsekiya * 4. The name of the author may not be used to endorse or promote products
2163b59c4dSsekiya * derived from this software without specific prior written permission.
2263b59c4dSsekiya *
2363b59c4dSsekiya * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2463b59c4dSsekiya * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2563b59c4dSsekiya * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2663b59c4dSsekiya * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2763b59c4dSsekiya * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2863b59c4dSsekiya * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2963b59c4dSsekiya * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3063b59c4dSsekiya * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3163b59c4dSsekiya * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3263b59c4dSsekiya * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3363b59c4dSsekiya */
3463b59c4dSsekiya
3563b59c4dSsekiya #include <sys/cdefs.h>
36*6d487047Sthorpej __KERNEL_RCSID(0, "$NetBSD: com_mace.c,v 1.12 2018/12/08 17:46:12 thorpej Exp $");
3763b59c4dSsekiya
3863b59c4dSsekiya #include <sys/param.h>
3963b59c4dSsekiya #include <sys/systm.h>
4063b59c4dSsekiya #include <sys/ioctl.h>
4163b59c4dSsekiya #include <sys/select.h>
4263b59c4dSsekiya #include <sys/tty.h>
4363b59c4dSsekiya #include <sys/proc.h>
4463b59c4dSsekiya #include <sys/file.h>
4563b59c4dSsekiya #include <sys/uio.h>
4663b59c4dSsekiya #include <sys/kernel.h>
4763b59c4dSsekiya #include <sys/syslog.h>
4863b59c4dSsekiya #include <sys/types.h>
4963b59c4dSsekiya #include <sys/device.h>
5063b59c4dSsekiya
5163b59c4dSsekiya #include <machine/cpu.h>
5263b59c4dSsekiya #include <machine/locore.h>
5363b59c4dSsekiya #include <machine/autoconf.h>
54cf10107dSdyoung #include <sys/bus.h>
55cfc3badeSsekiya #include <machine/machtype.h>
5663b59c4dSsekiya
5763b59c4dSsekiya #include <sgimips/mace/macevar.h>
58e57b94ffSmacallan #include <sgimips/mace/macereg.h>
5963b59c4dSsekiya
6063b59c4dSsekiya #include <dev/arcbios/arcbios.h>
6163b59c4dSsekiya #include <dev/arcbios/arcbiosvar.h>
6263b59c4dSsekiya
6363b59c4dSsekiya #include <dev/ic/comreg.h>
6463b59c4dSsekiya #include <dev/ic/comvar.h>
6563b59c4dSsekiya
6663b59c4dSsekiya struct com_mace_softc {
6763b59c4dSsekiya struct com_softc sc_com;
6863b59c4dSsekiya
6963b59c4dSsekiya /* XXX intr cookie */
7063b59c4dSsekiya };
7163b59c4dSsekiya
72607ead0eScube static int com_mace_match(device_t, cfdata_t , void *);
73607ead0eScube static void com_mace_attach(device_t, device_t, void *);
7463b59c4dSsekiya
75607ead0eScube CFATTACH_DECL_NEW(com_mace, sizeof(struct com_mace_softc),
7663b59c4dSsekiya com_mace_match, com_mace_attach, NULL, NULL);
7763b59c4dSsekiya
7863b59c4dSsekiya static int
com_mace_match(device_t parent,cfdata_t match,void * aux)79607ead0eScube com_mace_match(device_t parent, cfdata_t match, void *aux)
8063b59c4dSsekiya {
8163b59c4dSsekiya return 1;
8263b59c4dSsekiya }
8363b59c4dSsekiya
8463b59c4dSsekiya static void
com_mace_attach(device_t parent,device_t self,void * aux)85607ead0eScube com_mace_attach(device_t parent, device_t self, void *aux)
8663b59c4dSsekiya {
87607ead0eScube struct com_mace_softc *msc = device_private(self);
8863b59c4dSsekiya struct com_softc *sc = &msc->sc_com;
8963b59c4dSsekiya struct mace_attach_args *maa = aux;
9034537908Sgdamore bus_space_handle_t ioh;
9163b59c4dSsekiya
92607ead0eScube sc->sc_dev = self;
93607ead0eScube
9463b59c4dSsekiya /*
9563b59c4dSsekiya * XXX should check com_is_console() and
9663b59c4dSsekiya * XXX use bus_space_map().
9763b59c4dSsekiya */
9834537908Sgdamore ioh = maa->maa_sh + maa->maa_offset;
9934537908Sgdamore /* note that ioh on mac is *also* the iobase address */
100*6d487047Sthorpej com_init_regs(&sc->sc_regs, mace_isa_memt, ioh,
101e57b94ffSmacallan MACE_BASE + maa->maa_offset);
10263b59c4dSsekiya
10363b59c4dSsekiya sc->sc_frequency = COM_FREQ;
10463b59c4dSsekiya
10563b59c4dSsekiya delay(10000);
10663b59c4dSsekiya com_attach_subr(sc);
10763b59c4dSsekiya delay(10000);
10863b59c4dSsekiya
10963b59c4dSsekiya cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, comintr, sc);
11063b59c4dSsekiya
11163b59c4dSsekiya return;
11263b59c4dSsekiya }
113