From patchwork Mon Oct 2 01:56:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crescent CY Hsieh X-Patchwork-Id: 728686 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 9A181E784A7 for ; Mon, 2 Oct 2023 01:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbjJBB5w (ORCPT ); Sun, 1 Oct 2023 21:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbjJBB5v (ORCPT ); Sun, 1 Oct 2023 21:57:51 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2040.outbound.protection.outlook.com [40.107.215.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8591FC6; Sun, 1 Oct 2023 18:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9vLmohPW6g3wjZzZixGGs3y9YPnwN6BozSPPP+SfaxZLBQ11chrT8aQFYo7Nh/ALfZm8FxBcMYNKCq407Qs0Zo1qqhmrAxV+nxlv6Hla+Bz4oQe+50ebwJzzAsv/aOoKvpg/RmdPgBOnpT5+cuxIN5JHbON2X75hARPJdx6cSOwdU66pe1Tu9lZwcsgSZ0ipohLg2qzuA1Fp5PtLiUGVTkKYOP6SlCwMdQNHtfqGlq4nj7gz8WMDlSzJ/t0XcgB1hvNvolZ5HbhByjDDJthFfb3H5oWi6VLaybdQAJYOqCOzGvJ75lsp4EIgFu+q69r2PW74F4WZJz9dEOvUHfr+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2xZtzQXJdfV85aqK4Fe9r/c7fTggOyImm4SNI6LcIOA=; b=ctbTaUFTkqULzRomr6Y6voAxb7q5DxF3jGanpPw3qqtZcJ93eB4aLuhFRg8R0cX6qijcaJIu634Gv4ohM3fT7rJ6X1TkcRryEtHdauyBasIyOMlNitijOReALUhyvuhCW3PDpB4GSZ2XW+9q7BVBkn066mWVdpZBl1e9mpmkbSUizYw1bUfqgGf8L/5AskYk4MijrqutSLgfhW0DaYmC07/6wt7dbkwXaWD7T2CSpb+yqz/omrUTUH8UrpT1ALI++JTZWNTH/IEgypEwVCSSGAU3K5CLsBFOFJKtGviKb1kE02QJXXe5FHDaxEYGeLQcwjZdM4f2SG47+u4DdlJJHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=moxa.com; dmarc=pass action=none header.from=moxa.com; dkim=pass header.d=moxa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxa.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2xZtzQXJdfV85aqK4Fe9r/c7fTggOyImm4SNI6LcIOA=; b=SfGKk5uCcsr3IFBuZT+E2zGgyyQvtlrg1u1OxaFU/id47rbnqJIyuE6b1JeESV0JXPrurnSnBptX8mqveQOGjs8Xfm1vBHD6DQPgS3/USMr7454dJLJD1t+UvbMrNblNhKAFNy06CzOKpL1msaeTiVWuO1oN/wWfCeSBcQIKC9s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=moxa.com; Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) by TY0PR0101MB4788.apcprd01.prod.exchangelabs.com (2603:1096:400:279::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.29; Mon, 2 Oct 2023 01:57:44 +0000 Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::3f1:6c0e:dec3:714b]) by PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::3f1:6c0e:dec3:714b%5]) with mapi id 15.20.6838.024; Mon, 2 Oct 2023 01:57:44 +0000 From: Crescent CY Hsieh To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Crescent CY Hsieh Subject: [PATCH 1/4] tty: serial: 8250: Cleanup MOXA configurations in 8250_pci.c Date: Mon, 2 Oct 2023 09:56:59 +0800 Message-Id: <20231002015702.30509-2-crescentcy.hsieh@moxa.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231002015702.30509-1-crescentcy.hsieh@moxa.com> References: <20231002015702.30509-1-crescentcy.hsieh@moxa.com> X-ClientProxiedBy: PS2PR02CA0078.apcprd02.prod.outlook.com (2603:1096:300:5c::18) To PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR01MB5405:EE_|TY0PR0101MB4788:EE_ X-MS-Office365-Filtering-Correlation-Id: f6761304-20b5-4775-e040-08dbc2eaec67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sreUkBE9op9cbnbXccy92q0k0cWEjjVe3zKWroMRAfU8au+pqpypNEh1ge1pNpy/J6p8FWkPWo8gmJbBWih4eDJnSfq8+MR6Qsq3TfZHCErCeMTi1FfCY6mT3hlIGx1lLXTD9fKVJIw24t5HIry8dbiIdDUMcRhGcjOpq6IMLPXdsAutXP3DtjMeiLL71RjayrhMK/daclt7C9j9HkNBRDDLUinbawPKwkbV6TnA0lPy2/W6MdlSz2N7+mA52DKX8d0itl4xc6z203QB0Flp5vhV/PypkN0+v61GZstsWGuNaziz+VhHSY0zf1CB2lf5jOBECjjky8yV4xeu4gkL89ei+aYETdmi8a/hKV8IMMrOYhidbNXdUYumI3zLxLSEj/DIIGOh8FcqqEp9qmaANjTeFpVpxxnKREUeb/x+Yz8sKJoITBWJysWhvJ9buIT2OaiDuq4Y4Hzuo7Mhwm5F1fqeCEs98RRirUM2yujtu1ZVg8vGtWX2/o0tvg4881f6PHorIG8Ie2PfvqKZdQ2vnIYJbPhHebay9b5hvy5/xFQh4vO1slzxYdCeDjFAD1TSH1N+b4bGIaNsqypz67jXql1LvyUvMKnD2nyk8AHvLMyzjnlpFKNhzVD2CI0UAxdo X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PUZPR01MB5405.apcprd01.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(39850400004)(376002)(366004)(136003)(396003)(230922051799003)(64100799003)(1800799009)(451199024)(186009)(2616005)(107886003)(1076003)(26005)(38100700002)(86362001)(36756003)(38350700002)(83380400001)(316002)(4326008)(8676002)(5660300002)(41300700001)(8936002)(66476007)(66556008)(66946007)(2906002)(6506007)(6666004)(52116002)(6512007)(478600001)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N3V7kCVvsNtQuUqW/wdUzi3CGGbcjynVK0qAbmq6P+eygLwF+OZuAtKnMFCfosxBjfr/Gvt5m5zu837KOUZYNsJfxRolUL7x/feIa7JQZlOqybFhR2XMUAcKxhemULU8Bq6qlN+S0GoEvpBcXNFTx59Pvw8L/YGZCGnqY53BcWwrm2SAlrCJVV6xP6KoOxHLKKKJeYNfGnzpwwav5ytiuOxzXvaxsVh9VGYUQRrX/xHTUiE19wIraaKg/2SDKbe6N71ppdl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I+Me7Nn2RXi+H0NwIVtqI3xVt6XkET7VxyZZp+RH0RlmSNPzhqQDjn9/lebXESyAlORGLRPmTTTDSPw2wh6Ds1blUj131YDlccYF+ViwfMyhg4LkT0jUSYey2iAUBSQIlPqJ1G/TBV3DTtF9ET2KzIABl+bYpAVMCHt51mI+5HA3i1lhMihkzSBj6akoOMm2CBKWPybRlAnMDVaSwOtaTnCc69b4jyEIjN1grrEzZQOdEN7t/OlaUndbtScdVg/Nq1NFfcaSsRUGS1poNwwhg== X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6761304-20b5-4775-e040-08dbc2eaec67 X-MS-Exchange-CrossTenant-AuthSource: PUZPR01MB5405.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 01:57:24.9238 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5571c7d4-286b-47f6-9dd5-0aa688773c8e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: odWFe7d+C9+qobUOIV4bjxWqjxVGRfydeSNVZEBfY2n4JZ0ETZ45zn2VOWdYcdfFaOS6JwjUgiFCCYpR/GrS0gEx5KhYAAOXIzxwe5jkLqE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR0101MB4788 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org To enhance the maintainability of MOXA configurations in 8250_pci.c, clean up the code to achieve simplicity, clarity and consistency. Signed-off-by: Crescent CY Hsieh --- drivers/tty/serial/8250/8250_pci.c | 73 +++++++++++------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 62a9bd30b4db..a010790ccfcd 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1887,10 +1887,10 @@ pci_sunix_setup(struct serial_private *priv, return setup_port(priv, port, bar, offset, 0); } -static int -pci_moxa_setup(struct serial_private *priv, - const struct pciserial_board *board, - struct uart_8250_port *port, int idx) +static int pci_moxa_setup(struct serial_private *priv, + const struct pciserial_board *board, + struct uart_8250_port *port, + int idx) { unsigned int bar = FL_GET_BASE(board->flags); int offset; @@ -1958,6 +1958,9 @@ pci_moxa_setup(struct serial_private *priv, #define PCIE_DEVICE_ID_WCH_CH384_8S 0x3853 #define PCIE_DEVICE_ID_WCH_CH382_2S 0x3253 +/* MOXA */ +#define PCI_VENDOR_ID_MOXA 0x1393 +/* MOXA PCIe */ #define PCI_DEVICE_ID_MOXA_CP102E 0x1024 #define PCI_DEVICE_ID_MOXA_CP102EL 0x1025 #define PCI_DEVICE_ID_MOXA_CP104EL_A 0x1045 @@ -2854,9 +2857,9 @@ enum pci_board_num_t { pbn_titan_2_4000000, pbn_titan_4_4000000, pbn_titan_8_4000000, - pbn_moxa8250_2p, - pbn_moxa8250_4p, - pbn_moxa8250_8p, + pbn_moxa_2, + pbn_moxa_4, + pbn_moxa_8, }; /* @@ -3628,19 +3631,19 @@ static struct pciserial_board pci_boards[] = { .uart_offset = 0x200, .first_offset = 0x1000, }, - [pbn_moxa8250_2p] = { + [pbn_moxa_2] = { .flags = FL_BASE1, .num_ports = 2, .base_baud = 921600, .uart_offset = 0x200, }, - [pbn_moxa8250_4p] = { + [pbn_moxa_4] = { .flags = FL_BASE1, .num_ports = 4, .base_baud = 921600, .uart_offset = 0x200, }, - [pbn_moxa8250_8p] = { + [pbn_moxa_8] = { .flags = FL_BASE1, .num_ports = 8, .base_baud = 921600, @@ -5347,44 +5350,20 @@ static const struct pci_device_id serial_pci_tbl[] = { pbn_ni8430_4 }, /* - * MOXA + * MOXA PCIe */ - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102E, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_2p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102EL, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_2p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_4p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114EL, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_4p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_B, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118E_A_I, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132EL, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_2p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134EL_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_4p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP138E_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, - { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL_A, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_moxa8250_8p }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102E), 0, 0, pbn_moxa_2 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102EL), 0, 0, pbn_moxa_2 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL_A), 0, 0, pbn_moxa_4 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114EL), 0, 0, pbn_moxa_4 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_A), 0, 0, pbn_moxa_8 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_B), 0, 0, pbn_moxa_8 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL_A), 0, 0, pbn_moxa_8 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118E_A_I), 0, 0, pbn_moxa_8 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132EL), 0, 0, pbn_moxa_2 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134EL_A), 0, 0, pbn_moxa_4 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP138E_A), 0, 0, pbn_moxa_8 }, + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL_A), 0, 0, pbn_moxa_8 }, /* * ADDI-DATA GmbH communication cards From patchwork Mon Oct 2 01:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crescent CY Hsieh X-Patchwork-Id: 728685 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 5CECCE784A7 for ; Mon, 2 Oct 2023 01:58:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234967AbjJBB6I (ORCPT ); Sun, 1 Oct 2023 21:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbjJBB6F (ORCPT ); Sun, 1 Oct 2023 21:58:05 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2050.outbound.protection.outlook.com [40.107.215.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A55F1; Sun, 1 Oct 2023 18:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fd/5bcBH9eshjzu9/TH0WpJwUW/NK5G6NMwKa9/nmqeXFpBqF3ZJ6dAy6x85QodR4djvNeu1Fh6kIc3xo6pUlG/+6igew9F70qrPSZtk/wJBo0bsFtk43BDikscKpi3+8mnc+zTkYeOV343rM56o5r3qrXSFaxXd3P4mlKtjWgmZHHahsd5upTCHobWLyKXAFFvcS7vQMlxviBelpRK04e8/iEiLSnVO+Ij8Uqb98h5QCvcJSPvIx6Elmr+SJgTjkvgBJok3g5HC21yCCFFcSr2dsdB7EucxLZldAq9ejl9pPduSvSfdeiTQExpuKQgsf/gbxRJSrPJorDCkeKCU+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1rN0xugcHEdl40amAZLxWgN66eO1OsQTzLQZPVJL8a0=; b=fXmPQS2jO7qDS9xFw3Qp0r2n8zcSlaamHZRB93sSJAA3olM41MxZmuCTkCLIhiKHKo95nsDFqQUPrtGVNraTU2iMpc801C3yRj5Z0YS3xtffO7Btn8ptJQYn5FLf+vwE+sl4Xskzin/Rgp1VQn+ckfgARtproJB96sBF9IowapXU907VXR892lm7hJ+gnXmEECDZmlbAMqPJzTpxTCTShuvweyyjZ5iktxWag3gtxoCY3SOrcDcfDL77mv+vIBsiSZ9Vobtj1JQibnEzGLdDo/eHUAE1Af32q5JoAStxKNvfxgtngUmbET9oNUDtCF12s76h7Z9Jj61srovusIo9Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=moxa.com; dmarc=pass action=none header.from=moxa.com; dkim=pass header.d=moxa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxa.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1rN0xugcHEdl40amAZLxWgN66eO1OsQTzLQZPVJL8a0=; b=JFHbPiYKpTmxQFgMf7TzeCwZxG3LNNwLlhRn6djX+OJFCJClC0j0lPPBXzRLl9HDbMek2w5XFppXA3vd1xS5pKknvpX+CXuIIrQAxZDnLHJXGTAGKA/+Mi8HGaFGS2GEsPS9OlNWGqpJHFH7qCj3FU9JClPGoIVEQ9713qVhddM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=moxa.com; Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) by TY0PR0101MB4788.apcprd01.prod.exchangelabs.com (2603:1096:400:279::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.29; Mon, 2 Oct 2023 01:57:58 +0000 Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::3f1:6c0e:dec3:714b]) by PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::3f1:6c0e:dec3:714b%5]) with mapi id 15.20.6838.024; Mon, 2 Oct 2023 01:57:58 +0000 From: Crescent CY Hsieh To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Crescent CY Hsieh Subject: [PATCH 3/4] tty: serial: 8250: Fix MOXA RS422/RS485 PCIe boards not work by default Date: Mon, 2 Oct 2023 09:57:01 +0800 Message-Id: <20231002015702.30509-4-crescentcy.hsieh@moxa.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231002015702.30509-1-crescentcy.hsieh@moxa.com> References: <20231002015702.30509-1-crescentcy.hsieh@moxa.com> X-ClientProxiedBy: PS2PR02CA0078.apcprd02.prod.outlook.com (2603:1096:300:5c::18) To PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR01MB5405:EE_|TY0PR0101MB4788:EE_ X-MS-Office365-Filtering-Correlation-Id: ba3d243f-afef-47ae-ec4e-08dbc2eb0064 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dTHf6wGg0U0CqPvFv23yr7pZg9aXybhuYpKf24nORGCMTz6N/44CyH92gfE8QQ3igvyVruTCXU3ywWiocqpBr+RuIaMGMSe8Ig902h4TANrGy0N8/w+q3GHmRho2/f5QYN86flWRnK5ksCZjMdpuvUhWkD2QknlN1FkQvb/LVnr8OgUdlH30gAjGT5KjHp8YYO57qcMnD18MFO7nOdbfRD+7UAWG4iO1UNeQ8HMwALfoaVcIatSs2X/JHdOqkKYyLPFhLd8loV71BFwXTEfA19gpDJ6m4DlMlJU5dAFBKVC77mjLoXUz3Uit1Iol0PGxzy1bMxB1ZLTe7LG+k13bhWYby3jnwVyntfF6TF2Wbv7op/U798VBCo86dNrJV68L9eSWSIT4kpsiI2hWwZfM0bRPROm6hb/1ZwJytLxqXl949IBnbOdTo/IGXSErNs6PlIW8nYmceH0LPiPpvfXccenwOOaAbEjie+fUVk1gkOagUILdymyL5SJO4HI1QheWrpS+fqy0vFeNjW2EJOq43hnX0tn74rg8T8lHFYdM0F2ipkGzrE3ZMSKFivilJ6XRZ82UT1OAKylbPzgjpfCEsMwE9Bo2lWuZ1tgZR9Kc80OfHIm6LvXGlFkZ7IGeJ2zi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PUZPR01MB5405.apcprd01.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(39850400004)(376002)(366004)(136003)(396003)(230922051799003)(64100799003)(1800799009)(451199024)(186009)(2616005)(107886003)(1076003)(26005)(38100700002)(86362001)(36756003)(38350700002)(83380400001)(316002)(4326008)(8676002)(5660300002)(41300700001)(8936002)(66476007)(66556008)(66946007)(2906002)(6506007)(6666004)(52116002)(6512007)(478600001)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CfAPex8DfKpWPOQV4TnkG34KtYxaW7r4b0IiMXZqDc0klRlB8oRzeOJQW8+2eOXS/Exq1zUfW1JTONKdJpZ9GiSFUci2VHmtxj4ou8aEszAXLo3IOFXz6BIfT1Hi+3HTmyqqApHZkvr+3yp9unUDHvCLmK+XjTwgK/qdW7Q3aHcIcO7bbf8Bp7Dnbm/YbDAFyWkXgIG3LhsnhOawzemGSyecu2k6yAuyJkE74mIwL9x1qEKFmx4bNGwSTBqylWf4Mjr84grGwVa9p0q+QX5+d1J5Nk7z6NWiq9WpE18r5xcU8NcxOofR/Huk+2pDwWafpONL/klGlmSWeQs3Upm1Vm+2zESJiOoVPXYWbKz1S9TJIERJ7iplTx0K2E69yTf3Hjj7fAjmeCGzN105XU2n0qOSZTOiVUDH2KK77EGTLeLj05HQaWrQBg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zGKUQoWLc1qbLX/ukYC32KzttUPo4nb0iEt7S3+P6H1HcmhrVzNe3OHFx5KlTFuSfSxQn/6DkcuXTYzH69tGroLUq1xpul0KWtGcQltZX/83yww== X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba3d243f-afef-47ae-ec4e-08dbc2eb0064 X-MS-Exchange-CrossTenant-AuthSource: PUZPR01MB5405.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 01:57:58.4000 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5571c7d4-286b-47f6-9dd5-0aa688773c8e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bc6t4fZqM+cLsnvzg3OXEWUkbLXsZ7yOARJA7521pUC+7fqbC1Hr/9KGsexh57J3BzqyYjDELM87mHAtn7uKldmyLvR42L+G9OOz4v4MVhQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR0101MB4788 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org MOXA PCIe RS422/RS485 boards will not function by default because of the initial default serial interface of all MOXA PCIe boards is set to RS232. This patch fixes the problem above by setting the initial default serial interface to RS422 for those MOXA RS422/RS485 PCIe boards. Signed-off-by: Crescent CY Hsieh --- drivers/tty/serial/8250/8250_pci.c | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index a70546ac361e..31bfe5381000 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1890,17 +1890,54 @@ pci_sunix_setup(struct serial_private *priv, #define MOXA_PUART_GPIO_EN 0x09 #define MOXA_PUART_GPIO_OUT 0x0A +#define MOXA_RS232 0x00 +#define MOXA_RS422 0x01 +#define MOXA_RS485_4W 0x0B +#define MOXA_RS485_2W 0x0F +#define MOXA_UIR_OFFSET 0x04 + #define MOXA_GPIO_SET_ALL_OUTPUT 0x0F +static int pci_moxa_set_interface(struct pci_dev *dev, + unsigned int port_idx, + unsigned char mode) +{ + unsigned long iobar_addr = pci_resource_start(dev, 2); + unsigned long UIR_addr = iobar_addr + MOXA_UIR_OFFSET + (port_idx / 2); + unsigned char val, intf; + + val = inb(UIR_addr); + + if (port_idx % 2) { + intf = mode << 4; + val &= 0x0F; + } else { + intf = mode; + val &= 0xF0; + } + val |= intf; + outb(val, UIR_addr); + + return 0; +} + static int pci_moxa_init(struct pci_dev *dev) { unsigned short device = dev->device; unsigned long iobar_addr = pci_resource_start(dev, 2); + int i; int num_ports = (device & 0x00F0) >> 4; unsigned char val; outb(MOXA_GPIO_SET_ALL_OUTPUT, iobar_addr + MOXA_PUART_GPIO_EN); - + /* + * For the device IDs of MOXA PCIe boards match the pattern 0x*3**, + * the initial default serial interface mode should be set to RS422. + */ + if ((device & 0x0F00) == 0x0300) { + for (i = 0; i < num_ports; ++i) + pci_moxa_set_interface(dev, i, MOXA_RS422); + } /* * Enable hardware buffer to prevent break signal output when system boot up. * This hardware buffer is only supported on Mini PCIe series.