All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] usb: add support for Intel dual role port mux
@ 2016-03-03  6:37 Lu Baolu
  2016-03-03  6:37 ` [PATCH 1/7] extcon: usb-gpio: add device binding for platform device Lu Baolu
                   ` (6 more replies)
  0 siblings, 7 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

Intel SOC chips are featured with USB dual role. The host role is
provided by Intel xHCI IP, and the gadget role is provided by IP
from designware. Tablet platform designs always share a single
port for both host and gadget controllers. There is a mux to
switch the port to the right controller according to the cable
type. OS needs to provide the callback to control the mux when
a plug-in event raises. The method to control the mux is platform
dependent. At least three types of implementation can be found
across current devices. 1) GPIO pins; 2) a unit which can be
controlled by memory mapped registers; 3) ACPI ASL code.

This patch series adds supports for Intel dual role port mux.
It includes:
(1) A helper layer on top of extcon for individual mux driver.
    It listens to the USB-HOST extcon cable and call the switch
    call-back when the cable state changes.
(2) Drivers for GPIO controlled port mux which could be found on
    Baytrail devices. A mfd driver is used to split the GPIOs into
    USB gpio extcon device and a USB mux device. Driver for USB
    gpio extcon device is already in upstream Linux. This patch
    series includes a driver for GPIO USB mux.
(3) Drivers for USB port mux controlled through memory mapped
    registers and the logic to create the mux device. This type
    of dual role port mux could be found in Cherry Trail and
    Broxton devices.

Lu Baolu (7):
  extcon: usb-gpio: add device binding for platform device
  extcon: usb-gpio: add support for ACPI gpio interface
  usb: misc: add common code for Intel dual role port mux
  usb: misc: add driver for Intel gpio controlled port mux
  usb: misc: add driver for Intel drcfg controlled port mux
  usb: pci-quirks: add Intel USB drcfg mux device
  mfd: intel_vuport: Add Intel virtual USB port MFD Driver

 MAINTAINERS                        |  10 +++
 drivers/extcon/extcon-usb-gpio.c   |  10 ++-
 drivers/mfd/Kconfig                |   7 ++
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/intel-vuport.c         |  79 +++++++++++++++++
 drivers/usb/host/pci-quirks.c      |  47 +++++++++-
 drivers/usb/host/xhci-ext-caps.h   |   2 +
 drivers/usb/misc/Kconfig           |  20 +++++
 drivers/usb/misc/Makefile          |   4 +
 drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
 drivers/usb/misc/intel-mux-gpio.c  | 126 +++++++++++++++++++++++++++
 drivers/usb/misc/mux.c             | 172 ++++++++++++++++++++++++++++++++++++
 include/linux/usb/mux.h            |  71 +++++++++++++++
 13 files changed, 720 insertions(+), 3 deletions(-)
 create mode 100644 drivers/mfd/intel-vuport.c
 create mode 100644 drivers/usb/misc/intel-mux-drcfg.c
 create mode 100644 drivers/usb/misc/intel-mux-gpio.c
 create mode 100644 drivers/usb/misc/mux.c
 create mode 100644 include/linux/usb/mux.h

-- 
2.1.4

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 1/7] extcon: usb-gpio: add device binding for platform device
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03  7:24   ` Chanwoo Choi
  2016-03-03  6:37 ` [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

This is needed to handle the GPIO connected USB ID pin found on
Intel Baytrail devices.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 drivers/extcon/extcon-usb-gpio.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 2b2fecf..af9c8b0 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -206,6 +206,12 @@ static const struct of_device_id usb_extcon_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, usb_extcon_dt_match);
 
+static const struct platform_device_id usb_extcon_platform_ids[] = {
+	{ .name = "extcon-usb-gpio", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, usb_extcon_platform_ids);
+
 static struct platform_driver usb_extcon_driver = {
 	.probe		= usb_extcon_probe,
 	.remove		= usb_extcon_remove,
@@ -214,6 +220,7 @@ static struct platform_driver usb_extcon_driver = {
 		.pm	= &usb_extcon_pm_ops,
 		.of_match_table = usb_extcon_dt_match,
 	},
+	.id_table = usb_extcon_platform_ids,
 };
 
 module_platform_driver(usb_extcon_driver);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
  2016-03-03  6:37 ` [PATCH 1/7] extcon: usb-gpio: add device binding for platform device Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03  7:24   ` Chanwoo Choi
  2016-03-03  6:37 ` [PATCH 3/7] usb: misc: add common code for Intel dual role port mux Lu Baolu
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

GPIO resource could be retrieved through APCI as well.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 drivers/extcon/extcon-usb-gpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index af9c8b0..472c431 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -26,6 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
+#include <linux/acpi.h>
 
 #define USB_GPIO_DEBOUNCE_MS	20	/* ms */
 
@@ -91,7 +92,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
 	struct usb_extcon_info *info;
 	int ret;
 
-	if (!np)
+	if (!np && !ACPI_HANDLE(dev))
 		return -EINVAL;
 
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 3/7] usb: misc: add common code for Intel dual role port mux
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
  2016-03-03  6:37 ` [PATCH 1/7] extcon: usb-gpio: add device binding for platform device Lu Baolu
  2016-03-03  6:37 ` [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03 16:10   ` Greg Kroah-Hartman
  2016-03-03 16:15   ` Greg Kroah-Hartman
  2016-03-03  6:37 ` [PATCH 4/7] usb: misc: add driver for Intel gpio controlled " Lu Baolu
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

Several Intel PCHs and SOCs have an internal mux that is used to
share one USB port between device controller and host controller.

A usb port mux could be abstracted as the following elements:
1) mux state: HOST or PERIPHERAL;
2) an extcon cable which triggers the change of mux state between
   HOST and PERIPHERAL;
3) The required action to do the real port switch.

This patch adds the common code to handle usb port mux. With this
common code, the individual mux driver, which always is platform
dependent, could focus on the real operation of mux switch.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 MAINTAINERS               |   7 ++
 drivers/usb/misc/Kconfig  |   4 ++
 drivers/usb/misc/Makefile |   2 +
 drivers/usb/misc/mux.c    | 172 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/mux.h   |  71 +++++++++++++++++++
 5 files changed, 256 insertions(+)
 create mode 100644 drivers/usb/misc/mux.c
 create mode 100644 include/linux/usb/mux.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d894ee2..45f1e1e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11389,6 +11389,13 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
 S:	Maintained
 F:	drivers/usb/phy/
 
+USB PORT MUX DRIVER
+M:	Lu Baolu <baolu.lu@linux.intel.com>
+L:	linux-usb@vger.kernel.org
+S:	Supported
+F:	drivers/usb/misc/mux.c
+F:	include/linux/usb/mux.h
+
 USB PRINTER DRIVER (usblp)
 M:	Pete Zaitcev <zaitcev@redhat.com>
 L:	linux-usb@vger.kernel.org
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index f7a7fc2..6496d17 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -3,6 +3,10 @@
 #
 comment "USB Miscellaneous drivers"
 
+config USB_MUX
+	select EXTCON
+	def_bool n
+
 config USB_EMI62
 	tristate "EMI 6|2m USB Audio interface support"
 	---help---
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 45fd4ac..fd79dd5 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -29,3 +29,5 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
+
+obj-$(CONFIG_USB_MUX)			+= mux.o
diff --git a/drivers/usb/misc/mux.c b/drivers/usb/misc/mux.c
new file mode 100644
index 0000000..e353fff
--- /dev/null
+++ b/drivers/usb/misc/mux.c
@@ -0,0 +1,172 @@
+/**
+ * mux.c - USB Port Mux support
+ *
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/notifier.h>
+#include <linux/usb/mux.h>
+#include <linux/debugfs.h>
+#include <linux/err.h>
+
+static int usb_mux_change_state(struct usb_mux *mux, int state)
+{
+	int ret;
+	struct usb_mux_dev *umdev = mux->umdev;
+
+	dev_WARN_ONCE(umdev->dev, !mutex_is_locked(&mux->mux_mutex),
+			"mutex is unlocked\n");
+
+	mux->mux_state = state;
+
+	if (mux->mux_state)
+		ret = umdev->cable_set_cb(umdev);
+	else
+		ret = umdev->cable_unset_cb(umdev);
+
+	return ret;
+}
+
+static int usb_mux_notifier(struct notifier_block *nb,
+		unsigned long event, void *ptr)
+{
+	struct usb_mux *mux;
+	int state;
+	int ret = NOTIFY_DONE;
+
+	mux = container_of(nb, struct usb_mux, nb);
+
+	state = extcon_get_cable_state(mux->obj.edev,
+			mux->umdev->cable_name);
+
+	if (mux->mux_state == -1 || mux->mux_state != state) {
+		mutex_lock(&mux->mux_mutex);
+		ret = usb_mux_change_state(mux, state);
+		mutex_unlock(&mux->mux_mutex);
+	}
+
+	return ret;
+}
+
+static ssize_t mux_debug_read(struct file *file, char __user *user_buf,
+		size_t len, loff_t *offset)
+{
+	struct usb_mux *mux = file->private_data;
+	char output_buf[16];
+
+	memset(output_buf, 0, sizeof(output_buf));
+	if (mux->mux_state)
+		strcpy(output_buf, "host\n");
+	else
+		strcpy(output_buf, "peripheral\n");
+
+	return simple_read_from_buffer(user_buf, len, offset,
+			output_buf, strlen(output_buf));
+}
+
+static ssize_t mux_debug_write(struct file *file, const char __user *user_buf,
+		size_t count, loff_t *offset)
+{
+	struct usb_mux *mux = file->private_data;
+	char input_buf[16];
+	int size, state;
+
+	size = min(count, sizeof(input_buf) - 1);
+	memset(input_buf, 0, sizeof(input_buf));
+	if (strncpy_from_user(input_buf, user_buf, size) < 0)
+		return -EFAULT;
+
+	if (!strncmp(input_buf, "host", 4))
+		state = 1;
+	else if (!strncmp(input_buf, "peripheral", 10))
+		state = 0;
+	else
+		state = -1;
+
+	if (state != -1) {
+		mutex_lock(&mux->mux_mutex);
+		usb_mux_change_state(mux, state);
+		mutex_unlock(&mux->mux_mutex);
+	}
+
+	return count;
+}
+
+static const struct file_operations mux_debug_fops = {
+	.read =		mux_debug_read,
+	.write =	mux_debug_write,
+	.open =		simple_open,
+	.llseek =	default_llseek,
+};
+
+int usb_mux_register(struct usb_mux_dev *umdev)
+{
+	int ret;
+	struct device *dev = umdev->dev;
+	struct usb_mux *mux;
+
+	if (!umdev->cable_name)
+		return -ENODEV;
+
+	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
+	if (!mux)
+		return -ENOMEM;
+
+	mux->umdev = umdev;
+	mux->nb.notifier_call = usb_mux_notifier;
+	mutex_init(&mux->mux_mutex);
+	mux->mux_state = -1;
+	dev_set_drvdata(dev, mux);
+
+	ret = extcon_register_interest(&mux->obj, umdev->extcon_name,
+			umdev->cable_name, &mux->nb);
+	if (ret) {
+		dev_err(dev, "failed to register extcon notifier\n");
+		return -ENODEV;
+	}
+
+	usb_mux_notifier(&mux->nb, 0, NULL);
+
+	mux->debug_file = debugfs_create_file("usb_mux", 0600,
+			usb_debug_root, mux, &mux_debug_fops);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(usb_mux_register);
+
+int usb_mux_unregister(struct device *dev)
+{
+	struct usb_mux *mux = dev_get_drvdata(dev);
+
+	debugfs_remove(mux->debug_file);
+	extcon_unregister_interest(&mux->obj);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(usb_mux_unregister);
+
+struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
+{
+	struct usb_mux *mux = dev_get_drvdata(dev);
+
+	if (mux)
+		return mux->umdev;
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(usb_mux_get_dev);
+
+#ifdef CONFIG_PM_SLEEP
+void usb_mux_complete(struct device *dev)
+{
+	struct usb_mux *mux = dev_get_drvdata(dev);
+
+	usb_mux_notifier(&mux->nb, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(usb_mux_complete);
+#endif
diff --git a/include/linux/usb/mux.h b/include/linux/usb/mux.h
new file mode 100644
index 0000000..5dada48
--- /dev/null
+++ b/include/linux/usb/mux.h
@@ -0,0 +1,71 @@
+/**
+ * mux.h - USB Port Mux defines
+ *
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_USB_MUX_H
+#define __LINUX_USB_MUX_H
+
+#include <linux/extcon.h>
+#include <linux/usb.h>
+
+struct usb_mux_dev {
+	struct device	*dev;
+	char		*extcon_name;
+	char		*cable_name;
+	int		(*cable_set_cb)(struct usb_mux_dev *mux);
+	int		(*cable_unset_cb)(struct usb_mux_dev *mux);
+};
+
+struct usb_mux {
+	struct usb_mux_dev		*umdev;
+	struct notifier_block		nb;
+	struct extcon_specific_cable_nb	obj;
+
+	/*
+	 * The state of the mux.
+	 * 0, 1 - mux switch state
+	 * -1   - uninitialized state
+	 *
+	 * mux_mutex is lock to protect mux_state
+	 */
+	int				mux_state;
+	struct mutex			mux_mutex;
+
+	struct dentry			*debug_file;
+};
+
+#if IS_ENABLED(CONFIG_USB_MUX)
+extern int usb_mux_register(struct usb_mux_dev *mux);
+extern int usb_mux_unregister(struct device *dev);
+extern struct usb_mux_dev *usb_mux_get_dev(struct device *dev);
+
+#ifdef CONFIG_PM_SLEEP
+extern void usb_mux_complete(struct device *dev);
+#endif
+
+#else /* CONFIG_USB_MUX */
+static inline int usb_mux_register(struct usb_mux_dev *mux)
+{
+	return -ENODEV;
+}
+
+static inline int usb_mux_unregister(struct device *dev)
+{
+	return 0;
+}
+
+static inline struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
+{
+	return NULL;
+}
+#endif /* CONFIG_USB_MUX */
+
+#endif /* __LINUX_USB_MUX_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 4/7] usb: misc: add driver for Intel gpio controlled port mux
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
                   ` (2 preceding siblings ...)
  2016-03-03  6:37 ` [PATCH 3/7] usb: misc: add common code for Intel dual role port mux Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03  8:16   ` kbuild test robot
  2016-03-03  8:16   ` [PATCH] usb: misc: fix platform_no_drv_owner.cocci warnings kbuild test robot
  2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu, David Cohen

In some Intel platforms, a single usb port is shared between USB host
and device controller. The shared port is under control of GPIO pins.

This patch adds the support for USB GPIO controlled port mux.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 MAINTAINERS                       |   1 +
 drivers/usb/misc/Kconfig          |   9 +++
 drivers/usb/misc/Makefile         |   1 +
 drivers/usb/misc/intel-mux-gpio.c | 126 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 137 insertions(+)
 create mode 100644 drivers/usb/misc/intel-mux-gpio.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 45f1e1e..0f321e4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11395,6 +11395,7 @@ L:	linux-usb@vger.kernel.org
 S:	Supported
 F:	drivers/usb/misc/mux.c
 F:	include/linux/usb/mux.h
