1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016 Google, Inc
5 * Based on code from coreboot src/soc/intel/broadwell/me_status.c
10 #include <asm/arch/me.h>
12 static inline void me_read_dword_ptr(struct udevice *dev, void *ptr, int offset)
16 dm_pci_read_config32(dev, offset, &dword);
17 memcpy(ptr, &dword, sizeof(dword));
20 int intel_me_hsio_version(struct udevice *dev, uint16_t *versionp,
27 /* Query for HSIO version, overloads H_GS and HFS */
28 dm_pci_write_config32(dev, PCI_ME_H_GS,
29 ME_HSIO_MESSAGE | ME_HSIO_CMD_GETHSIOVER);
31 /* Must wait for ME acknowledgement */
32 for (count = ME_RETRY; count > 0; --count) {
33 me_read_dword_ptr(dev, &hfs, PCI_ME_HFS);
39 debug("ERROR: ME failed to respond\n");
43 /* HSIO version should be in HFS_5 */
44 dm_pci_read_config32(dev, PCI_ME_HFS5, &hsiover);
45 *versionp = hsiover >> 16;
46 *checksump = hsiover & 0xffff;
48 debug("ME: HSIO Version : %d (CRC 0x%04x)\n",
49 *versionp, *checksump);
51 /* Reset registers to normal behavior */
52 dm_pci_write_config32(dev, PCI_ME_H_GS,
53 ME_HSIO_MESSAGE | ME_HSIO_CMD_GETHSIOVER);