A start at O2 support..

This commit is contained in:
soren 2000-06-14 16:13:53 +00:00
parent 4fc3cd3c3d
commit 4a45886c8d
10 changed files with 1058 additions and 0 deletions

View File

@ -0,0 +1,134 @@
/* $NetBSD: com_mace.c,v 1.1 2000/06/14 16:13:53 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <machine/locore.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <sgimips/dev/macevar.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
struct com_mace_softc {
struct com_softc sc_com;
/* XXX intr cookie */
};
static int com_mace_match(struct device *, struct cfdata *, void *);
static void com_mace_attach(struct device *, struct device *, void *);
struct cfattach com_mace_ca = {
sizeof(struct com_mace_softc), com_mace_match, com_mace_attach
};
static int
com_mace_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
return 1;
}
extern void * crime_intr_establish(int, int, int, int (*)(void *), void *);
int console = 0;
static void
com_mace_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct com_mace_softc *msc = (void *)self;
struct com_softc *sc = &msc->sc_com;
struct mace_attach_args *maa = aux;
sc->sc_iot = maa->maa_st;
sc->sc_ioh = maa->maa_sh;
sc->sc_iobase = maa->maa_sh;
sc->sc_frequency = COM_FREQ;
/* XXX console check */
/* XXX map */
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#if 0
console = 1;
#endif
#if 0
console = GetEnvironmentVariable("console");
if console[0] = 'd'
dbaud = GetEnvironmentVariable("dbaud");
rate = strtoul(dbaud);
#endif
delay(10000);
/* if console & dbaud */
if (console == 0) {
comcnattach(sc->sc_iot, sc->sc_ioh, 38400, COM_FREQ, CONMODE);
console = 1;
}
delay(10000);
com_attach_subr(sc);
delay(10000);
crime_intr_establish(0, 0, 0, comintr, sc);
return;
}

View File

@ -0,0 +1,106 @@
/* $NetBSD: crime.c,v 1.1 2000/06/14 16:13:54 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* O2 CRIME
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <machine/cpu.h>
#include <machine/locore.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <dev/pci/pcivar.h>
#include <sgimips/dev/crimereg.h>
#include "locators.h"
static int crime_match(struct device *, struct cfdata *, void *);
static void crime_attach(struct device *, struct device *, void *);
struct cfattach crime_ca = {
sizeof(struct device), crime_match, crime_attach
};
static int
crime_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct mainbus_attach_args *ma = aux;
/*
* The CRIME is in the O2.
*/
switch (ma->ma_arch) {
case 32:
return 1;
default:
return 0;
}
}
static void
crime_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct mainbus_attach_args *ma = aux;
u_int32_t rev; /* really u_int64_t ! */
int major, minor;
rev = bus_space_read_4(ma->ma_iot, ma->ma_ioh, 4) & 0xff;
major = rev > 4;
minor = rev & 0x0f;
if (major == 0 && minor == 0)
printf(": petty\n");
else
printf(": rev %d.%d\n", major, minor);
#if 0
*(volatile u_int64_t *)0xb4000018 = 0xffffffffffffffff;
#else
/* enable all mace interrupts, but no crime devices */
*(volatile u_int64_t *)0xb4000018 = 0x000000000000ffff;
#endif
}

View File

@ -0,0 +1,39 @@
/* $NetBSD: crimereg.h,v 1.1 2000/06/14 16:13:56 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* O2 CRIME register definitions
*/
/* XXX */

View File