+F:	drivers/usb/misc/intel-mux-gpio.c
 
 USB PRINTER DRIVER (usblp)
 M:	Pete Zaitcev <zaitcev@redhat.com>
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 6496d17..33e6386 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -272,3 +272,12 @@ config USB_CHAOSKEY
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called chaoskey.
+
+config INTEL_MUX_GPIO
+	tristate "Intel dual role port mux controlled by GPIOs"
+	depends on GPIOLIB
+	depends on ACPI
+	select USB_MUX
+	help
+	  Say Y here to enable support for Intel dual role port mux
+	  controlled by GPIOs.
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index fd79dd5..da4fb4e 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
 
 obj-$(CONFIG_USB_MUX)			+= mux.o
+obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
diff --git a/drivers/usb/misc/intel-mux-gpio.c b/drivers/usb/misc/intel-mux-gpio.c
new file mode 100644
index 0000000..ae109e3
--- /dev/null
+++ b/drivers/usb/misc/intel-mux-gpio.c
@@ -0,0 +1,126 @@
+/*
+ * USB Dual Role Port Mux driver controlled by gpios
+ *
+ * Copyright (c) 2016, Intel Corporation.
+ * Author: David Cohen <david.a.cohen@linux.intel.com>
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/usb/mux.h>
+
+struct vuport {
+	struct usb_mux_dev umdev;
+	struct gpio_desc *gpio_vbus_en;
+	struct gpio_desc *gpio_usb_mux;
+};
+
+/*
+ * id == 0, HOST connected, USB port should be set to peripheral
+ * id == 1, HOST disconnected, USB port should be set to host
+ *
+ * Peripheral: set USB mux to peripheral and disable VBUS
+ * Host: set USB mux to host and enable VBUS
+ */
+static inline int vuport_set_port(struct usb_mux_dev *umdev, int id)
+{
+	struct vuport *vup = container_of(umdev, struct vuport, umdev);
+
+	dev_dbg(umdev->dev, "USB PORT ID: %s\n", id ? "HOST" : "PERIPHERAL");
+
+	gpiod_set_value_cansleep(vup->gpio_usb_mux, !id);
+	gpiod_set_value_cansleep(vup->gpio_vbus_en, id);
+
+	return 0;
+}
+
+static int vuport_cable_set(struct usb_mux_dev *umdev)
+{
+	return vuport_set_port(umdev, 1);
+}
+
+static int vuport_cable_unset(struct usb_mux_dev *umdev)
+{
+	return vuport_set_port(umdev, 0);
+}
+
+static int vuport_probe(struct platform_device *pdev)
+{
+	struct usb_mux_dev *umdev;
+	struct device *dev = &pdev->dev;
+	struct vuport *vup;
+
+	vup = devm_kzalloc(dev, sizeof(*vup), GFP_KERNEL);
+	if (!vup)
+		return -ENOMEM;
+
+	/* retrieve vbus and mux gpios */
+	vup->gpio_vbus_en = devm_gpiod_get_optional(dev,
+				"vbus_en", GPIOD_ASIS);
+	if (IS_ERR(vup->gpio_vbus_en))
+		return PTR_ERR(vup->gpio_vbus_en);
+
+	vup->gpio_usb_mux = devm_gpiod_get_optional(dev,
+				"usb_mux", GPIOD_ASIS);
+	if (IS_ERR(vup->gpio_usb_mux))
+		return PTR_ERR(vup->gpio_usb_mux);
+
+	/* populate the mux generic structure */
+	umdev = &vup->umdev;
+	umdev->dev = dev;
+	umdev->cable_name = "USB-HOST";
+	umdev->cable_set_cb = vuport_cable_set;
+	umdev->cable_unset_cb = vuport_cable_unset;
+
+	return usb_mux_register(umdev);
+}
+
+static int vuport_remove(struct platform_device *pdev)
+{
+	return usb_mux_unregister(&pdev->dev);
+}
+
+#ifdef CONFIG_PM_SLEEP
+/*
+ * In case a micro A cable was plugged in while device was sleeping,
+ * we missed the interrupt. We need to poll usb id gpio when waking the
+ * driver to detect the missed event.
+ * We use 'complete' callback to give time to all extcon listeners to
+ * resume before we send new events.
+ */
+static const struct dev_pm_ops vuport_pm_ops = {
+	.complete = usb_mux_complete,
+};
+#endif
+
+static const struct platform_device_id vuport_platform_ids[] = {
+	{ .name = "intel-mux-gpio", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, vuport_platform_ids);
+
+static struct platform_driver vuport_driver = {
+	.driver = {
+		.name = "intel-mux-gpio",
+		.owner = THIS_MODULE,
+#ifdef CONFIG_PM_SLEEP
+		.pm = &vuport_pm_ops,
+#endif
+	},
+	.probe = vuport_probe,
+	.remove = vuport_remove,
+	.id_table = vuport_platform_ids,
+};
+
+module_platform_driver(vuport_driver);
+
+MODULE_AUTHOR("David Cohen <david.a.cohen@linux.intel.com>");
+MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
+MODULE_DESCRIPTION("Intel USB gpio mux driver");
+MODULE_LICENSE("GPL v2");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
                   ` (3 preceding siblings ...)
  2016-03-03  6:37 ` [PATCH 4/7] usb: misc: add driver for Intel gpio controlled " Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03 15:20   ` kbuild test robot
                     ` (2 more replies)
  2016-03-03  6:37 ` [PATCH 6/7] usb: pci-quirks: add Intel USB drcfg mux device Lu Baolu
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
  6 siblings, 3 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu, Wu Hao

Several Intel PCHs and SOCs have an internal mux that is used to
share one USB port between device controller and host controller.
The mux is handled through the Dual Role Configuration Register.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Wu Hao <hao.wu@intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 MAINTAINERS                        |   1 +
 drivers/usb/misc/Kconfig           |   7 ++
 drivers/usb/misc/Makefile          |   1 +
 drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
 4 files changed, 183 insertions(+)
 create mode 100644 drivers/usb/misc/intel-mux-drcfg.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0f321e4..20eb873 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11396,6 +11396,7 @@ S:	Supported
 F:	drivers/usb/misc/mux.c
 F:	include/linux/usb/mux.h
 F:	drivers/usb/misc/intel-mux-gpio.c
+F:	drivers/usb/misc/intel-mux-drcfg.c
 
 USB PRINTER DRIVER (usblp)
 M:	Pete Zaitcev <zaitcev@redhat.com>
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 33e6386..befd910 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -281,3 +281,10 @@ config INTEL_MUX_GPIO
 	help
 	  Say Y here to enable support for Intel dual role port mux
 	  controlled by GPIOs.
+
+config INTEL_MUX_DRCFG
+	tristate "Intel dual role port mux controlled by register"
+	select USB_MUX
+	help
+	  Say Y here to enable support for Intel dual role port mux
+	  controlled by the Dual Role Configuration Registers.
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index da4fb4e..c4d19a0 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -32,3 +32,4 @@ obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
 
 obj-$(CONFIG_USB_MUX)			+= mux.o
 obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
+obj-$(CONFIG_INTEL_MUX_DRCFG)		+= intel-mux-drcfg.o
diff --git a/drivers/usb/misc/intel-mux-drcfg.c b/drivers/usb/misc/intel-mux-drcfg.c
new file mode 100644
index 0000000..29081c5
--- /dev/null
+++ b/drivers/usb/misc/intel-mux-drcfg.c
@@ -0,0 +1,174 @@
+/**
+ * intel-mux-drcfg.c - Driver for Intel USB mux via register
+ *
+ * Copyright (C) 2016 Intel Corporation
+ * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/property.h>
+#include <linux/usb/mux.h>
+#include <linux/platform_device.h>
+
+#define INTEL_MUX_CFG0		0x00
+#define INTEL_MUX_CFG1		0x04
+#define CFG0_SW_IDPIN		BIT(20)
+#define CFG0_SW_IDPIN_EN	BIT(21)
+#define CFG0_SW_VBUS_VALID	BIT(24)
+#define CFG1_SW_MODE		BIT(29)
+#define CFG1_POLL_TIMEOUT	1000
+
+struct intel_usb_mux {
+	struct usb_mux_dev umdev;
+	void __iomem *regs;
+	u32 cfg0_ctx;
+};
+
+static inline int intel_mux_drcfg_switch(struct usb_mux_dev *umdev, bool host)
+{
+	struct intel_usb_mux *mux;
+	unsigned long timeout;
+	u32 data;
+
+	mux = container_of(umdev, struct intel_usb_mux, umdev);
+
+	/* Check and set mux to SW controlled mode */
+	data = readl(mux->regs + INTEL_MUX_CFG0);
+	if (!(data & CFG0_SW_IDPIN_EN)) {
+		data |= CFG0_SW_IDPIN_EN;
+		writel(data, mux->regs + INTEL_MUX_CFG0);
+	}
+
+	/*
+	 * Configure CFG0 to switch the mux and VBUS_VALID bit is
+	 * required for device mode.
+	 */
+	data = readl(mux->regs + INTEL_MUX_CFG0);
+	if (host)
+		data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
+	else
+		data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
+	writel(data, mux->regs + INTEL_MUX_CFG0);
+
+	/*
+	 * Polling CFG1 for safety, most case it takes about 600ms
+	 * to finish mode switching, set TIMEOUT long enough.
+	 */
+	timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
+
+	/* Polling on CFG1 register to confirm mode switch. */
+	while (!time_after(jiffies, timeout)) {
+		data = readl(mux->regs + INTEL_MUX_CFG1);
+		if (!(host ^ (data & CFG1_SW_MODE)))
+			return 0;
+		/* interval for polling is set to about 5ms */
+		usleep_range(5000, 5100);
+	}
+
+	return -ETIMEDOUT;
+}
+
+static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
+{
+	dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
+
+	return intel_mux_drcfg_switch(umdev, true);
+}
+
+static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
+{
+	dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
+
+	return intel_mux_drcfg_switch(umdev, false);
+}
+
+static int intel_mux_drcfg_probe(struct platform_device *pdev)
+{
+	struct intel_usb_mux *mux;
+	struct usb_mux_dev *umdev;
+	struct device *dev = &pdev->dev;
+	u64 start, size;
+	int ret;
+
+	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
+	if (!mux)
+		return -ENOMEM;
+
+	ret = device_property_read_u64(dev, "reg-start", &start);
+	ret |= device_property_read_u64(dev, "reg-size", &size);
+	if (ret)
+		return -ENODEV;
+
+	mux->regs = devm_ioremap_nocache(dev, start, size);
+	if (!mux->regs)
+		return -ENOMEM;
+
+	mux->cfg0_ctx = readl(mux->regs + INTEL_MUX_CFG0);
+
+	umdev = &mux->umdev;
+	umdev->dev = dev;
+	umdev->cable_name = "USB-HOST";
+	umdev->cable_set_cb = intel_mux_drcfg_cable_set;
+	umdev->cable_unset_cb = intel_mux_drcfg_cable_unset;
+
+	ret = usb_mux_register(umdev);
+	if (ret)
+		writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);
+
+	return ret;
+}
+
+static int intel_mux_drcfg_remove(struct platform_device *pdev)
+{
+	struct usb_mux_dev *umdev = usb_mux_get_dev(&pdev->dev);
+	struct intel_usb_mux *mux = container_of(umdev,
+				struct intel_usb_mux, umdev);
+
+	writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);
+
+	return usb_mux_unregister(&pdev->dev);
+}
+
+#ifdef CONFIG_PM_SLEEP
+/*
+ * In case a micro A cable was plugged in while device was sleeping,
+ * we missed the interrupt. We need to poll usb id state when waking
+ * the driver to detect the missed event.
+ * We use 'complete' callback to give time to all extcon listeners to
+ * resume before we send new events.
+ */
+static const struct dev_pm_ops intel_mux_drcfg_pm_ops = {
+	.complete = usb_mux_complete,
+};
+#endif
+
+static const struct platform_device_id intel_mux_drcfg_platform_ids[] = {
+	{ .name = "intel-mux-drcfg", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, intel_mux_drcfg_platform_ids);
+
+static struct platform_driver intel_mux_drcfg_driver = {
+	.probe		= intel_mux_drcfg_probe,
+	.remove		= intel_mux_drcfg_remove,
+	.driver		= {
+		.name	= "intel-mux-drcfg",
+#ifdef CONFIG_PM_SLEEP
+		.pm	= &intel_mux_drcfg_pm_ops,
+#endif
+	},
+	.id_table = intel_mux_drcfg_platform_ids,
+};
+
+module_platform_driver(intel_mux_drcfg_driver);
+
+MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
+MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
+MODULE_DESCRIPTION("Intel USB drcfg mux driver");
+MODULE_LICENSE("GPL v2");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 6/7] usb: pci-quirks: add Intel USB drcfg mux device
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
                   ` (4 preceding siblings ...)
  2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
  6 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

In some Intel platforms, a single usb port is shared between USB host
and device controllers. The shared port is under control of a switch
which is defined in the Intel vendor defined extended capability for
xHCI.

This patch adds the support to detect and create the platform device
for the port mux switch.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 drivers/usb/host/pci-quirks.c    | 47 ++++++++++++++++++++++++++++++++++++++--
 drivers/usb/host/xhci-ext-caps.h |  2 ++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 35af362..6a737cf 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -16,10 +16,11 @@
 #include <linux/export.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/platform_device.h>
+
 #include "pci-quirks.h"
 #include "xhci-ext-caps.h"
 
-
 #define UHCI_USBLEGSUP		0xc0		/* legacy support */
 #define UHCI_USBCMD		0		/* command register */
 #define UHCI_USBINTR		4		/* interrupt register */
@@ -78,6 +79,9 @@
 #define USB_INTEL_USB3_PSSEN   0xD8
 #define USB_INTEL_USB3PRM      0xDC
 
+#define DEVICE_ID_INTEL_CHERRYVIEW_XHCI		0x22b5
+#define DEVICE_ID_INTEL_BROXTON_M_XHCI		0x0aa8
+
 /*
  * amd_chipset_gen values represent AMD different chipset generations
  */
@@ -956,6 +960,41 @@ void usb_disable_xhci_ports(struct pci_dev *xhci_pdev)
 }
 EXPORT_SYMBOL_GPL(usb_disable_xhci_ports);
 
+static void create_intel_usb_mux_device(struct pci_dev *xhci_pdev,
+			void __iomem *base)
+{
+	struct platform_device *plat_dev;
+	struct property_set pset;
+	int ret;
+
+	struct property_entry pentry[] = {
+		PROPERTY_ENTRY_U64("reg-start",
+				pci_resource_start(xhci_pdev, 0) + 0x80d8),
+		PROPERTY_ENTRY_U64("reg-size", 8),
+		{ },
+	};
+
+	if (!xhci_find_next_ext_cap(base, 0, XHCI_EXT_CAPS_INTEL_USB_MUX))
+		return;
+
+	plat_dev = platform_device_alloc("intel-mux-drcfg",
+					PLATFORM_DEVID_AUTO);
+	if (!plat_dev)
+		return;
+
+	plat_dev->dev.parent = &xhci_pdev->dev;
+	pset.properties = pentry;
+	platform_device_add_properties(plat_dev, &pset);
+
+	ret = platform_device_add(plat_dev);
+	if (ret) {
+		dev_warn(&xhci_pdev->dev,
+				"failed to create mux device with error %d",
+				ret);
+		platform_device_put(plat_dev);
+	}
+}
+
 /**
  * PCI Quirks for xHCI.
  *
@@ -1022,8 +1061,12 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
 	writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
 
 hc_init:
-	if (pdev->vendor == PCI_VENDOR_ID_INTEL)
+	if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
 		usb_enable_intel_xhci_ports(pdev);
+		if (pdev->device == DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
+				pdev->device == DEVICE_ID_INTEL_BROXTON_M_XHCI)
+			create_intel_usb_mux_device(pdev, base);
+	}
 
 	op_reg_base = base + XHCI_HC_LENGTH(readl(base));
 
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index e0244fb..e368ccb 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -51,6 +51,8 @@
 #define XHCI_EXT_CAPS_ROUTE	5
 /* IDs 6-9 reserved */
 #define XHCI_EXT_CAPS_DEBUG	10
+/* Vendor defined 192-255 */
+#define XHCI_EXT_CAPS_INTEL_USB_MUX	192
 /* USB Legacy Support Capability - section 7.1.1 */
 #define XHCI_HC_BIOS_OWNED	(1 << 16)
 #define XHCI_HC_OS_OWNED	(1 << 24)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
  2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
                   ` (5 preceding siblings ...)
  2016-03-03  6:37 ` [PATCH 6/7] usb: pci-quirks: add Intel USB drcfg mux device Lu Baolu
@ 2016-03-03  6:37 ` Lu Baolu
  2016-03-03  8:16   ` kbuild test robot
                     ` (4 more replies)
  6 siblings, 5 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  6:37 UTC (permalink / raw)
  To: Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman, Lee Jones,
	Heikki Krogerus, MyungJoo Ham, Chanwoo Choi
  Cc: linux-usb, linux-kernel, Lu Baolu

