omap-cache.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. *
  4. * Common functions for OMAP4/5 based boards
  5. *
  6. * (C) Copyright 2010
  7. * Texas Instruments, <www.ti.com>
  8. *
  9. * Author :
  10. * Aneesh V <aneesh@ti.com>
  11. * Steve Sakoman <steve@sakoman.com>
  12. */
  13. #include <common.h>
  14. #include <cpu_func.h>
  15. #include <log.h>
  16. #include <asm/cache.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. /*
  19. * Without LPAE short descriptors are used
  20. * Set C - Cache Bit3
  21. * Set B - Buffer Bit2
  22. * The last 2 bits set to 0b10
  23. * Do Not set XN bit4
  24. * So value is 0xe
  25. *
  26. * With LPAE cache configuration happens via MAIR0 register
  27. * AttrIndx value is 0x3 for picking byte3 for MAIR0 which has 0xFF.
  28. * 0xFF maps to Cache writeback with Read and Write Allocate set
  29. * The bits[1:0] should have the value 0b01 for the first level
  30. * descriptor.
  31. * So the value is 0xd
  32. */
  33. #ifdef CONFIG_ARMV7_LPAE
  34. #define ARMV7_DCACHE_POLICY DCACHE_WRITEALLOC
  35. #else
  36. #define ARMV7_DCACHE_POLICY DCACHE_WRITEBACK & ~TTB_SECT_XN_MASK
  37. #endif
  38. #define ARMV7_DOMAIN_CLIENT 1
  39. #define ARMV7_DOMAIN_MASK (0x3 << 0)
  40. void enable_caches(void)
  41. {
  42. /* Enable I cache if not enabled */
  43. if (!icache_status())
  44. icache_enable();
  45. dcache_enable();
  46. }
  47. void dram_bank_mmu_setup(int bank)
  48. {
  49. struct bd_info *bd = gd->bd;
  50. int i;
  51. u32 start = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
  52. u32 size = bd->bi_dram[bank].size >> MMU_SECTION_SHIFT;
  53. u32 end = start + size;
  54. debug("%s: bank: %d\n", __func__, bank);
  55. for (i = start; i < end; i++)
  56. set_section_dcache(i, ARMV7_DCACHE_POLICY);
  57. }
  58. void arm_init_domains(void)
  59. {
  60. u32 reg;
  61. reg = get_dacr();
  62. /*
  63. * Set DOMAIN to client access so that all permissions
  64. * set in pagetables are validated by the mmu.
  65. */
  66. reg &= ~ARMV7_DOMAIN_MASK;
  67. reg |= ARMV7_DOMAIN_CLIENT;
  68. set_dacr(reg);
  69. }