1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2022 Scott Long 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Thunderbolt PCIe bridge/switch definitions 29 * 30 * $FreeBSD$ 31 */ 32 33 #ifndef _TB_PCIB_H 34 #define _TB_PCIB_H 35 36 DECLARE_CLASS(tb_pcib_driver); 37 38 /* 39 * The order of the fields is very important. Class inherentence replies on 40 * implicitly knowing the location of the first 3 fields. 41 */ 42 struct tb_pcib_softc { 43 struct pcib_softc pcibsc; 44 ACPI_HANDLE ap_handle; 45 ACPI_BUFFER ap_prt; 46 device_t dev; 47 u_int debug; 48 int vsec; 49 int flags; 50 struct sysctl_ctx_list *sysctl_ctx; 51 struct sysctl_oid *sysctl_tree; 52 }; 53 54 /* Flags for tb_softc */ 55 #define TB_GEN_UNK 0x00 56 #define TB_GEN_TB1 0x01 57 #define TB_GEN_TB2 0x02 58 #define TB_GEN_TB3 0x03 59 #define TB_GEN_USB4 0x04 60 #define TB_GEN_MASK 0x0f 61 #define TB_HWIF_UNK 0x00 62 #define TB_HWIF_AR 0x10 63 #define TB_HWIF_TR 0x20 64 #define TB_HWIF_ICL 0x30 65 #define TB_HWIF_USB4 0x40 66 #define TB_HWIF_MASK 0xf0 67 #define TB_FLAGS_ISROOT 0x100 68 #define TB_FLAGS_ISUFP 0x200 69 70 #define TB_IS_AR(sc) (((sc)->flags & TB_HWIF_MASK) == TB_HWIF_AR) 71 #define TB_IS_TR(sc) (((sc)->flags & TB_HWIF_MASK) == TB_HWIF_TR) 72 #define TB_IS_ICL(sc) (((sc)->flags & TB_HWIF_MASK) == TB_HWIF_ICL) 73 #define TB_IS_USB4(sc) (((sc)->flags & TB_HWIF_MASK) == TB_HWIF_USB4) 74 75 #define TB_IS_ROOT(sc) (((sc)->flags & TB_FLAGS_ISROOT) != 0) 76 #define TB_IS_UFP(sc) (((sc)->flags & TB_FLAGS_ISUFP) != 0) 77 #define TB_IS_DFP(sc) (((sc)->flags & TB_FLAGS_ISUFP) == 0) 78 79 /* PCI IDs for the TB bridges */ 80 #define TB_DEV_AR_2C 0x1576 81 #define TB_DEV_AR_LP 0x15c0 82 #define TB_DEV_AR_C_4C 0x15d3 83 #define TB_DEV_AR_C_2C 0x15da 84 #define TB_DEV_ICL_0 0x8a1d 85 #define TB_DEV_ICL_1 0x8a21 86 87 #define TB_PCIB_VSEC(dev) ((struct tb_pcib_softc *)(device_get_softc(dev)))->vsec; 88 #define TB_DESC_MAX 80 89 90 int tb_pcib_probe_common(device_t, char *); 91 int tb_pcib_attach_common(device_t dev); 92 93 #endif /* _TB_PCIB_H */ 94