Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: Add driver for NVIDIA Alt Modes

Latest NVIDIA GPUs support VirtualLink device. Since USBIF
has not assigned a Standard ID (SID) for VirtualLink
so using NVIDA VID 0x955 as SVID.

Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ajay Gupta and committed by
Greg Kroah-Hartman
cf28369c d266e968

+64 -1
+10
drivers/usb/typec/altmodes/Kconfig
··· 12 12 To compile this driver as a module, choose M here: the 13 13 module will be called typec_displayport. 14 14 15 + config TYPEC_NVIDIA_ALTMODE 16 + tristate "NVIDIA Alternate Mode driver" 17 + depends on TYPEC_DP_ALTMODE 18 + help 19 + Latest NVIDIA GPUs support VirtualLink devices. Select this 20 + to enable support for VirtualLink devices with NVIDIA GPUs. 21 + 22 + To compile this driver as a module, choose M here: the 23 + module will be called typec_displayport. 24 + 15 25 endmenu
+2
drivers/usb/typec/altmodes/Makefile
··· 2 2 3 3 obj-$(CONFIG_TYPEC_DP_ALTMODE) += typec_displayport.o 4 4 typec_displayport-y := displayport.o 5 + obj-$(CONFIG_TYPEC_NVIDIA_ALTMODE) += typec_nvidia.o 6 + typec_nvidia-y := nvidia.o
+44
drivers/usb/typec/altmodes/nvidia.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2019 NVIDIA Corporation. All rights reserved. 4 + * 5 + * NVIDIA USB Type-C Alt Mode Driver 6 + */ 7 + #include <linux/module.h> 8 + #include <linux/usb/typec_altmode.h> 9 + #include <linux/usb/typec_dp.h> 10 + #include "displayport.h" 11 + 12 + static int nvidia_altmode_probe(struct typec_altmode *alt) 13 + { 14 + if (alt->svid == USB_TYPEC_NVIDIA_VLINK_SID) 15 + return dp_altmode_probe(alt); 16 + else 17 + return -ENOTSUPP; 18 + } 19 + 20 + static void nvidia_altmode_remove(struct typec_altmode *alt) 21 + { 22 + if (alt->svid == USB_TYPEC_NVIDIA_VLINK_SID) 23 + dp_altmode_remove(alt); 24 + } 25 + 26 + static const struct typec_device_id nvidia_typec_id[] = { 27 + { USB_TYPEC_NVIDIA_VLINK_SID, TYPEC_ANY_MODE }, 28 + { }, 29 + }; 30 + MODULE_DEVICE_TABLE(typec, nvidia_typec_id); 31 + 32 + static struct typec_altmode_driver nvidia_altmode_driver = { 33 + .id_table = nvidia_typec_id, 34 + .probe = nvidia_altmode_probe, 35 + .remove = nvidia_altmode_remove, 36 + .driver = { 37 + .name = "typec_nvidia", 38 + .owner = THIS_MODULE, 39 + }, 40 + }; 41 + module_typec_altmode_driver(nvidia_altmode_driver); 42 + 43 + MODULE_LICENSE("GPL v2"); 44 + MODULE_DESCRIPTION("NVIDIA USB Type-C Alt Mode Driver");
+3 -1
drivers/usb/typec/ucsi/ucsi.c
··· 283 283 284 284 switch (desc->svid) { 285 285 case USB_TYPEC_DP_SID: 286 + case USB_TYPEC_NVIDIA_VLINK_SID: 286 287 alt = ucsi_register_displayport(con, override, i, desc); 287 288 break; 288 289 default: ··· 405 404 406 405 while (adev[i]) { 407 406 if (recipient == UCSI_RECIPIENT_SOP && 408 - adev[i]->svid == USB_TYPEC_DP_SID) { 407 + (adev[i]->svid == USB_TYPEC_DP_SID || 408 + adev[i]->svid == USB_TYPEC_NVIDIA_VLINK_SID)) { 409 409 pdev = typec_altmode_get_partner(adev[i]); 410 410 ucsi_displayport_remove_partner((void *)pdev); 411 411 }
+5
include/linux/usb/typec_dp.h
··· 5 5 #include <linux/usb/typec_altmode.h> 6 6 7 7 #define USB_TYPEC_DP_SID 0xff01 8 + /* USB IF has not assigned a Standard ID (SID) for VirtualLink, 9 + * so the manufacturers of VirtualLink adapters use their Vendor 10 + * IDs as the SVID. 11 + */ 12 + #define USB_TYPEC_NVIDIA_VLINK_SID 0x955 /* NVIDIA VirtualLink */ 8 13 #define USB_TYPEC_DP_MODE 1 9 14 10 15 /*