plat_emmc.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2016 - 2020, Broadcom
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <lib/mmio.h>
  8. #include <platform_def.h>
  9. #define ICFG_IPROC_IOPAD_CTRL_4 (IPROC_ROOT + 0x9c0)
  10. #define ICFG_IPROC_IOPAD_CTRL_5 (IPROC_ROOT + 0x9c4)
  11. #define ICFG_IPROC_IOPAD_CTRL_6 (IPROC_ROOT + 0x9c8)
  12. #define ICFG_IPROC_IOPAD_CTRL_7 (IPROC_ROOT + 0x9cc)
  13. #define IOPAD_CTRL4_SDIO0_CD_IND_R 30
  14. #define IOPAD_CTRL4_SDIO0_CD_SRC_R 31
  15. #define IOPAD_CTRL4_SDIO0_CD_HYS_R 29
  16. #define IOPAD_CTRL4_SDIO0_CD_PULL_R 28
  17. #define IOPAD_CTRL4_SDIO0_CD_DRIVE_R 24
  18. #define IOPAD_CTRL4_SDIO0_CLK_SDCARD_SRC_R 23
  19. #define IOPAD_CTRL4_SDIO0_CLK_SDCARD_HYS_R 21
  20. #define IOPAD_CTRL4_SDIO0_CLK_SDCARD_DRIVE_R 17
  21. #define IOPAD_CTRL4_SDIO0_DATA0_SRC_R 15
  22. #define IOPAD_CTRL4_SDIO0_DATA0_HYS_R 13
  23. #define IOPAD_CTRL4_SDIO0_DATA0_DRIVE_R 9
  24. #define IOPAD_CTRL4_SDIO0_DATA1_SRC_R 7
  25. #define IOPAD_CTRL4_SDIO0_DATA1_HYS_R 5
  26. #define IOPAD_CTRL4_SDIO0_DATA1_DRIVE_R 1
  27. #define IOPAD_CTRL5_SDIO0_DATA2_SRC_R 31
  28. #define IOPAD_CTRL5_SDIO0_DATA2_HYS_R 29
  29. #define IOPAD_CTRL5_SDIO0_DATA2_DRIVE_R 25
  30. #define IOPAD_CTRL5_SDIO0_DATA3_SRC_R 23
  31. #define IOPAD_CTRL5_SDIO0_DATA3_IND_R 22
  32. #define IOPAD_CTRL5_SDIO0_DATA3_HYS_R 21
  33. #define IOPAD_CTRL5_SDIO0_DATA3_DRIVE_R 17
  34. #define IOPAD_CTRL5_SDIO0_DATA4_SRC_R 15
  35. #define IOPAD_CTRL5_SDIO0_DATA4_HYS_R 13
  36. #define IOPAD_CTRL5_SDIO0_DATA4_DRIVE_R 9
  37. #define IOPAD_CTRL5_SDIO0_DATA5_SRC_R 7
  38. #define IOPAD_CTRL5_SDIO0_DATA5_HYS_R 5
  39. #define IOPAD_CTRL5_SDIO0_DATA5_DRIVE_R 1
  40. #define IOPAD_CTRL6_SDIO0_DATA6_SRC_R 31
  41. #define IOPAD_CTRL6_SDIO0_DATA6_HYS_R 29
  42. #define IOPAD_CTRL6_SDIO0_DATA6_DRIVE_R 25
  43. #define IOPAD_CTRL6_SDIO0_DATA7_SRC_R 23
  44. #define IOPAD_CTRL6_SDIO0_DATA7_HYS_R 21
  45. #define IOPAD_CTRL6_SDIO0_DATA7_DRIVE_R 17
  46. void emmc_soft_reset(void)
  47. {
  48. uint32_t val = 0;
  49. val = (BIT(IOPAD_CTRL6_SDIO0_DATA7_SRC_R) |
  50. BIT(IOPAD_CTRL6_SDIO0_DATA7_HYS_R) |
  51. BIT(IOPAD_CTRL6_SDIO0_DATA7_DRIVE_R) |
  52. BIT(IOPAD_CTRL6_SDIO0_DATA6_SRC_R) |
  53. BIT(IOPAD_CTRL6_SDIO0_DATA6_HYS_R) |
  54. BIT(IOPAD_CTRL6_SDIO0_DATA6_DRIVE_R));
  55. mmio_write_32(ICFG_IPROC_IOPAD_CTRL_6, val);
  56. val = (BIT(IOPAD_CTRL5_SDIO0_DATA3_SRC_R) |
  57. BIT(IOPAD_CTRL5_SDIO0_DATA3_HYS_R) |
  58. BIT(IOPAD_CTRL5_SDIO0_DATA3_DRIVE_R) |
  59. BIT(IOPAD_CTRL5_SDIO0_DATA4_SRC_R) |
  60. BIT(IOPAD_CTRL5_SDIO0_DATA4_HYS_R) |
  61. BIT(IOPAD_CTRL5_SDIO0_DATA4_DRIVE_R) |
  62. BIT(IOPAD_CTRL5_SDIO0_DATA5_SRC_R) |
  63. BIT(IOPAD_CTRL5_SDIO0_DATA5_HYS_R) |
  64. BIT(IOPAD_CTRL5_SDIO0_DATA5_DRIVE_R));
  65. mmio_write_32(ICFG_IPROC_IOPAD_CTRL_5, val);
  66. val = (BIT(IOPAD_CTRL4_SDIO0_DATA0_SRC_R) |
  67. BIT(IOPAD_CTRL4_SDIO0_DATA0_HYS_R) |
  68. BIT(IOPAD_CTRL4_SDIO0_DATA0_DRIVE_R) |
  69. BIT(IOPAD_CTRL4_SDIO0_DATA1_SRC_R) |
  70. BIT(IOPAD_CTRL4_SDIO0_DATA1_HYS_R) |
  71. BIT(IOPAD_CTRL4_SDIO0_DATA1_DRIVE_R) |
  72. BIT(IOPAD_CTRL5_SDIO0_DATA2_SRC_R) |
  73. BIT(IOPAD_CTRL5_SDIO0_DATA2_HYS_R) |
  74. BIT(IOPAD_CTRL5_SDIO0_DATA2_DRIVE_R));
  75. mmio_write_32(ICFG_IPROC_IOPAD_CTRL_6, val);
  76. val = (BIT(IOPAD_CTRL4_SDIO0_CLK_SDCARD_SRC_R) |
  77. BIT(IOPAD_CTRL4_SDIO0_CLK_SDCARD_HYS_R) |
  78. BIT(IOPAD_CTRL4_SDIO0_CLK_SDCARD_DRIVE_R) |
  79. BIT(IOPAD_CTRL4_SDIO0_CD_SRC_R) |
  80. BIT(IOPAD_CTRL4_SDIO0_CD_HYS_R));
  81. /*
  82. * set pull-down, clear pull-up=0
  83. * bit 12: pull-down bit 11: pull-up
  84. * Note: In emulation, this pull-down setting was not
  85. * sufficient. Board design likely requires pull down on
  86. * this pin for eMMC.
  87. */
  88. val |= BIT(IOPAD_CTRL4_SDIO0_CD_PULL_R);
  89. mmio_write_32(ICFG_IPROC_IOPAD_CTRL_4, val);
  90. }