Commit 3f9c9784 authored by Yann Gautier's avatar Yann Gautier
Browse files

stm32mp1: make functions and macros more common



Mainly remove suffix 1 from prefix stm32mp1 in several macros and functions
that can be used in drivers shared by different platforms.

Change-Id: I2295c44f5b1edac7e80a93c0e8dfd671b36e88e7
Signed-off-by: default avatarYann Gautier <yann.gautier@st.com>
Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
parent c9d75b3c
...@@ -22,14 +22,13 @@ ...@@ -22,14 +22,13 @@
* STM32MP1 memory map related constants * STM32MP1 memory map related constants
******************************************************************************/ ******************************************************************************/
#define STM32MP1_SRAM_BASE U(0x2FFC0000) #define STM32MP_SYSRAM_BASE U(0x2FFC0000)
#define STM32MP1_SRAM_SIZE U(0x00040000) #define STM32MP_SYSRAM_SIZE U(0x00040000)
/* DDR configuration */ /* DDR configuration */
#define STM32MP1_DDR_BASE U(0xC0000000) #define STM32MP_DDR_BASE U(0xC0000000)
#define STM32MP1_DDR_SIZE_DFLT U(0x20000000) /* 512 MB */ #define STM32MP_DDR_MAX_SIZE U(0x40000000) /* Max 1GB */
#define STM32MP1_DDR_MAX_SIZE U(0x40000000) /* Max 1GB */ #define STM32MP_DDR_SPEED_DFLT 528
#define STM32MP1_DDR_SPEED_DFLT 528
/* DDR power initializations */ /* DDR power initializations */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -40,36 +39,36 @@ enum ddr_type { ...@@ -40,36 +39,36 @@ enum ddr_type {
#endif #endif
/* Section used inside TF binaries */ /* Section used inside TF binaries */
#define STM32MP1_PARAM_LOAD_SIZE U(0x00002400) /* 9 Ko for param */ #define STM32MP_PARAM_LOAD_SIZE U(0x00002400) /* 9 Ko for param */
/* 256 Octets reserved for header */ /* 256 Octets reserved for header */
#define STM32MP1_HEADER_SIZE U(0x00000100) #define STM32MP_HEADER_SIZE U(0x00000100)
#define STM32MP1_BINARY_BASE (STM32MP1_SRAM_BASE + \ #define STM32MP_BINARY_BASE (STM32MP_SYSRAM_BASE + \
STM32MP1_PARAM_LOAD_SIZE + \ STM32MP_PARAM_LOAD_SIZE + \
STM32MP1_HEADER_SIZE) STM32MP_HEADER_SIZE)
#define STM32MP1_BINARY_SIZE (STM32MP1_SRAM_SIZE - \ #define STM32MP_BINARY_SIZE (STM32MP_SYSRAM_SIZE - \
(STM32MP1_PARAM_LOAD_SIZE + \ (STM32MP_PARAM_LOAD_SIZE + \
STM32MP1_HEADER_SIZE)) STM32MP_HEADER_SIZE))
#if STACK_PROTECTOR_ENABLED #if STACK_PROTECTOR_ENABLED
#define STM32MP1_BL32_SIZE U(0x00012000) /* 72 Ko for BL32 */ #define STM32MP_BL32_SIZE U(0x00012000) /* 72 Ko for BL32 */
#else #else
#define STM32MP1_BL32_SIZE U(0x00011000) /* 68 Ko for BL32 */ #define STM32MP_BL32_SIZE U(0x00011000) /* 68 Ko for BL32 */
#endif #endif
#define STM32MP1_BL32_BASE (STM32MP1_SRAM_BASE + \ #define STM32MP_BL32_BASE (STM32MP_SYSRAM_BASE + \
STM32MP1_SRAM_SIZE - \ STM32MP_SYSRAM_SIZE - \
STM32MP1_BL32_SIZE) STM32MP_BL32_SIZE)
#if STACK_PROTECTOR_ENABLED #if STACK_PROTECTOR_ENABLED
#define STM32MP1_BL2_SIZE U(0x00015000) /* 84 Ko for BL2 */ #define STM32MP_BL2_SIZE U(0x00015000) /* 84 Ko for BL2 */
#else #else
#define STM32MP1_BL2_SIZE U(0x00013000) /* 76 Ko for BL2 */ #define STM32MP_BL2_SIZE U(0x00013000) /* 76 Ko for BL2 */
#endif #endif
#define STM32MP1_BL2_BASE (STM32MP1_BL32_BASE - \ #define STM32MP_BL2_BASE (STM32MP_BL32_BASE - \
STM32MP1_BL2_SIZE) STM32MP_BL2_SIZE)
/* BL2 and BL32/sp_min require 5 tables */ /* BL2 and BL32/sp_min require 5 tables */
#define MAX_XLAT_TABLES 5 #define MAX_XLAT_TABLES 5
...@@ -86,12 +85,12 @@ enum ddr_type { ...@@ -86,12 +85,12 @@ enum ddr_type {
#endif #endif
/* DTB initialization value */ /* DTB initialization value */
#define STM32MP1_DTB_SIZE U(0x00004000) /* 16Ko for DTB */ #define STM32MP_DTB_SIZE U(0x00004000) /* 16Ko for DTB */
#define STM32MP1_DTB_BASE (STM32MP1_BL2_BASE - \ #define STM32MP_DTB_BASE (STM32MP_BL2_BASE - \
STM32MP1_DTB_SIZE) STM32MP_DTB_SIZE)
#define STM32MP1_BL33_BASE (STM32MP1_DDR_BASE + U(0x100000)) #define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x100000))
/******************************************************************************* /*******************************************************************************
* STM32MP1 device/io map related constants (used for MMU) * STM32MP1 device/io map related constants (used for MMU)
...@@ -156,12 +155,12 @@ enum ddr_type { ...@@ -156,12 +155,12 @@ enum ddr_type {
#define USART6_BASE U(0x44003000) #define USART6_BASE U(0x44003000)
#define UART7_BASE U(0x40018000) #define UART7_BASE U(0x40018000)
#define UART8_BASE U(0x40019000) #define UART8_BASE U(0x40019000)
#define STM32MP1_UART_BAUDRATE U(115200) #define STM32MP_UART_BAUDRATE U(115200)
/* For UART crash console */ /* For UART crash console */
#define STM32MP1_DEBUG_USART_BASE UART4_BASE #define STM32MP_DEBUG_USART_BASE UART4_BASE
/* UART4 on HSI@64MHz, TX on GPIOG11 Alternate 6 */ /* UART4 on HSI@64MHz, TX on GPIOG11 Alternate 6 */
#define STM32MP1_DEBUG_USART_CLK_FRQ 64000000 #define STM32MP_DEBUG_USART_CLK_FRQ 64000000
#define DEBUG_UART_TX_GPIO_BANK_ADDRESS GPIOG_BASE #define DEBUG_UART_TX_GPIO_BANK_ADDRESS GPIOG_BASE
#define DEBUG_UART_TX_GPIO_BANK_CLK_REG RCC_MP_AHB4ENSETR #define DEBUG_UART_TX_GPIO_BANK_CLK_REG RCC_MP_AHB4ENSETR
#define DEBUG_UART_TX_GPIO_BANK_CLK_EN RCC_MP_AHB4ENSETR_GPIOGEN #define DEBUG_UART_TX_GPIO_BANK_CLK_EN RCC_MP_AHB4ENSETR_GPIOGEN
...@@ -193,15 +192,15 @@ enum ddr_type { ...@@ -193,15 +192,15 @@ enum ddr_type {
/******************************************************************************* /*******************************************************************************
* STM32MP1 SDMMC * STM32MP1 SDMMC
******************************************************************************/ ******************************************************************************/
#define STM32MP1_SDMMC1_BASE U(0x58005000) #define STM32MP_SDMMC1_BASE U(0x58005000)
#define STM32MP1_SDMMC2_BASE U(0x58007000) #define STM32MP_SDMMC2_BASE U(0x58007000)
#define STM32MP1_SDMMC3_BASE U(0x48004000) #define STM32MP_SDMMC3_BASE U(0x48004000)
#define STM32MP1_MMC_INIT_FREQ 400000 /*400 KHz*/ #define STM32MP_MMC_INIT_FREQ 400000 /*400 KHz*/
#define STM32MP1_SD_NORMAL_SPEED_MAX_FREQ 25000000 /*25 MHz*/ #define STM32MP_SD_NORMAL_SPEED_MAX_FREQ 25000000 /*25 MHz*/
#define STM32MP1_SD_HIGH_SPEED_MAX_FREQ 50000000 /*50 MHz*/ #define STM32MP_SD_HIGH_SPEED_MAX_FREQ 50000000 /*50 MHz*/
#define STM32MP1_EMMC_NORMAL_SPEED_MAX_FREQ 26000000 /*26 MHz*/ #define STM32MP_EMMC_NORMAL_SPEED_MAX_FREQ 26000000 /*26 MHz*/
#define STM32MP1_EMMC_HIGH_SPEED_MAX_FREQ 52000000 /*52 MHz*/ #define STM32MP_EMMC_HIGH_SPEED_MAX_FREQ 52000000 /*52 MHz*/
/******************************************************************************* /*******************************************************************************
* STM32MP1 BSEC / OTP * STM32MP1 BSEC / OTP
......
...@@ -74,7 +74,7 @@ func plat_is_my_cpu_primary ...@@ -74,7 +74,7 @@ func plat_is_my_cpu_primary
ldcopr r0, MPIDR ldcopr r0, MPIDR
ldr r1, =(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK) ldr r1, =(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
and r0, r1 and r0, r1
cmp r0, #STM32MP1_PRIMARY_CPU cmp r0, #STM32MP_PRIMARY_CPU
moveq r0, #1 moveq r0, #1
movne r0, #0 movne r0, #0
bx lr bx lr
...@@ -143,9 +143,9 @@ func plat_crash_console_init ...@@ -143,9 +143,9 @@ func plat_crash_console_init
orr r2, r2, #DEBUG_UART_TX_EN orr r2, r2, #DEBUG_UART_TX_EN
str r2, [r1] str r2, [r1]
ldr r0, =STM32MP1_DEBUG_USART_BASE ldr r0, =STM32MP_DEBUG_USART_BASE
ldr r1, =STM32MP1_DEBUG_USART_CLK_FRQ ldr r1, =STM32MP_DEBUG_USART_CLK_FRQ
ldr r2, =STM32MP1_UART_BAUDRATE ldr r2, =STM32MP_UART_BAUDRATE
b console_stm32_core_init b console_stm32_core_init
endfunc plat_crash_console_init endfunc plat_crash_console_init
...@@ -156,7 +156,7 @@ endfunc plat_crash_console_init ...@@ -156,7 +156,7 @@ endfunc plat_crash_console_init
* --------------------------------------------- * ---------------------------------------------
*/ */
func plat_crash_console_flush func plat_crash_console_flush
ldr r1, =STM32MP1_DEBUG_USART_BASE ldr r1, =STM32MP_DEBUG_USART_BASE
b console_stm32_core_flush b console_stm32_core_flush
endfunc plat_crash_console_flush endfunc plat_crash_console_flush
...@@ -172,6 +172,6 @@ endfunc plat_crash_console_flush ...@@ -172,6 +172,6 @@ endfunc plat_crash_console_flush
* --------------------------------------------- * ---------------------------------------------
*/ */
func plat_crash_console_putc func plat_crash_console_putc
ldr r1, =STM32MP1_DEBUG_USART_BASE ldr r1, =STM32MP_DEBUG_USART_BASE
b console_stm32_core_putc b console_stm32_core_putc
endfunc plat_crash_console_putc endfunc plat_crash_console_putc
...@@ -70,15 +70,15 @@ static int stm32_pwr_domain_on(u_register_t mpidr) ...@@ -70,15 +70,15 @@ static int stm32_pwr_domain_on(u_register_t mpidr)
return PSCI_E_INVALID_PARAMS; return PSCI_E_INVALID_PARAMS;
} }
if ((stm32_sec_entrypoint < STM32MP1_SRAM_BASE) || if ((stm32_sec_entrypoint < STM32MP_SYSRAM_BASE) ||
(stm32_sec_entrypoint > (STM32MP1_SRAM_BASE + (stm32_sec_entrypoint > (STM32MP_SYSRAM_BASE +
(STM32MP1_SRAM_SIZE - 1)))) { (STM32MP_SYSRAM_SIZE - 1)))) {
return PSCI_E_INVALID_ADDRESS; return PSCI_E_INVALID_ADDRESS;
} }
if (!stm32mp1_clk_is_enabled(RTCAPB)) { if (!stm32mp_clk_is_enabled(RTCAPB)) {
tamp_clk_off = 1; tamp_clk_off = 1;
if (stm32mp1_clk_enable(RTCAPB) != 0) { if (stm32mp_clk_enable(RTCAPB) != 0) {
panic(); panic();
} }
} }
...@@ -92,13 +92,13 @@ static int stm32_pwr_domain_on(u_register_t mpidr) ...@@ -92,13 +92,13 @@ static int stm32_pwr_domain_on(u_register_t mpidr)
mmio_write_32(bkpr_core1_magic, BOOT_API_A7_CORE1_MAGIC_NUMBER); mmio_write_32(bkpr_core1_magic, BOOT_API_A7_CORE1_MAGIC_NUMBER);
if (tamp_clk_off != 0U) { if (tamp_clk_off != 0U) {
if (stm32mp1_clk_disable(RTCAPB) != 0) { if (stm32mp_clk_disable(RTCAPB) != 0) {
panic(); panic();
} }
} }
/* Generate an IT to core 1 */ /* Generate an IT to core 1 */
gicv2_raise_sgi(ARM_IRQ_SEC_SGI_0, STM32MP1_SECONDARY_CPU); gicv2_raise_sgi(ARM_IRQ_SEC_SGI_0, STM32MP_SECONDARY_CPU);
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
...@@ -194,7 +194,7 @@ static int stm32_validate_power_state(unsigned int power_state, ...@@ -194,7 +194,7 @@ static int stm32_validate_power_state(unsigned int power_state,
static int stm32_validate_ns_entrypoint(uintptr_t entrypoint) static int stm32_validate_ns_entrypoint(uintptr_t entrypoint)
{ {
/* The non-secure entry point must be in DDR */ /* The non-secure entry point must be in DDR */
if (entrypoint < STM32MP1_DDR_BASE) { if (entrypoint < STM32MP_DDR_BASE) {
return PSCI_E_INVALID_ADDRESS; return PSCI_E_INVALID_ADDRESS;
} }
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <lib/xlat_tables/xlat_tables_v2.h> #include <lib/xlat_tables/xlat_tables_v2.h>
#define MAP_SRAM MAP_REGION_FLAT(STM32MP1_SRAM_BASE, \ #define MAP_SRAM MAP_REGION_FLAT(STM32MP_SYSRAM_BASE, \
STM32MP1_SRAM_SIZE, \ STM32MP_SYSRAM_SIZE, \
MT_MEMORY | \ MT_MEMORY | \
MT_RW | \ MT_RW | \
MT_SECURE | \ MT_SECURE | \
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
static void init_tzc400(void) static void init_tzc400(void)
{ {
unsigned long long region_base, region_top; unsigned long long region_base, region_top;
unsigned long long ddr_base = STM32MP1_DDR_BASE; unsigned long long ddr_base = STM32MP_DDR_BASE;
unsigned long long ddr_size = (unsigned long long)dt_get_ddr_size(); unsigned long long ddr_size = (unsigned long long)dt_get_ddr_size();
tzc400_init(STM32MP1_TZC_BASE); tzc400_init(STM32MP1_TZC_BASE);
...@@ -62,11 +62,11 @@ static void init_tzc400(void) ...@@ -62,11 +62,11 @@ static void init_tzc400(void)
******************************************************************************/ ******************************************************************************/
static void early_init_tzc400(void) static void early_init_tzc400(void)
{ {
if (stm32mp1_clk_enable(TZC1) != 0) { if (stm32mp_clk_enable(TZC1) != 0) {
ERROR("Cannot enable TZC1 clock\n"); ERROR("Cannot enable TZC1 clock\n");
panic(); panic();
} }
if (stm32mp1_clk_enable(TZC2) != 0) { if (stm32mp_clk_enable(TZC2) != 0) {
ERROR("Cannot enable TZC2 clock\n"); ERROR("Cannot enable TZC2 clock\n");
panic(); panic();
} }
...@@ -80,9 +80,9 @@ static void early_init_tzc400(void) ...@@ -80,9 +80,9 @@ static void early_init_tzc400(void)
* same configuration to all filters in the TZC. * same configuration to all filters in the TZC.
*/ */
tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 1, tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 1,
STM32MP1_DDR_BASE, STM32MP_DDR_BASE,
STM32MP1_DDR_BASE + STM32MP_DDR_BASE +
(STM32MP1_DDR_MAX_SIZE - 1U), (STM32MP_DDR_MAX_SIZE - 1U),
TZC_REGION_S_RDWR, TZC_REGION_S_RDWR,
TZC_REGION_ACCESS_RDWR(STM32MP1_TZC_A7_ID) | TZC_REGION_ACCESS_RDWR(STM32MP1_TZC_A7_ID) |
TZC_REGION_ACCESS_RDWR(STM32MP1_TZC_SDMMC_ID)); TZC_REGION_ACCESS_RDWR(STM32MP1_TZC_SDMMC_ID));
......
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