plumisa_machdep.c revision 1.5
11.5Sthorpej/*	$NetBSD: plumisa_machdep.c,v 1.5 2002/10/02 05:26:49 thorpej 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.2Such
391.1Such#include <sys/param.h>
401.1Such#include <sys/systm.h>
411.1Such
421.1Such#include <machine/bus.h>
431.1Such
441.1Such#include <dev/isa/isavar.h>
451.1Such#include <dev/isa/isareg.h>
461.1Such
471.1Such#include <machine/platid.h>
481.1Such#include <machine/platid_mask.h>
491.1Such
501.1Such#include <hpcmips/tx/tx39var.h>
511.1Such#include <hpcmips/dev/plumvar.h>
521.1Such#include <hpcmips/dev/plumicuvar.h>
531.1Such#include <hpcmips/dev/plumiobusvar.h>
541.1Such
551.1Such#include "locators.h"
561.1Such
571.2Suchint	plumisabprint(void *, const char *);
581.2Suchint	plumisabmatch(struct device *, struct cfdata *, void *);
591.2Suchvoid	plumisabattach(struct device *, struct device *, void *);
601.1Such
611.1Suchstruct plumisab_softc {
621.1Such	struct device sc_dev;
631.1Such	plum_chipset_tag_t sc_pc;
641.1Such	bus_space_tag_t sc_iot;
651.1Such	int sc_irq;
661.1Such	void *sc_ih;
671.1Such};
681.1Such
691.5SthorpejCFATTACH_DECL(plumisab, sizeof(struct plumisab_softc),
701.5Sthorpej    plumisabmatch, plumisabattach, NULL, NULL);
711.1Such
721.1Suchint
731.2Suchplumisabmatch(struct device *parent, struct cfdata *match, void *aux)
741.1Such{
751.1Such	struct plumiobus_attach_args *pba = aux;
761.1Such	platid_mask_t mask;
771.1Such
781.3Sthorpej	if (strcmp(pba->pba_busname, match->cf_name)) {
791.2Such		return (0);
801.1Such	}
811.1Such
821.1Such	if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] ==
831.1Such	    PLUMIOBUSIFCF_PLATFORM_DEFAULT) {
841.2Such		return (1);
851.1Such	}
861.1Such
871.1Such	mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]);
881.1Such	if (platid_match(&platid, &mask)) {
891.2Such		return (2);
901.1Such	}
911.1Such
921.2Such	return (0);
931.1Such}
941.1Such
951.1Suchvoid
961.2Suchplumisabattach(struct device *parent, struct device *self, void *aux)
971.1Such{
981.1Such	struct plumiobus_attach_args *pba = aux;
991.1Such	struct plumisab_softc *sc = (void*)self;
1001.1Such	struct isabus_attach_args iba;
1011.1Such
1021.1Such	printf("\n");
1031.1Such	sc->sc_pc = pba->pba_pc;
1041.1Such	sc->sc_iot = pba->pba_iot;
1051.1Such	sc->sc_irq = pba->pba_irq;
1061.1Such	printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq);
1071.1Such#if 0
1081.1Such	/* Reset I/O bus */
1091.1Such	plum_power_ioreset(sc->sc_pc);
1101.1Such#endif
1111.1Such	/* Dump I/O port */
1121.1Such	if (0) {
1131.1Such		bus_space_handle_t ioh;
1141.1Such		int i;
1151.1Such		bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh);
1161.1Such		for(i = 0; i < 0x400; i += 4) {
1171.1Such			printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3));
1181.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2));
1191.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1));
1201.1Such			printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0));
1211.1Such		}
1221.1Such		bus_space_unmap(sc->sc_iot, ioh, 0x400);
1231.1Such	}
1241.1Such
1251.1Such	iba.iba_busname = "isa";
1261.1Such	iba.iba_ic	= sc;
1271.1Such	/* Plum ISA-bus don't have memory space! */
1281.1Such	/* Plum ISA port space */
1291.1Such	iba.iba_iot     = sc->sc_iot;
1301.1Such	config_found(self, &iba, plumisabprint);
1311.1Such}
1321.1Such
1331.1Suchint
1341.2Suchplumisabprint(void *aux, const char *pnp)
1351.1Such{
1361.2Such
1371.2Such	return (pnp ? QUIET : UNCONF);
1381.1Such}
1391.1Such
1401.1Suchvoid
1411.2Suchisa_attach_hook(struct device *parent, struct device *self,
1421.2Such    struct isabus_attach_args *iba)
1431.1Such{
1441.2Such
1451.1Such}
1461.1Such
1471.1Suchvoid *
1481.2Suchisa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level,
1491.2Such    int (*ih_fun)(void *), void *ih_arg)
1501.1Such{
1511.1Such	struct plumisab_softc *sc = (void*)ic;
1521.1Such
1531.1Such	sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level,
1541.1Such					ih_fun, ih_arg);
1551.2Such	return (sc->sc_ih);
1561.1Such}
1571.1Such
1581.1Suchvoid
1591.2Suchisa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
1601.1Such{
1611.1Such	struct plumisab_softc *sc = (void*)ic;
1621.1Such
1631.1Such	plum_intr_disestablish(sc->sc_pc, arg);
1641.1Such}
1651.1Such
1661.1Suchint
1671.2Suchisa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq)
1681.1Such{
1691.1Such	struct plumisab_softc *sc = (void*)ic;
1701.1Such
1711.1Such	*irq = sc->sc_irq;
1721.1Such
1731.2Such	return (0);
1741.1Such}
175