1 /* 2 * Copyright (C) 2022-2024, STMicroelectronics - All Rights Reserved 3 * 4 * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause 5 */ 6 7 #ifndef STM32MP_DDR_H 8 #define STM32MP_DDR_H 9 10 #include <platform_def.h> 11 12 enum stm32mp_ddr_base_type { 13 DDR_BASE, 14 DDRPHY_BASE, 15 NONE_BASE 16 }; 17 18 enum stm32mp_ddr_reg_type { 19 REG_REG, 20 REG_TIMING, 21 REG_PERF, 22 REG_MAP, 23 REGPHY_REG, 24 REGPHY_TIMING, 25 REG_TYPE_NB 26 }; 27 28 struct stm32mp_ddr_reg_desc { 29 uint16_t offset; /* Offset for base address */ 30 uint8_t par_offset; /* Offset for parameter array */ 31 }; 32 33 struct stm32mp_ddr_reg_info { 34 const char *name; 35 const struct stm32mp_ddr_reg_desc *desc; 36 uint8_t size; 37 enum stm32mp_ddr_base_type base; 38 }; 39 40 struct stm32mp_ddr_size { 41 uint64_t base; 42 uint64_t size; 43 }; 44 45 struct stm32mp_ddr_priv { 46 struct stm32mp_ddr_size info; 47 struct stm32mp_ddrctl *ctl; 48 struct stm32mp_ddrphy *phy; 49 uintptr_t pwr; 50 uintptr_t rcc; 51 }; 52 53 struct stm32mp_ddr_info { 54 const char *name; 55 uint32_t speed; /* in kHz */ 56 size_t size; /* Memory size in byte = col * row * width */ 57 }; 58 59 #define DDR_DELAY_1US 1U 60 #define DDR_DELAY_2US 2U 61 #define DDR_DELAY_10US 10U 62 #define DDR_DELAY_50US 50U 63 #define DDR_TIMEOUT_500US 500U 64 #define DDR_TIMEOUT_US_1S 1000000U 65 66 void stm32mp_ddr_set_reg(const struct stm32mp_ddr_priv *priv, enum stm32mp_ddr_reg_type type, 67 const void *param, const struct stm32mp_ddr_reg_info *ddr_registers); 68 void stm32mp_ddr_start_sw_done(struct stm32mp_ddrctl *ctl); 69 void stm32mp_ddr_wait_sw_done_ack(struct stm32mp_ddrctl *ctl); 70 void stm32mp_ddr_enable_axi_port(struct stm32mp_ddrctl *ctl); 71 int stm32mp_ddr_disable_axi_port(struct stm32mp_ddrctl *ctl); 72 void stm32mp_ddr_enable_host_interface(struct stm32mp_ddrctl *ctl); 73 void stm32mp_ddr_disable_host_interface(struct stm32mp_ddrctl *ctl); 74 int stm32mp_ddr_sw_selfref_entry(struct stm32mp_ddrctl *ctl); 75 void stm32mp_ddr_sw_selfref_exit(struct stm32mp_ddrctl *ctl); 76 void stm32mp_ddr_set_qd3_update_conditions(struct stm32mp_ddrctl *ctl); 77 void stm32mp_ddr_unset_qd3_update_conditions(struct stm32mp_ddrctl *ctl); 78 void stm32mp_ddr_wait_refresh_update_done_ack(struct stm32mp_ddrctl *ctl); 79 int stm32mp_board_ddr_power_init(enum ddr_type ddr_type); 80 81 #endif /* STM32MP_DDR_H */ 82