From patchwork Thu Nov 24 12:59:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 25527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3393734wrr; Thu, 24 Nov 2022 05:22:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf47AKWooK0oZxx0uulYv3kwQz/PoomYS487wQg2XQkO8852Cx3NibBvX955238LUb/rzZu+ X-Received: by 2002:a17:902:e849:b0:186:dd96:ce45 with SMTP id t9-20020a170902e84900b00186dd96ce45mr13670786plg.73.1669296139023; Thu, 24 Nov 2022 05:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669296139; cv=none; d=google.com; s=arc-20160816; b=H8R/19hQjYsedcSSFANmEvGMSD6oBS/0m/eD5JyPjlh2YC/Tm9ZBZAvvjuOO7jvvuc sZu5aj1ytXGIEgbClOYz0mkETSVKrtT35Fx7Fw8YsimhIPXfuqmpBmc064RsjC6uiH4+ zb6XiBWvmBPXcDGDuBWgxPmDsWnIiR9ZOGO0X7hq/F7WvgRDlQ6T3pPYJTiiTTBoPO3W mitstL3IDA2Q4vLz4LBKMnUgFIKdz7P/09lj1x0aRJkM82T1DH3iW+T+SMIoAETzaOif lXi5LwQaUxFU8rMbZr2IT5H/i4l3Y1y3/5dmcCj+AmG/FLslOVnewaqsNf8wCcGgoe4E oOSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wqep1q07dmGJJ8JJFL2GnokS7TGL/P7HjZgeNidP0rg=; b=atMSWkw7RR8z1X4jRdtGh682VGqordGG2CDfF3MgoNVfWfjFWsRn9G/RXxKKEwfnWV Vgje3gadx1B5hVpRMpxj+bPP8ECJwDU4dJsx+tVrf93RsPdB8txbr/ySK7IAbTMDXj2v ZWLOp0rAziqjFtc9pDe4Ywc6AKUHOKN33UJsNnopOerrwVMO7rxvudWuo78eD3mVnjEz ZMdhjDoT35KcVHSdBlwaH0zOgez6LCbT+1q1fPhV9C7L3TIwU25rbl1c/ZxCVYfylgXb 4aQb7ox3LuoEZyYnUNPvnCHjlsypL8YFggZKHLYK5RHL2sQFN1RGDska1z1rLPjixDyW qIow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e5W07xu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a63e445000000b0046fc9e82c99si1241359pgk.206.2022.11.24.05.22.06; Thu, 24 Nov 2022 05:22:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e5W07xu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbiKXNAf (ORCPT + 99 others); Thu, 24 Nov 2022 08:00:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiKXNAV (ORCPT ); Thu, 24 Nov 2022 08:00:21 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25844B4815; Thu, 24 Nov 2022 05:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669294815; x=1700830815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VutGYxx4X5h3Re6dYoyp+VWTCDAcQnLjx3PAe8fAJyU=; b=e5W07xu9djo0dlXVSZ+OU4YId69ILWV0VaQ2uUUsbt7zuL7seue15/Ai rvs9TLp1wDgGqfvOQS15QRU8xGH1jW+54lwcIgJZw4w520nXtI0EBF08h 3yioaZ2L6QgCz2WIqjmkiFvEbvDada610JIcDXQ7mpQvy529O9loc7cyo t2cIhsx00zIVcbMjg0UDHkbRCGq7edhzyVx2xLUxnJtZTtzI3A7Mml500 At+ITSuvH/tnUwL4wEFOrHSxy+ffj5BQRW5HmJhfV4o9cMHjHF+fPY5OT tBSqBfu+N2zUX+J1Hdl26vtDksnOx/kOgjXUEJ3Rg8BDNBSCTcPfR2HEP Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="311932102" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="311932102" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 05:00:15 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="887367695" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="887367695" Received: from msharawy-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.48.147]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 05:00:13 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 5/6] serial: 8250: Define IIR 64 byte bit & cleanup related code Date: Thu, 24 Nov 2022 14:59:47 +0200 Message-Id: <20221124125948.23432-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221124125948.23432-1-ilpo.jarvinen@linux.intel.com> References: <20221124125948.23432-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750383868125083991?= X-GMAIL-MSGID: =?utf-8?q?1750383868125083991?= 16750 indicates 64 bytes FIFO with a IIR bit. Add define for it and make related code more obvious. Signed-off-by: Ilpo Järvinen --- 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 6d343b15bc58..764043931a99 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 = serial_in(up, UART_IIR) >> 5; + status1 = 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); - if (status1 == 7) + if (status1 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED)) up->port.type = 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 = serial_in(up, UART_IIR) >> 5; + status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_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 = serial_in(up, UART_IIR) >> 5; + status2 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_LCR, 0); DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2); - if (status1 == 6 && status2 == 7) { + if (status1 == UART_IIR_FIFO_ENABLED_16550A && + status2 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED_16550A)) { up->port.type = PORT_16750; up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; return; diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h index a63c124b7fdc..21ae5b930c7b 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 identification */ #define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */ #define UART_IIR_FIFO_EAABLED_16550 0x80 /* 16550: (broken/unusable) FIFO */