18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. All rights reserved.
48c2ecf20Sopenharmony_ci * Intel specific definitions for NVDIMM Firmware Interface Table - NFIT
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#ifndef _NFIT_INTEL_H_
78c2ecf20Sopenharmony_ci#define _NFIT_INTEL_H_
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define ND_INTEL_SMART 1
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define ND_INTEL_SMART_SHUTDOWN_COUNT_VALID     (1 << 5)
128c2ecf20Sopenharmony_ci#define ND_INTEL_SMART_SHUTDOWN_VALID           (1 << 10)
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct nd_intel_smart {
158c2ecf20Sopenharmony_ci	u32 status;
168c2ecf20Sopenharmony_ci	union {
178c2ecf20Sopenharmony_ci		struct {
188c2ecf20Sopenharmony_ci			u32 flags;
198c2ecf20Sopenharmony_ci			u8 reserved0[4];
208c2ecf20Sopenharmony_ci			u8 health;
218c2ecf20Sopenharmony_ci			u8 spares;
228c2ecf20Sopenharmony_ci			u8 life_used;
238c2ecf20Sopenharmony_ci			u8 alarm_flags;
248c2ecf20Sopenharmony_ci			u16 media_temperature;
258c2ecf20Sopenharmony_ci			u16 ctrl_temperature;
268c2ecf20Sopenharmony_ci			u32 shutdown_count;
278c2ecf20Sopenharmony_ci			u8 ait_status;
288c2ecf20Sopenharmony_ci			u16 pmic_temperature;
298c2ecf20Sopenharmony_ci			u8 reserved1[8];
308c2ecf20Sopenharmony_ci			u8 shutdown_state;
318c2ecf20Sopenharmony_ci			u32 vendor_size;
328c2ecf20Sopenharmony_ci			u8 vendor_data[92];
338c2ecf20Sopenharmony_ci		} __packed;
348c2ecf20Sopenharmony_ci		u8 data[128];
358c2ecf20Sopenharmony_ci	};
368c2ecf20Sopenharmony_ci} __packed;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciextern const struct nvdimm_security_ops *intel_security_ops;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_SIZE		4
418c2ecf20Sopenharmony_ci#define ND_INTEL_PASSPHRASE_SIZE	32
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_NOT_SUPPORTED	1
448c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_RETRY		5
458c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_NOT_READY	9
468c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_INVALID_STATE	10
478c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_INVALID_PASS	11
488c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_OVERWRITE_UNSUPPORTED	0x10007
498c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_OQUERY_INPROGRESS	0x10007
508c2ecf20Sopenharmony_ci#define ND_INTEL_STATUS_OQUERY_SEQUENCE_ERR	0x20007
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_ENABLED	0x02
538c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_LOCKED	0x04
548c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_FROZEN	0x08
558c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_PLIMIT	0x10
568c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_UNSUPPORTED	0x20
578c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_STATE_OVERWRITE	0x40
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_ESTATE_ENABLED	0x01
608c2ecf20Sopenharmony_ci#define ND_INTEL_SEC_ESTATE_PLIMIT	0x02
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct nd_intel_get_security_state {
638c2ecf20Sopenharmony_ci	u32 status;
648c2ecf20Sopenharmony_ci	u8 extended_state;
658c2ecf20Sopenharmony_ci	u8 reserved[3];
668c2ecf20Sopenharmony_ci	u8 state;
678c2ecf20Sopenharmony_ci	u8 reserved1[3];
688c2ecf20Sopenharmony_ci} __packed;
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistruct nd_intel_set_passphrase {
718c2ecf20Sopenharmony_ci	u8 old_pass[ND_INTEL_PASSPHRASE_SIZE];
728c2ecf20Sopenharmony_ci	u8 new_pass[ND_INTEL_PASSPHRASE_SIZE];
738c2ecf20Sopenharmony_ci	u32 status;
748c2ecf20Sopenharmony_ci} __packed;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistruct nd_intel_unlock_unit {
778c2ecf20Sopenharmony_ci	u8 passphrase[ND_INTEL_PASSPHRASE_SIZE];
788c2ecf20Sopenharmony_ci	u32 status;
798c2ecf20Sopenharmony_ci} __packed;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct nd_intel_disable_passphrase {
828c2ecf20Sopenharmony_ci	u8 passphrase[ND_INTEL_PASSPHRASE_SIZE];
838c2ecf20Sopenharmony_ci	u32 status;
848c2ecf20Sopenharmony_ci} __packed;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistruct nd_intel_freeze_lock {
878c2ecf20Sopenharmony_ci	u32 status;
888c2ecf20Sopenharmony_ci} __packed;
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistruct nd_intel_secure_erase {
918c2ecf20Sopenharmony_ci	u8 passphrase[ND_INTEL_PASSPHRASE_SIZE];
928c2ecf20Sopenharmony_ci	u32 status;
938c2ecf20Sopenharmony_ci} __packed;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistruct nd_intel_overwrite {
968c2ecf20Sopenharmony_ci	u8 passphrase[ND_INTEL_PASSPHRASE_SIZE];
978c2ecf20Sopenharmony_ci	u32 status;
988c2ecf20Sopenharmony_ci} __packed;
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistruct nd_intel_query_overwrite {
1018c2ecf20Sopenharmony_ci	u32 status;
1028c2ecf20Sopenharmony_ci} __packed;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistruct nd_intel_set_master_passphrase {
1058c2ecf20Sopenharmony_ci	u8 old_pass[ND_INTEL_PASSPHRASE_SIZE];
1068c2ecf20Sopenharmony_ci	u8 new_pass[ND_INTEL_PASSPHRASE_SIZE];
1078c2ecf20Sopenharmony_ci	u32 status;
1088c2ecf20Sopenharmony_ci} __packed;
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistruct nd_intel_master_secure_erase {
1118c2ecf20Sopenharmony_ci	u8 passphrase[ND_INTEL_PASSPHRASE_SIZE];
1128c2ecf20Sopenharmony_ci	u32 status;
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define ND_INTEL_FWA_IDLE 0
1168c2ecf20Sopenharmony_ci#define ND_INTEL_FWA_ARMED 1
1178c2ecf20Sopenharmony_ci#define ND_INTEL_FWA_BUSY 2
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_NONE 0
1208c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_NOTSTAGED 1
1218c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_SUCCESS 2
1228c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_NEEDRESET 3
1238c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_MEDIAFAILED 4
1248c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_ABORT 5
1258c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_NOTSUPP 6
1268c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_ERROR 7
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_cistruct nd_intel_fw_activate_dimminfo {
1298c2ecf20Sopenharmony_ci	u32 status;
1308c2ecf20Sopenharmony_ci	u16 result;
1318c2ecf20Sopenharmony_ci	u8 state;
1328c2ecf20Sopenharmony_ci	u8 reserved[7];
1338c2ecf20Sopenharmony_ci} __packed;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_ARM 1
1368c2ecf20Sopenharmony_ci#define ND_INTEL_DIMM_FWA_DISARM 0
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistruct nd_intel_fw_activate_arm {
1398c2ecf20Sopenharmony_ci	u8 activate_arm;
1408c2ecf20Sopenharmony_ci	u32 status;
1418c2ecf20Sopenharmony_ci} __packed;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/* Root device command payloads */
1448c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_CAP_FWQUIESCE (1 << 0)
1458c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_CAP_OSQUIESCE (1 << 1)
1468c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_CAP_RESET     (1 << 2)
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistruct nd_intel_bus_fw_activate_businfo {
1498c2ecf20Sopenharmony_ci	u32 status;
1508c2ecf20Sopenharmony_ci	u16 reserved;
1518c2ecf20Sopenharmony_ci	u8 state;
1528c2ecf20Sopenharmony_ci	u8 capability;
1538c2ecf20Sopenharmony_ci	u64 activate_tmo;
1548c2ecf20Sopenharmony_ci	u64 cpu_quiesce_tmo;
1558c2ecf20Sopenharmony_ci	u64 io_quiesce_tmo;
1568c2ecf20Sopenharmony_ci	u64 max_quiesce_tmo;
1578c2ecf20Sopenharmony_ci} __packed;
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_NOARM  (6 | 1 << 16)
1608c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_BUSY   (6 | 2 << 16)
1618c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_NOFW   (6 | 3 << 16)
1628c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_TMO    (6 | 4 << 16)
1638c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_NOIDLE (6 | 5 << 16)
1648c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_STATUS_ABORT  (6 | 6 << 16)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_IODEV_FORCE_IDLE (0)
1678c2ecf20Sopenharmony_ci#define ND_INTEL_BUS_FWA_IODEV_OS_IDLE (1)
1688c2ecf20Sopenharmony_cistruct nd_intel_bus_fw_activate {
1698c2ecf20Sopenharmony_ci	u8 iodev_state;
1708c2ecf20Sopenharmony_ci	u32 status;
1718c2ecf20Sopenharmony_ci} __packed;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ciextern const struct nvdimm_fw_ops *intel_fw_ops;
1748c2ecf20Sopenharmony_ciextern const struct nvdimm_bus_fw_ops *intel_bus_fw_ops;
1758c2ecf20Sopenharmony_ci#endif
176