162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * QLogic Fibre Channel HBA Driver
462306a36Sopenharmony_ci * Copyright (c)  2003-2014 QLogic Corporation
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef __QLA_NX2_H
862306a36Sopenharmony_ci#define __QLA_NX2_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define QSNT_ACK_TOV				30
1162306a36Sopenharmony_ci#define INTENT_TO_RECOVER			0x01
1262306a36Sopenharmony_ci#define PROCEED_TO_RECOVER			0x02
1362306a36Sopenharmony_ci#define IDC_LOCK_RECOVERY_OWNER_MASK		0x3C
1462306a36Sopenharmony_ci#define IDC_LOCK_RECOVERY_STATE_MASK		0x3
1562306a36Sopenharmony_ci#define IDC_LOCK_RECOVERY_STATE_SHIFT_BITS	2
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define QLA8044_DRV_LOCK_MSLEEP		200
1862306a36Sopenharmony_ci#define QLA8044_ADDR_DDR_NET		(0x0000000000000000ULL)
1962306a36Sopenharmony_ci#define QLA8044_ADDR_DDR_NET_MAX	(0x000000000fffffffULL)
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_LO		0x410000A0
2262306a36Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_HI		0x410000A4
2362306a36Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_ULO		0x410000B0
2462306a36Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_UHI		0x410000B4
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* MIU_TEST_AGT_CTRL flags. work for SIU as well */
2762306a36Sopenharmony_ci#define MIU_TA_CTL_WRITE_ENABLE	(MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE)
2862306a36Sopenharmony_ci#define MIU_TA_CTL_WRITE_START	(MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE |	\
2962306a36Sopenharmony_ci				 MIU_TA_CTL_START)
3062306a36Sopenharmony_ci#define MIU_TA_CTL_START_ENABLE	(MIU_TA_CTL_START | MIU_TA_CTL_ENABLE)
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* Imbus address bit used to indicate a host address. This bit is
3362306a36Sopenharmony_ci * eliminated by the pcie bar and bar select before presentation
3462306a36Sopenharmony_ci * over pcie. */
3562306a36Sopenharmony_ci/* host memory via IMBUS */
3662306a36Sopenharmony_ci#define QLA8044_P2_ADDR_PCIE	(0x0000000800000000ULL)
3762306a36Sopenharmony_ci#define QLA8044_P3_ADDR_PCIE	(0x0000008000000000ULL)
3862306a36Sopenharmony_ci#define QLA8044_ADDR_PCIE_MAX	(0x0000000FFFFFFFFFULL)
3962306a36Sopenharmony_ci#define QLA8044_ADDR_OCM0	(0x0000000200000000ULL)
4062306a36Sopenharmony_ci#define QLA8044_ADDR_OCM0_MAX	(0x00000002000fffffULL)
4162306a36Sopenharmony_ci#define QLA8044_ADDR_OCM1	(0x0000000200400000ULL)
4262306a36Sopenharmony_ci#define QLA8044_ADDR_OCM1_MAX	(0x00000002004fffffULL)
4362306a36Sopenharmony_ci#define QLA8044_ADDR_QDR_NET	(0x0000000300000000ULL)
4462306a36Sopenharmony_ci#define QLA8044_P2_ADDR_QDR_NET_MAX	(0x00000003001fffffULL)
4562306a36Sopenharmony_ci#define QLA8044_P3_ADDR_QDR_NET_MAX	(0x0000000303ffffffULL)
4662306a36Sopenharmony_ci#define QLA8044_ADDR_QDR_NET_MAX	(0x0000000307ffffffULL)
4762306a36Sopenharmony_ci#define QLA8044_PCI_CRBSPACE		((unsigned long)0x06000000)
4862306a36Sopenharmony_ci#define QLA8044_PCI_DIRECT_CRB		((unsigned long)0x04400000)
4962306a36Sopenharmony_ci#define QLA8044_PCI_CAMQM		((unsigned long)0x04800000)
5062306a36Sopenharmony_ci#define QLA8044_PCI_CAMQM_MAX		((unsigned long)0x04ffffff)
5162306a36Sopenharmony_ci#define QLA8044_PCI_DDR_NET		((unsigned long)0x00000000)
5262306a36Sopenharmony_ci#define QLA8044_PCI_QDR_NET		((unsigned long)0x04000000)
5362306a36Sopenharmony_ci#define QLA8044_PCI_QDR_NET_MAX		((unsigned long)0x043fffff)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/*  PCI Windowing for DDR regions.  */
5662306a36Sopenharmony_cistatic inline bool addr_in_range(u64 addr, u64 low, u64 high)
5762306a36Sopenharmony_ci{
5862306a36Sopenharmony_ci	return addr <= high && addr >= low;
5962306a36Sopenharmony_ci}
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* Indirectly Mapped Registers */
6262306a36Sopenharmony_ci#define QLA8044_FLASH_SPI_STATUS	0x2808E010
6362306a36Sopenharmony_ci#define QLA8044_FLASH_SPI_CONTROL	0x2808E014
6462306a36Sopenharmony_ci#define QLA8044_FLASH_STATUS		0x42100004
6562306a36Sopenharmony_ci#define QLA8044_FLASH_CONTROL		0x42110004
6662306a36Sopenharmony_ci#define QLA8044_FLASH_ADDR		0x42110008
6762306a36Sopenharmony_ci#define QLA8044_FLASH_WRDATA		0x4211000C
6862306a36Sopenharmony_ci#define QLA8044_FLASH_RDDATA		0x42110018
6962306a36Sopenharmony_ci#define QLA8044_FLASH_DIRECT_WINDOW	0x42110030
7062306a36Sopenharmony_ci#define QLA8044_FLASH_DIRECT_DATA(DATA) (0x42150000 | (0x0000FFFF&DATA))
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* Flash access regs */
7362306a36Sopenharmony_ci#define QLA8044_FLASH_LOCK		0x3850
7462306a36Sopenharmony_ci#define QLA8044_FLASH_UNLOCK		0x3854
7562306a36Sopenharmony_ci#define QLA8044_FLASH_LOCK_ID		0x3500
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* Driver Lock regs */
7862306a36Sopenharmony_ci#define QLA8044_DRV_LOCK		0x3868
7962306a36Sopenharmony_ci#define QLA8044_DRV_UNLOCK		0x386C
8062306a36Sopenharmony_ci#define QLA8044_DRV_LOCK_ID		0x3504
8162306a36Sopenharmony_ci#define QLA8044_DRV_LOCKRECOVERY	0x379C
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* IDC version */
8462306a36Sopenharmony_ci#define QLA8044_IDC_VER_MAJ_VALUE       0x1
8562306a36Sopenharmony_ci#define QLA8044_IDC_VER_MIN_VALUE       0x0
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/* IDC Registers : Driver Coexistence Defines */
8862306a36Sopenharmony_ci#define QLA8044_CRB_IDC_VER_MAJOR	0x3780
8962306a36Sopenharmony_ci#define QLA8044_CRB_IDC_VER_MINOR	0x3798
9062306a36Sopenharmony_ci#define QLA8044_IDC_DRV_AUDIT		0x3794
9162306a36Sopenharmony_ci#define QLA8044_SRE_SHIM_CONTROL	0x0D200284
9262306a36Sopenharmony_ci#define QLA8044_PORT0_RXB_PAUSE_THRS	0x0B2003A4
9362306a36Sopenharmony_ci#define QLA8044_PORT1_RXB_PAUSE_THRS	0x0B2013A4
9462306a36Sopenharmony_ci#define QLA8044_PORT0_RXB_TC_MAX_CELL	0x0B200388
9562306a36Sopenharmony_ci#define QLA8044_PORT1_RXB_TC_MAX_CELL	0x0B201388
9662306a36Sopenharmony_ci#define QLA8044_PORT0_RXB_TC_STATS	0x0B20039C
9762306a36Sopenharmony_ci#define QLA8044_PORT1_RXB_TC_STATS	0x0B20139C
9862306a36Sopenharmony_ci#define QLA8044_PORT2_IFB_PAUSE_THRS	0x0B200704
9962306a36Sopenharmony_ci#define QLA8044_PORT3_IFB_PAUSE_THRS	0x0B201704
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci/* set value to pause threshold value */
10262306a36Sopenharmony_ci#define QLA8044_SET_PAUSE_VAL		0x0
10362306a36Sopenharmony_ci#define QLA8044_SET_TC_MAX_CELL_VAL	0x03FF03FF
10462306a36Sopenharmony_ci#define QLA8044_PEG_HALT_STATUS1	0x34A8
10562306a36Sopenharmony_ci#define QLA8044_PEG_HALT_STATUS2	0x34AC
10662306a36Sopenharmony_ci#define QLA8044_PEG_ALIVE_COUNTER	0x34B0 /* FW_HEARTBEAT */
10762306a36Sopenharmony_ci#define QLA8044_FW_CAPABILITIES		0x3528
10862306a36Sopenharmony_ci#define QLA8044_CRB_DRV_ACTIVE		0x3788 /* IDC_DRV_PRESENCE */
10962306a36Sopenharmony_ci#define QLA8044_CRB_DEV_STATE		0x3784 /* IDC_DEV_STATE */
11062306a36Sopenharmony_ci#define QLA8044_CRB_DRV_STATE		0x378C /* IDC_DRV_ACK */
11162306a36Sopenharmony_ci#define QLA8044_CRB_DRV_SCRATCH		0x3548
11262306a36Sopenharmony_ci#define QLA8044_CRB_DEV_PART_INFO1	0x37E0
11362306a36Sopenharmony_ci#define QLA8044_CRB_DEV_PART_INFO2	0x37E4
11462306a36Sopenharmony_ci#define QLA8044_FW_VER_MAJOR		0x3550
11562306a36Sopenharmony_ci#define QLA8044_FW_VER_MINOR		0x3554
11662306a36Sopenharmony_ci#define QLA8044_FW_VER_SUB		0x3558
11762306a36Sopenharmony_ci#define QLA8044_NPAR_STATE		0x359C
11862306a36Sopenharmony_ci#define QLA8044_FW_IMAGE_VALID		0x35FC
11962306a36Sopenharmony_ci#define QLA8044_CMDPEG_STATE		0x3650
12062306a36Sopenharmony_ci#define QLA8044_ASIC_TEMP		0x37B4
12162306a36Sopenharmony_ci#define QLA8044_FW_API			0x356C
12262306a36Sopenharmony_ci#define QLA8044_DRV_OP_MODE		0x3570
12362306a36Sopenharmony_ci#define QLA8044_CRB_WIN_BASE		0x3800
12462306a36Sopenharmony_ci#define QLA8044_CRB_WIN_FUNC(f)		(QLA8044_CRB_WIN_BASE+((f)*4))
12562306a36Sopenharmony_ci#define QLA8044_SEM_LOCK_BASE		0x3840
12662306a36Sopenharmony_ci#define QLA8044_SEM_UNLOCK_BASE		0x3844
12762306a36Sopenharmony_ci#define QLA8044_SEM_LOCK_FUNC(f)	(QLA8044_SEM_LOCK_BASE+((f)*8))
12862306a36Sopenharmony_ci#define QLA8044_SEM_UNLOCK_FUNC(f)	(QLA8044_SEM_UNLOCK_BASE+((f)*8))
12962306a36Sopenharmony_ci#define QLA8044_LINK_STATE(f)		(0x3698+((f) > 7 ? 4 : 0))
13062306a36Sopenharmony_ci#define QLA8044_LINK_SPEED(f)		(0x36E0+(((f) >> 2) * 4))
13162306a36Sopenharmony_ci#define QLA8044_MAX_LINK_SPEED(f)       (0x36F0+(((f) / 4) * 4))
13262306a36Sopenharmony_ci#define QLA8044_LINK_SPEED_FACTOR	10
13362306a36Sopenharmony_ci#define QLA8044_FUN7_ACTIVE_INDEX	0x80
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/* FLASH API Defines */
13662306a36Sopenharmony_ci#define QLA8044_FLASH_MAX_WAIT_USEC	100
13762306a36Sopenharmony_ci#define QLA8044_FLASH_LOCK_TIMEOUT	10000
13862306a36Sopenharmony_ci#define QLA8044_FLASH_SECTOR_SIZE	65536
13962306a36Sopenharmony_ci#define QLA8044_DRV_LOCK_TIMEOUT	2000
14062306a36Sopenharmony_ci#define QLA8044_FLASH_SECTOR_ERASE_CMD	0xdeadbeef
14162306a36Sopenharmony_ci#define QLA8044_FLASH_WRITE_CMD		0xdacdacda
14262306a36Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_CMD	0xcadcadca
14362306a36Sopenharmony_ci#define QLA8044_FLASH_READ_RETRY_COUNT	2000
14462306a36Sopenharmony_ci#define QLA8044_FLASH_STATUS_READY	0x6
14562306a36Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_MIN	2
14662306a36Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_MAX	64
14762306a36Sopenharmony_ci#define QLA8044_FLASH_STATUS_REG_POLL_DELAY 1
14862306a36Sopenharmony_ci#define QLA8044_ERASE_MODE		1
14962306a36Sopenharmony_ci#define QLA8044_WRITE_MODE		2
15062306a36Sopenharmony_ci#define QLA8044_DWORD_WRITE_MODE	3
15162306a36Sopenharmony_ci#define QLA8044_GLOBAL_RESET		0x38CC
15262306a36Sopenharmony_ci#define QLA8044_WILDCARD		0x38F0
15362306a36Sopenharmony_ci#define QLA8044_INFORMANT		0x38FC
15462306a36Sopenharmony_ci#define QLA8044_HOST_MBX_CTRL		0x3038
15562306a36Sopenharmony_ci#define QLA8044_FW_MBX_CTRL		0x303C
15662306a36Sopenharmony_ci#define QLA8044_BOOTLOADER_ADDR		0x355C
15762306a36Sopenharmony_ci#define QLA8044_BOOTLOADER_SIZE		0x3560
15862306a36Sopenharmony_ci#define QLA8044_FW_IMAGE_ADDR		0x3564
15962306a36Sopenharmony_ci#define QLA8044_MBX_INTR_ENABLE		0x1000
16062306a36Sopenharmony_ci#define QLA8044_MBX_INTR_MASK		0x1200
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci/* IDC Control Register bit defines */
16362306a36Sopenharmony_ci#define DONTRESET_BIT0		0x1
16462306a36Sopenharmony_ci#define GRACEFUL_RESET_BIT1	0x2
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci/* ISP8044 PEG_HALT_STATUS1 bits */
16762306a36Sopenharmony_ci#define QLA8044_HALT_STATUS_INFORMATIONAL (0x1 << 29)
16862306a36Sopenharmony_ci#define QLA8044_HALT_STATUS_FW_RESET	  (0x2 << 29)
16962306a36Sopenharmony_ci#define QLA8044_HALT_STATUS_UNRECOVERABLE (0x4 << 29)
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci/* Firmware image definitions */
17262306a36Sopenharmony_ci#define QLA8044_BOOTLOADER_FLASH_ADDR	0x10000
17362306a36Sopenharmony_ci#define QLA8044_BOOT_FROM_FLASH		0
17462306a36Sopenharmony_ci#define QLA8044_IDC_PARAM_ADDR		0x3e8020
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci/* FLASH related definitions */
17762306a36Sopenharmony_ci#define QLA8044_OPTROM_BURST_SIZE		0x100
17862306a36Sopenharmony_ci#define QLA8044_MAX_OPTROM_BURST_DWORDS		(QLA8044_OPTROM_BURST_SIZE / 4)
17962306a36Sopenharmony_ci#define QLA8044_MIN_OPTROM_BURST_DWORDS		2
18062306a36Sopenharmony_ci#define QLA8044_SECTOR_SIZE			(64 * 1024)
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci#define QLA8044_FLASH_SPI_CTL			0x4
18362306a36Sopenharmony_ci#define QLA8044_FLASH_FIRST_TEMP_VAL		0x00800000
18462306a36Sopenharmony_ci#define QLA8044_FLASH_SECOND_TEMP_VAL		0x00800001
18562306a36Sopenharmony_ci#define QLA8044_FLASH_FIRST_MS_PATTERN		0x43
18662306a36Sopenharmony_ci#define QLA8044_FLASH_SECOND_MS_PATTERN		0x7F
18762306a36Sopenharmony_ci#define QLA8044_FLASH_LAST_MS_PATTERN		0x7D
18862306a36Sopenharmony_ci#define QLA8044_FLASH_STATUS_WRITE_DEF_SIG	0xFD0100
18962306a36Sopenharmony_ci#define QLA8044_FLASH_SECOND_ERASE_MS_VAL	0x5
19062306a36Sopenharmony_ci#define QLA8044_FLASH_ERASE_SIG			0xFD0300
19162306a36Sopenharmony_ci#define QLA8044_FLASH_LAST_ERASE_MS_VAL		0x3D
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/* Reset template definitions */
19462306a36Sopenharmony_ci#define QLA8044_MAX_RESET_SEQ_ENTRIES	16
19562306a36Sopenharmony_ci#define QLA8044_RESTART_TEMPLATE_SIZE	0x2000
19662306a36Sopenharmony_ci#define QLA8044_RESET_TEMPLATE_ADDR	0x4F0000
19762306a36Sopenharmony_ci#define QLA8044_RESET_SEQ_VERSION	0x0101
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* Reset template entry opcodes */
20062306a36Sopenharmony_ci#define OPCODE_NOP			0x0000
20162306a36Sopenharmony_ci#define OPCODE_WRITE_LIST		0x0001
20262306a36Sopenharmony_ci#define OPCODE_READ_WRITE_LIST		0x0002
20362306a36Sopenharmony_ci#define OPCODE_POLL_LIST		0x0004
20462306a36Sopenharmony_ci#define OPCODE_POLL_WRITE_LIST		0x0008
20562306a36Sopenharmony_ci#define OPCODE_READ_MODIFY_WRITE	0x0010
20662306a36Sopenharmony_ci#define OPCODE_SEQ_PAUSE		0x0020
20762306a36Sopenharmony_ci#define OPCODE_SEQ_END			0x0040
20862306a36Sopenharmony_ci#define OPCODE_TMPL_END			0x0080
20962306a36Sopenharmony_ci#define OPCODE_POLL_READ_LIST		0x0100
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci/* Template Header */
21262306a36Sopenharmony_ci#define RESET_TMPLT_HDR_SIGNATURE	0xCAFE
21362306a36Sopenharmony_ci#define QLA8044_IDC_DRV_CTRL            0x3790
21462306a36Sopenharmony_ci#define AF_8044_NO_FW_DUMP              27 /* 0x08000000 */
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#define MINIDUMP_SIZE_36K		36864
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_cistruct qla8044_reset_template_hdr {
21962306a36Sopenharmony_ci	uint16_t	version;
22062306a36Sopenharmony_ci	uint16_t	signature;
22162306a36Sopenharmony_ci	uint16_t	size;
22262306a36Sopenharmony_ci	uint16_t	entries;
22362306a36Sopenharmony_ci	uint16_t	hdr_size;
22462306a36Sopenharmony_ci	uint16_t	checksum;
22562306a36Sopenharmony_ci	uint16_t	init_seq_offset;
22662306a36Sopenharmony_ci	uint16_t	start_seq_offset;
22762306a36Sopenharmony_ci} __packed;
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci/* Common Entry Header. */
23062306a36Sopenharmony_cistruct qla8044_reset_entry_hdr {
23162306a36Sopenharmony_ci	uint16_t cmd;
23262306a36Sopenharmony_ci	uint16_t size;
23362306a36Sopenharmony_ci	uint16_t count;
23462306a36Sopenharmony_ci	uint16_t delay;
23562306a36Sopenharmony_ci} __packed;
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci/* Generic poll entry type. */
23862306a36Sopenharmony_cistruct qla8044_poll {
23962306a36Sopenharmony_ci	uint32_t  test_mask;
24062306a36Sopenharmony_ci	uint32_t  test_value;
24162306a36Sopenharmony_ci} __packed;
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/* Read modify write entry type. */
24462306a36Sopenharmony_cistruct qla8044_rmw {
24562306a36Sopenharmony_ci	uint32_t test_mask;
24662306a36Sopenharmony_ci	uint32_t xor_value;
24762306a36Sopenharmony_ci	uint32_t  or_value;
24862306a36Sopenharmony_ci	uint8_t shl;
24962306a36Sopenharmony_ci	uint8_t shr;
25062306a36Sopenharmony_ci	uint8_t index_a;
25162306a36Sopenharmony_ci	uint8_t rsvd;
25262306a36Sopenharmony_ci} __packed;
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* Generic Entry Item with 2 DWords. */
25562306a36Sopenharmony_cistruct qla8044_entry {
25662306a36Sopenharmony_ci	uint32_t arg1;
25762306a36Sopenharmony_ci	uint32_t arg2;
25862306a36Sopenharmony_ci} __packed;
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci/* Generic Entry Item with 4 DWords.*/
26162306a36Sopenharmony_cistruct qla8044_quad_entry {
26262306a36Sopenharmony_ci	uint32_t dr_addr;
26362306a36Sopenharmony_ci	uint32_t dr_value;
26462306a36Sopenharmony_ci	uint32_t ar_addr;
26562306a36Sopenharmony_ci	uint32_t ar_value;
26662306a36Sopenharmony_ci} __packed;
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_cistruct qla8044_reset_template {
26962306a36Sopenharmony_ci	int seq_index;
27062306a36Sopenharmony_ci	int seq_error;
27162306a36Sopenharmony_ci	int array_index;
27262306a36Sopenharmony_ci	uint32_t array[QLA8044_MAX_RESET_SEQ_ENTRIES];
27362306a36Sopenharmony_ci	uint8_t *buff;
27462306a36Sopenharmony_ci	uint8_t *stop_offset;
27562306a36Sopenharmony_ci	uint8_t *start_offset;
27662306a36Sopenharmony_ci	uint8_t *init_offset;
27762306a36Sopenharmony_ci	struct qla8044_reset_template_hdr *hdr;
27862306a36Sopenharmony_ci	uint8_t seq_end;
27962306a36Sopenharmony_ci	uint8_t template_end;
28062306a36Sopenharmony_ci};
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci/* Driver_code is for driver to write some info about the entry
28362306a36Sopenharmony_ci * currently not used.
28462306a36Sopenharmony_ci */
28562306a36Sopenharmony_cistruct qla8044_minidump_entry_hdr {
28662306a36Sopenharmony_ci	uint32_t entry_type;
28762306a36Sopenharmony_ci	uint32_t entry_size;
28862306a36Sopenharmony_ci	uint32_t entry_capture_size;
28962306a36Sopenharmony_ci	struct {
29062306a36Sopenharmony_ci		uint8_t entry_capture_mask;
29162306a36Sopenharmony_ci		uint8_t entry_code;
29262306a36Sopenharmony_ci		uint8_t driver_code;
29362306a36Sopenharmony_ci		uint8_t driver_flags;
29462306a36Sopenharmony_ci	} d_ctrl;
29562306a36Sopenharmony_ci} __packed;
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci/*  Read CRB entry header */
29862306a36Sopenharmony_cistruct qla8044_minidump_entry_crb {
29962306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
30062306a36Sopenharmony_ci	uint32_t addr;
30162306a36Sopenharmony_ci	struct {
30262306a36Sopenharmony_ci		uint8_t addr_stride;
30362306a36Sopenharmony_ci		uint8_t state_index_a;
30462306a36Sopenharmony_ci		uint16_t poll_timeout;
30562306a36Sopenharmony_ci	} crb_strd;
30662306a36Sopenharmony_ci	uint32_t data_size;
30762306a36Sopenharmony_ci	uint32_t op_count;
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci	struct {
31062306a36Sopenharmony_ci		uint8_t opcode;
31162306a36Sopenharmony_ci		uint8_t state_index_v;
31262306a36Sopenharmony_ci		uint8_t shl;
31362306a36Sopenharmony_ci		uint8_t shr;
31462306a36Sopenharmony_ci	} crb_ctrl;
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci	uint32_t value_1;
31762306a36Sopenharmony_ci	uint32_t value_2;
31862306a36Sopenharmony_ci	uint32_t value_3;
31962306a36Sopenharmony_ci} __packed;
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_cistruct qla8044_minidump_entry_cache {
32262306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
32362306a36Sopenharmony_ci	uint32_t tag_reg_addr;
32462306a36Sopenharmony_ci	struct {
32562306a36Sopenharmony_ci		uint16_t tag_value_stride;
32662306a36Sopenharmony_ci		uint16_t init_tag_value;
32762306a36Sopenharmony_ci	} addr_ctrl;
32862306a36Sopenharmony_ci	uint32_t data_size;
32962306a36Sopenharmony_ci	uint32_t op_count;
33062306a36Sopenharmony_ci	uint32_t control_addr;
33162306a36Sopenharmony_ci	struct {
33262306a36Sopenharmony_ci		uint16_t write_value;
33362306a36Sopenharmony_ci		uint8_t poll_mask;
33462306a36Sopenharmony_ci		uint8_t poll_wait;
33562306a36Sopenharmony_ci	} cache_ctrl;
33662306a36Sopenharmony_ci	uint32_t read_addr;
33762306a36Sopenharmony_ci	struct {
33862306a36Sopenharmony_ci		uint8_t read_addr_stride;
33962306a36Sopenharmony_ci		uint8_t read_addr_cnt;
34062306a36Sopenharmony_ci		uint16_t rsvd_1;
34162306a36Sopenharmony_ci	} read_ctrl;
34262306a36Sopenharmony_ci} __packed;
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci/* Read OCM */
34562306a36Sopenharmony_cistruct qla8044_minidump_entry_rdocm {
34662306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
34762306a36Sopenharmony_ci	uint32_t rsvd_0;
34862306a36Sopenharmony_ci	uint32_t rsvd_1;
34962306a36Sopenharmony_ci	uint32_t data_size;
35062306a36Sopenharmony_ci	uint32_t op_count;
35162306a36Sopenharmony_ci	uint32_t rsvd_2;
35262306a36Sopenharmony_ci	uint32_t rsvd_3;
35362306a36Sopenharmony_ci	uint32_t read_addr;
35462306a36Sopenharmony_ci	uint32_t read_addr_stride;
35562306a36Sopenharmony_ci} __packed;
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci/* Read Memory */
35862306a36Sopenharmony_cistruct qla8044_minidump_entry_rdmem {
35962306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
36062306a36Sopenharmony_ci	uint32_t rsvd[6];
36162306a36Sopenharmony_ci	uint32_t read_addr;
36262306a36Sopenharmony_ci	uint32_t read_data_size;
36362306a36Sopenharmony_ci};
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_ci/* Read Memory: For Pex-DMA */
36662306a36Sopenharmony_cistruct qla8044_minidump_entry_rdmem_pex_dma {
36762306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
36862306a36Sopenharmony_ci	uint32_t desc_card_addr;
36962306a36Sopenharmony_ci	uint16_t dma_desc_cmd;
37062306a36Sopenharmony_ci	uint8_t rsvd[2];
37162306a36Sopenharmony_ci	uint32_t start_dma_cmd;
37262306a36Sopenharmony_ci	uint8_t rsvd2[12];
37362306a36Sopenharmony_ci	uint32_t read_addr;
37462306a36Sopenharmony_ci	uint32_t read_data_size;
37562306a36Sopenharmony_ci} __packed;
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci/* Read ROM */
37862306a36Sopenharmony_cistruct qla8044_minidump_entry_rdrom {
37962306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
38062306a36Sopenharmony_ci	uint32_t rsvd[6];
38162306a36Sopenharmony_ci	uint32_t read_addr;
38262306a36Sopenharmony_ci	uint32_t read_data_size;
38362306a36Sopenharmony_ci} __packed;
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_ci/* Mux entry */
38662306a36Sopenharmony_cistruct qla8044_minidump_entry_mux {
38762306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
38862306a36Sopenharmony_ci	uint32_t select_addr;
38962306a36Sopenharmony_ci	uint32_t rsvd_0;
39062306a36Sopenharmony_ci	uint32_t data_size;
39162306a36Sopenharmony_ci	uint32_t op_count;
39262306a36Sopenharmony_ci	uint32_t select_value;
39362306a36Sopenharmony_ci	uint32_t select_value_stride;
39462306a36Sopenharmony_ci	uint32_t read_addr;
39562306a36Sopenharmony_ci	uint32_t rsvd_1;
39662306a36Sopenharmony_ci} __packed;
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_ci/* Queue entry */
39962306a36Sopenharmony_cistruct qla8044_minidump_entry_queue {
40062306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
40162306a36Sopenharmony_ci	uint32_t select_addr;
40262306a36Sopenharmony_ci	struct {
40362306a36Sopenharmony_ci		uint16_t queue_id_stride;
40462306a36Sopenharmony_ci		uint16_t rsvd_0;
40562306a36Sopenharmony_ci	} q_strd;
40662306a36Sopenharmony_ci	uint32_t data_size;
40762306a36Sopenharmony_ci	uint32_t op_count;
40862306a36Sopenharmony_ci	uint32_t rsvd_1;
40962306a36Sopenharmony_ci	uint32_t rsvd_2;
41062306a36Sopenharmony_ci	uint32_t read_addr;
41162306a36Sopenharmony_ci	struct {
41262306a36Sopenharmony_ci		uint8_t read_addr_stride;
41362306a36Sopenharmony_ci		uint8_t read_addr_cnt;
41462306a36Sopenharmony_ci		uint16_t rsvd_3;
41562306a36Sopenharmony_ci	} rd_strd;
41662306a36Sopenharmony_ci} __packed;
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci/* POLLRD Entry */
41962306a36Sopenharmony_cistruct qla8044_minidump_entry_pollrd {
42062306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
42162306a36Sopenharmony_ci	uint32_t select_addr;
42262306a36Sopenharmony_ci	uint32_t read_addr;
42362306a36Sopenharmony_ci	uint32_t select_value;
42462306a36Sopenharmony_ci	uint16_t select_value_stride;
42562306a36Sopenharmony_ci	uint16_t op_count;
42662306a36Sopenharmony_ci	uint32_t poll_wait;
42762306a36Sopenharmony_ci	uint32_t poll_mask;
42862306a36Sopenharmony_ci	uint32_t data_size;
42962306a36Sopenharmony_ci	uint32_t rsvd_1;
43062306a36Sopenharmony_ci} __packed;
43162306a36Sopenharmony_ci
43262306a36Sopenharmony_cistruct qla8044_minidump_entry_rddfe {
43362306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
43462306a36Sopenharmony_ci	uint32_t addr_1;
43562306a36Sopenharmony_ci	uint32_t value;
43662306a36Sopenharmony_ci	uint8_t stride;
43762306a36Sopenharmony_ci	uint8_t stride2;
43862306a36Sopenharmony_ci	uint16_t count;
43962306a36Sopenharmony_ci	uint32_t poll;
44062306a36Sopenharmony_ci	uint32_t mask;
44162306a36Sopenharmony_ci	uint32_t modify_mask;
44262306a36Sopenharmony_ci	uint32_t data_size;
44362306a36Sopenharmony_ci	uint32_t rsvd;
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci} __packed;
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_cistruct qla8044_minidump_entry_rdmdio {
44862306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci	uint32_t addr_1;
45162306a36Sopenharmony_ci	uint32_t addr_2;
45262306a36Sopenharmony_ci	uint32_t value_1;
45362306a36Sopenharmony_ci	uint8_t stride_1;
45462306a36Sopenharmony_ci	uint8_t stride_2;
45562306a36Sopenharmony_ci	uint16_t count;
45662306a36Sopenharmony_ci	uint32_t poll;
45762306a36Sopenharmony_ci	uint32_t mask;
45862306a36Sopenharmony_ci	uint32_t value_2;
45962306a36Sopenharmony_ci	uint32_t data_size;
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci} __packed;
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_cistruct qla8044_minidump_entry_pollwr {
46462306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
46562306a36Sopenharmony_ci	uint32_t addr_1;
46662306a36Sopenharmony_ci	uint32_t addr_2;
46762306a36Sopenharmony_ci	uint32_t value_1;
46862306a36Sopenharmony_ci	uint32_t value_2;
46962306a36Sopenharmony_ci	uint32_t poll;
47062306a36Sopenharmony_ci	uint32_t mask;
47162306a36Sopenharmony_ci	uint32_t data_size;
47262306a36Sopenharmony_ci	uint32_t rsvd;
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_ci}  __packed;
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci/* RDMUX2 Entry */
47762306a36Sopenharmony_cistruct qla8044_minidump_entry_rdmux2 {
47862306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
47962306a36Sopenharmony_ci	uint32_t select_addr_1;
48062306a36Sopenharmony_ci	uint32_t select_addr_2;
48162306a36Sopenharmony_ci	uint32_t select_value_1;
48262306a36Sopenharmony_ci	uint32_t select_value_2;
48362306a36Sopenharmony_ci	uint32_t op_count;
48462306a36Sopenharmony_ci	uint32_t select_value_mask;
48562306a36Sopenharmony_ci	uint32_t read_addr;
48662306a36Sopenharmony_ci	uint8_t select_value_stride;
48762306a36Sopenharmony_ci	uint8_t data_size;
48862306a36Sopenharmony_ci	uint8_t rsvd[2];
48962306a36Sopenharmony_ci} __packed;
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci/* POLLRDMWR Entry */
49262306a36Sopenharmony_cistruct qla8044_minidump_entry_pollrdmwr {
49362306a36Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
49462306a36Sopenharmony_ci	uint32_t addr_1;
49562306a36Sopenharmony_ci	uint32_t addr_2;
49662306a36Sopenharmony_ci	uint32_t value_1;
49762306a36Sopenharmony_ci	uint32_t value_2;
49862306a36Sopenharmony_ci	uint32_t poll_wait;
49962306a36Sopenharmony_ci	uint32_t poll_mask;
50062306a36Sopenharmony_ci	uint32_t modify_mask;
50162306a36Sopenharmony_ci	uint32_t data_size;
50262306a36Sopenharmony_ci} __packed;
50362306a36Sopenharmony_ci
50462306a36Sopenharmony_ci/* IDC additional information */
50562306a36Sopenharmony_cistruct qla8044_idc_information {
50662306a36Sopenharmony_ci	uint32_t request_desc;  /* IDC request descriptor */
50762306a36Sopenharmony_ci	uint32_t info1; /* IDC additional info */
50862306a36Sopenharmony_ci	uint32_t info2; /* IDC additional info */
50962306a36Sopenharmony_ci	uint32_t info3; /* IDC additional info */
51062306a36Sopenharmony_ci} __packed;
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_cienum qla_regs {
51362306a36Sopenharmony_ci	QLA8044_PEG_HALT_STATUS1_INDEX = 0,
51462306a36Sopenharmony_ci	QLA8044_PEG_HALT_STATUS2_INDEX,
51562306a36Sopenharmony_ci	QLA8044_PEG_ALIVE_COUNTER_INDEX,
51662306a36Sopenharmony_ci	QLA8044_CRB_DRV_ACTIVE_INDEX,
51762306a36Sopenharmony_ci	QLA8044_CRB_DEV_STATE_INDEX,
51862306a36Sopenharmony_ci	QLA8044_CRB_DRV_STATE_INDEX,
51962306a36Sopenharmony_ci	QLA8044_CRB_DRV_SCRATCH_INDEX,
52062306a36Sopenharmony_ci	QLA8044_CRB_DEV_PART_INFO_INDEX,
52162306a36Sopenharmony_ci	QLA8044_CRB_DRV_IDC_VERSION_INDEX,
52262306a36Sopenharmony_ci	QLA8044_FW_VERSION_MAJOR_INDEX,
52362306a36Sopenharmony_ci	QLA8044_FW_VERSION_MINOR_INDEX,
52462306a36Sopenharmony_ci	QLA8044_FW_VERSION_SUB_INDEX,
52562306a36Sopenharmony_ci	QLA8044_CRB_CMDPEG_STATE_INDEX,
52662306a36Sopenharmony_ci	QLA8044_CRB_TEMP_STATE_INDEX,
52762306a36Sopenharmony_ci} __packed;
52862306a36Sopenharmony_ci
52962306a36Sopenharmony_ci#define CRB_REG_INDEX_MAX	14
53062306a36Sopenharmony_ci#define CRB_CMDPEG_CHECK_RETRY_COUNT    60
53162306a36Sopenharmony_ci#define CRB_CMDPEG_CHECK_DELAY          500
53262306a36Sopenharmony_ci
53362306a36Sopenharmony_ci/* MiniDump Structures */
53462306a36Sopenharmony_ci
53562306a36Sopenharmony_ci/* Driver_code is for driver to write some info about the entry
53662306a36Sopenharmony_ci * currently not used.
53762306a36Sopenharmony_ci */
53862306a36Sopenharmony_ci#define QLA8044_SS_OCM_WNDREG_INDEX             3
53962306a36Sopenharmony_ci#define QLA8044_DBG_STATE_ARRAY_LEN             16
54062306a36Sopenharmony_ci#define QLA8044_DBG_CAP_SIZE_ARRAY_LEN          8
54162306a36Sopenharmony_ci#define QLA8044_DBG_RSVD_ARRAY_LEN              8
54262306a36Sopenharmony_ci#define QLA8044_DBG_OCM_WNDREG_ARRAY_LEN        16
54362306a36Sopenharmony_ci#define QLA8044_SS_PCI_INDEX                    0
54462306a36Sopenharmony_ci#define QLA8044_RDDFE          38
54562306a36Sopenharmony_ci#define QLA8044_RDMDIO         39
54662306a36Sopenharmony_ci#define QLA8044_POLLWR         40
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_cistruct qla8044_minidump_template_hdr {
54962306a36Sopenharmony_ci	uint32_t entry_type;
55062306a36Sopenharmony_ci	uint32_t first_entry_offset;
55162306a36Sopenharmony_ci	uint32_t size_of_template;
55262306a36Sopenharmony_ci	uint32_t capture_debug_level;
55362306a36Sopenharmony_ci	uint32_t num_of_entries;
55462306a36Sopenharmony_ci	uint32_t version;
55562306a36Sopenharmony_ci	uint32_t driver_timestamp;
55662306a36Sopenharmony_ci	uint32_t checksum;
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_ci	uint32_t driver_capture_mask;
55962306a36Sopenharmony_ci	uint32_t driver_info_word2;
56062306a36Sopenharmony_ci	uint32_t driver_info_word3;
56162306a36Sopenharmony_ci	uint32_t driver_info_word4;
56262306a36Sopenharmony_ci
56362306a36Sopenharmony_ci	uint32_t saved_state_array[QLA8044_DBG_STATE_ARRAY_LEN];
56462306a36Sopenharmony_ci	uint32_t capture_size_array[QLA8044_DBG_CAP_SIZE_ARRAY_LEN];
56562306a36Sopenharmony_ci	uint32_t ocm_window_reg[QLA8044_DBG_OCM_WNDREG_ARRAY_LEN];
56662306a36Sopenharmony_ci};
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_cistruct qla8044_pex_dma_descriptor {
56962306a36Sopenharmony_ci	struct {
57062306a36Sopenharmony_ci		uint32_t read_data_size; /* 0-23: size, 24-31: rsvd */
57162306a36Sopenharmony_ci		uint8_t rsvd[2];
57262306a36Sopenharmony_ci		uint16_t dma_desc_cmd;
57362306a36Sopenharmony_ci	} cmd;
57462306a36Sopenharmony_ci	uint64_t src_addr;
57562306a36Sopenharmony_ci	uint64_t dma_bus_addr; /*0-3: desc-cmd, 4-7: pci-func, 8-15: desc-cmd*/
57662306a36Sopenharmony_ci	uint8_t rsvd[24];
57762306a36Sopenharmony_ci} __packed;
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_ci#endif
580