zbbus.c revision 1.1
11.1Smrg/* $NetBSD: zbbus.c,v 1.1 2017/07/24 08:56:29 mrg 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.1Smrg__KERNEL_RCSID(0, "$NetBSD: zbbus.c,v 1.1 2017/07/24 08:56:29 mrg 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.1Smrg#include "locators.h" 451.1Smrg 461.1Smrgstatic int zbbus_match(device_t, cfdata_t, void *); 471.1Smrgstatic void zbbus_attach(device_t, device_t, void *); 481.1Smrg 491.1SmrgCFATTACH_DECL_NEW(zbbus, 0, 501.1Smrg zbbus_match, zbbus_attach, NULL, NULL); 511.1Smrg 521.1Smrgstatic int zbbus_print(void *, const char *); 531.1Smrgstatic int zbbus_submatch(device_t, cfdata_t, const int *, void *); 541.1Smrgstatic const char *zbbus_entity_type_name(enum zbbus_entity_type type); 551.1Smrg 561.1Smrgstatic int zbbus_attached; 571.1Smrg 581.1Smrgstatic const struct zbbus_attach_locs sb1250_zbbus_devs[] = { 591.1Smrg { 0, ZBBUS_ENTTYPE_CPU }, 601.1Smrg { 1, ZBBUS_ENTTYPE_CPU }, 611.1Smrg { 4, ZBBUS_ENTTYPE_SCD }, 621.1Smrg { 2, ZBBUS_ENTTYPE_BRZ }, 631.1Smrg { 3, ZBBUS_ENTTYPE_OBIO }, 641.1Smrg}; 651.1Smrgstatic const int sb1250_zbbus_dev_count = 661.1Smrg sizeof sb1250_zbbus_devs / sizeof sb1250_zbbus_devs[0]; 671.1Smrg 681.1Smrgstatic int 691.1Smrgzbbus_match(device_t parent, cfdata_t match, void *aux) 701.1Smrg{ 711.1Smrg 721.1Smrg if (zbbus_attached) 731.1Smrg return (0); 741.1Smrg return 1; 751.1Smrg} 761.1Smrg 771.1Smrgstatic void 781.1Smrgzbbus_attach(device_t parent, device_t self, void *aux) 791.1Smrg{ 801.1Smrg struct zbbus_attach_args za; 811.1Smrg int i; 821.1Smrg 831.1Smrg printf("\n"); 841.1Smrg zbbus_attached = 1; 851.1Smrg 861.1Smrg sb1250_icu_init(); 871.1Smrg 881.1Smrg for (i = 0; i < sb1250_zbbus_dev_count; i++) { 891.1Smrg memset(&za, 0, sizeof za); 901.1Smrg za.za_locs = sb1250_zbbus_devs[i]; 911.1Smrg config_found_sm_loc(self, "zbbus", NULL, &za, zbbus_print, 921.1Smrg zbbus_submatch); 931.1Smrg } 941.1Smrg 951.1Smrg return; 961.1Smrg} 971.1Smrg 981.1Smrgint 991.1Smrgzbbus_print(void *aux, const char *pnp) 1001.1Smrg{ 1011.1Smrg struct zbbus_attach_args *zap = aux; 1021.1Smrg 1031.1Smrg if (pnp) 1041.1Smrg aprint_normal("%s at %s", 1051.1Smrg zbbus_entity_type_name(zap->za_locs.za_type), pnp); 1061.1Smrg aprint_normal(" busid %d", zap->za_locs.za_busid); 1071.1Smrg return (UNCONF); 1081.1Smrg} 1091.1Smrg 1101.1Smrgstatic int 1111.1Smrgzbbus_submatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) 1121.1Smrg{ 1131.1Smrg struct zbbus_attach_args *zap = aux; 1141.1Smrg 1151.1Smrg if (cf->cf_loc[ZBBUSCF_BUSID] != ZBBUSCF_BUSID_DEFAULT && 1161.1Smrg cf->cf_loc[ZBBUSCF_BUSID] != zap->za_locs.za_busid) 1171.1Smrg return (0); 1181.1Smrg 1191.1Smrg return (config_match(parent, cf, aux)); 1201.1Smrg} 1211.1Smrg 1221.1Smrgstatic const char * 1231.1Smrgzbbus_entity_type_name(enum zbbus_entity_type type) 1241.1Smrg{ 1251.1Smrg 1261.1Smrg switch (type) { 1271.1Smrg case ZBBUS_ENTTYPE_CPU: 1281.1Smrg return ("cpu"); 1291.1Smrg case ZBBUS_ENTTYPE_SCD: 1301.1Smrg return ("sbscd"); 1311.1Smrg case ZBBUS_ENTTYPE_BRZ: 1321.1Smrg return ("sbbrz"); 1331.1Smrg case ZBBUS_ENTTYPE_OBIO: 1341.1Smrg return ("sbobio"); 1351.1Smrg } 1361.1Smrg panic("zbbus_entity_type_name"); 1371.1Smrg return ("panic"); 1381.1Smrg} 139