Commit 8fefbebe authored by Raptor Engineering Development Team's avatar Raptor Engineering Development Team
Browse files

kestrel: Reconfigure Tercel to high speed mode

This is Kestrel specific, NOT FOR UPSTREAM MERGE
Reduce main program load time from ~30s to ~3s
parent c0677a33
......@@ -545,6 +545,24 @@ static unsigned int check_image_in_flash(unsigned int base_address, int check_cr
return length;
}
// WARNING
// KESTREL SPECIFIC
#define TERCEL_SPI_REG_SYS_PHY_CFG1 0x10
#define TERCEL_SPI_REG_SYS_FLASH_CFG5 0x24
#define TERCEL_SPI_PHY_CLOCK_DIVISOR_MASK 0xff
#define TERCEL_SPI_PHY_CLOCK_DIVISOR_SHIFT 0
#define TERCEL_SPI_FLASH_EN_MULTCYC_READ_MASK 0x1
#define TERCEL_SPI_FLASH_EN_MULTCYC_READ_SHIFT 0
static inline uint32_t read_tercel_register(unsigned long base_address, uint8_t reg)
{
return *((volatile uint32_t *)(base_address + reg));
}
static inline void write_tercel_register(unsigned long base_address, uint8_t reg, uint32_t data)
{
*((volatile uint32_t *)(base_address + reg)) = data;
}
#if defined(MAIN_RAM_BASE) && defined(FLASH_BOOT_ADDRESS)
static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address)
{
......@@ -554,6 +572,19 @@ static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned lon
uint32_t crc;
uint32_t got_crc;
// WARNING
// KESTREL SPECIFIC
// Set SPI clock cycle divider to 1
uint32_t dword;
dword = read_tercel_register(BMCSPIFLASHCFG_BASE, TERCEL_SPI_REG_SYS_PHY_CFG1);
dword &= ~(TERCEL_SPI_PHY_CLOCK_DIVISOR_MASK << TERCEL_SPI_PHY_CLOCK_DIVISOR_SHIFT);
dword |= ((1 & TERCEL_SPI_PHY_CLOCK_DIVISOR_MASK) << TERCEL_SPI_PHY_CLOCK_DIVISOR_SHIFT);
write_tercel_register(BMCSPIFLASHCFG_BASE, TERCEL_SPI_REG_SYS_PHY_CFG1, dword);
// Enable read merging
write_tercel_register(BMCSPIFLASHCFG_BASE, TERCEL_SPI_REG_SYS_FLASH_CFG5,
read_tercel_register(BMCSPIFLASHCFG_BASE, TERCEL_SPI_REG_SYS_FLASH_CFG5) |
(TERCEL_SPI_FLASH_EN_MULTCYC_READ_MASK << TERCEL_SPI_FLASH_EN_MULTCYC_READ_SHIFT));
image_length = length = check_image_in_flash(flash_address, 0);
if(length > 0) {
printf("Copying 0x%08x to 0x%08lx (%d bytes)...\n", flash_address, ram_address, length);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment