162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Thunderbolt driver - NHI registers 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com> 662306a36Sopenharmony_ci * Copyright (C) 2018, Intel Corporation 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef NHI_REGS_H_ 1062306a36Sopenharmony_ci#define NHI_REGS_H_ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/types.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cienum ring_flags { 1562306a36Sopenharmony_ci RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */ 1662306a36Sopenharmony_ci RING_FLAG_E2E_FLOW_CONTROL = 1 << 28, 1762306a36Sopenharmony_ci RING_FLAG_PCI_NO_SNOOP = 1 << 29, 1862306a36Sopenharmony_ci RING_FLAG_RAW = 1 << 30, /* ignore EOF/SOF mask, include checksum */ 1962306a36Sopenharmony_ci RING_FLAG_ENABLE = 1 << 31, 2062306a36Sopenharmony_ci}; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/** 2362306a36Sopenharmony_ci * struct ring_desc - TX/RX ring entry 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * For TX set length/eof/sof. 2662306a36Sopenharmony_ci * For RX length/eof/sof are set by the NHI. 2762306a36Sopenharmony_ci */ 2862306a36Sopenharmony_cistruct ring_desc { 2962306a36Sopenharmony_ci u64 phys; 3062306a36Sopenharmony_ci u32 length:12; 3162306a36Sopenharmony_ci u32 eof:4; 3262306a36Sopenharmony_ci u32 sof:4; 3362306a36Sopenharmony_ci enum ring_desc_flags flags:12; 3462306a36Sopenharmony_ci u32 time; /* write zero */ 3562306a36Sopenharmony_ci} __packed; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* NHI registers in bar 0 */ 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* 4062306a36Sopenharmony_ci * 16 bytes per entry, one entry for every hop (REG_CAPS) 4162306a36Sopenharmony_ci * 00: physical pointer to an array of struct ring_desc 4262306a36Sopenharmony_ci * 08: ring tail (set by NHI) 4362306a36Sopenharmony_ci * 10: ring head (index of first non posted descriptor) 4462306a36Sopenharmony_ci * 12: descriptor count 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define REG_TX_RING_BASE 0x00000 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* 4962306a36Sopenharmony_ci * 16 bytes per entry, one entry for every hop (REG_CAPS) 5062306a36Sopenharmony_ci * 00: physical pointer to an array of struct ring_desc 5162306a36Sopenharmony_ci * 08: ring head (index of first not posted descriptor) 5262306a36Sopenharmony_ci * 10: ring tail (set by NHI) 5362306a36Sopenharmony_ci * 12: descriptor count 5462306a36Sopenharmony_ci * 14: max frame sizes (anything larger than 0x100 has no effect) 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_ci#define REG_RX_RING_BASE 0x08000 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/* 5962306a36Sopenharmony_ci * 32 bytes per entry, one entry for every hop (REG_CAPS) 6062306a36Sopenharmony_ci * 00: enum_ring_flags 6162306a36Sopenharmony_ci * 04: isoch time stamp ?? (write 0) 6262306a36Sopenharmony_ci * ..: unknown 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci#define REG_TX_OPTIONS_BASE 0x19800 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* 6762306a36Sopenharmony_ci * 32 bytes per entry, one entry for every hop (REG_CAPS) 6862306a36Sopenharmony_ci * 00: enum ring_flags 6962306a36Sopenharmony_ci * If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to 7062306a36Sopenharmony_ci * the corresponding TX hop id. 7162306a36Sopenharmony_ci * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings) 7262306a36Sopenharmony_ci * ..: unknown 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#define REG_RX_OPTIONS_BASE 0x29800 7562306a36Sopenharmony_ci#define REG_RX_OPTIONS_E2E_HOP_MASK GENMASK(22, 12) 7662306a36Sopenharmony_ci#define REG_RX_OPTIONS_E2E_HOP_SHIFT 12 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * three bitfields: tx, rx, rx overflow 8062306a36Sopenharmony_ci * Every bitfield contains one bit for every hop (REG_CAPS). 8162306a36Sopenharmony_ci * New interrupts are fired only after ALL registers have been 8262306a36Sopenharmony_ci * read (even those containing only disabled rings). 8362306a36Sopenharmony_ci */ 8462306a36Sopenharmony_ci#define REG_RING_NOTIFY_BASE 0x37800 8562306a36Sopenharmony_ci#define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32) 8662306a36Sopenharmony_ci#define REG_RING_INT_CLEAR 0x37808 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* 8962306a36Sopenharmony_ci * two bitfields: rx, tx 9062306a36Sopenharmony_ci * Both bitfields contains one bit for every hop (REG_CAPS). To 9162306a36Sopenharmony_ci * enable/disable interrupts set/clear the corresponding bits. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_ci#define REG_RING_INTERRUPT_BASE 0x38200 9462306a36Sopenharmony_ci#define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define REG_RING_INTERRUPT_MASK_CLEAR_BASE 0x38208 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define REG_INT_THROTTLING_RATE 0x38c00 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci/* Interrupt Vector Allocation */ 10162306a36Sopenharmony_ci#define REG_INT_VEC_ALLOC_BASE 0x38c40 10262306a36Sopenharmony_ci#define REG_INT_VEC_ALLOC_BITS 4 10362306a36Sopenharmony_ci#define REG_INT_VEC_ALLOC_MASK GENMASK(3, 0) 10462306a36Sopenharmony_ci#define REG_INT_VEC_ALLOC_REGS (32 / REG_INT_VEC_ALLOC_BITS) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* The last 11 bits contain the number of hops supported by the NHI port. */ 10762306a36Sopenharmony_ci#define REG_CAPS 0x39640 10862306a36Sopenharmony_ci#define REG_CAPS_VERSION_MASK GENMASK(23, 16) 10962306a36Sopenharmony_ci#define REG_CAPS_VERSION_2 0x40 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define REG_DMA_MISC 0x39864 11262306a36Sopenharmony_ci#define REG_DMA_MISC_INT_AUTO_CLEAR BIT(2) 11362306a36Sopenharmony_ci#define REG_DMA_MISC_DISABLE_AUTO_CLEAR BIT(17) 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci#define REG_RESET 0x39898 11662306a36Sopenharmony_ci#define REG_RESET_HRR BIT(0) 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci#define REG_INMAIL_DATA 0x39900 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define REG_INMAIL_CMD 0x39904 12162306a36Sopenharmony_ci#define REG_INMAIL_CMD_MASK GENMASK(7, 0) 12262306a36Sopenharmony_ci#define REG_INMAIL_ERROR BIT(30) 12362306a36Sopenharmony_ci#define REG_INMAIL_OP_REQUEST BIT(31) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci#define REG_OUTMAIL_CMD 0x3990c 12662306a36Sopenharmony_ci#define REG_OUTMAIL_CMD_OPMODE_SHIFT 8 12762306a36Sopenharmony_ci#define REG_OUTMAIL_CMD_OPMODE_MASK GENMASK(11, 8) 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#define REG_FW_STS 0x39944 13062306a36Sopenharmony_ci#define REG_FW_STS_NVM_AUTH_DONE BIT(31) 13162306a36Sopenharmony_ci#define REG_FW_STS_CIO_RESET_REQ BIT(30) 13262306a36Sopenharmony_ci#define REG_FW_STS_ICM_EN_CPU BIT(2) 13362306a36Sopenharmony_ci#define REG_FW_STS_ICM_EN_INVERT BIT(1) 13462306a36Sopenharmony_ci#define REG_FW_STS_ICM_EN BIT(0) 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* ICL NHI VSEC registers */ 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* FW ready */ 13962306a36Sopenharmony_ci#define VS_CAP_9 0xc8 14062306a36Sopenharmony_ci#define VS_CAP_9_FW_READY BIT(31) 14162306a36Sopenharmony_ci/* UUID */ 14262306a36Sopenharmony_ci#define VS_CAP_10 0xcc 14362306a36Sopenharmony_ci#define VS_CAP_11 0xd0 14462306a36Sopenharmony_ci/* LTR */ 14562306a36Sopenharmony_ci#define VS_CAP_15 0xe0 14662306a36Sopenharmony_ci#define VS_CAP_16 0xe4 14762306a36Sopenharmony_ci/* TBT2PCIe */ 14862306a36Sopenharmony_ci#define VS_CAP_18 0xec 14962306a36Sopenharmony_ci#define VS_CAP_18_DONE BIT(0) 15062306a36Sopenharmony_ci/* PCIe2TBT */ 15162306a36Sopenharmony_ci#define VS_CAP_19 0xf0 15262306a36Sopenharmony_ci#define VS_CAP_19_VALID BIT(0) 15362306a36Sopenharmony_ci#define VS_CAP_19_CMD_SHIFT 1 15462306a36Sopenharmony_ci#define VS_CAP_19_CMD_MASK GENMASK(7, 1) 15562306a36Sopenharmony_ci/* Force power */ 15662306a36Sopenharmony_ci#define VS_CAP_22 0xfc 15762306a36Sopenharmony_ci#define VS_CAP_22_FORCE_POWER BIT(1) 15862306a36Sopenharmony_ci#define VS_CAP_22_DMA_DELAY_MASK GENMASK(31, 24) 15962306a36Sopenharmony_ci#define VS_CAP_22_DMA_DELAY_SHIFT 24 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/** 16262306a36Sopenharmony_ci * enum icl_lc_mailbox_cmd - ICL specific LC mailbox commands 16362306a36Sopenharmony_ci * @ICL_LC_GO2SX: Ask LC to enter Sx without wake 16462306a36Sopenharmony_ci * @ICL_LC_GO2SX_NO_WAKE: Ask LC to enter Sx with wake 16562306a36Sopenharmony_ci * @ICL_LC_PREPARE_FOR_RESET: Prepare LC for reset 16662306a36Sopenharmony_ci */ 16762306a36Sopenharmony_cienum icl_lc_mailbox_cmd { 16862306a36Sopenharmony_ci ICL_LC_GO2SX = 0x02, 16962306a36Sopenharmony_ci ICL_LC_GO2SX_NO_WAKE = 0x03, 17062306a36Sopenharmony_ci ICL_LC_PREPARE_FOR_RESET = 0x21, 17162306a36Sopenharmony_ci}; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci#endif 174