stm32.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * (C) Copyright 2016
  3. * Vikas Manocha, STMicroelectronics, <vikas.manocha@st.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _ASM_ARCH_HARDWARE_H
  8. #define _ASM_ARCH_HARDWARE_H
  9. /* STM32F746 */
  10. #define ITCM_FLASH_BASE 0x00200000UL
  11. #define AXIM_FLASH_BASE 0x08000000UL
  12. #define ITCM_SRAM_BASE 0x00000000UL
  13. #define DTCM_SRAM_BASE 0x20000000UL
  14. #define SRAM1_BASE 0x20010000UL
  15. #define SRAM2_BASE 0x2004C000UL
  16. #define PERIPH_BASE 0x40000000UL
  17. #define APB1_PERIPH_BASE (PERIPH_BASE + 0x00000000)
  18. #define APB2_PERIPH_BASE (PERIPH_BASE + 0x00010000)
  19. #define AHB1_PERIPH_BASE (PERIPH_BASE + 0x00020000)
  20. #define AHB2_PERIPH_BASE (PERIPH_BASE + 0x10000000)
  21. #define AHB3_PERIPH_BASE (PERIPH_BASE + 0x20000000)
  22. #define TIM2_BASE (APB1_PERIPH_BASE + 0x0000)
  23. #define USART2_BASE (APB1_PERIPH_BASE + 0x4400)
  24. #define USART3_BASE (APB1_PERIPH_BASE + 0x4800)
  25. #define PWR_BASE (APB1_PERIPH_BASE + 0x7000)
  26. #define USART1_BASE (APB2_PERIPH_BASE + 0x1000)
  27. #define USART6_BASE (APB2_PERIPH_BASE + 0x1400)
  28. #define STM32_GPIOA_BASE (AHB1_PERIPH_BASE + 0x0000)
  29. #define STM32_GPIOB_BASE (AHB1_PERIPH_BASE + 0x0400)
  30. #define STM32_GPIOC_BASE (AHB1_PERIPH_BASE + 0x0800)
  31. #define STM32_GPIOD_BASE (AHB1_PERIPH_BASE + 0x0C00)
  32. #define STM32_GPIOE_BASE (AHB1_PERIPH_BASE + 0x1000)
  33. #define STM32_GPIOF_BASE (AHB1_PERIPH_BASE + 0x1400)
  34. #define STM32_GPIOG_BASE (AHB1_PERIPH_BASE + 0x1800)
  35. #define STM32_GPIOH_BASE (AHB1_PERIPH_BASE + 0x1C00)
  36. #define STM32_GPIOI_BASE (AHB1_PERIPH_BASE + 0x2000)
  37. #define STM32_GPIOJ_BASE (AHB1_PERIPH_BASE + 0x2400)
  38. #define STM32_GPIOK_BASE (AHB1_PERIPH_BASE + 0x2800)
  39. #define RCC_BASE (AHB1_PERIPH_BASE + 0x3800)
  40. #define FLASH_CNTL_BASE (AHB1_PERIPH_BASE + 0x3C00)
  41. #define SDRAM_FMC_BASE (AHB3_PERIPH_BASE + 0x4A0000140)
  42. static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
  43. [0 ... 3] = 32 * 1024,
  44. [4] = 128 * 1024,
  45. [5 ... 7] = 256 * 1024
  46. };
  47. enum clock {
  48. CLOCK_CORE,
  49. CLOCK_AHB,
  50. CLOCK_APB1,
  51. CLOCK_APB2
  52. };
  53. #define STM32_BUS_MASK 0xFFFF0000
  54. struct stm32_rcc_regs {
  55. u32 cr; /* RCC clock control */
  56. u32 pllcfgr; /* RCC PLL configuration */
  57. u32 cfgr; /* RCC clock configuration */
  58. u32 cir; /* RCC clock interrupt */
  59. u32 ahb1rstr; /* RCC AHB1 peripheral reset */
  60. u32 ahb2rstr; /* RCC AHB2 peripheral reset */
  61. u32 ahb3rstr; /* RCC AHB3 peripheral reset */
  62. u32 rsv0;
  63. u32 apb1rstr; /* RCC APB1 peripheral reset */
  64. u32 apb2rstr; /* RCC APB2 peripheral reset */
  65. u32 rsv1[2];
  66. u32 ahb1enr; /* RCC AHB1 peripheral clock enable */
  67. u32 ahb2enr; /* RCC AHB2 peripheral clock enable */
  68. u32 ahb3enr; /* RCC AHB3 peripheral clock enable */
  69. u32 rsv2;
  70. u32 apb1enr; /* RCC APB1 peripheral clock enable */
  71. u32 apb2enr; /* RCC APB2 peripheral clock enable */
  72. u32 rsv3[2];
  73. u32 ahb1lpenr; /* RCC AHB1 periph clk enable in low pwr mode */
  74. u32 ahb2lpenr; /* RCC AHB2 periph clk enable in low pwr mode */
  75. u32 ahb3lpenr; /* RCC AHB3 periph clk enable in low pwr mode */
  76. u32 rsv4;
  77. u32 apb1lpenr; /* RCC APB1 periph clk enable in low pwr mode */
  78. u32 apb2lpenr; /* RCC APB2 periph clk enable in low pwr mode */
  79. u32 rsv5[2];
  80. u32 bdcr; /* RCC Backup domain control */
  81. u32 csr; /* RCC clock control & status */
  82. u32 rsv6[2];
  83. u32 sscgr; /* RCC spread spectrum clock generation */
  84. u32 plli2scfgr; /* RCC PLLI2S configuration */
  85. u32 pllsaicfgr;
  86. u32 dckcfgr;
  87. };
  88. #define STM32_RCC ((struct stm32_rcc_regs *)RCC_BASE)
  89. struct stm32_pwr_regs {
  90. u32 cr1; /* power control register 1 */
  91. u32 csr1; /* power control/status register 2 */
  92. u32 cr2; /* power control register 2 */
  93. u32 csr2; /* power control/status register 2 */
  94. };
  95. #define STM32_PWR ((struct stm32_pwr_regs *)PWR_BASE)
  96. int configure_clocks(void);
  97. unsigned long clock_get(enum clock clck);
  98. void stm32_flash_latency_cfg(int latency);
  99. #endif /* _ASM_ARCH_HARDWARE_H */