| .. | .. |
|---|
| 97 | 97 | /* signal transactions for FBPRs with higher priority */ |
|---|
| 98 | 98 | #define FBPR_AR_RPRIO_HI BIT(30) |
|---|
| 99 | 99 | |
|---|
| 100 | | -static void bm_set_memory(u64 ba, u32 size) |
|---|
| 100 | +/* Track if probe has occurred and if cleanup is required */ |
|---|
| 101 | +static int __bman_probed; |
|---|
| 102 | +static int __bman_requires_cleanup; |
|---|
| 103 | + |
|---|
| 104 | + |
|---|
| 105 | +static int bm_set_memory(u64 ba, u32 size) |
|---|
| 101 | 106 | { |
|---|
| 107 | + u32 bar, bare; |
|---|
| 102 | 108 | u32 exp = ilog2(size); |
|---|
| 103 | 109 | /* choke if size isn't within range */ |
|---|
| 104 | 110 | DPAA_ASSERT(size >= 4096 && size <= 1024*1024*1024 && |
|---|
| 105 | 111 | is_power_of_2(size)); |
|---|
| 106 | 112 | /* choke if '[e]ba' has lower-alignment than 'size' */ |
|---|
| 107 | 113 | DPAA_ASSERT(!(ba & (size - 1))); |
|---|
| 114 | + |
|---|
| 115 | + /* Check to see if BMan has already been initialized */ |
|---|
| 116 | + bar = bm_ccsr_in(REG_FBPR_BAR); |
|---|
| 117 | + if (bar) { |
|---|
| 118 | + /* Maker sure ba == what was programmed) */ |
|---|
| 119 | + bare = bm_ccsr_in(REG_FBPR_BARE); |
|---|
| 120 | + if (bare != upper_32_bits(ba) || bar != lower_32_bits(ba)) { |
|---|
| 121 | + pr_err("Attempted to reinitialize BMan with different BAR, got 0x%llx read BARE=0x%x BAR=0x%x\n", |
|---|
| 122 | + ba, bare, bar); |
|---|
| 123 | + return -ENOMEM; |
|---|
| 124 | + } |
|---|
| 125 | + pr_info("BMan BAR already configured\n"); |
|---|
| 126 | + __bman_requires_cleanup = 1; |
|---|
| 127 | + return 1; |
|---|
| 128 | + } |
|---|
| 129 | + |
|---|
| 108 | 130 | bm_ccsr_out(REG_FBPR_BARE, upper_32_bits(ba)); |
|---|
| 109 | 131 | bm_ccsr_out(REG_FBPR_BAR, lower_32_bits(ba)); |
|---|
| 110 | 132 | bm_ccsr_out(REG_FBPR_AR, exp - 1); |
|---|
| 133 | + return 0; |
|---|
| 111 | 134 | } |
|---|
| 112 | 135 | |
|---|
| 113 | 136 | /* |
|---|
| .. | .. |
|---|
| 120 | 143 | */ |
|---|
| 121 | 144 | static dma_addr_t fbpr_a; |
|---|
| 122 | 145 | static size_t fbpr_sz; |
|---|
| 123 | | -static int __bman_probed; |
|---|
| 124 | 146 | |
|---|
| 125 | 147 | static int bman_fbpr(struct reserved_mem *rmem) |
|---|
| 126 | 148 | { |
|---|
| .. | .. |
|---|
| 173 | 195 | } |
|---|
| 174 | 196 | EXPORT_SYMBOL_GPL(bman_is_probed); |
|---|
| 175 | 197 | |
|---|
| 198 | +int bman_requires_cleanup(void) |
|---|
| 199 | +{ |
|---|
| 200 | + return __bman_requires_cleanup; |
|---|
| 201 | +} |
|---|
| 202 | + |
|---|
| 203 | +void bman_done_cleanup(void) |
|---|
| 204 | +{ |
|---|
| 205 | + __bman_requires_cleanup = 0; |
|---|
| 206 | +} |
|---|
| 207 | + |
|---|
| 176 | 208 | static int fsl_bman_probe(struct platform_device *pdev) |
|---|
| 177 | 209 | { |
|---|
| 178 | 210 | int ret, err_irq; |
|---|