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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 drivers/platform/x86/intel_cht_int33fe.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

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);
 
-- 
2.18.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux