stm32f746-disco.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * (C) Copyright 2016
  3. * Vikas Manocha, <vikas.manocha@st.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <dm.h>
  9. #include <ram.h>
  10. #include <asm/io.h>
  11. #include <asm/armv7m.h>
  12. #include <asm/arch/stm32.h>
  13. #include <asm/arch/gpio.h>
  14. #include <dm/platdata.h>
  15. #include <dm/platform_data/serial_stm32x7.h>
  16. #include <asm/arch/stm32_periph.h>
  17. #include <asm/arch/stm32_defs.h>
  18. #include <asm/arch/syscfg.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. const struct stm32_gpio_ctl gpio_ctl_gpout = {
  21. .mode = STM32_GPIO_MODE_OUT,
  22. .otype = STM32_GPIO_OTYPE_PP,
  23. .speed = STM32_GPIO_SPEED_50M,
  24. .pupd = STM32_GPIO_PUPD_NO,
  25. .af = STM32_GPIO_AF0
  26. };
  27. static int fmc_setup_gpio(void)
  28. {
  29. clock_setup(GPIO_B_CLOCK_CFG);
  30. clock_setup(GPIO_C_CLOCK_CFG);
  31. clock_setup(GPIO_D_CLOCK_CFG);
  32. clock_setup(GPIO_E_CLOCK_CFG);
  33. clock_setup(GPIO_F_CLOCK_CFG);
  34. clock_setup(GPIO_G_CLOCK_CFG);
  35. clock_setup(GPIO_H_CLOCK_CFG);
  36. return 0;
  37. }
  38. int dram_init(void)
  39. {
  40. struct udevice *dev;
  41. struct ram_info ram;
  42. int rv;
  43. rv = fmc_setup_gpio();
  44. if (rv)
  45. return rv;
  46. clock_setup(FMC_CLOCK_CFG);
  47. rv = uclass_get_device(UCLASS_RAM, 0, &dev);
  48. if (rv) {
  49. debug("DRAM init failed: %d\n", rv);
  50. return rv;
  51. }
  52. rv = ram_get_info(dev, &ram);
  53. if (rv) {
  54. debug("Cannot get DRAM size: %d\n", rv);
  55. return rv;
  56. }
  57. debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
  58. gd->ram_size = ram.size;
  59. /*
  60. * Fill in global info with description of SRAM configuration
  61. */
  62. gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE;
  63. gd->bd->bi_dram[0].size = ram.size;
  64. return rv;
  65. }
  66. int uart_setup_gpio(void)
  67. {
  68. clock_setup(GPIO_A_CLOCK_CFG);
  69. clock_setup(GPIO_B_CLOCK_CFG);
  70. return 0;
  71. }
  72. #ifdef CONFIG_ETH_DESIGNWARE
  73. static int stmmac_setup(void)
  74. {
  75. clock_setup(SYSCFG_CLOCK_CFG);
  76. /* Set >RMII mode */
  77. STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
  78. clock_setup(GPIO_A_CLOCK_CFG);
  79. clock_setup(GPIO_C_CLOCK_CFG);
  80. clock_setup(GPIO_G_CLOCK_CFG);
  81. clock_setup(STMMAC_CLOCK_CFG);
  82. return 0;
  83. }
  84. #endif
  85. #ifdef CONFIG_STM32_QSPI
  86. static int qspi_setup(void)
  87. {
  88. clock_setup(GPIO_B_CLOCK_CFG);
  89. clock_setup(GPIO_D_CLOCK_CFG);
  90. clock_setup(GPIO_E_CLOCK_CFG);
  91. return 0;
  92. }
  93. #endif
  94. u32 get_board_rev(void)
  95. {
  96. return 0;
  97. }
  98. int board_early_init_f(void)
  99. {
  100. int res;
  101. res = uart_setup_gpio();
  102. if (res)
  103. return res;
  104. #ifdef CONFIG_ETH_DESIGNWARE
  105. res = stmmac_setup();
  106. if (res)
  107. return res;
  108. #endif
  109. #ifdef CONFIG_STM32_QSPI
  110. res = qspi_setup();
  111. if (res)
  112. return res;
  113. #endif
  114. return 0;
  115. }
  116. int board_init(void)
  117. {
  118. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  119. return 0;
  120. }