From patchwork Fri Nov 18 12:25:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 22307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp165867wrr; Fri, 18 Nov 2022 04:28:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7yxn6TfgUqzrWNKD9AYWyCkOQ1IHa3+X7XF3BczgVG4bch0JqgShqI9ad7jc1isUIdCDYo X-Received: by 2002:a65:694e:0:b0:474:6749:407d with SMTP id w14-20020a65694e000000b004746749407dmr6314270pgq.425.1668774502866; Fri, 18 Nov 2022 04:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668774502; cv=none; d=google.com; s=arc-20160816; b=KVmOTvfKDAAK9mci+mw3iv1SsA4AGlwp13bIGZuixb9a4o168yg1viOfZQAHwBYFYw 1THdFThcETxGiFU8pTekChFLxZLmbwBPj6Vm+TDUBZrpkSYXzVXDay+7LAfLnM1OfwTD ncyYUHTQ/adWi2Uo0OoI/M+68oT4Qq2+tXvyawYeu2UjZrzaFZUTTTIqMjqkK/p08SmJ iIhGamZK04JicwBSwjE9JGp0ff63/vRY6HL0EW9Ahn2PyKN177EsxOJOCfA6Smq1BQ0t PIB1tGOcC8NcvpEKKdUQZFQ5uehkdzQW4ZVy/ngro9x30vOirBM/cgj9cl/YMWYXvyMb 0uVA== 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=+vWdaRfhODAgXHbciwp5dedPQgtHL42vE9HPN7sV7Xo=; b=yA27FOD98gKDdYfTvAQ0l+1UHH5SrQnhYEoC/vBfbcolCpK9UV50QOG0CUbm8Kx4je ezZ77NqV5mbqtL8IBbgc7Iitpj3vr+YzopeAXiiSNiTS9eAzZjAIp25zx8ifPxu3oJQH YuLeH12WKQ2PCLgw1ZgBrTZKrqYnzDwtUzV0/7NrFirLA4w4x13R8XbYqu8zo5BJiGVy edFciI0FT77E5Egyy4TZAMxypebXjzUap4+KcysMvo5COOCs8PKua4Qm35fZf6cKLp7t xXAu4K0zE6WafRCwmasgVvbtnNxdKWehj5LLDHl+hMQUmcvPzubnG34HCJRODFT9sK9Q ocKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=A3I9ebSn; 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 l27-20020a63ba5b000000b00476f2af54f6si3846652pgu.47.2022.11.18.04.28.08; Fri, 18 Nov 2022 04:28:22 -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=A3I9ebSn; 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 S241808AbiKRM1P (ORCPT + 99 others); Fri, 18 Nov 2022 07:27:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241758AbiKRM03 (ORCPT ); Fri, 18 Nov 2022 07:26:29 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413BF97AB3 for ; Fri, 18 Nov 2022 04:26:12 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id w14so9026170wru.8 for ; Fri, 18 Nov 2022 04:26:12 -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=+vWdaRfhODAgXHbciwp5dedPQgtHL42vE9HPN7sV7Xo=; b=A3I9ebSn8MP5IHCkR+JU5No+kasmCPdQLMoUahVY7mTEMzWGkac6JsvBdCbC1srPAV PgzWDHNYqpDHW2tSapQU8V6Q65C7xcYlcP7Ft4Da6Xin20coIt6uEEvxJjibMd0+UA1+ esO+UwnxJTpphcJBdMD/4TzOn+6br3VLlg7CGm5QEO9OvSX/A2Jio5wq3iJXD8/9A7QF MdDtuKQUwEu7AV5W77SShOuhPh61NRsDoFsxB4pWpjX6y54U/IjeBENl2SPhz3nsNFU0 gL4A3Pa6nN/wOEFFhJ6lVTdTjyAJOrjhpQeAiVoJYVJPmSMopMyxq/jM1fhiCQH3a3po XIHw== 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=+vWdaRfhODAgXHbciwp5dedPQgtHL42vE9HPN7sV7Xo=; b=YleyxLCmoRxrm1vrZ/FqZZWTg0fwZIcvreaDG0SMVrhCTREHojV/lzNIzaIADQlpBK yNbkDfFVePF34mwHSFZxJeoDP65PTPC7GrhtXPIpUH+pR8Y8qgZ6oSrqpnkiCO+29zqd a8TaV3V2nNYqOBaZPJSTpe9160ZM6+/oQ1Wq+jJjiUClJboNZC71iC5RFCT4x7KCEmSk 410fVQ4uXIFmkp+FWsgyf1tlUg3fv5b8j58WjyMIuIdeOroNi/kpEbZ+bz67CgBvS5b4 v7PValqY/LIB4IadZPD3aKiE2ucBR7Pt2A2iU2SNBs7JChVHVaFjQGDvW19m7EcXTDBf KpPg== X-Gm-Message-State: ANoB5pn8LXNH6YGP0sjsZQEPKaM+NEpLdku2vyum1t6TvKAusLO0bzJu NAFhEzVB2CXN8rb4ADaNHHmpSw== X-Received: by 2002:a5d:6107:0:b0:241:9a7d:32d7 with SMTP id v7-20020a5d6107000000b002419a7d32d7mr4224230wrt.197.1668774371837; Fri, 18 Nov 2022 04:26:11 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:b10c:1279:a704:75d4]) by smtp.gmail.com with ESMTPSA id f19-20020a05600c155300b003c6f3e5ba42sm9873958wmg.46.2022.11.18.04.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 04:26:11 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Jiri Slaby , Srinivas Kandagatla , Vinod Koul , Alex Elder Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 10/15] tty: serial: qcom-geni-serial: use of_device_id data Date: Fri, 18 Nov 2022 13:25:34 +0100 Message-Id: <20221118122539.384993-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221118122539.384993-1-brgl@bgdev.pl> References: <20221118122539.384993-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=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?1749836892789807630?= X-GMAIL-MSGID: =?utf-8?q?1749836892789807630?= 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 72d0e7b91080..6a9f3f937f29 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; @@ -637,7 +642,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) @@ -1348,13 +1353,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 { @@ -1364,7 +1370,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); @@ -1376,6 +1382,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"); @@ -1394,7 +1401,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) @@ -1424,7 +1431,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")) @@ -1446,7 +1453,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) @@ -1526,14 +1532,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);