Message ID | 20231027062440.7749-2-crescentcy.hsieh@moxa.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp397650vqb; Thu, 26 Oct 2023 23:26:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUYqS8t6JWZSIVP+JT8ashUJ9DngGOOFi8T13QGHx1nldOfEoGn33MkFuzprt9j+v7ogG5 X-Received: by 2002:a81:b247:0:b0:58e:a9d3:bf98 with SMTP id q68-20020a81b247000000b0058ea9d3bf98mr1493743ywh.27.1698387994824; Thu, 26 Oct 2023 23:26:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698387994; cv=pass; d=google.com; s=arc-20160816; b=nrfgja4q/JM+Xjn4v76XMLyLvNPqDqWITl04/wcBJ+bEnmSC09i/XoP94DrUpg0GrK S20oIixLj82hDFA7QTdurRdooSciTxhKAi2JhbmFj0PTNo6hnpIVqGDKEaKo8X1dHhwH rjv9gvMuUlrTW1ok8Ag+pWqq3JdeZ7CInbd306L9vibSb2P0jac3eMpEL8y4AcVvwFDk fNfpI+5VsK3thtzwkO92m06qEeY+0tPKmiQ/7umbq79+l9m9sJtbl/Fur9C8QAM0Lc9v Jurj6RpjKZr48wyo4rR2Gc/BTiRWjWYylEky43e+Q5zF5q+7ACSndsBG2AfgEHnTU7a+ +zPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y9l1w2+8VjOrBlskqMt7yo18vaGBhUWmQAJn+1ysJ1c=; fh=9IbzxucUBWcgEvhe+WtoxtT+FpcGkFAf3REsKls7q2A=; b=mJRDfdg1eoFJF0N3Z+37N6m4YT4FNIKyUTPm2CfuHZh09A5FZN0UT3tUyTBsWVI/7T JwWpdtvH10nmC7HXbZydP7D9oNlQu65a/EBFU38InNB1wReEVHrpPxLJqWk0rXEiBBrc BrliY88j8WTPivSnFELgtHKWN2NIIYmb9MUgEWYj8Nlon3Vr16eE0NIfMaW+KtUjgyp3 xuCqmCxAQT8OHUdXLkXB9RW790pCpf7g2+abDCF23Bzm3rJNiM/xtEdaW+VkQFfowhRm tl0oVWGLO+l5EDhYoAF+7gpb7GDnIu9OPmVI3PNriCpCqQeK6fT6n/863Z6sraoFyoYE RJvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@moxa.com header.s=selector1 header.b=K38rieJd; arc=pass (i=1 spf=pass spfdomain=moxa.com dkim=pass dkdomain=moxa.com dmarc=pass fromdomain=moxa.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=moxa.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i2-20020a816d02000000b005a7b8cb374dsi1481585ywc.38.2023.10.26.23.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@moxa.com header.s=selector1 header.b=K38rieJd; arc=pass (i=1 spf=pass spfdomain=moxa.com dkim=pass dkdomain=moxa.com dmarc=pass fromdomain=moxa.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=moxa.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1B28182DC625; Thu, 26 Oct 2023 23:26:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234963AbjJ0G0F (ORCPT <rfc822;aposhian.dev@gmail.com> + 26 others); Fri, 27 Oct 2023 02:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjJ0G0B (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 27 Oct 2023 02:26:01 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2047.outbound.protection.outlook.com [40.107.255.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A961B2; Thu, 26 Oct 2023 23:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Chay0qxpPCstQftwvA75S6brTGR4tCOMlEDzlHeI9e5tSl1tWkh2U5eLJT9q5lP//6Lk+iJn/gVVfSz8ziTAalEHmGNrd7SJG4MaZibY0uCJs/K8CqPzMSxcn8KMHZrK6Wl2L+Bf/ymwDKwrxDEhtiU7vpC+6qPRCwUjrnU/UHQXxU3WmMHAS6J0PWD6XJ5h1BKevD6a/+WHT4OKwFPju+if1d98WRcDXy5FTSj3OVQJ4NL177lthPFGe40pzz68t5pQRAzoDhRYnQ2zgyUpfZioUbwEIbezW1UCseH1+kE2fTMun+e/RrxVMu0W/hfw2WQwOo7OI6IBGitwIvj3+g== 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=y9l1w2+8VjOrBlskqMt7yo18vaGBhUWmQAJn+1ysJ1c=; b=gxuJ7H5ff1mYr/KSSDu5Bkt73UprVAo7tNyz7r/d0yXGjJCKkRVrxSFUhws3vRIXKsTSEKtbQL93HlQHv+kuxtbWih38iM4Isc7OmlP1AGgX7LKck0aaVQcOiKCQY7ynC/qhYim3WBW/h/Guj/8bxx7KRa16gaEpJbCI/JK0SjFtwSpk7JJSJqj0oCgwpwRscbrbZAZB64E6ASesWN4CywyWlvlaaVAq8QbszhrCF5xtbPNFcEIsypSUi86EqQ+VfHthlMj/6wbgWugM0vZb6vnnsiEcgygg5f5wY4U7ks+QLQMEjHrnrSnDkMI6oan1rFzFLrBZG8Fc5n0sSQ323w== 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=y9l1w2+8VjOrBlskqMt7yo18vaGBhUWmQAJn+1ysJ1c=; b=K38rieJdsCoI5+8mLplfzMy1JTJrkQaDxABbfxeq/6vTYWrhKoFiXyExWhkGGN8UGX/zaA4Ary0uf3XxY6IKEzDbiaUeIzMPmPXzzOFfmU/WUcndY3rsYaYjHmxBkfTCl4mLu9hbfLLc/GKJzhsIcLmnbXzLSCmfNzp1GjHiyRU= 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 TY2PR0101MB3696.apcprd01.prod.exchangelabs.com (2603:1096:404:8009::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.23; Fri, 27 Oct 2023 06:25:55 +0000 Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::7723:9ad4:633e:fe0d]) by PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::7723:9ad4:633e:fe0d%5]) with mapi id 15.20.6907.032; Fri, 27 Oct 2023 06:25:55 +0000 From: Crescent CY Hsieh <crescentcy.hsieh@moxa.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Crescent CY Hsieh <crescentcy.hsieh@moxa.com> Subject: [PATCH 1/2] tty: serial: 8250: Fix MOXA RS422/RS485 PCIe boards not work by default Date: Fri, 27 Oct 2023 14:24:39 +0800 Message-Id: <20231027062440.7749-2-crescentcy.hsieh@moxa.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027062440.7749-1-crescentcy.hsieh@moxa.com> References: <20231027062440.7749-1-crescentcy.hsieh@moxa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYAPR01CA0119.jpnprd01.prod.outlook.com (2603:1096:404:2a::35) To PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR01MB5405:EE_|TY2PR0101MB3696:EE_ X-MS-Office365-Filtering-Correlation-Id: 211858a5-fcc4-4122-1483-08dbd6b59354 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m4kRvcY1QrpHjOM56jPgAXku/aep8MISR9fEyZSma6bh6f/OZmUUnEA3vPw9XR3pBUs/qHKcq5m3+vbu9M/08hufmvxxreEpZ1EvQBAq/YvPSidRPddmcuOSW0o8a3IoN6/FOw7NDmSb+c8cQR/P1KK58TqAyNWnJZhqQMuOgc5yNwEaq6MVZrdTl2+K2eVdMx6L8ce5bcR6oMeKIIDHAVHZgDvj0ZnPsINDbcnV1d9dztzWjzdRV6nofRDjG/Lk81YKb1uLZmsVo9xxyoMPRFWmscPRXSIqjy8ttZzQw6nwzPhebqzubkIHvqHW1mwUuZAcNddjjDhttHA+mOAAZOPKQJB+2bunnzEThKYViRyT744FS1KWx6Qp/PUxrVQ5KxWYOeCV+89G2FAJHZO+usxwG+lPlEMzwqicsdqP597qvzmUGMcFa6XHw0OCcWUkdm2VIF+Lp0DxTbI81ypTfsRZoXX75LJ+tefDEOaIjP8q1x5Canqkfd1n3RNA9niyLiPe3YLiCWykaQZ/dNrLUGAAYljsmrvA3bR56bsGgpLQEa/5ffqntGtt7ZdGanhGlNk0scjiz7OeXUNdxkuM3v5BXu4vvpPYs3ceYhjUSNaNDH9Kcz68hBU/L5Sk2Deu 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)(39850400004)(366004)(346002)(376002)(396003)(136003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(26005)(38100700002)(83380400001)(4326008)(41300700001)(8676002)(8936002)(66556008)(2906002)(66946007)(5660300002)(110136005)(66476007)(86362001)(316002)(478600001)(38350700005)(36756003)(52116002)(6666004)(6486002)(6506007)(2616005)(1076003)(107886003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lXopcSbmkcqN55ggVpAaEdKDRXcGOVr3HLF7ze48cCycIOrDz3z+uPsBK6Mx+YtAX+sX8BVyzko6gg7cO+/92OhApyoqDRA8QWYMEpxgHrxEyvDcI5w4XGgTd0ptyEyw8vurttchSnLpqgCT+Vcs0lLMsSwWtPVOYbLZ1Z96fuvga8Lgo4jCxE+G8K6nf3oh08I9nHrlWLD1f7DkQfBSRd94+bHZaPf9c9y8Py8+oLg8w1VaoWyQ/qCP05AA6cqBWzUCEZAMbcMP/oU38qggyP0KT2u1UzKc3PI9N1iAnsVfMNZowRTjS6HpksLM5fgY/9rM5R8IOLpj3YPaGm5ssrYrxCEzqBgvBdw6v5yr+VJzPnDBF/jyaiTGIBzGXYcLuUcVKzQqMT/R5KZ4a8/AhuzX4pxhV3aGGglVbACZ1gFdAS0CUrrXz195ffUIoIazMnsQiSXjPx+ZTePpImaj3vd4K+ZyP6RKnQJSKhDor5nLpiQMt5T+afVYW85w8UeNTLqkyAvJEPozTvipgQAFG2LVxfz167HjPaFbY/xsw/X1RMTCY2onzSMMrAtDPyinDCv3aRdxt2L26vA6KCqoyTGeTvpRUeT9kRWbzOkMWAm20DMRA+swMPYiuDR/X7+9Iry54WtVrV29GIrfgu1/OCdzNGDsMMIBeWPQwXg8fysLu2vnYNnRYtoM2pX6m5H3PD0n9Ufstr6jz2P+5ni7/LtojOkv8v5w6FVEnEgtJRNL61daoagmyJubj8/uHC/xyFYNkGrnGL06t4Ol9PzqdqQxNR73LSK8Jk5BLULyHSMn8pUsYKrXwSaDvXbx6w1rR4yQw3yb7J/glrRs2GKU5HxQ5VjGXMTHzJXCpZzhNbO95Lt+/jkP8mTIY9/3gjsKPOmGcjcUv6cQtiPqGfjXbpx62U4ZXuP8Ya5c8j7Uo5xDGVhOmJAP/LZjVZuBstWjYo6dqc9WbnEBxUS0IPeWgIhLIQRCxCGu1x4tNTcMCxOb0lYQVCjejCOLVtX70X4u1epVUXpFrnZSA4XFLms/7UpcauyQTHYQ5qSGNFq/y487KM7GgSVzTHatl7Bm0n6hgWy2jgrfHDGo2aH7j3SUb/Zgue8YU7Zmnk2EHZH3Pwy32+QpOlF75X3AfwoIaCL0ngtQolN+3s0b5+L3+eHilyn5ulKXi+j4eLVPCVQMaccBu3t4FhDBcMKQ1NCg/5PDCd2TA0Fiwu/U8KLoZe+bRGPJhxqCeS8b09/xCymfo0b7LyiGDPFmlmz6OCKC7TNT+zUvcsWcEWrEsBKAY+5Ex2+NY8UGkLmCT3+cqk7C5QY7Ry6Tsa7Z7b45ntRMKCdqPh+xKjwwxck1ikcdTNGi6ydlg3/4Dzw9PtAoYhG4QpFOJE5/4KUJxZZfBIQw2Qo/G0cCm8+kw/z1YKQlhRCUQsDbansyyxExFP1xZEyUQMOnk36EQgByvy/11dIYqxMgTIiRWCspsqhJyYCh5/QGO6jhOI1T8jdZGwwJ8i8i1h5drtZw93z6fP1gwVEq92RBbT8K++O6xQCtGPwO1kn4VQG51qLOI3HsHRebyLFBTQvkKrDysH0Nz98KJP/iMUORlAypASSFLh7LBK+R3nE9Kg== X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 211858a5-fcc4-4122-1483-08dbd6b59354 X-MS-Exchange-CrossTenant-AuthSource: PUZPR01MB5405.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2023 06:25:55.3980 (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: FXnfOtl8jh3PTCJNbh7JzNk6xNP/nyarxuSIEShFKxUeBa0kDLgIIe2RbePpvMtk5KC+DU/xy5pJOIGfW8qQJdSYbUc0Bj5LD3Ky79x0eX4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY2PR0101MB3696 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 23:26:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780888890277514694 X-GMAIL-MSGID: 1780888890277514694 |
Series |
tty: serial: 8250: Adjustments of MOXA PCIe boards serial interface
|
|
Commit Message
Crescent CY Hsieh
Oct. 27, 2023, 6:24 a.m. UTC
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 <crescentcy.hsieh@moxa.com>
---
drivers/tty/serial/8250/8250_pci.c | 58 +++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
Comments
On 27. 10. 23, 8:24, Crescent CY Hsieh wrote: > 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 <crescentcy.hsieh@moxa.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> thanks,
Hi Crescent, kernel test robot noticed the following build warnings: [auto build test WARNING on tty/tty-testing] [also build test WARNING on tty/tty-next next-20231026] [cannot apply to tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.6-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Crescent-CY-Hsieh/tty-serial-8250-Fix-MOXA-RS422-RS485-PCIe-boards-not-work-by-default/20231027-142745 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing patch link: https://lore.kernel.org/r/20231027062440.7749-2-crescentcy.hsieh%40moxa.com patch subject: [PATCH 1/2] tty: serial: 8250: Fix MOXA RS422/RS485 PCIe boards not work by default config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231027/202310271618.QBCWA4yo-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231027/202310271618.QBCWA4yo-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202310271618.QBCWA4yo-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/tty/serial/8250/8250_pci.c:2001:5: warning: no previous prototype for 'pci_moxa_supported_rs' [-Wmissing-prototypes] 2001 | u32 pci_moxa_supported_rs(struct pci_dev *dev) | ^~~~~~~~~~~~~~~~~~~~~ vim +/pci_moxa_supported_rs +2001 drivers/tty/serial/8250/8250_pci.c 2000 > 2001 u32 pci_moxa_supported_rs(struct pci_dev *dev) 2002 { 2003 switch (dev->device & 0x0F00) { 2004 case 0x0000: 2005 case 0x0600: 2006 return MOXA_SUPP_RS232; 2007 case 0x0100: 2008 return MOXA_SUPP_RS232 | MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 2009 case 0x0300: 2010 return MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 2011 } 2012 return 0; 2013 } 2014
Hi Crescent, kernel test robot noticed the following build warnings: [auto build test WARNING on tty/tty-testing] [also build test WARNING on tty/tty-next next-20231027] [cannot apply to tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.6-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Crescent-CY-Hsieh/tty-serial-8250-Fix-MOXA-RS422-RS485-PCIe-boards-not-work-by-default/20231027-142745 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing patch link: https://lore.kernel.org/r/20231027062440.7749-2-crescentcy.hsieh%40moxa.com patch subject: [PATCH 1/2] tty: serial: 8250: Fix MOXA RS422/RS485 PCIe boards not work by default config: i386-randconfig-002-20231028 (https://download.01.org/0day-ci/archive/20231028/202310281723.0DAslF1o-lkp@intel.com/config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231028/202310281723.0DAslF1o-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202310281723.0DAslF1o-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/tty/serial/8250/8250_pci.c:2001:5: warning: no previous declaration for 'pci_moxa_supported_rs' [-Wmissing-declarations] u32 pci_moxa_supported_rs(struct pci_dev *dev) ^~~~~~~~~~~~~~~~~~~~~ vim +/pci_moxa_supported_rs +2001 drivers/tty/serial/8250/8250_pci.c 2000 > 2001 u32 pci_moxa_supported_rs(struct pci_dev *dev) 2002 { 2003 switch (dev->device & 0x0F00) { 2004 case 0x0000: 2005 case 0x0600: 2006 return MOXA_SUPP_RS232; 2007 case 0x0100: 2008 return MOXA_SUPP_RS232 | MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 2009 case 0x0300: 2010 return MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 2011 } 2012 return 0; 2013 } 2014
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index b2be3783f..66a2450da 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -19,6 +19,7 @@ #include <linux/serial_core.h> #include <linux/8250_pci.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <asm/byteorder.h> #include <asm/io.h> @@ -1968,6 +1969,20 @@ pci_sunix_setup(struct serial_private *priv, #define MOXA_GPIO_PIN2 BIT(2) +#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_EVEN_RS_MASK GENMASK(3, 0) +#define MOXA_ODD_RS_MASK GENMASK(7, 4) + +enum { + MOXA_SUPP_RS232 = BIT(0), + MOXA_SUPP_RS422 = BIT(1), + MOXA_SUPP_RS485 = BIT(2), +}; + static bool pci_moxa_is_mini_pcie(unsigned short device) { if (device == PCI_DEVICE_ID_MOXA_CP102N || @@ -1981,13 +1996,54 @@ static bool pci_moxa_is_mini_pcie(unsigned short device) return false; } +u32 pci_moxa_supported_rs(struct pci_dev *dev) +{ + switch (dev->device & 0x0F00) { + case 0x0000: + case 0x0600: + return MOXA_SUPP_RS232; + case 0x0100: + return MOXA_SUPP_RS232 | MOXA_SUPP_RS422 | MOXA_SUPP_RS485; + case 0x0300: + return MOXA_SUPP_RS422 | MOXA_SUPP_RS485; + } + return 0; +} + +static int pci_moxa_set_interface(const struct pci_dev *dev, + unsigned int port_idx, + u8 mode) +{ + resource_size_t iobar_addr = pci_resource_start(dev, 2); + resource_size_t UIR_addr = iobar_addr + MOXA_UIR_OFFSET + port_idx / 2; + u8 val; + + val = inb(UIR_addr); + + if (port_idx % 2) { + val &= ~MOXA_ODD_RS_MASK; + val |= FIELD_PREP(MOXA_ODD_RS_MASK, mode); + } else { + val &= ~MOXA_EVEN_RS_MASK; + val |= FIELD_PREP(MOXA_EVEN_RS_MASK, mode); + } + outb(val, UIR_addr); + + return 0; +} + static int pci_moxa_init(struct pci_dev *dev) { unsigned short device = dev->device; resource_size_t iobar_addr = pci_resource_start(dev, 2); - unsigned int num_ports = (device & 0x00F0) >> 4; + unsigned int num_ports = (device & 0x00F0) >> 4, i; u8 val; + if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) { + 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 boots up. * This hardware buffer is only supported on Mini PCIe series.