From patchwork Thu Dec 8 19:39:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 31477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp386956wrr; Thu, 8 Dec 2022 11:42:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KyUq2t85QLEEjYI64dofaQxEfGnBH/oYmdXrvg+bhjL0dsDrfugMGZdqyg/E0QuzfylsT X-Received: by 2002:a17:906:1797:b0:7c0:c805:42a with SMTP id t23-20020a170906179700b007c0c805042amr21023716eje.324.1670528535413; Thu, 08 Dec 2022 11:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670528535; cv=none; d=google.com; s=arc-20160816; b=e8MQjloF0O+hYa9qhBxDS+NREuoEOmPkb+1kMGcWeBObITHAgqb1+nsduCqIrUKKqc SA6E3qd8/zRwn1wdTW8O6aU79cR3YctC5gANBqoWNJ98rmB+jGfzAmwh8no/CPA0+AGz oZS2riEPfIHjeeoOPsvexAEGfP2CC8X47yqBzQBqtmed1xTlfRshiQfZDlG/f77HKY7n ET3qiaQMDxqhxZxkukZT+ShXtA7THpWHoj+8LyyudNz2eTqySzQLYphk6QoQi2xRBVJl nov68iHjeI+muislsetIX/R9OrN0u3QUIvmQbef/ZnAics+RFM+8psLHO+th0BDagMxo n6HQ== 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=h+YcwqXanmcBISih2ehEsPDeIn/EQ5HU2oNuW+2QoDs=; b=SLb9tx8IzSD6Rb+pcPMWLfmlioRGZa12K8Bc75GOSWLXcJAOus5zQpFuPEjqHNKUjj CGlUMlYN1qntCOFsKLubNCaY8yoB7cr1Fk1sX/y6rnGqxidEqeZmQwvQHzys+zf4YpxY 9Q9K4O2ODjUOiX/BmJa4LikUiNbrlhm3hXwyj9S5rJQF0lQUBZEAvrtPXlRqzJ2fh934 D6VTadS1/dXoiW42v6B/1s1/iPFuXtbu+Izc4CigMatNtttPcXilcs/B9Y+6HdK+MvZm pz8HCMYCrWkAaq6wNJPfnhog5qfEIZG6XJXFtpUPMkO04pDgkPK2++fgVK2Em1Cvb+jt UgDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="MD7fZlf/"; 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 c6-20020aa7c746000000b0046c53c2be4asi6469539eds.365.2022.12.08.11.41.52; Thu, 08 Dec 2022 11:42:15 -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="MD7fZlf/"; 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 S229929AbiLHTko (ORCPT + 99 others); Thu, 8 Dec 2022 14:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiLHTkS (ORCPT ); Thu, 8 Dec 2022 14:40:18 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC64C1AA1E for ; Thu, 8 Dec 2022 11:40:03 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id q190so862087iod.10 for ; Thu, 08 Dec 2022 11:40:03 -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=h+YcwqXanmcBISih2ehEsPDeIn/EQ5HU2oNuW+2QoDs=; b=MD7fZlf/e1u2e00KROqCESJr9+r/8PiPL5cVbYjmuP9ZolzUeXSAvZ5nNryWuvCmM5 GkO0B5l5M+gxxIvMaNBG+MRNg7B2VKBtjQpcvnhVa2Q3YMW1ef0fbaQYzEddF/8/5nr8 3cWEjU3ITPbTjEknuqYygs9o9yoNd2ZZ7d9gE= 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=h+YcwqXanmcBISih2ehEsPDeIn/EQ5HU2oNuW+2QoDs=; b=Ohqw36QhJQyD58DM+c73F9eUh55MIJ23nyXTg3XE198HON06/ICW9OZX/dOSdf/lPf DyN95cVzddyGc1N2QBnToZfOVUH6J0SAo9YRRTjzzqqAY/RhxZyv+97U1BN3OVSGtTtV o/zc4YWvjsjdFx3i2iKt5jdyhEfIN8ZgLyOOoz/m7MBlNAN+Pm3A6XaDO7hnO78B33QR zFt+qDFVI46XnwoIsNoC/0gxIVtjXMTxLzeJVioCcWOTPIMlbL8pnQayIlb0bYI06iPx IQbFug/Ri3i4cNhSLacOAHlE/iro/k/smYc6sa7zdLDc9v/5NEGi79M5n1BFynhAddoZ TG4A== X-Gm-Message-State: ANoB5pkGU/MITdMBntWqBNWJng9CB65vq7JyqtCvqn6mPxxwBPYtQoUt BRQkAn3we1y/u9FL2BsYS1iLO6haJ+jm4NhW X-Received: by 2002:a6b:dc03:0:b0:6bc:d715:b8fe with SMTP id s3-20020a6bdc03000000b006bcd715b8femr2269149ioc.13.1670528397951; Thu, 08 Dec 2022 11:39:57 -0800 (PST) Received: from markhas1.roam.corp.google.com (63-225-246-100.hlrn.qwest.net. [63.225.246.100]) by smtp.gmail.com with ESMTPSA id b5-20020a05660214c500b006df13af1f16sm9245441iow.50.2022.12.08.11.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 11:39:57 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Bhanu Prakash Maiya , kernel test robot , Mark Hasemeyer , Prashant Malani , Benson Leung , Guenter Roeck , Tzung-Bi Shih , chrome-platform@lists.linux.dev Subject: [PATCH v11 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Date: Thu, 8 Dec 2022 12:39:50 -0700 Message-Id: <20221208123944.v11.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-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?1751676129277601760?= X-GMAIL-MSGID: =?utf-8?q?1751676129277601760?= From: Bhanu Prakash Maiya 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. Reported-by: kernel test robot Signed-off-by: Bhanu Prakash Maiya Co-developed-by: Mark Hasemeyer Signed-off-by: Mark Hasemeyer Reviewed-by: Prashant Malani --- Changes in v11: - Clarify error status in documentation - Join more multi-line statments onto a single line if < 100 chars - Add newline to the end of some printks - Terminate acpi_device_id with a NULL entry - Fix serdev doc warning for cros_ec_uart struct Changes in v10: - Remove superfluous comments - Remove unneeded #include - Use uninterruptible variant of wait_event - Merge error and received variables into a single status var - White space alignment - Add warning message when byes are received out of band - Join some multi-line statments onto a single line if < 100 chars Changes in v9: - Rebase onto for-next - Update contact information in MAINTAINERS - Remove superfluous comments - Invert conditional logic checking response size - Update authorship - Convert single case switch statement to if conditional - Reorder initializer list in increasing order of line length - Use wait_event_timeout return value to detect timeout - Remove unnecessary zeroizing of ec_uart struct - Set received conditional on -EMSGSIZE error case - Join dev_err msg onto single line where possible 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 | 352 +++++++++++++++++++++++++ 4 files changed, 370 insertions(+) create mode 100644 drivers/platform/chrome/cros_ec_uart.c diff --git a/MAINTAINERS b/MAINTAINERS index 4002d61291ca7..1b54bd6f28328 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4913,6 +4913,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 c1ca247987d2d..0d272c87f32b2 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 f6068d077a40a..0f39edef660dd 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..43a7493347a59 --- /dev/null +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -0,0 +1,352 @@ +// 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 "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. + * @status: Re-init to 0 before sending a cmd. Updated to 1 when + * a response is successfully received, or an error number + * on failure. + * @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 status; + wait_queue_head_t wait_queue; +}; + +/** + * struct cros_ec_uart - information about a uart-connected EC + * + * @serdev: 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 */ + dev_warn(ec_dev->dev, "Bytes received out of band, dropping them.\n"); + return count; + } + + /* + * Check if incoming bytes + response.size is greater 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) { + ec_uart->response.status = -EMSGSIZE; + wake_up(&ec_uart->response.wait_queue); + return count; + } + + memcpy(ec_uart->response.data + ec_uart->response.size, data, count); + + 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) { + 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) { + ec_uart->response.status = 1; + wake_up(&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; + + 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.exp_len = 0; + ec_uart->response.status = 0; + + ret = serdev_device_write_buf(serdev, ec_dev->dout, len); + if (ret < len) { + dev_err(ec_dev->dev, "Unable to write data\n"); + ret = -EIO; + goto exit; + } + + ret = wait_event_timeout(ec_uart->response.wait_queue, + ec_uart->response.status, + msecs_to_jiffies(EC_MSG_DEADLINE_MS)); + if (ret == 0) { + dev_warn(ec_dev->dev, "Timed out waiting for response.\n"); + ret = -ETIMEDOUT; + goto exit; + } + + if (ec_uart->response.status < 0) { + dev_warn(ec_dev->dev, "Error response received: %d\n", ec_uart->response.status); + ret = ec_uart->response.status; + goto exit; + } + + response = (struct ec_host_response *)ec_dev->din; + ec_msg->result = response->result; + + if (response->data_len > ec_msg->insize) { + dev_err(ec_dev->dev, "Resp too long (%d bytes, expected %d)\n", 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; + } + + memcpy(ec_msg->data, ec_dev->din + sizeof(*response), response->data_len); + + ret = response->data_len; + +exit: + /* Invalidate response buffer to guard against out of band rx data */ + ec_uart->response.data = NULL; + + 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 = &ares->data.uart_serial_bus; + + if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS && + 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); + } + + return 0; +} + +static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) +{ + int ret; + LIST_HEAD(resources); + struct acpi_device *adev = ACPI_COMPANION(&ec_uart->serdev->dev); + + 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; + + 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); + 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; + } + + 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; + } + + 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); + + 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 }, + {} +}; + +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 Dec 8 19:39:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 31478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp387043wrr; Thu, 8 Dec 2022 11:42:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4eVt0lXc99P3p6nZj1f9qqqbYguGOJ3bVCa/vnGBHLv+nF0wSV+5T+97wN5EKO1/waI4hq X-Received: by 2002:a17:906:a845:b0:7c0:faca:524 with SMTP id dx5-20020a170906a84500b007c0faca0524mr12814883ejb.53.1670528546157; Thu, 08 Dec 2022 11:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670528546; cv=none; d=google.com; s=arc-20160816; b=Kykcnu31sfE5yaeaF6bYlW6x8E+iqnZUmcLbZG+V0dozAVzoPTNotId5KBOfCu18Qz 5IYmd4zMd5g2NyMis+QNA2wakSzE2lZZHCIr1MiuLp8FvlZ180N9LzRCtUTmguT1ayYx pzvrnKdqfiRq965Ck4LhIG1dlHwLn2b2CTItf57gShi9B9NvBF7QPtfTffVsftBhehEB YPO+rKJNoYZDZKBnDg88mlcPFJ2k1f+vqr7xGDMPDcWb7qMxRFaXZ9pQ/S2zcyE8u25O iDXgtXv1cL426U53tFchyUFGoQGTIgSMmH1Pyjok2q+8bbjoeGl1IuGAMGlv429hWlz5 OhMw== 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=6knfdCbn21BCTb9mG6T6YdbL/IZU8aMeiwcDOSNAJo4=; b=lpoerpKtvVojLmfwvd+wwMBJ2uqgpR1cCpq65JG8/xO+zsqQOPunz4flFiqoPQjZUL OA7mvcFvQgsedBWeYGw5P5C4YsGAlDNCrirpyExhuTLAmmthk9Sy/47d1L3lDYObErJq oPzM2/LMoaft0+YKi4BxqblSLwT9uDhOJ3rX21BUNNVbr9SPufp3PK0pqhcKeLnm4azV hbmZeBicFDxMlnr2JPcqQu4ey1yBZaunebUDLvJzNOvhgxwxpracdDUtfIFh1BSRxJHW wl8JmrzexltT71+WSkT/3fp4EOhg3N32/RPkD/axAr6LHYToxBb5G4I5OT3CDWyy9n5G N0hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gnTxgQ2Y; 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 m1-20020aa7c481000000b004573107a5basi6397993edq.352.2022.12.08.11.42.03; Thu, 08 Dec 2022 11:42:26 -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=gnTxgQ2Y; 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 S230043AbiLHTkk (ORCPT + 99 others); Thu, 8 Dec 2022 14:40:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbiLHTkR (ORCPT ); Thu, 8 Dec 2022 14:40:17 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF581AA23 for ; Thu, 8 Dec 2022 11:40:04 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id i83so860005ioa.11 for ; Thu, 08 Dec 2022 11:40:04 -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=6knfdCbn21BCTb9mG6T6YdbL/IZU8aMeiwcDOSNAJo4=; b=gnTxgQ2YNwFnoPYgG4cIMS+LZ97bY5Yp0AHyoiPlrUT7G4ndzlsjZQoB2Gfq67kx88 YiWicu4p4r1Zdr+9vpbO+5nEJZTqDOqwgKsxzmVAK537CbhlTySJfvrgonsJVt26ojyT pbJpSWBBpnn09OI6AweyatYOvcVUfVsBAhQaI= 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=6knfdCbn21BCTb9mG6T6YdbL/IZU8aMeiwcDOSNAJo4=; b=h7kBJ66w5ZGWVEQ7wsEbUQglj8KT005KhJad0l+WKZrUlSspDCX3IRDwgTdwngJqs0 LgOIId4B4Gg41RRDRy43jocEfIOfD2NEwE465OjPNuYwnL9DlVu2dmhJzrE0PRuPpWU1 T9ckeWsF/oUD3/IK3vIepd7SAKK9PVWJ5E2izMTGTomMTmkaC0F1R5uQz7AojtheUvZi swV55qdZi8mPFnzIybogCbG/bODatGBY0PYY2SvnVtznkyUaILRkovHPUwY0dfv5G/NB 6ieDpUectokhWMJWaQab/juJBJvP/q6Lv+FoO9J6E17hQXQ1BPkroQYquubx5x4pCl3m 4vKw== X-Gm-Message-State: ANoB5pntU3lW4emhCvl5isHuVIOZc06vKQOka4S9M63SHWjO8HSxqYnJ YE9tNryMiosIxqbBR43R53l+JW4XMs1TtNC6 X-Received: by 2002:a05:6602:381b:b0:6bc:d715:b8f8 with SMTP id bb27-20020a056602381b00b006bcd715b8f8mr2455896iob.7.1670528398762; Thu, 08 Dec 2022 11:39:58 -0800 (PST) Received: from markhas1.roam.corp.google.com (63-225-246-100.hlrn.qwest.net. [63.225.246.100]) by smtp.gmail.com with ESMTPSA id b5-20020a05660214c500b006df13af1f16sm9245441iow.50.2022.12.08.11.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 11:39:58 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Bhanu Prakash Maiya , Mark Hasemeyer , Krzysztof Kozlowski , Benson Leung , Guenter Roeck , Krzysztof Kozlowski , Lee Jones , Rob Herring , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH v11 2/3] dt-bindings: mfd: cros-ec: Add UART compatible string Date: Thu, 8 Dec 2022 12:39:51 -0700 Message-Id: <20221208123944.v11.2.I9e018ecb8bdf341648cb64417085978ff0d22a46@changeid> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog In-Reply-To: <20221208123944.v11.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221208123944.v11.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?1751676140898757211?= X-GMAIL-MSGID: =?utf-8?q?1751676140898757211?= From: Bhanu Prakash Maiya Add a compatible string to support the UART implementation of the cros ec interface. The driver does not support the reg and interrupt properties, so exempt them from being required for UART compatible nodes. Signed-off-by: Bhanu Prakash Maiya Co-developed-by: Mark Hasemeyer Signed-off-by: Mark Hasemeyer Acked-by: Krzysztof Kozlowski --- Changes in v11: - Update commit message to include device Changes in v10: - No change Changes in v9: - Rebase onto for-next - Update node-name from uart0 to serial - Remove reg and interrupt property requirement for UART compatible nodes. - Update authorship 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 --- .../bindings/mfd/google,cros-ec.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml index 3d5efa5578d1b..cdf1d719efe9d 100644 --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml @@ -33,6 +33,9 @@ properties: - description: For implementations of the EC connected through RPMSG. const: google,cros-ec-rpmsg + - description: + For implementations of the EC connected through UART. + const: google,cros-ec-uart controller-data: true @@ -187,6 +190,15 @@ allOf: properties: mediatek,rpmsg-name: false + - if: + properties: + compatible: + not: + contains: + enum: + - google,cros-ec-rpmsg + - google,cros-ec-uart + then: required: - reg - interrupts @@ -299,4 +311,12 @@ examples: vdd-supply = <&pp3300_fp_mcu>; }; }; + + # Example for UART + - | + serial { + cros-ec { + compatible = "google,cros-ec-uart"; + }; + }; ... From patchwork Thu Dec 8 19:39:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 31479 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp387091wrr; Thu, 8 Dec 2022 11:42:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ONldpQKQLAGpgo2y39/E8Q7qaGPrvGlcEn2tikNfSMglEZwT0001wKiZSNQmXdpqK25Aa X-Received: by 2002:a17:906:a983:b0:7b8:31b1:b23f with SMTP id jr3-20020a170906a98300b007b831b1b23fmr62558911ejb.591.1670528552114; Thu, 08 Dec 2022 11:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670528552; cv=none; d=google.com; s=arc-20160816; b=k62S7gn/mP+mnp3aQWjHN/tlfrRlSPXfHxGZP5omJczcvxaVbuj5A10Qxz5x2rb96q 4IC2AFGOOTlpxduudJIcVqGbKpSC5nNXPyP+u38Z+Ml4pKfl62WkUpk4xcinkfJWDjtU f1NGko0dzBTWwQBenmikN6u1hUi8DKTP/Xl1/T7hu1UGCBNU0FrJ1uDwnDOOWqREgJRw J8MIqqOgF5/GkPILSs2laECA7Af4zFWLNcaKE+hieTh/TWdZjrgVYZ1duBPdA52iZ6HD 4/lDk3ZXeAMHNUi6wIRoNOeKHK8IlBFzDOxY+D9c3h9YCqQzuI/DX1sMMen0WraIpegx NBPA== 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=MF2GnFpAR/trOfRUw0h2YfNoFU34O3eLGi2QsSIBLfs=; b=D+PkI3YXaNrSntQPrHSooPfVhyT1a/177N4u9Z/xJC0CpAdYFNJ6XmqeBERuLTRHGF Zb8OV9MrMOvZqSnHsTGmDbVRqaHP2JRuDlhkcFWTZIl51sZeqLPxe3sFV+uRll+rReOV 9N2/113QX3FrI7tX+riWDegJYD6k5OospOdHDV7JVvFf7wE8VIFaDN/pO3AEOpDK8w3r eKIBBrcsws/VL3n58yYKY+CTVxQFfSd9O2t4R+dnc15ZuEcUREkukyTzuO5TMsVO0ia/ wS8fVVrQxnxTUcls4VueYlH0azKwVuFfmg8GdApNjcYlgRDTWhUXxgA8EQo/CI4R5i8T RffA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hPlE8zmR; 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 i16-20020a1709064fd000b007b29ccd79c0si8597728ejw.590.2022.12.08.11.42.09; Thu, 08 Dec 2022 11:42:32 -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=hPlE8zmR; 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 S230076AbiLHTks (ORCPT + 99 others); Thu, 8 Dec 2022 14:40:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbiLHTkU (ORCPT ); Thu, 8 Dec 2022 14:40:20 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658C41AA2D for ; Thu, 8 Dec 2022 11:40:09 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id n188so863529iof.8 for ; Thu, 08 Dec 2022 11:40:09 -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=MF2GnFpAR/trOfRUw0h2YfNoFU34O3eLGi2QsSIBLfs=; b=hPlE8zmRLYztt7X5yzlayM9VZwsGmPFHXExXLXy7fB6CDM3KMd0FfG+TXSCQFj3HQI TNA799Zga7eR+gEPSU81vnBcgAS9bocdV3qnLB0KCUJsJG1IECxqxdjcPEmKOhqwygkr g1X6EuXc6obBF3e0FSWaTG/04o23f5jkvWHCA= 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=MF2GnFpAR/trOfRUw0h2YfNoFU34O3eLGi2QsSIBLfs=; b=mRVtyfJrj27B/KK+jrbvpqM4aM0Uu7n3VjOG7W9fWVS7h9pfWaHGikrthmzn4gGHyS v0h8AzFMNZF1SnvBp37e31Vii4KRi+GdRlZ6DHW2OPRA/0nGuJUR29r4nRwbmKY7YYSe PevR/lCt/FUEGENh6lP506q3wcJgx4u0LPqEGP4oNev03nPg2cW9zFipLE+NAsFn6xVq UGYScYixe1Op3zkUbOJ/Kk2xJmTXxNBLK7f9kcbLYSkwc8Syj2EnYTGAIG8AL9Bl2BGq 7RPwQ4lIiLABWZ7HwoV/rEWXrbe4o4FFtUkoWCU2QYmq1hZIPN/7C2zdmFtwNn8PZXIJ OLEQ== X-Gm-Message-State: ANoB5pkSlg3gq3QG88n3nAUg9C5UmEkNQ5BYyCPtz5vIJZhjEL/VhW+A woVBfc6/fExsHsW5kOhfxoDX3jWM6bSVf3pb X-Received: by 2002:a05:6602:184f:b0:6e2:ca58:695 with SMTP id d15-20020a056602184f00b006e2ca580695mr2038236ioi.3.1670528399577; Thu, 08 Dec 2022 11:39:59 -0800 (PST) Received: from markhas1.roam.corp.google.com (63-225-246-100.hlrn.qwest.net. [63.225.246.100]) by smtp.gmail.com with ESMTPSA id b5-20020a05660214c500b006df13af1f16sm9245441iow.50.2022.12.08.11.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 11:39:59 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Bhanu Prakash Maiya , Mark Hasemeyer , Benson Leung , Guenter Roeck , Tzung-Bi Shih , chrome-platform@lists.linux.dev Subject: [PATCH v11 3/3] platform/chrome: cros_ec_uart: Add DT enumeration support Date: Thu, 8 Dec 2022 12:39:52 -0700 Message-Id: <20221208123944.v11.3.Ie23c217d69ff25d7354db942613f143bbc8ef891@changeid> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog In-Reply-To: <20221208123944.v11.1.If7926fcbad397bc6990dd725690229bed403948c@changeid> References: <20221208123944.v11.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?1751676146945697951?= X-GMAIL-MSGID: =?utf-8?q?1751676146945697951?= From: Bhanu Prakash Maiya 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 Co-developed-by: Mark Hasemeyer Signed-off-by: Mark Hasemeyer Reviewed-by: Prashant Malani --- Changes in v11: - No change Changes in v10: - No change Changes in v9: - Rebase onto for-next - Update authorship 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 43a7493347a59..bf0c291914725 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 @@ -326,6 +327,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 }, @@ -339,6 +346,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,