singlemode.c (4407B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * The PCID application handler. 8 * 9 * Requires: 10 * All modules 11 * 12 * Provides: 13 * Initialization 14 */ 15 16 #ifdef SINGLE_MODE 17 18 #include <shared/bsl.h> 19 #include <shared/bslext.h> 20 21 #include <unistd.h> 22 #include <stdlib.h> 23 #include <ctype.h> 24 25 #include <sys/types.h> 26 #include <sys/socket.h> 27 #include <sys/time.h> 28 #include <soc/mem.h> 29 #include <soc/hash.h> 30 #include <soc/cmext.h> 31 32 #include <soc/cmic.h> 33 #ifdef BCM_CMICM_SUPPORT 34 #include <soc/cmicm.h> 35 #endif 36 #include <soc/drv.h> 37 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT) 38 #include <soc/dpp/drv.h> 39 #include <soc/dfe/cmn/dfe_drv.h> 40 #endif 41 #ifdef BCM_PETRA_SUPPORT 42 #include <soc/dpp/mbcm.h> 43 #endif 44 #include <soc/devids.h> 45 #include <soc/chip.h> 46 #include <soc/mcm/driver.h> /* soc_base_driver_table */ 47 #include <soc/debug.h> 48 #include <sal/appl/io.h> 49 50 #include <bde/pli/verinet.h> 51 #include <bde/pli/plibde.h> 52 53 #include <sal/core/boot.h> 54 #include <sal/appl/config.h> 55 56 #include <sim/pcid/pcid.h> 57 #include <sim/pcid/mem.h> 58 #include <sim/pcid/cmicsim.h> 59 #include <sim/pcid/dma.h> 60 #include <sim/pcid/pli.h> 61 #include <sim/pcid/socintf.h> 62 #include <sim/pcid/chipsim.h> 63 64 pcid_info_t pcid_info; 65 66 void 67 local_pcid_info_init(pcid_info_t *pcid_info) 68 { 69 sal_memset(pcid_info, 0, sizeof(pcid_info_t)); 70 pcid_info->opt_gbp_banks = 2; 71 pcid_info->opt_gbp_mb = 32; 72 pcid_info->opt_gbp_wid = 128; 73 74 pcid_info->single_mode = 1; 75 76 if ((pcid_info->pkt_mutex = sal_mutex_create("pkt_mutex")) == NULL) { 77 printf("sal_mutex_create -pkt_mutex failed\n"); 78 exit(1); 79 } 80 soc_cm_init(); 81 } 82 83 int 84 _local_setup(pcid_info_t* pcid_info, char *chip_name, uint16 *dev_id, uint8 *rev_id) 85 { 86 int i, chip, found; 87 #ifndef __STRICT_ANSI__ 88 extern char *optarg; 89 #endif 90 uint16 pci_dev_id, pci_ven_id; 91 uint8 pci_rev_id; 92 93 local_pcid_info_init(pcid_info); 94 95 pcid_info->opt_chip_name = chip_name; 96 pcid_info->sbus_addr_version = SBUS_ADDR_VERSION_2; 97 98 found = 0; 99 100 for (i = 0; i < SOC_CHIP_TYPES_COUNT; i++) { 101 if (sal_strcasecmp(pcid_info->opt_chip_name, soc_chip_type_names[i]) == 0) { 102 found = 1; 103 pcid_info->opt_chip = i; 104 chip = soc_chip_type_to_index(pcid_info->opt_chip); 105 break; 106 } 107 /* Allow specifying chip by number only, e.g. 5690 or 56504 */ 108 if (isdigit((unsigned)pcid_info->opt_chip_name[0]) && 109 atoi(pcid_info->opt_chip_name) == 110 atoi(&soc_chip_type_names[i][3])) { 111 found = 1; 112 pcid_info->opt_chip = i; 113 chip = soc_chip_type_to_index(pcid_info->opt_chip); 114 break; 115 } 116 } 117 118 if (!found) { 119 fprintf(stderr, 120 "pcid: Unrecognized chip type '%s'\n", 121 pcid_info->opt_chip_name); 122 fprintf(stderr, "pcid: Valid chip types are:\n"); 123 for (i = 0; i < SOC_CHIP_TYPES_COUNT; i++) { 124 fprintf(stderr, "pcid: %s\n", soc_chip_type_names[i]); 125 } 126 exit(1); 127 } 128 129 /* 130 * Set initial contents of PCI configuration space. 131 */ 132 chip = soc_chip_type_to_index(pcid_info->opt_chip); 133 pci_ven_id = soc_base_driver_table[chip]->pci_vendor; 134 pci_dev_id = soc_base_driver_table[chip]->pci_device; 135 pci_rev_id = soc_base_driver_table[chip]->pci_revision; 136 137 138 if (pci_dev_id == 0x0) { 139 fprintf(stderr, 140 "pcid: Not compiled with support for '%s'\n", 141 pcid_info->opt_chip_name); 142 exit(1); 143 } 144 145 /* From here on, we want the effective ID's */ 146 if (pcid_info->opt_override_devid) { 147 pci_dev_id = pcid_info->opt_override_devid; 148 } 149 if (pcid_info->opt_override_revid) { 150 pci_rev_id = pcid_info->opt_override_revid; 151 } 152 153 /* Set device and revision */ 154 *dev_id = pci_dev_id; 155 *rev_id = pci_rev_id; 156 157 soc_internal_pcic_init(pcid_info, pci_dev_id, 158 pci_ven_id, pci_rev_id, 0xcd600000); 159 160 pli_reset_service(pcid_info); 161 162 return 0; 163 } 164 #else 165 void single_mode_dummy_function(void) 166 { 167 /* ISO C forbids an empty source file */ 168 /* This function is here to handle cases when SINGLE_MODE is not defined */ 169 } 170 #endif /* !SINGLE_MODE */