bcm_emmc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2016 - 2020, Broadcom
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef EMMC_H
  7. #define EMMC_H
  8. #include <stdint.h>
  9. #include <common/debug.h>
  10. #include <platform_def.h>
  11. #include "emmc_chal_types.h"
  12. #include "emmc_chal_sd.h"
  13. #include "emmc_csl_sdprot.h"
  14. #include "emmc_csl_sdcmd.h"
  15. #include "emmc_pboot_hal_memory_drv.h"
  16. /* ------------------------------------------------------------------- */
  17. #define EXT_CSD_SIZE 512
  18. #ifdef PLAT_SD_MAX_READ_LENGTH
  19. #define SD_MAX_READ_LENGTH PLAT_SD_MAX_READ_LENGTH
  20. #ifdef USE_EMMC_LARGE_BLK_TRANSFER_LENGTH
  21. #define SD_MAX_BLK_TRANSFER_LENGTH 0x10000000
  22. #else
  23. #define SD_MAX_BLK_TRANSFER_LENGTH 0x1000
  24. #endif
  25. #else
  26. #define SD_MAX_READ_LENGTH EMMC_BLOCK_SIZE
  27. #define SD_MAX_BLK_TRANSFER_LENGTH EMMC_BLOCK_SIZE
  28. #endif
  29. struct emmc_global_buffer {
  30. union {
  31. uint8_t Ext_CSD_storage[EXT_CSD_SIZE];
  32. uint8_t tempbuf[SD_MAX_READ_LENGTH];
  33. } u;
  34. };
  35. struct emmc_global_vars {
  36. struct sd_card_data cardData;
  37. struct sd_handle sdHandle;
  38. struct sd_dev sdDevice;
  39. struct sd_card_info sdCard;
  40. unsigned int init_done;
  41. };
  42. #define ICFG_SDIO0_CAP0__SLOT_TYPE_R 27
  43. #define ICFG_SDIO0_CAP0__INT_MODE_R 26
  44. #define ICFG_SDIO0_CAP0__SYS_BUS_64BIT_R 25
  45. #define ICFG_SDIO0_CAP0__VOLTAGE_1P8V_R 24
  46. #define ICFG_SDIO0_CAP0__VOLTAGE_3P0V_R 23
  47. #define ICFG_SDIO0_CAP0__VOLTAGE_3P3V_R 22
  48. #define ICFG_SDIO0_CAP0__SUSPEND_RESUME_R 21
  49. #define ICFG_SDIO0_CAP0__SDMA_R 20
  50. #define ICFG_SDIO0_CAP0__HIGH_SPEED_R 19
  51. #define ICFG_SDIO0_CAP0__ADMA2_R 18
  52. #define ICFG_SDIO0_CAP0__EXTENDED_MEDIA_R 17
  53. #define ICFG_SDIO0_CAP0__MAX_BLOCK_LEN_R 15
  54. #define ICFG_SDIO0_CAP0__BASE_CLK_FREQ_R 7
  55. #define ICFG_SDIO0_CAP0__TIMEOUT_UNIT_R 6
  56. #define ICFG_SDIO0_CAP0__TIMEOUT_CLK_FREQ_R 0
  57. #define ICFG_SDIO0_CAP1__SPI_BLOCK_MODE_R 22
  58. #define ICFG_SDIO0_CAP1__SPI_MODE_R 21
  59. #define ICFG_SDIO0_CAP1__CLK_MULT_R 13
  60. #define ICFG_SDIO0_CAP1__RETUNING_MODE_R 11
  61. #define ICFG_SDIO0_CAP1__TUNE_SDR50_R 10
  62. #define ICFG_SDIO0_CAP1__TIME_RETUNE_R 6
  63. #define ICFG_SDIO0_CAP1__DRIVER_D_R 5
  64. #define ICFG_SDIO0_CAP1__DRIVER_C_R 4
  65. #define ICFG_SDIO0_CAP1__DRIVER_A_R 3
  66. #define ICFG_SDIO0_CAP1__DDR50_R 2
  67. #define ICFG_SDIO0_CAP1__SDR104_R 1
  68. #define ICFG_SDIO0_CAP1__SDR50_R 0
  69. #define SDIO0_CTRL_REGS_BASE_ADDR (SDIO0_EMMCSDXC_SYSADDR)
  70. #define SDIO0_IDM_RESET_CTRL_ADDR (SDIO_IDM0_IDM_RESET_CONTROL)
  71. #define EMMC_CTRL_REGS_BASE_ADDR SDIO0_CTRL_REGS_BASE_ADDR
  72. #define EMMC_IDM_RESET_CTRL_ADDR SDIO0_IDM_RESET_CTRL_ADDR
  73. #define EMMC_IDM_IO_CTRL_DIRECT_ADDR SDIO_IDM0_IO_CONTROL_DIRECT
  74. extern struct emmc_global_buffer *emmc_global_buf_ptr;
  75. extern struct emmc_global_vars *emmc_global_vars_ptr;
  76. #define EMMC_CARD_DETECT_TIMEOUT_MS 1200
  77. #define EMMC_CMD_TIMEOUT_MS 200
  78. #define EMMC_BUSY_CMD_TIMEOUT_MS 200
  79. #define EMMC_CLOCK_SETTING_TIMEOUT_MS 100
  80. #define EMMC_WFE_RETRY 40000
  81. #define EMMC_WFE_RETRY_DELAY_US 10
  82. #ifdef EMMC_DEBUG
  83. #define EMMC_TRACE INFO
  84. #else
  85. #define EMMC_TRACE(...)
  86. #endif
  87. #endif /* EMMC_H */