void arm_tf_run_bl31(u64 payload_entry, u64 payload_arg0, u64 payload_spsr) { struct prog bl31 = PROG_INIT(PROG_BL31, CONFIG_CBFS_PREFIX"/bl31"); void (*bl31_entry)(bl31_params_t *params, void *plat_params) = NULL; if (prog_locate(&bl31)) die("BL31 not found"); bl31_entry = selfload(&bl31, false); if (!bl31_entry) die("BL31 load failed"); SET_PARAM_HEAD(&bl31_params, PARAM_BL31, VERSION_1, 0); if (IS_ENABLED(CONFIG_ARM64_USE_SECURE_OS)) { struct prog bl32 = PROG_INIT(PROG_BL32, CONFIG_CBFS_PREFIX"/secure_os"); if (prog_locate(&bl32)) die("BL32 not found"); if (cbfs_prog_stage_load(&bl32)) die("BL32 load failed"); SET_PARAM_HEAD(&bl32_ep_info, PARAM_EP, VERSION_1, PARAM_EP_SECURE); bl32_ep_info.pc = (uintptr_t)prog_entry(&bl32); bl32_ep_info.spsr = SPSR_EXCEPTION_MASK | get_eret_el(EL1, SPSR_USE_L); bl31_params.bl32_ep_info = &bl32_ep_info; } bl31_params.bl33_ep_info = &bl33_ep_info; SET_PARAM_HEAD(&bl33_ep_info, PARAM_EP, VERSION_1, PARAM_EP_NON_SECURE); bl33_ep_info.pc = payload_entry; bl33_ep_info.spsr = payload_spsr; bl33_ep_info.args.arg0 = payload_arg0; /* May update bl31_params if necessary. Must flush all added structs. */ void *bl31_plat_params = soc_get_bl31_plat_params(&bl31_params); dcache_clean_by_mva(&bl31_params, sizeof(bl31_params)); dcache_clean_by_mva(&bl33_ep_info, sizeof(bl33_ep_info)); raw_write_daif(SPSR_EXCEPTION_MASK); mmu_disable(); bl31_entry(&bl31_params, bl31_plat_params); die("BL31 returned!"); }
static int tegra_spi_dma_prepare(struct tegra_spi_channel *spi, unsigned int bytes, enum spi_direction dir) { unsigned int todo, wcount; /* * For DMA we need to think of things in terms of word count. * AHB width is fixed at 32-bits. To avoid overrunning * the in/out buffers we must align down. (Note: lowest 2-bits * in WCOUNT register are ignored, and WCOUNT seems to count * words starting at n-1) * * Example: If "bytes" is 7 and we are transferring 1-byte at a time, * WCOUNT should be 4. The remaining 3 bytes must be transferred * using PIO. */ todo = MIN(bytes, SPI_MAX_TRANSFER_BYTES_DMA - TEGRA_DMA_ALIGN_BYTES); todo = ALIGN_DOWN(todo, TEGRA_DMA_ALIGN_BYTES); wcount = ALIGN_DOWN(todo - TEGRA_DMA_ALIGN_BYTES, TEGRA_DMA_ALIGN_BYTES); flush_fifos(spi); if (dir == SPI_SEND) { spi->dma_out = dma_claim(); if (!spi->dma_out) return -1; /* ensure bytes to send will be visible to DMA controller */ dcache_clean_by_mva(spi->out_buf, bytes); write32(&spi->dma_out->regs->apb_ptr, (uintptr_t) & spi->regs->tx_fifo); write32(&spi->dma_out->regs->ahb_ptr, (uintptr_t)spi->out_buf); setbits_le32(&spi->dma_out->regs->csr, APB_CSR_DIR); setup_dma_params(spi, spi->dma_out); write32(&spi->dma_out->regs->wcount, wcount); } else { spi->dma_in = dma_claim(); if (!spi->dma_in) return -1; /* avoid data collisions */ dcache_clean_invalidate_by_mva(spi->in_buf, bytes); write32(&spi->dma_in->regs->apb_ptr, (uintptr_t)&spi->regs->rx_fifo); write32(&spi->dma_in->regs->ahb_ptr, (uintptr_t)spi->in_buf); clrbits_le32(&spi->dma_in->regs->csr, APB_CSR_DIR); setup_dma_params(spi, spi->dma_in); write32(&spi->dma_in->regs->wcount, wcount); } /* BLOCK_SIZE starts at n-1 */ write32(&spi->regs->dma_blk, todo - 1); return todo; }
/* * startup_save_cpu_data is used to save register values that need to be setup * when a CPU starts booting. This is used by secondary CPUs as well as resume * path to directly setup MMU and other related registers. */ void startup_save_cpu_data(void) { save_element(MAIR_INDEX, raw_read_mair_current()); save_element(TCR_INDEX, raw_read_tcr_current()); save_element(TTBR0_INDEX, raw_read_ttbr0_current()); save_element(VBAR_INDEX, raw_read_vbar_current()); if (get_current_el() == EL3) save_element(SCR_INDEX, raw_read_scr_el3()); dcache_clean_by_mva(_arm64_startup_data, NUM_ELEMENTS * PER_ELEMENT_SIZE_BYTES); }
void *soc_get_bl31_plat_params(bl31_params_t *params) { uintptr_t tz_base_mib; size_t tz_size_mib; carveout_range(CARVEOUT_TZ, &tz_base_mib, &tz_size_mib); assert(tz_size_mib < 4096); t210_plat_params.tzdram_size = tz_size_mib * MiB; dcache_clean_by_mva(&t210_plat_params, sizeof(t210_plat_params)); return &t210_plat_params; }