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