diff --git a/drivers/st/ddr/stm32mp1_ddr.c b/drivers/st/ddr/stm32mp1_ddr.c index 27d8b2c00..af14781b8 100644 --- a/drivers/st/ddr/stm32mp1_ddr.c +++ b/drivers/st/ddr/stm32mp1_ddr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022, STMicroelectronics - All Rights Reserved + * Copyright (C) 2018-2024, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ @@ -215,7 +215,7 @@ static void stm32mp1_ddrphy_idone_wait(struct stm32mp_ddrphy *phy) { uint32_t pgsr; int error = 0; - uint64_t timeout = timeout_init_us(TIMEOUT_US_1S); + uint64_t timeout = timeout_init_us(DDR_TIMEOUT_US_1S); do { pgsr = mmio_read_32((uintptr_t)&phy->pgsr); @@ -266,7 +266,7 @@ static void stm32mp1_ddrphy_init(struct stm32mp_ddrphy *phy, uint32_t pir) mmio_read_32((uintptr_t)&phy->pir)); /* Need to wait 10 configuration clock before start polling */ - udelay(10); + udelay(DDR_DELAY_10US); /* Wait DRAM initialization and Gate Training Evaluation complete */ stm32mp1_ddrphy_idone_wait(phy); @@ -279,7 +279,7 @@ static void stm32mp1_wait_operating_mode(struct stm32mp_ddr_priv *priv, uint32_t uint32_t stat; int break_loop = 0; - timeout = timeout_init_us(TIMEOUT_US_1S); + timeout = timeout_init_us(DDR_TIMEOUT_US_1S); for ( ; ; ) { uint32_t operating_mode; uint32_t selref_type; @@ -614,7 +614,7 @@ void stm32mp1_ddr_init(struct stm32mp_ddr_priv *priv, mmio_clrbits_32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCAPBRST); /* 1.4. wait 128 cycles to permit initialization of end logic */ - udelay(2); + udelay(DDR_DELAY_2US); /* For PCLK = 133MHz => 1 us is enough, 2 to allow lower frequency */ /* 1.5. initialize registers ddr_umctl2 */ diff --git a/drivers/st/ddr/stm32mp_ddr.c b/drivers/st/ddr/stm32mp_ddr.c index 2136c7176..620aa04d2 100644 --- a/drivers/st/ddr/stm32mp_ddr.c +++ b/drivers/st/ddr/stm32mp_ddr.c @@ -65,7 +65,7 @@ void stm32mp_ddr_wait_sw_done_ack(struct stm32mp_ddrctl *ctl) VERBOSE("[0x%lx] swctl = 0x%x\n", (uintptr_t)&ctl->swctl, mmio_read_32((uintptr_t)&ctl->swctl)); - timeout = timeout_init_us(TIMEOUT_US_1S); + timeout = timeout_init_us(DDR_TIMEOUT_US_1S); do { swstat = mmio_read_32((uintptr_t)&ctl->swstat); VERBOSE("[0x%lx] swstat = 0x%x ", diff --git a/include/drivers/st/stm32mp_ddr.h b/include/drivers/st/stm32mp_ddr.h index 4535e3cb3..f28f8d6e0 100644 --- a/include/drivers/st/stm32mp_ddr.h +++ b/include/drivers/st/stm32mp_ddr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023, STMicroelectronics - All Rights Reserved + * Copyright (C) 2022-2024, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ @@ -57,7 +57,12 @@ struct stm32mp_ddr_info { size_t size; /* Memory size in byte = col * row * width */ }; -#define TIMEOUT_US_1S 1000000U +#define DDR_DELAY_1US 1U +#define DDR_DELAY_2US 2U +#define DDR_DELAY_10US 10U +#define DDR_DELAY_50US 50U +#define DDR_TIMEOUT_500US 500U +#define DDR_TIMEOUT_US_1S 1000000U void stm32mp_ddr_set_reg(const struct stm32mp_ddr_priv *priv, enum stm32mp_ddr_reg_type type, const void *param, const struct stm32mp_ddr_reg_info *ddr_registers);