From patchwork Tue May 9 11:39:19 2023 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: 91540 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2817321vqo; Tue, 9 May 2023 04:55:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6W1XzUlYq5NLeMug1v+f5UFyK6tUoYR9RwQoWczoQ9OT0L3POUAYYreMmxjZKxBmVDrowO X-Received: by 2002:a05:6a20:7489:b0:f6:4c57:265d with SMTP id p9-20020a056a20748900b000f64c57265dmr16983316pzd.1.1683633327062; Tue, 09 May 2023 04:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683633327; cv=none; d=google.com; s=arc-20160816; b=s2klHC32Snrg/quNKarzYmJkOphvsqVX1ExFqtZ3rwTFhoZvs/QYAA/y+Uaz0EVz26 4Zvv3x13ml4XcWmiJZfNozSBPQLnTfyLl1LMwRfdaQObnfr7fHoU4j/jph7k6Y1t9XeQ BJMV2ld1b7VhbnU74uTIS4xcAeNg3ALcVm5p8RsPvGRatt+l+V1NflYOFU57flyNOFsG zdNvZfyK9Nhy2MU3PSTtq8brVX6nMHNmQ3Dl+niXXaIQ6PdWu7TI5slAVe3D0ZNByBlT tOfQXLcWbYc3ePocDpwcwsQt7ssE9yqzGW1j+/3WhVxVI8QPUqrzNDk8UM2XofGajQgp qgjQ== 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=big2qFi5iTSPPX97OlqsgFF3N1MRJ4mNiRDDg8zNt4c=; b=zLKaRiSLMRF2KwGX9rnAhJwzi+uoM7BvFN2taUMHLD38gbgk1MNGpKnkaGJNcAerjw ZDBTSzeUnYepeYLRU3fmRy3Vg/eIZkQt/JTz8NED21k4KNzT3efJk1nXFaOtU0awuLLb SofqhvZZ2M2x3My74pknS0FfxEKPFRGNPSluq6NWhpO9vPwnIOEv7dbOI9ceLeW/AxDj bFEHaXNgDu1Umm/TACLauUT2mV74sE9UyEZJXEDuOL/PRwn31a22t+XlUfm0Ix/Hd0Qm qyV5USU6y4NfJWHhuq5jmt5hl9WjKpCvmfVYGIaR/4AWUrEUgmDO1N2nGuLz8JZF2qrx CJMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eT3xdnFP; 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 a184-20020a624dc1000000b0063b8a37e42bsi2255112pfb.123.2023.05.09.04.55.13; Tue, 09 May 2023 04:55:27 -0700 (PDT) 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=eT3xdnFP; 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 S235269AbjEILjo (ORCPT + 99 others); Tue, 9 May 2023 07:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235059AbjEILjk (ORCPT ); Tue, 9 May 2023 07:39:40 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33C84C3E; Tue, 9 May 2023 04:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632379; x=1715168379; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q1Er4kkG8eGciYxqILmGRDghl79dke4ewOvyg1s/eaw=; b=eT3xdnFP3+c0r1bkofEPw3AsCP/KuTvqqrYEgs1tT+ao2bWVCXPczYFY xi9dIlK4NA92wuMK0nqRdJU1A1hQYxsi2AhFGFvsEo4wH4ib94O6T2yic KnoY6b72GbyDiB4evOzdUjpFJYnLoOOxFW/Ucdc9yKSFQb5CSFVLG1PJP X/WCgM43hUFiHLtg2+VidnfdMkKt3HYuTtmmi6zOep7GNY/ZENCAV1c5u 4ERh+aahhvlg+rTx+HW+AkkIab3GZGaSIeVOBB6PJtz99FbRbhdp0G+Y5 rg1B+gBBBB1F4nprk/EHn9j7a9aSax/Ncw4cH6S8/P/CDHWd0LJBHrunI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362060" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362060" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805934" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805934" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:35 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kunihiko Hayashi , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 1/6] serial: 8250: Change dl_read/write to handle value as u32 Date: Tue, 9 May 2023 14:39:19 +0300 Message-Id: <20230509113924.19540-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765417499072284541?= X-GMAIL-MSGID: =?utf-8?q?1765417499072284541?= Divisor latch read/write functions currently handle the value is int. As the value is related to HW context, u32 makes much more sense than a signed type. While at it, name the parameters in the callback signature. Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250.h | 4 ++-- drivers/tty/serial/8250/8250_em.c | 4 ++-- drivers/tty/serial/8250/8250_port.c | 10 +++++----- drivers/tty/serial/8250/8250_pxa.c | 2 +- drivers/tty/serial/8250/8250_uniphier.c | 4 ++-- include/linux/serial_8250.h | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 1e8fe44a7099..5418708f4631 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -167,12 +167,12 @@ static unsigned int __maybe_unused serial_icr_read(struct uart_8250_port *up, void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p); -static inline int serial_dl_read(struct uart_8250_port *up) +static inline u32 serial_dl_read(struct uart_8250_port *up) { return up->dl_read(up); } -static inline void serial_dl_write(struct uart_8250_port *up, int value) +static inline void serial_dl_write(struct uart_8250_port *up, u32 value) { up->dl_write(up, value); } diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c index 25a9ecf26be6..ef5019e944ea 100644 --- a/drivers/tty/serial/8250/8250_em.c +++ b/drivers/tty/serial/8250/8250_em.c @@ -139,12 +139,12 @@ static void serial8250_em_serial_out(struct uart_port *p, int offset, int value) } } -static int serial8250_em_serial_dl_read(struct uart_8250_port *up) +static u32 serial8250_em_serial_dl_read(struct uart_8250_port *up) { return serial_in(up, UART_DLL_EM) | serial_in(up, UART_DLM_EM) << 8; } -static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value) +static void serial8250_em_serial_dl_write(struct uart_8250_port *up, u32 value) { serial_out(up, UART_DLL_EM, value & 0xff); serial_out(up, UART_DLM_EM, value >> 8 & 0xff); diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index fe8d79c4ae95..0622c11f0064 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -325,7 +325,7 @@ static const struct serial8250_config uart_config[] = { }; /* Uart divisor latch read */ -static int default_serial_dl_read(struct uart_8250_port *up) +static u32 default_serial_dl_read(struct uart_8250_port *up) { /* Assign these in pieces to truncate any bits above 7. */ unsigned char dll = serial_in(up, UART_DLL); @@ -335,7 +335,7 @@ static int default_serial_dl_read(struct uart_8250_port *up) } /* Uart divisor latch write */ -static void default_serial_dl_write(struct uart_8250_port *up, int value) +static void default_serial_dl_write(struct uart_8250_port *up, u32 value) { serial_out(up, UART_DLL, value & 0xff); serial_out(up, UART_DLM, value >> 8 & 0xff); @@ -389,12 +389,12 @@ void au_serial_out(struct uart_port *p, int offset, int value) } /* Au1x00 haven't got a standard divisor latch */ -static int au_serial_dl_read(struct uart_8250_port *up) +static u32 au_serial_dl_read(struct uart_8250_port *up) { return __raw_readl(up->port.membase + 0x28); } -static void au_serial_dl_write(struct uart_8250_port *up, int value) +static void au_serial_dl_write(struct uart_8250_port *up, u32 value) { __raw_writel(value, up->port.membase + 0x28); } @@ -847,7 +847,7 @@ static void disable_rsa(struct uart_8250_port *up) static int size_fifo(struct uart_8250_port *up) { unsigned char old_fcr, old_mcr, old_lcr; - unsigned short old_dl; + unsigned int old_dl; int count; old_lcr = serial_in(up, UART_LCR); diff --git a/drivers/tty/serial/8250/8250_pxa.c b/drivers/tty/serial/8250/8250_pxa.c index 795e55142d4c..28b341f602c6 100644 --- a/drivers/tty/serial/8250/8250_pxa.c +++ b/drivers/tty/serial/8250/8250_pxa.c @@ -60,7 +60,7 @@ static const struct of_device_id serial_pxa_dt_ids[] = { MODULE_DEVICE_TABLE(of, serial_pxa_dt_ids); /* Uart divisor latch write */ -static void serial_pxa_dl_write(struct uart_8250_port *up, int value) +static void serial_pxa_dl_write(struct uart_8250_port *up, u32 value) { unsigned int dll; diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index a2978abab0db..a405155264b1 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -145,12 +145,12 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value) * The divisor latch register exists at different address. * Override dl_read/write callbacks. */ -static int uniphier_serial_dl_read(struct uart_8250_port *up) +static u32 uniphier_serial_dl_read(struct uart_8250_port *up) { return readl(up->port.membase + UNIPHIER_UART_DLR); } -static void uniphier_serial_dl_write(struct uart_8250_port *up, int value) +static void uniphier_serial_dl_write(struct uart_8250_port *up, u32 value) { writel(value, up->port.membase + UNIPHIER_UART_DLR); } diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 6f78f302d272..7b5d558e4e0c 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -129,8 +129,8 @@ struct uart_8250_port { const struct uart_8250_ops *ops; /* 8250 specific callbacks */ - int (*dl_read)(struct uart_8250_port *); - void (*dl_write)(struct uart_8250_port *, int); + u32 (*dl_read)(struct uart_8250_port *up); + void (*dl_write)(struct uart_8250_port *up, u32 value); struct uart_8250_em485 *em485; void (*rs485_start_tx)(struct uart_8250_port *); From patchwork Tue May 9 11:39:20 2023 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: 91538 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2816622vqo; Tue, 9 May 2023 04:54:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6sgcp9SUwjCQWeb+BKIaAA4ntjEqPbQZniQoZ1vNKuCn62yr4P8HTRStGbf1pN/CJIfTSL X-Received: by 2002:a05:6a20:938e:b0:ea:fa7f:f879 with SMTP id x14-20020a056a20938e00b000eafa7ff879mr19623531pzh.42.1683633240660; Tue, 09 May 2023 04:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683633240; cv=none; d=google.com; s=arc-20160816; b=kKRxcVWBh2gkt91pVgv0gBz1fTRtCnPGIfFo8V/nkDQgtcUo/BInzhPH2nLqckfQQc LOGMFc5fENj3Rb3sWVq0FLyh0cL2DuVw9KqDhKyFaEJWkSgKpUNx7B42zMHGC5UjNchY 4cENNFIE+6j/hVM533qGHQWhw1aTts74oR5FD3XA0/gH67QSRu7hAZ8lOeEkht6pf0uT /zyN+Bieg1mPiwg27iihUlVRuCiBOJoJhB1syeGqTWb8bhdCbixo39v+e+ixPOdvb7Ch qqwMWP8puRYru7oMIZQ9kkItDI/mCzKCL2DZfjJnKDOmdLCSyCa1dhuf/vDyHIBk5oI+ civg== 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=WHYUQnoXWjvk14GYaZKim1GW+qzBUdwmVM+eexFMivk=; b=0VlNVbNSlquw0LbB2UfN2KmGJtJ36H8AccjO6L+8g/tm+pUovrwQHMSbj4CQw6o3bo nogx/wMq/uUQCqQ1rBfrEVBa6Pbfy6qDWaWlRb2Q0uCb0pkO+PZRd50nWDf1dH1Sz8Za 6iz6U0xOfnbilZx6W56vt+84/v0Gs1ytcjiu8lo2MKyvTWFPYRrTrKz7HE4BEr1sM2Yq 1JoZZ+uFgIUC9EQSVLj9KB6YLkpl6UJ37QffAF3BQg019g3cjnDJt/WlhQMlWgiNPDFJ AhEPo+fB5q0By8rg/DWyZ8b4ll5u5u0PjESCtULjmNTLkdpB5J5Xy3XC7PEy++QKXP3E oOog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y67raeDr; 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 lx9-20020a17090b4b0900b00246bd5445d7si29239131pjb.104.2023.05.09.04.53.48; Tue, 09 May 2023 04:54:00 -0700 (PDT) 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=Y67raeDr; 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 S235376AbjEILjt (ORCPT + 99 others); Tue, 9 May 2023 07:39:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235055AbjEILjm (ORCPT ); Tue, 9 May 2023 07:39:42 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DC930F5; Tue, 9 May 2023 04:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632382; x=1715168382; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KgSo5iUE5tQb+4UxGhuvzVjJhZnju7Zh1OoucPsBSwE=; b=Y67raeDrpcyhp8udNx7m1FT5aq4f1oWZFoO/RcMDHSlWxmHy/5KpndK/ nEu1vOT0B2lagSWUZY52QyMpnx0MrQ1QHLSI8EHq7qc6XePPJpg3dOG1d T8cKsJOFYzDC2Bhnwg2xxiBnUW9j4tauziWDQhtknKoavu6NdnU+8L+lA anc/mhWFH17oHYbD/wmqx9qZ1t/ELgZE+sF1xvLTlJ/n5TakH5rYnmk2g 0n/h1nHLlkV+L+1+PoT7vhIIjlV4SgNaOx/pqBZBmtP1AEE5UDndK18DF pNBuNIv0RqDNDw6IsTDl5qCD7yhRNk0O3C6K9+AedxNxbXS4a/yotGV1g w==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362072" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362072" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805936" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805936" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:39 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , linux-kernel@vger.kernel.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 2/6] serial: 8250: Document uart_8250_port's ->dl_read/write() Date: Tue, 9 May 2023 14:39:20 +0300 Message-Id: <20230509113924.19540-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765417409379735053?= X-GMAIL-MSGID: =?utf-8?q?1765417409379735053?= Add documentation for the struct uart_8250_port divisor latch function pointers. Documentation is in kernel doc format but don't enable kernel doc yet as many other fields remain undocumented. Signed-off-by: Ilpo Järvinen --- include/linux/serial_8250.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 7b5d558e4e0c..d64e7bbe1f2f 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -90,8 +90,17 @@ struct uart_8250_em485 { * their own 8250 ports without registering their own * platform device. Using these will make your driver * dependent on the 8250 driver. + * + * @dl_read: ``u32 ()(struct uart_8250_port *port)`` + * + * UART divisor latch read. + * + * @dl_write: ``void ()(struct uart_8250_port *port, u32 value)`` + * + * Write @value into UART divisor latch. + * + * Locking: Caller holds port's lock. */ - struct uart_8250_port { struct uart_port port; struct timer_list timer; /* "no irq" timer */ From patchwork Tue May 9 11:39:21 2023 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: 91535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2815945vqo; Tue, 9 May 2023 04:52:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4o+giTxXMFKmZcMEHXwTPrKxCKPsukSwQAj/2+1P2pQNhISE2ck2PYbOE3Vr+3gcszcJKq X-Received: by 2002:a17:90b:4a07:b0:250:2192:1bff with SMTP id kk7-20020a17090b4a0700b0025021921bffmr13791510pjb.23.1683633154978; Tue, 09 May 2023 04:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683633154; cv=none; d=google.com; s=arc-20160816; b=XNH8iHErRG1mk+wfGXZglzglbLHWvGYNDOyX/RU+10rgfYcIeqk79AVGGQy4AtFNhI Q2F6p7Ty44epm3wTX2KJh/gOmiCSx44Eh6yyFuBhbZncE4NUA5TZ7AGZPmJdnZEwzlaB fACFXsIHZN7U3ykDP8OPnBpkR43a/cHE3Tut/2k9nR0XpZsnnIlRASg1wmZ09cTdy2sY K5OLBkzhZILXmz9T9i7r7Jy8SIhYO+8GPaOglJ4SSycDzPqd2asuT7rJ++4qBWMYaxMM 5tqxjh7S2y6qohPrFugAtEp03QxK1YWcqf8M1bwFaogbTetL8ExqJz71V70qPTnWjpWA 5xxQ== 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=Geu/93n2mpxqeeFSgYvnIAEJBJi3mYg7MF/AkLZLRQY=; b=QD8DvlFSKkIOtV3wVJjf5jmOWFa5VyAO4L9KhkK+o/ygw23JtzFoKYRKIcW1Drw8ZY mPxX8mrPV+85qtmO8NZgfh/pjCxY/hxdgAU7npNx/tHky3G3krb9rcN8Z7V0Ir56ZaaB gYKYqJay4+r7yK3GH/PlT8JQT2gYeTmB+306uIFQTF6PwN3O8CXLn5TrwP6P8TC9v6dh dnb1j1EnIlaVrKjPBknP13APaYierPeG3fygak+jXPO2u1saOAIR7Dj9NenQZ8jkMk+x eQeDRvRznBB7B5ET4qlo5sihgfXN3EonrOCJj3Tl9PkWgcXXePWeNWTcM9m2hv16Ln66 DjmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Z8X/yBrO"; 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 v6-20020a17090a520600b00246bb27b5ffsi14549210pjh.109.2023.05.09.04.52.21; Tue, 09 May 2023 04:52:34 -0700 (PDT) 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="Z8X/yBrO"; 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 S235478AbjEILkB (ORCPT + 99 others); Tue, 9 May 2023 07:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235055AbjEILj5 (ORCPT ); Tue, 9 May 2023 07:39:57 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200903AB9; Tue, 9 May 2023 04:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632385; x=1715168385; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bkJgaLj7zK96fyaXORrKNOWGAI9VWJOsk35I/PUkbQk=; b=Z8X/yBrO/qKMjNBqFkVHccn6tjqxoGr6obJ1IxOj61kxzS55eGCpKPLG sJVPCYUT19VkJJ9UOkXUKz3cRCPxZZO1/J6EK0Pq62JJ19635VtSOw93G 0evEyuGIF39SsIu/nVXSpSDKYlUqCL0h9Wo4zvEv47qwmdx1Om1xnyiAV miTD66urIVOSgteNzpKN48L3KzM9GSZUvZPI91sMa5j+eHhYnKW9Fiza/ YlQCvnvVHqjCDlPX6tAhgTJJP0fVW5iL2Deo7rJrPV4E1RC7vwqOBa8Kz hsfkGZ8rRSMzDKHugC+C0paHXJ80TuZLmNFEjflwEAO5jWMw3LoW+iPxL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362077" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362077" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805943" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805943" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:42 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , linux-kernel@vger.kernel.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 3/6] serial: 8250: Add dl_read/write, bugs and mapsize into plat_serial8250_port Date: Tue, 9 May 2023 14:39:21 +0300 Message-Id: <20230509113924.19540-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765417318943708766?= X-GMAIL-MSGID: =?utf-8?q?1765417318943708766?= Add mapsize, bugs, and divisor latch read/write functions (->dl_read/write()) into plat_serial8250_port to carry the setup necessary for RT288x/Au1xxx devices over to uart port. Document the added members with kerneldoc style but do not enable kerneldoc yet as there are many fields which remain undocumented. Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_core.c | 4 ++++ include/linux/serial_8250.h | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 13bf535eedcd..21b15b130d12 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -822,12 +822,16 @@ static int serial8250_probe(struct platform_device *dev) uart.port.iotype = p->iotype; uart.port.flags = p->flags; uart.port.mapbase = p->mapbase; + uart.port.mapsize = p->mapsize; uart.port.hub6 = p->hub6; uart.port.has_sysrq = p->has_sysrq; uart.port.private_data = p->private_data; uart.port.type = p->type; + uart.bugs = p->bugs; uart.port.serial_in = p->serial_in; uart.port.serial_out = p->serial_out; + uart.dl_read = p->dl_read; + uart.dl_write = p->dl_write; uart.port.handle_irq = p->handle_irq; uart.port.handle_break = p->handle_break; uart.port.set_termios = p->set_termios; diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index d64e7bbe1f2f..82cd8d90a040 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -11,13 +11,29 @@ #include #include +struct uart_8250_port; + /* * This is the platform device platform_data structure + * + * @mapsize: Port size for ioremap() + * @bugs: Port bugs + * + * @dl_read: ``u32 ()(struct uart_8250_port *up)`` + * + * UART divisor latch read. + * + * @dl_write: ``void ()(struct uart_8250_port *up, u32 value)`` + * + * Write @value into UART divisor latch. + * + * Locking: Caller holds port's lock. */ struct plat_serial8250_port { unsigned long iobase; /* io base address */ void __iomem *membase; /* ioremap cookie or NULL */ resource_size_t mapbase; /* resource base */ + resource_size_t mapsize; unsigned int uartclk; /* UART clock rate */ unsigned int irq; /* interrupt number */ unsigned long irqflags; /* request_irq flags */ @@ -28,8 +44,11 @@ struct plat_serial8250_port { unsigned char has_sysrq; /* supports magic SysRq */ unsigned int type; /* If UPF_FIXED_TYPE */ upf_t flags; /* UPF_* flags */ + unsigned short bugs; /* port bugs */ unsigned int (*serial_in)(struct uart_port *, int); void (*serial_out)(struct uart_port *, int, int); + u32 (*dl_read)(struct uart_8250_port *up); + void (*dl_write)(struct uart_8250_port *up, u32 value); void (*set_termios)(struct uart_port *, struct ktermios *new, const struct ktermios *old); From patchwork Tue May 9 11:39:22 2023 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: 91542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2817372vqo; Tue, 9 May 2023 04:55:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YF+pClInxtJwqeMNwVPKwvoeMdh9T4czGdgnK611Jo/ASUf8H8ElJ441CwZbx0/J/RljH X-Received: by 2002:a05:6a20:429a:b0:100:a785:4a86 with SMTP id o26-20020a056a20429a00b00100a7854a86mr6863727pzj.7.1683633334787; Tue, 09 May 2023 04:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683633334; cv=none; d=google.com; s=arc-20160816; b=gdUZA4Y1p1Wtv3l0WN3VGD134/VhPNbYeYGELRE4yXkJGCc/um/wRWcvDyYF23bbuB V6dtRF72ip7/E4PwM9maTtJvZDVPlwPv1TjEbY//QcvGd2Sst+OAGtTenkDnnAB1kwzt 1xMeG7P+49+7QrWdlQtMc2SLIjwoSbqsSVmRqOip+y97FKcJQ6ckwKcxUk3wiS6jI76p qWX6LuHiNZlO93JgL45S1gCloxF3pGrdXyz4Zxz840dkBUvtD8nzAa7KqVZDlUIbpGgA 1x2LwkA0LWXFNABBi85D8+YwrucLwgdjL2Na2ZC6DqN+V7Ird0/Qd5gb2+ZLfcn6DXyW tUWQ== 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=svbRHpFPqEXxmbzOvZMZNd9f/7Y/vHGNlR7c+P+7/oo=; b=w7+kUdhw13xlLEi0Fqbh3U6KFfIQRLASaWIDiizxrgI/ESZ39SKEPbHs2dg13bfVz0 1xTsLbolz2HdFfTNJe527rT74LOyt3ZrNE0z9yFUGwfNT22V3KlaM/0U/kVDA/SJ7Hk0 45UlYsKVo5aeolX+MWN9s3/ZQl1wwhBRP/KKzCFxo30+DvYMRyGXZ3pTy0a61l7FfmhX FPjQFBLQUS4b7Bxuktr4zPilmektQaOEJdU3KNAXKwDGsodC2sgoBskCXKFurzfKmSQy voKpqkE8GyRo0TLJdq5aDKs57oWRZkhFJiMKL6zU1Qg2mVhDAMnHN/X7JN+f9MVl2dwU I1wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jZb6ww1j; 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 kk4-20020a17090b4a0400b00233d10c93b9si30007140pjb.179.2023.05.09.04.55.21; Tue, 09 May 2023 04:55:34 -0700 (PDT) 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=jZb6ww1j; 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 S235225AbjEILkO (ORCPT + 99 others); Tue, 9 May 2023 07:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235393AbjEILj7 (ORCPT ); Tue, 9 May 2023 07:39:59 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 574EF5FF5; Tue, 9 May 2023 04:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632389; x=1715168389; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ySFbRMPE5woE8/OgNoxQ54y0KJ1ObhlKfMTwKQtAX0Q=; b=jZb6ww1jV6SJbSarmcboblKT2xDNiFTrQBaXgYyWb1joz8yrrp9JKlXn 9pIg9uaynf4Jp0BpHAGkbrXCUGvUFIc8kG2CInj+IjBeI3XC16cRsRDbk XTn7jR7lUBoa2xty019f3e477c8LBHY/iZjTLDhD3YEVQ52oK6T2DalPL Io3OGMv28ru6nx6+Mf/SoUzzgeYHABhUBAIsyh4QFbFq/PHyzDLkqHJF/ bLWvm/Ju8vgPf3d2nP9fGOvFFG2o2BaLmn37mLx9ld7qVfoJqMm9h9H9l f/bsea2JwHRoiDjdUipRZl/T8GIABx8i3I/Rf3V9QmkpigaZanRKqLOGw Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362088" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362088" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805948" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805948" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:46 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Bogendoerfer , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 4/6] serial: 8250: RT288x/Au1xxx code away from core Date: Tue, 9 May 2023 14:39:22 +0300 Message-Id: <20230509113924.19540-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765417507618059288?= X-GMAIL-MSGID: =?utf-8?q?1765417507618059288?= A non-trivial amount of RT288x/Au1xxx code is encapsulated into ifdeffery in 8250_port / 8250_early and some if UPIO_AU blocks. Create a separate file from them. Also handle errors properly in the cases where RT288x/Au1xxx code is not configured. It seems that 0x1000 mapsize is likely overkill but I've kept it the same as previously (the value was shrunk to that value in commit b2b13cdfd05e ("SERIAL 8250: Fixes for Alchemy UARTs.")). Seemingly, the driver only needs to access register at 0x28 for the divisor latch. The Kconfig side is a bit tricky. As SERIAL_8250_RT288X is bool it can only be =y. It is possible to have SERIAL_8250=m + SERIAL_8250_RT288X=y which required altering when 8250/ is included or the rt288x would not be built. Signed-off-by: Ilpo Järvinen --- arch/mips/alchemy/common/platform.c | 10 +- drivers/tty/serial/8250/8250_early.c | 21 ---- drivers/tty/serial/8250/8250_of.c | 4 +- drivers/tty/serial/8250/8250_port.c | 78 -------------- drivers/tty/serial/8250/8250_rt288x.c | 142 ++++++++++++++++++++++++++ drivers/tty/serial/8250/Makefile | 1 + drivers/tty/serial/Makefile | 2 +- include/linux/serial_8250.h | 8 +- 8 files changed, 161 insertions(+), 105 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_rt288x.c diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c index b8f3397c59c9..d4ab34b3b404 100644 --- a/arch/mips/alchemy/common/platform.c +++ b/arch/mips/alchemy/common/platform.c @@ -51,9 +51,9 @@ static void alchemy_8250_pm(struct uart_port *port, unsigned int state, #define PORT(_base, _irq) \ { \ .mapbase = _base, \ + .mapsize = 0x1000, \ .irq = _irq, \ .regshift = 2, \ - .iotype = UPIO_AU, \ .flags = UPF_SKIP_TEST | UPF_IOREMAP | \ UPF_FIXED_TYPE, \ .type = PORT_16550A, \ @@ -124,8 +124,14 @@ static void __init alchemy_setup_uarts(int ctype) au1xx0_uart_device.dev.platform_data = ports; /* Fill up uartclk. */ - for (s = 0; s < c; s++) + for (s = 0; s < c; s++) { ports[s].uartclk = uartclk; + if (au_platform_setup(&ports[s]) < 0) { + kfree(ports); + printk(KERN_INFO "Alchemy: missing support for UARTs\n"); + return; + } + } if (platform_device_register(&au1xx0_uart_device)) printk(KERN_INFO "Alchemy: failed to register UARTs\n"); } diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index 0ebde0ab8167..4299a8bd83d9 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -36,7 +36,6 @@ static unsigned int serial8250_early_in(struct uart_port *port, int offset) { - int reg_offset = offset; offset <<= port->regshift; switch (port->iotype) { @@ -50,8 +49,6 @@ static unsigned int serial8250_early_in(struct uart_port *port, int offset) return ioread32be(port->membase + offset); case UPIO_PORT: return inb(port->iobase + offset); - case UPIO_AU: - return port->serial_in(port, reg_offset); default: return 0; } @@ -59,7 +56,6 @@ static unsigned int serial8250_early_in(struct uart_port *port, int offset) static void serial8250_early_out(struct uart_port *port, int offset, int value) { - int reg_offset = offset; offset <<= port->regshift; switch (port->iotype) { @@ -78,9 +74,6 @@ static void serial8250_early_out(struct uart_port *port, int offset, int value) case UPIO_PORT: outb(value, port->iobase + offset); break; - case UPIO_AU: - port->serial_out(port, reg_offset, value); - break; } } @@ -199,17 +192,3 @@ OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup); OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup); #endif - -#ifdef CONFIG_SERIAL_8250_RT288X - -static int __init early_au_setup(struct earlycon_device *dev, const char *opt) -{ - dev->port.serial_in = au_serial_in; - dev->port.serial_out = au_serial_out; - dev->port.iotype = UPIO_AU; - dev->con->write = early_serial8250_write; - return 0; -} -OF_EARLYCON_DECLARE(palmchip, "ralink,rt2880-uart", early_au_setup); - -#endif diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 1b461fba15a3..c9f6bd7a7038 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -171,7 +171,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev, switch (type) { case PORT_RT2880: - port->iotype = UPIO_AU; + ret = rt288x_setup(port); + if (ret) + goto err_unprepare; break; } diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 0622c11f0064..ae50744c6878 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -341,66 +341,6 @@ static void default_serial_dl_write(struct uart_8250_port *up, u32 value) serial_out(up, UART_DLM, value >> 8 & 0xff); } -#ifdef CONFIG_SERIAL_8250_RT288X - -#define UART_REG_UNMAPPED -1 - -/* Au1x00/RT288x UART hardware has a weird register layout */ -static const s8 au_io_in_map[8] = { - [UART_RX] = 0, - [UART_IER] = 2, - [UART_IIR] = 3, - [UART_LCR] = 5, - [UART_MCR] = 6, - [UART_LSR] = 7, - [UART_MSR] = 8, - [UART_SCR] = UART_REG_UNMAPPED, -}; - -static const s8 au_io_out_map[8] = { - [UART_TX] = 1, - [UART_IER] = 2, - [UART_FCR] = 4, - [UART_LCR] = 5, - [UART_MCR] = 6, - [UART_LSR] = UART_REG_UNMAPPED, - [UART_MSR] = UART_REG_UNMAPPED, - [UART_SCR] = UART_REG_UNMAPPED, -}; - -unsigned int au_serial_in(struct uart_port *p, int offset) -{ - if (offset >= ARRAY_SIZE(au_io_in_map)) - return UINT_MAX; - offset = au_io_in_map[offset]; - if (offset == UART_REG_UNMAPPED) - return UINT_MAX; - return __raw_readl(p->membase + (offset << p->regshift)); -} - -void au_serial_out(struct uart_port *p, int offset, int value) -{ - if (offset >= ARRAY_SIZE(au_io_out_map)) - return; - offset = au_io_out_map[offset]; - if (offset == UART_REG_UNMAPPED) - return; - __raw_writel(value, p->membase + (offset << p->regshift)); -} - -/* Au1x00 haven't got a standard divisor latch */ -static u32 au_serial_dl_read(struct uart_8250_port *up) -{ - return __raw_readl(up->port.membase + 0x28); -} - -static void au_serial_dl_write(struct uart_8250_port *up, u32 value) -{ - __raw_writel(value, up->port.membase + 0x28); -} - -#endif - static unsigned int hub6_serial_in(struct uart_port *p, int offset) { offset = offset << p->regshift; @@ -510,15 +450,6 @@ static void set_io_from_upio(struct uart_port *p) p->serial_out = mem32be_serial_out; break; -#ifdef CONFIG_SERIAL_8250_RT288X - case UPIO_AU: - p->serial_in = au_serial_in; - p->serial_out = au_serial_out; - up->dl_read = au_serial_dl_read; - up->dl_write = au_serial_dl_write; - break; -#endif - default: p->serial_in = io_serial_in; p->serial_out = io_serial_out; @@ -2968,11 +2899,6 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt) { if (pt->port.mapsize) return pt->port.mapsize; - if (pt->port.iotype == UPIO_AU) { - if (pt->port.type == PORT_RT2880) - return 0x100; - return 0x1000; - } if (is_omap1_8250(pt)) return 0x16 << pt->port.regshift; @@ -3222,10 +3148,6 @@ static void serial8250_config_port(struct uart_port *port, int flags) if (flags & UART_CONFIG_TYPE) autoconfig(up); - /* if access method is AU, it is a 16550 with a quirk */ - if (port->type == PORT_16550A && port->iotype == UPIO_AU) - up->bugs |= UART_BUG_NOMSR; - /* HW bugs may trigger IRQ while IIR == NO_INT */ if (port->type == PORT_TEGRA) up->bugs |= UART_BUG_NOMSR; diff --git a/drivers/tty/serial/8250/8250_rt288x.c b/drivers/tty/serial/8250/8250_rt288x.c new file mode 100644 index 000000000000..51b1cf5476dd --- /dev/null +++ b/drivers/tty/serial/8250/8250_rt288x.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RT288x/Au1xxx driver + */ + +#include +#include +#include +#include +#include +#include + +#include "8250.h" + +#define UART_REG_UNMAPPED -1 + +/* Au1x00/RT288x UART hardware has a weird register layout */ +static const s8 au_io_in_map[8] = { + [UART_RX] = 0, + [UART_IER] = 2, + [UART_IIR] = 3, + [UART_LCR] = 5, + [UART_MCR] = 6, + [UART_LSR] = 7, + [UART_MSR] = 8, + [UART_SCR] = UART_REG_UNMAPPED, +}; + +static const s8 au_io_out_map[8] = { + [UART_TX] = 1, + [UART_IER] = 2, + [UART_FCR] = 4, + [UART_LCR] = 5, + [UART_MCR] = 6, + [UART_LSR] = UART_REG_UNMAPPED, + [UART_MSR] = UART_REG_UNMAPPED, + [UART_SCR] = UART_REG_UNMAPPED, +}; + +static unsigned int au_serial_in(struct uart_port *p, int offset) +{ + if (offset >= ARRAY_SIZE(au_io_in_map)) + return UINT_MAX; + offset = au_io_in_map[offset]; + if (offset == UART_REG_UNMAPPED) + return UINT_MAX; + return __raw_readl(p->membase + (offset << p->regshift)); +} + +static void au_serial_out(struct uart_port *p, int offset, int value) +{ + if (offset >= ARRAY_SIZE(au_io_out_map)) + return; + offset = au_io_out_map[offset]; + if (offset == UART_REG_UNMAPPED) + return; + __raw_writel(value, p->membase + (offset << p->regshift)); +} + +/* Au1x00 haven't got a standard divisor latch */ +static u32 au_serial_dl_read(struct uart_8250_port *up) +{ + return __raw_readl(up->port.membase + 0x28); +} + +static void au_serial_dl_write(struct uart_8250_port *up, u32 value) +{ + __raw_writel(value, up->port.membase + 0x28); +} + +int au_platform_setup(struct plat_serial8250_port *p) +{ + p->iotype = UPIO_AU; + + p->serial_in = au_serial_in; + p->serial_out = au_serial_out; + p->dl_read = au_serial_dl_read; + p->dl_write = au_serial_dl_write; + + p->mapsize = 0x1000; + + p->bugs |= UART_BUG_NOMSR; + + return 0; +} +EXPORT_SYMBOL_GPL(au_platform_setup); + +int rt288x_setup(struct uart_port *p) +{ + struct uart_8250_port *up = up_to_u8250p(p); + + p->iotype = UPIO_AU; + + p->serial_in = au_serial_in; + p->serial_out = au_serial_out; + up->dl_read = au_serial_dl_read; + up->dl_write = au_serial_dl_write; + + p->mapsize = 0x100; + + up->bugs |= UART_BUG_NOMSR; + + return 0; +} +EXPORT_SYMBOL_GPL(rt288x_setup); + +#ifdef CONFIG_SERIAL_8250_CONSOLE +static void au_putc(struct uart_port *port, unsigned char c) +{ + unsigned int status; + + au_serial_out(port, UART_TX, c); + + for (;;) { + status = au_serial_in(port, UART_LSR); + if (uart_lsr_tx_empty(status)) + break; + cpu_relax(); + } +} + +static void au_early_serial8250_write(struct console *console, + const char *s, unsigned int count) +{ + struct earlycon_device *device = console->data; + struct uart_port *port = &device->port; + + uart_console_write(port, s, count, au_putc); +} + +static int __init early_au_setup(struct earlycon_device *dev, const char *opt) +{ + rt288x_setup(&dev->port); + dev->con->write = au_early_serial8250_write; + + return 0; +} +OF_EARLYCON_DECLARE(palmchip, "ralink,rt2880-uart", early_au_setup); +#endif + +MODULE_DESCRIPTION("RT288x/Au1xxx UART driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index 4fc2fc1f41b6..628b75be312e 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o obj-$(CONFIG_SERIAL_8250_IOC3) += 8250_ioc3.o obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o +obj-$(CONFIG_SERIAL_8250_RT288X) += 8250_rt288x.o obj-$(CONFIG_SERIAL_8250_LPC18XX) += 8250_lpc18xx.o obj-$(CONFIG_SERIAL_8250_MT6577) += 8250_mtk.o obj-$(CONFIG_SERIAL_8250_UNIPHIER) += 8250_uniphier.o diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index cd9afd9e3018..531ec3a19dae 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -21,7 +21,7 @@ obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o obj-$(CONFIG_SERIAL_21285) += 21285.o # Now bring in any enabled 8250/16450/16550 type drivers. -obj-$(CONFIG_SERIAL_8250) += 8250/ +obj-y += 8250/ obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 82cd8d90a040..8f38be25eefa 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -7,6 +7,7 @@ #ifndef _LINUX_SERIAL_8250_H #define _LINUX_SERIAL_8250_H +#include #include #include #include @@ -211,8 +212,11 @@ void serial8250_set_isa_configurator(void (*v)(int port, struct uart_port *up, u32 *capabilities)); #ifdef CONFIG_SERIAL_8250_RT288X -unsigned int au_serial_in(struct uart_port *p, int offset); -void au_serial_out(struct uart_port *p, int offset, int value); +int rt288x_setup(struct uart_port *p); +int au_platform_setup(struct plat_serial8250_port *p); +#else +static inline int rt288x_setup(struct uart_port *p) { return -ENODEV; } +static inline int au_platform_setup(struct plat_serial8250_port *p) { return -ENODEV; } #endif #endif From patchwork Tue May 9 11:39:23 2023 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: 91533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2813136vqo; Tue, 9 May 2023 04:46:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7F9YXStDbAtRMvqnr96wnvDs8C8A8g62tcMcOenuzrQLcdiImmpGtr+1ntNPfHAnNOHi63 X-Received: by 2002:a17:902:d505:b0:1a6:f93a:a136 with SMTP id b5-20020a170902d50500b001a6f93aa136mr22880562plg.22.1683632808303; Tue, 09 May 2023 04:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683632808; cv=none; d=google.com; s=arc-20160816; b=d4LFlVNRumtyS2E5lbp7Rd2Dbnv0nTGttlDpIRJAp5l1Ls6tiXP3LFXGUeDlO7hgn/ 5LBQxNwQJLN/AvJ1D/B+zW93iey/qnpExEHPjMyBrCmlLioyJ0XC8DlG4D+w4yJuSIf1 kXBXlAXW1PwXW+KDg+HXRQY1TuMluhZja9NrmhBU/3kFSbYd6bmTR5I9wtkqjSLifWWZ fw9Kkm+0Q7vXlduik40lJVmCQ20q7yJw9MWIqgCMDL7GzG9QcooQ0PaQC4yZB38g9ObW pzWoIQafXrnnEID24VlPkk0s8UyMGKffbVwvfvVn1G7TKZSVHq60OaBGLxdW7Qhufecy 9E4g== 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=iY/w238PyTdCW3e1Jqtic0LD2GXRc3UBWSwmTwNFxLo=; b=D4xTLAKyiKUhpdY/ygztdfdjs2wBfu0zbo4Lvi6+iIKOiQhlqM4wleLOWm/+PzsNFi Xxpr7Vrz8o48/5bEjrcAhEAx+K+6bHxd6u9PNL2ZtMGXFbZoC/06zyswJuZNC5RVr2jX 6dYQKjvGjAkvPkcFaxN+knXQdd+IDvHgH2zX8kMpPhtU0Jl2zprUqyfLH5c0+lrWel9h in2/etGYaFDB+trG3wnInEoKVi4gtABc2dzgjcUoK1omCaXyuCfi9afa4E215dQ6utqs MlwQyISNKoeWA0MEhK5IDM9CM9XAGqwFR/7Kmy+Abr+lgqokbyhU3gFHRB+4166CsJPd 8D4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CjPppXE7; 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 n7-20020a170903110700b001a9f42553dasi1355285plh.614.2023.05.09.04.46.34; Tue, 09 May 2023 04:46:48 -0700 (PDT) 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=CjPppXE7; 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 S234784AbjEILkQ (ORCPT + 99 others); Tue, 9 May 2023 07:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbjEILkA (ORCPT ); Tue, 9 May 2023 07:40:00 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9065C65BE; Tue, 9 May 2023 04:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632392; x=1715168392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wwhV8nJQahvCRqX3BBXXU6mZDO9OAAZ3tyuB/BORaYY=; b=CjPppXE7+sHsxYBio8pNxioqppUUXbMpX/f1JDVo75dia+MMw7Dt/cfB +CGkYZC28axOKV2jfWfF8mfatjwW4gRrQVrp73tIprwCkpq2f60sU5J0V 87T4P2S7qqgj/YFtuBQ70rHcCZ/vx2IkdAOf5GFT3R19y3zOiff6sG0gs IiJ+nmnt4PgHfhy41Sw7tQn+Ao+0iOJgwF9nT6M6meaWeTz5hghsKspig ei3qaRKMBX2tT0fQcv1kbmhHq301EP6B/P8184zusyKojgnKJGBM7nojo WjkqpfsKf5+0RZMPRMa80Xtz1Iu887FkpdQTP5847AtvuejJU57MSbzI5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362095" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362095" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805952" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805952" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:49 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , linux-kernel@vger.kernel.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 5/6] serial: 8250_rt288x: Name non-standard divisor latch reg Date: Tue, 9 May 2023 14:39:23 +0300 Message-Id: <20230509113924.19540-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765416955471422821?= X-GMAIL-MSGID: =?utf-8?q?1765416955471422821?= Instead of a literal, add proper name for the non-standard divisor latch register. Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_rt288x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_rt288x.c b/drivers/tty/serial/8250/8250_rt288x.c index 51b1cf5476dd..b091a1269bfa 100644 --- a/drivers/tty/serial/8250/8250_rt288x.c +++ b/drivers/tty/serial/8250/8250_rt288x.c @@ -12,6 +12,8 @@ #include "8250.h" +#define RT288X_DL 0x28 + #define UART_REG_UNMAPPED -1 /* Au1x00/RT288x UART hardware has a weird register layout */ @@ -60,12 +62,12 @@ static void au_serial_out(struct uart_port *p, int offset, int value) /* Au1x00 haven't got a standard divisor latch */ static u32 au_serial_dl_read(struct uart_8250_port *up) { - return __raw_readl(up->port.membase + 0x28); + return __raw_readl(up->port.membase + RT288X_DL); } static void au_serial_dl_write(struct uart_8250_port *up, u32 value) { - __raw_writel(value, up->port.membase + 0x28); + __raw_writel(value, up->port.membase + RT288X_DL); } int au_platform_setup(struct plat_serial8250_port *p) From patchwork Tue May 9 11:39:24 2023 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: 91534 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2815353vqo; Tue, 9 May 2023 04:51:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5R3wJDT6ODU39DKINq0hGBJpEHktY7+d7dfG3Yk9SHNRsTJ9Qw38OdZR3iuoGPF6uCj0MX X-Received: by 2002:a17:903:2308:b0:19c:fc41:2dfd with SMTP id d8-20020a170903230800b0019cfc412dfdmr16420875plh.29.1683633079145; Tue, 09 May 2023 04:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683633079; cv=none; d=google.com; s=arc-20160816; b=rPHI76vtyh8wGtTpjlMgSJLTyTPygwKZKoTUWu4jU5y4jrhON08zos6ITSU17qiUXx i+aDWJaTt7LzmGmz0MWFrKaXYg3nwyVzagM1hpzs7N+FKUn9KuBq5XkS6op5xdwT7nv7 PaoGJ1VGlBtZgLEDCjUTeslORil7Il/UAQ4ZP6clPyXRiVhGf4fjkZqh7qluCdQKhQo/ hMZ9V8tr+9K9dxN5bvol+yJl3sjnzTASm25uCmhNLK4LBMJupt15uSEg9g2VZWwGXRx/ IUI4bEhmb205AE4ulvTQtjfY6hnNG1YK2jmrnNkrdOAMQMlnRxe9nBMhmjVhcx5BHXRL PnVQ== 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=xalkhbORI4fxw0HC5JvGwNhv48fhT0SJG4srG51vYIs=; b=IGNaPYqgnpugwIX1mIRIcEnk7wpGgxSHgJ7Rq11KdAsXz1jIEDrSLqbDFiKx9kMwrA Cl3Ry5xtU9LfP9ROrBb4ZZvyK+oYwOKPiHICdi11GYh+N4G16uElZPP7HE9ywSWOpi4x cGrGIeinQ3I90KJhiCR55RKOMwbun/mcFHQBX3jvIs2VBikicq/qHLBGiSvhywEX7SOq rbLiignicw61Pi8It3eJo6f8eyfgMs4TTTdCNodk/aj9u45WDut57/SdLfkEwO/Ugtmt yWpY6YnXE4lpURug4PseoxSfZ5IoYGZ1UhO6Yg2WEhPHjgAYQBTIQ5q9wqnZOrNGDKcH NwHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kNbEI2r3; 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 c14-20020a170902d48e00b001a526bc2b84si1333050plg.620.2023.05.09.04.51.06; Tue, 09 May 2023 04:51:19 -0700 (PDT) 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=kNbEI2r3; 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 S235600AbjEILkc (ORCPT + 99 others); Tue, 9 May 2023 07:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235494AbjEILkK (ORCPT ); Tue, 9 May 2023 07:40:10 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE09772AA; Tue, 9 May 2023 04:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683632395; x=1715168395; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6LAY9JWX/aRhNzybSamq3VVrNZJvYyTc9TrazjZTyNY=; b=kNbEI2r37ckPaLBIh3py4wM92U4/tpBU8rrZUpE71OK/qew8DQbTZSl6 cXBJVLt6LNRG0Kt6XfyCKUDKgUvKTZqu/Vu+OsFCuG6ibSkSoryeQm6YR bbVnRGTMnQl1mqPCf4tIjBykXIDOLVW4vx/CN0/v1HfLtSp3L4cBh1GGI 2D2PzxXOt+OQypX7IR9mS+JGR/iaiMP763S9crb3/Mv8K1w50bEDyIL4o rpNtK3Hqisp3JlLVDbf+/Gt/SoObDxXA7YIk8AmTjhvfKt7ANg87i4XO/ M6Wr97cMgmmjWilLlpSAh+Foy9FKNd6MbIFCkVr10r1wK9s54PeMAhugV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="347362101" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="347362101" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="763805957" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="763805957" Received: from mbrdon-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.219.121]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 04:39:53 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , linux-kernel@vger.kernel.org Cc: Niklas Schnelle , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 6/6] serial: 8250_rt288x: Remove unnecessary UART_REG_UNMAPPED Date: Tue, 9 May 2023 14:39:24 +0300 Message-Id: <20230509113924.19540-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> References: <20230509113924.19540-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765417239722259155?= X-GMAIL-MSGID: =?utf-8?q?1765417239722259155?= As unmapped registers are at the tail of the array, the ARRAY_SIZE() condition will catch them just fine. No need to define special value for them. Convert the arrays to u8 as all entiries are now positive. Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_rt288x.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/8250/8250_rt288x.c b/drivers/tty/serial/8250/8250_rt288x.c index b091a1269bfa..6415ca8d3adf 100644 --- a/drivers/tty/serial/8250/8250_rt288x.c +++ b/drivers/tty/serial/8250/8250_rt288x.c @@ -14,10 +14,8 @@ #define RT288X_DL 0x28 -#define UART_REG_UNMAPPED -1 - /* Au1x00/RT288x UART hardware has a weird register layout */ -static const s8 au_io_in_map[8] = { +static const u8 au_io_in_map[7] = { [UART_RX] = 0, [UART_IER] = 2, [UART_IIR] = 3, @@ -25,18 +23,14 @@ static const s8 au_io_in_map[8] = { [UART_MCR] = 6, [UART_LSR] = 7, [UART_MSR] = 8, - [UART_SCR] = UART_REG_UNMAPPED, }; -static const s8 au_io_out_map[8] = { +static const u8 au_io_out_map[5] = { [UART_TX] = 1, [UART_IER] = 2, [UART_FCR] = 4, [UART_LCR] = 5, [UART_MCR] = 6, - [UART_LSR] = UART_REG_UNMAPPED, - [UART_MSR] = UART_REG_UNMAPPED, - [UART_SCR] = UART_REG_UNMAPPED, }; static unsigned int au_serial_in(struct uart_port *p, int offset) @@ -44,8 +38,7 @@ static unsigned int au_serial_in(struct uart_port *p, int offset) if (offset >= ARRAY_SIZE(au_io_in_map)) return UINT_MAX; offset = au_io_in_map[offset]; - if (offset == UART_REG_UNMAPPED) - return UINT_MAX; + return __raw_readl(p->membase + (offset << p->regshift)); } @@ -54,8 +47,7 @@ static void au_serial_out(struct uart_port *p, int offset, int value) if (offset >= ARRAY_SIZE(au_io_out_map)) return; offset = au_io_out_map[offset]; - if (offset == UART_REG_UNMAPPED) - return; + __raw_writel(value, p->membase + (offset << p->regshift)); }