@ -0,0 +1,301 @@
/* $NetBSD: if_mec.c,v 1.1 2000/06/14 16:13:57 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* MACE MAC-110 ethernet driver
*/
#include "opt_inet.h"
#include "opt_ns.h"
#include "bpfilter.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/callout.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <machine/endian.h>
#include <vm/vm.h> /* for PAGE_SIZE */
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_ether.h>
#if NBPFILTER > 0
#include <net/bpf.h>
#endif
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_inarp.h>
#endif
#ifdef NS
#include <netns/ns.h>
#include <netns/ns_if.h>
#endif
#include <machine/bus.h>
#include <machine/intr.h>
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
#include <sgimips/dev/macevar.h>
#include <sgimips/dev/if_mecreg.h>
struct mec_softc {
struct device sc_dev;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
bus_dma_tag_t sc_dmat;
struct ethercom sc_ethercom;
unsigned char sc_enaddr[6];
void *sc_sdhook;
struct mii_data sc_mii;
struct callout sc_callout;
#if NRND > 0
rndsource_element_t rnd_source; /* random source */
#endif
};
static int mec_match(struct device *, struct cfdata *, void *);
static void mec_attach(struct device *, struct device *, void *);
#if 0
static void epic_start(struct ifnet *);
static void epic_watchdog(struct ifnet *);
static int epic_ioctl(struct ifnet *, u_long, caddr_t);
#endif
static int mec_mii_readreg(struct device *, int, int);
static void mec_mii_writereg(struct device *, int, int, int);
static int mec_mii_wait(struct mec_softc *);
static void mec_statchg(struct device *);
static int mec_mediachange(struct ifnet *);
static void mec_mediastatus(struct ifnet *, struct ifmediareq *);
struct cfattach mec_ca = {
sizeof(struct mec_softc), mec_match, mec_attach
};
static int
mec_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
return 1;
}
static void
mec_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct mec_softc *sc = (void *)self;
struct mace_attach_args *maa = aux;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
u_int64_t command;
sc->sc_st = maa->maa_st;
sc->sc_sh = maa->maa_sh;
/*
* Reset device.
*/
bus_space_write_8(sc->sc_st, sc->sc_sh, MEC_MAC_CONTROL, 0);
command = bus_space_read_8(sc->sc_st, sc->sc_sh, MEC_MAC_CONTROL);
printf(": rev %lld\n", (command & MAC_REVISION) >> MAC_REVISION_SHIFT);
printf("%s: sorry, this is not a real driver\n", sc->sc_dev.dv_xname);
strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
ifp->if_softc = sc;
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
#if 0
ifp->if_ioctl = mec_ioctl;
ifp->if_start = mec_start;
ifp->if_watchdog = mec_watchdog;
#endif
sc->sc_mii.mii_ifp = ifp;
sc->sc_mii.mii_readreg = mec_mii_readreg;
sc->sc_mii.mii_writereg = mec_mii_writereg;
sc->sc_mii.mii_statchg = mec_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, mec_mediachange,
mec_mediastatus);
mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
} else
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
return;
if_attach(ifp);
ether_ifattach(ifp, sc->sc_enaddr);
#if NBPFILTER > 0
bpfattach(&sc->sc_ethercom.ec_if.if_bpf,
ifp, DLT_EN10MB, sizeof (struct ether_header));
#endif
}
int
mec_mii_readreg(self, phy, reg)
struct device *self;
int phy;
int reg;
{
struct mec_softc *sc = (struct mec_softc *)self;
u_int64_t val;
if (mec_mii_wait(sc) != 0)
return 0;
bus_space_write_8(sc->sc_st, sc->sc_sh, MEC_PHY_ADDRESS,
phy << PHY_ADDR_DEVSHIFT | reg);
bus_space_write_8(sc->sc_st, sc->sc_sh, MEC_PHY_READ_INITATE, 1);
if (mec_mii_wait(sc) != 0)
return 0;
val = bus_space_read_8(sc->sc_st, sc->sc_sh, MEC_PHY_DATA);
if (val == 0xffff)
val = 0;
return (int)val & PHY_DATA_VALUE;
}
void
mec_mii_writereg(self, phy, reg, val)
struct device *self;
int phy, reg, val;
{
struct mec_softc *sc = (struct mec_softc *)self;
if (mec_mii_wait(sc) != 0)
return;
bus_space_write_8(sc->sc_st, sc->sc_sh, MEC_PHY_ADDRESS,
phy << PHY_ADDR_DEVSHIFT | reg);
bus_space_write_8(sc->sc_st, sc->sc_sh, MEC_PHY_DATA,
val & PHY_DATA_VALUE);
(void)mec_mii_wait(sc);
return;
}
int
mec_mii_wait(sc)
struct mec_softc *sc;
{
int i;
delay(1000); /* XXX */
return 0;
for (i = 0; i < 100; i++) {
delay(10);
if ((bus_space_read_8(sc->sc_st, sc->sc_sh, MEC_PHY_DATA) &
PHY_DATA_BUSY) == 0)
break;
}
if (i == 100) {
printf("%s: MII timed out\n", sc->sc_dev.dv_xname);
return 1;
}
return 0;
}
void
mec_statchg(self)
struct device *self;
{
#if 0
struct mec_softc *sc = (void *)self;
#endif
return;
}
void
mec_mediastatus(ifp, ifmr)
struct ifnet *ifp;
struct ifmediareq *ifmr;
{
struct mec_softc *sc = ifp->if_softc;
mii_pollstat(&sc->sc_mii);
ifmr->ifm_status = sc->sc_mii.mii_media_status;
ifmr->ifm_active = sc->sc_mii.mii_media_active;
}
int
mec_mediachange(ifp)
struct ifnet *ifp;
{
struct mec_softc *sc = ifp->if_softc;
if (ifp->if_flags & IFF_UP)
mii_mediachg(&sc->sc_mii);
return 0;
}

