1f6220f1aSBin Meng /* 2f6220f1aSBin Meng * Copyright (c) 2014 Google, Inc 3f6220f1aSBin Meng * 4f6220f1aSBin Meng * SPDX-License-Identifier: GPL-2.0+ 5f6220f1aSBin Meng */ 6f6220f1aSBin Meng 7f6220f1aSBin Meng #ifndef _ASM_ARCH_MRCCACHE_H 8f6220f1aSBin Meng #define _ASM_ARCH_MRCCACHE_H 9f6220f1aSBin Meng 10f6220f1aSBin Meng #define MRC_DATA_ALIGN 0x1000 11f6220f1aSBin Meng #define MRC_DATA_SIGNATURE (('M' << 0) | ('R' << 8) | ('C' << 16) | \ 12f6220f1aSBin Meng ('D'<<24)) 13f6220f1aSBin Meng 14f6220f1aSBin Meng __packed struct 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 * 31f6220f1aSBin Meng * @entry: Information about the position and size of the MRC cache 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 * 39f6220f1aSBin Meng * This writes a new record to the end of the MRC cache. If the new record is 40f6220f1aSBin Meng * 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 46*2fe66dbcSBin 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 51f6220f1aSBin Meng #endif 52