From patchwork Thu Nov 17 18:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 21873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp575676wrr; Thu, 17 Nov 2022 11:10:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7bkoXrWtatWEQ9YsPxyprCFqpM7Kn+6o08DdrT1TmFZ2cazDnr3PBO9/2CvnNCjCrkpAt0 X-Received: by 2002:a17:907:1df2:b0:7ae:8411:112c with SMTP id og50-20020a1709071df200b007ae8411112cmr3128173ejc.97.1668712251230; Thu, 17 Nov 2022 11:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668712251; cv=none; d=google.com; s=arc-20160816; b=TUG1n3Ap30mnHvNTrGhybFW7TO4HRpUiqFBc5vdE9U0RFydWqYJMOTswWqdk2CgH4D 7PNLPGspmbfM6wx1pyLxnVgTiS0CYhYerp+0DlZSw6CblNxoj8LANPybHm3UTim2rwal AyMh3xl0ly7JF3jvzVAO5UNuwJp4cL4fOm/hhmC9o+zqc6lBt7c3xY9DYVZRbLahx0DT l4epPxII9189VOx4W63rTnhofEsZOxnyLkNl27++vX0s+ivrJisU5njYsyYnRTIr6UU/ u9L7t7tAxku7/mVpIRf6o7BSp1VzpVcSjpssE0wLzqETJtPGAOo70WfqKZQs8EVKDeQF gBCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=A6/e9gcdXnO8Tyz14NJuWr6De+kAZpG+gM0rMvCVARQ=; b=w5OzbrcTGCIuhkykhO9QVej8V1xTCdJc7grf844UUEYv0N4ksfPSINtixrWvI1adVi ocKwMzA4M5M2CxzT2pqwAbKZr5APlXhczH6URejZ6dOhalueI1RBD7csWEGDpSJBHCD/ 0SPFUXUbsvt+pmb9sRseNO+P0JfcEj/Qh0rx3u8CCyUpiijcdbSkI7OrFkbKkNS6wTns fUQtXcZHrSR25ijdFXT3gnj6NlcXKBqMwosAOBF1n+QvjMZQVWBj7Byn2NyR1qR8S0Nl CWdNIdl2LSuhsSKm8UcABn0dBg1koycjWrm9XdlroZnLYIzaLIN3DNWC3qBwfKiDWviw bD1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cv0MM6MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qc8-20020a170906d8a800b007ae86742c3bsi989728ejb.1009.2022.11.17.11.10.26; Thu, 17 Nov 2022 11:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cv0MM6MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234380AbiKQStU (ORCPT + 99 others); Thu, 17 Nov 2022 13:49:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231274AbiKQStR (ORCPT ); Thu, 17 Nov 2022 13:49:17 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA5B1057A for ; Thu, 17 Nov 2022 10:49:15 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id q21so2082141iod.4 for ; Thu, 17 Nov 2022 10:49:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=A6/e9gcdXnO8Tyz14NJuWr6De+kAZpG+gM0rMvCVARQ=; b=Cv0MM6MRRPK0t0qGjWSf4VSBYJX0wJhWQjGWsyuqdK5lHzQBjtp4bo+FFN3zQJMrB1 VQuyxeNmYFylkxkIJsrWRGD/ZZcJRODtb18yEFUpFk/Xok4ekKIXdMQcqJoPZ9ldKmZN LBBcZrPWeWu7vDB3SL7bimSdocRei+t2bJpyE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A6/e9gcdXnO8Tyz14NJuWr6De+kAZpG+gM0rMvCVARQ=; b=akwbugSUHsSZS/7B1qyzMzklKgpBpZR4CUdGdvB7kJlocTNhHD1SyytCiozE8wpyva qEWJnm2cO9P+XpbBjADxnqO+62ve3kUcsFB5cYYU+Q/VxOaYHB3sz5M99C9Ib19gusrl NXfCrFHaCmGecjsLerr1p//gMhKeoiyED8GgH7vsTVrXeicYt6xIDdrge37KL+6h/k3J EK1YIi8ABwOYOLzzdiHOuP+97lKbnE21ergfLXYsYm3y8bGnD4p079qspkS4Zv+iabwc 0AmDsFHe63uZNY6LRcwKELvBXkuDWL8AM220uDguO8YpPyu0nEIcHG+0jfH+iAEXvrv6 yK+A== X-Gm-Message-State: ANoB5pnQAz/jTnlFYJIKbqYLkOwhnPmw7YHJKPZjKKekKpp6h4iBZDu5 jzG9GTAE56rkOMGQFab6TkeDzEZOR5Jy3Ipo0vI= X-Received: by 2002:a6b:7903:0:b0:6cb:4c03:6d6e with SMTP id i3-20020a6b7903000000b006cb4c036d6emr1934177iop.168.1668710954986; Thu, 17 Nov 2022 10:49:14 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.223]) by smtp.gmail.com with ESMTPSA id q6-20020a02a986000000b00363faa1ea9asm503282jam.15.2022.11.17.10.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:49:14 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , chrome-platform@lists.linux.dev Subject: [PATCH v7 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Date: Thu, 17 Nov 2022 11:48:46 -0700 Message-Id: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749771617264270206?= X-GMAIL-MSGID: =?utf-8?q?1749771617264270206?= This patch does following: 1. Adds a new cros-ec-uart driver. This driver can send EC requests on UART and process response packets received on UART transport. 2. Once probed, this driver will initialize the serdev device based on the underlying information in the ACPI resource. After serdev device properties are set, this driver will register itself cros-ec. 3. High level driver can use this implementation to talk to ChromeOS Embedded Controller device in case it supports UART as transport. 4. When cros-ec driver initiates a request packet, outgoing message is processed in buffer and sent via serdev. Once bytes are sent, driver enables a wait_queue. 5. Since ChromeOS EC device sends response asynchronously, AP's TTY driver accumulates response bytes and calls the registered callback. TTY driver can send multiple callback for bytes ranging from 1 to MAX bytes supported by EC device. 6. Driver waits for EC_MSG_DEADLINE_MS to collect and process received bytes. It wakes wait_queue if expected bytes are received or else wait_queue timeout. Based on the error condition, driver returns data_len or error to cros_ec. Signed-off-by: Bhanu Prakash Maiya Signed-off-by: Mark Hasemeyer --- Changes in v7: - Use ACPI ID matching - Change MODULE_LICENSE from GPL v2 to GPL Changes in v6: - Tuning EC_MSG_DEADLINE_MS from 1 sec to 500 msec. Since the EC's UART response buffer was tuned and redeuced to 256 byte, 500 msec timeout should give enough time for 256 bytes to be recieved from SoC UART buffer. Changes in v5: - Fixed checkpatch.pl warnings. Changes in v4: - Change EC_MSG_DEADLINE_MS from 3 secs to 1 sec. 3 secs timeout prevents driver from intercepting EC in RO stage. In case of request failure, 1 sec allows driver to retry and send HC when EC is in RO. - Add more information in commit message. Changes in v3: - checkpatch.pl script warns about char len 80 even though we have relaxed view guideline for line below 100 chars. Currently sticking with 80 chars in v3. - Fixed style issues Changes in v2: - Fixed build error on v1. - Changed EC timeout for response packet to 3 Sec and added comments. - Fixed cros_ec_uart_rx_bytes function to handle rx buffer < size of response header. --- MAINTAINERS | 6 + drivers/platform/chrome/Kconfig | 10 + drivers/platform/chrome/Makefile | 1 + drivers/platform/chrome/cros_ec_uart.c | 418 +++++++++++++++++++++++++ 4 files changed, 435 insertions(+) create mode 100644 drivers/platform/chrome/cros_ec_uart.c diff --git a/MAINTAINERS b/MAINTAINERS index 256f03904987a..123fbe77bc236 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4918,6 +4918,12 @@ S: Maintained F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml F: sound/soc/codecs/cros_ec_codec.* +CHROMEOS EC UART DRIVER +M: Bhanu Prakash Maiya +R: Enric Balletbo i Serra +S: Maintained +F: drivers/platform/chrome/cros_ec_uart.c + CHROMEOS EC SUBDRIVERS M: Benson Leung R: Guenter Roeck diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 6b954c5acadb1..d4a95ec261ed3 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -119,6 +119,16 @@ config CROS_EC_SPI response time cannot be guaranteed, we support ignoring 'pre-amble' bytes before the response actually starts. +config CROS_EC_UART + tristate "ChromeOS Embedded Controller (UART)" + depends on CROS_EC && ACPI && SERIAL_DEV_BUS + help + If you say Y here, you get support for talking to the ChromeOS EC + through a UART, using a byte-level protocol. + + To compile this driver as a module, choose M here: the + module will be called cros_ec_uart. + config CROS_EC_LPC tristate "ChromeOS Embedded Controller (LPC)" depends on CROS_EC && ACPI && (X86 || COMPILE_TEST) diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index 2950610101f15..6f5b6f01940db 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_CROS_EC_ISHTP) += cros_ec_ishtp.o obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o +obj-$(CONFIG_CROS_EC_UART) += cros_ec_uart.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c new file mode 100644 index 0000000000000..b5f72f0104985 --- /dev/null +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -0,0 +1,418 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * UART interface for ChromeOS Embedded Controller + * + * Copyright 2020 Google LLC. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cros_ec.h" + +/* + * EC sends contiguous bytes of response packet on UART AP RX. + * TTY driver in AP accumulates incoming bytes and calls the registered callback + * function. Byte count can range from 1 to MAX bytes supported by EC. + * This driver should wait for long time for all callbacks to be processed. + * Considering the worst case scenario, wait for 500 msec. This timeout should + * account for max latency and some additional guard time. + * Best case: Entire packet is received in ~200 ms, wait queue will be released + * and packet will be processed. + * Worst case: TTY driver sends bytes in multiple callbacks. In this case this + * driver will wait for ~1 sec beyond which it will timeout. + * This timeout value should not exceed ~500 msec because in case if + * EC_CMD_REBOOT_EC sent, high level driver should be able to intercept EC + * in RO. + */ +#define EC_MSG_DEADLINE_MS 500 + +/** + * struct response_info - Encapsulate EC response related + * information for passing between function + * cros_ec_uart_pkt_xfer() and cros_ec_uart_rx_bytes() + * callback. + * @data: Copy the data received from EC here. + * @max_size: Max size allocated for the @data buffer. If the + * received data exceeds this value, we log an error. + * @size: Actual size of data received from EC. This is also + * used to accumulate byte count with response is received + * in dma chunks. + * @exp_len: Expected bytes of response from EC including header. + * @error: 0 for success, negative error code for a failure. + * @received: Set to true on receiving a valid EC response. + * @wait_queue: Wait queue EC response where the cros_ec sends request + * to EC and waits + */ +struct response_info { + void *data; + size_t max_size; + size_t size; + int error; + size_t exp_len; + bool received; + wait_queue_head_t wait_queue; +}; + +/** + * struct cros_ec_uart - information about a uart-connected EC + * + * @serdev_device: serdev uart device we are connected to. + * @baudrate: UART baudrate of attached EC device. + * @flowcontrol: UART flowcontrol of attached device. + * @irq: Linux IRQ number of associated serial device. + * @response: Response info passing between cros_ec_uart_pkt_xfer() + * and cros_ec_uart_rx_bytes() + */ +struct cros_ec_uart { + struct serdev_device *serdev; + u32 baudrate; + u8 flowcontrol; + u32 irq; + struct response_info response; +}; + +static int cros_ec_uart_rx_bytes(struct serdev_device *serdev, + const u8 *data, + size_t count) +{ + struct ec_host_response *response; + struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev); + struct cros_ec_uart *ec_uart = ec_dev->priv; + + /* Check if bytes were sent out of band */ + if (!ec_uart->response.data) + /* Discard all bytes */ + return count; + + /* + * Check if incoming bytes + response.size are less than allocated + * buffer in din by cros_ec. This will ensure that if EC sends more + * bytes than max_size, waiting process will be notified with an error. + */ + if (ec_uart->response.size + count <= ec_uart->response.max_size) { + /* Copy bytes in data in buffer */ + memcpy((void *)ec_uart->response.data + ec_uart->response.size, + (void *)data, count); + + /* Add incoming bytes in size */ + ec_uart->response.size += count; + + /* + * Read data_len if we received response header and if exp_len + * was not read before. + */ + if (ec_uart->response.size >= sizeof(*response) && + ec_uart->response.exp_len == 0) { + /* Get expected response length from response header */ + response = (struct ec_host_response *) + ec_uart->response.data; + + ec_uart->response.exp_len = response->data_len + + sizeof(*response); + } + + /* + * If driver received response header and payload from EC, + * Wake up the wait queue. + */ + if (ec_uart->response.size >= sizeof(*response) && + ec_uart->response.size == ec_uart->response.exp_len) { + /* Set flag before waking up the caller */ + ec_uart->response.received = true; + + /* Wake the calling thread */ + wake_up_interruptible(&ec_uart->response.wait_queue); + } + } else { + /* Received bytes are more the allocated buffer*/ + ec_uart->response.error = -EMSGSIZE; + + /* Wake the calling thread */ + wake_up_interruptible(&ec_uart->response.wait_queue); + } + + return count; +} + +static int cros_ec_uart_pkt_xfer(struct cros_ec_device *ec_dev, + struct cros_ec_command *ec_msg) +{ + struct cros_ec_uart *ec_uart = ec_dev->priv; + struct serdev_device *serdev = ec_uart->serdev; + struct ec_host_response *response; + unsigned int len; + int ret, i; + u8 sum = 0; + + /* Prepare an outgoing message in the output buffer */ + len = cros_ec_prepare_tx(ec_dev, ec_msg); + dev_dbg(ec_dev->dev, "Prepared len=%d\n", len); + + /* Setup for incoming response */ + ec_uart->response.data = ec_dev->din; + ec_uart->response.max_size = ec_dev->din_size; + ec_uart->response.size = 0; + ec_uart->response.error = 0; + ec_uart->response.exp_len = 0; + ec_uart->response.received = false; + + /* Write serial device buffer */ + ret = serdev_device_write_buf(serdev, ec_dev->dout, len); + if (ret < len) { + dev_err(&serdev->dev, + "Unable to write data to serial device %s", + dev_name(&serdev->dev)); + + /* Return EIO as controller had issues writing buffer */ + ret = -EIO; + goto exit; + } + + /* Once request is successfully sent to EC, wait to wait_queue */ + wait_event_interruptible_timeout(ec_uart->response.wait_queue, + ec_uart->response.received, + msecs_to_jiffies(EC_MSG_DEADLINE_MS)); + + /* Check if wait_queue was interrupted due to an error */ + if (ec_uart->response.error < 0) { + dev_warn(&serdev->dev, "Response error detected.\n"); + + ret = ec_uart->response.error; + goto exit; + } + + /* Check if valid response was received or there was a timeout */ + if (!ec_uart->response.received) { + dev_warn(&serdev->dev, "EC failed to respond in time.\n"); + + ret = -ETIMEDOUT; + goto exit; + } + + /* Check response error code */ + response = (struct ec_host_response *)ec_dev->din; + ec_msg->result = response->result; + + /* Check if received response is longer than expected */ + if (response->data_len > ec_msg->insize) { + dev_err(ec_dev->dev, "Resp too long (%d bytes, expected %d)", + response->data_len, + ec_msg->insize); + ret = -ENOSPC; + goto exit; + } + + /* Copy response packet to ec_msg data buffer */ + memcpy(ec_msg->data, + ec_dev->din + sizeof(*response), + response->data_len); + + /* Add all response header bytes for checksum calculation */ + for (i = 0; i < sizeof(*response); i++) + sum += ec_dev->din[i]; + + /* Copy response packet payload and compute checksum */ + for (i = 0; i < response->data_len; i++) + sum += ec_msg->data[i]; + + if (sum) { + dev_err(ec_dev->dev, + "Bad packet checksum calculated %x\n", + sum); + ret = -EBADMSG; + goto exit; + } + + /* Return data_len to cros_ec */ + ret = response->data_len; + +exit: + /* Reset ec_uart */ + ec_uart->response.data = NULL; + ec_uart->response.max_size = 0; + ec_uart->response.size = 0; + ec_uart->response.error = 0; + ec_uart->response.exp_len = 0; + ec_uart->response.received = false; + + if (ec_msg->command == EC_CMD_REBOOT_EC) + msleep(EC_REBOOT_DELAY_MS); + + return ret; +} + +static int cros_ec_uart_resource(struct acpi_resource *ares, void *data) +{ + struct cros_ec_uart *ec_uart = data; + struct acpi_resource_uart_serialbus *sb; + + switch (ares->type) { + case ACPI_RESOURCE_TYPE_SERIAL_BUS: + sb = &ares->data.uart_serial_bus; + if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_UART) { + ec_uart->baudrate = sb->default_baud_rate; + dev_dbg(&ec_uart->serdev->dev, "Baudrate %d\n", + ec_uart->baudrate); + + ec_uart->flowcontrol = sb->flow_control; + dev_dbg(&ec_uart->serdev->dev, "Flow control %d\n", + ec_uart->flowcontrol); + } + break; + default: + break; + } + + return 0; +} + +static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) +{ + LIST_HEAD(resources); + struct acpi_device *adev = ACPI_COMPANION(&ec_uart->serdev->dev); + int ret; + + /* Retrieve UART ACPI info */ + ret = acpi_dev_get_resources(adev, &resources, + cros_ec_uart_resource, ec_uart); + if (ret < 0) + return ret; + + acpi_dev_free_resource_list(&resources); + + /* Retrieve GpioInt and translate it to Linux IRQ number */ + ret = acpi_dev_gpio_irq_get(adev, 0); + if (ret < 0) + return ret; + + ec_uart->irq = ret; + dev_dbg(&ec_uart->serdev->dev, "IRQ number %d\n", ec_uart->irq); + + return 0; +} + +static const struct serdev_device_ops cros_ec_uart_client_ops = { + .receive_buf = cros_ec_uart_rx_bytes, +}; + +static int cros_ec_uart_probe(struct serdev_device *serdev) +{ + struct device *dev = &serdev->dev; + struct cros_ec_device *ec_dev; + struct cros_ec_uart *ec_uart; + int ret; + + ec_uart = devm_kzalloc(dev, sizeof(*ec_uart), GFP_KERNEL); + if (!ec_uart) + return -ENOMEM; + + ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); + if (!ec_dev) + return -ENOMEM; + + ec_uart->serdev = serdev; + + /* Open the serial device */ + ret = devm_serdev_device_open(dev, ec_uart->serdev); + if (ret) { + dev_err(dev, "Unable to open UART device %s", + dev_name(&serdev->dev)); + return ret; + } + + serdev_device_set_drvdata(serdev, ec_dev); + + serdev_device_set_client_ops(serdev, &cros_ec_uart_client_ops); + + /* Initialize wait queue */ + init_waitqueue_head(&ec_uart->response.wait_queue); + + ret = cros_ec_uart_acpi_probe(ec_uart); + if (ret < 0) { + dev_err(dev, "Failed to get ACPI info (%d)", ret); + return ret; + } + + /* Set baud rate of serial device */ + ret = serdev_device_set_baudrate(serdev, ec_uart->baudrate); + if (ret < 0) { + dev_err(dev, "Failed to set up host baud rate (%d)", ret); + return ret; + } + + /* Set flow control of serial device */ + serdev_device_set_flow_control(serdev, ec_uart->flowcontrol); + + /* Initialize ec_dev for cros_ec */ + ec_dev->phys_name = dev_name(&ec_uart->serdev->dev); + ec_dev->dev = dev; + ec_dev->priv = ec_uart; + ec_dev->irq = ec_uart->irq; + ec_dev->cmd_xfer = NULL; + ec_dev->pkt_xfer = cros_ec_uart_pkt_xfer; + ec_dev->din_size = sizeof(struct ec_host_response) + + sizeof(struct ec_response_get_protocol_info); + ec_dev->dout_size = sizeof(struct ec_host_request); + + /* Register a new cros_ec device */ + return cros_ec_register(ec_dev); +} + +static void cros_ec_uart_remove(struct serdev_device *serdev) +{ + struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev); + + cros_ec_unregister(ec_dev); +}; + +static int __maybe_unused cros_ec_uart_suspend(struct device *dev) +{ + struct cros_ec_device *ec_dev = dev_get_drvdata(dev); + + return cros_ec_suspend(ec_dev); +} + +static int __maybe_unused cros_ec_uart_resume(struct device *dev) +{ + struct cros_ec_device *ec_dev = dev_get_drvdata(dev); + + return cros_ec_resume(ec_dev); +} + +static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, + cros_ec_uart_resume); + +#ifdef CONFIG_ACPI +static const struct acpi_device_id cros_ec_uart_acpi_id[] = { + { "GOOG0019", 0 }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(acpi, cros_ec_uart_acpi_id); +#endif + +static struct serdev_device_driver cros_ec_uart_driver = { + .driver = { + .name = "cros-ec-uart", + .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), + .pm = &cros_ec_uart_pm_ops, + }, + .probe = cros_ec_uart_probe, + .remove = cros_ec_uart_remove, +}; + +module_serdev_device_driver(cros_ec_uart_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("UART interface for ChromeOS Embedded Controller"); +MODULE_AUTHOR("Bhanu Prakash Maiya "); From patchwork Thu Nov 17 18:48:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 21875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp575784wrr; Thu, 17 Nov 2022 11:11:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vhQhHSedow30hBBKGMeZoO2uVbY1ObJ+IVOirZMXCJ4o/fz2v83SjAx3K9l5HR0p46M+2 X-Received: by 2002:a17:906:7b93:b0:7ae:c9ae:938d with SMTP id s19-20020a1709067b9300b007aec9ae938dmr3252951ejo.313.1668712264103; Thu, 17 Nov 2022 11:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668712264; cv=none; d=google.com; s=arc-20160816; b=X4V20XrecJgJwreVPVMZlMo8f0BqPR/IYL0CRypFOIPVZ5g++pBUZa0QF6jGlkhmrG SG2n13tsNjA6rSMvLZRQElEfUVSqbVYrU0ATnc7NX/10aFRmgPZISNYL8y3JD3ZY+Ouo B6jmkYdfMz1xG1gbkbToCMPtjEcLy9VWDZBQQZxRNoD3nNgem3YfNz+MSehDtzLb/Fcs iNjuuRBqADqu4q7+zp4l7/D01g2O4Z3YAj6N7mRADkCimpXvISDU9vhd55cne82gWWoW Vx82dxP0ZdxNE8wqBQvpbr6Tnqdb6bvIDotCr2FyzSoG+vLyKD8htFUSXJ1EAKjTeByV bsTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q1Iy41MhZ3FqRDS+o4OCXIP3MAQhIgzbJl+JqnbSgTg=; b=eyt3JWczFai13dj7imwaTgUmV1LyQZrwI1J31tnFhFf81jkN3caJl5VSWy3obOW/Wt /F6p0+4Puv8HFDYIRx161YmqDNXWYFvuNoDG4/AbAf6zwACuTi+PIr1aJ2Vkh4sJHY43 RQxUzxfzDPjCgd+lTgBltjNfHX4RXLr+sBzhOzPcvTjH4dEwM+fGCxqzUqOh4fyqZBPP /skK2zlryYIrQcd6PXDtRA3G2JTKOBuoWCzdSrAMBLDBnYHg+AaFx3iHnzC7tSFi26kQ +rDIPVglMzEZYN/GQ8ocEDoVq25LgLWXLiS2tK6Glv5LRzuuPLxqK6IGtgJKRExf21cW zmFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NVAIjCoI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xd9-20020a170907078900b007addbdb9fbbsi1297238ejb.558.2022.11.17.11.10.38; Thu, 17 Nov 2022 11:11:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NVAIjCoI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239207AbiKQStX (ORCPT + 99 others); Thu, 17 Nov 2022 13:49:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234725AbiKQStV (ORCPT ); Thu, 17 Nov 2022 13:49:21 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A8B55917F for ; Thu, 17 Nov 2022 10:49:20 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id z3so2083964iof.3 for ; Thu, 17 Nov 2022 10:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q1Iy41MhZ3FqRDS+o4OCXIP3MAQhIgzbJl+JqnbSgTg=; b=NVAIjCoIr/gY3oZpSuV7SLL0QFcamToBZNGZFjyj8wdTwSUsNp+svdXfX1TbEXO3Ts ASj0kombCmsJtGIVLisb2N0pdbwKTtR7hHEwxwvccLERx+spTa+N+Q4ueHn2fuHahW1r NPkl04UJXnGnewPI5Py9iJ950jaEhDxY9Nafo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q1Iy41MhZ3FqRDS+o4OCXIP3MAQhIgzbJl+JqnbSgTg=; b=UtgROMirzytGNZ6C6Kybu3Yg1fn+xRiJDvIXoPlh3uRjMJdxAjQ9YIZMdVWE+FLyiy /35MPMaePn8ChSqi/Atgt0lxPKR211AxxNFtmAEDSwld/M0j2JA7FL/czajRpueQYQ/y 7ii5XxxCkZ0sqTP+EdGQCWQSVQb1+ZkEDfil3Bw+6Hkg+yBvXhtInVl0mfcArQrNdU/w 66dJwaeLvOB47VvDi4Y9Ik/QmlbRGuS6HnBKpeBempAGJrZVn7hrSP5iew0r2Dq26ith yUMsPxN3OE8kUUSNsQTuoYHGjlYFSIU8uWIs4WP+KvOzKeUjtTMcd0NaYJfFn/hSgcZb yJYQ== X-Gm-Message-State: ANoB5pmQvUTSgYgbAjUed9ORVguw/jc5mJwRJ456PiwwRacQXnB+z48d hEz3BF0uUUfoUOXjonVmeNIsMwND7zA7Bs6PaVc= X-Received: by 2002:a02:7409:0:b0:375:4727:8625 with SMTP id o9-20020a027409000000b0037547278625mr1629567jac.300.1668710959492; Thu, 17 Nov 2022 10:49:19 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.223]) by smtp.gmail.com with ESMTPSA id q6-20020a02a986000000b00363faa1ea9asm503282jam.15.2022.11.17.10.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:49:19 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Benson Leung , Guenter Roeck , Krzysztof Kozlowski , Lee Jones , Rob Herring , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH v7 2/3] dt-bindings: mfd: Add DT compatible string "google,cros_ec_uart" Date: Thu, 17 Nov 2022 11:48:47 -0700 Message-Id: <20221117114818.v7.2.I9e018ecb8bdf341648cb64417085978ff0d22a46@changeid> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749771630876717422?= X-GMAIL-MSGID: =?utf-8?q?1749771630876717422?= Add DT compatible string in Documentation/devicetree/bindings/mfd/cros_ec.txt Signed-off-by: Bhanu Prakash Maiya Signed-off-by: Mark Hasemeyer Acked-by: Krzysztof Kozlowski --- Changes in v7: - No change Changes in v6: - No change Changes in v5: - No change Changes in v4: - Changes in commit message. Changes in v3: - Rebased changes on google,cros-ec.yaml Changes in v2: - No change --- .../devicetree/bindings/mfd/google,cros-ec.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml index 04962bb29576e..26787e4574b8d 100644 --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml @@ -28,6 +28,9 @@ properties: - description: For implementations of the EC is connected through RPMSG. const: google,cros-ec-rpmsg + - description: + For implementations of the EC is connected through UART. + const: google,cros-ec-uart controller-data: description: @@ -222,4 +225,12 @@ examples: compatible = "google,cros-ec-rpmsg"; }; }; + + # Example for UART + - | + uart0 { + cros-ec { + compatible = "google,cros-ec-uart"; + }; + }; ... From patchwork Thu Nov 17 18:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 21874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp575775wrr; Thu, 17 Nov 2022 11:11:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UosnRHjHiCYLacWFcI/Zfzn5nDswrEVKDRPiFAZlJquIRF05Pe3KDReCAaA+pmUZA64GJ X-Received: by 2002:a17:907:766c:b0:7af:6ab:1d8d with SMTP id kk12-20020a170907766c00b007af06ab1d8dmr3203536ejc.211.1668712261968; Thu, 17 Nov 2022 11:11:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668712261; cv=none; d=google.com; s=arc-20160816; b=MruFE7IPHL8G1uWyAyg3yJ15MOccsE7hDchhIkttYp8mHUeqZUgNyA3GDwxJNSv6B/ nLg7ujG6TI8IwqY4u/kW0Q09zFh0fYnJbMabYqKuBbG7JX974bNyQZUd3o/cn7cNMJdH CmLNopbzumQeOl8nOz2QSaHFlNHcyI5VDdjUS58eGBQkjhgvcnnFzkUg4h8aLJxc6ANp GzrO2WJJIpDFHndzVmCX9g42aoGsRwz3lj5bFnhUtfJ5VmSEgMCbewx9GqJuZynjhN1O z5M5YOOGzfoXt7moUwrxnCaTK1kXSsw2SETFU70Fhi+cm/0Df9CdpR0BF3GXxWQ4fK5w TI9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vwzrdAjSSAlR7tomqz0SMFI6hrURlEbNjDi6TcOBnt0=; b=yD17JwoGuXiWkPBTTeDK2634A2nVT9jow1ZSlgKlac8i2EKxgLUEkiQ7FRjVuDp/0R jk3GDAvKlKlyZC+ceJTVC6nMvcjM4V+Sllv7jVMwsuMm5t1UDjP5nDqdXyh+xBNdmVap 98sz7c9vln4a4/HMPrwwEQEyUrBifgZsbJg5OXJ48ag9PKjENr0EtF3RVHggXBr43bol WWisUPysf1XZ2Xw8CMHo1xL898wr7el+Kqd61G2Wk9CLZV5+m83Ar1op20TbDez1BWwQ EVUcdUHusizVycttq1hXbq6vTlVz0ExrJiDBGYiFY2vwfr0vo93NN3IayQTBsgCsh0QN rpRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E44uNGH0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b0078de4629958si961364ejc.248.2022.11.17.11.10.37; Thu, 17 Nov 2022 11:11:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E44uNGH0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240638AbiKQStg (ORCPT + 99 others); Thu, 17 Nov 2022 13:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239783AbiKQSt0 (ORCPT ); Thu, 17 Nov 2022 13:49:26 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725525917F for ; Thu, 17 Nov 2022 10:49:23 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id z3so2084088iof.3 for ; Thu, 17 Nov 2022 10:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vwzrdAjSSAlR7tomqz0SMFI6hrURlEbNjDi6TcOBnt0=; b=E44uNGH0u4GiDI9/R8ntoTWwFpkCtXbQQISOpey6uGAk8d9oQyqEokIve+OP7X6gVR vBmMGMWfG2WltzzHPFvFHfREQNQwg7TMLrWzUDVYt2IXsK6xdSGVW8g67dbp11FwLfUj fTbO/ELwd/VaXdxMYgeS87+EWIbSshQFaJ334= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwzrdAjSSAlR7tomqz0SMFI6hrURlEbNjDi6TcOBnt0=; b=H6B/CPpVTIQ+uvAU6aPQWBdZfIT3cKeC5P7dwmo5j7pG0/SE3faLoDnHJbZaCL/wAu ao+SPfAtLOZNVheSbEFM2h73aQkXnXWNKLl6GQOLI5E4++N8m0D6hdI03GcxKU+Iekqr oITZu83Fs+lT2nev1FNisSZgHm/DFMpJiQPrwPeiVaMcN0F74CIP0+hYRJSNhfWhGB6s 9GMIcv55gNrYjBGRJrf0nwiSrzkkkQ41CZO3E2qMmPiazCYztb1bYmNLNwV6KLa72BKr uMHkVpDoXyeHNA3cY6llFhgaCCLlFjHxoxYwOH6aidW0W6IOGEi3HVtsvr84/tiz+2Eu W90g== X-Gm-Message-State: ANoB5pkIxHApAGVYQEOi3bEk0sxjlKrFJMTZjx5/fa9QVbzPHV7pXZ8k y8ug6tdnERoMghk4/eu86HeuFCbFNLCaNUmBtnk= X-Received: by 2002:a02:5dc1:0:b0:375:eb33:f73e with SMTP id w184-20020a025dc1000000b00375eb33f73emr1609076jaa.171.1668710963450; Thu, 17 Nov 2022 10:49:23 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.223]) by smtp.gmail.com with ESMTPSA id q6-20020a02a986000000b00363faa1ea9asm503282jam.15.2022.11.17.10.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:49:23 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , chrome-platform@lists.linux.dev Subject: [PATCH v7 3/3] platform/chrome: cros_ec_uart: Add DT enumeration support Date: Thu, 17 Nov 2022 11:48:48 -0700 Message-Id: <20221117114818.v7.3.Ie23c217d69ff25d7354db942613f143bbc8ef891@changeid> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749771628468915250?= X-GMAIL-MSGID: =?utf-8?q?1749771628468915250?= Existing firmware uses the "PRP0001" _HID and an associated compatible string to enumerate the cros_ec_uart. Add DT enumeration support for already shipped firmware. Signed-off-by: Bhanu Prakash Maiya Signed-off-by: Mark Hasemeyer --- Changes in v7: - Move PRP0001 enumeration support to its own commit drivers/platform/chrome/cros_ec_uart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c index b5f72f0104985..d44efb78bc881 100644 --- a/drivers/platform/chrome/cros_ec_uart.c +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, cros_ec_uart_resume); +static const struct of_device_id cros_ec_uart_of_match[] = { + { .compatible = "google,cros-ec-uart" }, + {} +}; +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); + #ifdef CONFIG_ACPI static const struct acpi_device_id cros_ec_uart_acpi_id[] = { { "GOOG0019", 0 }, @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { .driver = { .name = "cros-ec-uart", .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), + .of_match_table = cros_ec_uart_of_match, .pm = &cros_ec_uart_pm_ops, }, .probe = cros_ec_uart_probe,