1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) ASPEED Technology Inc. 4 * Chia-Wei Wang <chiawei_wang@aspeedtech.com> 5 */ 6 7#include <config.h> 8#include <asm/armv7.h> 9#include <linux/linkage.h> 10 11#define AST_SCU_BASE (0x1E6E2000) 12#define AST_SCU_HW_STRAP1 (AST_SCU_BASE + 0x500) 13#define AST_SCU_HW_STRAP2 (AST_SCU_BASE + 0x510) 14 15#define AST_FMC_BASE (0x1E620000) 16#define AST_FMC_INT_CTRL_STAT (AST_FMC_BASE + 0x008) 17#define AST_FMC_DMA_CTRL (AST_FMC_BASE + 0x080) 18#define AST_FMC_DMA_FLASH_ADDR (AST_FMC_BASE + 0x084) 19#define AST_FMC_DMA_DRAM_ADDR (AST_FMC_BASE + 0x088) 20#define AST_FMC_DMA_LENGTH (AST_FMC_BASE + 0x08C) 21 22/* 23 * void aspeed_bootmode(void) 24 * 25 * return the boot mode according to the HW strap information 26 */ 27ENTRY(aspeed_bootmode) 28 ldr r1, =AST_SCU_HW_STRAP2 29 ldr r0, [r1] 30 tst r0, #0x100 31 movne r0, #0x2 @; AST_BOOTMODE_UART 32 bne 0f 33 34 ldr r1, =AST_SCU_HW_STRAP1 35 ldr r0, [r1] 36 tst r0, #0x4 37 moveq r0, #0x0 @; AST_BOOTMODE_SPI 38 movne r0, #0x1 @; AST_BOOTMODE_EMMC 390: 40 mov pc, lr 41ENDPROC(aspeed_bootmode) 42 43/* 44 * void aspeed_spi_fastcpy(u32 mem_addr, u32 spi_addr, u32 count) 45 * 46 * perform FMC SPI DMA to speed up flash copy. 47 * @dst: destination memory address 48 * @src: source SPI address 49 * @count: number of bytes to be copied, 4-byte aligned 50 * 51 * NOTE that the caller must ensure the validity of parameters. 52 */ 53ENTRY(aspeed_spi_fastcpy) 54 ldr r3, =AST_FMC_DMA_DRAM_ADDR 55 str r0, [r3] 56 57 ldr r3, =AST_FMC_DMA_FLASH_ADDR 58 str r1, [r3] 59 60 ldr r3, =AST_FMC_DMA_LENGTH 61 str r2, [r3] 62 63 ldr r0, =AST_FMC_DMA_CTRL 64 mov r1, #1 65 str r1, [r0] 66 67 ldr r0, =AST_FMC_INT_CTRL_STAT 68polling: 69 ldr r1, [r0] 70 tst r1, #(1 << 11) 71 beq polling 72 73 ldr r0, =AST_FMC_DMA_CTRL 74 mov r1, #0 75 str r1, [r0] 76 77 mov pc, lr 78ENDPROC(aspeed_spi_fastcpy) 79