From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18288C4167D for ; Fri, 25 Nov 2022 13:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiKYNFf (ORCPT ); Fri, 25 Nov 2022 08:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiKYNFY (ORCPT ); Fri, 25 Nov 2022 08:05:24 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1473E2A253; Fri, 25 Nov 2022 05:05:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381523; x=1700917523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4vgVjpU9TM3c0NS17ZVh5x8n1rUnhEw0wd9aDkvz4nk=; b=jzmKeMMV0bFmDJAgLoCn50PQY3tQc2Yw0LddmwEt16ooYYi7B+N3wIOb TDjU1ikC/NJJiSYgFKo2sNU/ucwcc1hfPtv/5/5qEfSe4boKUIyCFfnQP xk92YnUvbWcLZcUQ/kZaXrao55bLRzl16ZlEN+4qAtoL7ZQigzKRDadrB IEW5CQ7uGTS0LgjsREtN8pd6eBmZNwK5w/gQSyxGXrVoISUD6yaGreBJo EXFFpBLqTk+hz/AAGu/+RQDWqSrCkm2fysvM/NA7+BusKZAPlAti2EIrp 0iWFVNQkzcxrn1xD/dXc9dyp1AgZNVQB/JHOeWETZ0n6T9wjn222CaGP5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300766" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300766" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:22 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064018" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064018" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:20 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 1/6] serial: 8250: Use defined IER bits Date: Fri, 25 Nov 2022 15:05:04 +0200 Message-Id: <20221125130509.8482-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of literal 0x0f, add a define for enabling all IER bits the 8250 driver is interested in. Don't make the define for combined flags part of UAPI. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 10 +++++----- include/linux/serial.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index beba8f38b3dc..8676f8b7f2e3 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1236,14 +1236,14 @@ static void autoconfig(struct uart_8250_port *up) * Mask out IER[7:4] bits for test as some UARTs (e.g. TL * 16C754B) allow only to modify them if an EFR bit is set. */ - scratch2 =3D serial_in(up, UART_IER) & 0x0f; - serial_out(up, UART_IER, 0x0F); + scratch2 =3D serial_in(up, UART_IER) & UART_IER_ALL_INTR; + serial_out(up, UART_IER, UART_IER_ALL_INTR); #ifdef __i386__ outb(0, 0x080); #endif - scratch3 =3D serial_in(up, UART_IER) & 0x0f; + scratch3 =3D serial_in(up, UART_IER) & UART_IER_ALL_INTR; serial_out(up, UART_IER, scratch); - if (scratch2 !=3D 0 || scratch3 !=3D 0x0F) { + if (scratch2 !=3D 0 || scratch3 !=3D UART_IER_ALL_INTR) { /* * We failed; there's nothing here */ @@ -1394,7 +1394,7 @@ static void autoconfig_irq(struct uart_8250_port *up) serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2); } - serial_out(up, UART_IER, 0x0f); /* enable all intrs */ + serial_out(up, UART_IER, UART_IER_ALL_INTR); serial_in(up, UART_LSR); serial_in(up, UART_RX); serial_in(up, UART_IIR); diff --git a/include/linux/serial.h b/include/linux/serial.h index 3d6fe3ef92cf..ad6e1c37e2d5 100644 --- a/include/linux/serial.h +++ b/include/linux/serial.h @@ -12,6 +12,11 @@ #include #include =20 +#define UART_IER_ALL_INTR (UART_IER_MSI | \ + UART_IER_RLSI | \ + UART_IER_THRI | \ + UART_IER_RDI) + /* Helper for dealing with UART_LCR_WLEN* defines */ #define UART_LCR_WLEN(x) ((x) - 5) =20 --=20 2.30.2 From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 712B8C43217 for ; Fri, 25 Nov 2022 13:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbiKYNFd (ORCPT ); Fri, 25 Nov 2022 08:05:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbiKYNF2 (ORCPT ); Fri, 25 Nov 2022 08:05:28 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E7C2B258; Fri, 25 Nov 2022 05:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381525; x=1700917525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=382hEEQ4aybhmi7q6KqC+mBW2YH4NFBL19G2ZyJJaHk=; b=NOPLbaZzR+Ww3HAfqB+WvtMxLkrTlwz/1nVi/Ka6Z1yxBhI07USp8UMc XETxdLg4vfhEdyyCqqOVqpyzoLG1uL9pRPr78qNayXYfvu3APfPoH9OMW XOaRfpyrRT4SNPvdxHNhiOaWFG3ECSmWyRk2f1eNfDg7dHIRuLtDtOuC5 1l8FcdlROuJki6LuQa+w+8WYennjcL5wdm5ECXayFDENymBAmYplvNK97 TkdtoqNLX8PHVgi0eq0zxaZP7fkjTvAv+vEW4i460f6+5+L0rGy4Sc7L/ s+Iqh6NETjkySMp6/l67fIqMzf+/m8ZmuzUqwAoEO+Pq+OWrUgJnadjj0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300773" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300773" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064021" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064021" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:23 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 2/6] serial: 8250: Name MSR literals Date: Fri, 25 Nov 2022 15:05:05 +0200 Message-Id: <20221125130509.8482-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add UART_MSR_STATUS_BITS for CD, RI, DSR & CTS. Use names for the literal. Don't make the define for combined flags part of UAPI. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 4 ++-- include/linux/serial.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index 8676f8b7f2e3..c870ee8e80b6 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1268,9 +1268,9 @@ static void autoconfig(struct uart_8250_port *up) */ if (!(port->flags & UPF_SKIP_TEST)) { serial8250_out_MCR(up, UART_MCR_LOOP | 0x0A); - status1 =3D serial_in(up, UART_MSR) & 0xF0; + status1 =3D serial_in(up, UART_MSR) & UART_MSR_STATUS_BITS; serial8250_out_MCR(up, save_mcr); - if (status1 !=3D 0x90) { + if (status1 !=3D (UART_MSR_DCD | UART_MSR_CTS)) { spin_unlock_irqrestore(&port->lock, flags); DEBUG_AUTOCONF("LOOP test failed (%02x) ", status1); diff --git a/include/linux/serial.h b/include/linux/serial.h index ad6e1c37e2d5..bfda927dde15 100644 --- a/include/linux/serial.h +++ b/include/linux/serial.h @@ -28,6 +28,11 @@ static inline bool uart_lsr_tx_empty(u16 lsr) return (lsr & UART_LSR_BOTH_EMPTY) =3D=3D UART_LSR_BOTH_EMPTY; } =20 +#define UART_MSR_STATUS_BITS (UART_MSR_DCD | \ + UART_MSR_RI | \ + UART_MSR_DSR | \ + UART_MSR_CTS) + /* * Counters of the input lines (CTS, DSR, RI, CD) interrupts */ --=20 2.30.2 From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F9ECC4332F for ; Fri, 25 Nov 2022 13:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbiKYNFr (ORCPT ); Fri, 25 Nov 2022 08:05:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbiKYNF2 (ORCPT ); Fri, 25 Nov 2022 08:05:28 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6262A95A; Fri, 25 Nov 2022 05:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381528; x=1700917528; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0HfKkgykKh/w7L9JZtBdMwCI7ryGACxBBLi2kGimSAk=; b=C2VP7sqw9puitksVBdsz1CMT3lpGmx6frpeROSbUDcfTgvRE+cuCLC7G 3V0w7+FRqgHm1iVEnWgmYZFLBLihxipep/hRs7swN8z/s972lkzeKT4L8 h2jFJS6+EG9q0GVQUMPRf69afqDt5YXEC66kB00sB1I6a62a6J4uY6csB jR/vGj7Epx1lO2IV4d06C8zyMmVmKl4p3g1ZRNaDueE4X3qWLjvL/Fxut 1RuSS6qEdzt8SRpBdQKiVsofQBf06Mc7r8ldm+v1I5dV25F+HfW9lQ7jK vjsPi33bGnaSjFxY6vFirTjss+zZrMYmScgneIKTMw83zMUG/0RVwWkwd A==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300781" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300781" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:27 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064030" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064030" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:26 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 3/6] serial: 8250: Cleanup MCR literals Date: Fri, 25 Nov 2022 15:05:06 +0200 Message-Id: <20221125130509.8482-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use proper names from MCR bits. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index c870ee8e80b6..e79bf2afd9be 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1267,7 +1267,7 @@ static void autoconfig(struct uart_8250_port *up) * that conflicts with COM 1-4 --- we hope! */ if (!(port->flags & UPF_SKIP_TEST)) { - serial8250_out_MCR(up, UART_MCR_LOOP | 0x0A); + serial8250_out_MCR(up, UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_RTS); status1 =3D serial_in(up, UART_MSR) & UART_MSR_STATUS_BITS; serial8250_out_MCR(up, save_mcr); if (status1 !=3D (UART_MSR_DCD | UART_MSR_CTS)) { --=20 2.30.2 From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ED33C4332F for ; Fri, 25 Nov 2022 13:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbiKYNFo (ORCPT ); Fri, 25 Nov 2022 08:05:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiKYNFb (ORCPT ); Fri, 25 Nov 2022 08:05:31 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9354C2A417; Fri, 25 Nov 2022 05:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381530; x=1700917530; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JyK1IkOeQHocT9IrUkcXubj5M8zAIvA2Nbr+c5YEM98=; b=mavMDgXaSx1p8ckmtBJ3rnkX/8fX6hxgQIAyLAkD/o6tWoD8sL4ryVN7 raTnsf7se5Yak6u1E7dSUJE4gd6XjoQMYNKqljb1bZL0e7R4JGtqFvm4T FMu3idA2oct9Cj1l0GVTOhqCNA42HTIr2xe+At7x7UEcr9EFxt05gwRuI yeOAvsa1nYKrKSCx3ADX17Hdnkmpg3n8HFH/SOH8Hzb9Vf4mFenRkuInB JF8KaLu3UvukNPNFeK+3n/sCzRVHeiJUkF7ZOKgXSx3caZzt0gUug9yoD WKR5rQe55bNvBDT8ce5rUyw6eIsT75e1H0Hkp9c2ADz0kdrvDNwnvcf/+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300785" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300785" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064033" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064033" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:28 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 4/6] serial: 8250: Add IIR FIFOs enabled field properly Date: Fri, 25 Nov 2022 15:05:07 +0200 Message-Id: <20221125130509.8482-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't use magic literals & comments but define a real field instead for UART_IIR_FIFO_ENABLED and name also the values. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 17 +++++++---------- include/uapi/linux/serial_reg.h | 4 ++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index e79bf2afd9be..a47ce3e974a2 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1293,22 +1293,19 @@ static void autoconfig(struct uart_8250_port *up) =20 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); =20 - /* Assign this as it is to truncate any bits above 7. */ - scratch =3D serial_in(up, UART_IIR); - - switch (scratch >> 6) { - case 0: + switch (serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED) { + case UART_IIR_FIFO_ENABLED_8250: autoconfig_8250(up); break; - case 1: - port->type =3D PORT_UNKNOWN; - break; - case 2: + case UART_IIR_FIFO_ENABLED_16550: port->type =3D PORT_16550; break; - case 3: + case UART_IIR_FIFO_ENABLED_16550A: autoconfig_16550a(up); break; + default: + port->type =3D PORT_UNKNOWN; + break; } =20 #ifdef CONFIG_SERIAL_8250_RSA diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_re= g.h index bab3b39266cc..19aef5b0b049 100644 --- a/include/uapi/linux/serial_reg.h +++ b/include/uapi/linux/serial_reg.h @@ -44,6 +44,10 @@ #define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */ #define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */ #define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */ +#define UART_IIR_FIFO_ENABLED 0xc0 /* FIFOs enabled / port type identifica= tion */ +#define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */ +#define UART_IIR_FIFO_ENABLED_16550 0x80 /* 16550: (broken/unusable) FIFO= */ +#define UART_IIR_FIFO_ENABLED_16550A 0xc0 /* 16550A: FIFO enabled */ =20 #define UART_FCR 2 /* Out: FIFO Control Register */ #define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */ --=20 2.30.2 From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5F49C4332F for ; Fri, 25 Nov 2022 13:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbiKYNFv (ORCPT ); Fri, 25 Nov 2022 08:05:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiKYNFk (ORCPT ); Fri, 25 Nov 2022 08:05:40 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F3B82B61C; Fri, 25 Nov 2022 05:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381533; x=1700917533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ic5NGKUd2TkcSnwEZPif9UrSF9XQfkvW0X1TSU5714E=; b=dtMGVOI9xXqLjnOvuHeihT/rhmwoHmLtWL9EoNPys7uhvmjrD1y6NfLJ IliVoyY7s1PqppB47/IMII7X0nIoOiY1asERWj49Bsb2mqhmahgH+m/vc fCQ2UTnxXSp36X/1+Sk9ZS1NFEpFWdtjc77utLlBKzvCrRfWaSCkuvUic VgH3P9yPqZis/o64I+y3nX7Z18l0SbeI6cpuM+8dY1Y/bPyQIx9jEexMW C3zJVq61CTuIzrmXGH30+hxGrSe3CAUQm+uSsVy2Oyu3zFJvkVnKZ2+Oo 3dQ8GCizmbJDOg9r+1cC2Pdi7+sVdFW7nJCKiXnh0P68elCvcshQV/xav w==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300796" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300796" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:32 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064040" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064040" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:31 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 5/6] serial: 8250: Define IIR 64 byte bit & cleanup related code Date: Fri, 25 Nov 2022 15:05:08 +0200 Message-Id: <20221125130509.8482-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 16750 indicates 64 bytes FIFO with a IIR bit. Add define for it and make related code more obvious. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 14 +++++++++----- include/uapi/linux/serial_reg.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index a47ce3e974a2..33be7aad11ef 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1050,11 +1050,12 @@ static void autoconfig_16550a(struct uart_8250_port= *up) serial_out(up, UART_LCR, 0); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); - status1 =3D serial_in(up, UART_IIR) >> 5; + status1 =3D serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | + UART_IIR_FIFO_ENABLED); serial_out(up, UART_FCR, 0); serial_out(up, UART_LCR, 0); =20 - if (status1 =3D=3D 7) + if (status1 =3D=3D (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED)) up->port.type =3D PORT_16550A_FSL64; else DEBUG_AUTOCONF("Motorola 8xxx DUART "); @@ -1122,17 +1123,20 @@ static void autoconfig_16550a(struct uart_8250_port= *up) */ serial_out(up, UART_LCR, 0); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); - status1 =3D serial_in(up, UART_IIR) >> 5; + status1 =3D serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FI= FO_ENABLED); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); - status2 =3D serial_in(up, UART_IIR) >> 5; + status2 =3D serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FI= FO_ENABLED); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_LCR, 0); =20 DEBUG_AUTOCONF("iir1=3D%d iir2=3D%d ", status1, status2); =20 - if (status1 =3D=3D 6 && status2 =3D=3D 7) { + if (status1 =3D=3D UART_IIR_FIFO_ENABLED_16550A && + status2 =3D=3D (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED_16550A))= { up->port.type =3D PORT_16750; up->capabilities |=3D UART_CAP_AFE | UART_CAP_SLEEP; return; diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_re= g.h index 19aef5b0b049..08b3527e1b93 100644 --- a/include/uapi/linux/serial_reg.h +++ b/include/uapi/linux/serial_reg.h @@ -44,6 +44,7 @@ #define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */ #define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */ #define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */ +#define UART_IIR_64BYTE_FIFO 0x20 /* 16750 64 bytes FIFO */ #define UART_IIR_FIFO_ENABLED 0xc0 /* FIFOs enabled / port type identifica= tion */ #define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */ #define UART_IIR_FIFO_ENABLED_16550 0x80 /* 16550: (broken/unusable) FIFO= */ --=20 2.30.2 From nobody Fri Sep 19 09:23:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7C70C4332F for ; Fri, 25 Nov 2022 13:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbiKYNFy (ORCPT ); Fri, 25 Nov 2022 08:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiKYNFm (ORCPT ); Fri, 25 Nov 2022 08:05:42 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869DB4C275; Fri, 25 Nov 2022 05:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381535; x=1700917535; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3xoDJ24ls7xPY5orIQfBql47gNQpE19TZHADmQ5loEY=; b=SjocPMA3y6CguntltyOhfQ+2lxLcKLnh2YCDOAE5gREOyDVddsyUnp5w qB30+JVxErLRppIiAPDv8Ua+TGQMkVy4UfHca5kGV0V8sFvrQVfJbNjfx lWe+jQzh0fXh8YM1LtNKGcG3OdSsBFE35gSXRNKgR6Cd2pHHa4nuWgccG M8OolNua5xKaMJ1DLt2LPkwqB6VrVEDoa9c3Nu/XWzWKyS7mjIAPanYEL H59ETrWNk7FkwpIx+d8PJrWoCj9mtQ1Imj9pJoSfvqK4hcsYjHFTT7AiH wLDYscSq0u9KZqYbcGSisstJ1WBZpiDYc/S9CpzworezDIJDMGA8dyxcA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316300802" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="316300802" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706064050" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706064050" Received: from dpotapen-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.50.101]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 05:05:33 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 6/6] serial: 8250_early: Convert literals to use defines Date: Fri, 25 Nov 2022 15:05:09 +0200 Message-Id: <20221125130509.8482-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> References: <20221125130509.8482-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use existing defines for the serial register values in 8250_early. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_early.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250= /8250_early.c index f271becfc46c..0ebde0ab8167 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -136,11 +136,11 @@ static void __init init_port(struct earlycon_device *= device) unsigned char c; unsigned int ier; =20 - serial8250_early_out(port, UART_LCR, 0x3); /* 8n1 */ + serial8250_early_out(port, UART_LCR, UART_LCR_WLEN8); /* 8n1 */ ier =3D serial8250_early_in(port, UART_IER); serial8250_early_out(port, UART_IER, ier & UART_IER_UUE); /* no interrupt= */ serial8250_early_out(port, UART_FCR, 0); /* no fifo */ - serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */ + serial8250_early_out(port, UART_MCR, UART_MCR_DTR | UART_MCR_RTS); =20 if (port->uartclk) { divisor =3D DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); --=20 2.30.2