txioman.c revision 1.2
11.2Such/* $NetBSD: txioman.c,v 1.2 2000/10/22 10:42:33 uch 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#include "opt_tx39_debug.h" 391.1Such 401.1Such#include <sys/param.h> 411.1Such#include <sys/systm.h> 421.1Such#include <sys/device.h> 431.1Such 441.1Such#include <machine/bus.h> 451.1Such#include <machine/intr.h> 461.1Such 471.1Such#include <machine/config_hook.h> 481.1Such#include <machine/platid.h> 491.1Such#include <machine/platid_mask.h> 501.1Such 511.1Such#include <hpcmips/tx/tx39var.h> 521.1Such#include <hpcmips/tx/txiomanvar.h> 531.1Such 541.1Such#include "locators.h" 551.1Such 561.2Suchint txioman_match(struct device *, struct cfdata *, void *); 571.2Suchvoid txioman_attach(struct device *, struct device *, void *); 581.2Suchint txioman_print(void *, const char *); 591.2Suchint txioman_search(struct device *, struct cfdata *, void *); 601.1Such 611.1Suchstruct txioman_softc { 621.2Such struct device sc_dev; 631.1Such}; 641.1Such 651.1Suchstruct cfattach txioman_ca = { 661.1Such sizeof(struct txioman_softc), txioman_match, txioman_attach 671.1Such}; 681.1Such 691.1Suchint 701.2Suchtxioman_match(struct device *parent, struct cfdata *cf, void *aux) 711.1Such{ 721.1Such platid_mask_t mask; 731.1Such 741.2Such /* select platform */ 751.2Such mask = PLATID_DEREF(cf->cf_loc[TXSIMCF_PLATFORM]); 761.1Such if (platid_match(&platid, &mask)) { 771.2Such return ATTACH_NORMAL; 781.1Such } 791.1Such 801.1Such return 0; 811.1Such} 821.1Such 831.1Suchvoid 841.2Suchtxioman_attach(struct device *parent, struct device *self, void *aux) 851.1Such{ 861.2Such struct txsim_attach_args *ta = aux; 871.2Such struct txio_attach_args taa; 881.2Such 891.2Such taa.taa_tc = ta->ta_tc; 901.2Such printf("\n"); 911.1Such 921.2Such config_search(txioman_search, self, &taa); 931.1Such} 941.1Such 951.2Suchint 961.2Suchtxioman_search(struct device *parent, struct cfdata *cf, void *aux) 971.1Such{ 981.2Such struct txio_attach_args *taa = aux; 991.1Such 1001.2Such taa->taa_group = cf->cf_group; 1011.2Such taa->taa_port = cf->cf_port; 1021.2Such taa->taa_type = cf->cf_type; 1031.2Such taa->taa_id = cf->cf_id; 1041.2Such taa->taa_edge = cf->cf_edge; 1051.2Such taa->taa_initial = cf->cf_initial; 1061.1Such 1071.2Such config_attach(parent, cf, taa, txioman_print); 1081.1Such 1091.2Such return 0; 1101.1Such} 1111.1Such 1121.1Suchint 1131.2Suchtxioman_print(void *aux, const char *pnp) 1141.1Such{ 1151.2Such struct txio_attach_args *taa = aux; 1161.2Such int edge = taa->taa_edge; 1171.2Such int type = taa->taa_type; 1181.2Such 1191.2Such if (!pnp) { 1201.2Such printf(" group %d port %d type %d id %d", taa->taa_group, 1211.2Such taa->taa_port, type, taa->taa_id); 1221.2Such if (type == CONFIG_HOOK_BUTTONEVENT || 1231.2Such type == CONFIG_HOOK_PMEVENT || 1241.2Such type == CONFIG_HOOK_EVENT) { 1251.2Such printf (" interrupt edge [%s%s]", 1261.2Such edge & 0x1 ? "p" : "", edge & 0x2 ? "n" : ""); 1271.2Such } 1281.2Such if (taa->taa_initial != -1) 1291.2Such printf(" initial %d", taa->taa_initial); 1301.2Such } 1311.1Such 1321.2Such return QUIET; 1331.1Such} 134