1 /*
2  * (C) Copyright 2013
3  * Corscience GmbH & Co. KG, <www.corscience.de>
4  * Andreas Bießmann <andreas.biessmann@corscience.de>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 #ifndef TRICORDER_EEPROM_H_
9 #define TRICORDER_EEPROM_H_
10 
11 #include <linux/compiler.h>
12 
13 #define TRICORDER_EEPROM_MAGIC 0xc2a94f52
14 #define TRICORDER_EEPROM_VERSION 1
15 
16 #define TRICORDER_BOARD_NAME_LENGTH		12
17 #define TRICORDER_BOARD_VERSION_LENGTH		4
18 #define TRICORDER_BOARD_SERIAL_LENGTH		12
19 #define TRICORDER_INTERFACE_VERSION_LENGTH	4
20 
21 struct tricorder_eeprom {
22 	uint32_t magic;
23 	uint16_t length;
24 	uint16_t version;
25 	char board_name[TRICORDER_BOARD_NAME_LENGTH];
26 	char board_version[TRICORDER_BOARD_VERSION_LENGTH];
27 	char board_serial[TRICORDER_BOARD_SERIAL_LENGTH];
28 	char interface_version[TRICORDER_INTERFACE_VERSION_LENGTH];
29 	uint32_t crc32;
30 } __packed;
31 
32 #define TRICORDER_EEPROM_SIZE		sizeof(struct tricorder_eeprom)
33 #define TRICORDER_EEPROM_CRC_SIZE	(TRICORDER_EEPROM_SIZE - \
34 					 sizeof(uint32_t))
35 
36 /**
37  * @brief read eeprom information from a specific eeprom address
38  */
39 int tricorder_get_eeprom(int addr, struct tricorder_eeprom *eeprom);
40 
41 #endif /* TRICORDER_EEPROM_H_ */
42