xref: /openbmc/u-boot/arch/x86/include/asm/mrccache.h (revision bfa95c53)
1f6220f1aSBin Meng /*
2*bfa95c53SBin Meng  * Copyright (C) 2014 Google, Inc
3f6220f1aSBin Meng  *
4f6220f1aSBin Meng  * SPDX-License-Identifier:	GPL-2.0+
5f6220f1aSBin Meng  */
6f6220f1aSBin Meng 
7*bfa95c53SBin Meng #ifndef _ASM_MRCCACHE_H
8*bfa95c53SBin Meng #define _ASM_MRCCACHE_H
9f6220f1aSBin Meng 
10f6220f1aSBin Meng #define MRC_DATA_ALIGN		0x1000
11*bfa95c53SBin Meng #define MRC_DATA_SIGNATURE	(('M' << 0) | ('R' << 8) | \
12*bfa95c53SBin Meng 				 ('C' << 16) | ('D'<<24))
13f6220f1aSBin Meng 
14*bfa95c53SBin Meng struct __packed mrc_data_container {
15f6220f1aSBin Meng 	u32	signature;	/* "MRCD" */
16f6220f1aSBin Meng 	u32	data_size;	/* Size of the 'data' field */
17f6220f1aSBin Meng 	u32	checksum;	/* IP style checksum */
18f6220f1aSBin Meng 	u32	reserved;	/* For header alignment */
19f6220f1aSBin Meng 	u8	data[0];	/* Variable size, platform/run time dependent */
20f6220f1aSBin Meng };
21f6220f1aSBin Meng 
22f6220f1aSBin Meng struct fmap_entry;
23f6220f1aSBin Meng struct udevice;
24f6220f1aSBin Meng 
25f6220f1aSBin Meng /**
26f6220f1aSBin Meng  * mrccache_find_current() - find the latest MRC cache record
27f6220f1aSBin Meng  *
28f6220f1aSBin Meng  * This searches the MRC cache region looking for the latest record to use
29f6220f1aSBin Meng  * for setting up SDRAM
30f6220f1aSBin Meng  *
31*bfa95c53SBin Meng  * @entry:	Position and size of MRC cache in SPI flash
32f6220f1aSBin Meng  * @return pointer to latest record, or NULL if none
33f6220f1aSBin Meng  */
34f6220f1aSBin Meng struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry);
35f6220f1aSBin Meng 
36f6220f1aSBin Meng /**
37f6220f1aSBin Meng  * mrccache_update() - update the MRC cache with a new record
38f6220f1aSBin Meng  *
39*bfa95c53SBin Meng  * This writes a new record to the end of the MRC cache region. If the new
40*bfa95c53SBin Meng  * record is the same as the latest record then the write is skipped
41f6220f1aSBin Meng  *
42f6220f1aSBin Meng  * @sf:		SPI flash to write to
43f6220f1aSBin Meng  * @entry:	Position and size of MRC cache in SPI flash
44f6220f1aSBin Meng  * @cur:	Record to write
45f6220f1aSBin Meng  * @return 0 if updated, -EEXIST if the record is the same as the latest
462fe66dbcSBin Meng  * record, -EINVAL if the record is not valid, other error if SPI write failed
47f6220f1aSBin Meng  */
48f6220f1aSBin Meng int mrccache_update(struct udevice *sf, struct fmap_entry *entry,
49f6220f1aSBin Meng 		    struct mrc_data_container *cur);
50f6220f1aSBin Meng 
51*bfa95c53SBin Meng #endif /* _ASM_MRCCACHE_H */
52