Lines Matching +full:cache +full:-

7  * SPDX-License-Identifier:	GPL-2.0
22 struct mrc_data_container *cache) in next_mrc_block() argument
25 u32 mrc_size = sizeof(*cache) + cache->data_size; in next_mrc_block()
26 u8 *region_ptr = (u8 *)cache; in next_mrc_block()
28 if (mrc_size & (MRC_DATA_ALIGN - 1UL)) { in next_mrc_block()
29 mrc_size &= ~(MRC_DATA_ALIGN - 1UL); in next_mrc_block()
38 static int is_mrc_cache(struct mrc_data_container *cache) in is_mrc_cache() argument
40 return cache && (cache->signature == MRC_DATA_SIGNATURE); in is_mrc_cache()
45 struct mrc_data_container *cache, *next; in mrccache_find_current() local
49 base_addr = entry->base + entry->offset; in mrccache_find_current()
50 end_addr = base_addr + entry->length; in mrccache_find_current()
51 cache = NULL; in mrccache_find_current()
57 cache = next; in mrccache_find_current()
63 if (id-- == 0) { in mrccache_find_current()
64 debug("%s: No valid MRC cache found.\n", __func__); in mrccache_find_current()
69 if (cache->checksum != compute_ip_checksum(cache->data, in mrccache_find_current()
70 cache->data_size)) { in mrccache_find_current()
71 printf("%s: MRC cache checksum mismatch\n", __func__); in mrccache_find_current()
75 debug("%s: picked entry %u from cache block\n", __func__, id); in mrccache_find_current()
77 return cache; in mrccache_find_current()
81 * find_next_mrc_cache() - get next cache entry
83 * @entry: MRC cache flash area
84 * @cache: Entry to start from
86 * @return next cache entry if found, NULL if we got to the end
89 struct mrc_data_container *cache) in find_next_mrc_cache() argument
93 base_addr = entry->base + entry->offset; in find_next_mrc_cache()
94 end_addr = base_addr + entry->length; in find_next_mrc_cache()
96 cache = next_mrc_block(cache); in find_next_mrc_cache()
97 if ((ulong)cache >= end_addr) { in find_next_mrc_cache()
99 cache = NULL; in find_next_mrc_cache()
102 debug("%s: picked next entry from cache block at %p\n", in find_next_mrc_cache()
103 __func__, cache); in find_next_mrc_cache()
106 return cache; in find_next_mrc_cache()
112 struct mrc_data_container *cache; in mrccache_update() local
118 return -EINVAL; in mrccache_update()
121 base_addr = entry->base + entry->offset; in mrccache_update()
122 debug("Updating MRC cache data\n"); in mrccache_update()
123 cache = mrccache_find_current(entry); in mrccache_update()
124 if (cache && (cache->data_size == cur->data_size) && in mrccache_update()
125 (!memcmp(cache, cur, cache->data_size + sizeof(*cur)))) { in mrccache_update()
127 return -EEXIST; in mrccache_update()
131 if (cache) in mrccache_update()
132 cache = find_next_mrc_cache(entry, cache); in mrccache_update()
135 * If we have got to the end, erase the entire mrc-cache area and start in mrccache_update()
138 if (!cache) { in mrccache_update()
139 debug("Erasing the MRC cache region of %x bytes at %x\n", in mrccache_update()
140 entry->length, entry->offset); in mrccache_update()
142 ret = spi_flash_erase_dm(sf, entry->offset, entry->length); in mrccache_update()
147 cache = (struct mrc_data_container *)base_addr; in mrccache_update()
151 offset = (ulong)cache - base_addr + entry->offset; in mrccache_update()
152 debug("Write MRC cache update to flash at %lx\n", offset); in mrccache_update()
153 ret = spi_flash_write_dm(sf, offset, cur->data_size + sizeof(*cur), in mrccache_update()
165 struct mrc_data_container *cache; in mrccache_reserve() local
168 if (!gd->arch.mrc_output_len) in mrccache_reserve()
171 /* adjust stack pointer to store pure cache data plus the header */ in mrccache_reserve()
172 gd->start_addr_sp -= (gd->arch.mrc_output_len + MRC_DATA_HEADER_SIZE); in mrccache_reserve()
173 cache = (struct mrc_data_container *)gd->start_addr_sp; in mrccache_reserve()
175 cache->signature = MRC_DATA_SIGNATURE; in mrccache_reserve()
176 cache->data_size = gd->arch.mrc_output_len; in mrccache_reserve()
177 checksum = compute_ip_checksum(gd->arch.mrc_output, cache->data_size); in mrccache_reserve()
179 cache->data_size, checksum); in mrccache_reserve()
180 cache->checksum = checksum; in mrccache_reserve()
181 cache->reserved = 0; in mrccache_reserve()
182 memcpy(cache->data, gd->arch.mrc_output, cache->data_size); in mrccache_reserve()
184 /* gd->arch.mrc_output now points to the container */ in mrccache_reserve()
185 gd->arch.mrc_output = (char *)cache; in mrccache_reserve()
187 gd->start_addr_sp &= ~0xf; in mrccache_reserve()
194 const void *blob = gd->fdt_blob; in mrccache_get_region()
203 return -ENOENT; in mrccache_get_region()
206 if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2)) in mrccache_get_region()
207 return -EINVAL; in mrccache_get_region()
208 entry->base = reg[0]; in mrccache_get_region()
210 /* Find the place where we put the MRC cache */ in mrccache_get_region()
211 mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache"); in mrccache_get_region()
213 return -EPERM; in mrccache_get_region()
216 return -EINVAL; in mrccache_get_region()
217 entry->offset = reg[0]; in mrccache_get_region()
218 entry->length = reg[1]; in mrccache_get_region()
238 if (!gd->arch.mrc_output_len) in mrccache_save()
241 gd->arch.mrc_output_len); in mrccache_save()
246 data = (struct mrc_data_container *)gd->arch.mrc_output; in mrccache_save()
249 debug("Saved MRC data with checksum %04x\n", data->checksum); in mrccache_save()
250 } else if (ret == -EEXIST) { in mrccache_save()