From b0b5e5918ad1babfd1d43d98c7281926a7b57b9f Mon Sep 17 00:00:00 2001 From: Andrew Donnellan Date: Thu, 14 Jul 2016 07:17:14 +1000 Subject: cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards Add a new API, cxl_check_and_switch_mode() to allow for switching of bi-modal CAPI cards, such as the Mellanox CX-4 network card. When a driver requests to switch a card to CAPI mode, use PCI hotplug infrastructure to remove all PCI devices underneath the slot. We then write an updated mode control register to the CAPI VSEC, hot reset the card, and reprobe the card. As the card may present a different set of PCI devices after the mode switch, use the infrastructure provided by the pnv_php driver and the OPAL PCI slot management facilities to ensure that: * the old devices are removed from both the OPAL and Linux device trees * the new devices are probed by OPAL and added to the OPAL device tree * the new devices are added to the Linux device tree and probed through the regular PCI device probe path As such, introduce a new option, CONFIG_CXL_BIMODAL, with a dependency on the pnv_php driver. Refactor existing code that touches the mode control register in the regular single mode case into a new function, setup_cxl_protocol_area(). Co-authored-by: Ian Munsie Cc: Gavin Shan Signed-off-by: Andrew Donnellan Signed-off-by: Ian Munsie Reviewed-by: Gavin Shan Signed-off-by: Michael Ellerman --- drivers/misc/cxl/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/misc/cxl/Kconfig') diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig index 560412cd4c98..8d767705ec21 100644 --- a/drivers/misc/cxl/Kconfig +++ b/drivers/misc/cxl/Kconfig @@ -38,3 +38,11 @@ config CXL CAPI adapters are found in POWER8 based systems. If unsure, say N. + +config CXL_BIMODAL + bool "Support for bi-modal CAPI cards" + depends on HOTPLUG_PCI_POWERNV = y && CXL || HOTPLUG_PCI_POWERNV = m && CXL = m + default y + help + Select this option to enable support for bi-modal CAPI cards, such as + the Mellanox CX-4. -- cgit