18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic Fibre Channel HBA Driver
48c2ecf20Sopenharmony_ci * Copyright (c)  2003-2014 QLogic Corporation
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __QLA_NX2_H
88c2ecf20Sopenharmony_ci#define __QLA_NX2_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define QSNT_ACK_TOV				30
118c2ecf20Sopenharmony_ci#define INTENT_TO_RECOVER			0x01
128c2ecf20Sopenharmony_ci#define PROCEED_TO_RECOVER			0x02
138c2ecf20Sopenharmony_ci#define IDC_LOCK_RECOVERY_OWNER_MASK		0x3C
148c2ecf20Sopenharmony_ci#define IDC_LOCK_RECOVERY_STATE_MASK		0x3
158c2ecf20Sopenharmony_ci#define IDC_LOCK_RECOVERY_STATE_SHIFT_BITS	2
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define QLA8044_DRV_LOCK_MSLEEP		200
188c2ecf20Sopenharmony_ci#define QLA8044_ADDR_DDR_NET		(0x0000000000000000ULL)
198c2ecf20Sopenharmony_ci#define QLA8044_ADDR_DDR_NET_MAX	(0x000000000fffffffULL)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_LO		0x410000A0
228c2ecf20Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_HI		0x410000A4
238c2ecf20Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_ULO		0x410000B0
248c2ecf20Sopenharmony_ci#define MD_MIU_TEST_AGT_WRDATA_UHI		0x410000B4
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* MIU_TEST_AGT_CTRL flags. work for SIU as well */
278c2ecf20Sopenharmony_ci#define MIU_TA_CTL_WRITE_ENABLE	(MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE)
288c2ecf20Sopenharmony_ci#define MIU_TA_CTL_WRITE_START	(MIU_TA_CTL_WRITE | MIU_TA_CTL_ENABLE |	\
298c2ecf20Sopenharmony_ci				 MIU_TA_CTL_START)
308c2ecf20Sopenharmony_ci#define MIU_TA_CTL_START_ENABLE	(MIU_TA_CTL_START | MIU_TA_CTL_ENABLE)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Imbus address bit used to indicate a host address. This bit is
338c2ecf20Sopenharmony_ci * eliminated by the pcie bar and bar select before presentation
348c2ecf20Sopenharmony_ci * over pcie. */
358c2ecf20Sopenharmony_ci/* host memory via IMBUS */
368c2ecf20Sopenharmony_ci#define QLA8044_P2_ADDR_PCIE	(0x0000000800000000ULL)
378c2ecf20Sopenharmony_ci#define QLA8044_P3_ADDR_PCIE	(0x0000008000000000ULL)
388c2ecf20Sopenharmony_ci#define QLA8044_ADDR_PCIE_MAX	(0x0000000FFFFFFFFFULL)
398c2ecf20Sopenharmony_ci#define QLA8044_ADDR_OCM0	(0x0000000200000000ULL)
408c2ecf20Sopenharmony_ci#define QLA8044_ADDR_OCM0_MAX	(0x00000002000fffffULL)
418c2ecf20Sopenharmony_ci#define QLA8044_ADDR_OCM1	(0x0000000200400000ULL)
428c2ecf20Sopenharmony_ci#define QLA8044_ADDR_OCM1_MAX	(0x00000002004fffffULL)
438c2ecf20Sopenharmony_ci#define QLA8044_ADDR_QDR_NET	(0x0000000300000000ULL)
448c2ecf20Sopenharmony_ci#define QLA8044_P2_ADDR_QDR_NET_MAX	(0x00000003001fffffULL)
458c2ecf20Sopenharmony_ci#define QLA8044_P3_ADDR_QDR_NET_MAX	(0x0000000303ffffffULL)
468c2ecf20Sopenharmony_ci#define QLA8044_ADDR_QDR_NET_MAX	(0x0000000307ffffffULL)
478c2ecf20Sopenharmony_ci#define QLA8044_PCI_CRBSPACE		((unsigned long)0x06000000)
488c2ecf20Sopenharmony_ci#define QLA8044_PCI_DIRECT_CRB		((unsigned long)0x04400000)
498c2ecf20Sopenharmony_ci#define QLA8044_PCI_CAMQM		((unsigned long)0x04800000)
508c2ecf20Sopenharmony_ci#define QLA8044_PCI_CAMQM_MAX		((unsigned long)0x04ffffff)
518c2ecf20Sopenharmony_ci#define QLA8044_PCI_DDR_NET		((unsigned long)0x00000000)
528c2ecf20Sopenharmony_ci#define QLA8044_PCI_QDR_NET		((unsigned long)0x04000000)
538c2ecf20Sopenharmony_ci#define QLA8044_PCI_QDR_NET_MAX		((unsigned long)0x043fffff)
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/*  PCI Windowing for DDR regions.  */
568c2ecf20Sopenharmony_cistatic inline bool addr_in_range(u64 addr, u64 low, u64 high)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	return addr <= high && addr >= low;
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Indirectly Mapped Registers */
628c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SPI_STATUS	0x2808E010
638c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SPI_CONTROL	0x2808E014
648c2ecf20Sopenharmony_ci#define QLA8044_FLASH_STATUS		0x42100004
658c2ecf20Sopenharmony_ci#define QLA8044_FLASH_CONTROL		0x42110004
668c2ecf20Sopenharmony_ci#define QLA8044_FLASH_ADDR		0x42110008
678c2ecf20Sopenharmony_ci#define QLA8044_FLASH_WRDATA		0x4211000C
688c2ecf20Sopenharmony_ci#define QLA8044_FLASH_RDDATA		0x42110018
698c2ecf20Sopenharmony_ci#define QLA8044_FLASH_DIRECT_WINDOW	0x42110030
708c2ecf20Sopenharmony_ci#define QLA8044_FLASH_DIRECT_DATA(DATA) (0x42150000 | (0x0000FFFF&DATA))
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Flash access regs */
738c2ecf20Sopenharmony_ci#define QLA8044_FLASH_LOCK		0x3850
748c2ecf20Sopenharmony_ci#define QLA8044_FLASH_UNLOCK		0x3854
758c2ecf20Sopenharmony_ci#define QLA8044_FLASH_LOCK_ID		0x3500
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* Driver Lock regs */
788c2ecf20Sopenharmony_ci#define QLA8044_DRV_LOCK		0x3868
798c2ecf20Sopenharmony_ci#define QLA8044_DRV_UNLOCK		0x386C
808c2ecf20Sopenharmony_ci#define QLA8044_DRV_LOCK_ID		0x3504
818c2ecf20Sopenharmony_ci#define QLA8044_DRV_LOCKRECOVERY	0x379C
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* IDC version */
848c2ecf20Sopenharmony_ci#define QLA8044_IDC_VER_MAJ_VALUE       0x1
858c2ecf20Sopenharmony_ci#define QLA8044_IDC_VER_MIN_VALUE       0x0
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/* IDC Registers : Driver Coexistence Defines */
888c2ecf20Sopenharmony_ci#define QLA8044_CRB_IDC_VER_MAJOR	0x3780
898c2ecf20Sopenharmony_ci#define QLA8044_CRB_IDC_VER_MINOR	0x3798
908c2ecf20Sopenharmony_ci#define QLA8044_IDC_DRV_AUDIT		0x3794
918c2ecf20Sopenharmony_ci#define QLA8044_SRE_SHIM_CONTROL	0x0D200284
928c2ecf20Sopenharmony_ci#define QLA8044_PORT0_RXB_PAUSE_THRS	0x0B2003A4
938c2ecf20Sopenharmony_ci#define QLA8044_PORT1_RXB_PAUSE_THRS	0x0B2013A4
948c2ecf20Sopenharmony_ci#define QLA8044_PORT0_RXB_TC_MAX_CELL	0x0B200388
958c2ecf20Sopenharmony_ci#define QLA8044_PORT1_RXB_TC_MAX_CELL	0x0B201388
968c2ecf20Sopenharmony_ci#define QLA8044_PORT0_RXB_TC_STATS	0x0B20039C
978c2ecf20Sopenharmony_ci#define QLA8044_PORT1_RXB_TC_STATS	0x0B20139C
988c2ecf20Sopenharmony_ci#define QLA8044_PORT2_IFB_PAUSE_THRS	0x0B200704
998c2ecf20Sopenharmony_ci#define QLA8044_PORT3_IFB_PAUSE_THRS	0x0B201704
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* set value to pause threshold value */
1028c2ecf20Sopenharmony_ci#define QLA8044_SET_PAUSE_VAL		0x0
1038c2ecf20Sopenharmony_ci#define QLA8044_SET_TC_MAX_CELL_VAL	0x03FF03FF
1048c2ecf20Sopenharmony_ci#define QLA8044_PEG_HALT_STATUS1	0x34A8
1058c2ecf20Sopenharmony_ci#define QLA8044_PEG_HALT_STATUS2	0x34AC
1068c2ecf20Sopenharmony_ci#define QLA8044_PEG_ALIVE_COUNTER	0x34B0 /* FW_HEARTBEAT */
1078c2ecf20Sopenharmony_ci#define QLA8044_FW_CAPABILITIES		0x3528
1088c2ecf20Sopenharmony_ci#define QLA8044_CRB_DRV_ACTIVE		0x3788 /* IDC_DRV_PRESENCE */
1098c2ecf20Sopenharmony_ci#define QLA8044_CRB_DEV_STATE		0x3784 /* IDC_DEV_STATE */
1108c2ecf20Sopenharmony_ci#define QLA8044_CRB_DRV_STATE		0x378C /* IDC_DRV_ACK */
1118c2ecf20Sopenharmony_ci#define QLA8044_CRB_DRV_SCRATCH		0x3548
1128c2ecf20Sopenharmony_ci#define QLA8044_CRB_DEV_PART_INFO1	0x37E0
1138c2ecf20Sopenharmony_ci#define QLA8044_CRB_DEV_PART_INFO2	0x37E4
1148c2ecf20Sopenharmony_ci#define QLA8044_FW_VER_MAJOR		0x3550
1158c2ecf20Sopenharmony_ci#define QLA8044_FW_VER_MINOR		0x3554
1168c2ecf20Sopenharmony_ci#define QLA8044_FW_VER_SUB		0x3558
1178c2ecf20Sopenharmony_ci#define QLA8044_NPAR_STATE		0x359C
1188c2ecf20Sopenharmony_ci#define QLA8044_FW_IMAGE_VALID		0x35FC
1198c2ecf20Sopenharmony_ci#define QLA8044_CMDPEG_STATE		0x3650
1208c2ecf20Sopenharmony_ci#define QLA8044_ASIC_TEMP		0x37B4
1218c2ecf20Sopenharmony_ci#define QLA8044_FW_API			0x356C
1228c2ecf20Sopenharmony_ci#define QLA8044_DRV_OP_MODE		0x3570
1238c2ecf20Sopenharmony_ci#define QLA8044_CRB_WIN_BASE		0x3800
1248c2ecf20Sopenharmony_ci#define QLA8044_CRB_WIN_FUNC(f)		(QLA8044_CRB_WIN_BASE+((f)*4))
1258c2ecf20Sopenharmony_ci#define QLA8044_SEM_LOCK_BASE		0x3840
1268c2ecf20Sopenharmony_ci#define QLA8044_SEM_UNLOCK_BASE		0x3844
1278c2ecf20Sopenharmony_ci#define QLA8044_SEM_LOCK_FUNC(f)	(QLA8044_SEM_LOCK_BASE+((f)*8))
1288c2ecf20Sopenharmony_ci#define QLA8044_SEM_UNLOCK_FUNC(f)	(QLA8044_SEM_UNLOCK_BASE+((f)*8))
1298c2ecf20Sopenharmony_ci#define QLA8044_LINK_STATE(f)		(0x3698+((f) > 7 ? 4 : 0))
1308c2ecf20Sopenharmony_ci#define QLA8044_LINK_SPEED(f)		(0x36E0+(((f) >> 2) * 4))
1318c2ecf20Sopenharmony_ci#define QLA8044_MAX_LINK_SPEED(f)       (0x36F0+(((f) / 4) * 4))
1328c2ecf20Sopenharmony_ci#define QLA8044_LINK_SPEED_FACTOR	10
1338c2ecf20Sopenharmony_ci#define QLA8044_FUN7_ACTIVE_INDEX	0x80
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* FLASH API Defines */
1368c2ecf20Sopenharmony_ci#define QLA8044_FLASH_MAX_WAIT_USEC	100
1378c2ecf20Sopenharmony_ci#define QLA8044_FLASH_LOCK_TIMEOUT	10000
1388c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SECTOR_SIZE	65536
1398c2ecf20Sopenharmony_ci#define QLA8044_DRV_LOCK_TIMEOUT	2000
1408c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SECTOR_ERASE_CMD	0xdeadbeef
1418c2ecf20Sopenharmony_ci#define QLA8044_FLASH_WRITE_CMD		0xdacdacda
1428c2ecf20Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_CMD	0xcadcadca
1438c2ecf20Sopenharmony_ci#define QLA8044_FLASH_READ_RETRY_COUNT	2000
1448c2ecf20Sopenharmony_ci#define QLA8044_FLASH_STATUS_READY	0x6
1458c2ecf20Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_MIN	2
1468c2ecf20Sopenharmony_ci#define QLA8044_FLASH_BUFFER_WRITE_MAX	64
1478c2ecf20Sopenharmony_ci#define QLA8044_FLASH_STATUS_REG_POLL_DELAY 1
1488c2ecf20Sopenharmony_ci#define QLA8044_ERASE_MODE		1
1498c2ecf20Sopenharmony_ci#define QLA8044_WRITE_MODE		2
1508c2ecf20Sopenharmony_ci#define QLA8044_DWORD_WRITE_MODE	3
1518c2ecf20Sopenharmony_ci#define QLA8044_GLOBAL_RESET		0x38CC
1528c2ecf20Sopenharmony_ci#define QLA8044_WILDCARD		0x38F0
1538c2ecf20Sopenharmony_ci#define QLA8044_INFORMANT		0x38FC
1548c2ecf20Sopenharmony_ci#define QLA8044_HOST_MBX_CTRL		0x3038
1558c2ecf20Sopenharmony_ci#define QLA8044_FW_MBX_CTRL		0x303C
1568c2ecf20Sopenharmony_ci#define QLA8044_BOOTLOADER_ADDR		0x355C
1578c2ecf20Sopenharmony_ci#define QLA8044_BOOTLOADER_SIZE		0x3560
1588c2ecf20Sopenharmony_ci#define QLA8044_FW_IMAGE_ADDR		0x3564
1598c2ecf20Sopenharmony_ci#define QLA8044_MBX_INTR_ENABLE		0x1000
1608c2ecf20Sopenharmony_ci#define QLA8044_MBX_INTR_MASK		0x1200
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/* IDC Control Register bit defines */
1638c2ecf20Sopenharmony_ci#define DONTRESET_BIT0		0x1
1648c2ecf20Sopenharmony_ci#define GRACEFUL_RESET_BIT1	0x2
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/* ISP8044 PEG_HALT_STATUS1 bits */
1678c2ecf20Sopenharmony_ci#define QLA8044_HALT_STATUS_INFORMATIONAL (0x1 << 29)
1688c2ecf20Sopenharmony_ci#define QLA8044_HALT_STATUS_FW_RESET	  (0x2 << 29)
1698c2ecf20Sopenharmony_ci#define QLA8044_HALT_STATUS_UNRECOVERABLE (0x4 << 29)
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/* Firmware image definitions */
1728c2ecf20Sopenharmony_ci#define QLA8044_BOOTLOADER_FLASH_ADDR	0x10000
1738c2ecf20Sopenharmony_ci#define QLA8044_BOOT_FROM_FLASH		0
1748c2ecf20Sopenharmony_ci#define QLA8044_IDC_PARAM_ADDR		0x3e8020
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci/* FLASH related definitions */
1778c2ecf20Sopenharmony_ci#define QLA8044_OPTROM_BURST_SIZE		0x100
1788c2ecf20Sopenharmony_ci#define QLA8044_MAX_OPTROM_BURST_DWORDS		(QLA8044_OPTROM_BURST_SIZE / 4)
1798c2ecf20Sopenharmony_ci#define QLA8044_MIN_OPTROM_BURST_DWORDS		2
1808c2ecf20Sopenharmony_ci#define QLA8044_SECTOR_SIZE			(64 * 1024)
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SPI_CTL			0x4
1838c2ecf20Sopenharmony_ci#define QLA8044_FLASH_FIRST_TEMP_VAL		0x00800000
1848c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SECOND_TEMP_VAL		0x00800001
1858c2ecf20Sopenharmony_ci#define QLA8044_FLASH_FIRST_MS_PATTERN		0x43
1868c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SECOND_MS_PATTERN		0x7F
1878c2ecf20Sopenharmony_ci#define QLA8044_FLASH_LAST_MS_PATTERN		0x7D
1888c2ecf20Sopenharmony_ci#define QLA8044_FLASH_STATUS_WRITE_DEF_SIG	0xFD0100
1898c2ecf20Sopenharmony_ci#define QLA8044_FLASH_SECOND_ERASE_MS_VAL	0x5
1908c2ecf20Sopenharmony_ci#define QLA8044_FLASH_ERASE_SIG			0xFD0300
1918c2ecf20Sopenharmony_ci#define QLA8044_FLASH_LAST_ERASE_MS_VAL		0x3D
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci/* Reset template definitions */
1948c2ecf20Sopenharmony_ci#define QLA8044_MAX_RESET_SEQ_ENTRIES	16
1958c2ecf20Sopenharmony_ci#define QLA8044_RESTART_TEMPLATE_SIZE	0x2000
1968c2ecf20Sopenharmony_ci#define QLA8044_RESET_TEMPLATE_ADDR	0x4F0000
1978c2ecf20Sopenharmony_ci#define QLA8044_RESET_SEQ_VERSION	0x0101
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* Reset template entry opcodes */
2008c2ecf20Sopenharmony_ci#define OPCODE_NOP			0x0000
2018c2ecf20Sopenharmony_ci#define OPCODE_WRITE_LIST		0x0001
2028c2ecf20Sopenharmony_ci#define OPCODE_READ_WRITE_LIST		0x0002
2038c2ecf20Sopenharmony_ci#define OPCODE_POLL_LIST		0x0004
2048c2ecf20Sopenharmony_ci#define OPCODE_POLL_WRITE_LIST		0x0008
2058c2ecf20Sopenharmony_ci#define OPCODE_READ_MODIFY_WRITE	0x0010
2068c2ecf20Sopenharmony_ci#define OPCODE_SEQ_PAUSE		0x0020
2078c2ecf20Sopenharmony_ci#define OPCODE_SEQ_END			0x0040
2088c2ecf20Sopenharmony_ci#define OPCODE_TMPL_END			0x0080
2098c2ecf20Sopenharmony_ci#define OPCODE_POLL_READ_LIST		0x0100
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/* Template Header */
2128c2ecf20Sopenharmony_ci#define RESET_TMPLT_HDR_SIGNATURE	0xCAFE
2138c2ecf20Sopenharmony_ci#define QLA8044_IDC_DRV_CTRL            0x3790
2148c2ecf20Sopenharmony_ci#define AF_8044_NO_FW_DUMP              27 /* 0x08000000 */
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci#define MINIDUMP_SIZE_36K		36864
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistruct qla8044_reset_template_hdr {
2198c2ecf20Sopenharmony_ci	uint16_t	version;
2208c2ecf20Sopenharmony_ci	uint16_t	signature;
2218c2ecf20Sopenharmony_ci	uint16_t	size;
2228c2ecf20Sopenharmony_ci	uint16_t	entries;
2238c2ecf20Sopenharmony_ci	uint16_t	hdr_size;
2248c2ecf20Sopenharmony_ci	uint16_t	checksum;
2258c2ecf20Sopenharmony_ci	uint16_t	init_seq_offset;
2268c2ecf20Sopenharmony_ci	uint16_t	start_seq_offset;
2278c2ecf20Sopenharmony_ci} __packed;
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/* Common Entry Header. */
2308c2ecf20Sopenharmony_cistruct qla8044_reset_entry_hdr {
2318c2ecf20Sopenharmony_ci	uint16_t cmd;
2328c2ecf20Sopenharmony_ci	uint16_t size;
2338c2ecf20Sopenharmony_ci	uint16_t count;
2348c2ecf20Sopenharmony_ci	uint16_t delay;
2358c2ecf20Sopenharmony_ci} __packed;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci/* Generic poll entry type. */
2388c2ecf20Sopenharmony_cistruct qla8044_poll {
2398c2ecf20Sopenharmony_ci	uint32_t  test_mask;
2408c2ecf20Sopenharmony_ci	uint32_t  test_value;
2418c2ecf20Sopenharmony_ci} __packed;
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/* Read modify write entry type. */
2448c2ecf20Sopenharmony_cistruct qla8044_rmw {
2458c2ecf20Sopenharmony_ci	uint32_t test_mask;
2468c2ecf20Sopenharmony_ci	uint32_t xor_value;
2478c2ecf20Sopenharmony_ci	uint32_t  or_value;
2488c2ecf20Sopenharmony_ci	uint8_t shl;
2498c2ecf20Sopenharmony_ci	uint8_t shr;
2508c2ecf20Sopenharmony_ci	uint8_t index_a;
2518c2ecf20Sopenharmony_ci	uint8_t rsvd;
2528c2ecf20Sopenharmony_ci} __packed;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/* Generic Entry Item with 2 DWords. */
2558c2ecf20Sopenharmony_cistruct qla8044_entry {
2568c2ecf20Sopenharmony_ci	uint32_t arg1;
2578c2ecf20Sopenharmony_ci	uint32_t arg2;
2588c2ecf20Sopenharmony_ci} __packed;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci/* Generic Entry Item with 4 DWords.*/
2618c2ecf20Sopenharmony_cistruct qla8044_quad_entry {
2628c2ecf20Sopenharmony_ci	uint32_t dr_addr;
2638c2ecf20Sopenharmony_ci	uint32_t dr_value;
2648c2ecf20Sopenharmony_ci	uint32_t ar_addr;
2658c2ecf20Sopenharmony_ci	uint32_t ar_value;
2668c2ecf20Sopenharmony_ci} __packed;
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cistruct qla8044_reset_template {
2698c2ecf20Sopenharmony_ci	int seq_index;
2708c2ecf20Sopenharmony_ci	int seq_error;
2718c2ecf20Sopenharmony_ci	int array_index;
2728c2ecf20Sopenharmony_ci	uint32_t array[QLA8044_MAX_RESET_SEQ_ENTRIES];
2738c2ecf20Sopenharmony_ci	uint8_t *buff;
2748c2ecf20Sopenharmony_ci	uint8_t *stop_offset;
2758c2ecf20Sopenharmony_ci	uint8_t *start_offset;
2768c2ecf20Sopenharmony_ci	uint8_t *init_offset;
2778c2ecf20Sopenharmony_ci	struct qla8044_reset_template_hdr *hdr;
2788c2ecf20Sopenharmony_ci	uint8_t seq_end;
2798c2ecf20Sopenharmony_ci	uint8_t template_end;
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/* Driver_code is for driver to write some info about the entry
2838c2ecf20Sopenharmony_ci * currently not used.
2848c2ecf20Sopenharmony_ci */
2858c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_hdr {
2868c2ecf20Sopenharmony_ci	uint32_t entry_type;
2878c2ecf20Sopenharmony_ci	uint32_t entry_size;
2888c2ecf20Sopenharmony_ci	uint32_t entry_capture_size;
2898c2ecf20Sopenharmony_ci	struct {
2908c2ecf20Sopenharmony_ci		uint8_t entry_capture_mask;
2918c2ecf20Sopenharmony_ci		uint8_t entry_code;
2928c2ecf20Sopenharmony_ci		uint8_t driver_code;
2938c2ecf20Sopenharmony_ci		uint8_t driver_flags;
2948c2ecf20Sopenharmony_ci	} d_ctrl;
2958c2ecf20Sopenharmony_ci} __packed;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci/*  Read CRB entry header */
2988c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_crb {
2998c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3008c2ecf20Sopenharmony_ci	uint32_t addr;
3018c2ecf20Sopenharmony_ci	struct {
3028c2ecf20Sopenharmony_ci		uint8_t addr_stride;
3038c2ecf20Sopenharmony_ci		uint8_t state_index_a;
3048c2ecf20Sopenharmony_ci		uint16_t poll_timeout;
3058c2ecf20Sopenharmony_ci	} crb_strd;
3068c2ecf20Sopenharmony_ci	uint32_t data_size;
3078c2ecf20Sopenharmony_ci	uint32_t op_count;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	struct {
3108c2ecf20Sopenharmony_ci		uint8_t opcode;
3118c2ecf20Sopenharmony_ci		uint8_t state_index_v;
3128c2ecf20Sopenharmony_ci		uint8_t shl;
3138c2ecf20Sopenharmony_ci		uint8_t shr;
3148c2ecf20Sopenharmony_ci	} crb_ctrl;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	uint32_t value_1;
3178c2ecf20Sopenharmony_ci	uint32_t value_2;
3188c2ecf20Sopenharmony_ci	uint32_t value_3;
3198c2ecf20Sopenharmony_ci} __packed;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_cache {
3228c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3238c2ecf20Sopenharmony_ci	uint32_t tag_reg_addr;
3248c2ecf20Sopenharmony_ci	struct {
3258c2ecf20Sopenharmony_ci		uint16_t tag_value_stride;
3268c2ecf20Sopenharmony_ci		uint16_t init_tag_value;
3278c2ecf20Sopenharmony_ci	} addr_ctrl;
3288c2ecf20Sopenharmony_ci	uint32_t data_size;
3298c2ecf20Sopenharmony_ci	uint32_t op_count;
3308c2ecf20Sopenharmony_ci	uint32_t control_addr;
3318c2ecf20Sopenharmony_ci	struct {
3328c2ecf20Sopenharmony_ci		uint16_t write_value;
3338c2ecf20Sopenharmony_ci		uint8_t poll_mask;
3348c2ecf20Sopenharmony_ci		uint8_t poll_wait;
3358c2ecf20Sopenharmony_ci	} cache_ctrl;
3368c2ecf20Sopenharmony_ci	uint32_t read_addr;
3378c2ecf20Sopenharmony_ci	struct {
3388c2ecf20Sopenharmony_ci		uint8_t read_addr_stride;
3398c2ecf20Sopenharmony_ci		uint8_t read_addr_cnt;
3408c2ecf20Sopenharmony_ci		uint16_t rsvd_1;
3418c2ecf20Sopenharmony_ci	} read_ctrl;
3428c2ecf20Sopenharmony_ci} __packed;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci/* Read OCM */
3458c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdocm {
3468c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3478c2ecf20Sopenharmony_ci	uint32_t rsvd_0;
3488c2ecf20Sopenharmony_ci	uint32_t rsvd_1;
3498c2ecf20Sopenharmony_ci	uint32_t data_size;
3508c2ecf20Sopenharmony_ci	uint32_t op_count;
3518c2ecf20Sopenharmony_ci	uint32_t rsvd_2;
3528c2ecf20Sopenharmony_ci	uint32_t rsvd_3;
3538c2ecf20Sopenharmony_ci	uint32_t read_addr;
3548c2ecf20Sopenharmony_ci	uint32_t read_addr_stride;
3558c2ecf20Sopenharmony_ci} __packed;
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/* Read Memory */
3588c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdmem {
3598c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3608c2ecf20Sopenharmony_ci	uint32_t rsvd[6];
3618c2ecf20Sopenharmony_ci	uint32_t read_addr;
3628c2ecf20Sopenharmony_ci	uint32_t read_data_size;
3638c2ecf20Sopenharmony_ci};
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci/* Read Memory: For Pex-DMA */
3668c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdmem_pex_dma {
3678c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3688c2ecf20Sopenharmony_ci	uint32_t desc_card_addr;
3698c2ecf20Sopenharmony_ci	uint16_t dma_desc_cmd;
3708c2ecf20Sopenharmony_ci	uint8_t rsvd[2];
3718c2ecf20Sopenharmony_ci	uint32_t start_dma_cmd;
3728c2ecf20Sopenharmony_ci	uint8_t rsvd2[12];
3738c2ecf20Sopenharmony_ci	uint32_t read_addr;
3748c2ecf20Sopenharmony_ci	uint32_t read_data_size;
3758c2ecf20Sopenharmony_ci} __packed;
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci/* Read ROM */
3788c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdrom {
3798c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3808c2ecf20Sopenharmony_ci	uint32_t rsvd[6];
3818c2ecf20Sopenharmony_ci	uint32_t read_addr;
3828c2ecf20Sopenharmony_ci	uint32_t read_data_size;
3838c2ecf20Sopenharmony_ci} __packed;
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci/* Mux entry */
3868c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_mux {
3878c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
3888c2ecf20Sopenharmony_ci	uint32_t select_addr;
3898c2ecf20Sopenharmony_ci	uint32_t rsvd_0;
3908c2ecf20Sopenharmony_ci	uint32_t data_size;
3918c2ecf20Sopenharmony_ci	uint32_t op_count;
3928c2ecf20Sopenharmony_ci	uint32_t select_value;
3938c2ecf20Sopenharmony_ci	uint32_t select_value_stride;
3948c2ecf20Sopenharmony_ci	uint32_t read_addr;
3958c2ecf20Sopenharmony_ci	uint32_t rsvd_1;
3968c2ecf20Sopenharmony_ci} __packed;
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci/* Queue entry */
3998c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_queue {
4008c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4018c2ecf20Sopenharmony_ci	uint32_t select_addr;
4028c2ecf20Sopenharmony_ci	struct {
4038c2ecf20Sopenharmony_ci		uint16_t queue_id_stride;
4048c2ecf20Sopenharmony_ci		uint16_t rsvd_0;
4058c2ecf20Sopenharmony_ci	} q_strd;
4068c2ecf20Sopenharmony_ci	uint32_t data_size;
4078c2ecf20Sopenharmony_ci	uint32_t op_count;
4088c2ecf20Sopenharmony_ci	uint32_t rsvd_1;
4098c2ecf20Sopenharmony_ci	uint32_t rsvd_2;
4108c2ecf20Sopenharmony_ci	uint32_t read_addr;
4118c2ecf20Sopenharmony_ci	struct {
4128c2ecf20Sopenharmony_ci		uint8_t read_addr_stride;
4138c2ecf20Sopenharmony_ci		uint8_t read_addr_cnt;
4148c2ecf20Sopenharmony_ci		uint16_t rsvd_3;
4158c2ecf20Sopenharmony_ci	} rd_strd;
4168c2ecf20Sopenharmony_ci} __packed;
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci/* POLLRD Entry */
4198c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_pollrd {
4208c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4218c2ecf20Sopenharmony_ci	uint32_t select_addr;
4228c2ecf20Sopenharmony_ci	uint32_t read_addr;
4238c2ecf20Sopenharmony_ci	uint32_t select_value;
4248c2ecf20Sopenharmony_ci	uint16_t select_value_stride;
4258c2ecf20Sopenharmony_ci	uint16_t op_count;
4268c2ecf20Sopenharmony_ci	uint32_t poll_wait;
4278c2ecf20Sopenharmony_ci	uint32_t poll_mask;
4288c2ecf20Sopenharmony_ci	uint32_t data_size;
4298c2ecf20Sopenharmony_ci	uint32_t rsvd_1;
4308c2ecf20Sopenharmony_ci} __packed;
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rddfe {
4338c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4348c2ecf20Sopenharmony_ci	uint32_t addr_1;
4358c2ecf20Sopenharmony_ci	uint32_t value;
4368c2ecf20Sopenharmony_ci	uint8_t stride;
4378c2ecf20Sopenharmony_ci	uint8_t stride2;
4388c2ecf20Sopenharmony_ci	uint16_t count;
4398c2ecf20Sopenharmony_ci	uint32_t poll;
4408c2ecf20Sopenharmony_ci	uint32_t mask;
4418c2ecf20Sopenharmony_ci	uint32_t modify_mask;
4428c2ecf20Sopenharmony_ci	uint32_t data_size;
4438c2ecf20Sopenharmony_ci	uint32_t rsvd;
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci} __packed;
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdmdio {
4488c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci	uint32_t addr_1;
4518c2ecf20Sopenharmony_ci	uint32_t addr_2;
4528c2ecf20Sopenharmony_ci	uint32_t value_1;
4538c2ecf20Sopenharmony_ci	uint8_t stride_1;
4548c2ecf20Sopenharmony_ci	uint8_t stride_2;
4558c2ecf20Sopenharmony_ci	uint16_t count;
4568c2ecf20Sopenharmony_ci	uint32_t poll;
4578c2ecf20Sopenharmony_ci	uint32_t mask;
4588c2ecf20Sopenharmony_ci	uint32_t value_2;
4598c2ecf20Sopenharmony_ci	uint32_t data_size;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci} __packed;
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_pollwr {
4648c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4658c2ecf20Sopenharmony_ci	uint32_t addr_1;
4668c2ecf20Sopenharmony_ci	uint32_t addr_2;
4678c2ecf20Sopenharmony_ci	uint32_t value_1;
4688c2ecf20Sopenharmony_ci	uint32_t value_2;
4698c2ecf20Sopenharmony_ci	uint32_t poll;
4708c2ecf20Sopenharmony_ci	uint32_t mask;
4718c2ecf20Sopenharmony_ci	uint32_t data_size;
4728c2ecf20Sopenharmony_ci	uint32_t rsvd;
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci}  __packed;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci/* RDMUX2 Entry */
4778c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_rdmux2 {
4788c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4798c2ecf20Sopenharmony_ci	uint32_t select_addr_1;
4808c2ecf20Sopenharmony_ci	uint32_t select_addr_2;
4818c2ecf20Sopenharmony_ci	uint32_t select_value_1;
4828c2ecf20Sopenharmony_ci	uint32_t select_value_2;
4838c2ecf20Sopenharmony_ci	uint32_t op_count;
4848c2ecf20Sopenharmony_ci	uint32_t select_value_mask;
4858c2ecf20Sopenharmony_ci	uint32_t read_addr;
4868c2ecf20Sopenharmony_ci	uint8_t select_value_stride;
4878c2ecf20Sopenharmony_ci	uint8_t data_size;
4888c2ecf20Sopenharmony_ci	uint8_t rsvd[2];
4898c2ecf20Sopenharmony_ci} __packed;
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci/* POLLRDMWR Entry */
4928c2ecf20Sopenharmony_cistruct qla8044_minidump_entry_pollrdmwr {
4938c2ecf20Sopenharmony_ci	struct qla8044_minidump_entry_hdr h;
4948c2ecf20Sopenharmony_ci	uint32_t addr_1;
4958c2ecf20Sopenharmony_ci	uint32_t addr_2;
4968c2ecf20Sopenharmony_ci	uint32_t value_1;
4978c2ecf20Sopenharmony_ci	uint32_t value_2;
4988c2ecf20Sopenharmony_ci	uint32_t poll_wait;
4998c2ecf20Sopenharmony_ci	uint32_t poll_mask;
5008c2ecf20Sopenharmony_ci	uint32_t modify_mask;
5018c2ecf20Sopenharmony_ci	uint32_t data_size;
5028c2ecf20Sopenharmony_ci} __packed;
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci/* IDC additional information */
5058c2ecf20Sopenharmony_cistruct qla8044_idc_information {
5068c2ecf20Sopenharmony_ci	uint32_t request_desc;  /* IDC request descriptor */
5078c2ecf20Sopenharmony_ci	uint32_t info1; /* IDC additional info */
5088c2ecf20Sopenharmony_ci	uint32_t info2; /* IDC additional info */
5098c2ecf20Sopenharmony_ci	uint32_t info3; /* IDC additional info */
5108c2ecf20Sopenharmony_ci} __packed;
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_cienum qla_regs {
5138c2ecf20Sopenharmony_ci	QLA8044_PEG_HALT_STATUS1_INDEX = 0,
5148c2ecf20Sopenharmony_ci	QLA8044_PEG_HALT_STATUS2_INDEX,
5158c2ecf20Sopenharmony_ci	QLA8044_PEG_ALIVE_COUNTER_INDEX,
5168c2ecf20Sopenharmony_ci	QLA8044_CRB_DRV_ACTIVE_INDEX,
5178c2ecf20Sopenharmony_ci	QLA8044_CRB_DEV_STATE_INDEX,
5188c2ecf20Sopenharmony_ci	QLA8044_CRB_DRV_STATE_INDEX,
5198c2ecf20Sopenharmony_ci	QLA8044_CRB_DRV_SCRATCH_INDEX,
5208c2ecf20Sopenharmony_ci	QLA8044_CRB_DEV_PART_INFO_INDEX,
5218c2ecf20Sopenharmony_ci	QLA8044_CRB_DRV_IDC_VERSION_INDEX,
5228c2ecf20Sopenharmony_ci	QLA8044_FW_VERSION_MAJOR_INDEX,
5238c2ecf20Sopenharmony_ci	QLA8044_FW_VERSION_MINOR_INDEX,
5248c2ecf20Sopenharmony_ci	QLA8044_FW_VERSION_SUB_INDEX,
5258c2ecf20Sopenharmony_ci	QLA8044_CRB_CMDPEG_STATE_INDEX,
5268c2ecf20Sopenharmony_ci	QLA8044_CRB_TEMP_STATE_INDEX,
5278c2ecf20Sopenharmony_ci} __packed;
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci#define CRB_REG_INDEX_MAX	14
5308c2ecf20Sopenharmony_ci#define CRB_CMDPEG_CHECK_RETRY_COUNT    60
5318c2ecf20Sopenharmony_ci#define CRB_CMDPEG_CHECK_DELAY          500
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci/* MiniDump Structures */
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci/* Driver_code is for driver to write some info about the entry
5368c2ecf20Sopenharmony_ci * currently not used.
5378c2ecf20Sopenharmony_ci */
5388c2ecf20Sopenharmony_ci#define QLA8044_SS_OCM_WNDREG_INDEX             3
5398c2ecf20Sopenharmony_ci#define QLA8044_DBG_STATE_ARRAY_LEN             16
5408c2ecf20Sopenharmony_ci#define QLA8044_DBG_CAP_SIZE_ARRAY_LEN          8
5418c2ecf20Sopenharmony_ci#define QLA8044_DBG_RSVD_ARRAY_LEN              8
5428c2ecf20Sopenharmony_ci#define QLA8044_DBG_OCM_WNDREG_ARRAY_LEN        16
5438c2ecf20Sopenharmony_ci#define QLA8044_SS_PCI_INDEX                    0
5448c2ecf20Sopenharmony_ci#define QLA8044_RDDFE          38
5458c2ecf20Sopenharmony_ci#define QLA8044_RDMDIO         39
5468c2ecf20Sopenharmony_ci#define QLA8044_POLLWR         40
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_cistruct qla8044_minidump_template_hdr {
5498c2ecf20Sopenharmony_ci	uint32_t entry_type;
5508c2ecf20Sopenharmony_ci	uint32_t first_entry_offset;
5518c2ecf20Sopenharmony_ci	uint32_t size_of_template;
5528c2ecf20Sopenharmony_ci	uint32_t capture_debug_level;
5538c2ecf20Sopenharmony_ci	uint32_t num_of_entries;
5548c2ecf20Sopenharmony_ci	uint32_t version;
5558c2ecf20Sopenharmony_ci	uint32_t driver_timestamp;
5568c2ecf20Sopenharmony_ci	uint32_t checksum;
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	uint32_t driver_capture_mask;
5598c2ecf20Sopenharmony_ci	uint32_t driver_info_word2;
5608c2ecf20Sopenharmony_ci	uint32_t driver_info_word3;
5618c2ecf20Sopenharmony_ci	uint32_t driver_info_word4;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	uint32_t saved_state_array[QLA8044_DBG_STATE_ARRAY_LEN];
5648c2ecf20Sopenharmony_ci	uint32_t capture_size_array[QLA8044_DBG_CAP_SIZE_ARRAY_LEN];
5658c2ecf20Sopenharmony_ci	uint32_t ocm_window_reg[QLA8044_DBG_OCM_WNDREG_ARRAY_LEN];
5668c2ecf20Sopenharmony_ci};
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_cistruct qla8044_pex_dma_descriptor {
5698c2ecf20Sopenharmony_ci	struct {
5708c2ecf20Sopenharmony_ci		uint32_t read_data_size; /* 0-23: size, 24-31: rsvd */
5718c2ecf20Sopenharmony_ci		uint8_t rsvd[2];
5728c2ecf20Sopenharmony_ci		uint16_t dma_desc_cmd;
5738c2ecf20Sopenharmony_ci	} cmd;
5748c2ecf20Sopenharmony_ci	uint64_t src_addr;
5758c2ecf20Sopenharmony_ci	uint64_t dma_bus_addr; /*0-3: desc-cmd, 4-7: pci-func, 8-15: desc-cmd*/
5768c2ecf20Sopenharmony_ci	uint8_t rsvd[24];
5778c2ecf20Sopenharmony_ci} __packed;
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci#endif
580