omap-cache.c 1.9 KB

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