View File

@ -0,0 +1,76 @@
/* $NetBSD: if_mecreg.h,v 1.1 2000/06/14 16:13:58 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* MACE MAC110 ethernet register definitions
*/
#define MEC_MAC_CONTROL 0x00
#define MAC_CORE_RESET 0x0000000000000001
#define MAC_FULL_DUPLEX 0x0000000000000002
#define MAC_INT_LOOPBACK 0x0000000000000004
#define MAC_SPEED_SELECT 0x0000000000000008
#define MAC_MII_SELECT 0x0000000000000010
#define MAC_FILTER_STATION 0x0000000000000000
#define MAC_FILTER_MATCHMULTI 0x0000000000000020
#define MAC_FILTER_ALLMULTI 0x0000000000000040
#define MAC_FILTER_PROMISC 0x0000000000000060
#define MAC_LINK_FAILURE 0x0000000000000080
#define MAC_IPGT 0x0000000000007f00
#define MAC_IPGT_SHIFT 8
#define MAC_IPGR1 0x00000000003f8000
#define MAC_IPGR1_SHIFT 15
#define MAC_IPGR2 0x000000001fc00000
#define MAC_IPGR2_SHIFT 22
#define MAC_REVISION 0x00000000e0000000
#define MAC_REVISION_SHIFT 29
#define MEC_INT_STATUS 0x08
#define MEC_DMA_CONTROl 0x10
#define MEC_PHY_DATA 0x60
#define PHY_DATA_BUSY 0x0000000000008000
#define PHY_DATA_VALUE 0x0000000000007fff
#define MEC_PHY_ADDRESS 0x68
#define PHY_ADDR_REGISTER 0x000000000000001f
#define PHY_ADDR_DEVICE 0x00000000000003e0
#define PHY_ADDR_DEVSHIFT 5
#define MEC_PHY_READ_INITATE 0x70
#define MEC_STATION 0xa0
#define MEC_STATION_ALT 0xa8
#define MEC_STATION_MASK 0x0000ffffffffffff

View File

@ -0,0 +1,96 @@
/* $NetBSD: lpt_mace.c,v 1.1 2000/06/14 16:13:59 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <machine/locore.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <sgimips/dev/macevar.h>
#include <dev/ic/lptreg.h>
#include <dev/ic/lptvar.h>
struct lpt_mace_softc {
struct lpt_softc sc_lpt;
/* XXX intr cookie */
};
static int lpt_mace_match(struct device *, struct cfdata *, void *);
static void lpt_mace_attach(struct device *, struct device *, void *);
struct cfattach lpt_mace_ca = {
sizeof(struct lpt_mace_softc), lpt_mace_match, lpt_mace_attach
};
static int
lpt_mace_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
return 1;
}
static void
lpt_mace_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
#if 0
struct lpt_mace_softc *msc = (void *)self;
struct lpt_softc *sc = &msc->sc_lpt;
struct mace_attach_args *maa = aux;
#endif
printf(": stub\n");
return;
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* MACE audio CODEC register definitions
*
* With an Analog Device AD1843 CODEC (?)
*/
#define MACAU_CONTROL_STATUS 0x00
#define MACAU_CODEC_STATUS_CNTL 0x08
#define MACAU_CODEC_STATUS_INPUT_MASK 0x10
#define MACAU_CODEC_STATUS_INPUT 0x18
#define MACAU_CH1_IN_RING_CONTROL 0x20
#define MACAU_CH1_IN_READ_POINTER 0x28
#define MACAU_CH1_IN_WRITE_POINTER 0x30
#define MACAU_CH1_IN_RING_DEPTH 0x38
#define MACAU_CH2_OUT_RING_CONTROL 0x40
#define MACAU_CH2_OUT_READ_POINTER 0x48
#define MACAU_CH2_OUT_WRITE_POINTER 0x50
#define MACAU_CH2_OUT_RING_DEPTH 0x58
#define MACAU_CH3_OUT_RING_CONTROL 0x60
#define MACAU_CH3_OUT_READ_POINTER 0x68
#define MACAU_CH3_OUT_WRITE_POINTER 0x70
#define MACAU_CH3_OUT_RING_DEPTH 0x78