Some Intel platforms have an USB port mux controlled by GPIOs.
There's a single ACPI platform device that provides both USB ID
extcon device and a USB port mux device. This MFD driver will
split the 2 devices for their respective drivers.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Suggested-by: David Cohen <david.a.cohen@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 MAINTAINERS                |  1 +
 drivers/mfd/Kconfig        |  7 ++++
 drivers/mfd/Makefile       |  1 +
 drivers/mfd/intel-vuport.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 88 insertions(+)
 create mode 100644 drivers/mfd/intel-vuport.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 20eb873..6e0bb12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11397,6 +11397,7 @@ F:	drivers/usb/misc/mux.c
 F:	include/linux/usb/mux.h
 F:	drivers/usb/misc/intel-mux-gpio.c
 F:	drivers/usb/misc/intel-mux-drcfg.c
+F:	drivers/mfd/intel-vuport.c
 
 USB PRINTER DRIVER (usblp)
 M:	Pete Zaitcev <zaitcev@redhat.com>
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..0913494 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1534,5 +1534,12 @@ config MFD_VEXPRESS_SYSREG
 	  System Registers are the platform configuration block
 	  on the ARM Ltd. Versatile Express board.
 
+config MFD_INTEL_VUPORT
+	tristate "Intel virtual USB port controller"
+	select MFD_CORE
+	help
+	  Say Y here to enable support for Intel dual role port mux
+	  controlled by 3 GPIOs.
+
 endmenu
 endif
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0f230a6..0ccd107 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -198,3 +198,4 @@ intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
+obj-$(CONFIG_MFD_INTEL_VUPORT)	+= intel-vuport.o
diff --git a/drivers/mfd/intel-vuport.c b/drivers/mfd/intel-vuport.c
new file mode 100644
index 0000000..63391dc
--- /dev/null
+++ b/drivers/mfd/intel-vuport.c
@@ -0,0 +1,79 @@
+/*
+ * MFD driver for Intel virtual USB port
+ *
+ * Copyright(c) 2016 Intel Corporation.
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/gpio.h>
+#include <linux/mfd/core.h>
+#include <linux/platform_device.h>
+
+/* ACPI GPIO Mappings */
+static const struct acpi_gpio_params id_gpio = { 0, 0, false };
+static const struct acpi_gpio_params vbus_gpio = { 1, 0, false };
+static const struct acpi_gpio_params mux_gpio = { 2, 0, false };
+static const struct acpi_gpio_mapping acpi_usb_gpios[] = {
+	{ "id-gpios", &id_gpio, 1 },
+	{ "vbus_en-gpios", &vbus_gpio, 1 },
+	{ "usb_mux-gpios", &mux_gpio, 1 },
+	{ },
+};
+
+static const struct mfd_cell intel_vuport_mfd_cells[] = {
+	{
+		.name = "extcon-usb-gpio",
+	},
+	{
+		.name = "intel-mux-gpio",
+	},
+};
+
+static int vuport_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_usb_gpios);
+	if (ret)
+		return ret;
+
+	return mfd_add_devices(&pdev->dev, 0, intel_vuport_mfd_cells,
+			ARRAY_SIZE(intel_vuport_mfd_cells), NULL, 0,
+			NULL);
+}
+
+static int vuport_remove(struct platform_device *pdev)
+{
+	mfd_remove_devices(&pdev->dev);
+	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
+
+	return 0;
+}
+
+static struct acpi_device_id vuport_acpi_match[] = {
+	{ "INT3496" },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, vuport_acpi_match);
+
+static struct platform_driver vuport_driver = {
+	.driver = {
+		.name = "intel-vuport",
+		.owner = THIS_MODULE,
+		.acpi_match_table = ACPI_PTR(vuport_acpi_match),
+	},
+	.probe = vuport_probe,
+	.remove = vuport_remove,
+};
+
+module_platform_driver(vuport_driver);
+
+MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
+MODULE_DESCRIPTION("Intel virtual USB port");
+MODULE_LICENSE("GPL v2");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/7] extcon: usb-gpio: add device binding for platform device
  2016-03-03  6:37 ` [PATCH 1/7] extcon: usb-gpio: add device binding for platform device Lu Baolu
@ 2016-03-03  7:24   ` Chanwoo Choi
  2016-03-03  7:35     ` Lu Baolu
  0 siblings, 1 reply; 30+ messages in thread
From: Chanwoo Choi @ 2016-03-03  7:24 UTC (permalink / raw)
  To: Lu Baolu, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham
  Cc: linux-usb, linux-kernel

Hell Lu,

On 2016년 03월 03일 15:37, Lu Baolu wrote:
> This is needed to handle the GPIO connected USB ID pin found on
> Intel Baytrail devices.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> ---
>  drivers/extcon/extcon-usb-gpio.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
> index 2b2fecf..af9c8b0 100644
> --- a/drivers/extcon/extcon-usb-gpio.c
> +++ b/drivers/extcon/extcon-usb-gpio.c
> @@ -206,6 +206,12 @@ static const struct of_device_id usb_extcon_dt_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, usb_extcon_dt_match);
>  
> +static const struct platform_device_id usb_extcon_platform_ids[] = {
> +	{ .name = "extcon-usb-gpio", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(platform, usb_extcon_platform_ids);
> +
>  static struct platform_driver usb_extcon_driver = {
>  	.probe		= usb_extcon_probe,
>  	.remove		= usb_extcon_remove,
> @@ -214,6 +220,7 @@ static struct platform_driver usb_extcon_driver = {
>  		.pm	= &usb_extcon_pm_ops,
>  		.of_match_table = usb_extcon_dt_match,
>  	},
> +	.id_table = usb_extcon_platform_ids,
>  };
>  
>  module_platform_driver(usb_extcon_driver);
> 

Looks good to me.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Best Regards,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface
  2016-03-03  6:37 ` [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu
@ 2016-03-03  7:24   ` Chanwoo Choi
  2016-03-03  7:35     ` Lu Baolu
  0 siblings, 1 reply; 30+ messages in thread
From: Chanwoo Choi @ 2016-03-03  7:24 UTC (permalink / raw)
  To: Lu Baolu, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham
  Cc: linux-usb, linux-kernel

Hi Lu,

On 2016년 03월 03일 15:37, Lu Baolu wrote:
> GPIO resource could be retrieved through APCI as well.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> ---
>  drivers/extcon/extcon-usb-gpio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
> index af9c8b0..472c431 100644
> --- a/drivers/extcon/extcon-usb-gpio.c
> +++ b/drivers/extcon/extcon-usb-gpio.c
> @@ -26,6 +26,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/workqueue.h>
> +#include <linux/acpi.h>
>  
>  #define USB_GPIO_DEBOUNCE_MS	20	/* ms */
>  
> @@ -91,7 +92,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
>  	struct usb_extcon_info *info;
>  	int ret;
>  
> -	if (!np)
> +	if (!np && !ACPI_HANDLE(dev))
>  		return -EINVAL;
>  
>  	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> 

Looks good to me.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Best Regards,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/7] extcon: usb-gpio: add device binding for platform device
  2016-03-03  7:24   ` Chanwoo Choi
@ 2016-03-03  7:35     ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  7:35 UTC (permalink / raw)
  To: Chanwoo Choi, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham
  Cc: linux-usb, linux-kernel



On 03/03/2016 03:24 PM, Chanwoo Choi wrote:
> Hell Lu,
>
> On 2016년 03월 03일 15:37, Lu Baolu wrote:
>> This is needed to handle the GPIO connected USB ID pin found on
>> Intel Baytrail devices.
>>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>> ---
>>  drivers/extcon/extcon-usb-gpio.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
>> index 2b2fecf..af9c8b0 100644
>> --- a/drivers/extcon/extcon-usb-gpio.c
>> +++ b/drivers/extcon/extcon-usb-gpio.c
>> @@ -206,6 +206,12 @@ static const struct of_device_id usb_extcon_dt_match[] = {
>>  };
>>  MODULE_DEVICE_TABLE(of, usb_extcon_dt_match);
>>  
>> +static const struct platform_device_id usb_extcon_platform_ids[] = {
>> +	{ .name = "extcon-usb-gpio", },
>> +	{ /* sentinel */ }
>> +};
>> +MODULE_DEVICE_TABLE(platform, usb_extcon_platform_ids);
>> +
>>  static struct platform_driver usb_extcon_driver = {
>>  	.probe		= usb_extcon_probe,
>>  	.remove		= usb_extcon_remove,
>> @@ -214,6 +220,7 @@ static struct platform_driver usb_extcon_driver = {
>>  		.pm	= &usb_extcon_pm_ops,
>>  		.of_match_table = usb_extcon_dt_match,
>>  	},
>> +	.id_table = usb_extcon_platform_ids,
>>  };
>>  
>>  module_platform_driver(usb_extcon_driver);
>>
> Looks good to me.
>
> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Thank you!

>
> Best Regards,
> Chanwoo Choi
>
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface
  2016-03-03  7:24   ` Chanwoo Choi
@ 2016-03-03  7:35     ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-03  7:35 UTC (permalink / raw)
  To: Chanwoo Choi, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham
  Cc: linux-usb, linux-kernel



On 03/03/2016 03:24 PM, Chanwoo Choi wrote:
> Hi Lu,
>
> On 2016년 03월 03일 15:37, Lu Baolu wrote:
>> GPIO resource could be retrieved through APCI as well.
>>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>> ---
>>  drivers/extcon/extcon-usb-gpio.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
>> index af9c8b0..472c431 100644
>> --- a/drivers/extcon/extcon-usb-gpio.c
>> +++ b/drivers/extcon/extcon-usb-gpio.c
>> @@ -26,6 +26,7 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/slab.h>
>>  #include <linux/workqueue.h>
>> +#include <linux/acpi.h>
>>  
>>  #define USB_GPIO_DEBOUNCE_MS	20	/* ms */
>>  
>> @@ -91,7 +92,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
>>  	struct usb_extcon_info *info;
>>  	int ret;
>>  
>> -	if (!np)
>> +	if (!np && !ACPI_HANDLE(dev))
>>  		return -EINVAL;
>>  
>>  	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
>>
> Looks good to me.
>
> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Thank you!

>
> Best Regards,
> Chanwoo Choi
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
@ 2016-03-03  8:16   ` kbuild test robot
  2016-03-03  8:16   ` [PATCH] mfd: intel_vuport: fix platform_no_drv_owner.cocci warnings kbuild test robot
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03  8:16 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing


coccinelle warnings: (new ones prefixed by >>)

>> drivers/mfd/intel-vuport.c:68:3-8: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH] mfd: intel_vuport: fix platform_no_drv_owner.cocci warnings
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
  2016-03-03  8:16   ` kbuild test robot
@ 2016-03-03  8:16   ` kbuild test robot
  2016-03-03 11:35   ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver kbuild test robot
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03  8:16 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu

