zbbus.c revision 1.9
11.9Sdrochner/* $NetBSD: zbbus.c,v 1.9 2005/06/28 18:30:00 drochner 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.7Scgd * Broadcom Corporation. The "Broadcom Corporation" name may not be 191.7Scgd * used to endorse or promote products derived from this software 201.7Scgd * without the prior written permission of Broadcom Corporation. 211.1Ssimonb * 221.1Ssimonb * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 231.1Ssimonb * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 241.1Ssimonb * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 251.1Ssimonb * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 261.1Ssimonb * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 271.1Ssimonb * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 301.1Ssimonb * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 311.1Ssimonb * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 321.1Ssimonb * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331.1Ssimonb */ 341.8Slukem 351.8Slukem#include <sys/cdefs.h> 361.9Sdrochner__KERNEL_RCSID(0, "$NetBSD: zbbus.c,v 1.9 2005/06/28 18:30:00 drochner Exp $"); 371.1Ssimonb 381.1Ssimonb#include <sys/param.h> 391.1Ssimonb#include <sys/systm.h> 401.1Ssimonb#include <sys/device.h> 411.1Ssimonb 421.1Ssimonb#include <mips/sibyte/include/zbbusvar.h> 431.1Ssimonb 441.1Ssimonb#include "locators.h" 451.1Ssimonb 461.1Ssimonbstatic int zbbus_match(struct device *, struct cfdata *, void *); 471.1Ssimonbstatic void zbbus_attach(struct device *, struct device *, void *); 481.1Ssimonb 491.4SthorpejCFATTACH_DECL(zbbus, sizeof(struct device), 501.5Sthorpej zbbus_match, zbbus_attach, NULL, NULL); 511.1Ssimonb 521.1Ssimonbstatic int zbbus_print(void *, const char *); 531.9Sdrochnerstatic int zbbus_submatch(struct device *, struct cfdata *, 541.9Sdrochner const locdesc_t *, void *); 551.1Ssimonbstatic const char *zbbus_entity_type_name(enum zbbus_entity_type type); 561.1Ssimonb 571.1Ssimonbstatic int zbbus_attached; 581.1Ssimonb 591.1Ssimonbstatic const struct zbbus_attach_locs sb1250_zbbus_devs[] = { 601.1Ssimonb { 0, ZBBUS_ENTTYPE_CPU }, 611.1Ssimonb { 1, ZBBUS_ENTTYPE_CPU }, 621.1Ssimonb { 4, ZBBUS_ENTTYPE_SCD }, 631.1Ssimonb { 2, ZBBUS_ENTTYPE_BRZ }, 641.1Ssimonb { 3, ZBBUS_ENTTYPE_OBIO }, 651.1Ssimonb}; 661.1Ssimonbstatic const int sb1250_zbbus_dev_count = 671.1Ssimonb sizeof sb1250_zbbus_devs / sizeof sb1250_zbbus_devs[0]; 681.1Ssimonb 691.1Ssimonbstatic int 701.1Ssimonbzbbus_match(struct device *parent, struct cfdata *match, void *aux) 711.1Ssimonb{ 721.1Ssimonb 731.1Ssimonb if (zbbus_attached) 741.1Ssimonb return (0); 751.1Ssimonb return 1; 761.1Ssimonb} 771.1Ssimonb 781.1Ssimonbstatic void 791.1Ssimonbzbbus_attach(struct device *parent, struct device *self, void *aux) 801.1Ssimonb{ 811.1Ssimonb struct zbbus_attach_args za; 821.1Ssimonb int i; 831.1Ssimonb 841.1Ssimonb printf("\n"); 851.1Ssimonb zbbus_attached = 1; 861.1Ssimonb 871.1Ssimonb sb1250_icu_init(); 881.1Ssimonb 891.1Ssimonb for (i = 0; i < sb1250_zbbus_dev_count; i++) { 901.1Ssimonb memset(&za, 0, sizeof za); 911.1Ssimonb za.za_locs = sb1250_zbbus_devs[i]; 921.9Sdrochner config_found_sm_loc(self, "zbbus", NULL, &za, zbbus_print, 931.9Sdrochner zbbus_submatch); 941.1Ssimonb } 951.1Ssimonb 961.1Ssimonb return; 971.1Ssimonb} 981.1Ssimonb 991.1Ssimonbint 1001.1Ssimonbzbbus_print(void *aux, const char *pnp) 1011.1Ssimonb{ 1021.1Ssimonb struct zbbus_attach_args *zap = aux; 1031.1Ssimonb 1041.1Ssimonb if (pnp) 1051.6Sthorpej aprint_normal("%s at %s", 1061.6Sthorpej zbbus_entity_type_name(zap->za_locs.za_type), pnp); 1071.6Sthorpej aprint_normal(" busid %d", zap->za_locs.za_busid); 1081.1Ssimonb return (UNCONF); 1091.1Ssimonb} 1101.1Ssimonb 1111.1Ssimonbstatic int 1121.9Sdrochnerzbbus_submatch(struct device *parent, struct cfdata *cf, 1131.9Sdrochner const locdesc_t *ldesc, void *aux) 1141.1Ssimonb{ 1151.1Ssimonb struct zbbus_attach_args *zap = aux; 1161.1Ssimonb 1171.1Ssimonb if (cf->cf_loc[ZBBUSCF_BUSID] != ZBBUSCF_BUSID_DEFAULT && 1181.1Ssimonb cf->cf_loc[ZBBUSCF_BUSID] != zap->za_locs.za_busid) 1191.1Ssimonb return (0); 1201.1Ssimonb 1211.2Sthorpej return (config_match(parent, cf, aux)); 1221.1Ssimonb} 1231.1Ssimonb 1241.1Ssimonbstatic const char * 1251.1Ssimonbzbbus_entity_type_name(enum zbbus_entity_type type) 1261.1Ssimonb{ 1271.1Ssimonb 1281.1Ssimonb switch (type) { 1291.1Ssimonb case ZBBUS_ENTTYPE_CPU: 1301.1Ssimonb return ("cpu"); 1311.1Ssimonb case ZBBUS_ENTTYPE_SCD: 1321.1Ssimonb return ("sbscd"); 1331.1Ssimonb case ZBBUS_ENTTYPE_BRZ: 1341.1Ssimonb return ("sbbrz"); 1351.1Ssimonb case ZBBUS_ENTTYPE_OBIO: 1361.1Ssimonb return ("sbobio"); 1371.1Ssimonb } 1381.1Ssimonb panic("zbbus_entity_type_name"); 1391.1Ssimonb return ("panic"); 1401.1Ssimonb} 141