omap-cache.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <asm/cache.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. /*
  17. * Without LPAE short descriptors are used
  18. * Set C - Cache Bit3
  19. * Set B - Buffer Bit2
  20. * The last 2 bits set to 0b10
  21. * Do Not set XN bit4
  22. * So value is 0xe
  23. *
  24. * With LPAE cache configuration happens via MAIR0 register
  25. * AttrIndx value is 0x3 for picking byte3 for MAIR0 which has 0xFF.
  26. * 0xFF maps to Cache writeback with Read and Write Allocate set
  27. * The bits[1:0] should have the value 0b01 for the first level
  28. * descriptor.
  29. * So the value is 0xd
  30. */
  31. #ifdef CONFIG_ARMV7_LPAE
  32. #define ARMV7_DCACHE_POLICY DCACHE_WRITEALLOC
  33. #else
  34. #define ARMV7_DCACHE_POLICY DCACHE_WRITEBACK & ~TTB_SECT_XN_MASK
  35. #endif
  36. #define ARMV7_DOMAIN_CLIENT 1
  37. #define ARMV7_DOMAIN_MASK (0x3 << 0)
  38. void enable_caches(void)
  39. {
  40. /* Enable I cache if not enabled */
  41. if (!icache_status())
  42. icache_enable();
  43. dcache_enable();
  44. }
  45. void dram_bank_mmu_setup(int bank)
  46. {
  47. bd_t *bd = gd->bd;
  48. int i;
  49. u32 start = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
  50. u32 size = bd->bi_dram[bank].size >> MMU_SECTION_SHIFT;
  51. u32 end = start + size;
  52. debug("%s: bank: %d\n", __func__, bank);
  53. for (i = start; i < end; i++)
  54. set_section_dcache(i, ARMV7_DCACHE_POLICY);
  55. }
  56. void arm_init_domains(void)
  57. {
  58. u32 reg;
  59. reg = get_dacr();
  60. /*
  61. * Set DOMAIN to client access so that all permissions
  62. * set in pagetables are validated by the mmu.
  63. */
  64. reg &= ~ARMV7_DOMAIN_MASK;
  65. reg |= ARMV7_DOMAIN_CLIENT;
  66. set_dacr(reg);
  67. }