From patchwork Wed Nov 30 20:12:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 27997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1133617wrr; Wed, 30 Nov 2022 12:25:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7yYypwmNuO/SZva2zuFtOBKA7qrEb6n7f8QK/9bsQeFm5Uv+FxKIAJLt97ZK0dMH5cYvEC X-Received: by 2002:a17:902:6a86:b0:188:cfc6:31fb with SMTP id n6-20020a1709026a8600b00188cfc631fbmr56057744plk.150.1669839914332; Wed, 30 Nov 2022 12:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669839914; cv=none; d=google.com; s=arc-20160816; b=abDtIrVSEmy65GqnrXiTPAgIPABfJUgZW2pL8OvBumnxrjwHQskTL1Nu3l7wMXvHhD jbCo0RxArcDqmYqIpMMqEi+5TkFcw7+4/lxtAUfItdchz3oadjmZ6duAYDotV7fYsniK UELB0MmWXoz4njTwG0XHGjIrfVwgxrrIyGJZOfUzrLTcfXVJRcbUzMHZ/XGc/EM5eZi+ hdasGY5fTZcyl7W9lMRTLb5mrKIlYgSOb522t++upFe4d59FR+qD3YgZHUsjLx3qFNP9 LwF0wL/2ghHHeKDm73JQk2g/7O/Q+kARSXEJvAEVzN+u92RFR7UapZ2xN2ZMp5knoh0u cCYA== 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=TJKObbSleGyxZKUvK8A5PqJ/1VVuKYxpDBXBo9A1n1s=; b=gwogqOxHF+cT6GA3WTjDOdvT+bu5hM6Zvz8LaVuubqop0YG94AR4yDefsQv9Kkh93p d2/hwgD5Hl9gAQsp6cbDeLbnzEV1jP9ZiYps35c1TT5XVlEpRyfdj7i9CifUdnWAdw9J YQh17Yv3NnzayAkIvcE/QiPCgU+oY03j6D4coNxrTMajxg68SaXSZVvzKC414OO0UqJ3 FoQmIvwUsjHfFV9Qk0B6wiN7E8iuRUPxzC/X3uF50QRh2LExEp0yLyep9LaTQjB5XzCX Lo5tnWnW2SaiwERVDgA/Da3YMJSQFkpLHpxoUniPxXH4irR08f4Ma3YMHUSNfolVbPdh rE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AeYeOW9a; 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 k8-20020a056a00134800b00574eff59ecesi2511066pfu.196.2022.11.30.12.25.01; Wed, 30 Nov 2022 12:25:14 -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=AeYeOW9a; 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 S229952AbiK3USV (ORCPT + 99 others); Wed, 30 Nov 2022 15:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiK3UR0 (ORCPT ); Wed, 30 Nov 2022 15:17:26 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2738F8E59C for ; Wed, 30 Nov 2022 12:13:34 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id q21so13086441iod.4 for ; Wed, 30 Nov 2022 12:13:34 -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=TJKObbSleGyxZKUvK8A5PqJ/1VVuKYxpDBXBo9A1n1s=; b=AeYeOW9a8C4qvU9JANp24Uy2NJXNpHxhM/uqRrf96srO6p0Zu2tvqMCnqjn6U+Hsuo jZ5JV7nE8uBQMjxzrCVEQtgAUZW4S705VbAhWCmM0rp20tZrqh3VWVK3gu0gQypiWBCy ncJUYJOThmzTKPrkHYGtZ4TzlMVaQ9iNGHUu8= 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=TJKObbSleGyxZKUvK8A5PqJ/1VVuKYxpDBXBo9A1n1s=; b=8NJfdVDxa51b+iYp8WNqGTGYqYGqD2UM4t7iAE9DvxATcMjficp94A2fmKdicCzT4s hSmx5J54nuXbgCpmWFZFVOpi3IXk5gBgzAvd/DI9o67IkY2yZUj9h94Axv+VGBEZOKQ+ LXo7L/QA2h6S8T17QeGf0+d415WWyZDbZNYVdI4UQ1fkHb//+QGerrk/1+QgEEfboQnh Qk3xzo9ufnl/xDooOX1oPu7lW97TCM4yWt+heU+CIhec4QLc7VzF3NCEzIDH2dlVuCMi yyd1gGXU2On6FTNzfPm0su6fA/LC3DCSlbY/MZiZBj0ZCGHYMewmlmdKPkq1BROBPFci HSsg== X-Gm-Message-State: ANoB5pnI3oo8YJNDTSOQ+tpSVWv2ljxnLF1Y+4QgWf4eUiiW8gIaLi4e zIR4vyFBwgJpgYDuOS5GGdMl/qEkDwoz9g== X-Received: by 2002:a02:ad12:0:b0:389:787a:ead5 with SMTP id s18-20020a02ad12000000b00389787aead5mr14910394jan.83.1669839212824; Wed, 30 Nov 2022 12:13:32 -0800 (PST) Received: from markhas1.lan (184-96-172-159.hlrn.qwest.net. [184.96.172.159]) by smtp.gmail.com with ESMTPSA id r2-20020a02b102000000b00363e61908bfsm902158jah.10.2022.11.30.12.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 12:13:32 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Benson Leung , Guenter Roeck , Tzung-Bi Shih , chrome-platform@lists.linux.dev Subject: [PATCH v8 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Date: Wed, 30 Nov 2022 13:12:54 -0700 Message-Id: <20221130131245.v8.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?1750954057733938501?= X-GMAIL-MSGID: =?utf-8?q?1750954057733938501?= 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 v8: - Combine for loops used for xsum calculation - Use ec_dev->dev instead of serdev->dev - Sort includes - Swap struct var order to match doc order - fix whitespace - Update contact information in MAINTAINERS - Update copyright date 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 | 7 + drivers/platform/chrome/Kconfig | 10 + drivers/platform/chrome/Makefile | 1 + drivers/platform/chrome/cros_ec_uart.c | 411 +++++++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 drivers/platform/chrome/cros_ec_uart.c diff --git a/MAINTAINERS b/MAINTAINERS index 2585e7edc3358..8ed08316fd11e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4918,6 +4918,13 @@ 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: Benson Leung +R: Tzung-Bi Shih +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..ef9ac7ace04b6 --- /dev/null +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -0,0 +1,411 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * UART interface for ChromeOS Embedded Controller + * + * Copyright 2020-2022 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; + size_t exp_len; + int error; + 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(ec_dev->dev, "Unable to write data"); + + /* 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(ec_dev->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(ec_dev->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; + } + + /* Validate checksum */ + for (i = 0; i < sizeof(*response) + response->data_len; i++) + sum += ec_dev->din[i]; + + if (sum) { + dev_err(ec_dev->dev, + "Bad packet checksum calculated %x\n", + sum); + ret = -EBADMSG; + goto exit; + } + + /* Copy response packet to ec_msg data buffer */ + memcpy(ec_msg->data, + ec_dev->din + sizeof(*response), + response->data_len); + + /* 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"); + 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(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 Wed Nov 30 20:12:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 27998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1133684wrr; Wed, 30 Nov 2022 12:25:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pKGB4/nMG3k5iB6MLOH1lrzYGVvmbsEXi5Mk87yWB3JkyIYsWsnjxYaROACWYe0HGnl9a X-Received: by 2002:a63:e20:0:b0:440:6e64:fb02 with SMTP id d32-20020a630e20000000b004406e64fb02mr37296080pgl.84.1669839923160; Wed, 30 Nov 2022 12:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669839923; cv=none; d=google.com; s=arc-20160816; b=cHPGO6U1Kb4D3uecccsY1nRSVjKU+Sc9UV3oyJvdSO5ITkDlFDprVoV4yT4V2ga3FZ 8c2iZOUn92IL+BWHrf/LTcZhGbauTgDSLnZUUkPepgb7k/rOGgpJsGDLN7VtWTJUySsl kjhgXUIg/KCIOFBjb8EsMOzvMrYyN91S/o671B39AGTtVJ0UuapgvJaM4/D6X1Bpnue+ e45VpZjjcdNVItBOdmTrCTmNXb9jakrZ67zieU5VhUGR7bLJqumkyxZ29/3jkeCQ8PxH bXcQsMdyz1TVn+WJE+ZNxoj/9Hipk4x4INQ9GLp2P0GUA0E6RwY+K/PW775BWGzZpcOO oCXw== 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=w5D9QgKvXJDSs69W719kOBsxIgJ1yqINQsNXR6y+ypg=; b=b9mMkuzR/UXMUnoRgv4hLuZu4ZHMOZNP2GfJkdhT0bwui2dghWGeO63Q53xuwE6e0S UoPHXFl05g+Hcy3UXBpbJLSOyPH7EvDHxA/kjPiyMaCx9JDif+ZBCzT/86aEPWfVklGl TcFNOauw1Ey3HVaiCte8ZcMYes80jB+zowJnlduaD11CjABJx5iROyr6eRAjz0akALjA b8Edmscvo4hDB1lLkPQb6lIq5L4B+08qEQfD/g8394r9mzqa33qowl05UDaM9BDIAzUb cTR5D+7E4jvWc+YqE3tQvSZrIYOZepfVrz7zCSTH5gZt7oPUo6F1HCywJ4IBvd1l9Yvn CebQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PPaNJJ4B; 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 l11-20020a63700b000000b00477cdcd6267si2058947pgc.697.2022.11.30.12.25.09; Wed, 30 Nov 2022 12:25:23 -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=PPaNJJ4B; 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 S230186AbiK3US2 (ORCPT + 99 others); Wed, 30 Nov 2022 15:18:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbiK3UR5 (ORCPT ); Wed, 30 Nov 2022 15:17:57 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9895093A43 for ; Wed, 30 Nov 2022 12:13:39 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id q13so8622120ild.3 for ; Wed, 30 Nov 2022 12:13:39 -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=w5D9QgKvXJDSs69W719kOBsxIgJ1yqINQsNXR6y+ypg=; b=PPaNJJ4BLUfwX1mQEBI+QDJAYRQmqRb4iG7M33xvC3iB/PTrpApOpWJuDXe/Zx+AFY HKm7ba+4GF3xyclbIX7mpmX4wrP+yq6EMSjV35dIhSiQ2sFiWA+STIggI5WTt8Nm41n3 VYhlWv+veee5m6oQcf4sLDVY7osh0e4eePoV0= 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=w5D9QgKvXJDSs69W719kOBsxIgJ1yqINQsNXR6y+ypg=; b=GLxizZ/shRYOwWtlMmevhkIKk7bE4jqEFk+5lt22rBde7LF5WYXyNZ3V57nZQtfewj tDO0M0ZIyk91iRnJQwyLy+EWGnmrI2dJeVJHupPFv6aB+6FeHx8Jt3N/e2Pwk3fbAPAe TFOyMutPaiFalQeKNZUHQflO56h3J4KUuqdbLwCrURNMrhnINPvI5Lu68czZxxjumYRd PNB58JVq1GXzB77E0DGaTblaKVJubTuKM87hF2XDgxjqOiZCdjP11+ou+9B5jZ2hTZM4 g+Fd8E9VnQ9nqtAcTHWG18QL2iciDPlwTiU69UoQTRPgwMPHaKf63d3KdNMu1u+kDbfs tEnQ== X-Gm-Message-State: ANoB5pkpT/rPeh0rnG7SNT0cI/TUXL6E1yEvqx2tXZrdw5FaWjO7SZWX aioovR5/PKaGlXR3eDtflUS7hshcK3M4EQ== X-Received: by 2002:a92:d607:0:b0:2fb:6601:80f2 with SMTP id w7-20020a92d607000000b002fb660180f2mr24147849ilm.208.1669839218517; Wed, 30 Nov 2022 12:13:38 -0800 (PST) Received: from markhas1.lan (184-96-172-159.hlrn.qwest.net. [184.96.172.159]) by smtp.gmail.com with ESMTPSA id r2-20020a02b102000000b00363e61908bfsm902158jah.10.2022.11.30.12.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 12:13:38 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Krzysztof Kozlowski , Benson Leung , Guenter Roeck , Krzysztof Kozlowski , Lee Jones , Rob Herring , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH v8 2/3] dt-bindings: mfd: Add compatible string for UART support Date: Wed, 30 Nov 2022 13:12:55 -0700 Message-Id: <20221130131245.v8.2.I9e018ecb8bdf341648cb64417085978ff0d22a46@changeid> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221130131245.v8.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221130131245.v8.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?1750954066829800548?= X-GMAIL-MSGID: =?utf-8?q?1750954066829800548?= Add a compatible string to support the UART implementation of the cros ec interface. Signed-off-by: Bhanu Prakash Maiya Signed-off-by: Mark Hasemeyer Acked-by: Krzysztof Kozlowski --- Changes in v8: - Update commit message 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 Wed Nov 30 20:12:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 27999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1133912wrr; Wed, 30 Nov 2022 12:25:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5spUwYqa96YWlBuAfbcDPO7f0e6kLiUAZi4Lh8lGq/0Q8RBVPlqVe4NF8yTznPczNubZE5 X-Received: by 2002:a05:6a00:11:b0:574:e01e:970e with SMTP id h17-20020a056a00001100b00574e01e970emr23935039pfk.20.1669839957236; Wed, 30 Nov 2022 12:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669839957; cv=none; d=google.com; s=arc-20160816; b=bs93KDydEZ7C+ZXoHow5OqkStUBGdY6L6Mf2ySKEBY3zCupbrGGT4VbnQmJyvTJMZT KEr2UpH81S49DVapst5407s99Rddto8DxTUutS2nKJvU/zOacCu08pIh8SjrSTwOY2Ke Yw5HtI7MWrmMiufml6cM0p12znjnXRVSHWNpDQhrCkQgxCqJn/uY600dZTQir/FeK4qZ GC6pQVkgyZrxtsCn0wGGuvD2xPxwZEP0rIQsovtCqjqOpEGjjJxfp/0hnc71b0mFi67F ciyQ7eVTP5XAfu7f5JTbzZEVvHKB0ZhGYSDVBVtMTNkpnqPR7zyez+Ctb3vts3DV41GJ 54eg== 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=K4gs1nqhWEkh1q6oBgpXv2FkSjhvCSKGs/o2Pfz2jr8=; b=Yw7drwVCEe4GwOV3QCLQTSH+3wE4dPKdz1kVsnPzBge+XkPPX8XIngyhgeRDgU6Mwu rI9sGQIDDSIGgRfWV815mePvCckyhtNKSJz7xegN6CkBfpJrgKXkOTLFG4EvbC4m2PVK YaS3k4gDvnG2wvFc4qsI1NEYGdGYF4s6u+ckBWd0H6CI9BPXDNwGZiShaezA0aY+Tv20 UXM4Dih87IrI8/KdhuyL4iSbrJpK2vevqx/Ja2XMmGB8D5mKPGl4wRp1U9YNcb+imeXo N1cuwyVIBhstzXXYM0+sAdOjGH6Kx42deAlTXWc1ggvmEALmbu/sPlj3/oH9woob69BL jQgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="M/3A/m/r"; 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 x7-20020a636307000000b0047741e1fdb4si2014714pgb.367.2022.11.30.12.25.44; Wed, 30 Nov 2022 12:25:57 -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="M/3A/m/r"; 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 S230155AbiK3USk (ORCPT + 99 others); Wed, 30 Nov 2022 15:18:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiK3USN (ORCPT ); Wed, 30 Nov 2022 15:18:13 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DDA950EB for ; Wed, 30 Nov 2022 12:13:41 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id x12so5690838ilg.1 for ; Wed, 30 Nov 2022 12:13:41 -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=K4gs1nqhWEkh1q6oBgpXv2FkSjhvCSKGs/o2Pfz2jr8=; b=M/3A/m/rdnLCwq+N0mKcmdE9X0YNCiy+AKyIyVOzqAFNENc7fYG+WQp3vAo7AhXL3I /c99IHcFQIxBAKtKzz91w/vQs9yd0iVRHu0YI3a23Rk4+SO7U123BhA/BbYlNt3DyohU KKwz+K4DFd/l4UaDzw0Y0Qbq4Skp95Fid0TF8= 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=K4gs1nqhWEkh1q6oBgpXv2FkSjhvCSKGs/o2Pfz2jr8=; b=AjcBoZaUKZuYY1/OvB1WwE3aIKxqpY1XJ7IS3Cv4MmdO3Wib4g5hR7uJQtoZUusD/A qTEaC0uXvnc1RDLGBUCV0LVjrQxl2WVBoH6q+k3N6Em8EvKhKWzeWWo48eDmy24fBEo5 cwTETVeHvQYYCybBX0XD/7IaFi2V3d/3IolcK2my3GfrwKL2BEJmu+FS44knDipYMXWn JZn8dM6AoDZWfd3fRUMCIONy8PfAPpfOBa9NOEAzlp9b2/m/qdebfyOBMmbsExUSzNXp OAEPv7bKiHS3sgNJE/UZGqbjvT9HbMrV6kCH/6ukTIbOz0nPpZbrfHATz/ILA9k8LSsX niNQ== X-Gm-Message-State: ANoB5pliHmXXK8wN0ARaBEm1BAmerjEjKh2XB7Jbeg2ehrdmtoPU2rSi fx5IO6LjfyyEN3hblwWx0Am0vZMYzpnYEQ== X-Received: by 2002:a05:6e02:2197:b0:302:391a:f67b with SMTP id j23-20020a056e02219700b00302391af67bmr22128556ila.265.1669839220208; Wed, 30 Nov 2022 12:13:40 -0800 (PST) Received: from markhas1.lan (184-96-172-159.hlrn.qwest.net. [184.96.172.159]) by smtp.gmail.com with ESMTPSA id r2-20020a02b102000000b00363e61908bfsm902158jah.10.2022.11.30.12.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 12:13:40 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Bhanu Prakash Maiya , Benson Leung , Guenter Roeck , Tzung-Bi Shih , chrome-platform@lists.linux.dev Subject: [PATCH v8 3/3] platform/chrome: cros_ec_uart: Add DT enumeration support Date: Wed, 30 Nov 2022 13:12:56 -0700 Message-Id: <20221130131245.v8.3.Ie23c217d69ff25d7354db942613f143bbc8ef891@changeid> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221130131245.v8.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221130131245.v8.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?1750954102875604492?= X-GMAIL-MSGID: =?utf-8?q?1750954102875604492?= 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 v8: - No change 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 ef9ac7ace04b6..521a3ee6f60b3 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 @@ -385,6 +386,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 }, @@ -398,6 +405,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,