From patchwork Thu Aug 22 09:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWX0T5tz1ybW for ; Thu, 22 Aug 2024 19:11:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3qs-00017h-OB; Thu, 22 Aug 2024 09:11:30 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3qr-00017J-9f for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:29 +0000 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 2A3383F12E for ; Thu, 22 Aug 2024 09:11:29 +0000 (UTC) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-7143ae1b4d6so235315b3a.2 for ; Thu, 22 Aug 2024 02:11:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317887; x=1724922687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bmg7JmWRHX2k5SUoJdXKbajuwv0OENlpOswMpx20GUg=; b=d8crJBp8CpTbvM/z7NhUJH8jHPkL7W46HXPfa75S8pJa5kTKy4UmQ6YbwoHSgAvctU 5WxnkyS4x7Sdsy9K2XPtuc4mm/WCOfW1of46BpGsH3yPcP5xfAXO/wb3lqs3cCHf+i/p llNzOeBis90yHGmbm+ayBUVM66dGCgiNsOiPo0OtgsmpEktsnok3CyYUW8zLtGPHpNsL WIOcuHU+oTRyzraNQJMIDPUoi7QYmMIxjfQDH1MqQzqaZ5ZtTECgZR64v7P3S/bnKrNo jFDkLMOgJMoFs0wRbPSRpxUQGWOTV6rWsyHLQ50NoXUFdNqh5ux/Ze+KPb7+dyeYFIWN af3A== X-Gm-Message-State: AOJu0YyTwYXu6FDUZc27sPpm2uLosuQh49izM9bI4XkXf//spTtTK4u/ KqyN0emQ/Osx3TCcVmyxngmD1gwGpxwqKRoTz2JSTCs4zTKZzJONMZUEaG7xqhkYLEb3zL4JIlb RwftQj8EM0L4x8WpqBQ6XtD9UQPcHvWVJlMoR+Al4UB34wftieKI/7XkF2Eny62XecpZmV5DbGj lma1XKlJn48g== X-Received: by 2002:a05:6a20:9f0b:b0:1ca:cbf5:593 with SMTP id adf61e73a8af0-1cad7f8b771mr6609096637.20.1724317886853; Thu, 22 Aug 2024 02:11:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgOd0VJavoZLUl66p7UfO7e/BUXAFhLMUM4xQPqEQKEvGWGsitEUHruo5Cpk4vHEo/xhbIJA== X-Received: by 2002:a05:6a20:9f0b:b0:1ca:cbf5:593 with SMTP id adf61e73a8af0-1cad7f8b771mr6609085637.20.1724317886499; Thu, 22 Aug 2024 02:11:26 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143433d924sm931795b3a.215.2024.08.22.02.11.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:25 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 01/14] dt-bindings: serial: cdsn, uart: add power-domains Date: Thu, 22 Aug 2024 19:11:04 +1000 Message-Id: <20240822091117.1760423-2-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Krzysztof Kozlowski BugLink: https://bugs.launchpad.net/bugs/2055237 Few Xilinx DTS have power domains in serial node: zynqmp-zc1232-revA.dtb: serial@ff000000: Unevaluated properties are not allowed ('power-domains' was unexpected) Signed-off-by: Krzysztof Kozlowski Reviewed-by: Michal Simek Acked-by: Rob Herring Link: https://lore.kernel.org/r/20230124091916.45054-3-krzysztof.kozlowski@linaro.org Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 3a7f73e3475d4f4288f8bd560253aca5cd0d0cad) Signed-off-by: Portia Stephens --- .../devicetree/bindings/serial/cdns,uart.yaml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.yaml b/Documentation/devicetree/bindings/serial/cdns,uart.yaml index fcdbe6f87e980..490a48ae92775 100644 --- a/Documentation/devicetree/bindings/serial/cdns,uart.yaml +++ b/Documentation/devicetree/bindings/serial/cdns,uart.yaml @@ -9,9 +9,6 @@ title: Cadence UART Controller Device Tree Bindings maintainers: - Michal Simek -allOf: - - $ref: /schemas/serial.yaml# - properties: compatible: oneOf: @@ -46,6 +43,9 @@ properties: port does not use this pin. type: boolean + power-domains: + maxItems: 1 + required: - compatible - reg @@ -53,6 +53,17 @@ required: - clocks - clock-names +allOf: + - $ref: serial.yaml# + - if: + properties: + compatible: + contains: + const: cdns,uart-r1p8 + then: + properties: + power-domains: false + unevaluatedProperties: false examples: From patchwork Thu Aug 22 09:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWb5Mxsz1ybW for ; Thu, 22 Aug 2024 19:11:39 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3qx-0001BZ-4W; Thu, 22 Aug 2024 09:11:35 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3qv-0001A1-E7 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:33 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 256F93F12E for ; Thu, 22 Aug 2024 09:11:33 +0000 (UTC) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-7b696999c65so539454a12.3 for ; Thu, 22 Aug 2024 02:11:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317891; x=1724922691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IkLB+CJ+sORxDGvcptBpKrRUyvxOfZONotv8/2iinI0=; b=t3qflJwhZ/9QtvUGQLaJmKpiVNqpo7xcOoKJTgrch71DmX1Wh/WjQyYTq4BAF3FXf3 Hu3I5tdY5TfeEKF0UQLtivASCla6HsWlXM+ZVtXwPWY3ghmkGIfM8ze3TVbznqvf6v8n CNdgPdZSUHeuvrPSsV02lYZ4W8oM0mgCp5b8L/B5xk3fkQuNXGw1TyWr9gwmKJn4e6Gw S1q468jycwUT4MXTQi+T7CiKKpHxedV3HpdXEbvk6LHbKizAT31HvwZrhhKgRWpeNui1 OSitDlOukvz8pZoAZQEPUHdrVNrdhQeh3GQFVe5fnVwZ2v2L8BxCexqK3Ml632rdDBsG VoiA== X-Gm-Message-State: AOJu0YzzG6s7oQYRy6PM7/koglX8us3st10cINwKBlI/wifRzEngAM8Q NM1m9uqAePqIy4fBwou+EeK1CdfMD+9GwK6LI5T386oApyaRX72G/X8vg2ec349P2KcM84BtNJJ n9CjUYn1BRfJ8WlOrcSG4+nDf00cmUG16daYWT3mY3jrWmTUcWDJWZl3O0U5gzR2iktdc/ZLXR9 gGrhTq2DDclg== X-Received: by 2002:a05:6a20:9d91:b0:1c4:f209:f1ea with SMTP id adf61e73a8af0-1cad80f657emr6120306637.31.1724317891061; Thu, 22 Aug 2024 02:11:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXO0zf4MnF+HJwORMz1KsZAbGx4N8dW5+ov5CLCD4dtd0XIN++vlBveZgwlWJ8idBIKEGbhQ== X-Received: by 2002:a05:6a20:9d91:b0:1c4:f209:f1ea with SMTP id adf61e73a8af0-1cad80f657emr6120294637.31.1724317890709; Thu, 22 Aug 2024 02:11:30 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d5ebbb1726sm3502860a91.37.2024.08.22.02.11.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:30 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 02/14] dt-bindings: Add reference to rs485.yaml Date: Thu, 22 Aug 2024 19:11:05 +1000 Message-Id: <20240822091117.1760423-3-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Xilinx/AMD Kria SOM KD240 board has a rs485 compatible peripheral. Update the binding to have rs485 support. Acked-by: Conor Dooley Signed-off-by: Manikanta Guntupalli Link: https://lore.kernel.org/r/20240123061655.2150946-2-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 32152467ffac3b79eae7313959c310946b0e6072) Signed-off-by: Portia Stephens --- Documentation/devicetree/bindings/serial/cdns,uart.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.yaml b/Documentation/devicetree/bindings/serial/cdns,uart.yaml index 490a48ae92775..140a787d088c4 100644 --- a/Documentation/devicetree/bindings/serial/cdns,uart.yaml +++ b/Documentation/devicetree/bindings/serial/cdns,uart.yaml @@ -55,6 +55,7 @@ required: allOf: - $ref: serial.yaml# + - $ref: rs485.yaml# - if: properties: compatible: From patchwork Thu Aug 22 09:11:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWf61nWz1ybW for ; Thu, 22 Aug 2024 19:11:42 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3r0-0001FB-9O; Thu, 22 Aug 2024 09:11:38 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3qz-0001Ds-79 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:37 +0000 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1F1583F12E for ; Thu, 22 Aug 2024 09:11:37 +0000 (UTC) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-7c6b4dcb60aso247340a12.0 for ; Thu, 22 Aug 2024 02:11:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317895; x=1724922695; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+srsVgAbGLDsDdKmA3MqtC0IyJ1hhxqS/wl8nJFnRa8=; b=DTbrlrm1GVUNrfyvQJ7r7VfS2SHJsdtrNy/H6iWenIyeI7ejan2kaixS4U8KGoDwsM 3ox786g5DRjG9sAoXYIh7MWaBqjRqT7s1bLtzg+dBhB6yU/UaVe3lr3tlq8akSih1GR/ bkJWwbXfOAEnnwR+/5h6qBk+1GhBq3FjzGMj+9SXcznjOEBzmPh8hiZ+GJ4U+JIRDNX+ l1vbka3uoo97vMQUnq1UTbT3ykufPSLwCUxoyJ/78mo4OSzl/m+YFYeZN6I7xLI/SJ53 fMBvtJZR3IZydgmun+NZ56+OIQ7lvGH8b5tP4TV6SP2MyNSY7RdcAWavTcpRWFznweOD L/7w== X-Gm-Message-State: AOJu0YzRi3sW0GuyQbn5saqWA49W0t0KcRwC1n2vKlH25O8NUommxyc+ yLAozaGZWgHttI6xBEkCkGJAlP3DSVWUUbgmkb79Fw0C3Sy8NYfngpAQuHqv9XbNZws1uO1Ydha kFkIy069yLqcp5itAxSnHUOKiNZ1QJN1dE9PEB8z1boY9v2NTtnRVrWlsURnrCoJXHhW3s3MO6d KOKrs7ra9YaA== X-Received: by 2002:a05:6a21:1646:b0:1c2:8efc:88e9 with SMTP id adf61e73a8af0-1caeb31d803mr1276596637.40.1724317895032; Thu, 22 Aug 2024 02:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7/QeiK+JtAM6KamRA7hjRFZ+FgwXU+RB/onkyV4XidgTg/519yuqO/w11arwjYlmjCjz77w== X-Received: by 2002:a05:6a21:1646:b0:1c2:8efc:88e9 with SMTP id adf61e73a8af0-1caeb31d803mr1276584637.40.1724317894602; Thu, 22 Aug 2024 02:11:34 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2038560e046sm8337385ad.199.2024.08.22.02.11.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:33 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 03/14] serial: Store character timing information to uart_port Date: Thu, 22 Aug 2024 19:11:06 +1000 Message-Id: <20240822091117.1760423-4-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ilpo Järvinen BugLink: https://bugs.launchpad.net/bugs/2055237 Struct uart_port currently stores FIFO timeout. Having character timing information readily available is useful. Even serial core itself determines char_time from port->timeout using inverse calculation. Store frame_time directly into uart_port. Character time is stored in nanoseconds to have reasonable precision with high rates. To avoid overflow, 64-bit math is necessary. It might be possible to determine timeout from frame_time by multiplying it with fifosize as needed but only part of the users seem to be protected by a lock. Thus, this patch does not pursue storing only frame_time in uart_port. Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220425143410.12703-2-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 31f6bd7fad3b149a1eb6f67fc2e742e4df369b3d) Signed-off-by: Portia Stephens --- drivers/tty/serial/serial_core.c | 14 ++++++++------ include/linux/serial_core.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index b638b2fd2d3d2..f18bbfab745b4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -333,15 +334,18 @@ void uart_update_timeout(struct uart_port *port, unsigned int cflag, unsigned int baud) { - unsigned int size; + unsigned int size = tty_get_frame_size(cflag); + u64 frame_time; - size = tty_get_frame_size(cflag) * port->fifosize; + frame_time = (u64)size * NSEC_PER_SEC; + size *= port->fifosize; /* * Figure the timeout to send the above number of bits. * Add .02 seconds of slop */ port->timeout = (HZ * size) / baud + HZ/50; + port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud); } EXPORT_SYMBOL(uart_update_timeout); @@ -1647,10 +1651,8 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) * Note: we have to use pretty tight timings here to satisfy * the NIST-PCTS. */ - char_time = (port->timeout - HZ/50) / port->fifosize; - char_time = char_time / 5; - if (char_time == 0) - char_time = 1; + char_time = max(nsecs_to_jiffies(port->frame_time / 5), 1UL); + if (timeout && timeout < char_time) char_time = timeout; diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 4d3ce67e85527..75a34a0fa7546 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -233,6 +233,7 @@ struct uart_port { int hw_stopped; /* sw-assisted CTS flow state */ unsigned int mctrl; /* current modem ctrl settings */ unsigned int timeout; /* character-based timeout */ + unsigned int frame_time; /* frame timing in ns */ unsigned int type; /* port type */ const struct uart_ops *ops; unsigned int custom_divisor; From patchwork Thu Aug 22 09:11:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWn0RZhz1ybW for ; Thu, 22 Aug 2024 19:11:49 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3r6-0001Mo-Em; Thu, 22 Aug 2024 09:11:44 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3r3-0001Jn-SG for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:41 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 9B32D3F12E for ; Thu, 22 Aug 2024 09:11:41 +0000 (UTC) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-201f45e20b1so6463455ad.2 for ; Thu, 22 Aug 2024 02:11:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317899; x=1724922699; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BsjkRqsbHna9+7ebCbf15pBNrC7LJlp2Cu6arQb9ZDA=; b=ftBNMPHSCaLX9Uitqq1jS7k9q+0xIxke09VMHiALCRX+hkoqAFavbeX9q8dPl0k/SB AaoHdxsHEXprg9Bu9ZRybG1JlowGe/MMBjgC+AAK6Y35Tsv7iIyCTTDIg/t9Aoy6Etpg Sz/FT489GKlPP6ZISBLlGGClobPFQpI7sFw+qInH+TyC7yjt46t/MZrppW23T+tPwQ/z FSrd/V6kScVQYr/rj43vzCc1uL8JL5RJYVeDZqwoHm2HvtN3TRmGt+RK1N7plxT+YEn/ O4MDs/4Fe7GTNIx41MZDPSWHeo5RXtzqp/BLqGfty+WaY7x4OeL69pXXj0D+fDZuA1Yd DyNQ== X-Gm-Message-State: AOJu0YyuGUCTiHz8T+7ykbgU+irGSX8f0+MprqYRPxK0cFfC0jmR4aYk ay2ahuwnTGSRjIQLzOtLj/0t92LTLGkBJAYCVhcmJ2bqSqG861nN1sGym3wgKB50RjF+g0BdAqf WTyR/q63D5uTGsk2lOtIfmWCEMW6Pkv7/y1E/pfBDfviPz6SjOqfIBkwX0Cbgquf7f1tsUFWTjJ Oju9iN2K04Dg== X-Received: by 2002:a17:902:e751:b0:202:2fc8:da35 with SMTP id d9443c01a7336-203681aab11mr60126385ad.55.1724317899379; Thu, 22 Aug 2024 02:11:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGknnBTKu7g/joeW8hHS9rwze/M//FSM3T6MBl9eKPm0rUt2bykakshEFxtQsIdo0xm1i2O8Q== X-Received: by 2002:a17:902:e751:b0:202:2fc8:da35 with SMTP id d9443c01a7336-203681aab11mr60126165ad.55.1724317898835; Thu, 22 Aug 2024 02:11:38 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2038556a2f7sm8388955ad.9.2024.08.22.02.11.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:38 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 04/14] serial: take termios_rwsem for ->rs485_config() & pass termios as param Date: Thu, 22 Aug 2024 19:11:07 +1000 Message-Id: <20240822091117.1760423-5-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ilpo Järvinen BugLink: https://bugs.launchpad.net/bugs/2055237 To be able to alter ADDRB within ->rs485_config(), take termios_rwsem before calling ->rs485_config() and pass termios. Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220624204210.11112-5-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman [updated ulite_config_rs485] (cherry picked from commit ae50bb2752836277ae15aa4e9d99074d6d947946) Signed-off-by: Portia Stephens --- drivers/staging/uartlite-rs485/uartlite-rs485.c | 1 + drivers/tty/serial/8250/8250.h | 3 ++- drivers/tty/serial/8250/8250_exar.c | 9 +++++---- drivers/tty/serial/8250/8250_fintek.c | 2 +- drivers/tty/serial/8250/8250_lpc18xx.c | 2 +- drivers/tty/serial/8250/8250_pci.c | 2 +- drivers/tty/serial/8250/8250_port.c | 3 ++- drivers/tty/serial/amba-pl011.c | 2 +- drivers/tty/serial/ar933x_uart.c | 2 +- drivers/tty/serial/atmel_serial.c | 2 +- drivers/tty/serial/fsl_lpuart.c | 4 ++-- drivers/tty/serial/imx.c | 2 +- drivers/tty/serial/max310x.c | 2 +- drivers/tty/serial/mcf.c | 3 ++- drivers/tty/serial/omap-serial.c | 3 ++- drivers/tty/serial/sc16is7xx.c | 2 +- drivers/tty/serial/serial_core.c | 16 +++++++++++----- drivers/tty/serial/stm32-usart.c | 2 +- include/linux/serial_core.h | 1 + 19 files changed, 38 insertions(+), 25 deletions(-) diff --git a/drivers/staging/uartlite-rs485/uartlite-rs485.c b/drivers/staging/uartlite-rs485/uartlite-rs485.c index 66dcdbe7e847f..a09f6deb52735 100644 --- a/drivers/staging/uartlite-rs485/uartlite-rs485.c +++ b/drivers/staging/uartlite-rs485/uartlite-rs485.c @@ -398,6 +398,7 @@ static void ulite_pm(struct uart_port *port, unsigned int state, } static int ulite_config_rs485(struct uart_port *port, + struct ktermios *termios, struct serial_rs485 *rs485conf) { port->rs485 = *rs485conf; diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index d9500a25e03ab..3426eba6d3b2f 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -181,7 +181,8 @@ void serial8250_rpm_put(struct uart_8250_port *p); void serial8250_rpm_get_tx(struct uart_8250_port *p); void serial8250_rpm_put_tx(struct uart_8250_port *p); -int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485); +int serial8250_em485_config(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485); void serial8250_em485_start_tx(struct uart_8250_port *p); void serial8250_em485_stop_tx(struct uart_8250_port *p); void serial8250_em485_destroy(struct uart_8250_port *p); diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 48769e059772a..d861979889b06 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -122,7 +122,8 @@ struct exar8250; struct exar8250_platform { - int (*rs485_config)(struct uart_port *, struct serial_rs485 *); + int (*rs485_config)(struct uart_port *, struct ktermios *, + struct serial_rs485 *); const struct serial_rs485 *rs485_supported; int (*register_gpio)(struct pci_dev *, struct uart_8250_port *); void (*unregister_gpio)(struct uart_8250_port *); @@ -419,7 +420,7 @@ static void xr17v35x_unregister_gpio(struct uart_8250_port *port) port->port.private_data = NULL; } -static int generic_rs485_config(struct uart_port *port, +static int generic_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); @@ -453,7 +454,7 @@ static const struct exar8250_platform exar8250_default_platform = { .rs485_supported = &generic_rs485_supported, }; -static int iot2040_rs485_config(struct uart_port *port, +static int iot2040_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); @@ -483,7 +484,7 @@ static int iot2040_rs485_config(struct uart_port *port, value |= mode; writeb(value, p + UART_EXAR_MPIOLVL_7_0); - return generic_rs485_config(port, rs485); + return generic_rs485_config(port, termios, rs485); } static const struct serial_rs485 iot2040_rs485_supported = { diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c index dba5950b8d0e2..b03de7c0a360f 100644 --- a/drivers/tty/serial/8250/8250_fintek.c +++ b/drivers/tty/serial/8250/8250_fintek.c @@ -191,7 +191,7 @@ static int fintek_8250_get_ldn_range(struct fintek_8250 *pdata, int *min, return -ENODEV; } -static int fintek_8250_rs485_config(struct uart_port *port, +static int fintek_8250_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { uint8_t config = 0; diff --git a/drivers/tty/serial/8250/8250_lpc18xx.c b/drivers/tty/serial/8250/8250_lpc18xx.c index 570e25d6f37e3..780e81e3336ea 100644 --- a/drivers/tty/serial/8250/8250_lpc18xx.c +++ b/drivers/tty/serial/8250/8250_lpc18xx.c @@ -32,7 +32,7 @@ struct lpc18xx_uart_data { int line; }; -static int lpc18xx_rs485_config(struct uart_port *port, +static int lpc18xx_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct uart_8250_port *up = up_to_u8250p(port); diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 1d842bb8d9469..2d4876339b676 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1647,7 +1647,7 @@ pci_brcm_trumanage_setup(struct serial_private *priv, #define FINTEK_RTS_INVERT BIT(5) /* We should do proper H/W transceiver setting before change to RS485 mode */ -static int pci_fintek_rs485_config(struct uart_port *port, +static int pci_fintek_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct pci_dev *pci_dev = to_pci_dev(port->dev); diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 2d595a646bb89..d7dd643661265 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -659,7 +659,8 @@ EXPORT_SYMBOL_GPL(serial8250_em485_destroy); * if the uart is incapable of driving RTS as a Transmit Enable signal in * hardware, relying on software emulation instead. */ -int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485) +int serial8250_em485_config(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485) { struct uart_8250_port *up = up_to_u8250p(port); diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 1db98f76b1144..53b96fc843cc0 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2294,7 +2294,7 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser) return ret; } -static int pl011_rs485_config(struct uart_port *port, +static int pl011_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct uart_amba_port *uap = diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index 0f2677695b521..ab74fc151b2b7 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -580,7 +580,7 @@ static const struct uart_ops ar933x_uart_ops = { .verify_port = ar933x_uart_verify_port, }; -static int ar933x_config_rs485(struct uart_port *port, +static int ar933x_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485conf) { struct ar933x_uart_port *up = diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 98a3f36b40b92..654862589fa4e 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -284,7 +284,7 @@ static void atmel_tasklet_schedule(struct atmel_uart_port *atmel_port, } /* Enable or disable the rs485 support */ -static int atmel_config_rs485(struct uart_port *port, +static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485conf) { struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 9f1be9ce47e03..8f91d3136669d 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1338,7 +1338,7 @@ static void lpuart_dma_rx_free(struct uart_port *port) sport->dma_rx_cookie = -EINVAL; } -static int lpuart_config_rs485(struct uart_port *port, +static int lpuart_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct lpuart_port *sport = container_of(port, @@ -1389,7 +1389,7 @@ static int lpuart_config_rs485(struct uart_port *port, return 0; } -static int lpuart32_config_rs485(struct uart_port *port, +static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct lpuart_port *sport = container_of(port, diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 0587beaaea08d..6113d5bdcffe8 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1944,7 +1944,7 @@ static void imx_uart_poll_put_char(struct uart_port *port, unsigned char c) #endif /* called with port.lock taken and irqs off or from .probe without locking */ -static int imx_uart_rs485_config(struct uart_port *port, +static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485conf) { struct imx_port *sport = (struct imx_port *)port; diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 714c23f9504fc..6a1833d820f9f 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1035,7 +1035,7 @@ static void max310x_rs_proc(struct work_struct *ws) MAX310X_MODE2_ECHOSUPR_BIT, mode2); } -static int max310x_rs485_config(struct uart_port *port, +static int max310x_rs485_config(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct max310x_one *one = to_max310x_port(port); diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index c7cec7d036203..8b57fd1cac804 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c @@ -432,7 +432,8 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser) /****************************************************************************/ /* Enable or disable the RS485 support */ -static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) +static int mcf_config_rs485(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485) { unsigned char mr1, mr2; diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 0862941862c8b..a91c91f4231dc 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1339,7 +1339,8 @@ static inline void serial_omap_add_console_port(struct uart_omap_port *up) /* Enable or disable the rs485 support */ static int -serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) +serial_omap_config_rs485(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485) { struct uart_omap_port *up = to_uart_omap_port(port); unsigned int mode; diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 0066a0e235164..f0c82c3ab224a 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -969,7 +969,7 @@ static void sc16is7xx_set_termios(struct uart_port *port, uart_update_timeout(port, termios->c_cflag, baud); } -static int sc16is7xx_config_rs485(struct uart_port *port, +static int sc16is7xx_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485) { struct sc16is7xx_port *s = dev_get_drvdata(port->dev); diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f18bbfab745b4..2170721186f6b 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1290,7 +1290,7 @@ static int uart_get_rs485_config(struct uart_port *port, return 0; } -static int uart_set_rs485_config(struct uart_port *port, +static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, struct serial_rs485 __user *rs485_user) { struct serial_rs485 rs485; @@ -1330,7 +1330,7 @@ static int uart_set_rs485_config(struct uart_port *port, memset(rs485.padding, 0, sizeof(rs485.padding)); spin_lock_irqsave(&port->lock, flags); - ret = port->rs485_config(port, &rs485); + ret = port->rs485_config(port, &tty->termios, &rs485); if (!ret) { port->rs485 = rs485; @@ -1444,6 +1444,10 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) if (ret != -ENOIOCTLCMD) goto out; + /* rs485_config requires more locking than others */ + if (cmd == TIOCGRS485) + down_write(&tty->termios_rwsem); + mutex_lock(&port->mutex); uport = uart_port_check(state); @@ -1467,7 +1471,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) break; case TIOCSRS485: - ret = uart_set_rs485_config(uport, uarg); + ret = uart_set_rs485_config(tty, uport, uarg); break; case TIOCSISO7816: @@ -1484,6 +1488,8 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) } out_up: mutex_unlock(&port->mutex); + if (cmd == TIOCGRS485) + up_write(&tty->termios_rwsem); out: return ret; } @@ -2324,7 +2330,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) if (!(uport->rs485.flags & SER_RS485_ENABLED)) ops->set_mctrl(uport, uport->mctrl); else - uport->rs485_config(uport, &uport->rs485); + uport->rs485_config(uport, NULL, &uport->rs485); ops->start_tx(uport); spin_unlock_irq(&uport->lock); tty_port_set_initialized(port, 1); @@ -2442,7 +2448,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, if (!(port->rs485.flags & SER_RS485_ENABLED)) port->ops->set_mctrl(port, port->mctrl); else - port->rs485_config(port, &port->rs485); + port->rs485_config(port, NULL, &port->rs485); spin_unlock_irqrestore(&port->lock, flags); if (uart_console(port)) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 3b7d4481edbea..c0d6e61986355 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -145,7 +145,7 @@ static void stm32_usart_config_reg_rs485(u32 *cr1, u32 *cr3, u32 delay_ADE, *cr1 |= rs485_deat_dedt; } -static int stm32_usart_config_rs485(struct uart_port *port, +static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485conf) { struct stm32_port *stm32_port = to_stm32_port(port); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 75a34a0fa7546..5e52bb1419330 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -132,6 +132,7 @@ struct uart_port { unsigned int old); void (*handle_break)(struct uart_port *); int (*rs485_config)(struct uart_port *, + struct ktermios *termios, struct serial_rs485 *rs485); int (*iso7816_config)(struct uart_port *, struct serial_iso7816 *iso7816); From patchwork Thu Aug 22 09:11:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWq6tNJz1ybW for ; Thu, 22 Aug 2024 19:11:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3r8-0001Sm-VO; Thu, 22 Aug 2024 09:11:46 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3r7-0001Nl-Pj for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:45 +0000 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E61223F2E7 for ; Thu, 22 Aug 2024 09:11:44 +0000 (UTC) Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-270521c63c7so711116fac.3 for ; Thu, 22 Aug 2024 02:11:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317903; x=1724922703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VIqFZeRqycIyMr+LoYIHBY8c6iQz8rg/qddVG+bv1+I=; b=dJknKKg5l0xOImVBIGgI61OQU4UBAQr5IgJdKFTtexapupuU6WqY1vnQYB5KttB5QR H8JDkeeCWtdWco7+frTek/EVp2x3RuNp5ctJoLhm8tNtxCf7OQLtCmGdRjrJw18bOEq8 j9eX+1D/whJj1Sk9zxiVzxDAeQzbKi/s92LXu47Kbq48+bPmCnKP1jzKJW4vet4ZN1IQ xBkEoawWtJRVF8OH4PgzC7mHLf7o4RuhfIwFT4ah44r6dOGQ86bbyqKrFtCj20UC1p4F 2y9wXvXqGTxXYVKoZ3oR5F0t8+DlhdR7Vq3gyzweK1p4SNEJojCDtggJDCISjzWDv2w0 6AJQ== X-Gm-Message-State: AOJu0Yyr3cikuo3dBgz6sy0jG+99dbH5kZnznqxxS9EsJ50X+4jfxj/L FNYQsA4qjf3qzbQM3skpjJbp9eFsu2bCaSoy049mOukLo21cGvTO3ko1K37Sfp6hsH0WI2ruofD Ic/oytHT8noredSoTIbelIoGVTPf/wMnM8sG5BXHhEISTtGp8wigB9iMLN/u0U9jbv23ey8n+JD O5byg4ZrA70g== X-Received: by 2002:a05:6870:b40e:b0:260:3bdb:93a8 with SMTP id 586e51a60fabf-2738be80d00mr5482003fac.41.1724317902989; Thu, 22 Aug 2024 02:11:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFlsf3emyLegp53mLlTvBIvrqRxZ5YLtE1R4y2t+hDDZwSMoxqVJzO4IXWJbE/cXG9M+9cgg== X-Received: by 2002:a05:6870:b40e:b0:260:3bdb:93a8 with SMTP id 586e51a60fabf-2738be80d00mr5481979fac.41.1724317902515; Thu, 22 Aug 2024 02:11:42 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-714342e0a56sm934490b3a.102.2024.08.22.02.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:41 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 05/14] tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485 Date: Thu, 22 Aug 2024 19:11:08 +1000 Message-Id: <20240822091117.1760423-6-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Relocate cdns_uart_tx_empty function to avoid prototype statement in rs485 changes. Update return check with uart_tx_stopped() in cdns_uart_handle_tx(). Signed-off-by: Manikanta Guntupalli Link: https://lore.kernel.org/r/20240123061655.2150946-3-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 74231ab6cc2d02303ddf1fabd878756c52f788a5) Signed-off-by: Portia Stephens --- drivers/tty/serial/xilinx_uartps.c | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 9f9fdd7424bc4..1c26ea4789f51 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -313,7 +313,22 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) } /** - * cdns_uart_handle_tx - Handle the bytes to be Txed. + * cdns_uart_tx_empty - Check whether TX is empty + * @port: Handle to the uart port structure + * + * Return: TIOCSER_TEMT on success, 0 otherwise + */ +static unsigned int cdns_uart_tx_empty(struct uart_port *port) +{ + unsigned int status; + + status = readl(port->membase + CDNS_UART_SR); + status &= (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE); + return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; +} + +/** + * cdns_uart_handle_tx - Handle the bytes to be transmitted. * @dev_id: Id of the UART port * Return: None */ @@ -322,7 +337,8 @@ static void cdns_uart_handle_tx(void *dev_id) struct uart_port *port = (struct uart_port *)dev_id; unsigned int numbytes; - if (uart_circ_empty(&port->state->xmit)) { + if (uart_circ_empty(&port->state->xmit) || uart_tx_stopped(port)) { + /* Disable the TX Empty interrupt */ writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR); } else { numbytes = port->fifosize; @@ -610,6 +626,7 @@ static void cdns_uart_start_tx(struct uart_port *port) if (uart_circ_empty(&port->state->xmit)) return; + /* Clear the TX Empty interrupt */ writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); cdns_uart_handle_tx(port); @@ -649,21 +666,6 @@ static void cdns_uart_stop_rx(struct uart_port *port) writel(regval, port->membase + CDNS_UART_CR); } -/** - * cdns_uart_tx_empty - Check whether TX is empty - * @port: Handle to the uart port structure - * - * Return: TIOCSER_TEMT on success, 0 otherwise - */ -static unsigned int cdns_uart_tx_empty(struct uart_port *port) -{ - unsigned int status; - - status = readl(port->membase + CDNS_UART_SR) & - (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE); - return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; -} - /** * cdns_uart_break_ctl - Based on the input ctl we have to start or stop * transmitting char breaks From patchwork Thu Aug 22 09:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHWw1yX4z1ybW for ; Thu, 22 Aug 2024 19:11:56 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rD-0001Yo-FE; Thu, 22 Aug 2024 09:11:51 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rB-0001WW-Df for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:49 +0000 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 43A4A3F12E for ; Thu, 22 Aug 2024 09:11:49 +0000 (UTC) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-71431f47164so728613b3a.1 for ; Thu, 22 Aug 2024 02:11:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317907; x=1724922707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=frFniUL/CxTbUYvYomGy3HNqq/Vxv6QM2n24fTytqEw=; b=H/TiDYW2mDi1nRPvUf7wgS+ubDTgyWo3DmlYpSGVZJXf7KLVFTTUq2Hqqwwr5Y/HmD 5dM45Q4vzPWw1SySq3IA56DMz0MUt6PH3qveKWYDOmt74A6sQQGBpZEoCXNGYL1f3paF XNi0DQtFw8nIWZD8i8D7WMgTiV6M4GhEB631BrILsx3XzLVnqHMiTVZd8IdOEu5VNPPG HI5DfXiI5sNfLmLKly0CfXCvAUuEO0RhvGgHvXTA7nAUJwLqXc5N/pbsxQ3TZtC+Ua5x x3JHw91UcLYwO5oI8wUWev+d9CMJPKt3aUs/sltSK3lnZzzTFgDywrkvvPiGE0QQQNEr QjEA== X-Gm-Message-State: AOJu0Yy9A80F6afHQWwfC0F/aJzgnxIgPclqorkWvFhmO6aYSe/0YHLz gdmfgfmqM0ld8HrqrNRM9lA1u+1UksKaeqbzAMU8JA9CA3JluYNjNZp6yrSTy1QGBovegVlKwwa E3ZnrEiP0qyS8ZJPILd0+Z3dnLlN/Yda6S6sKK15ZTqk8cz479bOPYoaFwRW1YfD99Rlzo+9hHp 6LuGSi4chBtg== X-Received: by 2002:a05:6a21:478a:b0:1c4:ba7c:741c with SMTP id adf61e73a8af0-1caeb1d90e2mr1439875637.21.1724317907029; Thu, 22 Aug 2024 02:11:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHccDYF13+OlTApFbQ5j3Ruh8hnMXTllXUVonSwbLz9lK1YQ/Dw/MWdcY6VlTYtD+eYLdu/HA== X-Received: by 2002:a05:6a21:478a:b0:1c4:ba7c:741c with SMTP id adf61e73a8af0-1caeb1d90e2mr1439851637.21.1724317906462; Thu, 22 Aug 2024 02:11:46 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d5ebbb1726sm3503448a91.37.2024.08.22.02.11.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:45 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 06/14] tty: serial: uartps: Add rs485 support to uartps driver Date: Thu, 22 Aug 2024 19:11:09 +1000 Message-Id: <20240822091117.1760423-7-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add rs485 support to uartps driver. Use either rts-gpios or RTS to control RS485 phy as driver or a receiver. Signed-off-by: Manikanta Guntupalli Link: https://lore.kernel.org/r/20240123061655.2150946-4-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit fccc9d9233f918ee50cf2955ae7134a7f3418351) Signed-off-by: Portia Stephens --- drivers/tty/serial/xilinx_uartps.c | 200 ++++++++++++++++++++++++++++- 1 file changed, 196 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 1c26ea4789f51..8c8689e387aa4 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -22,7 +22,9 @@ #include #include #include -#include +#include +#include +#include #define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_NAME "xuartps" @@ -193,6 +195,9 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); * @clk_rate_change_nb: Notifier block for clock changes * @quirks: Flags for RXBS support. * @cts_override: Modem control state override + * @gpiod_rts: Pointer to the gpio descriptor + * @rs485_tx_started: RS485 tx state + * @tx_timer: Timer for tx */ struct cdns_uart { struct uart_port *port; @@ -203,10 +208,21 @@ struct cdns_uart { struct notifier_block clk_rate_change_nb; u32 quirks; bool cts_override; + struct gpio_desc *gpiod_rts; + bool rs485_tx_started; + struct hrtimer tx_timer; }; struct cdns_platform_data { u32 quirks; }; + +struct serial_rs485 cdns_rs485_supported = { + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | + SER_RS485_RTS_AFTER_SEND, + .delay_rts_before_send = 1, + .delay_rts_after_send = 1, +}; + #define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \ clk_rate_change_nb) @@ -312,6 +328,55 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) tty_flip_buffer_push(&port->state->port); } +/** + * cdns_rts_gpio_enable - Configure RTS/GPIO to high/low + * @cdns_uart: Handle to the cdns_uart + * @enable: Value to be set to RTS/GPIO + */ +static void cdns_rts_gpio_enable(struct cdns_uart *cdns_uart, bool enable) +{ + u32 val; + + if (cdns_uart->gpiod_rts) { + gpiod_set_value(cdns_uart->gpiod_rts, enable); + } else { + val = readl(cdns_uart->port->membase + CDNS_UART_MODEMCR); + if (enable) + val |= CDNS_UART_MODEMCR_RTS; + else + val &= ~CDNS_UART_MODEMCR_RTS; + writel(val, cdns_uart->port->membase + CDNS_UART_MODEMCR); + } +} + +/** + * cdns_rs485_tx_setup - Tx setup specific to rs485 + * @cdns_uart: Handle to the cdns_uart + */ +static void cdns_rs485_tx_setup(struct cdns_uart *cdns_uart) +{ + bool enable; + + enable = cdns_uart->port->rs485.flags & SER_RS485_RTS_ON_SEND; + cdns_rts_gpio_enable(cdns_uart, enable); + + cdns_uart->rs485_tx_started = true; +} + +/** + * cdns_rs485_rx_setup - Rx setup specific to rs485 + * @cdns_uart: Handle to the cdns_uart + */ +static void cdns_rs485_rx_setup(struct cdns_uart *cdns_uart) +{ + bool enable; + + enable = cdns_uart->port->rs485.flags & SER_RS485_RTS_AFTER_SEND; + cdns_rts_gpio_enable(cdns_uart, enable); + + cdns_uart->rs485_tx_started = false; +} + /** * cdns_uart_tx_empty - Check whether TX is empty * @port: Handle to the uart port structure @@ -327,6 +392,37 @@ static unsigned int cdns_uart_tx_empty(struct uart_port *port) return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; } +/** + * cdns_rs485_rx_callback - Timer rx callback handler for rs485. + * @t: Handle to the hrtimer structure + */ +static enum hrtimer_restart cdns_rs485_rx_callback(struct hrtimer *t) +{ + struct cdns_uart *cdns_uart = container_of(t, struct cdns_uart, tx_timer); + + /* + * Default Rx should be setup, because Rx signaling path + * need to enable to receive data. + */ + cdns_rs485_rx_setup(cdns_uart); + + return HRTIMER_NORESTART; +} + +/** + * cdns_calc_after_tx_delay - calculate delay required for after tx. + * @cdns_uart: Handle to the cdns_uart + */ +static u64 cdns_calc_after_tx_delay(struct cdns_uart *cdns_uart) +{ + /* + * Frame time + stop bit time + rs485.delay_rts_after_send + */ + return cdns_uart->port->frame_time + + DIV_ROUND_UP(cdns_uart->port->frame_time, 7) + + (u64)cdns_uart->port->rs485.delay_rts_after_send * NSEC_PER_MSEC; +} + /** * cdns_uart_handle_tx - Handle the bytes to be transmitted. * @dev_id: Id of the UART port @@ -335,6 +431,7 @@ static unsigned int cdns_uart_tx_empty(struct uart_port *port) static void cdns_uart_handle_tx(void *dev_id) { struct uart_port *port = (struct uart_port *)dev_id; + struct cdns_uart *cdns_uart = port->private_data; unsigned int numbytes; if (uart_circ_empty(&port->state->xmit) || uart_tx_stopped(port)) { @@ -371,6 +468,16 @@ static void cdns_uart_handle_tx(void *dev_id) &port->state->xmit) < WAKEUP_CHARS) uart_write_wakeup(port); } + + /* Enable the TX Empty interrupt */ + writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER); + + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED && + (uart_circ_empty(&port->state->xmit) || uart_tx_stopped(port))) { + cdns_uart->tx_timer.function = &cdns_rs485_rx_callback; + hrtimer_start(&cdns_uart->tx_timer, + ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart)), HRTIMER_MODE_REL); + } } /** @@ -603,6 +710,21 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, } #endif +/** + * cdns_rs485_tx_callback - Timer tx callback handler for rs485. + * @t: Handle to the hrtimer structure + */ +static enum hrtimer_restart cdns_rs485_tx_callback(struct hrtimer *t) +{ + struct cdns_uart *cdns_uart = container_of(t, struct cdns_uart, tx_timer); + + uart_port_lock(cdns_uart->port); + cdns_uart_handle_tx(cdns_uart->port); + uart_port_unlock(cdns_uart->port); + + return HRTIMER_NORESTART; +} + /** * cdns_uart_start_tx - Start transmitting bytes * @port: Handle to the uart port structure @@ -610,6 +732,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, static void cdns_uart_start_tx(struct uart_port *port) { unsigned int status; + struct cdns_uart *cdns_uart = port->private_data; if (uart_tx_stopped(port)) return; @@ -629,10 +752,16 @@ static void cdns_uart_start_tx(struct uart_port *port) /* Clear the TX Empty interrupt */ writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + if (!cdns_uart->rs485_tx_started) { + cdns_uart->tx_timer.function = &cdns_rs485_tx_callback; + cdns_rs485_tx_setup(cdns_uart); + return hrtimer_start(&cdns_uart->tx_timer, + ms_to_ktime(port->rs485.delay_rts_before_send), + HRTIMER_MODE_REL); + } + } cdns_uart_handle_tx(port); - - /* Enable the TX Empty interrupt */ - writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER); } /** @@ -642,6 +771,10 @@ static void cdns_uart_start_tx(struct uart_port *port) static void cdns_uart_stop_tx(struct uart_port *port) { unsigned int regval; + struct cdns_uart *cdns_uart = port->private_data; + + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_rx_setup(cdns_uart); regval = readl(port->membase + CDNS_UART_CR); regval |= CDNS_UART_CR_TX_DIS; @@ -853,6 +986,9 @@ static int cdns_uart_startup(struct uart_port *port) (CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST)) cpu_relax(); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_rx_setup(cdns_uart); + /* * Clear the RX disable bit and then set the RX enable bit to enable * the receiver. @@ -912,6 +1048,10 @@ static void cdns_uart_shutdown(struct uart_port *port) { int status; unsigned long flags; + struct cdns_uart *cdns_uart = port->private_data; + + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) + hrtimer_cancel(&cdns_uart->tx_timer); spin_lock_irqsave(&port->lock, flags); @@ -1057,6 +1197,8 @@ static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) if (mctrl & TIOCM_RTS) val |= CDNS_UART_MODEMCR_RTS; + if (cdns_uart_data->gpiod_rts) + gpiod_set_value(cdns_uart_data->gpiod_rts, !(mctrl & TIOCM_RTS)); if (mctrl & TIOCM_DTR) val |= CDNS_UART_MODEMCR_DTR; if (mctrl & TIOCM_LOOP) @@ -1537,6 +1679,39 @@ static int cdns_get_id(struct platform_device *pdev) return id; } +/** + * cdns_rs485_config - Called when an application calls TIOCSRS485 ioctl. + * @port: Pointer to the uart_port structure + * @termios: Pointer to the ktermios structure + * @rs485: Pointer to the serial_rs485 structure + * + * Return: 0 + */ +static int cdns_rs485_config(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485) +{ + u32 val; + struct cdns_uart *cdns_uart = port->private_data; + + if (rs485->flags & SER_RS485_ENABLED) { + dev_dbg(port->dev, "Setting UART to RS485\n"); + /* Make sure auto RTS is disabled */ + val = readl(port->membase + CDNS_UART_MODEMCR); + val &= ~CDNS_UART_MODEMCR_FCM; + writel(val, port->membase + CDNS_UART_MODEMCR); + + /* Timer setup */ + hrtimer_init(&cdns_uart->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + cdns_uart->tx_timer.function = &cdns_rs485_tx_callback; + + /* Disable transmitter and make Rx setup*/ + cdns_uart_stop_tx(port); + } else { + hrtimer_cancel(&cdns_uart->tx_timer); + } + return 0; +} + /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1674,9 +1849,23 @@ static int cdns_uart_probe(struct platform_device *pdev) port->private_data = cdns_uart_data; port->read_status_mask = CDNS_UART_IXR_TXEMPTY | CDNS_UART_IXR_RXTRIG | CDNS_UART_IXR_OVERRUN | CDNS_UART_IXR_TOUT; + port->rs485_config = cdns_rs485_config; + port->rs485_supported = &cdns_rs485_supported; cdns_uart_data->port = port; platform_set_drvdata(pdev, port); + rc = uart_get_rs485_mode(port); + if (rc) + goto err_out_clk_notifier; + + cdns_uart_data->gpiod_rts = devm_gpiod_get_optional(&pdev->dev, "rts", + GPIOD_OUT_LOW); + if (IS_ERR(cdns_uart_data->gpiod_rts)) { + rc = PTR_ERR(cdns_uart_data->gpiod_rts); + dev_err(port->dev, "xuartps: devm_gpiod_get_optional failed\n"); + goto err_out_clk_notifier; + } + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT); pm_runtime_set_active(&pdev->dev); @@ -1695,6 +1884,8 @@ static int cdns_uart_probe(struct platform_device *pdev) console_port = port; } #endif + if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_rx_setup(cdns_uart_data); rc = uart_add_one_port(&cdns_uart_uart_driver, port); if (rc) { @@ -1723,6 +1914,7 @@ static int cdns_uart_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); +err_out_clk_notifier: #ifdef CONFIG_COMMON_CLK clk_notifier_unregister(cdns_uart_data->uartclk, &cdns_uart_data->clk_rate_change_nb); From patchwork Thu Aug 22 09:11:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHX03kz6z1ybW for ; Thu, 22 Aug 2024 19:12:00 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rI-0001hy-3P; Thu, 22 Aug 2024 09:11:56 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rF-0001cp-W6 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:54 +0000 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CB3BD3F429 for ; Thu, 22 Aug 2024 09:11:53 +0000 (UTC) Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-2700478ee09so742205fac.3 for ; Thu, 22 Aug 2024 02:11:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317911; x=1724922711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JPksqbqZM8R9Zb9unaOr7S9R0u07nkcwmz/+fJop/6M=; b=hVSwOak7M16kpK/8SJMUF5bCwlA0Im5vT5lz9nHudgnMPkhXcxHRwOcpq+PvjHt5MS D46s8pGmJ+lMPRkkrgArOTHuTEJQxCKZ211CNfg8r/chL5cNVB5gpxaUyjAEbrufO4qS EZg42A+8P24WnGqOM01t1yrAhZZ9m+78j2O7nc0DG3p49dsFmLHqjYfuf7mmjaNidjoB 06eXpqYNoA+jMHZMDeFwtHk3rCLb5EstaJlkMm+iyJQvHDnONXXeWe2xRcn/QQ2pd4vE nVZMj1eCQBDtSjCaMeZMxh7g52boEnw70Ax4esUF0fdJ3RcnLwnUs3s91zoToimurI0B kDZQ== X-Gm-Message-State: AOJu0Yysx/I/t7kZBpg+oCmxeEVn/cr28LK8k5w2JcmgLC5R7qDKQEle /UTxnenqVgIBWWaJJqeEsA9uqeuAq21cigDUShadxVZPPAO9ohwxi+eZpyc/oNj8aXm+STnySPJ z4zsq9ubtOzBm8kmgMMd0iJO3Bhbr0dMwpOvSP9iL7oNMdov5WHbtji4CYTVwA1pgBot5VPDtim 4LUCPbF/Qipw== X-Received: by 2002:a05:6871:3a29:b0:260:fbf0:d65c with SMTP id 586e51a60fabf-273cfba9227mr1653226fac.9.1724317911467; Thu, 22 Aug 2024 02:11:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0ZSeCC7mSG+7eJyBzLVDTVxt+SH7g02bDV4bwXXsaS3Fisgt2SqwhMM7IT55jhyY0efFSuA== X-Received: by 2002:a05:6871:3a29:b0:260:fbf0:d65c with SMTP id 586e51a60fabf-273cfba9227mr1653211fac.9.1724317911126; Thu, 22 Aug 2024 02:11:51 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434235f77sm969849b3a.13.2024.08.22.02.11.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:50 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 07/14] dt-bindings: serial: cdns, uart: Add optional reset property Date: Thu, 22 Aug 2024 19:11:10 +1000 Message-Id: <20240822091117.1760423-8-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add optional reset device-tree property to the uartps controller. Signed-off-by: Manikanta Guntupalli Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240425062358.1347684-2-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit cc3236cd758b07c1f36cabd55ea1740f0881faa0) Signed-off-by: Portia Stephens --- Documentation/devicetree/bindings/serial/cdns,uart.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.yaml b/Documentation/devicetree/bindings/serial/cdns,uart.yaml index 140a787d088c4..5ab27f0e290a5 100644 --- a/Documentation/devicetree/bindings/serial/cdns,uart.yaml +++ b/Documentation/devicetree/bindings/serial/cdns,uart.yaml @@ -46,6 +46,9 @@ properties: power-domains: maxItems: 1 + resets: + maxItems: 1 + required: - compatible - reg From patchwork Thu Aug 22 09:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHX35Lmrz1ybW for ; Thu, 22 Aug 2024 19:12:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rL-0001sH-AD; Thu, 22 Aug 2024 09:11:59 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rJ-0001lX-Jj for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:11:57 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 693353F2E7 for ; Thu, 22 Aug 2024 09:11:57 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2035232f929so6533865ad.2 for ; Thu, 22 Aug 2024 02:11:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317915; x=1724922715; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wqyNHcuBfMc5rX/D42RF1B+QRT4oo7UU0Go7ZcdRgag=; b=sqLl0y+KTSwvF/Wo+5FsD75oOat6Pw/wVZR5cO7+ZLfdDp3jq96KEC2ioz2icnQElv oLf3AgjruO5cgCxnHOh/9RduJTY0zCUBV4TvFoXrd4Bre1I6CmR+KNiEcTFx9AimwwA2 TUqHUK7TY6G5I73ePV3vv6+CCdV4+HQO+sIpYW0UYRLXUMUy/W6Cw/1WUAmc8CSAyt8F TIEPsnO4Iu+XxSLNQBUE/C6gYySqdkzn6+n173UHe+HXOIQKuuRoYlY/I8C9RU/l/b3D dNbT37nBxjU/o8AhvaQ87BCY2hEXi4AjXgpXepJhGZbgxWEARCiAz11P1o6nobf5KXdN Ze4w== X-Gm-Message-State: AOJu0YwNKTGnOlqNEkDCn1veOriX8Wy2TdtJ6rymlKKAv3mmc821y9oP i1GNc7BBgNEutSmQvR/TvkjLGbLgXfJWqHpmQJ9MT/POJAbbc9MzNeL+abtTCaAvVUroH+fz876 TTBZEJLjEjP8A+yxYNI00NmFl+2/CLFFvkIX6w6ICfM1g/a5rU3HA6jCVzdQSC8UM0va4tesS8J bOny8gvSdQwA== X-Received: by 2002:a17:902:d488:b0:202:dcd:d44 with SMTP id d9443c01a7336-203681f1bacmr53972755ad.54.1724317915340; Thu, 22 Aug 2024 02:11:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcOBSmUS25eJYRcip5xQqZuDMPxpUwAZrOWZ3LRJcbgk62Tu+GTVDq7w/DhojJGYh0ED4Y+g== X-Received: by 2002:a17:902:d488:b0:202:dcd:d44 with SMTP id d9443c01a7336-203681f1bacmr53972625ad.54.1724317914960; Thu, 22 Aug 2024 02:11:54 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385566568sm8410685ad.37.2024.08.22.02.11.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:54 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 08/14] arm64: zynqmp: Add resets property for UART nodes Date: Thu, 22 Aug 2024 19:11:11 +1000 Message-Id: <20240822091117.1760423-9-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add resets property for UART0 and UART1 nodes Signed-off-by: Manikanta Guntupalli Link: https://lore.kernel.org/r/20240425062358.1347684-3-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit b4337685010990385901405cc317a5a46b147b5a) Signed-off-by: Portia Stephens --- arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi index 2c59088ceeb1e..b319b864fba3a 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi @@ -965,6 +965,7 @@ uart0: serial@ff000000 { reg = <0x0 0xff000000 0x0 0x1000>; clock-names = "uart_clk", "pclk"; power-domains = <&zynqmp_firmware PD_UART_0>; + resets = <&zynqmp_reset ZYNQMP_RESET_UART0>; }; uart1: serial@ff010000 { @@ -976,6 +977,7 @@ uart1: serial@ff010000 { reg = <0x0 0xff010000 0x0 0x1000>; clock-names = "uart_clk", "pclk"; power-domains = <&zynqmp_firmware PD_UART_1>; + resets = <&zynqmp_reset ZYNQMP_RESET_UART1>; }; usb0: usb@ff9d0000 { From patchwork Thu Aug 22 09:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHX74szqz1ybW for ; Thu, 22 Aug 2024 19:12:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rP-00023M-61; Thu, 22 Aug 2024 09:12:03 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rN-0001zs-RJ for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:01 +0000 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 823923F12E for ; Thu, 22 Aug 2024 09:12:01 +0000 (UTC) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-7143b3025caso210819b3a.2 for ; Thu, 22 Aug 2024 02:12:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317919; x=1724922719; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/MSw51EUDYOmZPJIwMNkRtN3LLOiGtGtUREXozuu9Xo=; b=MCC3Li2H5/TOFiVuVvZj18BV4B7uLFl8qiFhgR+z4uGBwn72I2pqgyHL1AVBXfxtsk scKpz5xw26CKMJ5NSulRwrsY+t3CFNKP9bFStXzSd4scAWSnlORzcesjDXli+uuRdREz sybJmluAiZ290pA76mbWx0dGEZ6d687XthbwnP+aATCgD7O32DS2JKWHQsgC99JPkMXw SaWlL0AHRDnw3SQZ/wKnBAtgvUrTaLSX9FfktnIoQUlBN2Olc/rwkskYVrxg4fxNPkWV gVK3RuItIN7fyyvMGD7Qi0bhw/bsYMFY2xaKRvoKVghAJi2AYqnbHxe3heXqkGnX8of7 DIJA== X-Gm-Message-State: AOJu0YwkgQ+de4B0PTHAAvxNBN0o39VTeVoVC4Zl7e6dH5RG/hS5/RPd nJDrwBY46qdyFhyq9f+5LJmpV5JxskRRBMUCJJ1L+se4kwyMIKKHajeVP0ijbTdClcSj4tY6ZsG 6opX7rlXPTQ07miTxQnsUiHbCk/dnadcWhNNL9DHIw+GKRbdYrW7bb1BzUqbL9CeU4sBLYnWKsi RoUwy6r6/YGg== X-Received: by 2002:a05:6a21:3418:b0:1c6:f043:693f with SMTP id adf61e73a8af0-1cada054f37mr5522189637.17.1724317919520; Thu, 22 Aug 2024 02:11:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL7jlMYsxtXM4FwNIkEV+MRhljbgiVbGJTJ7UQo0FZKUTGsrxthaqju8Wvp5m+wcFWtsh7yw== X-Received: by 2002:a05:6a21:3418:b0:1c6:f043:693f with SMTP id adf61e73a8af0-1cada054f37mr5522175637.17.1724317919084; Thu, 22 Aug 2024 02:11:59 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385bdca50sm8335085ad.245.2024.08.22.02.11.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:11:58 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 09/14] tty: serial: uartps: Add support for uartps controller reset Date: Thu, 22 Aug 2024 19:11:12 +1000 Message-Id: <20240822091117.1760423-10-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add support for an optional reset for the uartps controller using the reset driver. If the uartps node contains the "resets" property, then cdns_uart_startup performs uartps controller non-pulse out of reset and reset in exit path. Signed-off-by: Manikanta Guntupalli Link: https://lore.kernel.org/r/20240425062358.1347684-4-manikanta.guntupalli@amd.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit e3896be240780ccade65cc6cc8925c6f12e7f6c6) Signed-off-by: Portia Stephens --- drivers/tty/serial/xilinx_uartps.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 8c8689e387aa4..7aa2595b0f9ad 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -25,6 +25,7 @@ #include #include #include +#include #define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_NAME "xuartps" @@ -198,6 +199,7 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); * @gpiod_rts: Pointer to the gpio descriptor * @rs485_tx_started: RS485 tx state * @tx_timer: Timer for tx + * @rstc: Pointer to the reset control */ struct cdns_uart { struct uart_port *port; @@ -211,6 +213,7 @@ struct cdns_uart { struct gpio_desc *gpiod_rts; bool rs485_tx_started; struct hrtimer tx_timer; + struct reset_control *rstc; }; struct cdns_platform_data { u32 quirks; @@ -970,6 +973,10 @@ static int cdns_uart_startup(struct uart_port *port) is_brk_support = cdns_uart->quirks & CDNS_UART_RXBS_SUPPORT; + ret = reset_control_deassert(cdns_uart->rstc); + if (ret) + return ret; + spin_lock_irqsave(&port->lock, flags); /* Disable the TX and RX */ @@ -1796,6 +1803,13 @@ static int cdns_uart_probe(struct platform_device *pdev) dev_err(&pdev->dev, "clock name 'ref_clk' is deprecated.\n"); } + cdns_uart_data->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + if (IS_ERR(cdns_uart_data->rstc)) { + rc = PTR_ERR(cdns_uart_data->rstc); + dev_err_probe(&pdev->dev, rc, "Cannot get UART reset\n"); + goto err_out_unregister_driver; + } + rc = clk_prepare_enable(cdns_uart_data->pclk); if (rc) { dev_err(&pdev->dev, "Unable to enable pclk clock.\n"); @@ -1967,6 +1981,7 @@ static int cdns_uart_remove(struct platform_device *pdev) if (console_port == port) console_port = NULL; #endif + reset_control_assert(cdns_uart_data->rstc); if (!--instances) uart_unregister_driver(cdns_uart_data->cdns_uart_driver); From patchwork Thu Aug 22 09:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975372 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHXD4wX0z1ybW for ; Thu, 22 Aug 2024 19:12:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rT-0002DL-KN; Thu, 22 Aug 2024 09:12:07 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rR-0002A8-Ra for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:05 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id AA7E43F2E7 for ; Thu, 22 Aug 2024 09:12:05 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-70eebcab33aso574680b3a.1 for ; Thu, 22 Aug 2024 02:12:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317923; x=1724922723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nAh+yoUMwuhHh0vEn8KeHkVP2il7FZrXygGh/EZmjo0=; b=tEeV1UsvDfTTeDYcEoDueqZf69HXyONt6C21xtFQM1MztGA04gz9GGjJxjURGrPmZD liJsGxxVS3GkXL23U4EjnTKnz8Bc3nfmxqwYyKMmng/W0o/pJ7vOK/nzFg2uRLpA1pKa iLiTkgGgKushqtcmsjHnvUTav/j0Z9YUvaHbYLJfp5oBqntiPagJmTW/QqtZlQIvRDLw Ty/JznF7xrnpcQesOYNxg8BdL1s3y/kg9FVJ+jzU2h4DCBf8vSRS3ADg3GC7+t880bkM lA5y+l/H9cybckdOMKBXPCRkVRxRW6p6ZAFw8UJmI6YBIsy6/vsMIvqy0rXDKl5SZvAi z6nA== X-Gm-Message-State: AOJu0YymLSZxARvfIhnetHvCOipOV+CJTWvpgB12KNoEw/0XBGg91dku paPwi7RGujiO+0KPIrwV9FUbPkMRyky9IZtCplzGzX9DawrnHKHTpxwrfIF5AQt83dra95I4Bib ZjmMIzAmS6vv6yC5IKF5ifOrmCumve/cmzcLPrHP6LHKEqH9/wcwVg9+R5SJvCelof7kqXjeWsY W/DNNEXqQVFQ== X-Received: by 2002:a05:6a00:21d0:b0:714:209c:4371 with SMTP id d2e1a72fcca58-7142376a1e3mr4796794b3a.10.1724317923507; Thu, 22 Aug 2024 02:12:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn5yPjAPQxuaHoe5qncN/2TJZNLfm2tv8ani0mtEtVkWzU2Soai/EvXLKTFCTZ/549HOBHfg== X-Received: by 2002:a05:6a00:21d0:b0:714:209c:4371 with SMTP id d2e1a72fcca58-7142376a1e3mr4796777b3a.10.1724317923057; Thu, 22 Aug 2024 02:12:03 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-714340d06c5sm952443b3a.0.2024.08.22.02.12.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:12:02 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 10/14] UBUNTU: SAUCE: dts: zynqmp-sck-kd-g-revA: Enable uart0 for KD240 Date: Thu, 22 Aug 2024 19:11:13 +1000 Message-Id: <20240822091117.1760423-11-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Wen-chien Jesse Sung BugLink: https://bugs.launchpad.net/bugs/2055237 This is backported from commit 1dfb4885eaa3 linux-xlnx. This change comes from a large syncing commit so this commit pulls out only the required changes to enabled uart0. Signed-off-by: Portia Stephens --- .../boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts index 94cb63cc6a186..6bfb2594bda8c 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts +++ b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts @@ -171,6 +171,30 @@ conf-tx { }; }; + pinctrl_uart0_default: uart0-default { + conf { + groups = "uart0_17_grp"; + slew-rate = ; + power-source = ; + drive-strength = <12>; + }; + + conf-rx { + pins = "MIO70"; + bias-high-impedance; + }; + + conf-tx { + pins = "MIO71"; + bias-disable; + }; + + mux { + groups = "uart0_17_grp"; + function = "uart0"; + }; + }; + pinctrl_uart1_default: uart1-default { conf { groups = "uart1_9_grp"; @@ -321,6 +345,13 @@ mux { }; }; +&uart0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart0_default>; + assigned-clock-rates = <100000000>; +}; + &uart1 { status = "okay"; pinctrl-names = "default"; From patchwork Thu Aug 22 09:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHXJ194Zz1ybW for ; Thu, 22 Aug 2024 19:12:16 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rX-0002Mm-Pp; Thu, 22 Aug 2024 09:12:11 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rW-0002Hy-11 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:10 +0000 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id EA4A73F12E for ; Thu, 22 Aug 2024 09:12:09 +0000 (UTC) Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-709664a6285so606317a34.3 for ; Thu, 22 Aug 2024 02:12:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317927; x=1724922727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y0Yghu4x8GLyGNPr3Fql8N5BUZMrBiFfSa7o9elxKCw=; b=R1PKgj8TOd184u2dyq13b8oKrxv0lrZBmfhROjzqZdB7kNSE4ztYQp4UnIZKEcDLhj tTiPzG8T2yWShCaY5jTPFAlVLVLL0USEdIAXUQHYPD1EPOCzyDHIqVOQxOv/qIiXb8qq YMhZuIdt05wlEjO7Ne1GIC8wvsRxKAxqgNIBhXlziYFiSNOjShw2zMoW8ltEtOcuMqLi cBprPQLbOLspgo5JRgWLmABQY2pLW3PX7uLxEznNq4El5YN0ePpP+EgANtbobXMQCRqz GQnwrc/YtvkuJR1YL0Njf3T2kAaMaZybXsNkDKgC9WMmq6pdpFG3ua0Jvfg+JmyiSXdQ VgvQ== X-Gm-Message-State: AOJu0YxJ/YNIS/RQ58JjhIdb6iiTPT0TYLFNtAM2ExkM870D8DAr+AY9 RpahSgPj8EIQ3ehvUVCaxSdseei8DBB5EeKoEuDBVNZc9M2mB0QXelbMb0Alpvx6rjx0T5EBeDZ ZjlN9bOMV6NkmPmZ/N8AoRTBHu001Uu0VGHNrTODyt9u/7DoOHTpOLWYCKr293lB0Ua8ISpjhj5 qck+tAh4sBLA== X-Received: by 2002:a05:6808:2e8c:b0:3d9:33e9:e339 with SMTP id 5614622812f47-3de194e7d5amr6377034b6e.9.1724317927726; Thu, 22 Aug 2024 02:12:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhq1A7aiL0qlrDAAfNvcsu0cLfkkvQM496mpy//xiXdBxBh2tg/yrDr47+oLEeGmXgCqPdtA== X-Received: by 2002:a05:6808:2e8c:b0:3d9:33e9:e339 with SMTP id 5614622812f47-3de194e7d5amr6377021b6e.9.1724317927409; Thu, 22 Aug 2024 02:12:07 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ad6e563sm925978a12.81.2024.08.22.02.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:12:06 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 11/14] arm64: zynqmp: dts: Add required properties for rs485 support for KD240 Date: Thu, 22 Aug 2024 19:11:14 +1000 Message-Id: <20240822091117.1760423-12-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add "rts-gpios" and "linux,rs485-enabled-at-boot-time" properties to uartps node to support RS485 on KD240. Signed-off-by: Manikanta Guntupalli State: pending (cherry picked from git@github.com:Xilinx/linux-xlnx.git xlnx_rebase_v6.6) Signed-off-by: Portia Stephens --- arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts index 6bfb2594bda8c..5cd7ed12dd079 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts +++ b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts @@ -347,6 +347,8 @@ mux { &uart0 { status = "okay"; + rts-gpios = <&gpio 72 GPIO_ACTIVE_HIGH>; + linux,rs485-enabled-at-boot-time; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart0_default>; assigned-clock-rates = <100000000>; From patchwork Thu Aug 22 09:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975374 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHXN44q1z1ybW for ; Thu, 22 Aug 2024 19:12:20 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rc-0002aC-Bj; Thu, 22 Aug 2024 09:12:16 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3ra-0002TQ-4B for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:14 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F03303F2E7 for ; Thu, 22 Aug 2024 09:12:13 +0000 (UTC) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2d441cdb503so681141a91.1 for ; Thu, 22 Aug 2024 02:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317932; x=1724922732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hPHplbLd5+0bfeoE12qDNtXYuP7kEWH9PLQ4aS9Y04k=; b=KwW2O0JPUx9hxrKh7bwcqckCQWL4rMZy4qOolBYsjScBCN7xMzxke5VmOxR4aQjiyF EZ9Puo6xBx22NfkJxpJ7GjrRChD3KSHZTDORRw1nuw6toVnsdCqdGIavnMzY00AVtZ3L XEyHF77tzzlNFnUr5LduDkJugszhQ4gs7BIWr+GTXkxZfiEJlG0F0ZvtxDzLLjSO4d5s EU2Xqhu90tlt6WHKw5w56JWuYp/DDqZCPtvlWLvbFx39CHKezvmuhblWefedw50g+MKz PE9mRt75aixvqaJSmUxovXjwoVX7ec8EHss959qXCjZh9XGbiNnQXsqH/Ot44ETeweBR XimA== X-Gm-Message-State: AOJu0YwsqBOVuKeFrtaDJr9MjmdYgMlmL7ZckxILcE2Ib/I1ZOsmauRg KgxkmE92qUGE40jYur40JzpGxBIb7UGHCNlHe/DB5hk+kkzBmEpl7TRgmmmBecYniTvpBnqrLzg 7CQ2v1NFa+6x6HXaTpimAZjoPSqhhHZfwGPbHL3yAltgLF34SNmp00Iu4MWtNT0lkn+mKEYkOkU l/JfCBrbIZ6A== X-Received: by 2002:a17:90a:8914:b0:2c9:e0d3:1100 with SMTP id 98e67ed59e1d1-2d616b284edmr1228387a91.19.1724317931639; Thu, 22 Aug 2024 02:12:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9Gy1aHfrKXjEKMOu41CFqEdZRubj494RfjwX05LrGUXqa4MImPEpbttRJu0mUA1T1hbmXjg== X-Received: by 2002:a17:90a:8914:b0:2c9:e0d3:1100 with SMTP id 98e67ed59e1d1-2d616b284edmr1228368a91.19.1724317931232; Thu, 22 Aug 2024 02:12:11 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d5ebbb1726sm3504381a91.37.2024.08.22.02.12.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:12:10 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 12/14] arm64: zynqmp: dts: Add rts delay property for rs485 mode on KD240 Date: Thu, 22 Aug 2024 19:11:15 +1000 Message-Id: <20240822091117.1760423-13-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Manikanta Guntupalli BugLink: https://bugs.launchpad.net/bugs/2055237 Add "rs485-rts-delay" property to uartps node with delay_rts_before_send and delay_rts_after_send values as 10ms for rs485 mode on KD240. 10ms rts delay values have been chosen based on testing with rs485 temperature sensor (which is part of the kit) as safe minimum value for reliable operation at a baud rate of 9600. Signed-off-by: Manikanta Guntupalli State: pending (cherry picked from git@github.com:Xilinx/linux-xlnx.git xlnx_rebase_v6.6) Signed-off-by: Portia Stephens --- arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts index 5cd7ed12dd079..1d41b4061b2cc 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts +++ b/arch/arm64/boot/dts/xilinx/zynqmp-sck-kd-g-revA.dts @@ -349,6 +349,7 @@ &uart0 { status = "okay"; rts-gpios = <&gpio 72 GPIO_ACTIVE_HIGH>; linux,rs485-enabled-at-boot-time; + rs485-rts-delay = <10 10>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart0_default>; assigned-clock-rates = <100000000>; From patchwork Thu Aug 22 09:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975375 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHXR5pClz1ybW for ; Thu, 22 Aug 2024 19:12:23 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rf-0002i2-HF; Thu, 22 Aug 2024 09:12:19 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3re-0002ep-A7 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:18 +0000 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 2D8A13F2E7 for ; Thu, 22 Aug 2024 09:12:18 +0000 (UTC) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-7142a78918bso723647b3a.0 for ; Thu, 22 Aug 2024 02:12:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317935; x=1724922735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xS1eKNPA0tyb4VTzl46pt6MIA7PfATQ6sSxMp7YMzaU=; b=whmIGGjbv2HgMFt+Jj2Vj7pAmf1lXdEGDf2MTahZnZdSu+2fUmC0AYohF1EiTnP2fN otGE9o6hrE5YrPHCOWbo2SXyNz3YlVRt7zv3k267iH45Lz5yBQwrOelx5oOqPcna4AG6 NiOJJ/Gj/7AB4GmDojAWvhy5Bb3Q9ahtki0++SYZJI7ueWTVrCOpKvCateVrAAJYBK/y /0iTZaXRgAmsn9D3TqWYXJ3Afii8TZC4S9RRZy5qlQ97PD1y7gXLZ2E9+vGGv+CckAdT p48UOT8mbmBe9qeLyya/0jEeMsjzgZC/pXvKJisvCCP44oHgwmAQeHXx5pMpOhdbVAds sBkw== X-Gm-Message-State: AOJu0YySDr1SIb021qAe6HxknKysQj0mwunoyRd7dOURYQy8RyzFTelq aNXSUIhZktCXH+DqDAXKHTzYQo/uzOZ+vnECdaUhyL36Xl6jhU1ScKEzhkPm4rwGgGIuJq4Aq8E A/gc8BuRuJBkVAtJa/44HIg01tuFmVnxd/2c/4u1HM/+gNjISaiSgIxAiAfRKdNlOqeyEXSMzYy RZpJYP7dYoCg== X-Received: by 2002:a05:6a21:4581:b0:1c4:c449:41e6 with SMTP id adf61e73a8af0-1caeb2410d2mr1136309637.31.1724317935627; Thu, 22 Aug 2024 02:12:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlK+aqZSXxANz4VST/jKPvuCjpoJ2BfcG2u+gj6+qCx2KpZK3F0N6ue625YM1Md6scLzX4/Q== X-Received: by 2002:a05:6a21:4581:b0:1c4:c449:41e6 with SMTP id adf61e73a8af0-1caeb2410d2mr1136294637.31.1724317935246; Thu, 22 Aug 2024 02:12:15 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d6136fef1bsm1203002a91.4.2024.08.22.02.12.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:12:14 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 13/14] serial: 8250: Document termios parameter of serial8250_em485_config() Date: Thu, 22 Aug 2024 19:11:16 +1000 Message-Id: <20240822091117.1760423-14-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Geert Uytterhoeven BugLink: https://bugs.launchpad.net/bugs/2055237 With W=1: drivers/tty/serial/8250/8250_port.c:679: warning: Function parameter or member 'termios' not described in 'serial8250_em485_config' Fix this by documenting the parameter. Fixes: ae50bb2752836277 ("serial: take termios_rwsem for ->rs485_config() & pass termios as param") Signed-off-by: Geert Uytterhoeven Reviewed-by: Jiri Slaby Link: https://lore.kernel.org/r/2bd1e62be1d5d33333002910372feecc6d52e78f.1682071013.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman (cherry picked from f16182ed9d8430adfab77f5929c23756c94b0230) Signed-off-by: Portia Stephens --- drivers/tty/serial/8250/8250_port.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index d7dd643661265..4b3c81e916cf9 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -653,6 +653,7 @@ EXPORT_SYMBOL_GPL(serial8250_em485_destroy); /** * serial8250_em485_config() - generic ->rs485_config() callback * @port: uart port + * @termios: termios structure * @rs485: rs485 settings * * Generic callback usable by 8250 uart drivers to activate rs485 settings From patchwork Thu Aug 22 09:11:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1975376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqHXX5Lrgz1ybW for ; Thu, 22 Aug 2024 19:12:28 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sh3rj-0002uY-Lf; Thu, 22 Aug 2024 09:12:23 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sh3rh-0002nd-L3 for kernel-team@lists.ubuntu.com; Thu, 22 Aug 2024 09:12:21 +0000 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 796B83F12E for ; Thu, 22 Aug 2024 09:12:21 +0000 (UTC) Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-2701eeb69f4so509543fac.3 for ; Thu, 22 Aug 2024 02:12:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724317940; x=1724922740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gNFkCXacIUh/+8/dZu2Ck1s3NR3JPoQH/EjsiZQupNw=; b=LbFBzie3X5jRSRW1brEYokkWuQZGjabMM1pFY0wrWt8xbP5vmey/ZPMtS3xZKvK6wr daGMIofA4+yAfGcLttGKzyLsHuSN1ycWRmQb44pirDqUGSxKz/r5dAZF0zhemp8PZsC2 L4gXdQl6EK89tOkBRCDVp6jKDpUz/gcIBv6nuGz7J09s0qKSrbOwDH78lP8b2vHHxVXj jc9Sphw0bYZutPU9u2YXsLUphZclMllpCTWQU6apTy0yBw3MyQ4NeVsxlPNol59aYezb c0xFSwBYFAUTQCprkjO/EgjFF/EVnSaUPzAFOXVunT+7znTZNBwvM9C2+uOCpbiZfIkJ 3sBQ== X-Gm-Message-State: AOJu0YwwHI/OSKY8YwpkMHkPXqPjX9iFtSQh/wMKUo9EH4TWpArA4fK+ oG4qHm2+I/EY5LwH2jHw+3TD5+c7Y+f8a0ZzkGRwDdMHoq9Ox36WmVHLqjK0hdqPVuOQ/NZ23yk mgyt4XvdDRhWZHPJzlck9w+gWYWo+PuIvoiWCKWWgtxgSPdrawD1PR4MZEjYdszJMAvf2WB88VP wWhi6I/LeAyg== X-Received: by 2002:a05:6870:f218:b0:260:ffaf:8126 with SMTP id 586e51a60fabf-2737eec8b51mr5570085fac.9.1724317939748; Thu, 22 Aug 2024 02:12:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp7aDqvN+VsxUWmjF+pbSBUUtpRY8yjpQmkUv+sQkFIrxYzvotgi1fFQmcMoj/7COpI0KJ4A== X-Received: by 2002:a05:6870:f218:b0:260:ffaf:8126 with SMTP id 586e51a60fabf-2737eec8b51mr5570074fac.9.1724317939438; Thu, 22 Aug 2024 02:12:19 -0700 (PDT) Received: from localhost ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-714342731acsm944144b3a.88.2024.08.22.02.12.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 02:12:18 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [SRU] [jammy:linux-xilinx-zynqmp 14/14] serial: fix TIOCSRS485 locking Date: Thu, 22 Aug 2024 19:11:17 +1000 Message-Id: <20240822091117.1760423-15-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822091117.1760423-1-portia.stephens@canonical.com> References: <20240822091117.1760423-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Johan Hovold BugLink: https://bugs.launchpad.net/bugs/2055237 The RS485 multipoint addressing support for some reason added a new ADDRB termios cflag which is (only!) updated from one of the RS485 ioctls. Make sure to take the termios rw semaphore for the right ioctl (i.e. set, not get). Fixes: ae50bb275283 ("serial: take termios_rwsem for ->rs485_config() & pass termios as param") Cc: stable@vger.kernel.org # 6.0 Cc: Ilpo Järvinen Reviewed-by: Ilpo Järvinen Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20230412124811.11217-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman (cherry picked from 9e4f2a8004213339e9d837d891a59cc80e082966) Signed-off-by: Portia Stephens --- drivers/tty/serial/serial_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2170721186f6b..d90184953977c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1445,7 +1445,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) goto out; /* rs485_config requires more locking than others */ - if (cmd == TIOCGRS485) + if (cmd == TIOCSRS485) down_write(&tty->termios_rwsem); mutex_lock(&port->mutex); @@ -1488,7 +1488,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) } out_up: mutex_unlock(&port->mutex); - if (cmd == TIOCGRS485) + if (cmd == TIOCSRS485) up_write(&tty->termios_rwsem); out: return ret;