drivers/mfd/intel-vuport.c:68:3-8: No need to set .owner here. The core will do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 intel-vuport.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/mfd/intel-vuport.c
+++ b/drivers/mfd/intel-vuport.c
@@ -65,7 +65,6 @@ MODULE_DEVICE_TABLE(acpi, vuport_acpi_ma
 static struct platform_driver vuport_driver = {
 	.driver = {
 		.name = "intel-vuport",
-		.owner = THIS_MODULE,
 		.acpi_match_table = ACPI_PTR(vuport_acpi_match),
 	},
 	.probe = vuport_probe,

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/7] usb: misc: add driver for Intel gpio controlled port mux
  2016-03-03  6:37 ` [PATCH 4/7] usb: misc: add driver for Intel gpio controlled " Lu Baolu
@ 2016-03-03  8:16   ` kbuild test robot
  2016-03-03  8:16   ` [PATCH] usb: misc: fix platform_no_drv_owner.cocci warnings kbuild test robot
  1 sibling, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03  8:16 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu, David Cohen

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing


coccinelle warnings: (new ones prefixed by >>)

>> drivers/usb/misc/intel-mux-gpio.c:111:3-8: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH] usb: misc: fix platform_no_drv_owner.cocci warnings
  2016-03-03  6:37 ` [PATCH 4/7] usb: misc: add driver for Intel gpio controlled " Lu Baolu
  2016-03-03  8:16   ` kbuild test robot
@ 2016-03-03  8:16   ` kbuild test robot
  1 sibling, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03  8:16 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu, David Cohen

drivers/usb/misc/intel-mux-gpio.c:111:3-8: No need to set .owner here. The core will do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 intel-mux-gpio.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/usb/misc/intel-mux-gpio.c
+++ b/drivers/usb/misc/intel-mux-gpio.c
@@ -108,7 +108,6 @@ MODULE_DEVICE_TABLE(platform, vuport_pla
 static struct platform_driver vuport_driver = {
 	.driver = {
 		.name = "intel-mux-gpio",
-		.owner = THIS_MODULE,
 #ifdef CONFIG_PM_SLEEP
 		.pm = &vuport_pm_ops,
 #endif

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
  2016-03-03  8:16   ` kbuild test robot
  2016-03-03  8:16   ` [PATCH] mfd: intel_vuport: fix platform_no_drv_owner.cocci warnings kbuild test robot
@ 2016-03-03 11:35   ` kbuild test robot
  2016-03-03 17:26   ` kbuild test robot
  2016-03-03 19:57   ` kbuild test robot
  4 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03 11:35 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu

[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: openrisc-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=openrisc 

All warnings (new ones prefixed by >>):

   drivers/mfd/intel-vuport.c: In function 'vuport_probe':
>> drivers/mfd/intel-vuport.c:39:17: warning: unused variable 'dev'
   drivers/mfd/intel-vuport.c: At top level:
   drivers/mfd/intel-vuport.c:59:30: warning: 'vuport_acpi_match' defined but not used

vim +/dev +39 drivers/mfd/intel-vuport.c

    23		{ "vbus_en-gpios", &vbus_gpio, 1 },
    24		{ "usb_mux-gpios", &mux_gpio, 1 },
    25		{ },
    26	};
    27	
    28	static const struct mfd_cell intel_vuport_mfd_cells[] = {
    29		{
    30			.name = "extcon-usb-gpio",
    31		},
    32		{
    33			.name = "intel-mux-gpio",
    34		},
    35	};
    36	
    37	static int vuport_probe(struct platform_device *pdev)
    38	{
  > 39		struct device *dev = &pdev->dev;
    40		int ret;
    41	
    42		ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_usb_gpios);
    43		if (ret)
    44			return ret;
    45	
    46		return mfd_add_devices(&pdev->dev, 0, intel_vuport_mfd_cells,
    47				ARRAY_SIZE(intel_vuport_mfd_cells), NULL, 0,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 36869 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
@ 2016-03-03 15:20   ` kbuild test robot
  2016-03-03 16:12   ` Greg Kroah-Hartman
  2016-03-03 16:14   ` Greg Kroah-Hartman
  2 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03 15:20 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu, Wu Hao

[-- Attachment #1: Type: text/plain, Size: 4380 bytes --]

Hi Lu,

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: arm64-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   drivers/usb/misc/intel-mux-drcfg.c: In function 'intel_mux_drcfg_switch':
>> drivers/usb/misc/intel-mux-drcfg.c:42:2: error: implicit declaration of function 'readl' [-Werror=implicit-function-declaration]
     data = readl(mux->regs + INTEL_MUX_CFG0);
     ^
>> drivers/usb/misc/intel-mux-drcfg.c:45:3: error: implicit declaration of function 'writel' [-Werror=implicit-function-declaration]
      writel(data, mux->regs + INTEL_MUX_CFG0);
      ^
   drivers/usb/misc/intel-mux-drcfg.c: In function 'intel_mux_drcfg_probe':
>> drivers/usb/misc/intel-mux-drcfg.c:108:2: error: implicit declaration of function 'devm_ioremap_nocache' [-Werror=implicit-function-declaration]
     mux->regs = devm_ioremap_nocache(dev, start, size);
     ^
>> drivers/usb/misc/intel-mux-drcfg.c:108:12: warning: assignment makes pointer from integer without a cast
     mux->regs = devm_ioremap_nocache(dev, start, size);
               ^
   cc1: some warnings being treated as errors

vim +/readl +42 drivers/usb/misc/intel-mux-drcfg.c

    36		unsigned long timeout;
    37		u32 data;
    38	
    39		mux = container_of(umdev, struct intel_usb_mux, umdev);
    40	
    41		/* Check and set mux to SW controlled mode */
  > 42		data = readl(mux->regs + INTEL_MUX_CFG0);
    43		if (!(data & CFG0_SW_IDPIN_EN)) {
    44			data |= CFG0_SW_IDPIN_EN;
  > 45			writel(data, mux->regs + INTEL_MUX_CFG0);
    46		}
    47	
    48		/*
    49		 * Configure CFG0 to switch the mux and VBUS_VALID bit is
    50		 * required for device mode.
    51		 */
    52		data = readl(mux->regs + INTEL_MUX_CFG0);
    53		if (host)
    54			data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
    55		else
    56			data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
    57		writel(data, mux->regs + INTEL_MUX_CFG0);
    58	
    59		/*
    60		 * Polling CFG1 for safety, most case it takes about 600ms
    61		 * to finish mode switching, set TIMEOUT long enough.
    62		 */
    63		timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
    64	
    65		/* Polling on CFG1 register to confirm mode switch. */
    66		while (!time_after(jiffies, timeout)) {
    67			data = readl(mux->regs + INTEL_MUX_CFG1);
    68			if (!(host ^ (data & CFG1_SW_MODE)))
    69				return 0;
    70			/* interval for polling is set to about 5ms */
    71			usleep_range(5000, 5100);
    72		}
    73	
    74		return -ETIMEDOUT;
    75	}
    76	
    77	static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
    78	{
    79		dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
    80	
    81		return intel_mux_drcfg_switch(umdev, true);
    82	}
    83	
    84	static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
    85	{
    86		dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
    87	
    88		return intel_mux_drcfg_switch(umdev, false);
    89	}
    90	
    91	static int intel_mux_drcfg_probe(struct platform_device *pdev)
    92	{
    93		struct intel_usb_mux *mux;
    94		struct usb_mux_dev *umdev;
    95		struct device *dev = &pdev->dev;
    96		u64 start, size;
    97		int ret;
    98	
    99		mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
   100		if (!mux)
   101			return -ENOMEM;
   102	
   103		ret = device_property_read_u64(dev, "reg-start", &start);
   104		ret |= device_property_read_u64(dev, "reg-size", &size);
   105		if (ret)
   106			return -ENODEV;
   107	
 > 108		mux->regs = devm_ioremap_nocache(dev, start, size);
   109		if (!mux->regs)
   110			return -ENOMEM;
   111	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 48219 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/7] usb: misc: add common code for Intel dual role port mux
  2016-03-03  6:37 ` [PATCH 3/7] usb: misc: add common code for Intel dual role port mux Lu Baolu
@ 2016-03-03 16:10   ` Greg Kroah-Hartman
  2016-03-04  1:11     ` Lu Baolu
  2016-03-03 16:15   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 30+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-03 16:10 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel

On Thu, Mar 03, 2016 at 02:37:40PM +0800, Lu Baolu wrote:
> Several Intel PCHs and SOCs have an internal mux that is used to
> share one USB port between device controller and host controller.
> 
> A usb port mux could be abstracted as the following elements:
> 1) mux state: HOST or PERIPHERAL;
> 2) an extcon cable which triggers the change of mux state between
>    HOST and PERIPHERAL;
> 3) The required action to do the real port switch.
> 
> This patch adds the common code to handle usb port mux. With this
> common code, the individual mux driver, which always is platform
> dependent, could focus on the real operation of mux switch.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> ---
>  MAINTAINERS               |   7 ++
>  drivers/usb/misc/Kconfig  |   4 ++
>  drivers/usb/misc/Makefile |   2 +
>  drivers/usb/misc/mux.c    | 172 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/mux.h   |  71 +++++++++++++++++++
>  5 files changed, 256 insertions(+)
>  create mode 100644 drivers/usb/misc/mux.c
>  create mode 100644 include/linux/usb/mux.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d894ee2..45f1e1e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11389,6 +11389,13 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
>  S:	Maintained
>  F:	drivers/usb/phy/
>  
> +USB PORT MUX DRIVER
> +M:	Lu Baolu <baolu.lu@linux.intel.com>
> +L:	linux-usb@vger.kernel.org
> +S:	Supported
> +F:	drivers/usb/misc/mux.c
> +F:	include/linux/usb/mux.h
> +
>  USB PRINTER DRIVER (usblp)
>  M:	Pete Zaitcev <zaitcev@redhat.com>
>  L:	linux-usb@vger.kernel.org
> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
> index f7a7fc2..6496d17 100644
> --- a/drivers/usb/misc/Kconfig
> +++ b/drivers/usb/misc/Kconfig
> @@ -3,6 +3,10 @@
>  #
>  comment "USB Miscellaneous drivers"
>  
> +config USB_MUX
> +	select EXTCON
> +	def_bool n
> +
>  config USB_EMI62
>  	tristate "EMI 6|2m USB Audio interface support"
>  	---help---
> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
> index 45fd4ac..fd79dd5 100644
> --- a/drivers/usb/misc/Makefile
> +++ b/drivers/usb/misc/Makefile
> @@ -29,3 +29,5 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
>  
>  obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
>  obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
> +
> +obj-$(CONFIG_USB_MUX)			+= mux.o

"mux.ko" is a _VERY_ generic name of a kernel module.  Please make this
much more specific to your chip as this will not work for any other
platform that has this type of functionality.

Same goes for all of your exported symbols.



> diff --git a/drivers/usb/misc/mux.c b/drivers/usb/misc/mux.c
> new file mode 100644
> index 0000000..e353fff
> --- /dev/null
> +++ b/drivers/usb/misc/mux.c
> @@ -0,0 +1,172 @@
> +/**
> + * mux.c - USB Port Mux support
> + *
> + * Copyright (C) 2016 Intel Corporation
> + *
> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#include <linux/notifier.h>
> +#include <linux/usb/mux.h>
> +#include <linux/debugfs.h>
> +#include <linux/err.h>
> +
> +static int usb_mux_change_state(struct usb_mux *mux, int state)
> +{
> +	int ret;
> +	struct usb_mux_dev *umdev = mux->umdev;
> +
> +	dev_WARN_ONCE(umdev->dev, !mutex_is_locked(&mux->mux_mutex),
> +			"mutex is unlocked\n");
> +
> +	mux->mux_state = state;
> +
> +	if (mux->mux_state)
> +		ret = umdev->cable_set_cb(umdev);
> +	else
> +		ret = umdev->cable_unset_cb(umdev);
> +
> +	return ret;
> +}
> +
> +static int usb_mux_notifier(struct notifier_block *nb,
> +		unsigned long event, void *ptr)
> +{
> +	struct usb_mux *mux;
> +	int state;
> +	int ret = NOTIFY_DONE;
> +
> +	mux = container_of(nb, struct usb_mux, nb);
> +
> +	state = extcon_get_cable_state(mux->obj.edev,
> +			mux->umdev->cable_name);
> +
> +	if (mux->mux_state == -1 || mux->mux_state != state) {
> +		mutex_lock(&mux->mux_mutex);
> +		ret = usb_mux_change_state(mux, state);
> +		mutex_unlock(&mux->mux_mutex);
> +	}
> +
> +	return ret;
> +}
> +
> +static ssize_t mux_debug_read(struct file *file, char __user *user_buf,
> +		size_t len, loff_t *offset)
> +{
> +	struct usb_mux *mux = file->private_data;
> +	char output_buf[16];
> +
> +	memset(output_buf, 0, sizeof(output_buf));
> +	if (mux->mux_state)
> +		strcpy(output_buf, "host\n");
> +	else
> +		strcpy(output_buf, "peripheral\n");
> +
> +	return simple_read_from_buffer(user_buf, len, offset,
> +			output_buf, strlen(output_buf));
> +}
> +
> +static ssize_t mux_debug_write(struct file *file, const char __user *user_buf,
> +		size_t count, loff_t *offset)
> +{
> +	struct usb_mux *mux = file->private_data;
> +	char input_buf[16];
> +	int size, state;
> +
> +	size = min(count, sizeof(input_buf) - 1);
> +	memset(input_buf, 0, sizeof(input_buf));
> +	if (strncpy_from_user(input_buf, user_buf, size) < 0)
> +		return -EFAULT;
> +
> +	if (!strncmp(input_buf, "host", 4))
> +		state = 1;
> +	else if (!strncmp(input_buf, "peripheral", 10))
> +		state = 0;
> +	else
> +		state = -1;
> +
> +	if (state != -1) {
> +		mutex_lock(&mux->mux_mutex);
> +		usb_mux_change_state(mux, state);
> +		mutex_unlock(&mux->mux_mutex);
> +	}
> +
> +	return count;
> +}
> +
> +static const struct file_operations mux_debug_fops = {
> +	.read =		mux_debug_read,
> +	.write =	mux_debug_write,
> +	.open =		simple_open,
> +	.llseek =	default_llseek,
> +};
> +
> +int usb_mux_register(struct usb_mux_dev *umdev)
> +{
> +	int ret;
> +	struct device *dev = umdev->dev;
> +	struct usb_mux *mux;
> +
> +	if (!umdev->cable_name)
> +		return -ENODEV;
> +
> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
> +	if (!mux)
> +		return -ENOMEM;
> +
> +	mux->umdev = umdev;
> +	mux->nb.notifier_call = usb_mux_notifier;
> +	mutex_init(&mux->mux_mutex);
> +	mux->mux_state = -1;
> +	dev_set_drvdata(dev, mux);
> +
> +	ret = extcon_register_interest(&mux->obj, umdev->extcon_name,
> +			umdev->cable_name, &mux->nb);
> +	if (ret) {
> +		dev_err(dev, "failed to register extcon notifier\n");
> +		return -ENODEV;
> +	}
> +
> +	usb_mux_notifier(&mux->nb, 0, NULL);
> +
> +	mux->debug_file = debugfs_create_file("usb_mux", 0600,
> +			usb_debug_root, mux, &mux_debug_fops);

So you control this through debugfs?  That's not a good idea, what if
you have multiple ones of these?  What if debugfs is not enabled?  Who
is in charge of controlling this from userspace?

> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(usb_mux_register);
> +
> +int usb_mux_unregister(struct device *dev)
> +{
> +	struct usb_mux *mux = dev_get_drvdata(dev);
> +
> +	debugfs_remove(mux->debug_file);
> +	extcon_unregister_interest(&mux->obj);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(usb_mux_unregister);
> +
> +struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
> +{
> +	struct usb_mux *mux = dev_get_drvdata(dev);
> +
> +	if (mux)
> +		return mux->umdev;
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL_GPL(usb_mux_get_dev);
> +
> +#ifdef CONFIG_PM_SLEEP
> +void usb_mux_complete(struct device *dev)
> +{
> +	struct usb_mux *mux = dev_get_drvdata(dev);
> +
> +	usb_mux_notifier(&mux->nb, 0, NULL);
> +}
> +EXPORT_SYMBOL_GPL(usb_mux_complete);
> +#endif
> diff --git a/include/linux/usb/mux.h b/include/linux/usb/mux.h
> new file mode 100644
> index 0000000..5dada48
> --- /dev/null
> +++ b/include/linux/usb/mux.h
> @@ -0,0 +1,71 @@
> +/**
> + * mux.h - USB Port Mux defines
> + *
> + * Copyright (C) 2016 Intel Corporation
> + *
> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef __LINUX_USB_MUX_H
> +#define __LINUX_USB_MUX_H
> +
> +#include <linux/extcon.h>
> +#include <linux/usb.h>
> +
> +struct usb_mux_dev {
> +	struct device	*dev;
> +	char		*extcon_name;
> +	char		*cable_name;
> +	int		(*cable_set_cb)(struct usb_mux_dev *mux);
> +	int		(*cable_unset_cb)(struct usb_mux_dev *mux);
> +};
> +
> +struct usb_mux {
> +	struct usb_mux_dev		*umdev;
> +	struct notifier_block		nb;
> +	struct extcon_specific_cable_nb	obj;
> +
> +	/*
> +	 * The state of the mux.
> +	 * 0, 1 - mux switch state
> +	 * -1   - uninitialized state
> +	 *
> +	 * mux_mutex is lock to protect mux_state
> +	 */
> +	int				mux_state;
> +	struct mutex			mux_mutex;
> +
> +	struct dentry			*debug_file;
> +};


Why is this a public structure?

And why isn't it properly reference counted if it is a public structure?


> +
> +#if IS_ENABLED(CONFIG_USB_MUX)
> +extern int usb_mux_register(struct usb_mux_dev *mux);
> +extern int usb_mux_unregister(struct device *dev);
> +extern struct usb_mux_dev *usb_mux_get_dev(struct device *dev);
> +
> +#ifdef CONFIG_PM_SLEEP
> +extern void usb_mux_complete(struct device *dev);
> +#endif
> +
> +#else /* CONFIG_USB_MUX */
> +static inline int usb_mux_register(struct usb_mux_dev *mux)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int usb_mux_unregister(struct device *dev)
> +{
> +	return 0;
> +}
> +
> +static inline struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
> +{
> +	return NULL;
> +}
> +#endif /* CONFIG_USB_MUX */
> +
> +#endif /* __LINUX_USB_MUX_H */


Why do you need this .h file at all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
  2016-03-03 15:20   ` kbuild test robot
@ 2016-03-03 16:12   ` Greg Kroah-Hartman
  2016-03-04  1:41     ` Lu Baolu
  2016-03-03 16:14   ` Greg Kroah-Hartman
  2 siblings, 1 reply; 30+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-03 16:12 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao

On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
> Several Intel PCHs and SOCs have an internal mux that is used to
> share one USB port between device controller and host controller.
> The mux is handled through the Dual Role Configuration Register.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Wu Hao <hao.wu@intel.com>
> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> ---
>  MAINTAINERS                        |   1 +
>  drivers/usb/misc/Kconfig           |   7 ++
>  drivers/usb/misc/Makefile          |   1 +
>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++

If you are going to start having a bunch of these, please make a new
directory, drivers/usb/mux/ ?

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
  2016-03-03 15:20   ` kbuild test robot
  2016-03-03 16:12   ` Greg Kroah-Hartman
@ 2016-03-03 16:14   ` Greg Kroah-Hartman
  2016-03-04  1:38     ` Lu Baolu
  2 siblings, 1 reply; 30+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-03 16:14 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao

On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
> Several Intel PCHs and SOCs have an internal mux that is used to
> share one USB port between device controller and host controller.
> The mux is handled through the Dual Role Configuration Register.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Wu Hao <hao.wu@intel.com>
> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> ---
>  MAINTAINERS                        |   1 +
>  drivers/usb/misc/Kconfig           |   7 ++
>  drivers/usb/misc/Makefile          |   1 +
>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
>  4 files changed, 183 insertions(+)
>  create mode 100644 drivers/usb/misc/intel-mux-drcfg.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0f321e4..20eb873 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11396,6 +11396,7 @@ S:	Supported
>  F:	drivers/usb/misc/mux.c
>  F:	include/linux/usb/mux.h
>  F:	drivers/usb/misc/intel-mux-gpio.c
> +F:	drivers/usb/misc/intel-mux-drcfg.c
>  
>  USB PRINTER DRIVER (usblp)
>  M:	Pete Zaitcev <zaitcev@redhat.com>
> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
> index 33e6386..befd910 100644
> --- a/drivers/usb/misc/Kconfig
> +++ b/drivers/usb/misc/Kconfig
> @@ -281,3 +281,10 @@ config INTEL_MUX_GPIO
>  	help
>  	  Say Y here to enable support for Intel dual role port mux
>  	  controlled by GPIOs.
> +
> +config INTEL_MUX_DRCFG
> +	tristate "Intel dual role port mux controlled by register"
> +	select USB_MUX
> +	help
> +	  Say Y here to enable support for Intel dual role port mux
> +	  controlled by the Dual Role Configuration Registers.
> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
> index da4fb4e..c4d19a0 100644
> --- a/drivers/usb/misc/Makefile
> +++ b/drivers/usb/misc/Makefile
> @@ -32,3 +32,4 @@ obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
>  
>  obj-$(CONFIG_USB_MUX)			+= mux.o
>  obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
> +obj-$(CONFIG_INTEL_MUX_DRCFG)		+= intel-mux-drcfg.o
> diff --git a/drivers/usb/misc/intel-mux-drcfg.c b/drivers/usb/misc/intel-mux-drcfg.c
> new file mode 100644
> index 0000000..29081c5
> --- /dev/null
> +++ b/drivers/usb/misc/intel-mux-drcfg.c
> @@ -0,0 +1,174 @@
> +/**
> + * intel-mux-drcfg.c - Driver for Intel USB mux via register
> + *
> + * Copyright (C) 2016 Intel Corporation
> + * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/slab.h>
> +#include <linux/module.h>
> +#include <linux/property.h>
> +#include <linux/usb/mux.h>
> +#include <linux/platform_device.h>
> +
> +#define INTEL_MUX_CFG0		0x00
> +#define INTEL_MUX_CFG1		0x04
> +#define CFG0_SW_IDPIN		BIT(20)
> +#define CFG0_SW_IDPIN_EN	BIT(21)
> +#define CFG0_SW_VBUS_VALID	BIT(24)
> +#define CFG1_SW_MODE		BIT(29)
> +#define CFG1_POLL_TIMEOUT	1000
> +
> +struct intel_usb_mux {
> +	struct usb_mux_dev umdev;
> +	void __iomem *regs;
> +	u32 cfg0_ctx;
> +};
> +
> +static inline int intel_mux_drcfg_switch(struct usb_mux_dev *umdev, bool host)
> +{
> +	struct intel_usb_mux *mux;
> +	unsigned long timeout;
> +	u32 data;
> +
> +	mux = container_of(umdev, struct intel_usb_mux, umdev);
> +
> +	/* Check and set mux to SW controlled mode */
> +	data = readl(mux->regs + INTEL_MUX_CFG0);
> +	if (!(data & CFG0_SW_IDPIN_EN)) {
> +		data |= CFG0_SW_IDPIN_EN;
> +		writel(data, mux->regs + INTEL_MUX_CFG0);
> +	}
> +
> +	/*
> +	 * Configure CFG0 to switch the mux and VBUS_VALID bit is
> +	 * required for device mode.
> +	 */
> +	data = readl(mux->regs + INTEL_MUX_CFG0);
> +	if (host)
> +		data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
> +	else
> +		data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
> +	writel(data, mux->regs + INTEL_MUX_CFG0);
> +
> +	/*
> +	 * Polling CFG1 for safety, most case it takes about 600ms
> +	 * to finish mode switching, set TIMEOUT long enough.
> +	 */
> +	timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
> +
> +	/* Polling on CFG1 register to confirm mode switch. */
> +	while (!time_after(jiffies, timeout)) {
> +		data = readl(mux->regs + INTEL_MUX_CFG1);
> +		if (!(host ^ (data & CFG1_SW_MODE)))
> +			return 0;
> +		/* interval for polling is set to about 5ms */
> +		usleep_range(5000, 5100);
> +	}
> +
> +	return -ETIMEDOUT;
> +}
> +
> +static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
> +{
> +	dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
> +
> +	return intel_mux_drcfg_switch(umdev, true);
> +}
> +
> +static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
> +{
> +	dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
> +
> +	return intel_mux_drcfg_switch(umdev, false);
> +}
> +
> +static int intel_mux_drcfg_probe(struct platform_device *pdev)
> +{
> +	struct intel_usb_mux *mux;
> +	struct usb_mux_dev *umdev;
> +	struct device *dev = &pdev->dev;
> +	u64 start, size;
> +	int ret;
> +
> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
> +	if (!mux)
> +		return -ENOMEM;
> +
> +	ret = device_property_read_u64(dev, "reg-start", &start);
> +	ret |= device_property_read_u64(dev, "reg-size", &size);
> +	if (ret)
> +		return -ENODEV;

And you leaked memory :(

> +
> +	mux->regs = devm_ioremap_nocache(dev, start, size);
> +	if (!mux->regs)
> +		return -ENOMEM;

Memory gone :(

> +
> +	mux->cfg0_ctx = readl(mux->regs + INTEL_MUX_CFG0);
> +
> +	umdev = &mux->umdev;
> +	umdev->dev = dev;
> +	umdev->cable_name = "USB-HOST";
> +	umdev->cable_set_cb = intel_mux_drcfg_cable_set;
> +	umdev->cable_unset_cb = intel_mux_drcfg_cable_unset;
> +
> +	ret = usb_mux_register(umdev);
> +	if (ret)
> +		writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);

So if an error happens you just keep going?

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/7] usb: misc: add common code for Intel dual role port mux
  2016-03-03  6:37 ` [PATCH 3/7] usb: misc: add common code for Intel dual role port mux Lu Baolu
  2016-03-03 16:10   ` Greg Kroah-Hartman
@ 2016-03-03 16:15   ` Greg Kroah-Hartman
  2016-03-04  1:25     ` Lu Baolu
  1 sibling, 1 reply; 30+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-03 16:15 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel

On Thu, Mar 03, 2016 at 02:37:40PM +0800, Lu Baolu wrote:
> +#if IS_ENABLED(CONFIG_USB_MUX)
> +extern int usb_mux_register(struct usb_mux_dev *mux);
> +extern int usb_mux_unregister(struct device *dev);
> +extern struct usb_mux_dev *usb_mux_get_dev(struct device *dev);

This api needs a lot of work, for such a "tiny" api, it's obviously
pretty incorrect.  Please fix it up to be sane...

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
                     ` (2 preceding siblings ...)
  2016-03-03 11:35   ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver kbuild test robot
@ 2016-03-03 17:26   ` kbuild test robot
  2016-03-03 19:57   ` kbuild test robot
  4 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03 17:26 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu

[-- Attachment #1: Type: text/plain, Size: 6945 bytes --]

Hi Lu,

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: mn10300-allmodconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mn10300 

All error/warnings (new ones prefixed by >>):

   drivers/mfd/intel-vuport.c: In function 'vuport_probe':
   drivers/mfd/intel-vuport.c:39:17: warning: unused variable 'dev' [-Wunused-variable]
     struct device *dev = &pdev->dev;
                    ^
   drivers/mfd/intel-vuport.c: At top level:
>> drivers/mfd/intel-vuport.c:63:1: warning: data definition has no type or storage class
    MODULE_DEVICE_TABLE(acpi, vuport_acpi_match);
    ^
>> drivers/mfd/intel-vuport.c:63:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' [-Werror=implicit-int]
>> drivers/mfd/intel-vuport.c:63:1: warning: parameter names (without types) in function declaration
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/device.h:1337:1: warning: data definition has no type or storage class
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   include/linux/device.h:1337:1: error: type defaults to 'int' in declaration of 'module_init' [-Werror=implicit-int]
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   drivers/mfd/intel-vuport.c:75:1: warning: parameter names (without types) in function declaration
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/device.h:1342:1: warning: data definition has no type or storage class
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   include/linux/device.h:1342:1: error: type defaults to 'int' in declaration of 'module_exit' [-Werror=implicit-int]
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   drivers/mfd/intel-vuport.c:75:1: warning: parameter names (without types) in function declaration
>> drivers/mfd/intel-vuport.c:77:15: error: expected declaration specifiers or '...' before string constant
    MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
                  ^
   drivers/mfd/intel-vuport.c:78:20: error: expected declaration specifiers or '...' before string constant
    MODULE_DESCRIPTION("Intel virtual USB port");
                       ^
   drivers/mfd/intel-vuport.c:79:16: error: expected declaration specifiers or '...' before string constant
    MODULE_LICENSE("GPL v2");
                   ^
   drivers/mfd/intel-vuport.c:59:30: warning: 'vuport_acpi_match' defined but not used [-Wunused-variable]
    static struct acpi_device_id vuport_acpi_match[] = {
                                 ^
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   drivers/mfd/intel-vuport.c:75:24: warning: 'vuport_driver_init' defined but not used [-Wunused-function]
    module_platform_driver(vuport_driver);
                           ^
   include/linux/device.h:1333:19: note: in definition of macro 'module_driver'
    static int __init __driver##_init(void) \
                      ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   drivers/mfd/intel-vuport.c:75:24: warning: 'vuport_driver_exit' defined but not used [-Wunused-function]
    module_platform_driver(vuport_driver);
                           ^
   include/linux/device.h:1338:20: note: in definition of macro 'module_driver'
    static void __exit __driver##_exit(void) \
                       ^
   drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   cc1: some warnings being treated as errors

vim +63 drivers/mfd/intel-vuport.c

    33			.name = "intel-mux-gpio",
    34		},
    35	};
    36	
    37	static int vuport_probe(struct platform_device *pdev)
    38	{
  > 39		struct device *dev = &pdev->dev;
    40		int ret;
    41	
    42		ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_usb_gpios);
    43		if (ret)
    44			return ret;
    45	
    46		return mfd_add_devices(&pdev->dev, 0, intel_vuport_mfd_cells,
    47				ARRAY_SIZE(intel_vuport_mfd_cells), NULL, 0,
    48				NULL);
    49	}
    50	
    51	static int vuport_remove(struct platform_device *pdev)
    52	{
    53		mfd_remove_devices(&pdev->dev);
    54		acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
    55	
    56		return 0;
    57	}
    58	
    59	static struct acpi_device_id vuport_acpi_match[] = {
    60		{ "INT3496" },
    61		{ }
    62	};
  > 63	MODULE_DEVICE_TABLE(acpi, vuport_acpi_match);
    64	
    65	static struct platform_driver vuport_driver = {
    66		.driver = {
    67			.name = "intel-vuport",
    68			.owner = THIS_MODULE,
    69			.acpi_match_table = ACPI_PTR(vuport_acpi_match),
    70		},
    71		.probe = vuport_probe,
    72		.remove = vuport_remove,
    73	};
    74	
  > 75	module_platform_driver(vuport_driver);
    76	
  > 77	MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
    78	MODULE_DESCRIPTION("Intel virtual USB port");
    79	MODULE_LICENSE("GPL v2");

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 37405 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
  2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
                     ` (3 preceding siblings ...)
  2016-03-03 17:26   ` kbuild test robot
@ 2016-03-03 19:57   ` kbuild test robot
  4 siblings, 0 replies; 30+ messages in thread
From: kbuild test robot @ 2016-03-03 19:57 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Felipe Balbi, Mathias Nyman, Greg Kroah-Hartman,
	Lee Jones, Heikki Krogerus, MyungJoo Ham, Chanwoo Choi,
	linux-usb, linux-kernel, Lu Baolu

[-- Attachment #1: Type: text/plain, Size: 7825 bytes --]

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.5-rc6 next-20160303]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-add-support-for-Intel-dual-role-port-mux/20160303-144241
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: parisc-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   drivers/mfd/intel-vuport.c: In function 'vuport_probe':
   drivers/mfd/intel-vuport.c:39:17: warning: unused variable 'dev' [-Wunused-variable]
     struct device *dev = &pdev->dev;
                    ^
   drivers/mfd/intel-vuport.c: At top level:
   drivers/mfd/intel-vuport.c:63:1: warning: data definition has no type or storage class
    MODULE_DEVICE_TABLE(acpi, vuport_acpi_match);
    ^
   drivers/mfd/intel-vuport.c:63:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' [-Werror=implicit-int]
   drivers/mfd/intel-vuport.c:63:1: warning: parameter names (without types) in function declaration
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/device.h:1337:1: warning: data definition has no type or storage class
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   include/linux/device.h:1337:1: error: type defaults to 'int' in declaration of 'module_init' [-Werror=implicit-int]
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/linux/list.h:8,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/export.h:36:30: warning: parameter names (without types) in function declaration
    #define THIS_MODULE ((struct module *)0)
                                 ^
   include/linux/platform_device.h:198:34: note: in expansion of macro 'THIS_MODULE'
     __platform_driver_register(drv, THIS_MODULE)
                                     ^
   include/linux/device.h:1335:9: note: in expansion of macro 'platform_driver_register'
     return __register(&(__driver) , ##__VA_ARGS__); \
            ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/device.h:1342:1: warning: data definition has no type or storage class
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   include/linux/device.h:1342:1: error: type defaults to 'int' in declaration of 'module_exit' [-Werror=implicit-int]
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/linux/list.h:8,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/mfd/intel-vuport.c:12:
   include/linux/export.h:36:30: warning: parameter names (without types) in function declaration
    #define THIS_MODULE ((struct module *)0)
                                 ^
   include/linux/platform_device.h:198:34: note: in expansion of macro 'THIS_MODULE'
     __platform_driver_register(drv, THIS_MODULE)
                                     ^
   include/linux/device.h:1335:9: note: in expansion of macro 'platform_driver_register'
     return __register(&(__driver) , ##__VA_ARGS__); \
            ^
   include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   drivers/mfd/intel-vuport.c:77:15: error: expected declaration specifiers or '...' before string constant
    MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
                  ^
   drivers/mfd/intel-vuport.c:78:20: error: expected declaration specifiers or '...' before string constant
    MODULE_DESCRIPTION("Intel virtual USB port");
                       ^
   drivers/mfd/intel-vuport.c:79:16: error: expected declaration specifiers or '...' before string constant
    MODULE_LICENSE("GPL v2");
                   ^
   drivers/mfd/intel-vuport.c:59:30: warning: 'vuport_acpi_match' defined but not used [-Wunused-variable]
    static struct acpi_device_id vuport_acpi_match[] = {
                                 ^
   In file included from include/linux/acpi.h:27:0,
                    from drivers/mfd/intel-vuport.c:12:
   drivers/mfd/intel-vuport.c:75:24: warning: 'vuport_driver_init' defined but not used [-Wunused-function]
    module_platform_driver(vuport_driver);
                           ^
   include/linux/device.h:1333:19: note: in definition of macro 'module_driver'
    static int __init __driver##_init(void) \
                      ^
>> drivers/mfd/intel-vuport.c:75:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(vuport_driver);
    ^
   cc1: some warnings being treated as errors

vim +/module_platform_driver +75 drivers/mfd/intel-vuport.c

    57	}
    58	
    59	static struct acpi_device_id vuport_acpi_match[] = {
    60		{ "INT3496" },
    61		{ }
    62	};
  > 63	MODULE_DEVICE_TABLE(acpi, vuport_acpi_match);
    64	
    65	static struct platform_driver vuport_driver = {
    66		.driver = {
    67			.name = "intel-vuport",
    68			.owner = THIS_MODULE,
    69			.acpi_match_table = ACPI_PTR(vuport_acpi_match),
    70		},
    71		.probe = vuport_probe,
    72		.remove = vuport_remove,
    73	};
    74	
  > 75	module_platform_driver(vuport_driver);
    76	
    77	MODULE_AUTHOR("Lu Baolu <baolu.lu@linux.intel.com>");
    78	MODULE_DESCRIPTION("Intel virtual USB port");

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 43738 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/7] usb: misc: add common code for Intel dual role port mux
  2016-03-03 16:10   ` Greg Kroah-Hartman
@ 2016-03-04  1:11     ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-04  1:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel



On 03/04/2016 12:10 AM, Greg Kroah-Hartman wrote:
> On Thu, Mar 03, 2016 at 02:37:40PM +0800, Lu Baolu wrote:
>> Several Intel PCHs and SOCs have an internal mux that is used to
>> share one USB port between device controller and host controller.
>>
>> A usb port mux could be abstracted as the following elements:
>> 1) mux state: HOST or PERIPHERAL;
>> 2) an extcon cable which triggers the change of mux state between
>>    HOST and PERIPHERAL;
>> 3) The required action to do the real port switch.
>>
>> This patch adds the common code to handle usb port mux. With this
>> common code, the individual mux driver, which always is platform
>> dependent, could focus on the real operation of mux switch.
>>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>> ---
>>  MAINTAINERS               |   7 ++
>>  drivers/usb/misc/Kconfig  |   4 ++
>>  drivers/usb/misc/Makefile |   2 +
>>  drivers/usb/misc/mux.c    | 172 ++++++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/usb/mux.h   |  71 +++++++++++++++++++
>>  5 files changed, 256 insertions(+)
>>  create mode 100644 drivers/usb/misc/mux.c
>>  create mode 100644 include/linux/usb/mux.h
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d894ee2..45f1e1e 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -11389,6 +11389,13 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
>>  S:	Maintained
>>  F:	drivers/usb/phy/
>>  
>> +USB PORT MUX DRIVER
>> +M:	Lu Baolu <baolu.lu@linux.intel.com>
>> +L:	linux-usb@vger.kernel.org
>> +S:	Supported
>> +F:	drivers/usb/misc/mux.c
>> +F:	include/linux/usb/mux.h
>> +
>>  USB PRINTER DRIVER (usblp)
>>  M:	Pete Zaitcev <zaitcev@redhat.com>
>>  L:	linux-usb@vger.kernel.org
>> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
>> index f7a7fc2..6496d17 100644
>> --- a/drivers/usb/misc/Kconfig
>> +++ b/drivers/usb/misc/Kconfig
>> @@ -3,6 +3,10 @@
>>  #
>>  comment "USB Miscellaneous drivers"
>>  
>> +config USB_MUX
>> +	select EXTCON
>> +	def_bool n
>> +
>>  config USB_EMI62
>>  	tristate "EMI 6|2m USB Audio interface support"
>>  	---help---
>> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
>> index 45fd4ac..fd79dd5 100644
>> --- a/drivers/usb/misc/Makefile
>> +++ b/drivers/usb/misc/Makefile
>> @@ -29,3 +29,5 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
>>  
>>  obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
>>  obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
>> +
>> +obj-$(CONFIG_USB_MUX)			+= mux.o
> "mux.ko" is a _VERY_ generic name of a kernel module.  Please make this
> much more specific to your chip as this will not work for any other
> platform that has this type of functionality.
>
> Same goes for all of your exported symbols.

