From patchwork Wed Apr 10 19:50:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Gupta X-Patchwork-Id: 10894609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B68311515 for ; Wed, 10 Apr 2019 19:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CD8428B00 for ; Wed, 10 Apr 2019 19:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9183428BA1; Wed, 10 Apr 2019 19:51:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E773C28B00 for ; Wed, 10 Apr 2019 19:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726854AbfDJTvJ (ORCPT ); Wed, 10 Apr 2019 15:51:09 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46973 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726794AbfDJTvI (ORCPT ); Wed, 10 Apr 2019 15:51:08 -0400 Received: by mail-pg1-f194.google.com with SMTP id q1so2149768pgv.13 for ; Wed, 10 Apr 2019 12:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SeXAJL0wpPo6+BBBW52vsqXvxUEPnhyNdehrTQR7HyM=; b=Bla3+yde1gz5Fj2kAB7VyjqNzwlsHiL+SZC0PdhEHjs/0gQWfcJpeqFpVVVZ5+P9lY i9TDAz+HF2gzHI17+56SjGOFv1fE5wO7+gknWVM1YvaGXy3O1mi00VxcbR5btUm1cTuR fu4nhtBmk41wMj9SfZNa7brz8Fx/sjMNSmYM9xQlbyKjeA14uJIPOCM9zWSQDIAtZbh/ vRfqmmYXku1XKrplHQ//PSTbZdkP35lNAFqeMORt3f8tUFPCPW4aqvvmswdgRxKtM6uA PgBLuF750tgrLTM4dsMbUd4MeKGDjFeYqPr3ielc1blhpYk+eqVDAghJ6uE2PSXNns56 gf6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SeXAJL0wpPo6+BBBW52vsqXvxUEPnhyNdehrTQR7HyM=; b=WHZbNrq6cOUFRvOsEdRUC/HGFSnd6goNXMAzQv4hYLpTLRS7SuMjnwL0iJHQaCt4Sf gJlVTkBb88PdSeEzVQO+mYVf0yyDMp+pMoTYb/2nshpgpIat2cpdJbRn7yjETlY+W1bz Ulc4mMEm5iUKPFdwMu2924nq2FoSH6HSBpO6btJU/M9bXu6tsf6mdqhVfXwiqxvjSxMa w1FWUR0iPDcMS7A5pM0WiDVhxSxcn09IdNBEpOfHG0MVmPo4A4ArNM9MiBOnX90QkBgB uEq/bMgMBafDrLX+owksOiIhqbv/kL3nDIBOv4Pcqx+vfZo8O0VmwXxu+uIGq7Z9H9CK M83g== X-Gm-Message-State: APjAAAVwr5Rpb6ISlJWdGhCB1Sysf85Pb44RMIET0N0OVNxprA+pccRF ctObFWOYRw2dPtLfRbymf+I= X-Google-Smtp-Source: APXvYqxydAGqLgk5ThOA+HZFq4jmKH26AIHWqWGSSF+v7211sYBtPFYd4Dzt1NbqxrNXcWuAHrEqfg== X-Received: by 2002:a62:a513:: with SMTP id v19mr45076470pfm.212.1554925867794; Wed, 10 Apr 2019 12:51:07 -0700 (PDT) Received: from ajayg.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id g4sm4485786pfc.75.2019.04.10.12.51.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 12:51:07 -0700 (PDT) From: Ajay Gupta X-Google-Original-From: Ajay Gupta To: heikki.krogerus@linux.intel.com Cc: linux-usb@vger.kernel.org, Ajay Gupta Subject: [PATCH 1/2] usb: typec: displayport: Export probe and remove functions Date: Wed, 10 Apr 2019 12:50:57 -0700 Message-Id: <20190410195058.9996-2-ajayg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190410195058.9996-1-ajayg@nvidia.com> References: <20190410195058.9996-1-ajayg@nvidia.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Heikki Krogerus VirtualLink standard extends the DisplayPort Alt Mode by utilizing also the USB 2 pins on the USB Type-C connector. It uses the same messages as DisplayPort, but not the DP SVID. At the time of writing, USB IF has not assigned a Standard ID (SID) for VirtualLink, so the manufacturers of VirtualLink adapters use their Vendor IDs as the SVID. Since the SVID specific communication is exactly the same as with DisplayPort alternate mode, there is no need to implement separate driver for VirtualLink. We'll handle the current VirtualLink adapters with probe drivers, and once there is SVID assigned for it, we add it to the displayport alt mode driver. To support probing drivers, exporting the probe and remove functions, and also changing the DP_HEADER helper macro to use the SVID of the alternate mode device instead of the DisplayPort alt mode SVID. [Fixed two warnings from checkpatch.pl script -Ajay] Signed-off-by: Heikki Krogerus Signed-off-by: Ajay Gupta Tested-by: Ajay Gupta --- drivers/usb/typec/altmodes/displayport.c | 12 +++++++----- drivers/usb/typec/altmodes/displayport.h | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 drivers/usb/typec/altmodes/displayport.h diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index 610d790bc9be..bbf317c838d3 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -14,7 +14,7 @@ #include #include -#define DP_HEADER(cmd) (VDO(USB_TYPEC_DP_SID, 1, cmd) | \ +#define DP_HEADER(_dp, cmd) (VDO((_dp)->alt->svid, 1, cmd) | \ VDO_OPOS(USB_TYPEC_DP_MODE)) enum { @@ -155,7 +155,7 @@ static int dp_altmode_configured(struct dp_altmode *dp) static int dp_altmode_configure_vdm(struct dp_altmode *dp, u32 conf) { - u32 header = DP_HEADER(DP_CMD_CONFIGURE); + u32 header = DP_HEADER(dp, DP_CMD_CONFIGURE); int ret; ret = typec_altmode_notify(dp->alt, TYPEC_STATE_SAFE, &dp->data); @@ -193,7 +193,7 @@ static void dp_altmode_work(struct work_struct *work) dev_err(&dp->alt->dev, "failed to enter mode\n"); break; case DP_STATE_UPDATE: - header = DP_HEADER(DP_CMD_STATUS_UPDATE); + header = DP_HEADER(dp, DP_CMD_STATUS_UPDATE); vdo = 1; ret = typec_altmode_vdm(dp->alt, header, &vdo, 2); if (ret) @@ -507,7 +507,7 @@ static const struct attribute_group dp_altmode_group = { .attrs = dp_altmode_attrs, }; -static int dp_altmode_probe(struct typec_altmode *alt) +int dp_altmode_probe(struct typec_altmode *alt) { const struct typec_altmode *port = typec_altmode_get_partner(alt); struct dp_altmode *dp; @@ -545,14 +545,16 @@ static int dp_altmode_probe(struct typec_altmode *alt) return 0; } +EXPORT_SYMBOL_GPL(dp_altmode_probe); -static void dp_altmode_remove(struct typec_altmode *alt) +void dp_altmode_remove(struct typec_altmode *alt) { struct dp_altmode *dp = typec_altmode_get_drvdata(alt); sysfs_remove_group(&alt->dev.kobj, &dp_altmode_group); cancel_work_sync(&dp->work); } +EXPORT_SYMBOL_GPL(dp_altmode_remove); static const struct typec_device_id dp_typec_id[] = { { USB_TYPEC_DP_SID, USB_TYPEC_DP_MODE }, diff --git a/drivers/usb/typec/altmodes/displayport.h b/drivers/usb/typec/altmodes/displayport.h new file mode 100644 index 000000000000..e120364da9fd --- /dev/null +++ b/drivers/usb/typec/altmodes/displayport.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#if IS_ENABLED(CONFIG_TYPEC_DP_ALTMODE) +int dp_altmode_probe(struct typec_altmode *alt); +void dp_altmode_remove(struct typec_altmode *alt); +#else +int dp_altmode_probe(struct typec_altmode *alt) { return -ENOTSUPP; } +void dp_altmode_remove(struct typec_altmode *alt) { } +#endif /* CONFIG_TYPEC_DP_ALTMODE */ From patchwork Wed Apr 10 19:50:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Gupta X-Patchwork-Id: 10894611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEB51139A for ; Wed, 10 Apr 2019 19:51:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B761528B00 for ; Wed, 10 Apr 2019 19:51:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B593B28B90; Wed, 10 Apr 2019 19:51:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4235D28B00 for ; Wed, 10 Apr 2019 19:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbfDJTvL (ORCPT ); Wed, 10 Apr 2019 15:51:11 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45746 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbfDJTvK (ORCPT ); Wed, 10 Apr 2019 15:51:10 -0400 Received: by mail-pf1-f193.google.com with SMTP id e24so2079812pfi.12 for ; Wed, 10 Apr 2019 12:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i41RtPXA9JcCVezacaHuLFatc3IsRIgnz4SFTcDTI38=; b=BKFY6JtGU+cAuJAM3bWam3wnfDcZ8ePoN/pUIhgYt2Jj76lkMlPbFG/LmvAafzBFX+ TJQ7LIoi6rH2A+TOaSt9rba6zX/25V47Pq1U/abIz80RQGoS3hVFCDt1FzVD3kVt40YI 4RVuh6PBvA/WZiLwp4uiZE8v4oKhH1+A++8NBoBAz3MGWkCUfAtkU/Wg8/bNV24m+dix QS0mX9t9zWGYUSXnk3wEKXSDbyEuy1bVnIgpH31QhJXOam9XofIVAhFcf7KHIuS+BWql Iw/ral4QPCtRlFxke/f5vkNTpka+XQ1PpAVxHKv4AS7TsbW4ifSPeG1u+CIR4lk+ydp1 H23g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i41RtPXA9JcCVezacaHuLFatc3IsRIgnz4SFTcDTI38=; b=G4vRRUzWdyJ+bDf0ADLDC3TZIDms8PYfEmVh9jlaS8y0tv9yT+XTeuboStq4IkkHZb FPtxRbXV1L5NLL61gKEqyGz/uY/HzeE0vdSKaRvDZLQHD2reRGE/1a5zjCMueE0XJ5zj lmnvaIjXK1Q9kqOufuUqItEc8bOINqgAALpC46M5ks+6N/L4JwBMfHX71Kw12Hy1MIQJ FKYjQmw9kKV/+LxdtyA2v0pAwZAa9jLmfVm53CCwJ/7RKvVsfBmaRjlhh4nq/ADqSucT lX40jOf4QYLDop92QmGTcw7d55fKRSEWboqdDgGEL2wIx7iPra+YcdL7RJx3rkQPcZtt ci9Q== X-Gm-Message-State: APjAAAWVaF98QeHP5HORuNIXouitXqVd2pue6ic1F7Md+MZ/86UqIogk ziKgnpRQ5XQU+T0HyfE7ebowEQaU X-Google-Smtp-Source: APXvYqwlLU1Lp/00aRAFf/FVXzoSSoraLkshjjWC7LtebImO/+aQ5hCJb5cpEHkm23l8oeqVeuXa+g== X-Received: by 2002:a63:5b0a:: with SMTP id p10mr43206561pgb.282.1554925868878; Wed, 10 Apr 2019 12:51:08 -0700 (PDT) Received: from ajayg.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id g4sm4485786pfc.75.2019.04.10.12.51.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 12:51:08 -0700 (PDT) From: Ajay Gupta X-Google-Original-From: Ajay Gupta To: heikki.krogerus@linux.intel.com Cc: linux-usb@vger.kernel.org, Ajay Gupta Subject: [PATCH 2/2] usb: typec: Add driver for NVIDIA Alt Modes Date: Wed, 10 Apr 2019 12:50:58 -0700 Message-Id: <20190410195058.9996-3-ajayg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190410195058.9996-1-ajayg@nvidia.com> References: <20190410195058.9996-1-ajayg@nvidia.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ajay Gupta 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 --- drivers/usb/typec/altmodes/Kconfig | 10 +++++++ drivers/usb/typec/altmodes/Makefile | 2 ++ drivers/usb/typec/altmodes/nvidia.c | 44 +++++++++++++++++++++++++++++ drivers/usb/typec/ucsi/ucsi.c | 4 ++- include/linux/usb/typec_dp.h | 5 ++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/typec/altmodes/nvidia.c diff --git a/drivers/usb/typec/altmodes/Kconfig b/drivers/usb/typec/altmodes/Kconfig index ef2226eb7a33..187690fd1a5b 100644 --- a/drivers/usb/typec/altmodes/Kconfig +++ b/drivers/usb/typec/altmodes/Kconfig @@ -12,4 +12,14 @@ config TYPEC_DP_ALTMODE To compile this driver as a module, choose M here: the module will be called typec_displayport. +config TYPEC_NVIDIA_ALTMODE + tristate "NVIDIA Alternate Mode driver" + depends on TYPEC_DP_ALTMODE + help + Latest NVIDIA GPUs support VirtualLink devices. Select this + to enable support for VirtualLink devices with NVIDIA GPUs. + + To compile this driver as a module, choose M here: the + module will be called typec_displayport. + endmenu diff --git a/drivers/usb/typec/altmodes/Makefile b/drivers/usb/typec/altmodes/Makefile index eda8456f1c92..45717548b396 100644 --- a/drivers/usb/typec/altmodes/Makefile +++ b/drivers/usb/typec/altmodes/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_TYPEC_DP_ALTMODE) += typec_displayport.o typec_displayport-y := displayport.o +obj-$(CONFIG_TYPEC_NVIDIA_ALTMODE) += typec_nvidia.o +typec_nvidia-y := nvidia.o diff --git a/drivers/usb/typec/altmodes/nvidia.c b/drivers/usb/typec/altmodes/nvidia.c new file mode 100644 index 000000000000..c36769736405 --- /dev/null +++ b/drivers/usb/typec/altmodes/nvidia.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 NVIDIA Corporation. All rights reserved. + * + * NVIDIA USB Type-C Alt Mode Driver + */ +#include +#include +#include +#include "displayport.h" + +static int nvidia_altmode_probe(struct typec_altmode *alt) +{ + if (alt->svid == USB_TYPEC_NVIDIA_VLINK_SID) + return dp_altmode_probe(alt); + else + return -ENOTSUPP; +} + +static void nvidia_altmode_remove(struct typec_altmode *alt) +{ + if (alt->svid == USB_TYPEC_NVIDIA_VLINK_SID) + dp_altmode_remove(alt); +} + +static const struct typec_device_id nvidia_typec_id[] = { + { USB_TYPEC_NVIDIA_VLINK_SID, TYPEC_ANY_MODE }, + { }, +}; +MODULE_DEVICE_TABLE(typec, nvidia_typec_id); + +static struct typec_altmode_driver nvidia_altmode_driver = { + .id_table = nvidia_typec_id, + .probe = nvidia_altmode_probe, + .remove = nvidia_altmode_remove, + .driver = { + .name = "typec_nvidia", + .owner = THIS_MODULE, + }, +}; +module_typec_altmode_driver(nvidia_altmode_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("NVIDIA USB Type-C Alt Mode Driver"); diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 46feae074d8f..a8c8e66621ec 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -306,6 +306,7 @@ static int ucsi_register_altmode(struct ucsi_connector *con, switch (desc->svid) { case USB_TYPEC_DP_SID: + case USB_TYPEC_NVIDIA_VLINK_SID: alt = ucsi_register_displayport(con, override, i, desc); break; default: @@ -424,7 +425,8 @@ static void ucsi_unregister_altmodes(struct ucsi_connector *con, u8 recipient) while (adev[i]) { if (recipient == UCSI_RECIPIENT_SOP && - adev[i]->svid == USB_TYPEC_DP_SID) { + (adev[i]->svid == USB_TYPEC_DP_SID || + adev[i]->svid == USB_TYPEC_NVIDIA_VLINK_SID)) { pdev = typec_altmode_get_partner(adev[i]); ucsi_displayport_remove_partner((void *)pdev); } diff --git a/include/linux/usb/typec_dp.h b/include/linux/usb/typec_dp.h index 7fa12ef8d09a..fc4c7edb2e8a 100644 --- a/include/linux/usb/typec_dp.h +++ b/include/linux/usb/typec_dp.h @@ -5,6 +5,11 @@ #include #define USB_TYPEC_DP_SID 0xff01 +/* USB IF has not assigned a Standard ID (SID) for VirtualLink, + * so the manufacturers of VirtualLink adapters use their Vendor + * IDs as the SVID. + */ +#define USB_TYPEC_NVIDIA_VLINK_SID 0x955 /* NVIDIA VirtualLink */ #define USB_TYPEC_DP_MODE 1 /*