ddrphy_phyinit_usercustom.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2021-2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef DDRPHY_PHYINIT_USERCUSTOM_H
  7. #define DDRPHY_PHYINIT_USERCUSTOM_H
  8. #include <stdbool.h>
  9. #include <stdint.h>
  10. #include <ddrphy_csr_all_cdefines.h>
  11. #include <drivers/st/stm32mp2_ddr.h>
  12. /* Message Block Structure Definitions */
  13. #if STM32MP_DDR3_TYPE
  14. #include <mnpmusrammsgblock_ddr3.h>
  15. #elif STM32MP_DDR4_TYPE
  16. #include <mnpmusrammsgblock_ddr4.h>
  17. #else /* STM32MP_LPDDR4_TYPE */
  18. #include <mnpmusrammsgblock_lpddr4.h>
  19. #endif /* STM32MP_DDR3_TYPE */
  20. /*
  21. * -------------------------------------------------------------
  22. * Defines for Firmware Images
  23. * - indicate IMEM/DMEM address, size (bytes) and offsets.
  24. * -------------------------------------------------------------
  25. *
  26. * IMEM_SIZE max size of instruction memory.
  27. * DMEM_SIZE max size of data memory.
  28. *
  29. * IMEM_ST_ADDR start of IMEM address in memory.
  30. * DMEM_ST_ADDR start of DMEM address in memory.
  31. * DMEM_BIN_OFFSET start offset in DMEM memory (message block).
  32. */
  33. #if STM32MP_DDR3_TYPE
  34. #define IMEM_SIZE 0x4C28U
  35. #define DMEM_SIZE 0x6C8U
  36. #elif STM32MP_DDR4_TYPE
  37. #define IMEM_SIZE 0x6D24U
  38. #define DMEM_SIZE 0x6CCU
  39. #else /* STM32MP_LPDDR4_TYPE */
  40. #define IMEM_SIZE 0x7E50U
  41. #define DMEM_SIZE 0x67CU
  42. #endif /* STM32MP_DDR3_TYPE */
  43. #define IMEM_ST_ADDR 0x50000U
  44. #define DMEM_ST_ADDR 0x54000U
  45. #define DMEM_BIN_OFFSET 0x200U
  46. /*
  47. * ------------------
  48. * Type definitions
  49. * ------------------
  50. */
  51. /* A structure used to SRAM memory address space */
  52. enum return_offset_lastaddr {
  53. RETURN_OFFSET,
  54. RETURN_LASTADDR
  55. };
  56. /* Enumeration of instructions for PhyInit Register Interface */
  57. enum reginstr {
  58. STARTTRACK, /* Start register tracking */
  59. STOPTRACK, /* Stop register tracking */
  60. SAVEREGS, /* Save(read) tracked register values */
  61. RESTOREREGS, /* Restore (write) saved register values */
  62. };
  63. /* Data structure to store register address/value pairs */
  64. struct reg_addr_val {
  65. uint32_t address; /* Register address */
  66. uint16_t value; /* Register value */
  67. };
  68. /* Target CSR for the impedance value for ddrphy_phyinit_mapdrvstren() */
  69. enum drvtype {
  70. DRVSTRENFSDQP,
  71. DRVSTRENFSDQN,
  72. ODTSTRENP,
  73. ODTSTRENN,
  74. ADRVSTRENP,
  75. ADRVSTRENN
  76. };
  77. /*
  78. * -------------------------------------------------------------
  79. * Fixed Function prototypes
  80. * -------------------------------------------------------------
  81. */
  82. int ddrphy_phyinit_sequence(struct stm32mp_ddr_config *config, bool skip_training, bool reten);
  83. int ddrphy_phyinit_restore_sequence(void);
  84. int ddrphy_phyinit_c_initphyconfig(struct stm32mp_ddr_config *config,
  85. struct pmu_smb_ddr_1d *mb_ddr_1d, uint32_t *ardptrinitval);
  86. void ddrphy_phyinit_d_loadimem(void);
  87. void ddrphy_phyinit_progcsrskiptrain(struct stm32mp_ddr_config *config,
  88. struct pmu_smb_ddr_1d *mb_ddr_1d, uint32_t ardptrinitval);
  89. int ddrphy_phyinit_f_loaddmem(struct stm32mp_ddr_config *config, struct pmu_smb_ddr_1d *mb_ddr_1d);
  90. int ddrphy_phyinit_g_execfw(void);
  91. void ddrphy_phyinit_i_loadpieimage(struct stm32mp_ddr_config *config, bool skip_training);
  92. void ddrphy_phyinit_loadpieprodcode(void);
  93. int ddrphy_phyinit_mapdrvstren(uint32_t drvstren_ohm, enum drvtype targetcsr);
  94. int ddrphy_phyinit_calcmb(struct stm32mp_ddr_config *config, struct pmu_smb_ddr_1d *mb_ddr_1d);
  95. void ddrphy_phyinit_writeoutmem(uint32_t *mem, uint32_t mem_offset, uint32_t mem_size);
  96. void ddrphy_phyinit_writeoutmsgblk(uint16_t *mem, uint32_t mem_offset, uint32_t mem_size);
  97. int ddrphy_phyinit_isdbytedisabled(struct stm32mp_ddr_config *config,
  98. struct pmu_smb_ddr_1d *mb_ddr_1d, uint32_t dbytenumber);
  99. int ddrphy_phyinit_trackreg(uint32_t adr);
  100. int ddrphy_phyinit_reginterface(enum reginstr myreginstr, uint32_t adr, uint16_t dat);
  101. void ddrphy_phyinit_usercustom_custompretrain(struct stm32mp_ddr_config *config);
  102. int ddrphy_phyinit_usercustom_g_waitfwdone(void);
  103. int ddrphy_phyinit_usercustom_saveretregs(struct stm32mp_ddr_config *config);
  104. #endif /* DDRPHY_PHYINIT_USERCUSTOM_H */