soc.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
  3. * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/armv7m_mpu.h>
  10. int arch_cpu_init(void)
  11. {
  12. int i;
  13. struct mpu_region_config stm32_region_config[] = {
  14. /*
  15. * Make all 4GB cacheable & executable. We are overriding it
  16. * with next region for any requirement. e.g. below region1,
  17. * 2 etc.
  18. * In other words, the area not coming in following
  19. * regions configuration is the one configured here in region_0
  20. * (cacheable & executable).
  21. */
  22. { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
  23. O_I_WB_RD_WR_ALLOC, REGION_4GB },
  24. /* armv7m code area */
  25. { 0x00000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
  26. STRONG_ORDER, REGION_512MB },
  27. /* Device area : Not executable */
  28. { 0x40000000, REGION_2, XN_EN, PRIV_RW_USR_RW,
  29. DEVICE_NON_SHARED, REGION_512MB },
  30. /*
  31. * Armv7m fixed configuration: strongly ordered & not
  32. * executable, not cacheable
  33. */
  34. { 0xE0000000, REGION_3, XN_EN, PRIV_RW_USR_RW,
  35. STRONG_ORDER, REGION_512MB },
  36. #if !defined(CONFIG_STM32H7)
  37. /* Device area : Not executable */
  38. { 0xA0000000, REGION_4, XN_EN, PRIV_RW_USR_RW,
  39. DEVICE_NON_SHARED, REGION_512MB },
  40. #endif
  41. };
  42. disable_mpu();
  43. for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++)
  44. mpu_config(&stm32_region_config[i]);
  45. enable_mpu();
  46. return 0;
  47. }