From patchwork Wed Nov 23 11:07:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 24910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2724534wrr; Wed, 23 Nov 2022 03:15:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ZlXYvLYDZ6QlGfaKp3TqC+JbS3DmVQaBg+M6CMP6JdqBQ4LYI3TysqfFo1Arae2i6/Li9 X-Received: by 2002:a63:5108:0:b0:477:9a46:d051 with SMTP id f8-20020a635108000000b004779a46d051mr7049979pgb.160.1669202120151; Wed, 23 Nov 2022 03:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669202120; cv=none; d=google.com; s=arc-20160816; b=ngyVyLjKNX5CK3I1b/MdRstjDrF0XmbgsoJJ8UY7/hTwBeX15uYQfIML7q2etIZYVp Nr7to3+cfb8TPJW5U9jOwLW6+1tcKNuFnhIrP+JC1n1g/CxvUOLo5VNA8V8exUwqM5BN PLHX/1tRG/zeEIg0J/rQqXicR3sV995jHwZzWFbeQt3sqx5a9pbdcVhQRtggLH2oqyi1 vqpmf2FvivfTnQrvMk27K2DbrtQguikt6z4sCcpjwdoq6s82M8erXKdLEA7IbYBJXLFV 3kW7SuDG0GEOumuiZxop4x2kLesf+WYXIzzOpAyOjvxfMUxVG05bFQWlEA17yakVMyXb 6H4w== 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=1DxIiePzG0//WGc1u8vcjab6CCEoh5mD9xNBPVt3Cw9yBgLmkf/2bb1S0Aan47e9cZ ErUDhIv1xUi3FQ1sljRm2rKZyEPceLwnRRuq2bLwMdwLzobg3e3+pbJaih35fESpZLJv iw2MOMCG099maJ7txoCajbD+3QdRm5o5418HPW9tTNSRVWLUkeq9LWbErCu4T9xBQ2yF ENRZ5OQjPbC8mZCVQ/dgeYFcSQ20lpejpPON+ngcoxTYdGENdxXyVK5j5zxx7AUmNVDF YV6eKRx75QdTccIdm4vSYCTldPhogBS0oN3wzsoeboGURiFgzjVkCwu3XWu2j47pfCGp FMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=p5qE2jgb; 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 p12-20020a056a000b4c00b0056d7aaaf1eesi16267753pfo.122.2022.11.23.03.15.06; Wed, 23 Nov 2022 03:15:20 -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=p5qE2jgb; 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 S235963AbiKWLJq (ORCPT + 99 others); Wed, 23 Nov 2022 06:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237639AbiKWLId (ORCPT ); Wed, 23 Nov 2022 06:08:33 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7D19C28D for ; Wed, 23 Nov 2022 03:08:14 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id n3so12284835wrp.5 for ; Wed, 23 Nov 2022 03:08:14 -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=p5qE2jgb2LOAm20iEZm7s3ykUED/tYXYc3k13raCuZX0DelZXEOCyr/PRW0AoMv0Y8 sucY5CNWUKtDcQenxcPkDcL8iYQxl3qjZwq1eo1o5Tlg8lloFIVh/VlAaqeGxuwmJ1C+ Oq60FkB0BD5Eg55H3qwjlzchz47elJPRNsZdYXToGuQfZXz9QJ+FmNUaoSir5ifYZaJn g5xvR2leVI3vadEDjLatUsif0ZnNYcz6qTz+4yUYiV4R8Pr78A9MEBj8hmzCjbjoMbDY RPQUN5k5ATMpPlfbDOHFFmdjpktjmWBVyBIFJa03raoUVtB1kE8COOcyZtigbPoIIaHl lEaw== 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=ojAxKXRQ8c9+7Wib172WyXCKPLQkyxiN0v38SurFVmEK8KOBXtGi9qur5CsrUxvr31 uoatjGkun9SNGkjijqtm5Z1m01lwsZ7mcplBG4YBeuWBETTpskHYqJ1xe7T9zmHFJJcU Y2TUux/VU+O7owOXQc8qImrx7Q8knayzSwy7Geb6c1CnrajhObt9phYhvdsracd6YuFt Oq1R6WfGfOIiRjU6uoaQih4irme82Zqh8W0zuaKYLwDs8rMta5vNQ+tVxCz6Y42fyfot GmSc/9vYl89ShGM4dt0qcvLThb7sKv4nb3rhU+zFpFAAw2lp5xI0RnfRWVgA4xMvWo4f +SFA== X-Gm-Message-State: ANoB5pnGzvyFitz868bbKIskm/slvye8sUVmALZ6kZvLtz+LfsRwESn2 rV0HM/s30khoq02qdAdwedMlNQ== X-Received: by 2002:adf:ea0b:0:b0:236:695b:6275 with SMTP id q11-20020adfea0b000000b00236695b6275mr17368695wrm.116.1669201694233; Wed, 23 Nov 2022 03:08:14 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae74:d94f:4677:3378]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c4e8d00b003c6c182bef9sm2560406wmq.36.2022.11.23.03.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 03:08:13 -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 v3 10/13] tty: serial: qcom-geni-serial: use of_device_id data Date: Wed, 23 Nov 2022 12:07:56 +0100 Message-Id: <20221123110759.1836666-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221123110759.1836666-1-brgl@bgdev.pl> References: <20221123110759.1836666-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?1750285282007601141?= X-GMAIL-MSGID: =?utf-8?q?1750285282007601141?= 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);