summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/tb.h
Commit message (Collapse)AuthorAgeFilesLines
* thunderbolt: Add support for DisplayPort bandwidth allocation modeMika Westerberg2023-01-171-0/+22
| | | | | | | | | | | | | | | | | | | The USB4 spec defines an optional feature that allows the connection manager to negotiate with the graphics through DPCD registers changes in the bandwidth allocation dynamically. This is referred as "bandwidth allocation mode" in the spec. The connection manager uses DP IN adapters registers to communicate with the graphics, and also gets notifications from these adapters when the graphics wants to change the bandwidth allocation. Both the connection manager and the graphics driver needs to support this. We check if the DP IN adapter supports this and if it does enable it before establishing a DP tunnel. Then we react on DP_BW notifications coming from the DP IN adapter and update the bandwidth allocation accordingly (within the maximum common capabilities the DP IN/OUT support). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add functions to support DisplayPort bandwidth allocation modeMika Westerberg2023-01-171-0/+15
| | | | | | | | | | | USB4 spec defines an additional feature that DP IN adapters can implement (alongside with the graphics DPCD register set) to support more dynamic bandwidth management for DisplayPort tunnels. For the connection manager the communication happens through the DP IN adapter using a set of registers in the adapter config space allocated for this. Add functions that export this functionality for the rest of the driver. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Use correct type in tb_port_is_clx_enabled() prototypeJiri Slaby (SUSE)2022-12-271-1/+1
| | | | | | | | | | | | | | tb_port_is_clx_enabled() generates a valid warning with gcc-13: drivers/thunderbolt/switch.c:1286:6: error: conflicting types for 'tb_port_is_clx_enabled' due to enum/integer mismatch; have 'bool(struct tb_port *, unsigned int)' ... drivers/thunderbolt/tb.h:1050:6: note: previous declaration of 'tb_port_is_clx_enabled' with type 'bool(struct tb_port *, enum tb_clx)' ... I.e. the type of the 2nd parameter of tb_port_is_clx_enabled() in the declaration is unsigned int, while the definition spells enum tb_clx. Synchronize them to the former as the parameter is in fact a mask of the enum values. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* Merge tag 'usb-6.1-rc1' of ↵Linus Torvalds2022-10-071-12/+44
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB / Thunderbolt updates from Greg KH: "Here is the big set of USB and Thunderbolt driver changes for 6.1-rc1. Nothing major in here, lots of little things with new devices supported and updates for a few drivers. Highlights include: - thunderbolt/USB4 devices supported a bit better than before, and some new ids to enable new hardware devices - USB gadget uvc updates for newer video formats and better v4l integration (the v4l portions were acked by those maintainers) - typec updates for tiny issues and more typec drivers for new chips. - xhci tiny updates for minor issues - big usb-serial ftdi_sio driver update to handle new devices better - lots of tiny dwc3 fixes and updates for the IP block that is showing up everywhere these days - dts updates for new devices being supported - other tiny janitorial and cleanups fixes for lots of different USB drivers. Full details are in the shortlog. All of these have been in linux-next for a while with no reported issues" * tag 'usb-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (169 commits) usb: gadget: uvc: don't put item still in use usb: gadget: uvc: Fix argument to sizeof() in uvc_register_video() usb: host: ehci-exynos: switch to using gpiod API Revert "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" Revert "USB: fixup for merge issue with "usb: dwc3: Don't switch OTG -> peripheral if extcon is present"" dt-bindings: usb: Convert FOTG210 to dt schema usb: mtu3: fix failed runtime suspend in host only mode USB: omap_udc: Fix spelling mistake: "tranceiver_ctrl" -> "transceiver_ctrl" usb: typec: ucsi_ccg: Disable UCSI ALT support on Tegra usb: typec: Replace custom implementation of device_match_fwnode() usb: typec: ucsi: Don't warn on probe deferral usb: add quirks for Lenovo OneLink+ Dock MAINTAINERS: switch dwc3 to Thinh usb: idmouse: fix an uninit-value in idmouse_open USB: PHY: JZ4770: Switch to use dev_err_probe() helper usb: phy: generic: Switch to use dev_err_probe() helper usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs usb: cdns3: remove dead code usb: cdc-wdm: Use skb_put_data() instead of skb_put/memcpy pair usb: musb: sunxi: Switch to use dev_err_probe() helper ...
| * thunderbolt: Explicitly enable lane adapter hotplug events at startupMario Limonciello2022-09-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Software that has run before the USB4 CM in Linux runs may have disabled hotplug events for a given lane adapter. Other CMs such as that one distributed with Windows 11 will enable hotplug events. Do the same thing in the Linux CM which fixes hotplug events on "AMD Pink Sardine". Cc: stable@vger.kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Move vendor specific NVM handling into nvm.cSzuying Chen2022-09-071-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As there will be more USB4 devices that support NVM firmware upgrade from various vendors, it makes sense to split out the Intel specific NVM image handling from the generic code. This moves the Intel specific NVM handling into a new structure that will be matched by the device type and the vendor ID. Do this for both routers and retimers. This makes it easier to extend the NVM support to cover new vendors and NVM image formats in the future. Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Provide tb_retimer_nvm_read() analogous to tb_switch_nvm_read()Mika Westerberg2022-09-071-0/+2
| | | | | | | | | | | | | | | | | | | | As we are moving the NVM vendor specifics into nvm.c we need to deal witht he retimer NVM formats too. For this reason provide retimer specific function that can be used to read the contents of the NVM and rename the internal ones accordingly analogous to what we do with routers. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Rename and make nvm_read() available for other filesSzuying Chen2022-09-071-0/+2
| | | | | | | | | | | | | | | | | | | | In order to support non-Intel NVM formats the vendor specific NVM validation code that will live in nvm.c needs to be able to read various parts of the NVM so make the function available outside of switch.c and rename it accordingly. Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Extend NVM version fields to 32-bitsSzuying Chen2022-09-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | In order to support non-Intel NVM image formats extend the NVM major and minor version to 32-bits to better accommondate different versioning schemes. No functional impact. Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Add support for receiver lane marginingMika Westerberg2022-09-051-0/+15
| | | | | | | | | | | | | | | | | | | | | | USB4 spec defines standard set of registers to be used for receiver lane margining. This is useful for I/O interface quality and electrical robustness validation during manufacturing. Expose receiver lane margining through new debugfs directory "margining" that is added under each connected USB4 port. Users can then run the margining by writing to the exposed attributes under that directory. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Add helper to check if CL states are enabled on portMika Westerberg2022-09-051-0/+1
| | | | | | | | | | | | We will need this when enabling lane margining support. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Pass CL state bitmask to tb_port_clx_supported()Mika Westerberg2022-09-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | Instead of testing just a single CL state we can pass a bitmask of states to check. This makes it simpler for callers of the function. We also add a check for CL2 even though not fully supported by the driver yet. Suggested-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Move tb_xdomain_parent() to tb.hMika Westerberg2022-09-051-0/+5
| | | | | | | | | | | | | | We are going to need this for lane margining support so make it available outside of xdomain.c. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* | thunderbolt: Show link type for XDomain connections tooMika Westerberg2022-08-311-1/+1
|/ | | | | | | | | Following what we do for routers already, extend this to XDomain connections as well. This will show in sysfs whether the link is in USB4 or Thunderbolt mode. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge tag 'usb-6.0-rc1' of ↵Linus Torvalds2022-08-041-22/+26
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB / Thunderbolt updates from Greg KH: "Here is the big set of Thunderbolt and USB changes for 6.0-rc1. Lots of little things here, nothing major, just constant development on some new hardware support and cleanups of older drivers. Highlights are: - lots of typec changes and improvements for new hardware - new gadget controller driver - thunderbolt support for new hardware - the normal set of new usb-serial device ids and cleanups - loads of dwc3 controller fixes and improvements - mtu3 driver updates - testusb fixes for longtime issues (not many people use this tool it seems.) - minor driver fixes and improvements over the USB tree - chromeos platform driver changes were added and then reverted as they depened on some typec changes, but the cross-tree merges caused problems so they will come back later through the platform tree. All of these have been in linux-next for a while now with no reported issues" * tag 'usb-6.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (193 commits) usb: misc: onboard_usb_hub: Remove duplicated power_on delay usb: misc: onboard_usb_hub: Add TI USB8041 hub support usb: misc: onboard_usb_hub: Add reset-gpio support USB: usbsevseg: convert sysfs snprintf to sysfs_emit dt-bindings: usb: Add binding for TI USB8041 hub controller ARM: multi_v7_defconfig: enable USB onboard HUB driver ARM: dts: stm32: add support for USB2514B onboard hub on stm32mp15xx-dkx usb: misc: onboard-hub: add support for Microchip USB2514B USB 2.0 hub dt-bindings: usb: generic-ehci: allow usb-hcd schema properties usb: typec: ucsi: stm32g0: add bootloader support usb: typec: ucsi: stm32g0: add support for stm32g0 controller dt-bindings: usb: typec: add bindings for stm32g0 controller usb: typec: ucsi: Acknowledge the GET_ERROR_STATUS command completion usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable() usb/chipidea: fix repeated words in comments usb: renesas-xhci: Do not print any log while fw verif success usb: typec: retimer: Add missing id check in match callback USB: xhci: Fix comment typo usb/typec/tcpm: fix repeated words in comments usb/musb: fix repeated words in comments ...
| * thunderbolt: Change TMU mode to HiFi uni-directional once DisplayPort tunneledGil Fine2022-06-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Here we configure TMU mode to HiFi uni-directional once DP tunnel is created. This is due to accuracy requirement for DP tunneling as appears in CM guide 1.0, section 7.3.2. Due to Intel hardware limitation, once we changed the TMU mode to HiFi uni-directional (when DP tunnel exists), we don't change TMU mode back to normal uni-directional, even if DP tunnel is torn down later. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
| * thunderbolt: Add CL1 support for USB4 and Titan Ridge routersGil Fine2022-06-061-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | In this patch we add support for a second low power state of the link: CL1. Low power states (called collectively CLx) are used to reduce transmitter and receiver power when a high-speed lane is idle. We enable it, if both sides of the link support it, and only for the first hop router (i.e. the first device that connected to the host router). This is needed for better thermal management. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* | thunderbolt: test: Use kunit_test_suite() macroDavid Gow2022-07-111-8/+0
|/ | | | | | | | | | | | | | | | | | | | The new implementation of kunit_test_suite() for modules no longer conflicts with module_init, so can now be used by the thunderbolt tests. Also update the Kconfig entry to enable the test when KUNIT_ALL_TESTS is enabled. This means that kunit_tool can now successfully run and parse the test results with, for example: ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kconfig_add CONFIG_PCI=y --kconfig_add CONFIG_USB4=y \ 'thunderbolt' Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Daniel Latypov <dlatypov@google.com> Acked-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
* thunderbolt: Split setting link width and lane bonding into own functionsMika Westerberg2022-05-051-0/+2
| | | | | | | | | | | | | When bonding lanes over XDomain the host that has "higher" UUID triggers link re-train for bonding, and the host that has "lower" UUID just waits for this to happen. To support this split setting the link width and triggering the actual bonding a separate functions that can be called as needed. While there remove duplicated empty line in the kernel-doc comment of tb_port_lane_bonding_disable(). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Move tb_port_state() prototype to correct placeMika Westerberg2022-05-051-1/+1
| | | | | | | This should be before tb_wait_for_port() following how the functions in switch.c are organized. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Use decimal number with port numbersMika Westerberg2022-04-191-1/+1
| | | | | | | This makes it consistent with the other logging functions. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Brad Campbell <lists2009@fnarfbargle.com>
* thunderbolt: Add internal xHCI connect flows for Thunderbolt 3 devicesMika Westerberg2022-02-021-0/+7
| | | | | | | | | Both Alpine Ridge and Titan Ridge require special flows in order to activate the internal xHCI controller when there is USB device connected to the downstream type-C port. This implements the missing flows for both. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add missing device ID to tb_switch_is_alpine_ridge()Mika Westerberg2022-02-021-0/+1
| | | | | | | tb_switch_is_alpine_ridge() is missing device ID for Intel Alpine Ridge dual port version so add this. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Enable CL0s for Intel Titan RidgeGil Fine2021-12-281-0/+16
| | | | | | | | | | | Low power link states (called collectively CLx) are used to reduce transmitter and receiver power when a high-speed lane is idle. The simplest one being called CL0s. Follow what we already do for USB4 device routers and enable CL0s for Intel Titan Ridge device router too. This allows better thermal management. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Implement TMU time disruption for Intel Titan RidgeGil Fine2021-12-221-0/+2
| | | | | | | | | Intel Titan Ridge based routers have slightly different flow for time disruption than USB4 compliant routers. This makes it work on Titan Ridge too. Needed to enable link low power states on Titan Ridge. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Move usb4_switch_wait_for_bit() to switch.cGil Fine2021-12-221-0/+2
| | | | | | | | | Currently usb4_switch_wait_for_bit() used only in usb4.c Moving to switch.c to call it from other files. Also change the prefix to "tb_" to follow to the naming convention. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add CL0s support for USB4 routersGil Fine2021-12-221-0/+51
| | | | | | | | | | | | | In this patch we add enabling of CL0s - a low power state of the link. Low power states (called collectively CLx) are used to reduce transmitter and receiver power when a high-speed lane is idle. For now, we add support only for first low power state: CL0s. We enable it, if both sides of the link support it, and only for the first hop router. (i.e. the first device that connected to the host router). This is needed for better thermal management. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add TMU uni-directional modeGil Fine2021-12-221-5/+25
| | | | | | | | | | Up until Titan Ridge (Thunderbolt 3) device routers only supported bi-directional mode. In this patch we add to TMU a uni-directional mode. The uni-directional mode is needed for enabling of low power state of the link (CLx). Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Tear down existing tunnels when resuming from hibernateMika Westerberg2021-12-071-1/+4
| | | | | | | | | | | | | If the boot firmware implements connection manager of its own it may not create the paths in the same way or order we do. For example it may create first PCIe tunnel and then USB3 tunnel. When we restore our tunnels (first de-activating them) we may be doing that over completely different tunnels and that leaves them possibly non-functional. For this reason we re-use the tunnel discovery functionality and find out all the existing tunnels, and tear them down. Once that is done we can restore our tunnels. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add WRITE_ONLY and AUTHENTICATE_ONLY NVM operations for retimersRajmohan Mani2021-06-011-0/+2
| | | | | | | | | | The same way we support these two operations for USB4 routers we can extend the retimer NVM operations to support retimers also. Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Allow router NVM authenticate separatelyMika Westerberg2021-06-011-0/+2
| | | | | | | | | | | | It may be useful if the actual NVM authentication can be delayed to be run later, for instance when the user logs out. For this reason add a new NVM operation (AUHENTICATE_ONLY) that just triggers the authentication procedure over whatever was written to the NVM storage. This is not supported with Thunderbolt 1-3 devices, though. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Move nvm_write_ops to tb.hRajmohan Mani2021-06-011-0/+5
| | | | | | | | | | | Currently these write ops are used for updating router firmware images only. Moving to tb.h helps the retimers also to use the same ops. Also add tb_ prefix to the enum while there. Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Add support for retimer NVM upgrade when there is no linkRajmohan Mani2021-06-011-1/+4
| | | | | | | | | | | | | | | | | | With help from platform firmware (ACPI) it is possible to power on retimers even when there is no USB4 link (e.g nothing is connected to the USB4 ports). This allows us to bring the USB4 sideband up so that we can access retimers and upgrade their NVM firmware. If the platform has support for this, we expose two additional attributes under USB4 ports: offline and rescan. These can be used to bring the port offline, rescan for the retimers and put the port online again. The retimer NVM upgrade itself works the same way than with cable connected. Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Add additional USB4 port operations for retimer accessRajmohan Mani2021-06-011-0/+3
| | | | | | | | | | | When accessing retimers when there is no cable connected we are going to need additional USB4 port operations. First the port needs to be put into offline mode, and then the sideband channel transactions must be enabled on the SBTX line. This adds support for these operations. Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Add support for ACPI _DSM to power on/off retimersRajmohan Mani2021-06-011-0/+13
| | | | | | | | | | | | | | | | | | | | | | Typically retimers can be accessed only when the USB4 link is up (e.g there is a cable connected). However, sometimes it is useful to be able to access retimers even if there is nothing connected to the USB4 port. For instance we may still want to be able to upgrade the retimer NVM firmware even if the user does not have any USB4 devices. This is something that USB4 spec leaves to implementers. In case of ACPI based systems, we can support this by providing a special _DSM method under each USB4 port. This _DSM can be used to turn on power to on-board retimers (and cycle it through different modes so that the sideband becomes usable). This patch adds support for this _DSM and makes the functionality available to the rest of the driver through tb_acpi_power_[on|off]_retimers(). Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Add USB4 port devicesMika Westerberg2021-06-011-0/+30
| | | | | | | | | | | Create devices for each USB4 port. This is needed when we add retimer access when there is no device connected but may be useful for other purposes too following what USB subsystem does. This exports a single attribute "link" that shows the type of the USB4 link (or "none" if there is no cable connected). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* thunderbolt: Allocate credits according to router preferencesMika Westerberg2021-06-011-0/+14
| | | | | | | | | | | | | | | | | | | The USB4 Connection Manager guide provides detailed information how the USB4 router buffer (credit) allocation information should be used by the connection manager when it allocates buffers for different paths. This patch implements it for Linux. For USB 3.x and DisplayPort we use directly the router preferences. The rest of the buffer space is then used for PCIe and DMA (peer-to-peer, XDomain) traffic. DMA tunnels require at least one buffer and PCIe six, so if there is not enough buffers we fail the tunnel creation. For the legacy Thunderbolt 1-3 devices we use the existing hard-coded scheme except for DMA where we use the values suggested by the USB4 spec chapter 13. Co-developed-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Update port credits after bonding is enabled/disabledMika Westerberg2021-06-011-0/+1
| | | | | | | | Once lane bonding has been enabled (or disabled) both lane adapters may update their total credits accordingly. For this reason re-read the port credits after lane bonding has been enabled or disabled. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Read router preferred credit allocation informationMika Westerberg2021-06-011-0/+22
| | | | | | | | | | | | USB4 routers must expose their preferred credit (buffer) allocation information through router operation. This information tells the connection manager how the router prefers its buffers to be allocated to get the expected bandwidth for the supported protocols. Read this information and store it as part of struct tb_switch for each USB4 router. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Wait for the lanes to actually bondMika Westerberg2021-06-011-0/+2
| | | | | | | | | It may take some time until the two lanes enter bonded state so poll for the link width to match what is expected before going forward. This ensures the link is in expected state before we start establishing paths through it. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Move nfc_credits field to struct tb_path_hopMika Westerberg2021-06-011-2/+3
| | | | | | | | | With the USB4 buffer allocation the number of credits (and non-flow credits) may be different depending on the router buffer allocation preferences. To allow this move the nfc_credits field to struct tb_path_hop. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add wake from DisplayPortMika Westerberg2021-05-311-0/+1
| | | | | | | | | | | Latest USB4 spec added a new wake bit for DisplayPort so add this to the driver when runtime suspending. This way wake up the domain when a new monitor is plugged in to any of the device routers. Also do the same for pre-USB4 devices through the link controller registers as documented in chapter 13 of the USB4 spec. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Split NVM read/write generic functions out from usb4.cMika Westerberg2021-05-311-0/+11
| | | | | | | | | We do this for Thunderbolt 2/3 devices through DMA port, USB4 devices and retimers pretty much the same way. Only the actual block read/write is different. For this reason split out the NVM read/write functions from usb4.c to nvm.c and make USB4 device code call these when needed. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Allow multiple DMA tunnels over a single XDomain connectionMika Westerberg2021-03-181-4/+12
| | | | | | | | | | | | | | | | | Currently we have had an artificial limitation of a single DMA tunnel per XDomain connection. However, hardware wise there is no such limit and software based connection manager can take advantage of all the DMA rings available on the host to establish tunnels. For this reason make the tb_xdomain_[enable|disable]_paths() to take the DMA ring and HopID as parameter instead of storing them in the struct tb_xdomain. We also add API functions to allocate input and output HopIDs of the XDomain connection that the service drivers can use instead of hard-coding. Also convert the two existing service drivers over to this API. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Drop unused tb_port_set_initial_credits()Mika Westerberg2021-03-181-1/+0
| | | | | | This function is not used anymore in the driver so we can remove it. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Decrease control channel timeout for software connection managerMika Westerberg2021-03-181-1/+1
| | | | | | | | | | | | | | | | | | When the firmware connection manager is not proxying between the software and the hardware we can decrease the timeout for control packets significantly. The USB4 spec recommends 10 ms +- 1 ms but we use slightly larger value (100 ms) which is recommendation from Intel Thunderbolt firmware folks. When firmware connection manager is running then we keep using the existing 5000 ms. To implement this we move the control channel allocation to tb_domain_alloc(), and pass the timeout from that function to the tb_ctl_alloc(). Then make both connection manager implementations pass the timeout when they alloc the domain structure. While there update kernel-doc of struct tb_ctl to match the reality. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Drop unused functions tb_switch_is_[ice|tiger]_lake()Gil Fine2021-03-081-26/+0
| | | | | | | Drop the two functions not used anymore in the driver. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* thunderbolt: Add support for native USB4 _OSCMika Westerberg2021-02-041-0/+12
| | | | | | | | | | | | | | | | ACPI 6.4 introduced a new _OSC capability used to negotiate whether the OS is supposed to use Software (native) or Firmware based Connection Manager. If the native support is granted then there are set of bits that enable/disable different tunnel types that the Software Connection Manager is allowed to tunnel. This adds support for this new USB4 _OSC accordingly. When PCIe tunneling is disabled then the driver switches security level to be "nopcie" following the security level 5 used in Firmware based Connection Manager. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
* thunderbolt: Allow disabling XDomain protocolMika Westerberg2021-02-041-0/+1
| | | | | | | | | | | | | This allows disabling XDomain protocol completely if the user does not plan to use the USB4/Thunderbolt peer-to-peer functionality, or for security reasons. XDomain protocol is enabled by default but with this commit it is possible to disable it by passing "xdomain=0" as module parameter (or through the kernel command line). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
* thunderbolt: Add clarifying comments about USB4 terms router and adapterMika Westerberg2021-02-041-0/+5
| | | | | | | | | USB4 spec talks about routers and adapters whereas Thunderbolt 1-3 talked about CIO (Converged I/O) switches and ports. These are the same thing but might cause confusion so add clarifying comments to struct tb_switch and struct tb_port about the USB4 terms. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>