From: Lu Baolu <baolu.lu@linux.intel.com>
To: felipe.balbi@linux.intel.com,
Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Lee Jones <lee.jones@linaro.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Lu Baolu <baolu.lu@linux.intel.com>
Subject: [PATCH v10 5/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver
Date: Thu, 2 Jun 2016 09:37:27 +0800 [thread overview]
Message-ID: <1464831449-8973-6-git-send-email-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <1464831449-8973-1-git-send-email-baolu.lu@linux.intel.com>
Some Intel platforms have an USB port mux controlled by GPIOs.
There's a single ACPI platform device that provides 1) USB ID
extcon device; 2) USB vbus regulator device; and 3) USB port
switch device. This MFD driver will split these 3 devices for
their respective drivers.
[baolu: removed .owner per platform_no_drv_owner.cocci]
Suggested-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mfd/Kconfig | 8 +++++
drivers/mfd/Makefile | 1 +
drivers/mfd/intel-vuport.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 drivers/mfd/intel-vuport.c
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1bcf601..94affb3 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1603,5 +1603,13 @@ 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
+ depends on X86 && ACPI
+ help
+ Say Y here to enable support for Intel's dual role port mux
+ controlled by GPIOs.
+
endmenu
endif
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 42a66e1..b86d4f9 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -205,3 +205,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..eb27a8f
--- /dev/null
+++ b/drivers/mfd/intel-vuport.c
@@ -0,0 +1,86 @@
+/*
+ * 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/module.h>
+#include <linux/gpio.h>
+#include <linux/mfd/core.h>
+#include <linux/property.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 },
+ { "gpio-gpios", &vbus_gpio, 1 },
+ { "usb_mux-gpios", &mux_gpio, 1 },
+ { },
+};
+
+static struct property_entry reg_properties[] = {
+ PROPERTY_ENTRY_STRING("supply-name", "regulator-usb-gpio"),
+ { },
+};
+
+static const struct mfd_cell intel_vuport_mfd_cells[] = {
+ { .name = "extcon-usb-gpio", },
+ {
+ .name = "reg-fixed-voltage",
+ .properties = reg_properties,
+ },
+ { .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, PLATFORM_DEVID_NONE,
+ 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",
+ .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
next prev parent reply other threads:[~2016-06-02 1:38 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 1:37 [PATCH v10 0/7] usb: add support for Intel dual role port mux Lu Baolu
2016-06-02 1:37 ` [PATCH v10 1/7] regulator: fixed: add support for ACPI interface Lu Baolu
2016-06-08 4:42 ` Greg Kroah-Hartman
2016-06-08 13:43 ` Mark Brown
2016-06-08 15:46 ` Greg Kroah-Hartman
2016-06-09 2:43 ` Lu Baolu
2016-06-02 1:37 ` [PATCH v10 2/7] usb: mux: add generic code for dual role port mux Lu Baolu
2016-06-03 7:41 ` Peter Chen
2016-06-03 8:16 ` Heikki Krogerus
2016-06-03 9:20 ` Peter Chen
2016-06-03 16:06 ` Lu Baolu
2016-06-04 2:28 ` Peter Chen
2016-06-05 6:55 ` Lu Baolu
2016-06-05 8:33 ` Jun Li
2016-06-05 8:46 ` Lu Baolu
2016-06-06 1:08 ` Jun Li
2016-06-06 2:30 ` Lu Baolu
2016-06-06 2:05 ` Peter Chen
2016-06-06 2:45 ` Lu Baolu
2016-06-06 6:48 ` Peter Chen
2016-06-06 1:25 ` Peter Chen
2016-06-06 3:04 ` Lu Baolu
2016-06-06 7:02 ` Roger Quadros
2016-06-07 3:03 ` Jun Li
2016-06-07 6:27 ` Lu Baolu
2016-06-07 6:34 ` Jun Li
2016-06-07 9:27 ` Lu Baolu
2016-06-07 12:49 ` Roger Quadros
2016-06-07 9:53 ` Lu Baolu
2016-06-07 12:58 ` Roger Quadros
2016-06-07 13:04 ` Felipe Balbi
2016-06-07 14:02 ` Roger Quadros
2016-06-07 15:05 ` Felipe Balbi
2016-06-08 3:04 ` Jun Li
[not found] ` <5757A8CB.90402@linux.intel.com>
2016-06-08 6:20 ` Jun Li
2016-06-08 6:25 ` Peter Chen
2016-06-08 7:58 ` Roger Quadros
2016-06-06 7:02 ` Peter Chen
2016-06-06 7:35 ` Lu Baolu
2016-06-02 1:37 ` [PATCH v10 3/7] usb: mux: add driver for Intel gpio controlled " Lu Baolu
2016-06-02 1:37 ` [PATCH v10 4/7] usb: mux: add driver for Intel drcfg " Lu Baolu
2016-06-02 1:37 ` Lu Baolu [this message]
2016-06-02 1:37 ` [PATCH v10 6/7] usb: pci-quirks: add Intel USB drcfg mux device Lu Baolu
2016-06-08 4:45 ` Greg Kroah-Hartman
2016-06-08 7:56 ` Lu Baolu
2016-06-08 15:45 ` Greg Kroah-Hartman
2016-06-09 2:39 ` Lu Baolu
2016-06-16 0:27 ` Lu Baolu
2016-06-18 0:58 ` Greg Kroah-Hartman
2016-06-19 9:52 ` Lu Baolu
2016-06-02 1:37 ` [PATCH v10 7/7] MAINTAINERS: add maintainer entry for Intel USB dual role mux drivers Lu Baolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464831449-8973-6-git-send-email-baolu.lu@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=broonie@kernel.org \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).