1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2008-2011 Freescale Semiconductor, Inc.
10 #include <linux/log2.h>
12 #define LAW_EN 0x80000000
14 #define SET_LAW_ENTRY(idx, a, sz, trgt) \
15 { .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
17 #define SET_LAW(a, sz, trgt) \
18 { .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
47 #define law_size_bits(sz) (__ilog2_u64(sz) - 1)
48 #define lawar_size(x) (1ULL << ((x & 0x3f) + 1))
50 #ifdef CONFIG_FSL_CORENET
52 LAW_TRGT_IF_PCIE_1 = 0x00,
53 LAW_TRGT_IF_PCIE_2 = 0x01,
54 LAW_TRGT_IF_PCIE_3 = 0x02,
55 LAW_TRGT_IF_PCIE_4 = 0x03,
56 LAW_TRGT_IF_RIO_1 = 0x08,
57 LAW_TRGT_IF_RIO_2 = 0x09,
59 LAW_TRGT_IF_DDR_1 = 0x10,
60 LAW_TRGT_IF_DDR_2 = 0x11, /* 2nd controller */
61 LAW_TRGT_IF_DDR_3 = 0x12,
62 LAW_TRGT_IF_DDR_4 = 0x13,
63 LAW_TRGT_IF_DDR_INTRLV = 0x14,
64 LAW_TRGT_IF_DDR_INTLV_34 = 0x15,
65 LAW_TRGT_IF_DDR_INTLV_123 = 0x17,
66 LAW_TRGT_IF_DDR_INTLV_1234 = 0x16,
67 LAW_TRGT_IF_BMAN = 0x18,
68 LAW_TRGT_IF_DCSR = 0x1d,
69 LAW_TRGT_IF_CCSR = 0x1e,
70 LAW_TRGT_IF_LBC = 0x1f,
71 LAW_TRGT_IF_QMAN = 0x3c,
73 LAW_TRGT_IF_MAPLE = 0x50,
75 #define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1
76 #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC
79 LAW_TRGT_IF_PCI = 0x00,
80 LAW_TRGT_IF_PCI_2 = 0x01,
81 LAW_TRGT_IF_PCIE_1 = 0x02,
82 #if defined(CONFIG_ARCH_BSC9131) || defined(CONFIG_ARCH_BSC9132)
83 LAW_TRGT_IF_OCN_DSP = 0x03,
85 #if !defined(CONFIG_ARCH_P2020)
86 LAW_TRGT_IF_PCIE_3 = 0x03,
89 LAW_TRGT_IF_LBC = 0x04,
90 LAW_TRGT_IF_CCSR = 0x08,
91 LAW_TRGT_IF_DSP_CCSR = 0x09,
92 LAW_TRGT_IF_PLATFORM_SRAM = 0x0a,
93 LAW_TRGT_IF_DDR_INTRLV = 0x0b,
94 LAW_TRGT_IF_RIO = 0x0c,
95 #if defined(CONFIG_ARCH_BSC9132)
96 LAW_TRGT_IF_CLASS_DSP = 0x0d,
98 LAW_TRGT_IF_RIO_2 = 0x0d,
100 LAW_TRGT_IF_DPAA_SWP_SRAM = 0x0e,
101 LAW_TRGT_IF_DDR = 0x0f,
102 LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */
103 /* place holder for 3-way and 4-way interleaving */
106 LAW_TRGT_IF_DDR_INTLV_34,
107 LAW_TRGT_IF_DDR_INTLV_123,
108 LAW_TRGT_IF_DDR_INTLV_1234,
110 #define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR
111 #define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI
112 #define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI
113 #define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2
114 #define LAW_TRGT_IF_RIO_1 LAW_TRGT_IF_RIO
115 #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC
117 #if defined(CONFIG_ARCH_P2020)
118 #define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
120 #endif /* CONFIG_FSL_CORENET */
126 enum law_trgt_if trgt_id;
129 extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
130 extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
131 extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
132 extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
133 extern struct law_entry find_law(phys_addr_t addr);
134 extern void disable_law(u8 idx);
135 extern void init_laws(void);
136 extern void print_laws(void);
138 /* define in board code */
139 extern struct law_entry law_table[];
140 extern int num_law_entries;