From patchwork Tue Nov 22 10:21:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 24254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2118878wrr; Tue, 22 Nov 2022 02:24:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5guhIqiv1hNKnLK2dtEZCNfjGxnR2PPAiwKJnFMRtstJhSfk932BiJwgRYxfzWA259ZIVx X-Received: by 2002:a05:6402:b8c:b0:463:b8dc:893f with SMTP id cf12-20020a0564020b8c00b00463b8dc893fmr21023870edb.28.1669112687367; Tue, 22 Nov 2022 02:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669112687; cv=none; d=google.com; s=arc-20160816; b=FL1KwdGxfnpN17LUVG/iO0BGVv927JVNv8PphtZVoWWrSW72BxqPE/bzHf26KyvkfF 7WwISGzdVgGdUbLcMjIXWFTyezYMRHo3TaEVQ+p4CYayrokZz9TRBkAy4hacaa1/imQ8 dYYiSi4H7WNUopfQFdmxYLBfw0IGIxPrYTBbqxgT7FaoEDYsz6PvwiNkxxiID2p0Xitg 1P1oJfl6PMqj+Xt1qXx6PaGgIuhBpBvBmxJUc7xTwHfVwkngT8vW62vpDbNnivvaD6JU jXyO+sOFzeKjLZMvU2UqcZyk6zKUogYlP8L/qlY8zvGZlABtG6jTHll3cRhcqEl4Skto LdEQ== 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=npWHp37Z5aqJft0VcgEPQBxH0XaK5lUmiP+By6Idpv0=; b=RVg8JoMnWNk4b+NUi1q8AueBfb3reD0Dp/f7yoPGb0pAn4dChSbd1iaoukzPu5Lthz RJVqQo4qKPw/vThtLIV3MWAFQ11dR5FumJlawuS3VZz5ylbdTeSqmcKP51MTMVZWeK2K 1oa5j5p+lWc9bVkVjgQ/HE9rCaC9HsZSsgc/nO5VXjvJEdHma+EOzs+SrJM2KMV4kDM7 q3fMdo4XFibcfdFzs3rTy+bI/V2VKtzC5S2n9X75jC4XOZ5Mlpcq7g/UK671xDLlL368 MLPH6o6vxeoMww5ZVedJlPTZ/a5WUC2OoCn6EiqVWTeBDQdogp+saFHIKY7jpRJoizO6 JHtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=PkQHJpHo; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wu13-20020a170906eecd00b0078d4ba46622si13217517ejb.616.2022.11.22.02.24.23; Tue, 22 Nov 2022 02:24:47 -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=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=PkQHJpHo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbiKVKXc (ORCPT + 99 others); Tue, 22 Nov 2022 05:23:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbiKVKWJ (ORCPT ); Tue, 22 Nov 2022 05:22:09 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3377F42F4B for ; Tue, 22 Nov 2022 02:21:51 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id bs21so23993768wrb.4 for ; Tue, 22 Nov 2022 02:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; 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=npWHp37Z5aqJft0VcgEPQBxH0XaK5lUmiP+By6Idpv0=; b=PkQHJpHo/PEa66JrHtMHcptcmHQfpK7HwPkPNE24wY3a/XCrj17CjVss7i5bbt6kyC 7W1r7T0SFnCud9TzH5mKebgp/dRZd2z5xrC7cOalTRfWEs8j4RtFZv0SNk1rkir/BQez Bydjel/MgzF1mtqhilcLeTOvFDmAQHST3q2YRgemF/miuWseiY7Rk4Usaf1WNPnjm4NT CM/Cf5QRApqvvTjX1bq93yRSX9dtnaMrKtWm06NSKbmHrcNZ4MLR/8WDIR0oPWNfN8EL N8LX2QCvaIQh4jDKFtoeBIEDd/2sROpQx8qwxcasIgpL/t5QXjQG1fe6EeVKLV1JnbzW wNkg== 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=npWHp37Z5aqJft0VcgEPQBxH0XaK5lUmiP+By6Idpv0=; b=MdwsJNyV/KxLX8Qomo6EGn2goo0W0vJm+HoAOruKd39Gaehh7+6h6DfgH0Mvsmczpy VUIfaxu4hC49qpYUub0lPJJ5P/XrY5zZtWk4BtlKEHIanPzVXttmJ//qqlOaW1ESISnG ZNNDnwoI3pBpIcuOJHxyF05BE3sMTSr6V+VQko3FCWk94ApVvwBN5oIYuorGdHTMD/ts A8UrELxUvWeOzchliltDMFnpswlXmiAMxcOtMcAYfP0aE5de85xFkY1Px5OUaBll0erl ZVCk+1Fsyh0I2TQ062wbVs0tlruyaueVUoC94yFLzpoIHjCi9ipWOqvH1c29IbpzJ7Rn GUng== X-Gm-Message-State: ANoB5pnmuzK8WQ0rF2NoKjDTzHNwER7v6cOLrtgTquogjhXTVn+K3JD3 59zMOzq2mBfzrCdeUFwBgmrmZQ== X-Received: by 2002:adf:fc8e:0:b0:241:855e:34d6 with SMTP id g14-20020adffc8e000000b00241855e34d6mr13084119wrr.189.1669112510761; Tue, 22 Nov 2022 02:21:50 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:e011:9e81:66f1:3415]) by smtp.gmail.com with ESMTPSA id o3-20020a5d4083000000b002366e8eee11sm13432873wrp.101.2022.11.22.02.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 02:21:50 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Jiri Slaby , Srinivas Kandagatla , Vinod Koul , Alex Elder , =?utf-8?q?Ilp?= =?utf-8?q?o_J=C3=A4rvinen?= Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Bartosz Golaszewski , Konrad Dybcio Subject: [PATCH v2 10/15] tty: serial: qcom-geni-serial: use of_device_id data Date: Tue, 22 Nov 2022 11:21:20 +0100 Message-Id: <20221122102125.142075-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221122102125.142075-1-brgl@bgdev.pl> References: <20221122102125.142075-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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?1750191505271231178?= X-GMAIL-MSGID: =?utf-8?q?1750191505271231178?= From: Bartosz Golaszewski Instead of checking the device compatible in probe(), assign the device-specific data to struct of_device_id. We'll use it later when providing SE DMA support. Signed-off-by: Bartosz Golaszewski Reviewed-by: Konrad Dybcio --- drivers/tty/serial/qcom_geni_serial.c | 46 ++++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index d5c343b06c23..036231106321 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -95,6 +95,11 @@ /* We always configure 4 bytes per FIFO word */ #define BYTES_PER_FIFO_WORD 4 +struct qcom_geni_device_data { + bool console; + void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); +}; + struct qcom_geni_private_data { /* NOTE: earlycon port will have NULL here */ struct uart_driver *drv; @@ -114,7 +119,6 @@ struct qcom_geni_serial_port { u32 tx_fifo_width; u32 rx_fifo_depth; bool setup; - void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); unsigned int baud; void *rx_fifo; u32 loopback; @@ -126,6 +130,7 @@ struct qcom_geni_serial_port { bool cts_rts_swap; struct qcom_geni_private_data private_data; + const struct qcom_geni_device_data *dev_data; }; static const struct uart_ops qcom_geni_console_pops; @@ -640,7 +645,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop) total_bytes += last_word_byte_cnt; else total_bytes += BYTES_PER_FIFO_WORD; - port->handle_rx(uport, total_bytes, drop); + port->dev_data->handle_rx(uport, total_bytes, drop); } static void qcom_geni_serial_stop_rx(struct uart_port *uport) @@ -1345,13 +1350,14 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) struct uart_port *uport; struct resource *res; int irq; - bool console = false; struct uart_driver *drv; + const struct qcom_geni_device_data *data; - if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart")) - console = true; + data = of_device_get_match_data(&pdev->dev); + if (!data) + return -EINVAL; - if (console) { + if (data->console) { drv = &qcom_geni_console_driver; line = of_alias_get_id(pdev->dev.of_node, "serial"); } else { @@ -1361,7 +1367,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) line = of_alias_get_id(pdev->dev.of_node, "hsuart"); } - port = get_port_from_line(line, console); + port = get_port_from_line(line, data->console); if (IS_ERR(port)) { dev_err(&pdev->dev, "Invalid line %d\n", line); return PTR_ERR(port); @@ -1373,6 +1379,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) return -ENODEV; uport->dev = &pdev->dev; + port->dev_data = data; port->se.dev = &pdev->dev; port->se.wrapper = dev_get_drvdata(pdev->dev.parent); port->se.clk = devm_clk_get(&pdev->dev, "se"); @@ -1391,7 +1398,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS; port->tx_fifo_width = DEF_FIFO_WIDTH_BITS; - if (!console) { + if (!data->console) { port->rx_fifo = devm_kcalloc(uport->dev, port->rx_fifo_depth, sizeof(u32), GFP_KERNEL); if (!port->rx_fifo) @@ -1421,7 +1428,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) uport->irq = irq; uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE); - if (!console) + if (!data->console) port->wakeup_irq = platform_get_irq_optional(pdev, 1); if (of_property_read_bool(pdev->dev.of_node, "rx-tx-swap")) @@ -1443,7 +1450,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) port->private_data.drv = drv; uport->private_data = &port->private_data; platform_set_drvdata(pdev, port); - port->handle_rx = console ? handle_rx_console : handle_rx_uart; ret = uart_add_one_port(drv, uport); if (ret) @@ -1523,14 +1529,30 @@ static int __maybe_unused qcom_geni_serial_sys_resume(struct device *dev) return ret; } +static const struct qcom_geni_device_data qcom_geni_console_data = { + .console = true, + .handle_rx = handle_rx_console, +}; + +static const struct qcom_geni_device_data qcom_geni_uart_data = { + .console = false, + .handle_rx = handle_rx_uart, +}; + static const struct dev_pm_ops qcom_geni_serial_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_sys_suspend, qcom_geni_serial_sys_resume) }; static const struct of_device_id qcom_geni_serial_match_table[] = { - { .compatible = "qcom,geni-debug-uart", }, - { .compatible = "qcom,geni-uart", }, + { + .compatible = "qcom,geni-debug-uart", + .data = &qcom_geni_console_data, + }, + { + .compatible = "qcom,geni-uart", + .data = &qcom_geni_uart_data, + }, {} }; MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table);