Sure. I will change the module name to "intel-mux", and change
the exported symbols to "intel_usb_mux_*".

>
>
>> diff --git a/drivers/usb/misc/mux.c b/drivers/usb/misc/mux.c
>> new file mode 100644
>> index 0000000..e353fff
>> --- /dev/null
>> +++ b/drivers/usb/misc/mux.c
>> @@ -0,0 +1,172 @@
>> +/**
>> + * mux.c - USB Port Mux support
>> + *
>> + * Copyright (C) 2016 Intel Corporation
>> + *
>> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +#include <linux/notifier.h>
>> +#include <linux/usb/mux.h>
>> +#include <linux/debugfs.h>
>> +#include <linux/err.h>
>> +
>> +static int usb_mux_change_state(struct usb_mux *mux, int state)
>> +{
>> +	int ret;
>> +	struct usb_mux_dev *umdev = mux->umdev;
>> +
>> +	dev_WARN_ONCE(umdev->dev, !mutex_is_locked(&mux->mux_mutex),
>> +			"mutex is unlocked\n");
>> +
>> +	mux->mux_state = state;
>> +
>> +	if (mux->mux_state)
>> +		ret = umdev->cable_set_cb(umdev);
>> +	else
>> +		ret = umdev->cable_unset_cb(umdev);
>> +
>> +	return ret;
>> +}
>> +
>> +static int usb_mux_notifier(struct notifier_block *nb,
>> +		unsigned long event, void *ptr)
>> +{
>> +	struct usb_mux *mux;
>> +	int state;
>> +	int ret = NOTIFY_DONE;
>> +
>> +	mux = container_of(nb, struct usb_mux, nb);
>> +
>> +	state = extcon_get_cable_state(mux->obj.edev,
>> +			mux->umdev->cable_name);
>> +
>> +	if (mux->mux_state == -1 || mux->mux_state != state) {
>> +		mutex_lock(&mux->mux_mutex);
>> +		ret = usb_mux_change_state(mux, state);
>> +		mutex_unlock(&mux->mux_mutex);
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +static ssize_t mux_debug_read(struct file *file, char __user *user_buf,
>> +		size_t len, loff_t *offset)
>> +{
>> +	struct usb_mux *mux = file->private_data;
>> +	char output_buf[16];
>> +
>> +	memset(output_buf, 0, sizeof(output_buf));
>> +	if (mux->mux_state)
>> +		strcpy(output_buf, "host\n");
>> +	else
>> +		strcpy(output_buf, "peripheral\n");
>> +
>> +	return simple_read_from_buffer(user_buf, len, offset,
>> +			output_buf, strlen(output_buf));
>> +}
>> +
>> +static ssize_t mux_debug_write(struct file *file, const char __user *user_buf,
>> +		size_t count, loff_t *offset)
>> +{
>> +	struct usb_mux *mux = file->private_data;
>> +	char input_buf[16];
>> +	int size, state;
>> +
>> +	size = min(count, sizeof(input_buf) - 1);
>> +	memset(input_buf, 0, sizeof(input_buf));
>> +	if (strncpy_from_user(input_buf, user_buf, size) < 0)
>> +		return -EFAULT;
>> +
>> +	if (!strncmp(input_buf, "host", 4))
>> +		state = 1;
>> +	else if (!strncmp(input_buf, "peripheral", 10))
>> +		state = 0;
>> +	else
>> +		state = -1;
>> +
>> +	if (state != -1) {
>> +		mutex_lock(&mux->mux_mutex);
>> +		usb_mux_change_state(mux, state);
>> +		mutex_unlock(&mux->mux_mutex);
>> +	}
>> +
>> +	return count;
>> +}
>> +
>> +static const struct file_operations mux_debug_fops = {
>> +	.read =		mux_debug_read,
>> +	.write =	mux_debug_write,
>> +	.open =		simple_open,
>> +	.llseek =	default_llseek,
>> +};
>> +
>> +int usb_mux_register(struct usb_mux_dev *umdev)
>> +{
>> +	int ret;
>> +	struct device *dev = umdev->dev;
>> +	struct usb_mux *mux;
>> +
>> +	if (!umdev->cable_name)
>> +		return -ENODEV;
>> +
>> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
>> +	if (!mux)
>> +		return -ENOMEM;
>> +
>> +	mux->umdev = umdev;
>> +	mux->nb.notifier_call = usb_mux_notifier;
>> +	mutex_init(&mux->mux_mutex);
>> +	mux->mux_state = -1;
>> +	dev_set_drvdata(dev, mux);
>> +
>> +	ret = extcon_register_interest(&mux->obj, umdev->extcon_name,
>> +			umdev->cable_name, &mux->nb);
>> +	if (ret) {
>> +		dev_err(dev, "failed to register extcon notifier\n");
>> +		return -ENODEV;
>> +	}
>> +
>> +	usb_mux_notifier(&mux->nb, 0, NULL);
>> +
>> +	mux->debug_file = debugfs_create_file("usb_mux", 0600,
>> +			usb_debug_root, mux, &mux_debug_fops);
> So you control this through debugfs?  That's not a good idea, what if
> you have multiple ones of these?  What if debugfs is not enabled?

Agree. It's really a problem if we have multiple ones (although
currently we have only single one).

I will make it with sysfs instead.

> Who
> is in charge of controlling this from userspace?

Port mux is only handled in kernel. There is no requirement to
control it from user space. This is added for debugging and
information only.

>
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(usb_mux_register);
>> +
>> +int usb_mux_unregister(struct device *dev)
>> +{
>> +	struct usb_mux *mux = dev_get_drvdata(dev);
>> +
>> +	debugfs_remove(mux->debug_file);
>> +	extcon_unregister_interest(&mux->obj);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(usb_mux_unregister);
>> +
>> +struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
>> +{
>> +	struct usb_mux *mux = dev_get_drvdata(dev);
>> +
>> +	if (mux)
>> +		return mux->umdev;
>> +
>> +	return NULL;
>> +}
>> +EXPORT_SYMBOL_GPL(usb_mux_get_dev);
>> +
>> +#ifdef CONFIG_PM_SLEEP
>> +void usb_mux_complete(struct device *dev)
>> +{
>> +	struct usb_mux *mux = dev_get_drvdata(dev);
>> +
>> +	usb_mux_notifier(&mux->nb, 0, NULL);
>> +}
>> +EXPORT_SYMBOL_GPL(usb_mux_complete);
>> +#endif
>> diff --git a/include/linux/usb/mux.h b/include/linux/usb/mux.h
>> new file mode 100644
>> index 0000000..5dada48
>> --- /dev/null
>> +++ b/include/linux/usb/mux.h
>> @@ -0,0 +1,71 @@
>> +/**
>> + * mux.h - USB Port Mux defines
>> + *
>> + * Copyright (C) 2016 Intel Corporation
>> + *
>> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#ifndef __LINUX_USB_MUX_H
>> +#define __LINUX_USB_MUX_H
>> +
>> +#include <linux/extcon.h>
>> +#include <linux/usb.h>
>> +
>> +struct usb_mux_dev {
>> +	struct device	*dev;
>> +	char		*extcon_name;
>> +	char		*cable_name;
>> +	int		(*cable_set_cb)(struct usb_mux_dev *mux);
>> +	int		(*cable_unset_cb)(struct usb_mux_dev *mux);
>> +};
>> +
>> +struct usb_mux {
>> +	struct usb_mux_dev		*umdev;
>> +	struct notifier_block		nb;
>> +	struct extcon_specific_cable_nb	obj;
>> +
>> +	/*
>> +	 * The state of the mux.
>> +	 * 0, 1 - mux switch state
>> +	 * -1   - uninitialized state
>> +	 *
>> +	 * mux_mutex is lock to protect mux_state
>> +	 */
>> +	int				mux_state;
>> +	struct mutex			mux_mutex;
>> +
>> +	struct dentry			*debug_file;
>> +};
>
> Why is this a public structure?
>
> And why isn't it properly reference counted if it is a public structure?

