Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1386082 > unrolled thread
| Started by | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| First post | 2016-04-25 10:10 +0200 |
| Last post | 2016-04-26 02:50 +0200 |
| Articles | 20 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v6 00/10] usb: add support for Intel dual role port mux Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
[PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
Re: [PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface Chanwoo Choi <cw00.choi@samsung.com> - 2016-04-26 02:00 +0200
Re: [PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-26 02:50 +0200
[PATCH v6 10/10] MAINTAINERS: add maintainer entry for Intel USB dual role mux drivers Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
[PATCH v6 03/10] regulator: fixed: add device binding for platform device Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
Re: [PATCH v6 03/10] regulator: fixed: add device binding for platform device Mark Brown <broonie@kernel.org> - 2016-04-25 18:50 +0200
Re: [PATCH v6 03/10] regulator: fixed: add device binding for platform device Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-26 04:20 +0200
[PATCH v6 06/10] usb: mux: add driver for Intel gpio controlled port mux Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
[PATCH v6 04/10] regulator: fixed: add support for ACPI interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Mark Brown <broonie@kernel.org> - 2016-04-25 19:40 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-26 04:30 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Mark Brown <broonie@kernel.org> - 2016-04-26 12:30 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-27 04:00 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Mark Brown <broonie@kernel.org> - 2016-04-27 14:40 +0200
Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-28 08:00 +0200
[PATCH v6 09/10] usb: pci-quirks: add Intel USB drcfg mux device Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:10 +0200
[PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-25 10:20 +0200
Re: [PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device Chanwoo Choi <cw00.choi@samsung.com> - 2016-04-26 02:00 +0200
Re: [PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device Lu Baolu <baolu.lu@linux.intel.com> - 2016-04-26 02:50 +0200
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 00/10] usb: add support for Intel dual role port mux |
| Message-ID | <rrJKG-2lq-3@gated-at.bofh.it> |
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 a USB gpio extcon device, a fixed regulator for gpio
controlled USB VCC, 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 (10):
extcon: usb-gpio: add device binding for platform device
extcon: usb-gpio: add support for ACPI gpio interface
regulator: fixed: add device binding for platform device
regulator: fixed: add support for ACPI interface
usb: mux: add generic code for dual role port mux
usb: mux: add driver for Intel gpio controlled port mux
usb: mux: add driver for Intel drcfg controlled port mux
mfd: intel_vuport: Add Intel virtual USB port MFD Driver
usb: pci-quirks: add Intel USB drcfg mux device
MAINTAINERS: add maintainer entry for Intel USB dual role mux drivers
Change log:
v5->v6:
Work internally with Felipe to improve the whole patch series.
Below changes have been made since last version.
- rework the common code to make it a generic interface for mux devices;
- split the vbus gpio handling to a fixed regulator device;
- removed unnecessary filtering for state change;
- removed unnecessary WARN statement;
- removed globals in mux drivers;
- removed unnecessary register polling and waiting in drcfg driver;
v4->v5:
- Change the extcon interfaces with the new ones suggested by
2a9de9c0f08d6 (extcon: Use the unique id for external connector
instead of string)
- remove patch "usb: pci-quirks: add Intel USB drcfg mux device"
from this serial due to that it's not driver staff. Will be
submitted seperately.
v3->v4:
- Check all patches with "checkpatch.pl --strict", and fix all
CHECKs;
- Change sysfs node from "intel_mux" to "port_mux";
- Refines below confusing functions:
intel_usb_mux_register() -> intel_usb_mux_bind_cable()
intel_usb_mux_unregister() -> intel_usb_mux_unbind_cable();
- Remove unnecessary struct intel_mux_dev.
v2->v3:
- uvport mfd driver got reviewed by Lee Jones, the following
changes were made accordingly.
- seperate uvport driver from the mux drivers in MAINTAINERS file
- refine the description in Kconfig
- refine the mfd_cell structure data
v1->v2:
- move mux driver from drivers/usb/misc to drivers/usb/mux;
- replace debugfs with sysfs for user level mux control;
- remove unnecessary register restore if mux registeration failed;
- Add "Acked-by: Chanwoo Choi <cw00.choi@samsung.com>" to extcon changes;
- Make the file names and exported function names more specific;
- Remove the usb_mux_get_dev() interface;
- Move "struct intel_usb_mux" from .h to .c file;
- Fix various kbuild robot warnings.
Documentation/ABI/testing/sysfs-bus-platform | 17 +++
MAINTAINERS | 10 ++
drivers/extcon/extcon-usb-gpio.c | 10 +-
drivers/mfd/Kconfig | 8 +
drivers/mfd/Makefile | 1 +
drivers/mfd/intel-vuport.c | 90 +++++++++++
drivers/regulator/fixed.c | 55 +++++++
drivers/usb/Kconfig | 2 +
drivers/usb/Makefile | 1 +
drivers/usb/host/pci-quirks.c | 45 +++++-
drivers/usb/host/xhci-ext-caps.h | 2 +
drivers/usb/mux/Kconfig | 30 ++++
drivers/usb/mux/Makefile | 6 +
drivers/usb/mux/portmux-core.c | 217 +++++++++++++++++++++++++++
drivers/usb/mux/portmux-intel-drcfg.c | 171 +++++++++++++++++++++
drivers/usb/mux/portmux-intel-gpio.c | 149 ++++++++++++++++++
include/linux/usb/portmux.h | 78 ++++++++++
17 files changed, 889 insertions(+), 3 deletions(-)
create mode 100644 drivers/mfd/intel-vuport.c
create mode 100644 drivers/usb/mux/Kconfig
create mode 100644 drivers/usb/mux/Makefile
create mode 100644 drivers/usb/mux/portmux-core.c
create mode 100644 drivers/usb/mux/portmux-intel-drcfg.c
create mode 100644 drivers/usb/mux/portmux-intel-gpio.c
create mode 100644 include/linux/usb/portmux.h
--
2.1.4
[toc] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface |
| Message-ID | <rrJKG-2lq-11@gated-at.bofh.it> |
| In reply to | #1386082 |
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> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> --- 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
[toc] | [prev] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2016-04-26 02:00 +0200 |
| Subject | Re: [PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface |
| Message-ID | <rrYA1-67A-1@gated-at.bofh.it> |
| In reply to | #1386083 |
Hi Lu, On 2016년 04월 25일 17:04, 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> > Acked-by: Chanwoo Choi <cw00.choi@samsung.com> > --- > 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); > Applied it. Thanks, Chanwoo Choi
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-26 02:50 +0200 |
| Subject | Re: [PATCH v6 02/10] extcon: usb-gpio: add support for ACPI gpio interface |
| Message-ID | <rrZmq-6LW-11@gated-at.bofh.it> |
| In reply to | #1387007 |
Hi, On 04/26/2016 07:51 AM, Chanwoo Choi wrote: > Hi Lu, > > On 2016년 04월 25일 17:04, 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> >> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> >> --- >> 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); >> > Applied it. > > Thanks, > Chanwoo Choi > Thank you. Best regards, Baolu >
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 10/10] MAINTAINERS: add maintainer entry for Intel USB dual role mux drivers |
| Message-ID | <rrJKG-2lq-9@gated-at.bofh.it> |
| In reply to | #1386082 |
Add a maintainer entry for Intel USB dual role mux drivers and add myself as a maintainer. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 03e00c7..e2609e6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5878,6 +5878,16 @@ S: Maintained F: arch/x86/include/asm/intel_telemetry.h F: drivers/platform/x86/intel_telemetry* +INTEL USB DUAL ROLE PORT MUX DRIVERS +M: Lu Baolu <baolu.lu@linux.intel.com> +L: linux-usb@vger.kernel.org +S: Supported +F: include/linux/usb/intel-mux.h +F: drivers/usb/mux/intel-mux.c +F: drivers/usb/mux/intel-mux-gpio.c +F: drivers/usb/mux/intel-mux-drcfg.c +F: drivers/mfd/intel-vuport.c + IOC3 ETHERNET DRIVER M: Ralf Baechle <ralf@linux-mips.org> L: linux-mips@linux-mips.org -- 2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 03/10] regulator: fixed: add device binding for platform device |
| Message-ID | <rrJKH-2lq-21@gated-at.bofh.it> |
| In reply to | #1386082 |
This is needed to handle the GPIO connected USB vcc pin found on
Intel Baytrail devices.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/regulator/fixed.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index ff62d69..e6f376f 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -209,12 +209,19 @@ static const struct of_device_id fixed_of_match[] = {
MODULE_DEVICE_TABLE(of, fixed_of_match);
#endif
+static const struct platform_device_id fixed_platform_ids[] = {
+ { .name = "reg-fixed-voltage", },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, fixed_platform_ids);
+
static struct platform_driver regulator_fixed_voltage_driver = {
.probe = reg_fixed_voltage_probe,
.driver = {
.name = "reg-fixed-voltage",
.of_match_table = of_match_ptr(fixed_of_match),
},
+ .id_table = fixed_platform_ids,
};
static int __init regulator_fixed_voltage_init(void)
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-04-25 18:50 +0200 |
| Subject | Re: [PATCH v6 03/10] regulator: fixed: add device binding for platform device |
| Message-ID | <rrRRU-GH-1@gated-at.bofh.it> |
| In reply to | #1386087 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Apr 25, 2016 at 04:04:49PM +0800, Lu Baolu wrote: > This is needed to handle the GPIO connected USB vcc pin found on > Intel Baytrail devices. In what way is this needed? The we defualt to using the driver name if no platform ID table, AFAICT this is just restating the same string?
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-26 04:20 +0200 |
| Subject | Re: [PATCH v6 03/10] regulator: fixed: add device binding for platform device |
| Message-ID | <rs0Lw-89e-15@gated-at.bofh.it> |
| In reply to | #1386661 |
Hi Mark, On 04/26/2016 12:40 AM, Mark Brown wrote: > On Mon, Apr 25, 2016 at 04:04:49PM +0800, Lu Baolu wrote: > >> This is needed to handle the GPIO connected USB vcc pin found on >> Intel Baytrail devices. > In what way is this needed? The we defualt to using the driver name if > no platform ID table, AFAICT this is just restating the same string? You are right. This is not a "needed". It just makes the platform driver binding explicit. We can ignore it if you don't like it. Best regards, Lu Baolu
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 06/10] usb: mux: add driver for Intel gpio controlled port mux |
| Message-ID | <rrJKH-2lq-23@gated-at.bofh.it> |
| In reply to | #1386082 |
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.
[baolu: removed .owner per platform_no_drv_owner.cocci]
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>
---
drivers/usb/mux/Kconfig | 11 +++
drivers/usb/mux/Makefile | 1 +
drivers/usb/mux/portmux-intel-gpio.c | 149 +++++++++++++++++++++++++++++++++++
3 files changed, 161 insertions(+)
create mode 100644 drivers/usb/mux/portmux-intel-gpio.c
diff --git a/drivers/usb/mux/Kconfig b/drivers/usb/mux/Kconfig
index d91909f..1dc1f33 100644
--- a/drivers/usb/mux/Kconfig
+++ b/drivers/usb/mux/Kconfig
@@ -8,4 +8,15 @@ config USB_PORTMUX
def_bool n
help
Generic USB dual role port mux support.
+
+config INTEL_MUX_GPIO
+ tristate "Intel dual role port mux controlled by GPIOs"
+ depends on GPIOLIB
+ depends on REGULATOR
+ depends on X86 && ACPI
+ select USB_PORTMUX
+ help
+ Say Y here to enable support for Intel dual role port mux
+ controlled by GPIOs.
+
endmenu
diff --git a/drivers/usb/mux/Makefile b/drivers/usb/mux/Makefile
index f85df92..4eb5582 100644
--- a/drivers/usb/mux/Makefile
+++ b/drivers/usb/mux/Makefile
@@ -2,3 +2,4 @@
# Makefile for USB port mux drivers
#
obj-$(CONFIG_USB_PORTMUX) += portmux-core.o
+obj-$(CONFIG_INTEL_MUX_GPIO) += portmux-intel-gpio.o
diff --git a/drivers/usb/mux/portmux-intel-gpio.c b/drivers/usb/mux/portmux-intel-gpio.c
new file mode 100644
index 0000000..b07ae2c
--- /dev/null
+++ b/drivers/usb/mux/portmux-intel-gpio.c
@@ -0,0 +1,149 @@
+/*
+ * 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/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/usb/portmux.h>
+#include <linux/regulator/consumer.h>
+
+struct vuport {
+ struct portmux_desc desc;
+ struct portmux_dev *pdev;
+ struct regulator *regulator;
+ 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 device *dev, int id)
+{
+ struct vuport *vup;
+
+ dev_dbg(dev, "USB PORT ID: %s\n", id ? "HOST" : "PERIPHERAL");
+
+ vup = dev_get_drvdata(dev);
+
+ gpiod_set_value_cansleep(vup->gpio_usb_mux, !id);
+
+ if (!id ^ regulator_is_enabled(vup->regulator))
+ return id ? regulator_disable(vup->regulator) :
+ regulator_enable(vup->regulator);
+
+ return 0;
+}
+
+static int vuport_cable_set(struct device *dev)
+{
+ return vuport_set_port(dev, 1);
+}
+
+static int vuport_cable_unset(struct device *dev)
+{
+ return vuport_set_port(dev, 0);
+}
+
+static const struct portmux_ops vuport_ops = {
+ .cable_set_cb = vuport_cable_set,
+ .cable_unset_cb = vuport_cable_unset,
+};
+
+static int vuport_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct vuport *vup;
+
+ vup = devm_kzalloc(dev, sizeof(*vup), GFP_KERNEL);
+ if (!vup)
+ return -ENOMEM;
+
+ vup->regulator = devm_regulator_get_exclusive(dev,
+ "regulator-usb-gpio");
+ if (IS_ERR(vup->regulator))
+ return -EPROBE_DEFER;
+
+ 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);
+
+ vup->desc.dev = dev;
+ vup->desc.name = "intel-mux-gpio";
+ vup->desc.extcon_name = "extcon-usb-gpio";
+ vup->desc.ops = &vuport_ops;
+ vup->desc.initial_state = -1;
+ dev_set_drvdata(dev, vup);
+ vup->pdev = portmux_register(&vup->desc);
+
+ return PTR_ERR_OR_ZERO(vup->pdev);
+}
+
+static int vuport_remove(struct platform_device *pdev)
+{
+ struct vuport *vup;
+
+ vup = platform_get_drvdata(pdev);
+ portmux_unregister(vup->pdev);
+
+ return 0;
+}
+
+#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 void vuport_complete(struct device *dev)
+{
+ struct vuport *vup;
+
+ vup = dev_get_drvdata(dev);
+ portmux_complete(vup->pdev);
+}
+
+static const struct dev_pm_ops vuport_pm_ops = {
+ .complete = vuport_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",
+#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
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rrJKH-2lq-25@gated-at.bofh.it> |
| In reply to | #1386082 |
Add support to retrieve fixed voltage configure information through
ACPI interface. This is needed for Intel Bay Trail devices, where a
GPIO is used to control the USB vbus.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/regulator/fixed.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index e6f376f..4d0cc84 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -30,6 +30,9 @@
#include <linux/of_gpio.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
+#include <linux/acpi.h>
+#include <linux/property.h>
+#include <linux/gpio/consumer.h>
struct fixed_voltage_data {
struct regulator_desc desc;
@@ -104,6 +107,46 @@ of_get_fixed_voltage_config(struct device *dev,
return config;
}
+/**
+ * acpi_get_fixed_voltage_config - extract fixed_voltage_config structure info
+ * @dev: device requesting for fixed_voltage_config
+ * @desc: regulator description
+ *
+ * Populates fixed_voltage_config structure by extracting data through ACPI
+ * interface, returns a pointer to the populated structure of NULL if memory
+ * alloc fails.
+ */
+static struct fixed_voltage_config *
+acpi_get_fixed_voltage_config(struct device *dev,
+ const struct regulator_desc *desc)
+{
+ struct fixed_voltage_config *config;
+ const char *supply_name, *gpio_name;
+ struct gpio_desc *gpiod;
+ int ret;
+
+ config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL);
+ if (!config)
+ return ERR_PTR(-ENOMEM);
+
+ ret = device_property_read_string(dev, "supply-name", &supply_name);
+ if (!ret)
+ config->supply_name = supply_name;
+
+ ret = device_property_read_string(dev, "gpio-name", &gpio_name);
+ if (!ret) {
+ gpiod = gpiod_get(dev, gpio_name, GPIOD_ASIS);
+ if (!IS_ERR(gpiod)) {
+ config->gpio = desc_to_gpio(gpiod);
+ config->enable_high = device_property_read_bool(dev,
+ "enable-active-high");
+ gpiod_put(gpiod);
+ }
+ }
+
+ return config;
+}
+
static struct regulator_ops fixed_voltage_ops = {
};
@@ -124,6 +167,11 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
&drvdata->desc);
if (IS_ERR(config))
return PTR_ERR(config);
+ } else if (ACPI_HANDLE(&pdev->dev)) {
+ config = acpi_get_fixed_voltage_config(&pdev->dev,
+ &drvdata->desc);
+ if (IS_ERR(config))
+ return PTR_ERR(config);
} else {
config = dev_get_platdata(&pdev->dev);
}
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-04-25 19:40 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rrSEj-1jR-35@gated-at.bofh.it> |
| In reply to | #1386090 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Apr 25, 2016 at 04:04:50PM +0800, Lu Baolu wrote:
> + ret = device_property_read_string(dev, "gpio-name", &gpio_name);
> + if (!ret) {
> + gpiod = gpiod_get(dev, gpio_name, GPIOD_ASIS);
> + if (!IS_ERR(gpiod)) {
This doesn't look like it's a standard ACPI binding for GPIOs, why are
we using a property to get the GPIO noame?
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-26 04:30 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rs0Vb-8eO-3@gated-at.bofh.it> |
| In reply to | #1386697 |
Hi Mark,
On 04/26/2016 01:30 AM, Mark Brown wrote:
> On Mon, Apr 25, 2016 at 04:04:50PM +0800, Lu Baolu wrote:
>
>> + ret = device_property_read_string(dev, "gpio-name", &gpio_name);
>> + if (!ret) {
>> + gpiod = gpiod_get(dev, gpio_name, GPIOD_ASIS);
>> + if (!IS_ERR(gpiod)) {
> This doesn't look like it's a standard ACPI binding for GPIOs, why are
> we using a property to get the GPIO noame?
The GPIO name might be different in different use cases. For my case,
it is "vbus_en", but other cases should use the different name.
On ACPI compatible platforms, GPIO resources are reported via ACPI
tables and (devm_)gpiod_get() hides the APCI complexity and returns
the gpiod according to "gpio_name".
Best regards,
Lu Baolu
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-04-26 12:30 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rs8pI-5ZZ-9@gated-at.bofh.it> |
| In reply to | #1387089 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Apr 26, 2016 at 10:24:56AM +0800, Lu Baolu wrote: > The GPIO name might be different in different use cases. For my case, > it is "vbus_en", but other cases should use the different name. > On ACPI compatible platforms, GPIO resources are reported via ACPI > tables and (devm_)gpiod_get() hides the APCI complexity and returns > the gpiod according to "gpio_name". That's labelling that you might want to do on the supplier side or at system level. Why does the device care? It's requesting the GPIO in its own context and it's only requesting one GPIO, with DT we're just always calling the GPIO "gpio" which works fine.
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-27 04:00 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rsmVI-1a3-3@gated-at.bofh.it> |
| In reply to | #1387336 |
Hi, On 04/26/2016 06:23 PM, Mark Brown wrote: > On Tue, Apr 26, 2016 at 10:24:56AM +0800, Lu Baolu wrote: > >> The GPIO name might be different in different use cases. For my case, >> it is "vbus_en", but other cases should use the different name. >> On ACPI compatible platforms, GPIO resources are reported via ACPI >> tables and (devm_)gpiod_get() hides the APCI complexity and returns >> the gpiod according to "gpio_name". > That's labelling that you might want to do on the supplier side or at > system level. The labeling is done at firmware level (ACPI 5.1). It uses _DSD configuration object to give names to GPIOs. There are systems which don't contain _DSD. On those platforms, Linux kernel could do this instead. Please refer to Documentation/acpi/gpio-properties.txt. > Why does the device care?It's requesting the GPIO in > its own context and it's only requesting one GPIO, with DT we're just > always calling the GPIO "gpio" which works fine. This driver is not bound to an ACPI device node directly. It's a child of a mfd device, which is corresponding to a real ACPI device node. I agree with you that we should not retrieve gpio name from the device provider. Driver should have the knowledge of the gpio name. (Please correct me if I didn't understand your point right. :-) ) Best regards, Lu Baolu
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-04-27 14:40 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rswV3-1g9-11@gated-at.bofh.it> |
| In reply to | #1388586 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Apr 27, 2016 at 09:54:10AM +0800, Lu Baolu wrote: > Please refer to Documentation/acpi/gpio-properties.txt. That's not visibly what your driver is doing, that is also recommending using a static name which is what I'm asking for. > > Why does the device care?It's requesting the GPIO in > > its own context and it's only requesting one GPIO, with DT we're just > > always calling the GPIO "gpio" which works fine. > This driver is not bound to an ACPI device node directly. It's a child > of a mfd device, which is corresponding to a real ACPI device node. If it's the child of a MFD it's got an ACPI device, the ACPI device is the parent. It should use the parent device or the parent should map the GPIO through to the child as many other MFDs do, the whole concept of a MFD is a Linux internal implementation detail.
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-28 08:00 +0200 |
| Subject | Re: [PATCH v6 04/10] regulator: fixed: add support for ACPI interface |
| Message-ID | <rsN9v-6ll-3@gated-at.bofh.it> |
| In reply to | #1388982 |
Hi, On 04/27/2016 08:33 PM, Mark Brown wrote: > On Wed, Apr 27, 2016 at 09:54:10AM +0800, Lu Baolu wrote: > >> Please refer to Documentation/acpi/gpio-properties.txt. > That's not visibly what your driver is doing, that is also recommending > using a static name which is what I'm asking for. Yes, I agree that we should use a static name. > >>> Why does the device care?It's requesting the GPIO in >>> its own context and it's only requesting one GPIO, with DT we're just >>> always calling the GPIO "gpio" which works fine. >> This driver is not bound to an ACPI device node directly. It's a child >> of a mfd device, which is corresponding to a real ACPI device node. > If it's the child of a MFD it's got an ACPI device, the ACPI device is > the parent.It should use the parent device or the parent should map > the GPIO through to the child as many other MFDs do, the whole concept > of a MFD is a Linux internal implementation detail. Yes. The mapping of GPIO is done in the parent. And the parent passes the GPIO by setting ACPI companion to this device (done in mfd internal). This driver is able to get the gpio descriptor with a static name. How about below code? + gpiod = gpiod_get(dev, "vbus_en", GPIOD_ASIS); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + + config->gpio = desc_to_gpio(gpiod); + config->enable_high = device_property_read_bool(dev, + "enable-active-high"); + gpiod_put(gpiod); Best regards, Lu Baolu
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:10 +0200 |
| Subject | [PATCH v6 09/10] usb: pci-quirks: add Intel USB drcfg mux device |
| Message-ID | <rrJKH-2lq-27@gated-at.bofh.it> |
| In reply to | #1386082 |
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 | 45 ++++++++++++++++++++++++++++++++++++++--
drivers/usb/host/xhci-ext-caps.h | 2 ++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 35af362..9bb7aa1 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,8 @@
#define USB_INTEL_USB3_PSSEN 0xD8
#define USB_INTEL_USB3PRM 0xDC
+#define DEVICE_ID_INTEL_BROXTON_P_XHCI 0x5aa8
+
/*
* amd_chipset_gen values represent AMD different chipset generations
*/
@@ -956,6 +959,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_NONE);
+ 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 +1060,11 @@ 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_BROXTON_P_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
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-25 10:20 +0200 |
| Subject | [PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device |
| Message-ID | <rrJUm-2qD-13@gated-at.bofh.it> |
| In reply to | #1386082 |
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>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
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
[toc] | [prev] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2016-04-26 02:00 +0200 |
| Subject | Re: [PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device |
| Message-ID | <rrYA2-67A-13@gated-at.bofh.it> |
| In reply to | #1386094 |
Hi Lu,
On 2016년 04월 25일 17:04, 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>
> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
> 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);
>
Applied it.
Thanks,
Chanwoo Choi
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2016-04-26 02:50 +0200 |
| Subject | Re: [PATCH v6 01/10] extcon: usb-gpio: add device binding for platform device |
| Message-ID | <rrZmq-6LW-21@gated-at.bofh.it> |
| In reply to | #1387011 |
Hi,
On 04/26/2016 07:51 AM, Chanwoo Choi wrote:
> Hi Lu,
>
> On 2016년 04월 25일 17:04, 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>
>> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>> 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);
>>
> Applied it.
>
> Thanks,
> Chanwoo Choi
Thank you.
Best regards,
Baolu
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web