170
sys/arch/sgimips/dev/mace.c Normal file
View File

@ -0,0 +1,170 @@
/* $NetBSD: mace.c,v 1.1 2000/06/14 16:14:00 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/*
* O2 MACE
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <machine/cpu.h>
#include <machine/locore.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <sgimips/dev/macereg.h>
#include <sgimips/dev/macevar.h>
#include "locators.h"
struct mace_softc {
struct device sc_dev;
};
static int mace_match(struct device *, struct cfdata *, void *);
static void mace_attach(struct device *, struct device *, void *);
static int mace_print(void *, const char *);
static int mace_search(struct device *, struct cfdata *, void *);
struct cfattach mace_ca = {
sizeof(struct mace_softc), mace_match, mace_attach
};
static int
mace_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct mainbus_attach_args *ma = aux;
/*
* The MACE is in the O2.
*/
switch (ma->ma_arch) {
case 32:
return 1;
default:
return 0;
}
}
static void
mace_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
printf("\n");
/*
* Enable all "ISA" interrupts.
*/
#if 0
printf("mace0: isa sts %llx\n", *(volatile u_int64_t *)0xbf310010);
printf("mace0: isa msk %llx\n", *(volatile u_int64_t *)0xbf310018);
*(volatile u_int64_t *)0xbf310018 = 0xffffffff;
#endif
printf("mace0: isa sts %llx\n", *(volatile u_int64_t *)0xbf310010);
printf("mace0: isa msk %llx\n", *(volatile u_int64_t *)0xbf310018);
config_search(mace_search, self, NULL);
}
static int
mace_print(aux, pnp)
void *aux;
const char *pnp;
{
struct mace_attach_args *maa = aux;
if (pnp != 0)
return QUIET;
if (maa->maa_offset != MACECF_OFFSET_DEFAULT)
printf(" offset 0x%lx", maa->maa_offset);
if (maa->maa_offset != MACECF_INTR_DEFAULT)
printf(" intr %d", maa->maa_intr);
#if 0
if (maa->maa_offset != MACECF_STRIDE_DEFAULT)
printf(" stride 0x%lx", maa->maa_stride);
#endif
return UNCONF;
}
static int
mace_search(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct mace_attach_args maa;
int tryagain;
do {
maa.maa_offset = cf->cf_loc[MACECF_OFFSET];
maa.maa_intr = cf->cf_loc[MACECF_INTR];
#if 0
maa.maa_stride = cf->cf_loc[MACECF_STRIDE];
#endif
maa.maa_st = 3;
/* XXX */
maa.maa_sh = MIPS_PHYS_TO_KSEG1(maa.maa_offset + 0x1f000000);
tryagain = 0;
if ((*cf->cf_attach->ca_match)(parent, cf, &maa) > 0) {
config_attach(parent, cf, &maa, mace_print);
tryagain = (cf->cf_fstate == FSTATE_STAR);
}
} while (tryagain);
return 0;
}
void *
mace_intr_establish(intr, level, func, arg)
int intr;
int level;
int (*func)(void *);
void *arg;
{
/* XXX */
return 0;
}

View File

@ -0,0 +1,35 @@
/* $NetBSD: macereg.h,v 1.1 2000/06/14 16:14:01 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
/* XXX */

View File

@ -0,0 +1,47 @@
/* $NetBSD: macevar.h,v 1.1 2000/06/14 16:14:01 soren Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
* All rights reserved.
*
* 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:
* This product includes software developed for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
*/
struct mace_attach_args {
bus_space_tag_t maa_st;
bus_space_handle_t maa_sh;
/* ? */
long maa_offset;
int maa_intr;
#if 0
int maa_stride;
#endif
};
extern void * mace_intr_establish(int, int, int (*)(void *), void *);