1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2025 Beckhoff Automation GmbH & Co. KG 5 * Author: Corvin Köhne <c.koehne@beckhoff.com> 6 */ 7 8 #include <dev/pci/pcireg.h> 9 10 #include <errno.h> 11 12 #include "pci_passthru.h" 13 14 #define PCI_VENDOR_NVIDIA 0x10DE 15 16 static int 17 nvidia_gpu_probe(struct pci_devinst *const pi) 18 { 19 struct passthru_softc *sc; 20 uint16_t vendor; 21 uint8_t class; 22 23 sc = pi->pi_arg; 24 25 vendor = pci_host_read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02); 26 if (vendor != PCI_VENDOR_NVIDIA) 27 return (ENXIO); 28 29 class = pci_host_read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01); 30 if (class != PCIC_DISPLAY) 31 return (ENXIO); 32 33 return (0); 34 } 35 36 static int 37 nvidia_gpu_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused) 38 { 39 pci_set_cfgdata8(pi, PCIR_INTPIN, 1); 40 41 return (0); 42 } 43 44 static struct passthru_dev nvidia_gpu = { 45 .probe = nvidia_gpu_probe, 46 .init = nvidia_gpu_init, 47 }; 48 PASSTHRU_DEV_SET(nvidia_gpu); 49