txioman.c revision 1.12
11.12Sthorpej/*	$NetBSD: txioman.c,v 1.12 2021/08/07 16:18:54 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.1Such *
191.2Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.2Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.2Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.2Such * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.2Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.2Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.2Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.2Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.2Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.2Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.2Such * POSSIBILITY OF SUCH DAMAGE.
301.1Such */
311.7Slukem
321.7Slukem#include <sys/cdefs.h>
331.12Sthorpej__KERNEL_RCSID(0, "$NetBSD: txioman.c,v 1.12 2021/08/07 16:18:54 thorpej Exp $");
341.1Such
351.1Such#include <sys/param.h>
361.1Such#include <sys/systm.h>
371.1Such#include <sys/device.h>
381.1Such
391.1Such#include <machine/bus.h>
401.1Such#include <hpcmips/tx/tx39var.h>
411.1Such
421.3Such#include <dev/hpc/hpciovar.h>
431.1Such
441.10Smattint txioman_match(device_t, cfdata_t, void *);
451.10Smattvoid txioman_attach(device_t, device_t, void *);
461.10Smattvoid txioman_callback(device_t);
471.3Suchint txioman_print(void *, const char *);
481.3Suchhpcio_chip_t tx_conf_reference_ioman(void *, int);
491.1Such
501.10SmattCFATTACH_DECL_NEW(txioman, 0,
511.6Sthorpej    txioman_match, txioman_attach, NULL, NULL);
521.1Such
531.1Suchint
541.10Smatttxioman_match(device_t parent, cfdata_t cf, void *aux)
551.1Such{
561.3Such	return (1);
571.1Such}
581.1Such
591.1Suchvoid
601.10Smatttxioman_attach(device_t parent, device_t self, void *aux)
611.1Such{
621.2Such	printf("\n");
631.1Such
641.3Such	config_defer(self, txioman_callback);
651.1Such}
661.1Such
671.3Suchvoid
681.10Smatttxioman_callback(device_t self)
691.1Such{
701.3Such	struct hpcio_attach_args haa;
711.1Such
721.3Such	haa.haa_busname = HPCIO_BUSNAME;
731.3Such	haa.haa_sc = tx_conf_get_tag();
741.3Such	haa.haa_getchip = tx_conf_reference_ioman;
751.3Such	haa.haa_iot = 0; /* not needed for TX */
761.3Such
771.12Sthorpej	config_found(self, &haa, txioman_print, CFARGS_NONE);
781.1Such}
791.1Such
801.1Suchint
811.2Suchtxioman_print(void *aux, const char *pnp)
821.1Such{
831.3Such
841.3Such	return (QUIET);
851.3Such}
861.3Such
871.3Suchvoid
881.3Suchtx_conf_register_ioman(tx_chipset_tag_t t, struct hpcio_chip *hc)
891.3Such{
901.3Such	KASSERT(t == tx_conf_get_tag());
911.3Such	KASSERT(hc);
921.3Such
931.3Such	t->tc_iochip[hc->hc_chipid] = hc;
941.3Such}
951.3Such
961.3Suchhpcio_chip_t
971.3Suchtx_conf_reference_ioman(void *ctx, int iochip)
981.3Such{
991.3Such	struct tx_chipset_tag *t = tx_conf_get_tag();
1001.3Such	KASSERT(iochip >= 0 && iochip < NTXIO_GROUP);
1011.3Such
1021.3Such	return (t->tc_iochip[iochip]);
1031.1Such}
104