summaryrefslogtreecommitdiffstats
path: root/src/mainboard/prodrive/atlas/vpd.h
blob: 3955c119a7609401c0298c98ef1573f34e4bdcc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef ATLAS_VPD_H
#define ATLAS_VPD_H

/*
 * The Atlas COMe module stores some non-volatile vital product data in
 * an EC-attached I2C EEPROM. The EC firmware reads the EEPROM contents
 * and provides them to the host via EMI (Embedded Memory Interface) 0.
 */

#include <types.h>

#define VPD_MAGIC	0x56504453  /* 'VPDS' */

/*
 * Increment this value whenever new fields are added to the structures.
 * Furthermore, adapt the `get_emi_eeprom_vpd()` function accordingly to
 * provide fallback values for newly-added fields.
 */
#define VPD_LATEST_REVISION	1

struct __packed emi_eeprom_vpd_header {
	uint32_t magic;
	uint8_t revision;
	uint8_t _rfu[15];	/* Reserved for Future Use */
};

/* For backwards compatibility reasons, do NOT reuse enum values! */
enum atlas_profile {
	ATLAS_PROF_UNPROGRAMMED		= 0,	/* EEPROM not initialised */
	ATLAS_PROF_DEFAULT		= 1,
	ATLAS_PROF_REALTIME_PERFORMANCE	= 2,
	ATLAS_PROF_THEMIS_LED_CONFIG	= 3,
};

#define ATLAS_SN_PN_LENGTH	20

#define EMI_EEPROM_LAYOUT_LENGTH (			\
		sizeof(struct emi_eeprom_vpd_header) +	\
		ATLAS_SN_PN_LENGTH +			\
		ATLAS_SN_PN_LENGTH +			\
		sizeof(uint16_t)			\
	)

union emi_eeprom_vpd {
	struct __packed {
		struct emi_eeprom_vpd_header header;
		char serial_number[ATLAS_SN_PN_LENGTH];	/* xx-xx-xxx-xxx */
		char part_number[ATLAS_SN_PN_LENGTH];	/* xxx-xxxx-xxxx.Rxx */
		uint16_t profile;
	};
	uint8_t raw[EMI_EEPROM_LAYOUT_LENGTH];
};

/* Always returns a non-NULL pointer to valid data */
const union emi_eeprom_vpd *get_emi_eeprom_vpd(void);

#endif /* ATLAS_VPD_H */