102d12855SRajmohan Mani /* SPDX-License-Identifier: GPL-2.0 */ 202d12855SRajmohan Mani /* 302d12855SRajmohan Mani * USB4 port sideband registers found on routers and retimers 402d12855SRajmohan Mani * 502d12855SRajmohan Mani * Copyright (C) 2020, Intel Corporation 602d12855SRajmohan Mani * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> 702d12855SRajmohan Mani * Rajmohan Mani <rajmohan.mani@intel.com> 802d12855SRajmohan Mani */ 902d12855SRajmohan Mani 1002d12855SRajmohan Mani #ifndef _SB_REGS 1102d12855SRajmohan Mani #define _SB_REGS 1202d12855SRajmohan Mani 13dacb1287SKranthi Kuntala #define USB4_SB_VENDOR_ID 0x00 14dacb1287SKranthi Kuntala #define USB4_SB_PRODUCT_ID 0x01 1502d12855SRajmohan Mani #define USB4_SB_OPCODE 0x08 1602d12855SRajmohan Mani 1702d12855SRajmohan Mani enum usb4_sb_opcode { 1802d12855SRajmohan Mani USB4_SB_OPCODE_ERR = 0x20525245, /* "ERR " */ 1902d12855SRajmohan Mani USB4_SB_OPCODE_ONS = 0x444d4321, /* "!CMD" */ 203406de7cSRajmohan Mani USB4_SB_OPCODE_ROUTER_OFFLINE = 0x4e45534c, /* "LSEN" */ 2102d12855SRajmohan Mani USB4_SB_OPCODE_ENUMERATE_RETIMERS = 0x4d554e45, /* "ENUM" */ 223406de7cSRajmohan Mani USB4_SB_OPCODE_SET_INBOUND_SBTX = 0x5055534c, /* "LSUP" */ 23*cd0c1e58SGil Fine USB4_SB_OPCODE_UNSET_INBOUND_SBTX = 0x50555355, /* "USUP" */ 2402d12855SRajmohan Mani USB4_SB_OPCODE_QUERY_LAST_RETIMER = 0x5453414c, /* "LAST" */ 2502d12855SRajmohan Mani USB4_SB_OPCODE_GET_NVM_SECTOR_SIZE = 0x53534e47, /* "GNSS" */ 2602d12855SRajmohan Mani USB4_SB_OPCODE_NVM_SET_OFFSET = 0x53504f42, /* "BOPS" */ 2702d12855SRajmohan Mani USB4_SB_OPCODE_NVM_BLOCK_WRITE = 0x574b4c42, /* "BLKW" */ 2802d12855SRajmohan Mani USB4_SB_OPCODE_NVM_AUTH_WRITE = 0x48545541, /* "AUTH" */ 2902d12855SRajmohan Mani USB4_SB_OPCODE_NVM_READ = 0x52524641, /* "AFRR" */ 30d0f1e0c2SMika Westerberg USB4_SB_OPCODE_READ_LANE_MARGINING_CAP = 0x50434452, /* "RDCP" */ 31d0f1e0c2SMika Westerberg USB4_SB_OPCODE_RUN_HW_LANE_MARGINING = 0x474d4852, /* "RHMG" */ 32d0f1e0c2SMika Westerberg USB4_SB_OPCODE_RUN_SW_LANE_MARGINING = 0x474d5352, /* "RSMG" */ 33d0f1e0c2SMika Westerberg USB4_SB_OPCODE_READ_SW_MARGIN_ERR = 0x57534452, /* "RDSW" */ 3402d12855SRajmohan Mani }; 3502d12855SRajmohan Mani 3602d12855SRajmohan Mani #define USB4_SB_METADATA 0x09 3702d12855SRajmohan Mani #define USB4_SB_METADATA_NVM_AUTH_WRITE_MASK GENMASK(5, 0) 3802d12855SRajmohan Mani #define USB4_SB_DATA 0x12 3902d12855SRajmohan Mani 40d0f1e0c2SMika Westerberg /* USB4_SB_OPCODE_READ_LANE_MARGINING_CAP */ 41d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_MODES_HW BIT(0) 42d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_MODES_SW BIT(1) 43d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_2_LANES BIT(2) 44d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_INDP_MASK GENMASK(4, 3) 45d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_INDP_SHIFT 3 46d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_MIN 0x0 47d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_HL 0x1 48d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_BOTH 0x2 49d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_TIME BIT(5) 50d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_STEPS_MASK GENMASK(12, 6) 51d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_VOLTAGE_STEPS_SHIFT 6 52d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_MAX_VOLTAGE_OFFSET_MASK GENMASK(18, 13) 53d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_0_MAX_VOLTAGE_OFFSET_SHIFT 13 54d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_DESTR BIT(8) 55d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_INDP_MASK GENMASK(10, 9) 56d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_INDP_SHIFT 9 57d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_MIN 0x0 58d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_LR 0x1 59d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_BOTH 0x2 60d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_STEPS_MASK GENMASK(15, 11) 61d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_STEPS_SHIFT 11 62d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_OFFSET_MASK GENMASK(20, 16) 63d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_TIME_OFFSET_SHIFT 16 64d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_MIN_BER_MASK GENMASK(25, 21) 65d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_MIN_BER_SHIFT 21 66d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_MAX_BER_MASK GENMASK(30, 26) 67d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_MAX_BER_SHIFT 26 68d0f1e0c2SMika Westerberg #define USB4_MARGIN_CAP_1_MAX_BER_SHIFT 26 69d0f1e0c2SMika Westerberg 70d0f1e0c2SMika Westerberg /* USB4_SB_OPCODE_RUN_HW_LANE_MARGINING */ 71d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_TIME BIT(3) 72d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RH BIT(4) 73d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_BER_MASK GENMASK(9, 5) 74d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_BER_SHIFT 5 75d0f1e0c2SMika Westerberg 76d0f1e0c2SMika Westerberg /* Applicable to all margin values */ 77d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RES_1_MARGIN_MASK GENMASK(6, 0) 78d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RES_1_EXCEEDS BIT(7) 79d0f1e0c2SMika Westerberg /* Different lane margin shifts */ 80d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RES_1_L0_LL_MARGIN_SHIFT 8 81d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RES_1_L1_RH_MARGIN_SHIFT 16 82d0f1e0c2SMika Westerberg #define USB4_MARGIN_HW_RES_1_L1_LL_MARGIN_SHIFT 24 83d0f1e0c2SMika Westerberg 84d0f1e0c2SMika Westerberg /* USB4_SB_OPCODE_RUN_SW_LANE_MARGINING */ 85d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_TIME BIT(3) 86d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_RH BIT(4) 87d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_MASK GENMASK(14, 13) 88d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_SHIFT 13 89d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_NOP 0x0 90d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_CLEAR 0x1 91d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_START 0x2 92d0f1e0c2SMika Westerberg #define USB4_MARGIN_SW_COUNTER_STOP 0x3 93d0f1e0c2SMika Westerberg 9402d12855SRajmohan Mani #endif 95