From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Felipe Balbi <balbi@kernel.org>
Subject: [PATCH 3/3] usb: type-c: UCSI ACPI driver
Date: Tue, 9 Feb 2016 19:01:23 +0200 [thread overview]
Message-ID: <1455037283-106479-4-git-send-email-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <1455037283-106479-1-git-send-email-heikki.krogerus@linux.intel.com>
Driver for ACPI enumerated UCSI devices.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/usb/type-c/Kconfig | 10 ++++
drivers/usb/type-c/Makefile | 1 +
drivers/usb/type-c/ucsi_acpi.c | 133 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+)
create mode 100644 drivers/usb/type-c/ucsi_acpi.c
diff --git a/drivers/usb/type-c/Kconfig b/drivers/usb/type-c/Kconfig
index 02abd74..72b002e 100644
--- a/drivers/usb/type-c/Kconfig
+++ b/drivers/usb/type-c/Kconfig
@@ -12,4 +12,14 @@ config TYPEC_UCSI
registers and data structures used to interface with the USB Type-C
connectors on a system.
+if TYPEC_UCSI
+
+config TYPEC_UCSI_ACPI
+ tristate "UCSI ACPI Driver"
+ depends on ACPI
+ help
+ Driver for ACPI enumerated UCSI devices.
+
+endif
+
endmenu
diff --git a/drivers/usb/type-c/Makefile b/drivers/usb/type-c/Makefile
index ab974ba..17933dc 100644
--- a/drivers/usb/type-c/Makefile
+++ b/drivers/usb/type-c/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_TYPEC) += typec.o
obj-$(CONFIG_TYPEC_UCSI) += ucsi.o
+obj-$(CONFIG_TYPEC_UCSI_ACPI) += ucsi_acpi.o
diff --git a/drivers/usb/type-c/ucsi_acpi.c b/drivers/usb/type-c/ucsi_acpi.c
new file mode 100644
index 0000000..8445a7d
--- /dev/null
+++ b/drivers/usb/type-c/ucsi_acpi.c
@@ -0,0 +1,133 @@
+/*
+ * UCSI ACPI driver
+ *
+ * Copyright (C) 2016, Intel Corporation
+ * Author: Heikki Krogerus <heikki.krogerus@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/platform_device.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/acpi.h>
+
+#include "ucsi.h"
+
+struct ucsi_acpi {
+ struct device *dev;
+ struct ucsi *ucsi;
+ struct ucsi_ppm ppm;
+};
+
+static const u8 ucsi_uuid[] = {
+ 0xc2, 0x98, 0x83, 0x6f, 0xa4, 0x7c, 0xe4, 0x11,
+ 0xad, 0x36, 0x63, 0x10, 0x42, 0xb5, 0x00, 0x8f,
+};
+
+static int ucsi_acpi_cmd(struct ucsi_ppm *ppm)
+{
+ struct ucsi_acpi *ua = container_of(ppm, struct ucsi_acpi, ppm);
+ union acpi_object *obj;
+
+ obj = acpi_evaluate_dsm(ACPI_HANDLE(ua->dev), ucsi_uuid, 1, 1, NULL);
+ if (!obj) {
+ dev_err(ua->dev, "%s: failed to evaluate _DSM\n", __func__);
+ return -EIO;
+ }
+
+ ACPI_FREE(obj);
+ return 0;
+}
+
+static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data)
+{
+ struct ucsi_acpi *ua = data;
+
+ if (!ucsi_interrupt(ua->ucsi))
+ dev_err(ua->dev, "spurious ACPI notification\n");
+}
+
+static int ucsi_acpi_probe(struct platform_device *pdev)
+{
+ struct ucsi_acpi *ua;
+ struct resource *res;
+ acpi_status status;
+ int ret;
+
+ ua = devm_kzalloc(&pdev->dev, sizeof(*ua), GFP_KERNEL);
+ if (!ua)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "missing memory resource\n");
+ return -ENODEV;
+ }
+
+ ua->ppm.data = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!ua->ppm.data)
+ return -ENOMEM;
+
+ ua->ppm.cmd = ucsi_acpi_cmd;
+ ua->dev = &pdev->dev;
+
+ ua->ucsi = ucsi_register_ppm(&pdev->dev, &ua->ppm);
+ if (IS_ERR(ua->ucsi))
+ return PTR_ERR(ua->ucsi);
+
+ status = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev),
+ ACPI_DEVICE_NOTIFY,
+ ucsi_acpi_notify, ua);
+ if (ACPI_FAILURE(status)) {
+ ret = -ENODEV;
+ goto err;
+ }
+
+ ret = ucsi_init(ua->ucsi);
+ if (ret) {
+ acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev),
+ ACPI_DEVICE_NOTIFY,
+ ucsi_acpi_notify);
+ goto err;
+ }
+
+ platform_set_drvdata(pdev, ua);
+ return 0;
+err:
+ ucsi_unregister_ppm(ua->ucsi);
+ return ret;
+}
+
+static int ucsi_acpi_remove(struct platform_device *pdev)
+{
+ struct ucsi_acpi *ua = platform_get_drvdata(pdev);
+
+ acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev),
+ ACPI_DEVICE_NOTIFY, ucsi_acpi_notify);
+ ucsi_unregister_ppm(ua->ucsi);
+ return 0;
+}
+
+static const struct acpi_device_id ucsi_acpi_match[] = {
+ { "PNP0CA0", 0 },
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, ucsi_acpi_match);
+
+static struct platform_driver ucsi_acpi_platform_driver = {
+ .driver = {
+ .name = "ucsi_acpi",
+ .acpi_match_table = ACPI_PTR(ucsi_acpi_match),
+ },
+ .probe = ucsi_acpi_probe,
+ .remove = ucsi_acpi_remove,
+};
+
+module_platform_driver(ucsi_acpi_platform_driver);
+
+MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("UCSI ACPI driver");
--
2.7.0
next prev parent reply other threads:[~2016-02-09 17:03 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-09 17:01 [PATCH 0/3] usb: USB Type-C Class and driver for UCSI Heikki Krogerus
2016-02-09 17:01 ` [PATCH 1/3] usb: USB Type-C Connector Class Heikki Krogerus
2016-02-09 18:20 ` Greg KH
2016-02-10 10:38 ` Heikki Krogerus
2016-02-10 17:26 ` Greg KH
2016-02-11 14:07 ` Heikki Krogerus
2016-02-10 10:49 ` Oliver Neukum
2016-02-10 11:05 ` Andy Shevchenko
2016-02-10 11:11 ` Heikki Krogerus
2016-02-10 11:14 ` Andy Shevchenko
2016-02-10 11:23 ` Heikki Krogerus
2016-02-15 15:16 ` Oliver Neukum
2016-02-11 8:55 ` Felipe Balbi
2016-02-11 9:08 ` Oliver Neukum
2016-02-11 14:51 ` Heikki Krogerus
2016-02-11 14:36 ` Heikki Krogerus
2016-02-11 14:56 ` Oliver Neukum
2016-02-17 14:07 ` Oliver Neukum
2016-02-18 8:47 ` Heikki Krogerus
2016-02-18 9:21 ` Oliver Neukum
2016-02-18 13:09 ` Heikki Krogerus
2016-02-18 9:35 ` Oliver Neukum
2016-02-18 13:25 ` Heikki Krogerus
2016-02-18 13:44 ` Oliver Neukum
2016-02-18 15:13 ` Heikki Krogerus
2016-02-26 13:09 ` Heikki Krogerus
2016-02-09 17:01 ` [PATCH 2/3] usb: type-c: USB Type-C Connector System Software Interface Heikki Krogerus
2016-02-09 18:21 ` Greg KH
2016-02-10 10:30 ` Heikki Krogerus
2016-02-10 17:20 ` Greg KH
2016-02-11 13:50 ` Heikki Krogerus
2016-02-15 15:30 ` Oliver Neukum
2016-02-16 9:22 ` Heikki Krogerus
2016-02-16 13:39 ` Oliver Neukum
2016-02-17 7:58 ` Heikki Krogerus
2016-02-17 9:03 ` Oliver Neukum
2016-02-17 10:29 ` Felipe Balbi
2016-02-17 10:36 ` Oliver Neukum
2016-02-17 11:11 ` Heikki Krogerus
2016-02-17 13:36 ` Felipe Balbi
2016-02-17 14:28 ` Heikki Krogerus
2016-02-18 9:07 ` Peter Chen
2016-02-18 10:44 ` Heikki Krogerus
2016-02-18 10:37 ` Rajaram R
2016-02-18 10:47 ` Heikki Krogerus
2016-02-18 11:06 ` Rajaram R
2016-02-17 13:34 ` Felipe Balbi
2016-02-17 13:51 ` Oliver Neukum
2016-02-18 7:08 ` Felipe Balbi
2016-02-18 10:18 ` Oliver Neukum
2016-02-18 10:30 ` Felipe Balbi
2016-02-18 10:40 ` Oliver Neukum
2016-02-18 9:29 ` Peter Chen
2016-02-18 9:44 ` Oliver Neukum
2016-02-10 11:19 ` Oliver Neukum
2016-02-10 12:04 ` Heikki Krogerus
2016-02-10 11:56 ` Andy Shevchenko
2016-02-10 13:21 ` Oliver Neukum
2016-02-10 14:02 ` Andy Shevchenko
2016-02-10 15:11 ` Bjørn Mork
2016-02-11 8:26 ` Andy Shevchenko
2016-02-11 8:59 ` Bjørn Mork
2016-02-10 14:15 ` Oliver Neukum
2016-02-10 14:24 ` Andy Shevchenko
2016-02-10 15:08 ` Oliver Neukum
[not found] ` <CAHp75VfmGsskf7Cmni3b4=tCbkPsR8d3jPYiv93Lm6DM9gq1-g@mail.gmail.com>
2016-02-11 8:13 ` Fwd: " Andy Shevchenko
2016-02-11 14:10 ` Heikki Krogerus
2016-02-10 13:04 ` Oliver Neukum
2016-02-11 14:08 ` Heikki Krogerus
2016-02-09 17:01 ` Heikki Krogerus [this message]
2016-02-09 18:22 ` [PATCH 3/3] usb: type-c: UCSI ACPI driver Greg KH
2016-02-10 10:23 ` Heikki Krogerus
2016-02-17 18:53 ` [PATCH 0/3] usb: USB Type-C Class and driver for UCSI Oliver Neukum
2016-02-18 9:21 ` Heikki Krogerus
2016-02-17 19:34 ` Rajaram R
2016-02-18 11:05 ` Heikki Krogerus
2016-02-18 11:15 ` Oliver Neukum
2016-05-05 3:05 ` Guenter Roeck
2016-05-06 6:50 ` Felipe Balbi
2016-05-06 8:05 ` Guenter Roeck
2016-05-06 8:29 ` Heikki Krogerus
2016-05-06 14:10 ` Guenter Roeck
2016-05-06 8:23 ` Heikki Krogerus
2016-05-06 8:08 ` Heikki Krogerus
2016-05-06 14:08 ` Guenter Roeck
2016-05-11 3:14 ` Guenter Roeck
2016-05-11 9:40 ` Heikki Krogerus
2016-05-11 14:47 ` Guenter Roeck
2016-05-13 14:23 ` Heikki Krogerus
2016-05-13 17:48 ` Guenter Roeck
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=1455037283-106479-4-git-send-email-heikki.krogerus@linux.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.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
all inboxes | Powered by JetHome®