fsl_law.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright 2008-2011 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. #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC
  62. #else
  63. enum law_trgt_if {
  64. LAW_TRGT_IF_PCI = 0x00,
  65. LAW_TRGT_IF_PCI_2 = 0x01,
  66. #ifndef CONFIG_MPC8641
  67. LAW_TRGT_IF_PCIE_1 = 0x02,
  68. #endif
  69. #if !defined(CONFIG_MPC8572) && !defined(CONFIG_P2020)
  70. LAW_TRGT_IF_PCIE_3 = 0x03,
  71. #endif
  72. LAW_TRGT_IF_LBC = 0x04,
  73. LAW_TRGT_IF_CCSR = 0x08,
  74. LAW_TRGT_IF_DDR_INTRLV = 0x0b,
  75. LAW_TRGT_IF_RIO = 0x0c,
  76. LAW_TRGT_IF_RIO_2 = 0x0d,
  77. LAW_TRGT_IF_DPAA_SWP_SRAM = 0x0e,
  78. LAW_TRGT_IF_DDR = 0x0f,
  79. LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */
  80. };
  81. #define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR
  82. #define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI
  83. #define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI
  84. #define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2
  85. #define LAW_TRGT_IF_RIO_1 LAW_TRGT_IF_RIO
  86. #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC
  87. #ifdef CONFIG_MPC8641
  88. #define LAW_TRGT_IF_PCIE_1 LAW_TRGT_IF_PCI
  89. #endif
  90. #if defined(CONFIG_MPC8572) || defined(CONFIG_P2020)
  91. #define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
  92. #endif
  93. #endif /* CONFIG_FSL_CORENET */
  94. struct law_entry {
  95. int index;
  96. phys_addr_t addr;
  97. enum law_size size;
  98. enum law_trgt_if trgt_id;
  99. };
  100. extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  101. extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  102. extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
  103. extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
  104. extern struct law_entry find_law(phys_addr_t addr);
  105. extern void disable_law(u8 idx);
  106. extern void init_laws(void);
  107. extern void print_laws(void);
  108. /* define in board code */
  109. extern struct law_entry law_table[];
  110. extern int num_law_entries;
  111. #endif