Chrome platform driver development
 help / color / mirror / Atom feed
From: Won Chung <wonchung@google.com>
To: wonchung@google.com, Benson Leung <bleung@chromium.org>,
	linux-kernel@vger.kernel.org,  chrome-platform@lists.linux.dev
Subject: [PATCH] platform/chrome: Create new USB driver for RGB keyboard in ChromeOS devices
Date: Wed, 30 Nov 2022 23:19:36 +0000	[thread overview]
Message-ID: <20221130231936.1666390-1-wonchung@google.com> (raw)

Without any driver bound to RGB keyboard, it may not be suspended
properly, preventing USB xHCI to be suspended and causing power drain.
Create new USB driver for RGB keyboard so that it can be suspended
properly.

Signed-off-by: Won Chung <wonchung@google.com>
---
 drivers/platform/chrome/Kconfig             |  8 ++++
 drivers/platform/chrome/Makefile            |  1 +
 drivers/platform/chrome/cros_rgb_keyboard.c | 44 +++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/platform/chrome/cros_rgb_keyboard.c

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index c45fb376d653..a7c36df99432 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -265,6 +265,14 @@ config CHROMEOS_PRIVACY_SCREEN
 	  this should probably always be built into the kernel to avoid or
 	  minimize drm probe deferral.
 
+config CROS_RGB_KEYBOARD
+	tristate "ChromeOS RGB keyboard"
+	depends on USB
+	help
+	  This driver supports RGB keyboard in some ChromeOS devices. This shall be
+	  enabled if RGB keyboard is present, otherwise it may not be suspended
+	  properly.
+
 source "drivers/platform/chrome/wilco_ec/Kconfig"
 
 # Kunit test cases
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index f7e74a845afc..e4ffa17c57fc 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_CROS_EC_SENSORHUB)		+= cros-ec-sensorhub.o
 obj-$(CONFIG_CROS_EC_SYSFS)		+= cros_ec_sysfs.o
 obj-$(CONFIG_CROS_USBPD_LOGGER)		+= cros_usbpd_logger.o
 obj-$(CONFIG_CROS_USBPD_NOTIFY)		+= cros_usbpd_notify.o
+obj-$(CONFIG_CROS_RGB_KEYBOARD)		+= cros_rgb_keyboard.o
 
 obj-$(CONFIG_WILCO_EC)			+= wilco_ec/
 
diff --git a/drivers/platform/chrome/cros_rgb_keyboard.c b/drivers/platform/chrome/cros_rgb_keyboard.c
new file mode 100644
index 000000000000..1d53fc832d76
--- /dev/null
+++ b/drivers/platform/chrome/cros_rgb_keyboard.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0
+// RGB keyboard driver for ChromeOS
+//
+// Copyright (C) 2022 Google, Inc.
+
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#define DRV_NAME "cros-rgb-keyboard"
+
+/* vendor ID */
+#define ID_GOOGLE 0x18d1
+/* product ID */
+#define ID_PRISM 0x5022
+
+static const struct usb_device_id cros_rgb_keyboard_table[] = {
+	{USB_DEVICE(ID_GOOGLE, ID_PRISM)},
+	{} // terminating null entry
+};
+
+static int cros_rgb_keyboard_probe(struct usb_interface *interface, const struct usb_device_id *id)
+{
+	struct usb_device *udev = interface_to_usbdev(interface);
+
+	usb_enable_autosuspend(udev);
+	return 0;
+}
+
+static void cros_rgb_keyboard_disconnect(struct usb_interface *interface)
+{
+}
+
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver cros_rgb_keyboard_driver = {
+	.name = DRV_NAME,
+	.id_table = cros_rgb_keyboard_table,
+	.probe = cros_rgb_keyboard_probe,
+	.disconnect = cros_rgb_keyboard_disconnect,
+};
+
+module_usb_driver(cros_rgb_keyboard_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("ChromeOS RGB keyboard driver");
-- 
2.39.0.rc0.267.gcb52ba06e7-goog


             reply	other threads:[~2022-11-30 23:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 23:19 Won Chung [this message]
2022-12-01 20:10 ` [PATCH] platform/chrome: Create new USB driver for RGB keyboard in ChromeOS devices Prashant Malani
2022-12-01 21:00   ` Benson Leung
2022-12-01 21:36     ` Prashant Malani
2022-12-01 22:52       ` Won Chung
2022-12-02  0:29         ` Prashant Malani

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=20221130231936.1666390-1-wonchung@google.com \
    --to=wonchung@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox