txioman.c revision 1.6
11.6Sthorpej/*	$NetBSD: txioman.c,v 1.6 2002/10/02 05:26:51 thorpej Exp $ */
21.1Such
31.2Such/*-
41.2Such * Copyright (c) 1999, 2000 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.1Such
391.1Such#include <sys/param.h>
401.1Such#include <sys/systm.h>
411.1Such#include <sys/device.h>
421.1Such
431.1Such#include <machine/bus.h>
441.1Such#include <hpcmips/tx/tx39var.h>
451.1Such
461.3Such#include <dev/hpc/hpciovar.h>
471.1Such
481.3Suchint txioman_match(struct device *, struct cfdata *, void *);
491.3Suchvoid txioman_attach(struct device *, struct device *, void *);
501.3Suchvoid txioman_callback(struct device *);
511.3Suchint txioman_print(void *, const char *);
521.3Suchhpcio_chip_t tx_conf_reference_ioman(void *, int);
531.1Such
541.6SthorpejCFATTACH_DECL(txioman, sizeof(struct device),
551.6Sthorpej    txioman_match, txioman_attach, NULL, NULL);
561.1Such
571.1Suchint
581.2Suchtxioman_match(struct device *parent, struct cfdata *cf, void *aux)
591.1Such{
601.3Such	return (1);
611.1Such}
621.1Such
631.1Suchvoid
641.2Suchtxioman_attach(struct device *parent, struct device *self, void *aux)
651.1Such{
661.2Such	printf("\n");
671.1Such
681.3Such	config_defer(self, txioman_callback);
691.1Such}
701.1Such
711.3Suchvoid
721.3Suchtxioman_callback(struct device *self)
731.1Such{
741.3Such	struct hpcio_attach_args haa;
751.1Such
761.3Such	haa.haa_busname = HPCIO_BUSNAME;
771.3Such	haa.haa_sc = tx_conf_get_tag();
781.3Such	haa.haa_getchip = tx_conf_reference_ioman;
791.3Such	haa.haa_iot = 0; /* not needed for TX */
801.3Such
811.3Such	config_found(self, &haa, txioman_print);
821.1Such}
831.1Such
841.1Suchint
851.2Suchtxioman_print(void *aux, const char *pnp)
861.1Such{
871.3Such
881.3Such	return (QUIET);
891.3Such}
901.3Such
911.3Suchvoid
921.3Suchtx_conf_register_ioman(tx_chipset_tag_t t, struct hpcio_chip *hc)
931.3Such{
941.3Such	KASSERT(t == tx_conf_get_tag());
951.3Such	KASSERT(hc);
961.3Such
971.3Such	t->tc_iochip[hc->hc_chipid] = hc;
981.3Such}
991.3Such
1001.3Suchhpcio_chip_t
1011.3Suchtx_conf_reference_ioman(void *ctx, int iochip)
1021.3Such{
1031.3Such	struct tx_chipset_tag *t = tx_conf_get_tag();
1041.3Such	KASSERT(iochip >= 0 && iochip < NTXIO_GROUP);
1051.3Such
1061.3Such	return (t->tc_iochip[iochip]);
1071.1Such}
108