Agree. I will move it to .c file and make it private one.

>
>
>> +
>> +#if IS_ENABLED(CONFIG_USB_MUX)
>> +extern int usb_mux_register(struct usb_mux_dev *mux);
>> +extern int usb_mux_unregister(struct device *dev);
>> +extern struct usb_mux_dev *usb_mux_get_dev(struct device *dev);
>> +
>> +#ifdef CONFIG_PM_SLEEP
>> +extern void usb_mux_complete(struct device *dev);
>> +#endif
>> +
>> +#else /* CONFIG_USB_MUX */
>> +static inline int usb_mux_register(struct usb_mux_dev *mux)
>> +{
>> +	return -ENODEV;
>> +}
>> +
>> +static inline int usb_mux_unregister(struct device *dev)
>> +{
>> +	return 0;
>> +}
>> +
>> +static inline struct usb_mux_dev *usb_mux_get_dev(struct device *dev)
>> +{
>> +	return NULL;
>> +}
>> +#endif /* CONFIG_USB_MUX */
>> +
>> +#endif /* __LINUX_USB_MUX_H */
>
> Why do you need this .h file at all?

File mux.c is a common file for all port mux drivers. The individual port
mux driver needs this .h file for structure and function interface definition.

>
> thanks,
>
> greg k-h
>

