cplbinit.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Blackfin CPLB initialization
  3. *
  4. * Copyright 2008-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/module.h>
  9. #include <asm/blackfin.h>
  10. #include <asm/cplb.h>
  11. #include <asm/cplbinit.h>
  12. #include <asm/mem_map.h>
  13. struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS];
  14. struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS];
  15. int first_switched_icplb, first_switched_dcplb;
  16. int first_mask_dcplb;
  17. void __init generate_cplb_tables_cpu(unsigned int cpu)
  18. {
  19. int i_d, i_i;
  20. unsigned long addr;
  21. unsigned long d_data, i_data;
  22. unsigned long d_cache = 0, i_cache = 0;
  23. printk(KERN_INFO "MPU: setting up cplb tables with memory protection\n");
  24. #ifdef CONFIG_BFIN_EXTMEM_ICACHEABLE
  25. i_cache = CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
  26. #endif
  27. #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
  28. d_cache = CPLB_L1_CHBL;
  29. #ifdef CONFIG_BFIN_EXTMEM_WRITETHROUGH
  30. d_cache |= CPLB_L1_AOW | CPLB_WT;
  31. #endif
  32. #endif
  33. i_d = i_i = 0;
  34. /* Set up the zero page. */
  35. dcplb_tbl[cpu][i_d].addr = 0;
  36. dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
  37. icplb_tbl[cpu][i_i].addr = 0;
  38. icplb_tbl[cpu][i_i++].data = CPLB_VALID | i_cache | CPLB_USER_RD | PAGE_SIZE_1KB;
  39. /* Cover kernel memory with 4M pages. */
  40. addr = 0;
  41. d_data = d_cache | CPLB_SUPV_WR | CPLB_VALID | PAGE_SIZE_4MB | CPLB_DIRTY;
  42. i_data = i_cache | CPLB_VALID | CPLB_PORTPRIO | PAGE_SIZE_4MB;
  43. for (; addr < memory_start; addr += 4 * 1024 * 1024) {
  44. dcplb_tbl[cpu][i_d].addr = addr;
  45. dcplb_tbl[cpu][i_d++].data = d_data;
  46. icplb_tbl[cpu][i_i].addr = addr;
  47. icplb_tbl[cpu][i_i++].data = i_data | (addr == 0 ? CPLB_USER_RD : 0);
  48. }
  49. #ifdef CONFIG_ROMKERNEL
  50. /* Cover kernel XIP flash area */
  51. addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1);
  52. dcplb_tbl[cpu][i_d].addr = addr;
  53. dcplb_tbl[cpu][i_d++].data = d_data | CPLB_USER_RD;
  54. icplb_tbl[cpu][i_i].addr = addr;
  55. icplb_tbl[cpu][i_i++].data = i_data | CPLB_USER_RD;
  56. #endif
  57. /* Cover L1 memory. One 4M area for code and data each is enough. */
  58. #if L1_DATA_A_LENGTH > 0 || L1_DATA_B_LENGTH > 0
  59. dcplb_tbl[cpu][i_d].addr = get_l1_data_a_start_cpu(cpu);
  60. dcplb_tbl[cpu][i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  61. #endif
  62. #if L1_CODE_LENGTH > 0
  63. icplb_tbl[cpu][i_i].addr = get_l1_code_start_cpu(cpu);
  64. icplb_tbl[cpu][i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  65. #endif
  66. /* Cover L2 memory */
  67. #if L2_LENGTH > 0
  68. dcplb_tbl[cpu][i_d].addr = L2_START;
  69. dcplb_tbl[cpu][i_d++].data = L2_DMEMORY;
  70. icplb_tbl[cpu][i_i].addr = L2_START;
  71. icplb_tbl[cpu][i_i++].data = L2_IMEMORY;
  72. #endif
  73. first_mask_dcplb = i_d;
  74. first_switched_dcplb = i_d + (1 << page_mask_order);
  75. first_switched_icplb = i_i;
  76. while (i_d < MAX_CPLBS)
  77. dcplb_tbl[cpu][i_d++].data = 0;
  78. while (i_i < MAX_CPLBS)
  79. icplb_tbl[cpu][i_i++].data = 0;
  80. }
  81. void __init generate_cplb_tables_all(void)
  82. {
  83. }