init.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright 2015 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <asm/io.h>
  7. #include <asm/arch/imx-regs.h>
  8. #include <asm/arch/clock.h>
  9. #include <asm/arch/sys_proto.h>
  10. #include <asm/imx-common/boot_mode.h>
  11. #include <asm/arch/crm_regs.h>
  12. void init_aips(void)
  13. {
  14. struct aipstz_regs *aips1, *aips2;
  15. #ifdef CONFIG_MX6SX
  16. struct aipstz_regs *aips3;
  17. #endif
  18. aips1 = (struct aipstz_regs *)AIPS1_BASE_ADDR;
  19. aips2 = (struct aipstz_regs *)AIPS2_BASE_ADDR;
  20. #ifdef CONFIG_MX6SX
  21. aips3 = (struct aipstz_regs *)AIPS3_BASE_ADDR;
  22. #endif
  23. /*
  24. * Set all MPROTx to be non-bufferable, trusted for R/W,
  25. * not forced to user-mode.
  26. */
  27. writel(0x77777777, &aips1->mprot0);
  28. writel(0x77777777, &aips1->mprot1);
  29. writel(0x77777777, &aips2->mprot0);
  30. writel(0x77777777, &aips2->mprot1);
  31. /*
  32. * Set all OPACRx to be non-bufferable, not require
  33. * supervisor privilege level for access,allow for
  34. * write access and untrusted master access.
  35. */
  36. writel(0x00000000, &aips1->opacr0);
  37. writel(0x00000000, &aips1->opacr1);
  38. writel(0x00000000, &aips1->opacr2);
  39. writel(0x00000000, &aips1->opacr3);
  40. writel(0x00000000, &aips1->opacr4);
  41. writel(0x00000000, &aips2->opacr0);
  42. writel(0x00000000, &aips2->opacr1);
  43. writel(0x00000000, &aips2->opacr2);
  44. writel(0x00000000, &aips2->opacr3);
  45. writel(0x00000000, &aips2->opacr4);
  46. #ifdef CONFIG_MX6SX
  47. /*
  48. * Set all MPROTx to be non-bufferable, trusted for R/W,
  49. * not forced to user-mode.
  50. */
  51. writel(0x77777777, &aips3->mprot0);
  52. writel(0x77777777, &aips3->mprot1);
  53. /*
  54. * Set all OPACRx to be non-bufferable, not require
  55. * supervisor privilege level for access,allow for
  56. * write access and untrusted master access.
  57. */
  58. writel(0x00000000, &aips3->opacr0);
  59. writel(0x00000000, &aips3->opacr1);
  60. writel(0x00000000, &aips3->opacr2);
  61. writel(0x00000000, &aips3->opacr3);
  62. writel(0x00000000, &aips3->opacr4);
  63. #endif
  64. }
  65. #define SRC_SCR_WARM_RESET_ENABLE 0
  66. void init_src(void)
  67. {
  68. struct src *src_regs = (struct src *)SRC_BASE_ADDR;
  69. u32 val;
  70. /*
  71. * force warm reset sources to generate cold reset
  72. * for a more reliable restart
  73. */
  74. val = readl(&src_regs->scr);
  75. val &= ~(1 << SRC_SCR_WARM_RESET_ENABLE);
  76. writel(val, &src_regs->scr);
  77. }
  78. void boot_mode_apply(unsigned cfg_val)
  79. {
  80. unsigned reg;
  81. struct src *psrc = (struct src *)SRC_BASE_ADDR;
  82. writel(cfg_val, &psrc->gpr9);
  83. reg = readl(&psrc->gpr10);
  84. if (cfg_val)
  85. reg |= 1 << 28;
  86. else
  87. reg &= ~(1 << 28);
  88. writel(reg, &psrc->gpr10);
  89. }