12025cf9eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 25a1c269fSLogan Gunthorpe /* 35a1c269fSLogan Gunthorpe * Microsemi Switchtec PCIe Driver 45a1c269fSLogan Gunthorpe * Copyright (c) 2017, Microsemi Corporation 55a1c269fSLogan Gunthorpe */ 65a1c269fSLogan Gunthorpe 75a1c269fSLogan Gunthorpe #ifndef _SWITCHTEC_H 85a1c269fSLogan Gunthorpe #define _SWITCHTEC_H 95a1c269fSLogan Gunthorpe 105a1c269fSLogan Gunthorpe #include <linux/pci.h> 115a1c269fSLogan Gunthorpe #include <linux/cdev.h> 125a1c269fSLogan Gunthorpe 135a1c269fSLogan Gunthorpe #define SWITCHTEC_MRPC_PAYLOAD_SIZE 1024 14ba8a3982SWesley Sheng #define SWITCHTEC_MAX_PFF_CSR 255 155a1c269fSLogan Gunthorpe 165a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_OCCURRED BIT(0) 175a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_CLEAR BIT(0) 185a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_EN_LOG BIT(1) 195a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_EN_CLI BIT(2) 205a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_EN_IRQ BIT(3) 215a1c269fSLogan Gunthorpe #define SWITCHTEC_EVENT_FATAL BIT(4) 225a1c269fSLogan Gunthorpe 23f7eb7b8aSWesley Sheng #define SWITCHTEC_DMA_MRPC_EN BIT(0) 245a1c269fSLogan Gunthorpe enum { 255a1c269fSLogan Gunthorpe SWITCHTEC_GAS_MRPC_OFFSET = 0x0000, 265a1c269fSLogan Gunthorpe SWITCHTEC_GAS_TOP_CFG_OFFSET = 0x1000, 275a1c269fSLogan Gunthorpe SWITCHTEC_GAS_SW_EVENT_OFFSET = 0x1800, 285a1c269fSLogan Gunthorpe SWITCHTEC_GAS_SYS_INFO_OFFSET = 0x2000, 295a1c269fSLogan Gunthorpe SWITCHTEC_GAS_FLASH_INFO_OFFSET = 0x2200, 305a1c269fSLogan Gunthorpe SWITCHTEC_GAS_PART_CFG_OFFSET = 0x4000, 315a1c269fSLogan Gunthorpe SWITCHTEC_GAS_NTB_OFFSET = 0x10000, 325a1c269fSLogan Gunthorpe SWITCHTEC_GAS_PFF_CSR_OFFSET = 0x134000, 335a1c269fSLogan Gunthorpe }; 345a1c269fSLogan Gunthorpe 355a1c269fSLogan Gunthorpe struct mrpc_regs { 365a1c269fSLogan Gunthorpe u8 input_data[SWITCHTEC_MRPC_PAYLOAD_SIZE]; 375a1c269fSLogan Gunthorpe u8 output_data[SWITCHTEC_MRPC_PAYLOAD_SIZE]; 385a1c269fSLogan Gunthorpe u32 cmd; 395a1c269fSLogan Gunthorpe u32 status; 405a1c269fSLogan Gunthorpe u32 ret_value; 41f7eb7b8aSWesley Sheng u32 dma_en; 42f7eb7b8aSWesley Sheng u64 dma_addr; 43f7eb7b8aSWesley Sheng u32 dma_vector; 44f7eb7b8aSWesley Sheng u32 dma_ver; 455a1c269fSLogan Gunthorpe } __packed; 465a1c269fSLogan Gunthorpe 475a1c269fSLogan Gunthorpe enum mrpc_status { 485a1c269fSLogan Gunthorpe SWITCHTEC_MRPC_STATUS_INPROGRESS = 1, 495a1c269fSLogan Gunthorpe SWITCHTEC_MRPC_STATUS_DONE = 2, 505a1c269fSLogan Gunthorpe SWITCHTEC_MRPC_STATUS_ERROR = 0xFF, 515a1c269fSLogan Gunthorpe SWITCHTEC_MRPC_STATUS_INTERRUPTED = 0x100, 525a1c269fSLogan Gunthorpe }; 535a1c269fSLogan Gunthorpe 545a1c269fSLogan Gunthorpe struct sw_event_regs { 555a1c269fSLogan Gunthorpe u64 event_report_ctrl; 565a1c269fSLogan Gunthorpe u64 reserved1; 575a1c269fSLogan Gunthorpe u64 part_event_bitmap; 585a1c269fSLogan Gunthorpe u64 reserved2; 595a1c269fSLogan Gunthorpe u32 global_summary; 605a1c269fSLogan Gunthorpe u32 reserved3[3]; 615a1c269fSLogan Gunthorpe u32 stack_error_event_hdr; 625a1c269fSLogan Gunthorpe u32 stack_error_event_data; 635a1c269fSLogan Gunthorpe u32 reserved4[4]; 645a1c269fSLogan Gunthorpe u32 ppu_error_event_hdr; 655a1c269fSLogan Gunthorpe u32 ppu_error_event_data; 665a1c269fSLogan Gunthorpe u32 reserved5[4]; 675a1c269fSLogan Gunthorpe u32 isp_error_event_hdr; 685a1c269fSLogan Gunthorpe u32 isp_error_event_data; 695a1c269fSLogan Gunthorpe u32 reserved6[4]; 705a1c269fSLogan Gunthorpe u32 sys_reset_event_hdr; 715a1c269fSLogan Gunthorpe u32 reserved7[5]; 725a1c269fSLogan Gunthorpe u32 fw_exception_hdr; 735a1c269fSLogan Gunthorpe u32 reserved8[5]; 745a1c269fSLogan Gunthorpe u32 fw_nmi_hdr; 755a1c269fSLogan Gunthorpe u32 reserved9[5]; 765a1c269fSLogan Gunthorpe u32 fw_non_fatal_hdr; 775a1c269fSLogan Gunthorpe u32 reserved10[5]; 785a1c269fSLogan Gunthorpe u32 fw_fatal_hdr; 795a1c269fSLogan Gunthorpe u32 reserved11[5]; 805a1c269fSLogan Gunthorpe u32 twi_mrpc_comp_hdr; 815a1c269fSLogan Gunthorpe u32 twi_mrpc_comp_data; 825a1c269fSLogan Gunthorpe u32 reserved12[4]; 835a1c269fSLogan Gunthorpe u32 twi_mrpc_comp_async_hdr; 845a1c269fSLogan Gunthorpe u32 twi_mrpc_comp_async_data; 855a1c269fSLogan Gunthorpe u32 reserved13[4]; 865a1c269fSLogan Gunthorpe u32 cli_mrpc_comp_hdr; 875a1c269fSLogan Gunthorpe u32 cli_mrpc_comp_data; 885a1c269fSLogan Gunthorpe u32 reserved14[4]; 895a1c269fSLogan Gunthorpe u32 cli_mrpc_comp_async_hdr; 905a1c269fSLogan Gunthorpe u32 cli_mrpc_comp_async_data; 915a1c269fSLogan Gunthorpe u32 reserved15[4]; 925a1c269fSLogan Gunthorpe u32 gpio_interrupt_hdr; 935a1c269fSLogan Gunthorpe u32 gpio_interrupt_data; 945a1c269fSLogan Gunthorpe u32 reserved16[4]; 95f0edce7aSLogan Gunthorpe u32 gfms_event_hdr; 96f0edce7aSLogan Gunthorpe u32 gfms_event_data; 97f0edce7aSLogan Gunthorpe u32 reserved17[4]; 985a1c269fSLogan Gunthorpe } __packed; 995a1c269fSLogan Gunthorpe 1005a1c269fSLogan Gunthorpe enum { 101*fcccd282SLogan Gunthorpe SWITCHTEC_GEN3_CFG0_RUNNING = 0x04, 102*fcccd282SLogan Gunthorpe SWITCHTEC_GEN3_CFG1_RUNNING = 0x05, 103*fcccd282SLogan Gunthorpe SWITCHTEC_GEN3_IMG0_RUNNING = 0x03, 104*fcccd282SLogan Gunthorpe SWITCHTEC_GEN3_IMG1_RUNNING = 0x07, 1055a1c269fSLogan Gunthorpe }; 1065a1c269fSLogan Gunthorpe 1075a1c269fSLogan Gunthorpe struct sys_info_regs { 1085a1c269fSLogan Gunthorpe u32 device_id; 1095a1c269fSLogan Gunthorpe u32 device_version; 1105a1c269fSLogan Gunthorpe u32 firmware_version; 1115a1c269fSLogan Gunthorpe u32 reserved1; 1125a1c269fSLogan Gunthorpe u32 vendor_table_revision; 1135a1c269fSLogan Gunthorpe u32 table_format_version; 1145a1c269fSLogan Gunthorpe u32 partition_id; 1155a1c269fSLogan Gunthorpe u32 cfg_file_fmt_version; 1165a1c269fSLogan Gunthorpe u16 cfg_running; 1175a1c269fSLogan Gunthorpe u16 img_running; 1185a1c269fSLogan Gunthorpe u32 reserved2[57]; 1195a1c269fSLogan Gunthorpe char vendor_id[8]; 1205a1c269fSLogan Gunthorpe char product_id[16]; 1215a1c269fSLogan Gunthorpe char product_revision[4]; 1225a1c269fSLogan Gunthorpe char component_vendor[8]; 1235a1c269fSLogan Gunthorpe u16 component_id; 1245a1c269fSLogan Gunthorpe u8 component_revision; 1255a1c269fSLogan Gunthorpe } __packed; 1265a1c269fSLogan Gunthorpe 1275a1c269fSLogan Gunthorpe struct flash_info_regs { 1285a1c269fSLogan Gunthorpe u32 flash_part_map_upd_idx; 1295a1c269fSLogan Gunthorpe 1305a1c269fSLogan Gunthorpe struct active_partition_info { 1315a1c269fSLogan Gunthorpe u32 address; 1325a1c269fSLogan Gunthorpe u32 build_version; 1335a1c269fSLogan Gunthorpe u32 build_string; 1345a1c269fSLogan Gunthorpe } active_img; 1355a1c269fSLogan Gunthorpe 1365a1c269fSLogan Gunthorpe struct active_partition_info active_cfg; 1375a1c269fSLogan Gunthorpe struct active_partition_info inactive_img; 1385a1c269fSLogan Gunthorpe struct active_partition_info inactive_cfg; 1395a1c269fSLogan Gunthorpe 1405a1c269fSLogan Gunthorpe u32 flash_length; 1415a1c269fSLogan Gunthorpe 1425a1c269fSLogan Gunthorpe struct partition_info { 1435a1c269fSLogan Gunthorpe u32 address; 1445a1c269fSLogan Gunthorpe u32 length; 1455a1c269fSLogan Gunthorpe } cfg0; 1465a1c269fSLogan Gunthorpe 1475a1c269fSLogan Gunthorpe struct partition_info cfg1; 1485a1c269fSLogan Gunthorpe struct partition_info img0; 1495a1c269fSLogan Gunthorpe struct partition_info img1; 1505a1c269fSLogan Gunthorpe struct partition_info nvlog; 1515a1c269fSLogan Gunthorpe struct partition_info vendor[8]; 1525a1c269fSLogan Gunthorpe }; 1535a1c269fSLogan Gunthorpe 154c082b04cSLogan Gunthorpe enum { 155c082b04cSLogan Gunthorpe SWITCHTEC_NTB_REG_INFO_OFFSET = 0x0000, 156c082b04cSLogan Gunthorpe SWITCHTEC_NTB_REG_CTRL_OFFSET = 0x4000, 157c082b04cSLogan Gunthorpe SWITCHTEC_NTB_REG_DBMSG_OFFSET = 0x64000, 158c082b04cSLogan Gunthorpe }; 159c082b04cSLogan Gunthorpe 1605a1c269fSLogan Gunthorpe struct ntb_info_regs { 1615a1c269fSLogan Gunthorpe u8 partition_count; 1625a1c269fSLogan Gunthorpe u8 partition_id; 1635a1c269fSLogan Gunthorpe u16 reserved1; 1645a1c269fSLogan Gunthorpe u64 ep_map; 1655a1c269fSLogan Gunthorpe u16 requester_id; 1663df54c87SKelvin Cao u16 reserved2; 1673df54c87SKelvin Cao u32 reserved3[4]; 1683df54c87SKelvin Cao struct nt_partition_info { 1693df54c87SKelvin Cao u32 xlink_enabled; 1703df54c87SKelvin Cao u32 target_part_low; 1713df54c87SKelvin Cao u32 target_part_high; 1723df54c87SKelvin Cao u32 reserved; 1733df54c87SKelvin Cao } ntp_info[48]; 1745a1c269fSLogan Gunthorpe } __packed; 1755a1c269fSLogan Gunthorpe 1765a1c269fSLogan Gunthorpe struct part_cfg_regs { 1775a1c269fSLogan Gunthorpe u32 status; 1785a1c269fSLogan Gunthorpe u32 state; 1795a1c269fSLogan Gunthorpe u32 port_cnt; 1805a1c269fSLogan Gunthorpe u32 usp_port_mode; 1815a1c269fSLogan Gunthorpe u32 usp_pff_inst_id; 1825a1c269fSLogan Gunthorpe u32 vep_pff_inst_id; 1835a1c269fSLogan Gunthorpe u32 dsp_pff_inst_id[47]; 1845a1c269fSLogan Gunthorpe u32 reserved1[11]; 1855a1c269fSLogan Gunthorpe u16 vep_vector_number; 1865a1c269fSLogan Gunthorpe u16 usp_vector_number; 1875a1c269fSLogan Gunthorpe u32 port_event_bitmap; 1885a1c269fSLogan Gunthorpe u32 reserved2[3]; 1895a1c269fSLogan Gunthorpe u32 part_event_summary; 1905a1c269fSLogan Gunthorpe u32 reserved3[3]; 1915a1c269fSLogan Gunthorpe u32 part_reset_hdr; 1925a1c269fSLogan Gunthorpe u32 part_reset_data[5]; 1935a1c269fSLogan Gunthorpe u32 mrpc_comp_hdr; 1945a1c269fSLogan Gunthorpe u32 mrpc_comp_data[5]; 1955a1c269fSLogan Gunthorpe u32 mrpc_comp_async_hdr; 1965a1c269fSLogan Gunthorpe u32 mrpc_comp_async_data[5]; 1975a1c269fSLogan Gunthorpe u32 dyn_binding_hdr; 1985a1c269fSLogan Gunthorpe u32 dyn_binding_data[5]; 199a6b0ef9aSLogan Gunthorpe u32 intercomm_notify_hdr; 200a6b0ef9aSLogan Gunthorpe u32 intercomm_notify_data[5]; 201a6b0ef9aSLogan Gunthorpe u32 reserved4[153]; 2025a1c269fSLogan Gunthorpe } __packed; 2035a1c269fSLogan Gunthorpe 2045a1c269fSLogan Gunthorpe enum { 205c082b04cSLogan Gunthorpe NTB_CTRL_PART_OP_LOCK = 0x1, 206c082b04cSLogan Gunthorpe NTB_CTRL_PART_OP_CFG = 0x2, 207c082b04cSLogan Gunthorpe NTB_CTRL_PART_OP_RESET = 0x3, 208c082b04cSLogan Gunthorpe 209c082b04cSLogan Gunthorpe NTB_CTRL_PART_STATUS_NORMAL = 0x1, 210c082b04cSLogan Gunthorpe NTB_CTRL_PART_STATUS_LOCKED = 0x2, 211c082b04cSLogan Gunthorpe NTB_CTRL_PART_STATUS_LOCKING = 0x3, 212c082b04cSLogan Gunthorpe NTB_CTRL_PART_STATUS_CONFIGURING = 0x4, 213c082b04cSLogan Gunthorpe NTB_CTRL_PART_STATUS_RESETTING = 0x5, 214c082b04cSLogan Gunthorpe 215c082b04cSLogan Gunthorpe NTB_CTRL_BAR_VALID = 1 << 0, 216c082b04cSLogan Gunthorpe NTB_CTRL_BAR_DIR_WIN_EN = 1 << 4, 217c082b04cSLogan Gunthorpe NTB_CTRL_BAR_LUT_WIN_EN = 1 << 5, 218c082b04cSLogan Gunthorpe 219c082b04cSLogan Gunthorpe NTB_CTRL_REQ_ID_EN = 1 << 0, 220c082b04cSLogan Gunthorpe 221c082b04cSLogan Gunthorpe NTB_CTRL_LUT_EN = 1 << 0, 222c082b04cSLogan Gunthorpe 223c082b04cSLogan Gunthorpe NTB_PART_CTRL_ID_PROT_DIS = 1 << 0, 224c082b04cSLogan Gunthorpe }; 225c082b04cSLogan Gunthorpe 226c082b04cSLogan Gunthorpe struct ntb_ctrl_regs { 227c082b04cSLogan Gunthorpe u32 partition_status; 228c082b04cSLogan Gunthorpe u32 partition_op; 229c082b04cSLogan Gunthorpe u32 partition_ctrl; 230c082b04cSLogan Gunthorpe u32 bar_setup; 231c082b04cSLogan Gunthorpe u32 bar_error; 232c082b04cSLogan Gunthorpe u16 lut_table_entries; 233c082b04cSLogan Gunthorpe u16 lut_table_offset; 234c082b04cSLogan Gunthorpe u32 lut_error; 235c082b04cSLogan Gunthorpe u16 req_id_table_size; 236c082b04cSLogan Gunthorpe u16 req_id_table_offset; 237c082b04cSLogan Gunthorpe u32 req_id_error; 238c082b04cSLogan Gunthorpe u32 reserved1[7]; 239c082b04cSLogan Gunthorpe struct { 240c082b04cSLogan Gunthorpe u32 ctl; 241c082b04cSLogan Gunthorpe u32 win_size; 242c082b04cSLogan Gunthorpe u64 xlate_addr; 243c082b04cSLogan Gunthorpe } bar_entry[6]; 244a2585cdcSPaul Selles struct { 245a2585cdcSPaul Selles u32 win_size; 246a2585cdcSPaul Selles u32 reserved[3]; 247a2585cdcSPaul Selles } bar_ext_entry[6]; 248a2585cdcSPaul Selles u32 reserved2[192]; 249d123fab7SWesley Sheng u32 req_id_table[512]; 250d123fab7SWesley Sheng u32 reserved3[256]; 251c082b04cSLogan Gunthorpe u64 lut_entry[512]; 252c082b04cSLogan Gunthorpe } __packed; 253c082b04cSLogan Gunthorpe 254c082b04cSLogan Gunthorpe #define NTB_DBMSG_IMSG_STATUS BIT_ULL(32) 255c082b04cSLogan Gunthorpe #define NTB_DBMSG_IMSG_MASK BIT_ULL(40) 256c082b04cSLogan Gunthorpe 257c082b04cSLogan Gunthorpe struct ntb_dbmsg_regs { 258c082b04cSLogan Gunthorpe u32 reserved1[1024]; 259c082b04cSLogan Gunthorpe u64 odb; 260c082b04cSLogan Gunthorpe u64 odb_mask; 261c082b04cSLogan Gunthorpe u64 idb; 262c082b04cSLogan Gunthorpe u64 idb_mask; 263c082b04cSLogan Gunthorpe u8 idb_vec_map[64]; 264c082b04cSLogan Gunthorpe u32 msg_map; 265c082b04cSLogan Gunthorpe u32 reserved2; 266c082b04cSLogan Gunthorpe struct { 267c082b04cSLogan Gunthorpe u32 msg; 268c082b04cSLogan Gunthorpe u32 status; 269c082b04cSLogan Gunthorpe } omsg[4]; 270c082b04cSLogan Gunthorpe 271c082b04cSLogan Gunthorpe struct { 272c082b04cSLogan Gunthorpe u32 msg; 273c082b04cSLogan Gunthorpe u8 status; 274c082b04cSLogan Gunthorpe u8 mask; 275c082b04cSLogan Gunthorpe u8 src; 276c082b04cSLogan Gunthorpe u8 reserved; 277c082b04cSLogan Gunthorpe } imsg[4]; 278c082b04cSLogan Gunthorpe 279c082b04cSLogan Gunthorpe u8 reserved3[3928]; 280c082b04cSLogan Gunthorpe u8 msix_table[1024]; 281c082b04cSLogan Gunthorpe u8 reserved4[3072]; 282c082b04cSLogan Gunthorpe u8 pba[24]; 283c082b04cSLogan Gunthorpe u8 reserved5[4072]; 284c082b04cSLogan Gunthorpe } __packed; 285c082b04cSLogan Gunthorpe 286c082b04cSLogan Gunthorpe enum { 2875a1c269fSLogan Gunthorpe SWITCHTEC_PART_CFG_EVENT_RESET = 1 << 0, 2885a1c269fSLogan Gunthorpe SWITCHTEC_PART_CFG_EVENT_MRPC_CMP = 1 << 1, 2895a1c269fSLogan Gunthorpe SWITCHTEC_PART_CFG_EVENT_MRPC_ASYNC_CMP = 1 << 2, 2905a1c269fSLogan Gunthorpe SWITCHTEC_PART_CFG_EVENT_DYN_PART_CMP = 1 << 3, 2915a1c269fSLogan Gunthorpe }; 2925a1c269fSLogan Gunthorpe 2935a1c269fSLogan Gunthorpe struct pff_csr_regs { 2945a1c269fSLogan Gunthorpe u16 vendor_id; 2955a1c269fSLogan Gunthorpe u16 device_id; 29645f447deSLogan Gunthorpe u16 pcicmd; 29745f447deSLogan Gunthorpe u16 pcists; 29845f447deSLogan Gunthorpe u32 pci_class; 29945f447deSLogan Gunthorpe u32 pci_opts; 30045f447deSLogan Gunthorpe union { 30145f447deSLogan Gunthorpe u32 pci_bar[6]; 30245f447deSLogan Gunthorpe u64 pci_bar64[3]; 30345f447deSLogan Gunthorpe }; 30445f447deSLogan Gunthorpe u32 pci_cardbus; 30545f447deSLogan Gunthorpe u32 pci_subsystem_id; 30645f447deSLogan Gunthorpe u32 pci_expansion_rom; 30745f447deSLogan Gunthorpe u32 pci_cap_ptr; 30845f447deSLogan Gunthorpe u32 reserved1; 30945f447deSLogan Gunthorpe u32 pci_irq; 3105a1c269fSLogan Gunthorpe u32 pci_cap_region[48]; 3115a1c269fSLogan Gunthorpe u32 pcie_cap_region[448]; 3125a1c269fSLogan Gunthorpe u32 indirect_gas_window[128]; 3135a1c269fSLogan Gunthorpe u32 indirect_gas_window_off; 3145a1c269fSLogan Gunthorpe u32 reserved[127]; 3155a1c269fSLogan Gunthorpe u32 pff_event_summary; 3165a1c269fSLogan Gunthorpe u32 reserved2[3]; 3175a1c269fSLogan Gunthorpe u32 aer_in_p2p_hdr; 3185a1c269fSLogan Gunthorpe u32 aer_in_p2p_data[5]; 3195a1c269fSLogan Gunthorpe u32 aer_in_vep_hdr; 3205a1c269fSLogan Gunthorpe u32 aer_in_vep_data[5]; 3215a1c269fSLogan Gunthorpe u32 dpc_hdr; 3225a1c269fSLogan Gunthorpe u32 dpc_data[5]; 3235a1c269fSLogan Gunthorpe u32 cts_hdr; 3245a1c269fSLogan Gunthorpe u32 cts_data[5]; 325a6b0ef9aSLogan Gunthorpe u32 uec_hdr; 326a6b0ef9aSLogan Gunthorpe u32 uec_data[5]; 3275a1c269fSLogan Gunthorpe u32 hotplug_hdr; 3285a1c269fSLogan Gunthorpe u32 hotplug_data[5]; 3295a1c269fSLogan Gunthorpe u32 ier_hdr; 3305a1c269fSLogan Gunthorpe u32 ier_data[5]; 3315a1c269fSLogan Gunthorpe u32 threshold_hdr; 3325a1c269fSLogan Gunthorpe u32 threshold_data[5]; 3335a1c269fSLogan Gunthorpe u32 power_mgmt_hdr; 3345a1c269fSLogan Gunthorpe u32 power_mgmt_data[5]; 3355a1c269fSLogan Gunthorpe u32 tlp_throttling_hdr; 3365a1c269fSLogan Gunthorpe u32 tlp_throttling_data[5]; 3375a1c269fSLogan Gunthorpe u32 force_speed_hdr; 3385a1c269fSLogan Gunthorpe u32 force_speed_data[5]; 3395a1c269fSLogan Gunthorpe u32 credit_timeout_hdr; 3405a1c269fSLogan Gunthorpe u32 credit_timeout_data[5]; 3415a1c269fSLogan Gunthorpe u32 link_state_hdr; 3425a1c269fSLogan Gunthorpe u32 link_state_data[5]; 3435a1c269fSLogan Gunthorpe u32 reserved4[174]; 3445a1c269fSLogan Gunthorpe } __packed; 3455a1c269fSLogan Gunthorpe 34633dea5aaSLogan Gunthorpe struct switchtec_ntb; 34733dea5aaSLogan Gunthorpe 348f7eb7b8aSWesley Sheng struct dma_mrpc_output { 349f7eb7b8aSWesley Sheng u32 status; 350f7eb7b8aSWesley Sheng u32 cmd_id; 351f7eb7b8aSWesley Sheng u32 rtn_code; 352f7eb7b8aSWesley Sheng u32 output_size; 353f7eb7b8aSWesley Sheng u8 data[SWITCHTEC_MRPC_PAYLOAD_SIZE]; 354f7eb7b8aSWesley Sheng }; 355f7eb7b8aSWesley Sheng 3565a1c269fSLogan Gunthorpe struct switchtec_dev { 3575a1c269fSLogan Gunthorpe struct pci_dev *pdev; 3585a1c269fSLogan Gunthorpe struct device dev; 3595a1c269fSLogan Gunthorpe struct cdev cdev; 3605a1c269fSLogan Gunthorpe 3615a1c269fSLogan Gunthorpe int partition; 3625a1c269fSLogan Gunthorpe int partition_count; 3635a1c269fSLogan Gunthorpe int pff_csr_count; 3645a1c269fSLogan Gunthorpe char pff_local[SWITCHTEC_MAX_PFF_CSR]; 3655a1c269fSLogan Gunthorpe 3665a1c269fSLogan Gunthorpe void __iomem *mmio; 3675a1c269fSLogan Gunthorpe struct mrpc_regs __iomem *mmio_mrpc; 3685a1c269fSLogan Gunthorpe struct sw_event_regs __iomem *mmio_sw_event; 3695a1c269fSLogan Gunthorpe struct sys_info_regs __iomem *mmio_sys_info; 3705a1c269fSLogan Gunthorpe struct flash_info_regs __iomem *mmio_flash_info; 3715a1c269fSLogan Gunthorpe struct ntb_info_regs __iomem *mmio_ntb; 3725a1c269fSLogan Gunthorpe struct part_cfg_regs __iomem *mmio_part_cfg; 3735a1c269fSLogan Gunthorpe struct part_cfg_regs __iomem *mmio_part_cfg_all; 3745a1c269fSLogan Gunthorpe struct pff_csr_regs __iomem *mmio_pff_csr; 3755a1c269fSLogan Gunthorpe 3765a1c269fSLogan Gunthorpe /* 3775a1c269fSLogan Gunthorpe * The mrpc mutex must be held when accessing the other 3785a1c269fSLogan Gunthorpe * mrpc_ fields, alive flag and stuser->state field 3795a1c269fSLogan Gunthorpe */ 3805a1c269fSLogan Gunthorpe struct mutex mrpc_mutex; 3815a1c269fSLogan Gunthorpe struct list_head mrpc_queue; 3825a1c269fSLogan Gunthorpe int mrpc_busy; 3835a1c269fSLogan Gunthorpe struct work_struct mrpc_work; 3845a1c269fSLogan Gunthorpe struct delayed_work mrpc_timeout; 3855a1c269fSLogan Gunthorpe bool alive; 3865a1c269fSLogan Gunthorpe 3875a1c269fSLogan Gunthorpe wait_queue_head_t event_wq; 3885a1c269fSLogan Gunthorpe atomic_t event_cnt; 38948c302dcSLogan Gunthorpe 39048c302dcSLogan Gunthorpe struct work_struct link_event_work; 39148c302dcSLogan Gunthorpe void (*link_notifier)(struct switchtec_dev *stdev); 39248c302dcSLogan Gunthorpe u8 link_event_count[SWITCHTEC_MAX_PFF_CSR]; 39333dea5aaSLogan Gunthorpe 39433dea5aaSLogan Gunthorpe struct switchtec_ntb *sndev; 395f7eb7b8aSWesley Sheng 396f7eb7b8aSWesley Sheng struct dma_mrpc_output *dma_mrpc; 397f7eb7b8aSWesley Sheng dma_addr_t dma_mrpc_dma_addr; 3985a1c269fSLogan Gunthorpe }; 3995a1c269fSLogan Gunthorpe 4005a1c269fSLogan Gunthorpe static inline struct switchtec_dev *to_stdev(struct device *dev) 4015a1c269fSLogan Gunthorpe { 4025a1c269fSLogan Gunthorpe return container_of(dev, struct switchtec_dev, dev); 4035a1c269fSLogan Gunthorpe } 4045a1c269fSLogan Gunthorpe 405302e994dSLogan Gunthorpe extern struct class *switchtec_class; 406302e994dSLogan Gunthorpe 4075a1c269fSLogan Gunthorpe #endif 408