162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2013-2014, Intel Corporation. All rights reserved.
462306a36Sopenharmony_ci * Intel Management Engine Interface (Intel MEI) Linux driver
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef _MEI_HW_TXE_REGS_H_
762306a36Sopenharmony_ci#define _MEI_HW_TXE_REGS_H_
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include "hw.h"
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#define SEC_ALIVENESS_TIMER_TIMEOUT        (5 * MSEC_PER_SEC)
1262306a36Sopenharmony_ci#define SEC_ALIVENESS_WAIT_TIMEOUT         (1 * MSEC_PER_SEC)
1362306a36Sopenharmony_ci#define SEC_RESET_WAIT_TIMEOUT             (1 * MSEC_PER_SEC)
1462306a36Sopenharmony_ci#define SEC_READY_WAIT_TIMEOUT             (5 * MSEC_PER_SEC)
1562306a36Sopenharmony_ci#define START_MESSAGE_RESPONSE_WAIT_TIMEOUT (5 * MSEC_PER_SEC)
1662306a36Sopenharmony_ci#define RESET_CANCEL_WAIT_TIMEOUT          (1 * MSEC_PER_SEC)
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cienum {
1962306a36Sopenharmony_ci	SEC_BAR,
2062306a36Sopenharmony_ci	BRIDGE_BAR,
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci	NUM_OF_MEM_BARS
2362306a36Sopenharmony_ci};
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* SeC FW Status Register
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * FW uses this register in order to report its status to host.
2862306a36Sopenharmony_ci * This register resides in PCI-E config space.
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci#define PCI_CFG_TXE_FW_STS0   0x40
3162306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_WRK_ST_MSK    0x0000000F
3262306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_OP_ST_MSK     0x000001C0
3362306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_FW_INIT_CMPLT 0x00000200
3462306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_ERR_CODE_MSK  0x0000F000
3562306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_OP_MODE_MSK   0x000F0000
3662306a36Sopenharmony_ci#  define PCI_CFG_TXE_FW_STS0_RST_CNT_MSK   0x00F00000
3762306a36Sopenharmony_ci#define PCI_CFG_TXE_FW_STS1   0x48
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define IPC_BASE_ADDR	0x80400 /* SeC IPC Base Address */
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* IPC Input Doorbell Register */
4262306a36Sopenharmony_ci#define SEC_IPC_INPUT_DOORBELL_REG       (0x0000 + IPC_BASE_ADDR)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* IPC Input Status Register
4562306a36Sopenharmony_ci * This register indicates whether or not processing of
4662306a36Sopenharmony_ci * the most recent command has been completed by the SEC
4762306a36Sopenharmony_ci * New commands and payloads should not be written by the Host
4862306a36Sopenharmony_ci * until this indicates that the previous command has been processed.
4962306a36Sopenharmony_ci */
5062306a36Sopenharmony_ci#define SEC_IPC_INPUT_STATUS_REG         (0x0008 + IPC_BASE_ADDR)
5162306a36Sopenharmony_ci#  define SEC_IPC_INPUT_STATUS_RDY    BIT(0)
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci/* IPC Host Interrupt Status Register */
5462306a36Sopenharmony_ci#define SEC_IPC_HOST_INT_STATUS_REG      (0x0010 + IPC_BASE_ADDR)
5562306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_OUT_DB             BIT(0)
5662306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_IN_RDY             BIT(1)
5762306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_HDCP_M0_RCVD       BIT(5)
5862306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_ILL_MEM_ACCESS     BIT(17)
5962306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_AES_HKEY_ERR       BIT(18)
6062306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_DES_HKEY_ERR       BIT(19)
6162306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_TMRMTB_OVERFLOW    BIT(21)
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/* Convenient mask for pending interrupts */
6462306a36Sopenharmony_ci#define   SEC_IPC_HOST_INT_STATUS_PENDING \
6562306a36Sopenharmony_ci		(SEC_IPC_HOST_INT_STATUS_OUT_DB| \
6662306a36Sopenharmony_ci		SEC_IPC_HOST_INT_STATUS_IN_RDY)
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/* IPC Host Interrupt Mask Register */
6962306a36Sopenharmony_ci#define SEC_IPC_HOST_INT_MASK_REG        (0x0014 + IPC_BASE_ADDR)
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci#  define SEC_IPC_HOST_INT_MASK_OUT_DB	BIT(0) /* Output Doorbell Int Mask */
7262306a36Sopenharmony_ci#  define SEC_IPC_HOST_INT_MASK_IN_RDY	BIT(1) /* Input Ready Int Mask */
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/* IPC Input Payload RAM */
7562306a36Sopenharmony_ci#define SEC_IPC_INPUT_PAYLOAD_REG        (0x0100 + IPC_BASE_ADDR)
7662306a36Sopenharmony_ci/* IPC Shared Payload RAM */
7762306a36Sopenharmony_ci#define IPC_SHARED_PAYLOAD_REG           (0x0200 + IPC_BASE_ADDR)
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/* SeC Address Translation Table Entry 2 - Ctrl
8062306a36Sopenharmony_ci *
8162306a36Sopenharmony_ci * This register resides also in SeC's PCI-E Memory space.
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci#define SATT2_CTRL_REG                   0x1040
8462306a36Sopenharmony_ci#  define SATT2_CTRL_VALID_MSK            BIT(0)
8562306a36Sopenharmony_ci#  define SATT2_CTRL_BR_BASE_ADDR_REG_SHIFT 8
8662306a36Sopenharmony_ci#  define SATT2_CTRL_BRIDGE_HOST_EN_MSK   BIT(12)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* SATT Table Entry 2 SAP Base Address Register */
8962306a36Sopenharmony_ci#define SATT2_SAP_BA_REG                 0x1044
9062306a36Sopenharmony_ci/* SATT Table Entry 2 SAP Size Register. */
9162306a36Sopenharmony_ci#define SATT2_SAP_SIZE_REG               0x1048
9262306a36Sopenharmony_ci /* SATT Table Entry 2 SAP Bridge Address - LSB Register */
9362306a36Sopenharmony_ci#define SATT2_BRG_BA_LSB_REG             0x104C
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/* Host High-level Interrupt Status Register */
9662306a36Sopenharmony_ci#define HHISR_REG                        0x2020
9762306a36Sopenharmony_ci/* Host High-level Interrupt Enable Register
9862306a36Sopenharmony_ci *
9962306a36Sopenharmony_ci * Resides in PCI memory space. This is the top hierarchy for
10062306a36Sopenharmony_ci * interrupts from SeC to host, aggregating both interrupts that
10162306a36Sopenharmony_ci * arrive through HICR registers as well as interrupts
10262306a36Sopenharmony_ci * that arrive via IPC.
10362306a36Sopenharmony_ci */
10462306a36Sopenharmony_ci#define HHIER_REG                        0x2024
10562306a36Sopenharmony_ci#define   IPC_HHIER_SEC	BIT(0)
10662306a36Sopenharmony_ci#define   IPC_HHIER_BRIDGE	BIT(1)
10762306a36Sopenharmony_ci#define   IPC_HHIER_MSK	(IPC_HHIER_SEC | IPC_HHIER_BRIDGE)
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/* Host High-level Interrupt Mask Register.
11062306a36Sopenharmony_ci *
11162306a36Sopenharmony_ci * Resides in PCI memory space.
11262306a36Sopenharmony_ci * This is the top hierarchy for masking interrupts from SeC to host.
11362306a36Sopenharmony_ci */
11462306a36Sopenharmony_ci#define HHIMR_REG                        0x2028
11562306a36Sopenharmony_ci#define   IPC_HHIMR_SEC       BIT(0)
11662306a36Sopenharmony_ci#define   IPC_HHIMR_BRIDGE    BIT(1)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/* Host High-level IRQ Status Register */
11962306a36Sopenharmony_ci#define HHIRQSR_REG                      0x202C
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/* Host Interrupt Cause Register 0 - SeC IPC Readiness
12262306a36Sopenharmony_ci *
12362306a36Sopenharmony_ci * This register is both an ICR to Host from PCI Memory Space
12462306a36Sopenharmony_ci * and it is also exposed in the SeC memory space.
12562306a36Sopenharmony_ci * This register is used by SeC's IPC driver in order
12662306a36Sopenharmony_ci * to synchronize with host about IPC interface state.
12762306a36Sopenharmony_ci */
12862306a36Sopenharmony_ci#define HICR_SEC_IPC_READINESS_REG       0x2040
12962306a36Sopenharmony_ci#define   HICR_SEC_IPC_READINESS_HOST_RDY  BIT(0)
13062306a36Sopenharmony_ci#define   HICR_SEC_IPC_READINESS_SEC_RDY   BIT(1)
13162306a36Sopenharmony_ci#define   HICR_SEC_IPC_READINESS_SYS_RDY     \
13262306a36Sopenharmony_ci	  (HICR_SEC_IPC_READINESS_HOST_RDY | \
13362306a36Sopenharmony_ci	   HICR_SEC_IPC_READINESS_SEC_RDY)
13462306a36Sopenharmony_ci#define   HICR_SEC_IPC_READINESS_RDY_CLR   BIT(2)
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci/* Host Interrupt Cause Register 1 - Aliveness Response */
13762306a36Sopenharmony_ci/* This register is both an ICR to Host from PCI Memory Space
13862306a36Sopenharmony_ci * and it is also exposed in the SeC memory space.
13962306a36Sopenharmony_ci * The register may be used by SeC to ACK a host request for aliveness.
14062306a36Sopenharmony_ci */
14162306a36Sopenharmony_ci#define HICR_HOST_ALIVENESS_RESP_REG     0x2044
14262306a36Sopenharmony_ci#define   HICR_HOST_ALIVENESS_RESP_ACK    BIT(0)
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* Host Interrupt Cause Register 2 - SeC IPC Output Doorbell */
14562306a36Sopenharmony_ci#define HICR_SEC_IPC_OUTPUT_DOORBELL_REG 0x2048
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci/* Host Interrupt Status Register.
14862306a36Sopenharmony_ci *
14962306a36Sopenharmony_ci * Resides in PCI memory space.
15062306a36Sopenharmony_ci * This is the main register involved in generating interrupts
15162306a36Sopenharmony_ci * from SeC to host via HICRs.
15262306a36Sopenharmony_ci * The interrupt generation rules are as follows:
15362306a36Sopenharmony_ci * An interrupt will be generated whenever for any i,
15462306a36Sopenharmony_ci * there is a transition from a state where at least one of
15562306a36Sopenharmony_ci * the following conditions did not hold, to a state where
15662306a36Sopenharmony_ci * ALL the following conditions hold:
15762306a36Sopenharmony_ci * A) HISR.INT[i]_STS == 1.
15862306a36Sopenharmony_ci * B) HIER.INT[i]_EN == 1.
15962306a36Sopenharmony_ci */
16062306a36Sopenharmony_ci#define HISR_REG                         0x2060
16162306a36Sopenharmony_ci#define   HISR_INT_0_STS      BIT(0)
16262306a36Sopenharmony_ci#define   HISR_INT_1_STS      BIT(1)
16362306a36Sopenharmony_ci#define   HISR_INT_2_STS      BIT(2)
16462306a36Sopenharmony_ci#define   HISR_INT_3_STS      BIT(3)
16562306a36Sopenharmony_ci#define   HISR_INT_4_STS      BIT(4)
16662306a36Sopenharmony_ci#define   HISR_INT_5_STS      BIT(5)
16762306a36Sopenharmony_ci#define   HISR_INT_6_STS      BIT(6)
16862306a36Sopenharmony_ci#define   HISR_INT_7_STS      BIT(7)
16962306a36Sopenharmony_ci#define   HISR_INT_STS_MSK \
17062306a36Sopenharmony_ci	(HISR_INT_0_STS | HISR_INT_1_STS | HISR_INT_2_STS)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci/* Host Interrupt Enable Register. Resides in PCI memory space. */
17362306a36Sopenharmony_ci#define HIER_REG                         0x2064
17462306a36Sopenharmony_ci#define   HIER_INT_0_EN      BIT(0)
17562306a36Sopenharmony_ci#define   HIER_INT_1_EN      BIT(1)
17662306a36Sopenharmony_ci#define   HIER_INT_2_EN      BIT(2)
17762306a36Sopenharmony_ci#define   HIER_INT_3_EN      BIT(3)
17862306a36Sopenharmony_ci#define   HIER_INT_4_EN      BIT(4)
17962306a36Sopenharmony_ci#define   HIER_INT_5_EN      BIT(5)
18062306a36Sopenharmony_ci#define   HIER_INT_6_EN      BIT(6)
18162306a36Sopenharmony_ci#define   HIER_INT_7_EN      BIT(7)
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define   HIER_INT_EN_MSK \
18462306a36Sopenharmony_ci	 (HIER_INT_0_EN | HIER_INT_1_EN | HIER_INT_2_EN)
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci/* SEC Memory Space IPC output payload.
18862306a36Sopenharmony_ci *
18962306a36Sopenharmony_ci * This register is part of the output payload which SEC provides to host.
19062306a36Sopenharmony_ci */
19162306a36Sopenharmony_ci#define BRIDGE_IPC_OUTPUT_PAYLOAD_REG    0x20C0
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/* SeC Interrupt Cause Register - Host Aliveness Request
19462306a36Sopenharmony_ci * This register is both an ICR to SeC and it is also exposed
19562306a36Sopenharmony_ci * in the host-visible PCI memory space.
19662306a36Sopenharmony_ci * The register is used by host to request SeC aliveness.
19762306a36Sopenharmony_ci */
19862306a36Sopenharmony_ci#define SICR_HOST_ALIVENESS_REQ_REG      0x214C
19962306a36Sopenharmony_ci#define   SICR_HOST_ALIVENESS_REQ_REQUESTED    BIT(0)
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci/* SeC Interrupt Cause Register - Host IPC Readiness
20362306a36Sopenharmony_ci *
20462306a36Sopenharmony_ci * This register is both an ICR to SeC and it is also exposed
20562306a36Sopenharmony_ci * in the host-visible PCI memory space.
20662306a36Sopenharmony_ci * This register is used by the host's SeC driver uses in order
20762306a36Sopenharmony_ci * to synchronize with SeC about IPC interface state.
20862306a36Sopenharmony_ci */
20962306a36Sopenharmony_ci#define SICR_HOST_IPC_READINESS_REQ_REG  0x2150
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci#define SICR_HOST_IPC_READINESS_HOST_RDY  BIT(0)
21362306a36Sopenharmony_ci#define SICR_HOST_IPC_READINESS_SEC_RDY   BIT(1)
21462306a36Sopenharmony_ci#define SICR_HOST_IPC_READINESS_SYS_RDY     \
21562306a36Sopenharmony_ci	(SICR_HOST_IPC_READINESS_HOST_RDY | \
21662306a36Sopenharmony_ci	 SICR_HOST_IPC_READINESS_SEC_RDY)
21762306a36Sopenharmony_ci#define SICR_HOST_IPC_READINESS_RDY_CLR   BIT(2)
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci/* SeC Interrupt Cause Register - SeC IPC Output Status
22062306a36Sopenharmony_ci *
22162306a36Sopenharmony_ci * This register indicates whether or not processing of the most recent
22262306a36Sopenharmony_ci * command has been completed by the Host.
22362306a36Sopenharmony_ci * New commands and payloads should not be written by SeC until this
22462306a36Sopenharmony_ci * register indicates that the previous command has been processed.
22562306a36Sopenharmony_ci */
22662306a36Sopenharmony_ci#define SICR_SEC_IPC_OUTPUT_STATUS_REG   0x2154
22762306a36Sopenharmony_ci#  define SEC_IPC_OUTPUT_STATUS_RDY BIT(0)
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci/*  MEI IPC Message payload size 64 bytes */
23262306a36Sopenharmony_ci#define PAYLOAD_SIZE        64
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci/* MAX size for SATT range 32MB */
23562306a36Sopenharmony_ci#define SATT_RANGE_MAX     (32 << 20)
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci#endif /* _MEI_HW_TXE_REGS_H_ */
23962306a36Sopenharmony_ci
240