2 * Copyright (c) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef _ASM_ARCH_MRCCACHE_H
8 #define _ASM_ARCH_MRCCACHE_H
10 #define MRC_DATA_ALIGN 0x1000
11 #define MRC_DATA_SIGNATURE (('M' << 0) | ('R' << 8) | ('C' << 16) | \
14 __packed struct mrc_data_container {
15 u32 signature; /* "MRCD" */
16 u32 data_size; /* Size of the 'data' field */
17 u32 checksum; /* IP style checksum */
18 u32 reserved; /* For header alignment */
19 u8 data[0]; /* Variable size, platform/run time dependent */
26 * mrccache_find_current() - find the latest MRC cache record
28 * This searches the MRC cache region looking for the latest record to use
29 * for setting up SDRAM
31 * @entry: Information about the position and size of the MRC cache
32 * @return pointer to latest record, or NULL if none
34 struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry);
37 * mrccache_update() - update the MRC cache with a new record
39 * This writes a new record to the end of the MRC cache. If the new record is
40 * the same as the latest record then the write is skipped
42 * @sf: SPI flash to write to
43 * @entry: Position and size of MRC cache in SPI flash
44 * @cur: Record to write
45 * @return 0 if updated, -EEXIST if the record is the same as the latest
46 * record, other error if SPI write failed
48 int mrccache_update(struct spi_flash *sf, struct fmap_entry *entry,
49 struct mrc_data_container *cur);