plumisa_machdep.c revision 1.6
11.6Slukem/*	$NetBSD: plumisa_machdep.c,v 1.6 2003/07/15 02:29:32 lukem Exp $ */
21.1Such
31.2Such/*-
41.2Such * Copyright (c) 1999 The NetBSD Foundation, Inc.
51.1Such * All rights reserved.
61.1Such *
71.2Such * This code is derived from software contributed to The NetBSD Foundation
81.2Such * by UCHIYAMA Yasushi.
91.2Such *
101.1Such * Redistribution and use in source and binary forms, with or without
111.1Such * modification, are permitted provided that the following conditions
121.1Such * are met:
131.1Such * 1. Redistributions of source code must retain the above copyright
141.1Such *    notice, this list of conditions and the following disclaimer.
151.2Such * 2. Redistributions in binary form must reproduce the above copyright
161.2Such *    notice, this list of conditions and the following disclaimer in the
171.2Such *    documentation and/or other materials provided with the distribution.
181.2Such * 3. All advertising materials mentioning features or use of this software
191.2Such *    must display the following acknowledgement:
201.2Such *        This product includes software developed by the NetBSD
211.2Such *        Foundation, Inc. and its contributors.
221.2Such * 4. Neither the name of The NetBSD Foundation nor the names of its
231.2Such *    contributors may be used to endorse or promote products derived
241.2Such *    from this software without specific prior written permission.
251.1Such *
261.2Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.2Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.2Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.2Such * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.2Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.2Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.2Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.2Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.2Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.2Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.2Such * POSSIBILITY OF SUCH DAMAGE.
371.1Such */
381.6Slukem
391.6Slukem#include <sys/cdefs.h>
401.6Slukem__KERNEL_RCSID(0, "$NetBSD: plumisa_machdep.c,v 1.6 2003/07/15 02:29:32 lukem Exp $");
411.2Such
421.1Such#include <sys/param.h>
431.1Such#include <sys/systm.h>
441.1Such
451.1Such#include <machine/bus.h>
461.1Such
471.1Such#include <dev/isa/isavar.h>
481.1Such#include <dev/isa/isareg.h>
491.1Such
501.1Such#include <machine/platid.h>
511.1Such#include <machine/platid_mask.h>
521.1Such
531.1Such#include <hpcmips/tx/tx39var.h>
541.1Such#include <hpcmips/dev/plumvar.h>
551.1Such#include <hpcmips/dev/plumicuvar.h>
561.1Such#include <hpcmips/dev/plumiobusvar.h>
571.1Such
581.1Such#include "locators.h"
591.1Such
601.2Suchint	plumisabprint(void *, const char *);
611.2Suchint	plumisabmatch(struct device *, struct cfdata *, void *);
621.2Suchvoid	plumisabattach(struct device *, struct device *, void *);
631.1Such
641.1Suchstruct plumisab_softc {
651.1Such	struct device sc_dev;
661.1Such	plum_chipset_tag_t sc_pc;
671.1Such	bus_space_tag_t sc_iot;
681.1Such	int sc_irq;
691.1Such	void *sc_ih;
701.1Such};
711.1Such
721.5SthorpejCFATTACH_DECL(plumisab, sizeof(struct plumisab_softc),
731.5Sthorpej    plumisabmatch, plumisabattach, NULL, NULL);
741.1Such
751.1Suchint
761.2Suchplumisabmatch(struct device *parent, struct cfdata *match, void *aux)
771.1Such{
781.1Such	struct plumiobus_attach_args *pba = aux;
791.1Such	platid_mask_t mask;
801.1Such
811.3Sthorpej	if (strcmp(pba->pba_busname, match->cf_name)) {
821.2Such		return (0);
831.1Such	}
841.1Such
851.1Such	if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] ==
861.1Such	    PLUMIOBUSIFCF_PLATFORM_DEFAULT) {
871.2Such		return (1);
881.1Such	}
891.1Such
901.1Such	mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]);
911.1Such	if (platid_match(&platid, &mask)) {
921.2Such		return (2);
931.1Such	}
941.1Such
951.2Such	return (0);
961.1Such}
971.1Such
981.1Suchvoid
991.2Suchplumisabattach(struct device *parent, struct device *self, void *aux)
1001.1Such{
1011.1Such	struct plumiobus_attach_args *pba = aux;
1021.1Such	struct plumisab_softc *sc = (void*)self;
1031.1Such	struct isabus_attach_args iba;
1041.1Such
1051.1Such	printf("\n");
1061.1Such	sc->sc_pc = pba->pba_pc;
1071.1Such	sc->sc_iot = pba->pba_iot;
1081.1Such	sc->sc_irq = pba->pba_irq;
1091.1Such	printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq);
1101.1Such#if 0
1111.1Such	/* Reset I/O bus */
1121.1Such	plum_power_ioreset(sc->sc_pc);
1131.1Such#endif
1141.1Such	/* Dump I/O port */
1151.1Such	if (0) {
1161.1Such		bus_space_handle_t ioh;
1171.1Such		int i;
1181.1Such		bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh);
1191.1Such		for(i = 0; i < 0x400; i += 4) {
1201.1Such			printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3));
1211.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2));
1221.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1));
1231.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0));
1241.1Such		}
1251.1Such		bus_space_unmap(sc->sc_iot, ioh, 0x400);
1261.1Such	}
1271.1Such
1281.1Such	iba.iba_busname = "isa";
1291.1Such	iba.iba_ic	= sc;
1301.1Such	/* Plum ISA-bus don't have memory space! */
1311.1Such	/* Plum ISA port space */
1321.1Such	iba.iba_iot     = sc->sc_iot;
1331.1Such	config_found(self, &iba, plumisabprint);
1341.1Such}
1351.1Such
1361.1Suchint
1371.2Suchplumisabprint(void *aux, const char *pnp)
1381.1Such{
1391.2Such
1401.2Such	return (pnp ? QUIET : UNCONF);
1411.1Such}
1421.1Such
1431.1Suchvoid
1441.2Suchisa_attach_hook(struct device *parent, struct device *self,
1451.2Such    struct isabus_attach_args *iba)
1461.1Such{
1471.2Such
1481.1Such}
1491.1Such
1501.1Suchvoid *
1511.2Suchisa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level,
1521.2Such    int (*ih_fun)(void *), void *ih_arg)
1531.1Such{
1541.1Such	struct plumisab_softc *sc = (void*)ic;
1551.1Such
1561.1Such	sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level,
1571.1Such					ih_fun, ih_arg);
1581.2Such	return (sc->sc_ih);
1591.1Such}
1601.1Such
1611.1Suchvoid
1621.2Suchisa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
1631.1Such{
1641.1Such	struct plumisab_softc *sc = (void*)ic;
1651.1Such
1661.1Such	plum_intr_disestablish(sc->sc_pc, arg);
1671.1Such}
1681.1Such
1691.1Suchint
1701.2Suchisa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq)
1711.1Such{
1721.1Such	struct plumisab_softc *sc = (void*)ic;
1731.1Such
1741.1Such	*irq = sc->sc_irq;
1751.1Such
1761.2Such	return (0);
1771.1Such}
178