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_FMC_BASE (0x1E620000) 12#define AST_FMC_INT_CTRL_STAT (AST_FMC_BASE + 0x008) 13#define AST_FMC_DMA_CTRL (AST_FMC_BASE + 0x080) 14#define AST_FMC_DMA_FLASH_ADDR (AST_FMC_BASE + 0x084) 15#define AST_FMC_DMA_DRAM_ADDR (AST_FMC_BASE + 0x088) 16#define AST_FMC_DMA_LENGTH (AST_FMC_BASE + 0x08C) 17 18/* 19 * void aspeed_spi_fastcpy(u32 mem_addr, u32 spi_addr, u32 count) 20 * 21 * perform FMC SPI DMA to speed up flash copy. 22 * @dst: destination memory address 23 * @src: source SPI address 24 * @count: number of bytes to be copied, 4-byte aligned 25 * 26 * NOTE that the caller must ensure the validity of parameters. 27 */ 28ENTRY(aspeed_spi_fastcpy) 29 ldr r3, =AST_FMC_DMA_DRAM_ADDR 30 str r0, [r3] 31 32 ldr r3, =AST_FMC_DMA_FLASH_ADDR 33 str r1, [r3] 34 35 ldr r3, =AST_FMC_DMA_LENGTH 36 str r2, [r3] 37 38 ldr r0, =AST_FMC_DMA_CTRL 39 mov r1, #1 40 str r1, [r0] 41 42 ldr r0, =AST_FMC_INT_CTRL_STAT 43polling: 44 ldr r1, [r0] 45 tst r1, #(1 << 11) 46 beq polling 47 48 ldr r0, =AST_FMC_DMA_CTRL 49 mov r1, #0 50 str r1, [r0] 51 52 mov pc, lr 53ENDPROC(aspeed_spi_fastcpy) 54