zbbus.c revision 1.2
11.2Sthorpej/* $NetBSD: zbbus.c,v 1.2 2002/09/27 03:18:04 thorpej Exp $ */ 21.1Ssimonb 31.1Ssimonb/* 41.1Ssimonb * Copyright 2000, 2001 51.1Ssimonb * Broadcom Corporation. All rights reserved. 61.1Ssimonb * 71.1Ssimonb * This software is furnished under license and may be used and copied only 81.1Ssimonb * in accordance with the following terms and conditions. Subject to these 91.1Ssimonb * conditions, you may download, copy, install, use, modify and distribute 101.1Ssimonb * modified or unmodified copies of this software in source and/or binary 111.1Ssimonb * form. No title or ownership is transferred hereby. 121.1Ssimonb * 131.1Ssimonb * 1) Any source code used, modified or distributed must reproduce and 141.1Ssimonb * retain this copyright notice and list of conditions as they appear in 151.1Ssimonb * the source file. 161.1Ssimonb * 171.1Ssimonb * 2) No right is granted to use any trade name, trademark, or logo of 181.1Ssimonb * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any 191.1Ssimonb * trademark or logo of Broadcom Corporation may be used to endorse or 201.1Ssimonb * promote products derived from this software without the prior written 211.1Ssimonb * permission of Broadcom Corporation. 221.1Ssimonb * 231.1Ssimonb * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 241.1Ssimonb * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 251.1Ssimonb * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 261.1Ssimonb * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 271.1Ssimonb * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 281.1Ssimonb * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 291.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 301.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 311.1Ssimonb * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 321.1Ssimonb * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 331.1Ssimonb * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 341.1Ssimonb */ 351.1Ssimonb 361.1Ssimonb#include <sys/param.h> 371.1Ssimonb#include <sys/systm.h> 381.1Ssimonb#include <sys/device.h> 391.1Ssimonb 401.1Ssimonb#include <mips/sibyte/include/zbbusvar.h> 411.1Ssimonb 421.1Ssimonb#include "locators.h" 431.1Ssimonb 441.1Ssimonbstatic int zbbus_match(struct device *, struct cfdata *, void *); 451.1Ssimonbstatic void zbbus_attach(struct device *, struct device *, void *); 461.1Ssimonb 471.1Ssimonbstruct cfattach zbbus_ca = { 481.1Ssimonb sizeof(struct device), zbbus_match, zbbus_attach 491.1Ssimonb}; 501.1Ssimonb 511.1Ssimonbstatic int zbbus_print(void *, const char *); 521.1Ssimonbstatic int zbbus_submatch(struct device *, struct cfdata *, void *); 531.1Ssimonbstatic const char *zbbus_entity_type_name(enum zbbus_entity_type type); 541.1Ssimonb 551.1Ssimonbstatic int zbbus_attached; 561.1Ssimonb 571.1Ssimonbstatic const struct zbbus_attach_locs sb1250_zbbus_devs[] = { 581.1Ssimonb { 0, ZBBUS_ENTTYPE_CPU }, 591.1Ssimonb { 1, ZBBUS_ENTTYPE_CPU }, 601.1Ssimonb { 4, ZBBUS_ENTTYPE_SCD }, 611.1Ssimonb { 2, ZBBUS_ENTTYPE_BRZ }, 621.1Ssimonb { 3, ZBBUS_ENTTYPE_OBIO }, 631.1Ssimonb}; 641.1Ssimonbstatic const int sb1250_zbbus_dev_count = 651.1Ssimonb sizeof sb1250_zbbus_devs / sizeof sb1250_zbbus_devs[0]; 661.1Ssimonb 671.1Ssimonbstatic int 681.1Ssimonbzbbus_match(struct device *parent, struct cfdata *match, void *aux) 691.1Ssimonb{ 701.1Ssimonb 711.1Ssimonb if (zbbus_attached) 721.1Ssimonb return (0); 731.1Ssimonb return 1; 741.1Ssimonb} 751.1Ssimonb 761.1Ssimonbstatic void 771.1Ssimonbzbbus_attach(struct device *parent, struct device *self, void *aux) 781.1Ssimonb{ 791.1Ssimonb struct zbbus_attach_args za; 801.1Ssimonb int i; 811.1Ssimonb 821.1Ssimonb printf("\n"); 831.1Ssimonb zbbus_attached = 1; 841.1Ssimonb 851.1Ssimonb sb1250_icu_init(); 861.1Ssimonb 871.1Ssimonb for (i = 0; i < sb1250_zbbus_dev_count; i++) { 881.1Ssimonb memset(&za, 0, sizeof za); 891.1Ssimonb za.za_locs = sb1250_zbbus_devs[i]; 901.1Ssimonb config_found_sm(self, &za, zbbus_print, zbbus_submatch); 911.1Ssimonb } 921.1Ssimonb 931.1Ssimonb return; 941.1Ssimonb} 951.1Ssimonb 961.1Ssimonbint 971.1Ssimonbzbbus_print(void *aux, const char *pnp) 981.1Ssimonb{ 991.1Ssimonb struct zbbus_attach_args *zap = aux; 1001.1Ssimonb 1011.1Ssimonb if (pnp) 1021.1Ssimonb printf("%s at %s", 1031.1Ssimonb zbbus_entity_type_name(zap->za_locs.za_type), pnp); 1041.1Ssimonb printf(" busid %d", zap->za_locs.za_busid); 1051.1Ssimonb return (UNCONF); 1061.1Ssimonb} 1071.1Ssimonb 1081.1Ssimonbstatic int 1091.1Ssimonbzbbus_submatch(struct device *parent, struct cfdata *cf, void *aux) 1101.1Ssimonb{ 1111.1Ssimonb struct zbbus_attach_args *zap = aux; 1121.1Ssimonb 1131.1Ssimonb if (cf->cf_loc[ZBBUSCF_BUSID] != ZBBUSCF_BUSID_DEFAULT && 1141.1Ssimonb cf->cf_loc[ZBBUSCF_BUSID] != zap->za_locs.za_busid) 1151.1Ssimonb return (0); 1161.1Ssimonb 1171.2Sthorpej return (config_match(parent, cf, aux)); 1181.1Ssimonb} 1191.1Ssimonb 1201.1Ssimonbstatic const char * 1211.1Ssimonbzbbus_entity_type_name(enum zbbus_entity_type type) 1221.1Ssimonb{ 1231.1Ssimonb 1241.1Ssimonb switch (type) { 1251.1Ssimonb case ZBBUS_ENTTYPE_CPU: 1261.1Ssimonb return ("cpu"); 1271.1Ssimonb case ZBBUS_ENTTYPE_SCD: 1281.1Ssimonb return ("sbscd"); 1291.1Ssimonb case ZBBUS_ENTTYPE_BRZ: 1301.1Ssimonb return ("sbbrz"); 1311.1Ssimonb case ZBBUS_ENTTYPE_OBIO: 1321.1Ssimonb return ("sbobio"); 1331.1Ssimonb } 1341.1Ssimonb panic("zbbus_entity_type_name"); 1351.1Ssimonb return ("panic"); 1361.1Ssimonb} 137