fsl_law.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright 2008-2010 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * Version 2 as published by the Free Software Foundation.
  7. */
  8. #ifndef _FSL_LAW_H_
  9. #define _FSL_LAW_H_
  10. #include <asm/io.h>
  11. #define LAW_EN 0x80000000
  12. #define SET_LAW_ENTRY(idx, a, sz, trgt) \
  13. { .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
  14. #define SET_LAW(a, sz, trgt) \
  15. { .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
  16. enum law_size {
  17. LAW_SIZE_4K = 0xb,
  18. LAW_SIZE_8K,
  19. LAW_SIZE_16K,
  20. LAW_SIZE_32K,
  21. LAW_SIZE_64K,
  22. LAW_SIZE_128K,
  23. LAW_SIZE_256K,
  24. LAW_SIZE_512K,
  25. LAW_SIZE_1M,
  26. LAW_SIZE_2M,
  27. LAW_SIZE_4M,
  28. LAW_SIZE_8M,
  29. LAW_SIZE_16M,
  30. LAW_SIZE_32M,
  31. LAW_SIZE_64M,
  32. LAW_SIZE_128M,
  33. LAW_SIZE_256M,
  34. LAW_SIZE_512M,
  35. LAW_SIZE_1G,
  36. LAW_SIZE_2G,
  37. LAW_SIZE_4G,
  38. LAW_SIZE_8G,
  39. LAW_SIZE_16G,
  40. LAW_SIZE_32G,
  41. };
  42. #define law_size_bits(sz) (__ilog2_u64(sz) - 1)
  43. #define lawar_size(x) (1ULL << ((x & 0x3f) + 1))
  44. #ifdef CONFIG_FSL_CORENET
  45. enum law_trgt_if {
  46. LAW_TRGT_IF_PCIE_1 = 0x00,
  47. LAW_TRGT_IF_PCIE_2 = 0x01,
  48. LAW_TRGT_IF_PCIE_3 = 0x02,
  49. LAW_TRGT_IF_PCIE_4 = 0x03,
  50. LAW_TRGT_IF_RIO_1 = 0x08,
  51. LAW_TRGT_IF_RIO_2 = 0x09,
  52. LAW_TRGT_IF_DDR_1 = 0x10,
  53. LAW_TRGT_IF_DDR_2 = 0x11, /* 2nd controller */
  54. LAW_TRGT_IF_DDR_INTRLV = 0x14,
  55. LAW_TRGT_IF_BMAN = 0x18,
  56. LAW_TRGT_IF_DCSR = 0x1d,
  57. LAW_TRGT_IF_LBC = 0x1f,
  58. LAW_TRGT_IF_QMAN = 0x3c,
  59. };
  60. #define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1
  61. #else
  62. enum law_trgt_if {
  63. LAW_TRGT_IF_PCI = 0x00,
  64. LAW_TRGT_IF_PCI_2 = 0x01,
  65. #ifndef CONFIG_MPC8641
  66. LAW_TRGT_IF_PCIE_1 = 0x02,
  67. #endif
  68. #if !defined(CONFIG_MPC8572) && !defined(CONFIG_P2020)
  69. LAW_TRGT_IF_PCIE_3 = 0x03,
  70. #endif
  71. LAW_TRGT_IF_LBC = 0x04,
  72. LAW_TRGT_IF_CCSR = 0x08,
  73. LAW_TRGT_IF_DDR_INTRLV = 0x0b,
  74. LAW_TRGT_IF_RIO = 0x0c,
  75. LAW_TRGT_IF_RIO_2 = 0x0d,
  76. LAW_TRGT_IF_DDR = 0x0f,
  77. LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */
  78. };
  79. #define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR
  80. #define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI
  81. #define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI
  82. #define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2
  83. #ifdef CONFIG_MPC8641
  84. #define LAW_TRGT_IF_PCIE_1 LAW_TRGT_IF_PCI
  85. #endif
  86. #if defined(CONFIG_MPC8572) || defined(CONFIG_P2020)
  87. #define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
  88. #endif
  89. #endif /* CONFIG_FSL_CORENET */
  90. struct law_entry {
  91. int index;
  92. phys_addr_t addr;
  93. enum law_size size;
  94. enum law_trgt_if trgt_id;
  95. };
  96. extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  97. extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  98. extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  99. extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
  100. extern struct law_entry find_law(phys_addr_t addr);
  101. extern void disable_law(u8 idx);
  102. extern void init_laws(void);
  103. extern void print_laws(void);
  104. /* define in board code */
  105. extern struct law_entry law_table[];
  106. extern int num_law_entries;
  107. #endif