stm32f746-disco.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. rv = uclass_get_device(UCLASS_RAM, 0, &dev);
  47. if (rv) {
  48. debug("DRAM init failed: %d\n", rv);
  49. return rv;
  50. }
  51. rv = ram_get_info(dev, &ram);
  52. if (rv) {
  53. debug("Cannot get DRAM size: %d\n", rv);
  54. return rv;
  55. }
  56. debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
  57. gd->ram_size = ram.size;
  58. /*
  59. * Fill in global info with description of SRAM configuration
  60. */
  61. gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE;
  62. gd->bd->bi_dram[0].size = ram.size;
  63. return rv;
  64. }
  65. int uart_setup_gpio(void)
  66. {
  67. clock_setup(GPIO_A_CLOCK_CFG);
  68. clock_setup(GPIO_B_CLOCK_CFG);
  69. return 0;
  70. }
  71. #ifdef CONFIG_ETH_DESIGNWARE
  72. static int stmmac_setup(void)
  73. {
  74. clock_setup(SYSCFG_CLOCK_CFG);
  75. /* Set >RMII mode */
  76. STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
  77. clock_setup(GPIO_A_CLOCK_CFG);
  78. clock_setup(GPIO_C_CLOCK_CFG);
  79. clock_setup(GPIO_G_CLOCK_CFG);
  80. clock_setup(STMMAC_CLOCK_CFG);
  81. return 0;
  82. }
  83. #endif
  84. #ifdef CONFIG_STM32_QSPI
  85. static int qspi_setup(void)
  86. {
  87. clock_setup(GPIO_B_CLOCK_CFG);
  88. clock_setup(GPIO_D_CLOCK_CFG);
  89. clock_setup(GPIO_E_CLOCK_CFG);
  90. return 0;
  91. }
  92. #endif
  93. u32 get_board_rev(void)
  94. {
  95. return 0;
  96. }
  97. int board_early_init_f(void)
  98. {
  99. int res;
  100. res = uart_setup_gpio();
  101. if (res)
  102. return res;
  103. #ifdef CONFIG_ETH_DESIGNWARE
  104. res = stmmac_setup();
  105. if (res)
  106. return res;
  107. #endif
  108. #ifdef CONFIG_STM32_QSPI
  109. res = qspi_setup();
  110. if (res)
  111. return res;
  112. #endif
  113. return 0;
  114. }
  115. int board_init(void)
  116. {
  117. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  118. return 0;
  119. }