From: Pavan Holla <pholla@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Guenter Roeck <groeck@chromium.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
chrome-platform@lists.linux.dev,
Pavan Holla <pholla@chromium.org>
Subject: [PATCH v2 1/3] usb: typec: ucsi: Provide interface for UCSI transport
Date: Mon, 25 Mar 2024 23:42:25 +0000 [thread overview]
Message-ID: <20240325-public-ucsi-h-v2-1-a6d716968bb1@chromium.org> (raw)
In-Reply-To: <20240325-public-ucsi-h-v2-0-a6d716968bb1@chromium.org>
The ucsi.h include can be used by driver implementations that
provide transport for UCSI commands.
Signed-off-by: Pavan Holla <pholla@chromium.org>
---
MAINTAINERS | 1 +
include/linux/usb/ucsi.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index aa3b947fb080..e799d67a8fa5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22987,6 +22987,7 @@ F: Documentation/ABI/testing/sysfs-class-typec
F: Documentation/driver-api/usb/typec.rst
F: drivers/usb/typec/
F: include/linux/usb/typec.h
+F: include/linux/usb/ucsi.h
USB TYPEC INTEL PMC MUX DRIVER
M: Heikki Krogerus <heikki.krogerus@linux.intel.com>
diff --git a/include/linux/usb/ucsi.h b/include/linux/usb/ucsi.h
new file mode 100644
index 000000000000..3ec1db968070
--- /dev/null
+++ b/include/linux/usb/ucsi.h
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __LINUX_USB_UCSI_H
+#define __LINUX_USB_UCSI_H
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+#include <linux/types.h>
+
+/* -------------------------------------------------------------------------- */
+
+struct ucsi;
+struct ucsi_altmode;
+
+/* UCSI offsets (Bytes) */
+#define UCSI_VERSION 0
+#define UCSI_CCI 4
+#define UCSI_CONTROL 8
+#define UCSI_MESSAGE_IN 16
+#define UCSI_MESSAGE_OUT 32
+#define UCSIv2_MESSAGE_OUT 272
+
+/* Command Status and Connector Change Indication (CCI) bits */
+#define UCSI_CCI_CONNECTOR(_c_) (((_c_) & GENMASK(7, 1)) >> 1)
+#define UCSI_CCI_LENGTH(_c_) (((_c_) & GENMASK(15, 8)) >> 8)
+#define UCSI_CCI_NOT_SUPPORTED BIT(25)
+#define UCSI_CCI_CANCEL_COMPLETE BIT(26)
+#define UCSI_CCI_RESET_COMPLETE BIT(27)
+#define UCSI_CCI_BUSY BIT(28)
+#define UCSI_CCI_ACK_COMPLETE BIT(29)
+#define UCSI_CCI_ERROR BIT(30)
+#define UCSI_CCI_COMMAND_COMPLETE BIT(31)
+
+/**
+ * struct ucsi_operations - UCSI I/O operations
+ * @read: Read operation
+ * @sync_write: Blocking write operation
+ * @async_write: Non-blocking write operation
+ * @update_altmodes: Squashes duplicate DP altmodes
+ *
+ * Read and write routines for UCSI interface. @sync_write must wait for the
+ * Command Completion Event from the PPM before returning, and @async_write must
+ * return immediately after sending the data to the PPM.
+ */
+struct ucsi_operations {
+ int (*read)(struct ucsi *ucsi, unsigned int offset,
+ void *val, size_t val_len);
+ int (*sync_write)(struct ucsi *ucsi, unsigned int offset,
+ const void *val, size_t val_len);
+ int (*async_write)(struct ucsi *ucsi, unsigned int offset,
+ const void *val, size_t val_len);
+ bool (*update_altmodes)(struct ucsi *ucsi, struct ucsi_altmode *orig,
+ struct ucsi_altmode *updated);
+};
+
+struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops);
+void ucsi_destroy(struct ucsi *ucsi);
+int ucsi_register(struct ucsi *ucsi);
+void ucsi_unregister(struct ucsi *ucsi);
+int ucsi_resume(struct ucsi *ucsi);
+void *ucsi_get_drvdata(struct ucsi *ucsi);
+void ucsi_set_drvdata(struct ucsi *ucsi, void *data);
+
+void ucsi_connector_change(struct ucsi *ucsi, u8 num);
+
+#endif /* __LINUX_USB_UCSI_H */
--
2.44.0.396.g6e790dbe36-goog
next prev parent reply other threads:[~2024-03-25 23:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 23:42 [PATCH v2 0/3] usb: typec: Implement UCSI driver for ChromeOS Pavan Holla
2024-03-25 23:42 ` Pavan Holla [this message]
2024-03-25 23:42 ` [PATCH v2 2/3] usb: typec: ucsi: Import interface for UCSI transport Pavan Holla
2024-03-27 11:22 ` Heikki Krogerus
2024-03-27 22:40 ` Pavan Holla
2024-03-25 23:42 ` [PATCH v2 3/3] platform/chrome: cros_ec_ucsi: Implement UCSI PDC driver Pavan Holla
2024-03-26 8:46 ` Krzysztof Kozlowski
2024-03-27 3:39 ` Pavan Holla
2024-03-27 4:59 ` Krzysztof Kozlowski
2024-03-28 2:32 ` Pavan Holla
2024-03-28 8:36 ` Krzysztof Kozlowski
2024-03-28 9:57 ` Tzung-Bi Shih
2024-03-28 12:16 ` Krzysztof Kozlowski
2024-03-29 1:37 ` Tzung-Bi Shih
2024-03-28 15:32 ` Dmitry Baryshkov
2024-03-29 15:08 ` Pavan Holla
2024-03-29 15:13 ` Dmitry Baryshkov
2024-04-01 20:32 ` Pavan Holla
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=20240325-public-ucsi-h-v2-1-a6d716968bb1@chromium.org \
--to=pholla@chromium.org \
--cc=abhishekpandit@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=tzungbi@kernel.org \
/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 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.