int main (void) { boot_up(); //Initialize USB port pins and set up the UART rprintf("Boot up complete\n"); if(IOPIN0 & (1<<23)) //Check to see if the USB cable is plugged in { main_msc(); //If so, run the USB device driver. } else{ rprintf("No USB Detected\n"); } //Init SD if(sd_raw_init()) //Initialize the SD card { openroot(); //Open the root directory on the SD card rprintf("Root open\n"); if(root_file_exists(FW_FILE)) //Check to see if the firmware file is residing in the root directory { rprintf("New firmware found\n"); load_fw(FW_FILE); //If we found the firmware file, then program it's contents into memory. rprintf("New firmware loaded\n"); } } else{ //Didn't find a card to initialize rprintf("No SD Card Detected\n"); delay_ms(250); } rprintf("Boot Done. Calling firmware...\n"); call_firmware(); //Run the new code! while(1); }
static int init_hw(struct tegra_xhci_softc *sc) { int rv; uint32_t reg; rman_res_t base_addr; base_addr = rman_get_start(sc->xhci_softc.sc_io_res); /* Enable FPCI access */ reg = IPFS_RD4(sc, XUSB_HOST_CONFIGURATION); reg |= CONFIGURATION_EN_FPCI; IPFS_WR4(sc, XUSB_HOST_CONFIGURATION, reg); IPFS_RD4(sc, XUSB_HOST_CONFIGURATION); /* Program bar for XHCI base address */ reg = FPCI_RD4(sc, T_XUSB_CFG_4); reg &= ~CFG_4_BASE_ADDRESS(~0); reg |= CFG_4_BASE_ADDRESS((uint32_t)base_addr >> 15); FPCI_WR4(sc, T_XUSB_CFG_4, reg); FPCI_WR4(sc, T_XUSB_CFG_5, (uint32_t)((uint64_t)(base_addr) >> 32)); /* Enable bus master */ reg = FPCI_RD4(sc, T_XUSB_CFG_1); reg |= CFG_1_IO_SPACE; reg |= CFG_1_MEMORY_SPACE; reg |= CFG_1_BUS_MASTER; FPCI_WR4(sc, T_XUSB_CFG_1, reg); /* Enable Interrupts */ reg = IPFS_RD4(sc, XUSB_HOST_INTR_MASK); reg |= INTR_IP_INT_MASK; IPFS_WR4(sc, XUSB_HOST_INTR_MASK, reg); /* Set hysteresis */ IPFS_WR4(sc, XUSB_HOST_CLKGATE_HYSTERESIS, 128); rv = load_fw(sc); if (rv != 0) return rv; return (0); }