diff mbox series

[3/8] plarform: x86: intel_cht_int33fe: Use the USB role switch conditionally

Message ID 20180831142026.49401-4-heikki.krogerus@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series usb: typec: A few more improvements for Intel CHT | expand

Commit Message

Heikki Krogerus Aug. 31, 2018, 2:20 p.m. UTC
Only adding connection between the USB role switch and
FUSB302 when the board has USB Device Controller (UDC).
Several CHT based products do not enable the UDC PCI device
by default.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/platform/x86/intel_cht_int33fe.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index b0cef48f77af..4d11f5fb23cd 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -24,6 +24,7 @@ 
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/pci.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
@@ -96,6 +97,7 @@  static int cht_int33fe_probe(struct i2c_client *client)
 	struct i2c_client *max17047;
 	struct regulator *regulator;
 	unsigned long long ptyp;
+	struct pci_dev *udc;
 	acpi_status status;
 	int fusb302_irq;
 	int ret;
@@ -180,9 +182,15 @@  static int cht_int33fe_probe(struct i2c_client *client)
 	data->connections[1].endpoint[0] = "i2c-fusb302";
 	data->connections[1].endpoint[1] = "i2c-pi3usb30532";
 	data->connections[1].id = "typec-mux";
-	data->connections[2].endpoint[0] = "i2c-fusb302";
-	data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch";
-	data->connections[2].id = "usb-role-switch";
+
+	/* Only adding connection for role switch if UDC exists */
+	udc = pci_get_class(PCI_CLASS_SERIAL_USB_DEVICE, NULL);
+	if (udc) {
+		pci_dev_put(udc);
+		data->connections[2].endpoint[0] = "i2c-fusb302";
+		data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch";
+		data->connections[2].id = "usb-role-switch";
+	}
 
 	device_connections_add(data->connections);