stm32mp_ddr.h 2.2 KB

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