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