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
11 #include <asm/arch/me.h>
12 #include <linux/delay.h>
14 static inline void me_read_dword_ptr(struct udevice *dev, void *ptr, int offset)
18 dm_pci_read_config32(dev, offset, &dword);
19 memcpy(ptr, &dword, sizeof(dword));
22 int intel_me_hsio_version(struct udevice *dev, uint16_t *versionp,
29 /* Query for HSIO version, overloads H_GS and HFS */
30 dm_pci_write_config32(dev, PCI_ME_H_GS,
31 ME_HSIO_MESSAGE | ME_HSIO_CMD_GETHSIOVER);
33 /* Must wait for ME acknowledgement */
34 for (count = ME_RETRY; count > 0; --count) {
35 me_read_dword_ptr(dev, &hfs, PCI_ME_HFS);
41 debug("ERROR: ME failed to respond\n");
45 /* HSIO version should be in HFS_5 */
46 dm_pci_read_config32(dev, PCI_ME_HFS5, &hsiover);
47 *versionp = hsiover >> 16;
48 *checksump = hsiover & 0xffff;
50 debug("ME: HSIO Version : %d (CRC 0x%04x)\n",
51 *versionp, *checksump);
53 /* Reset registers to normal behavior */
54 dm_pci_write_config32(dev, PCI_ME_H_GS,
55 ME_HSIO_MESSAGE | ME_HSIO_CMD_GETHSIOVER);