Thank you for your time.

Best Regards,
-Baolu

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/7] usb: misc: add common code for Intel dual role port mux
  2016-03-03 16:15   ` Greg Kroah-Hartman
@ 2016-03-04  1:25     ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-04  1:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel



On 03/04/2016 12:15 AM, Greg Kroah-Hartman wrote:
> On Thu, Mar 03, 2016 at 02:37:40PM +0800, Lu Baolu wrote:
>> +#if IS_ENABLED(CONFIG_USB_MUX)
>> +extern int usb_mux_register(struct usb_mux_dev *mux);
>> +extern int usb_mux_unregister(struct device *dev);
>> +extern struct usb_mux_dev *usb_mux_get_dev(struct device *dev);
> This api needs a lot of work, for such a "tiny" api, it's obviously
> pretty incorrect.  Please fix it up to be sane...

Sure.

>
>
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03 16:14   ` Greg Kroah-Hartman
@ 2016-03-04  1:38     ` Lu Baolu
  2016-03-04  1:44       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 30+ messages in thread
From: Lu Baolu @ 2016-03-04  1:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao



On 03/04/2016 12:14 AM, Greg Kroah-Hartman wrote:
> On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
>> Several Intel PCHs and SOCs have an internal mux that is used to
>> share one USB port between device controller and host controller.
>> The mux is handled through the Dual Role Configuration Register.
>>
>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> Signed-off-by: Wu Hao <hao.wu@intel.com>
>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>> ---
>>  MAINTAINERS                        |   1 +
>>  drivers/usb/misc/Kconfig           |   7 ++
>>  drivers/usb/misc/Makefile          |   1 +
>>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
>>  4 files changed, 183 insertions(+)
>>  create mode 100644 drivers/usb/misc/intel-mux-drcfg.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 0f321e4..20eb873 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -11396,6 +11396,7 @@ S:	Supported
>>  F:	drivers/usb/misc/mux.c
>>  F:	include/linux/usb/mux.h
>>  F:	drivers/usb/misc/intel-mux-gpio.c
>> +F:	drivers/usb/misc/intel-mux-drcfg.c
>>  
>>  USB PRINTER DRIVER (usblp)
>>  M:	Pete Zaitcev <zaitcev@redhat.com>
>> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
>> index 33e6386..befd910 100644
>> --- a/drivers/usb/misc/Kconfig
>> +++ b/drivers/usb/misc/Kconfig
>> @@ -281,3 +281,10 @@ config INTEL_MUX_GPIO
>>  	help
>>  	  Say Y here to enable support for Intel dual role port mux
>>  	  controlled by GPIOs.
>> +
>> +config INTEL_MUX_DRCFG
>> +	tristate "Intel dual role port mux controlled by register"
>> +	select USB_MUX
>> +	help
>> +	  Say Y here to enable support for Intel dual role port mux
>> +	  controlled by the Dual Role Configuration Registers.
>> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
>> index da4fb4e..c4d19a0 100644
>> --- a/drivers/usb/misc/Makefile
>> +++ b/drivers/usb/misc/Makefile
>> @@ -32,3 +32,4 @@ obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
>>  
>>  obj-$(CONFIG_USB_MUX)			+= mux.o
>>  obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
>> +obj-$(CONFIG_INTEL_MUX_DRCFG)		+= intel-mux-drcfg.o
>> diff --git a/drivers/usb/misc/intel-mux-drcfg.c b/drivers/usb/misc/intel-mux-drcfg.c
>> new file mode 100644
>> index 0000000..29081c5
>> --- /dev/null
>> +++ b/drivers/usb/misc/intel-mux-drcfg.c
>> @@ -0,0 +1,174 @@
>> +/**
>> + * intel-mux-drcfg.c - Driver for Intel USB mux via register
>> + *
>> + * Copyright (C) 2016 Intel Corporation
>> + * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/slab.h>
>> +#include <linux/module.h>
>> +#include <linux/property.h>
>> +#include <linux/usb/mux.h>
>> +#include <linux/platform_device.h>
>> +
>> +#define INTEL_MUX_CFG0		0x00
>> +#define INTEL_MUX_CFG1		0x04
>> +#define CFG0_SW_IDPIN		BIT(20)
>> +#define CFG0_SW_IDPIN_EN	BIT(21)
>> +#define CFG0_SW_VBUS_VALID	BIT(24)
>> +#define CFG1_SW_MODE		BIT(29)
>> +#define CFG1_POLL_TIMEOUT	1000
>> +
>> +struct intel_usb_mux {
>> +	struct usb_mux_dev umdev;
>> +	void __iomem *regs;
>> +	u32 cfg0_ctx;
>> +};
>> +
>> +static inline int intel_mux_drcfg_switch(struct usb_mux_dev *umdev, bool host)
>> +{
>> +	struct intel_usb_mux *mux;
>> +	unsigned long timeout;
>> +	u32 data;
>> +
>> +	mux = container_of(umdev, struct intel_usb_mux, umdev);
>> +
>> +	/* Check and set mux to SW controlled mode */
>> +	data = readl(mux->regs + INTEL_MUX_CFG0);
>> +	if (!(data & CFG0_SW_IDPIN_EN)) {
>> +		data |= CFG0_SW_IDPIN_EN;
>> +		writel(data, mux->regs + INTEL_MUX_CFG0);
>> +	}
>> +
>> +	/*
>> +	 * Configure CFG0 to switch the mux and VBUS_VALID bit is
>> +	 * required for device mode.
>> +	 */
>> +	data = readl(mux->regs + INTEL_MUX_CFG0);
>> +	if (host)
>> +		data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
>> +	else
>> +		data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
>> +	writel(data, mux->regs + INTEL_MUX_CFG0);
>> +
>> +	/*
>> +	 * Polling CFG1 for safety, most case it takes about 600ms
>> +	 * to finish mode switching, set TIMEOUT long enough.
>> +	 */
>> +	timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
>> +
>> +	/* Polling on CFG1 register to confirm mode switch. */
>> +	while (!time_after(jiffies, timeout)) {
>> +		data = readl(mux->regs + INTEL_MUX_CFG1);
>> +		if (!(host ^ (data & CFG1_SW_MODE)))
>> +			return 0;
>> +		/* interval for polling is set to about 5ms */
>> +		usleep_range(5000, 5100);
>> +	}
>> +
>> +	return -ETIMEDOUT;
>> +}
>> +
>> +static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
>> +{
>> +	dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
>> +
>> +	return intel_mux_drcfg_switch(umdev, true);
>> +}
>> +
>> +static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
>> +{
>> +	dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
>> +
>> +	return intel_mux_drcfg_switch(umdev, false);
>> +}
>> +
>> +static int intel_mux_drcfg_probe(struct platform_device *pdev)
>> +{
>> +	struct intel_usb_mux *mux;
>> +	struct usb_mux_dev *umdev;
>> +	struct device *dev = &pdev->dev;
>> +	u64 start, size;
>> +	int ret;
>> +
>> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
>> +	if (!mux)
>> +		return -ENOMEM;
>> +
>> +	ret = device_property_read_u64(dev, "reg-start", &start);
>> +	ret |= device_property_read_u64(dev, "reg-size", &size);
>> +	if (ret)
>> +		return -ENODEV;
> And you leaked memory :(

Did you mean device_property_read_*() allocated memory
and I need to release it before return error?

>
>> +
>> +	mux->regs = devm_ioremap_nocache(dev, start, size);
>> +	if (!mux->regs)
>> +		return -ENOMEM;
> Memory gone :(

devm interface will manage the resources by itself, or not?

>
>> +
>> +	mux->cfg0_ctx = readl(mux->regs + INTEL_MUX_CFG0);
>> +
>> +	umdev = &mux->umdev;
>> +	umdev->dev = dev;
>> +	umdev->cable_name = "USB-HOST";
>> +	umdev->cable_set_cb = intel_mux_drcfg_cable_set;
>> +	umdev->cable_unset_cb = intel_mux_drcfg_cable_unset;
>> +
>> +	ret = usb_mux_register(umdev);
>> +	if (ret)
>> +		writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);
> So if an error happens you just keep going?

No. If error happens, I will restore the register and return error.

Thanks,
-Baolu

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-03 16:12   ` Greg Kroah-Hartman
@ 2016-03-04  1:41     ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-04  1:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao



On 03/04/2016 12:12 AM, Greg Kroah-Hartman wrote:
> On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
>> Several Intel PCHs and SOCs have an internal mux that is used to
>> share one USB port between device controller and host controller.
>> The mux is handled through the Dual Role Configuration Register.
>>
>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> Signed-off-by: Wu Hao <hao.wu@intel.com>
>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>> ---
>>  MAINTAINERS                        |   1 +
>>  drivers/usb/misc/Kconfig           |   7 ++
>>  drivers/usb/misc/Makefile          |   1 +
>>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
> If you are going to start having a bunch of these, please make a new
> directory, drivers/usb/mux/ ?

Sure. I can put them in drivers/usb/mux.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-04  1:38     ` Lu Baolu
@ 2016-03-04  1:44       ` Greg Kroah-Hartman
  2016-03-04  1:58         ` Lu Baolu
  0 siblings, 1 reply; 30+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-04  1:44 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao

On Fri, Mar 04, 2016 at 09:38:58AM +0800, Lu Baolu wrote:
> 
> 
> On 03/04/2016 12:14 AM, Greg Kroah-Hartman wrote:
> > On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
> >> Several Intel PCHs and SOCs have an internal mux that is used to
> >> share one USB port between device controller and host controller.
> >> The mux is handled through the Dual Role Configuration Register.
> >>
> >> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> >> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> >> Signed-off-by: Wu Hao <hao.wu@intel.com>
> >> Reviewed-by: Felipe Balbi <balbi@kernel.org>
> >> ---
> >>  MAINTAINERS                        |   1 +
> >>  drivers/usb/misc/Kconfig           |   7 ++
> >>  drivers/usb/misc/Makefile          |   1 +
> >>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
> >>  4 files changed, 183 insertions(+)
> >>  create mode 100644 drivers/usb/misc/intel-mux-drcfg.c
> >>
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> >> index 0f321e4..20eb873 100644
> >> --- a/MAINTAINERS
> >> +++ b/MAINTAINERS
> >> @@ -11396,6 +11396,7 @@ S:	Supported
> >>  F:	drivers/usb/misc/mux.c
> >>  F:	include/linux/usb/mux.h
> >>  F:	drivers/usb/misc/intel-mux-gpio.c
> >> +F:	drivers/usb/misc/intel-mux-drcfg.c
> >>  
> >>  USB PRINTER DRIVER (usblp)
> >>  M:	Pete Zaitcev <zaitcev@redhat.com>
> >> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
> >> index 33e6386..befd910 100644
> >> --- a/drivers/usb/misc/Kconfig
> >> +++ b/drivers/usb/misc/Kconfig
> >> @@ -281,3 +281,10 @@ config INTEL_MUX_GPIO
> >>  	help
> >>  	  Say Y here to enable support for Intel dual role port mux
> >>  	  controlled by GPIOs.
> >> +
> >> +config INTEL_MUX_DRCFG
> >> +	tristate "Intel dual role port mux controlled by register"
> >> +	select USB_MUX
> >> +	help
> >> +	  Say Y here to enable support for Intel dual role port mux
> >> +	  controlled by the Dual Role Configuration Registers.
> >> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
> >> index da4fb4e..c4d19a0 100644
> >> --- a/drivers/usb/misc/Makefile
> >> +++ b/drivers/usb/misc/Makefile
> >> @@ -32,3 +32,4 @@ obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
> >>  
> >>  obj-$(CONFIG_USB_MUX)			+= mux.o
> >>  obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
> >> +obj-$(CONFIG_INTEL_MUX_DRCFG)		+= intel-mux-drcfg.o
> >> diff --git a/drivers/usb/misc/intel-mux-drcfg.c b/drivers/usb/misc/intel-mux-drcfg.c
> >> new file mode 100644
> >> index 0000000..29081c5
> >> --- /dev/null
> >> +++ b/drivers/usb/misc/intel-mux-drcfg.c
> >> @@ -0,0 +1,174 @@
> >> +/**
> >> + * intel-mux-drcfg.c - Driver for Intel USB mux via register
> >> + *
> >> + * Copyright (C) 2016 Intel Corporation
> >> + * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> >> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/slab.h>
> >> +#include <linux/module.h>
> >> +#include <linux/property.h>
> >> +#include <linux/usb/mux.h>
> >> +#include <linux/platform_device.h>
> >> +
> >> +#define INTEL_MUX_CFG0		0x00
> >> +#define INTEL_MUX_CFG1		0x04
> >> +#define CFG0_SW_IDPIN		BIT(20)
> >> +#define CFG0_SW_IDPIN_EN	BIT(21)
> >> +#define CFG0_SW_VBUS_VALID	BIT(24)
> >> +#define CFG1_SW_MODE		BIT(29)
> >> +#define CFG1_POLL_TIMEOUT	1000
> >> +
> >> +struct intel_usb_mux {
> >> +	struct usb_mux_dev umdev;
> >> +	void __iomem *regs;
> >> +	u32 cfg0_ctx;
> >> +};
> >> +
> >> +static inline int intel_mux_drcfg_switch(struct usb_mux_dev *umdev, bool host)
> >> +{
> >> +	struct intel_usb_mux *mux;
> >> +	unsigned long timeout;
> >> +	u32 data;
> >> +
> >> +	mux = container_of(umdev, struct intel_usb_mux, umdev);
> >> +
> >> +	/* Check and set mux to SW controlled mode */
> >> +	data = readl(mux->regs + INTEL_MUX_CFG0);
> >> +	if (!(data & CFG0_SW_IDPIN_EN)) {
> >> +		data |= CFG0_SW_IDPIN_EN;
> >> +		writel(data, mux->regs + INTEL_MUX_CFG0);
> >> +	}
> >> +
> >> +	/*
> >> +	 * Configure CFG0 to switch the mux and VBUS_VALID bit is
> >> +	 * required for device mode.
> >> +	 */
> >> +	data = readl(mux->regs + INTEL_MUX_CFG0);
> >> +	if (host)
> >> +		data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
> >> +	else
> >> +		data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
> >> +	writel(data, mux->regs + INTEL_MUX_CFG0);
> >> +
> >> +	/*
> >> +	 * Polling CFG1 for safety, most case it takes about 600ms
> >> +	 * to finish mode switching, set TIMEOUT long enough.
> >> +	 */
> >> +	timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
> >> +
> >> +	/* Polling on CFG1 register to confirm mode switch. */
> >> +	while (!time_after(jiffies, timeout)) {
> >> +		data = readl(mux->regs + INTEL_MUX_CFG1);
> >> +		if (!(host ^ (data & CFG1_SW_MODE)))
> >> +			return 0;
> >> +		/* interval for polling is set to about 5ms */
> >> +		usleep_range(5000, 5100);
> >> +	}
> >> +
> >> +	return -ETIMEDOUT;
> >> +}
> >> +
> >> +static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
> >> +{
> >> +	dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
> >> +
> >> +	return intel_mux_drcfg_switch(umdev, true);
> >> +}
> >> +
> >> +static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
> >> +{
> >> +	dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
> >> +
> >> +	return intel_mux_drcfg_switch(umdev, false);
> >> +}
> >> +
> >> +static int intel_mux_drcfg_probe(struct platform_device *pdev)
> >> +{
> >> +	struct intel_usb_mux *mux;
> >> +	struct usb_mux_dev *umdev;
> >> +	struct device *dev = &pdev->dev;
> >> +	u64 start, size;
> >> +	int ret;
> >> +
> >> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
> >> +	if (!mux)
> >> +		return -ENOMEM;
> >> +
> >> +	ret = device_property_read_u64(dev, "reg-start", &start);
> >> +	ret |= device_property_read_u64(dev, "reg-size", &size);
> >> +	if (ret)
> >> +		return -ENODEV;
> > And you leaked memory :(
> 
> Did you mean device_property_read_*() allocated memory
> and I need to release it before return error?
> 
> >
> >> +
> >> +	mux->regs = devm_ioremap_nocache(dev, start, size);
> >> +	if (!mux->regs)
> >> +		return -ENOMEM;
> > Memory gone :(
> 
> devm interface will manage the resources by itself, or not?

Ugh, you are right, nevermind, these both are fine, sorry for the noise.

> >> +	mux->cfg0_ctx = readl(mux->regs + INTEL_MUX_CFG0);
> >> +
> >> +	umdev = &mux->umdev;
> >> +	umdev->dev = dev;
> >> +	umdev->cable_name = "USB-HOST";
> >> +	umdev->cable_set_cb = intel_mux_drcfg_cable_set;
> >> +	umdev->cable_unset_cb = intel_mux_drcfg_cable_unset;
> >> +
> >> +	ret = usb_mux_register(umdev);
> >> +	if (ret)
> >> +		writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);
> > So if an error happens you just keep going?
> 
> No. If error happens, I will restore the register and return error.

That seems a bit "odd", and will change when you fix up the api...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux
  2016-03-04  1:44       ` Greg Kroah-Hartman
