ec/google/chromeec: Define ACPI_NOTIFY_CROS_EC_MKBP constant
[coreboot2.git] / src / device / dram / ddr_common.c
blobc75cba71281aba6b9ed1680101b071f1639d2e18
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/dram/common.h>
4 #include <types.h>
6 /**
7 * \brief Calculate the CRC of a DDR SPD data
9 * @param spd pointer to raw SPD data
10 * @param len length of data in SPD
12 * @return the CRC of the SPD data
14 u16 ddr_crc16(const u8 *ptr, int n_crc)
16 int i;
17 u16 crc = 0;
19 while (--n_crc >= 0) {
20 crc = crc ^ ((int)*ptr++ << 8);
21 for (i = 0; i < 8; ++i)
22 if (crc & 0x8000)
23 crc = (crc << 1) ^ 0x1021;
24 else
25 crc = crc << 1;
28 return crc;