@ 2016-03-04  1:58         ` Lu Baolu
  0 siblings, 0 replies; 30+ messages in thread
From: Lu Baolu @ 2016-03-04  1:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Mathias Nyman, Lee Jones, Heikki Krogerus,
	MyungJoo Ham, Chanwoo Choi, linux-usb, linux-kernel, Wu Hao



On 03/04/2016 09:44 AM, Greg Kroah-Hartman wrote:
> On Fri, Mar 04, 2016 at 09:38:58AM +0800, Lu Baolu wrote:
>>
>> On 03/04/2016 12:14 AM, Greg Kroah-Hartman wrote:
>>> On Thu, Mar 03, 2016 at 02:37:42PM +0800, Lu Baolu wrote:
>>>> Several Intel PCHs and SOCs have an internal mux that is used to
>>>> share one USB port between device controller and host controller.
>>>> The mux is handled through the Dual Role Configuration Register.
>>>>
>>>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>>>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>>>> Signed-off-by: Wu Hao <hao.wu@intel.com>
>>>> Reviewed-by: Felipe Balbi <balbi@kernel.org>
>>>> ---
>>>>  MAINTAINERS                        |   1 +
>>>>  drivers/usb/misc/Kconfig           |   7 ++
>>>>  drivers/usb/misc/Makefile          |   1 +
>>>>  drivers/usb/misc/intel-mux-drcfg.c | 174 +++++++++++++++++++++++++++++++++++++
>>>>  4 files changed, 183 insertions(+)
>>>>  create mode 100644 drivers/usb/misc/intel-mux-drcfg.c
>>>>
>>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>>> index 0f321e4..20eb873 100644
>>>> --- a/MAINTAINERS
>>>> +++ b/MAINTAINERS
>>>> @@ -11396,6 +11396,7 @@ S:	Supported
>>>>  F:	drivers/usb/misc/mux.c
>>>>  F:	include/linux/usb/mux.h
>>>>  F:	drivers/usb/misc/intel-mux-gpio.c
>>>> +F:	drivers/usb/misc/intel-mux-drcfg.c
>>>>  
>>>>  USB PRINTER DRIVER (usblp)
>>>>  M:	Pete Zaitcev <zaitcev@redhat.com>
>>>> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
>>>> index 33e6386..befd910 100644
>>>> --- a/drivers/usb/misc/Kconfig
>>>> +++ b/drivers/usb/misc/Kconfig
>>>> @@ -281,3 +281,10 @@ config INTEL_MUX_GPIO
>>>>  	help
>>>>  	  Say Y here to enable support for Intel dual role port mux
>>>>  	  controlled by GPIOs.
>>>> +
>>>> +config INTEL_MUX_DRCFG
>>>> +	tristate "Intel dual role port mux controlled by register"
>>>> +	select USB_MUX
>>>> +	help
>>>> +	  Say Y here to enable support for Intel dual role port mux
>>>> +	  controlled by the Dual Role Configuration Registers.
>>>> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
>>>> index da4fb4e..c4d19a0 100644
>>>> --- a/drivers/usb/misc/Makefile
>>>> +++ b/drivers/usb/misc/Makefile
>>>> @@ -32,3 +32,4 @@ obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
>>>>  
>>>>  obj-$(CONFIG_USB_MUX)			+= mux.o
>>>>  obj-$(CONFIG_INTEL_MUX_GPIO)		+= intel-mux-gpio.o
>>>> +obj-$(CONFIG_INTEL_MUX_DRCFG)		+= intel-mux-drcfg.o
>>>> diff --git a/drivers/usb/misc/intel-mux-drcfg.c b/drivers/usb/misc/intel-mux-drcfg.c
>>>> new file mode 100644
>>>> index 0000000..29081c5
>>>> --- /dev/null
>>>> +++ b/drivers/usb/misc/intel-mux-drcfg.c
>>>> @@ -0,0 +1,174 @@
>>>> +/**
>>>> + * intel-mux-drcfg.c - Driver for Intel USB mux via register
>>>> + *
>>>> + * Copyright (C) 2016 Intel Corporation
>>>> + * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>>>> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundation.
>>>> + */
>>>> +
>>>> +#include <linux/slab.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/property.h>
>>>> +#include <linux/usb/mux.h>
>>>> +#include <linux/platform_device.h>
>>>> +
>>>> +#define INTEL_MUX_CFG0		0x00
>>>> +#define INTEL_MUX_CFG1		0x04
>>>> +#define CFG0_SW_IDPIN		BIT(20)
>>>> +#define CFG0_SW_IDPIN_EN	BIT(21)
>>>> +#define CFG0_SW_VBUS_VALID	BIT(24)
>>>> +#define CFG1_SW_MODE		BIT(29)
>>>> +#define CFG1_POLL_TIMEOUT	1000
>>>> +
>>>> +struct intel_usb_mux {
>>>> +	struct usb_mux_dev umdev;
>>>> +	void __iomem *regs;
>>>> +	u32 cfg0_ctx;
>>>> +};
>>>> +
>>>> +static inline int intel_mux_drcfg_switch(struct usb_mux_dev *umdev, bool host)
>>>> +{
>>>> +	struct intel_usb_mux *mux;
>>>> +	unsigned long timeout;
>>>> +	u32 data;
>>>> +
>>>> +	mux = container_of(umdev, struct intel_usb_mux, umdev);
>>>> +
>>>> +	/* Check and set mux to SW controlled mode */
>>>> +	data = readl(mux->regs + INTEL_MUX_CFG0);
>>>> +	if (!(data & CFG0_SW_IDPIN_EN)) {
>>>> +		data |= CFG0_SW_IDPIN_EN;
>>>> +		writel(data, mux->regs + INTEL_MUX_CFG0);
>>>> +	}
>>>> +
>>>> +	/*
>>>> +	 * Configure CFG0 to switch the mux and VBUS_VALID bit is
>>>> +	 * required for device mode.
>>>> +	 */
>>>> +	data = readl(mux->regs + INTEL_MUX_CFG0);
>>>> +	if (host)
>>>> +		data &= ~(CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
>>>> +	else
>>>> +		data |= (CFG0_SW_IDPIN | CFG0_SW_VBUS_VALID);
>>>> +	writel(data, mux->regs + INTEL_MUX_CFG0);
>>>> +
>>>> +	/*
>>>> +	 * Polling CFG1 for safety, most case it takes about 600ms
>>>> +	 * to finish mode switching, set TIMEOUT long enough.
>>>> +	 */
>>>> +	timeout = jiffies + msecs_to_jiffies(CFG1_POLL_TIMEOUT);
>>>> +
>>>> +	/* Polling on CFG1 register to confirm mode switch. */
>>>> +	while (!time_after(jiffies, timeout)) {
>>>> +		data = readl(mux->regs + INTEL_MUX_CFG1);
>>>> +		if (!(host ^ (data & CFG1_SW_MODE)))
>>>> +			return 0;
>>>> +		/* interval for polling is set to about 5ms */
>>>> +		usleep_range(5000, 5100);
>>>> +	}
>>>> +
>>>> +	return -ETIMEDOUT;
>>>> +}
>>>> +
>>>> +static int intel_mux_drcfg_cable_set(struct usb_mux_dev *umdev)
>>>> +{
>>>> +	dev_dbg(umdev->dev, "drcfg mux switch to HOST\n");
>>>> +
>>>> +	return intel_mux_drcfg_switch(umdev, true);
>>>> +}
>>>> +
>>>> +static int intel_mux_drcfg_cable_unset(struct usb_mux_dev *umdev)
>>>> +{
>>>> +	dev_dbg(umdev->dev, "drcfg mux switch to DEVICE\n");
>>>> +
>>>> +	return intel_mux_drcfg_switch(umdev, false);
>>>> +}
>>>> +
>>>> +static int intel_mux_drcfg_probe(struct platform_device *pdev)
>>>> +{
>>>> +	struct intel_usb_mux *mux;
>>>> +	struct usb_mux_dev *umdev;
>>>> +	struct device *dev = &pdev->dev;
>>>> +	u64 start, size;
>>>> +	int ret;
>>>> +
>>>> +	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
>>>> +	if (!mux)
>>>> +		return -ENOMEM;
>>>> +
>>>> +	ret = device_property_read_u64(dev, "reg-start", &start);
>>>> +	ret |= device_property_read_u64(dev, "reg-size", &size);
>>>> +	if (ret)
>>>> +		return -ENODEV;
>>> And you leaked memory :(
>> Did you mean device_property_read_*() allocated memory
>> and I need to release it before return error?
>>
>>>> +
>>>> +	mux->regs = devm_ioremap_nocache(dev, start, size);
>>>> +	if (!mux->regs)
>>>> +		return -ENOMEM;
>>> Memory gone :(
>> devm interface will manage the resources by itself, or not?
> Ugh, you are right, nevermind, these both are fine, sorry for the noise.
>
>>>> +	mux->cfg0_ctx = readl(mux->regs + INTEL_MUX_CFG0);
>>>> +
>>>> +	umdev = &mux->umdev;
>>>> +	umdev->dev = dev;
>>>> +	umdev->cable_name = "USB-HOST";
>>>> +	umdev->cable_set_cb = intel_mux_drcfg_cable_set;
>>>> +	umdev->cable_unset_cb = intel_mux_drcfg_cable_unset;
>>>> +
>>>> +	ret = usb_mux_register(umdev);
>>>> +	if (ret)
>>>> +		writel(mux->cfg0_ctx, mux->regs + INTEL_MUX_CFG0);
>>> So if an error happens you just keep going?
>> No. If error happens, I will restore the register and return error.
> That seems a bit "odd", and will change when you fix up the api...

Sure.

>
> thanks,
>
> greg k-h
>

Thank you for your time.

Best Regards,
baolu

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-03-04  1:58 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-03  6:37 [PATCH 0/7] usb: add support for Intel dual role port mux Lu Baolu
2016-03-03  6:37 ` [PATCH 1/7] extcon: usb-gpio: add device binding for platform device Lu Baolu
2016-03-03  7:24   ` Chanwoo Choi
2016-03-03  7:35     ` Lu Baolu
2016-03-03  6:37 ` [PATCH 2/7] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu
2016-03-03  7:24   ` Chanwoo Choi
2016-03-03  7:35     ` Lu Baolu
2016-03-03  6:37 ` [PATCH 3/7] usb: misc: add common code for Intel dual role port mux Lu Baolu
2016-03-03 16:10   ` Greg Kroah-Hartman
2016-03-04  1:11     ` Lu Baolu
2016-03-03 16:15   ` Greg Kroah-Hartman
2016-03-04  1:25     ` Lu Baolu
2016-03-03  6:37 ` [PATCH 4/7] usb: misc: add driver for Intel gpio controlled " Lu Baolu
2016-03-03  8:16   ` kbuild test robot
2016-03-03  8:16   ` [PATCH] usb: misc: fix platform_no_drv_owner.cocci warnings kbuild test robot
2016-03-03  6:37 ` [PATCH 5/7] usb: misc: add driver for Intel drcfg controlled port mux Lu Baolu
2016-03-03 15:20   ` kbuild test robot
2016-03-03 16:12   ` Greg Kroah-Hartman
2016-03-04  1:41     ` Lu Baolu
2016-03-03 16:14   ` Greg Kroah-Hartman
2016-03-04  1:38     ` Lu Baolu
2016-03-04  1:44       ` Greg Kroah-Hartman
2016-03-04  1:58         ` Lu Baolu
2016-03-03  6:37 ` [PATCH 6/7] usb: pci-quirks: add Intel USB drcfg mux device Lu Baolu
2016-03-03  6:37 ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
2016-03-03  8:16   ` kbuild test robot
2016-03-03  8:16   ` [PATCH] mfd: intel_vuport: fix platform_no_drv_owner.cocci warnings kbuild test robot
2016-03-03 11:35   ` [PATCH 7/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver kbuild test robot
2016-03-03 17:26   ` kbuild test robot
2016-03-03 19:57   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.