From patchwork Wed Jul 5 13:15:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Rodr=C3=ADguez_Barbarin=2C_Jos=C3=A9_Javier?= X-Patchwork-Id: 699550 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 1AA9CEB64DA for ; Wed, 5 Jul 2023 13:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbjGEN3r (ORCPT ); Wed, 5 Jul 2023 09:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjGEN3q (ORCPT ); Wed, 5 Jul 2023 09:29:46 -0400 Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01on2129.outbound.protection.outlook.com [40.107.23.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A858172D; Wed, 5 Jul 2023 06:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZRlIbKPBHzFrx7gBMAj60nh9ou4ga3sflcdrVgzvyg=; b=MU6ltNd8QhioKc1YZ/ZSAm/w3loJOjQlFCS16bCgO8Esu5IJRRyrfM9/sryclde4yTCyp2g48xuUBEJxWgeSfRXCOqF/FPB1nCD32056Z29KePrnhXaYOiVu9MFThxOq5BE/50hUy3PGYHi6QJWaPFgu+VVC4XB2tDDeaonT3vM= Received: from DU2PR04CA0193.eurprd04.prod.outlook.com (2603:10a6:10:28d::18) by ZR0P278MB1124.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:51::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:29:37 +0000 Received: from DB5EUR01FT006.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:28d:cafe::fd) by DU2PR04CA0193.outlook.office365.com (2603:10a6:10:28d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:29:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 77.74.96.169) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 77.74.96.169 as permitted sender) receiver=protection.outlook.com; client-ip=77.74.96.169; helo=securemail.duagon.com; pr=C Received: from securemail.duagon.com (77.74.96.169) by DB5EUR01FT006.mail.protection.outlook.com (10.152.4.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.24 via Frontend Transport; Wed, 5 Jul 2023 13:29:34 +0000 Received: from securemail (localhost [127.0.0.1]) by securemail.duagon.com (Postfix) with SMTP id 4Qx0rG4MvqzxpF; Wed, 5 Jul 2023 15:29:34 +0200 (CEST) Received: from CHE01-ZR0-obe.outbound.protection.outlook.com (mail-zr0che01lp2104.outbound.protection.outlook.com [104.47.22.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by securemail.duagon.com (Postfix) with ESMTPS; Wed, 5 Jul 2023 15:29:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZRlIbKPBHzFrx7gBMAj60nh9ou4ga3sflcdrVgzvyg=; b=MU6ltNd8QhioKc1YZ/ZSAm/w3loJOjQlFCS16bCgO8Esu5IJRRyrfM9/sryclde4yTCyp2g48xuUBEJxWgeSfRXCOqF/FPB1nCD32056Z29KePrnhXaYOiVu9MFThxOq5BE/50hUy3PGYHi6QJWaPFgu+VVC4XB2tDDeaonT3vM= Received: from DUZPR01CA0059.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::13) by GVAP278MB0120.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:22::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:15 +0000 Received: from DB5EUR01FT097.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:469:cafe::c1) by DUZPR01CA0059.outlook.office365.com (2603:10a6:10:469::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.31 via Frontend Transport; Wed, 5 Jul 2023 13:15:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.79.222.204) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 20.79.222.204 as permitted sender) receiver=protection.outlook.com; client-ip=20.79.222.204; helo=de2-emailsignatures-cloud.codetwo.com; pr=C Received: from de2-emailsignatures-cloud.codetwo.com (20.79.222.204) by DB5EUR01FT097.mail.protection.outlook.com (10.152.5.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.24 via Frontend Transport; Wed, 5 Jul 2023 13:15:15 +0000 Received: from CHE01-GV0-obe.outbound.protection.outlook.com (104.47.22.49) by de2-emailsignatures-cloud.codetwo.com with CodeTwo SMTP Server (TLS12) via SMTP; Wed, 05 Jul 2023 13:15:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bHfPDJRldO/1xQWpeO30cOrOYHAp7tMRGI5xpf8EXDhG9gpuUdtjig0kfbEdxRw8xlIEfCGgA/hcjiMWnv7UewoSvbzsRlJRhV87IiiHOyFvYwM5FEsME5ZMu5Dsqp2uWEyrPScnZAALSd4/+Fas6M9CQzoDv8QGxiqSPEd9A1d7VxSZj8tQDCb5EBexHWSww94Favo9nm3Oyu1fZyppCuW2bSIAGJa/0UBZ7oqhSDc6z2yMdUkPPp9AIJlb7sw6SDQyefUoDVJFJ7lPl57wF8Z1pClQufXDbGxohjVLgeysFJ0nDFem8aHHZxkcyGdsHgDI9Dc34wEkA5/QYCHOxQ== 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=xZRlIbKPBHzFrx7gBMAj60nh9ou4ga3sflcdrVgzvyg=; b=CxPieoYSSrV9pR35QyEDacV3uOZ8k4MxAVvaqZQDww188xvxHfzYNkN4gbC5OoizxlzKuMK27LmQtNatHZqRRQ626GKrjzgvtcTTd3olqDYOLtofsh+rurMLqtdxGI8UznLY+K+P2wJ82WdSf4gneOAYYOJ7eH2kKJtjfPboaIz4qL9kSEjSyaM46t7fbpSMc13tBRV8kQBBY8TJwX7dTwkMq7WT7seufQEBnvwKQR5gCfrU85h+CZOlPIaRIbsII5exXb6lT3f0jbvvca5Xthq+XC7bVW8HKACnYCuaudrSng/V+Ov3zvIsnSGhwKCbjacbBbObgImiPOl7TiZLFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=duagon.com; dmarc=pass action=none header.from=duagon.com; dkim=pass header.d=duagon.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZRlIbKPBHzFrx7gBMAj60nh9ou4ga3sflcdrVgzvyg=; b=MU6ltNd8QhioKc1YZ/ZSAm/w3loJOjQlFCS16bCgO8Esu5IJRRyrfM9/sryclde4yTCyp2g48xuUBEJxWgeSfRXCOqF/FPB1nCD32056Z29KePrnhXaYOiVu9MFThxOq5BE/50hUy3PGYHi6QJWaPFgu+VVC4XB2tDDeaonT3vM= Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:4f::13) by ZRAP278MB0875.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:4a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:11 +0000 Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620]) by GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620%7]) with mapi id 15.20.6565.016; Wed, 5 Jul 2023 13:15:10 +0000 From: =?iso-8859-1?q?Rodr=EDguez_Barbarin=2C_Jos=E9_Javier?= To: "gregkh@linuxfoundation.org" , "jirislaby@kernel.org" CC: "morbidrsa@gmail.com" , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jth@kernel.org" , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jor?= =?iso-8859-1?q?ge?= , =?iso-8859-1?q?Rodr?= =?iso-8859-1?q?=EDguez_Barbarin=2C_Jos=E9_Javier?= , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jo?= =?iso-8859-1?q?rge?= Subject: [PATCH 1/3] 8250_men_mcb: Add clockrate speed for G215/F215 boards Thread-Topic: [PATCH 1/3] 8250_men_mcb: Add clockrate speed for G215/F215 boards Thread-Index: AQHZr0K5klI/G48NSESVER1GvVjuRQ== Date: Wed, 5 Jul 2023 13:15:10 +0000 Message-ID: <20230705131423.30552-2-josejavier.rodriguez@duagon.com> References: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> In-Reply-To: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> Accept-Language: es-ES, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=duagon.com; x-ms-traffictypediagnostic: GV0P278MB0996:EE_|ZRAP278MB0875:EE_|DB5EUR01FT097:EE_|GVAP278MB0120:EE_|DB5EUR01FT006:EE_|ZR0P278MB1124:EE_ X-MS-Office365-Filtering-Correlation-Id: b22644b8-3ec2-4e86-3245-08db7d5bdfc4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: T4MGTF3FTAhrficKFu1l2ofFZL2rX+1FV7wVAcSCWMy4iI86wtbZ7LQ4LiKlwgqFr3QWrzYVY1q3hwjXlEeKBOvu9umoMW1WuxrijMNgNDmqPBKkK2rujCLA/X0dbAv0hP3ZYjp9aWvwx+Yc8DqdIz9GB0UC01MxedDINpBXkTVPcJFX8S6hZhnS3Z36xlMZ4jbzmi5yE1RtfsxIEdodoJB7/X9szB8mCoaJ3OPoo0GVkqDLVows/Rip0j3umucaL8fPYuQOK9Zne9ge+x3aNDD6cgeinhstCAVg5CkXAA2CsBqJ9Yc/Jfv8kX/SNGHqM7OfphTRhCdspRmtQ4lZq/eFDumABwjy5fkilbGPlV+d0vFk/DoJZltk0L4URF7LeZF7WD3Vxdumrc6wK63re8z1sQ8Nti96piC33jo6uNc9AVTBGFI3buGBMWDbOeyO6BvtIF+doSybxGv0glyZK/9OBzfISbhA70vAHjNPKumKPGYtrkftYBGtV3znpHkKv7Jfz5MkIjqboT8iALtWBD0edFAMVSR57ywU1xYAo7nnazvkW8HRiPxiZ7u3MfB5E+UgjlODZj/pX+ZTLVPivuyBZpc9fhC7vXRijBW5TZbfIv/j6jsOgwpLihbFEyhJ X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(366004)(39850400004)(136003)(396003)(376002)(346002)(451199021)(76116006)(91956017)(66556008)(64756008)(4326008)(66476007)(66446008)(107886003)(122000001)(2616005)(38100700002)(38070700005)(86362001)(186003)(26005)(1076003)(66946007)(6506007)(83380400001)(478600001)(6512007)(6486002)(110136005)(36756003)(54906003)(41300700001)(8676002)(8936002)(2906002)(71200400001)(5660300002)(316002); DIR:OUT; SFP:1102; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZRAP278MB0875 X-CodeTwo-MessageID: b5d17346-b4e4-42cd-a570-13ae77858080.20230705131512@de2-emailsignatures-cloud.codetwo.com X-CodeTwoProcessed: true X-EOPAttributedMessage: 1 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR01FT097.eop-EUR01.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 21c30629-8700-43f0-bc36-08db7d59dc78 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 599IbhdMirDzyyYrK2rNGu5vi6yFnpCJrjwmMNaJno/rcOjt1c4D04kRaHUNeIG+aYI8BV/V0WIpx1Vo5jfcz8KagKLl07yUWzMdyk8PVyHbzAwtzDaPgEGywo2ZI602RB8xAIUqOl0wad6AESE2VsE760YD97ZEE+AtD5+UNHOSXBJkqL/GUNDm+5ihPRcw0N6N6ZoXbELv4tZpbwDVo805s7++3D/lD9RVGQs2TzovF4HbSNBzZnebjLM0UhabOOQyeHMKxWLwaBLPdiSlOyJvex79L6WMTDNvXyaO1W2H7Q+sR9U2mkl0Cq6r3Su0GuiG2f4FG+lNO+3xf+wLcIYPTkUJDkDdTYkBzVInkRa2UZMIy//FXat4QRyCR7Jzb31QszYljZMqmhE3obn39LQqrRRCRcLSuM9ZoD//YmAdEk0klQS8ygUgwNmhQWRWoKtK0APukYBl4LzKtObsaDiqqS0d51prcHZie/3a3mhDqzb1T2rbGjy2M5OQNzIGkbcgthDtYKjs5H150mfaOA77zmUATGEKzfA6DynX3nybIIiKU3Uw/Ey4bWcUusC0YEvDb8utmLtPGRH5mEthssmbXmjCw4u1aU3VH/KMtpoddQzkWev/Dy1HMO2tCS6ftMuSj6u+8WpC3c4wdqkB1cfuaJ1odBfySxZ4JLm7tGxwjvHwQTWzu7eEEXt/IUZtxdBZx2ZY2muMGdJFAVNTPw== X-Forefront-Antispam-Report-Untrusted: CIP:20.79.222.204; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:de2-emailsignatures-cloud.codetwo.com; PTR:de2-emailsignatures-cloud.codetwo.com; CAT:NONE; SFS:(13230028)(39850400004)(376002)(136003)(346002)(396003)(451199021)(36840700001)(46966006)(41300700001)(6486002)(82310400005)(82740400003)(7596003)(356005)(2616005)(107886003)(83380400001)(7636003)(186003)(336012)(6506007)(1076003)(26005)(6512007)(86362001)(47076005)(36860700001)(40480700001)(54906003)(110136005)(316002)(478600001)(2906002)(36756003)(4326008)(70586007)(70206006)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVAP278MB0120 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR01FT006.eop-EUR01.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a7c2b813-3233-4dbc-d8f9-08db7d59df3f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DO/hOCIJ7lRCOgq/EVuIESV6lLKSLpHqK6yhFfNSxf3TQS0268S3jvWDJVLse++r5Z4xRuRT7ikgNB5RydAKJjEkG5S76sFxleOI5jOhck2C779tUTZQklCTRBFGPmbRJG/UCux1S2rRa9v0au3y0+ymiK+cu1ipymb2QsW00Vi4voHlkqNFlygMBLh/znw13PNBsXOpaQITpLdGWGvPwOM3EeccKOkZt5hjQggEwqP4OCXrA4q6iHK6yEX+lNB2VowF2Qn10KOUrryDIG1S60HAahhAKUdg+d9ge1oFAZtmpS0RyNGnAYT9eD89RKW9ehr8kna2sKujjQnUhXiRBs+kytW0l5AyIUzA7JOju97Nl/PSooak9Cj5evZcJTgee/DH6iE21a1uo30pTDFqWoBt4Mx8krAwyCDVezHIzE27UmM0hv3XSpbmzZTpAlLJ7vD9krdqYParXF2nDpn/rB4ZqU+V9wmaQOIQh2cAOe3gGsbe1ZIQU13YZssCpsTMKFTEvYTyz+p1sKpdcc7vsJEzy9YaKbTPDdDgyrRs8B+6MTv8o7yazxMpe/8jprCYNoCwj/DYHqkheIR0IwSzer45XZN/SLHO/b1i5/zWJJYqHwJAjl2o/KzWf4d+qSAndLsUpshY/VeKZCt5wZAcI0C9/xiGIYE39AlzWVzWF2w7a4YMtxG433AYs3NHdC2EqoXO9Hf/zaNU5fcXzga1jg== X-Forefront-Antispam-Report: CIP:77.74.96.169; CTRY:CH; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:securemail.duagon.com; PTR:169.96.74.77.ftth.as8758.net; CAT:NONE; SFS:(13230028)(136003)(376002)(39850400004)(396003)(346002)(451199021)(46966006)(36840700001)(4326008)(70206006)(70586007)(81166007)(2616005)(82310400005)(107886003)(86362001)(186003)(6506007)(26005)(1076003)(36860700001)(47076005)(82740400003)(83380400001)(336012)(478600001)(6512007)(36756003)(6486002)(40480700001)(110136005)(41300700001)(54906003)(8936002)(8676002)(5660300002)(2906002)(316002); DIR:OUT; SFP:1102; X-OriginatorOrg: duagon.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 13:29:34.9761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b22644b8-3ec2-4e86-3245-08db7d5bdfc4 X-MS-Exchange-CrossTenant-Id: e5e7e96e-8a28-45d6-9093-a40dd5b51a57 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5e7e96e-8a28-45d6-9093-a40dd5b51a57; Ip=[77.74.96.169]; Helo=[securemail.duagon.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT006.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZR0P278MB1124 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Some F215 FPGA multifunction boards announce themselves as 215. This leads to a misconfigured clockrate. The F215 is the same board as G215 but with different cPCI interface so make them get the same configuration Co-developed-by: Jorge Sanjuan Garcia Signed-off-by: Jorge Sanjuan Garcia Signed-off-by: Javier Rodriguez --- drivers/tty/serial/8250/8250_men_mcb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c index f46ca13ff4aa..a2cdaeb61e00 100644 --- a/drivers/tty/serial/8250/8250_men_mcb.c +++ b/drivers/tty/serial/8250/8250_men_mcb.c @@ -37,10 +37,10 @@ static u32 men_lookup_uartclk(struct mcb_device *mdev) clkval = 1041666; else if (strncmp(mdev->bus->name, "F216", 4) == 0) clkval = 1843200; - else if (strncmp(mdev->bus->name, "G215", 4) == 0) - clkval = 1843200; else if (strncmp(mdev->bus->name, "F210", 4) == 0) clkval = 115200; + else if (strstr(mdev->bus->name, "215")) + clkval = 1843200; else dev_info(&mdev->dev, "board not detected, using default uartclk\n"); From patchwork Wed Jul 5 13:15:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Rodr=C3=ADguez_Barbarin=2C_Jos=C3=A9_Javier?= X-Patchwork-Id: 699549 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 93B7CEB64DA for ; Wed, 5 Jul 2023 13:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbjGENam (ORCPT ); Wed, 5 Jul 2023 09:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjGENal (ORCPT ); Wed, 5 Jul 2023 09:30:41 -0400 Received: from CHE01-ZR0-obe.outbound.protection.outlook.com (mail-zr0che01on2095.outbound.protection.outlook.com [40.107.24.95]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD1319A8; Wed, 5 Jul 2023 06:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xzzhH/rqjiPS4yBcZ466ZUkjNRvT5dcUCstQhyeZxqM=; b=AyFm1QKdPDUnrYYJpR7veH4APjrwhvEJZN4p29NSoCgG/L/z1OWQY3zAFljq8mcaly5HFNQmgSW2jdaUl4vkgH1OFmIVFsSNwbXZekPe+/yjBupmzp+KB70e9yUJwrtoA6A1e5NlCMG6dLVBqPWWB0uvcpK5vTm960ngvlYsGV8= Received: from DB7PR02CA0021.eurprd02.prod.outlook.com (2603:10a6:10:52::34) by ZR2P278MB1081.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:5f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:30:22 +0000 Received: from DB5EUR01FT054.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:52:cafe::d3) by DB7PR02CA0021.outlook.office365.com (2603:10a6:10:52::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:30:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 77.74.96.169) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 77.74.96.169 as permitted sender) receiver=protection.outlook.com; client-ip=77.74.96.169; helo=securemail.duagon.com; pr=C Received: from securemail.duagon.com (77.74.96.169) by DB5EUR01FT054.mail.protection.outlook.com (10.152.5.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.24 via Frontend Transport; Wed, 5 Jul 2023 13:30:21 +0000 Received: from securemail (localhost [127.0.0.1]) by securemail.duagon.com (Postfix) with SMTP id 4Qx0s91qfVzxpF; Wed, 5 Jul 2023 15:30:21 +0200 (CEST) Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01lp2045.outbound.protection.outlook.com [104.47.22.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by securemail.duagon.com (Postfix) with ESMTPS; Wed, 5 Jul 2023 15:30:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xzzhH/rqjiPS4yBcZ466ZUkjNRvT5dcUCstQhyeZxqM=; b=AyFm1QKdPDUnrYYJpR7veH4APjrwhvEJZN4p29NSoCgG/L/z1OWQY3zAFljq8mcaly5HFNQmgSW2jdaUl4vkgH1OFmIVFsSNwbXZekPe+/yjBupmzp+KB70e9yUJwrtoA6A1e5NlCMG6dLVBqPWWB0uvcpK5vTm960ngvlYsGV8= Received: from DU2PR04CA0283.eurprd04.prod.outlook.com (2603:10a6:10:28c::18) by ZR0P278MB0041.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:17::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:16 +0000 Received: from DB5EUR01FT029.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:28c:cafe::12) by DU2PR04CA0283.outlook.office365.com (2603:10a6:10:28c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:15:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.79.222.204) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 20.79.222.204 as permitted sender) receiver=protection.outlook.com; client-ip=20.79.222.204; helo=de2-emailsignatures-cloud.codetwo.com; pr=C Received: from de2-emailsignatures-cloud.codetwo.com (20.79.222.204) by DB5EUR01FT029.mail.protection.outlook.com (10.152.4.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.24 via Frontend Transport; Wed, 5 Jul 2023 13:15:16 +0000 Received: from CHE01-ZR0-obe.outbound.protection.outlook.com (104.47.22.113) by de2-emailsignatures-cloud.codetwo.com with CodeTwo SMTP Server (TLS12) via SMTP; Wed, 05 Jul 2023 13:15:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fg6OTZTSrgP+KAv4nI1UQQZkMD84ptsC+/B2maXLKgoJXqUw8AVopp4RJfmNh2Ld9fAjN6e6MygHIN+SMwUTLPB21qKCIgOArF3tPvsp7tessjAePr3VlWoeWQAHHqKbcoW1FDdEMrJ7DowtSGkNN/D0X7pkXV+E1IWGovetchFzbYcFmf8cfDu/RxGO3IC9bCEMeYSNvh2uI5PABsSb5JaBY+MV4RTriNgT/Ple7dnmyc4WH9RZp3VKAe5eqcPYktXCGD6x8AbOmflMLJCYZkP196eTOWEt9NOKxELIjWsQi1bckNzx3IxLedpVhfkdx+RneTc9+k6zJoGzBK/goA== 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=xzzhH/rqjiPS4yBcZ466ZUkjNRvT5dcUCstQhyeZxqM=; b=F4tc0hixQzaplcz6UDCTSdfMXYZSKcyWcHEyxpMxeWExRyyfajYFDkeo3COlMxZDZ5KVtB1QGmunR2X4wcOk29qsD+PtqNZByck8yvB80W6tKiZR7W9nBduLAFdmym6GE8YunWu900YkKsjdIhh7SYpv8V0+4Kh5hUfWW7MQc/guEinJdQNPeN6Ml/ft4PihgybmHVHGH+7ADzbk0TT/fJMJ9WEOLa4fcfbTSSNzxifWy1ho9DbWomdqGrpoJ8YWT9M81m+vSl6GRAdxI9XOlCG8ip7sjsAP1KK6JiBmHimcjUmAfdN0qGqcR6RXWggzGVSlOP3YWbso7JrZUIEhVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=duagon.com; dmarc=pass action=none header.from=duagon.com; dkim=pass header.d=duagon.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xzzhH/rqjiPS4yBcZ466ZUkjNRvT5dcUCstQhyeZxqM=; b=AyFm1QKdPDUnrYYJpR7veH4APjrwhvEJZN4p29NSoCgG/L/z1OWQY3zAFljq8mcaly5HFNQmgSW2jdaUl4vkgH1OFmIVFsSNwbXZekPe+/yjBupmzp+KB70e9yUJwrtoA6A1e5NlCMG6dLVBqPWWB0uvcpK5vTm960ngvlYsGV8= Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:4f::13) by ZRAP278MB0875.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:4a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:12 +0000 Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620]) by GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620%7]) with mapi id 15.20.6565.016; Wed, 5 Jul 2023 13:15:12 +0000 From: =?iso-8859-1?q?Rodr=EDguez_Barbarin=2C_Jos=E9_Javier?= To: "gregkh@linuxfoundation.org" , "jirislaby@kernel.org" CC: "morbidrsa@gmail.com" , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jth@kernel.org" , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jor?= =?iso-8859-1?q?ge?= , =?iso-8859-1?q?Rodr?= =?iso-8859-1?q?=EDguez_Barbarin=2C_Jos=E9_Javier?= , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jo?= =?iso-8859-1?q?rge?= Subject: [PATCH 2/3] 8250_men_mcb: Read num ports from register data. Thread-Topic: [PATCH 2/3] 8250_men_mcb: Read num ports from register data. Thread-Index: AQHZr0K629B3pWDifkyi2ePTTBFfaQ== Date: Wed, 5 Jul 2023 13:15:12 +0000 Message-ID: <20230705131423.30552-3-josejavier.rodriguez@duagon.com> References: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> In-Reply-To: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> Accept-Language: es-ES, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=duagon.com; x-ms-traffictypediagnostic: GV0P278MB0996:EE_|ZRAP278MB0875:EE_|DB5EUR01FT029:EE_|ZR0P278MB0041:EE_|DB5EUR01FT054:EE_|ZR2P278MB1081:EE_ X-MS-Office365-Filtering-Correlation-Id: 258f9141-1b8a-4818-2835-08db7d5bfba7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: lhYHM6Du2aVHf5ladjSBy50lbeyohmnXE/758/IVJMQONK0lMQYez69wO6APvTdQHPaqAM9XVFEzcyQS4hKLhApgr17KulygUB+jUEcJk/6N2Wcv2fztOZlyJksf0ijpZC3xM3JDvY8zfGA2+FJ0zowAA0SPjOJlE6n33ZdfCOiOn4BKR0ROTku7qN/tPpR9JLdCgy82vVa5RgpScsPVO1/CvE3V7Th4qZukjHeiTiU8kIkkfF1J3OxSMKH3AGzkAQkGxQ5NWE22mqNjQLGqJHBneNE6wYtl5bop7Idz34mi5Dk9AhOOkBrODClsB4wdHe/LPj7JMLLAtQP6bKWyA+AwnJsLqPtrs+240lnTpzcgb6MtiE6I05hsi3FZGEoNLfefG40TFN8/+lWVyg656Tgci0IDRMWKVNpzkZnvBehBcyPrqT/LVm74UG0MupeaxZ1+SbPDthUslGq5eAOXugt5PBMmllsPSdkGOmd+U9uv9peIq9ItaJLE4D4BDwiRCNDCZBmQwrdYIZ5aEGqkQw52y0x1vWcNQzLk/gqcEBWBRppF9tKvebPTkm+CzOj8tVZvD53Vkn96B1x/9qlM6hlguUDHE9fRvIETQ3vXKzGgvrTueYJ8DGk0yGYjgR1occDCw3CkzU91C3VWtY8RpA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(366004)(39850400004)(136003)(396003)(376002)(346002)(451199021)(76116006)(91956017)(66556008)(64756008)(4326008)(66476007)(66446008)(107886003)(122000001)(2616005)(38100700002)(38070700005)(86362001)(186003)(26005)(1076003)(66946007)(6506007)(83380400001)(478600001)(6512007)(6486002)(110136005)(36756003)(54906003)(41300700001)(8676002)(8936002)(2906002)(71200400001)(5660300002)(316002)(414714003); DIR:OUT; SFP:1102; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZRAP278MB0875 X-CodeTwo-MessageID: c799f95c-d563-4b6e-9a59-2dff1778767b.20230705131513@de2-emailsignatures-cloud.codetwo.com X-CodeTwoProcessed: true X-EOPAttributedMessage: 1 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR01FT029.eop-EUR01.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: da788636-1662-4c37-9146-08db7d59dd4a X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Ru4QdlEGXgh91IymW+xiLF9SrTrMewL3WbEgbAZiUfzGc6ncsC+Vx1NbLaX+XtWZKsL/1rZVI/NVOHg2Un+OBjxuguC7aqA0nv/CWNXVAZLnlDc/OYGwPH4m/yhloLpRodooC8mVvfSMNB697WJ9LdbGwE1eQrjEnxag5AB2ym41htmmhIpsnfmyAKIJZWflSlnt2CAKW92KvmYE3kEJXcUUR0vpyx1vhtUENC8oSQ7Nbbc3IHvEStdk+5v5WtV48YiI1M4Vgf23BVK2hJlZoMj6QsE7uSL04BMpJBtDuvDh+95eLORy9ZeLRYLKG5JwFNEbN7GjBxu30LQqTEf4Lcg1n8ZijlCgNe/uQVX/cHqLXcr/LFZ12oh8XSZNrCDk1Ltp3+209vNFU75y1y8c9qD0X/0ltCbWi7MRhBduhn3r4hMNffH0npVVeeQ8XAp3E01mknZ9cSukBGlhU0J6Lt4jA6L4a3KU5Q6hqduVCA5xa35iT9fYMxJD2cBXZC5P7acO0Yphf5eL+fc+UNcoz6lWstVVDxHq3u5HDxeWesKpZav9sGtZ/M03PKsXgGVfwk0HyoL4SBRegRj5UIiK2A7rU6iN4f2hvx9C6XG4ZesaVmbiCZJ0g2BBTQR94eKehfZ+p7hZQa4AfJKuDJA2ZeyGYIXtD/u6v9lXkbCKfZjn1PwkEf/E2SLMXgnKeP+1ZplVJ1ZXpHDnqIc/XIygdOwR+Ry9r4eV62yCagMm7Nw= X-Forefront-Antispam-Report-Untrusted: CIP:20.79.222.204; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:de2-emailsignatures-cloud.codetwo.com; PTR:de2-emailsignatures-cloud.codetwo.com; CAT:NONE; SFS:(13230028)(136003)(346002)(39850400004)(396003)(376002)(451199021)(36840700001)(46966006)(4326008)(316002)(2616005)(36860700001)(70586007)(83380400001)(8936002)(70206006)(336012)(2906002)(47076005)(86362001)(1076003)(5660300002)(356005)(8676002)(41300700001)(186003)(6486002)(6506007)(6512007)(478600001)(26005)(107886003)(110136005)(36756003)(54906003)(82740400003)(7636003)(40480700001)(7596003)(82310400005)(414714003); DIR:OUT; SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZR0P278MB0041 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR01FT054.eop-EUR01.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b1e3c0cd-bc6b-4be1-8f4f-08db7d59dfde X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zpUufDnF3SWBKVsvoBf2ouWMdzRwzUgj/JyS9KYatMkuOIVv9zqeg6UTO9453Kfa8G13WIXUGxP0YPPcQYTzg+a8xvUgc3kSXbK6R0qV3TDIezlomSKmQhHIbg20GRWja/fxe91MVpJsBhWFO7isTMbevxuvDwT3yca/ekC990WGFgkK/1mYN0F67cVRUYfQLkNfWgXHB0dhkT24AR7TnOwt50F4P9A9/Z8x9/aqlglSyayH6H/qG3OE1RDvl+UNopJkdPPNoLZjaQacBOLaK80HP+JcLT21419NfjHxnv/WhNxh0yQLYHcLk/OLwuk7cfA63UE7XrdmUVtMLT3rJx3jR6Q0cYEKnPLht1/tBoGKc0cpZGjqhvkCKHrgv5zkSLuiDV7Hv7qG57lw3Iq683uyfhtmpW1wcNWi2YGu1zP40O7cfboCeo5NOwCWfrOuHZmYf7XT34bCUDNbojk3XXppaG0cSLeYqXYGnXbH3QZfrJ6Ehwba/OD+7uV5zquZXo6OpFDfQzVJeaZXNTyedH25aGIkbfwGI/zTWBJ370P9qUV/7Ok/lf3XAgRIjbFODJyQGag6cxNr+TVl6ZcpM7WWMXRp9lJvcFFZC41nepsj3Dp72wxbIkR5kRTcnWNScop4r9PHgfq1JhVKCXXPzdLHNtk4hdnbg1qiV/UIwk5pJpalmk782/I25At9xWlgBoToobA9ZW6rUlOwIBCCdEbLxJBXqbwaDYcfBrdceNeGC/JORZoCCftXzKPA3qq6tZB+00RpoJiAFalY4efa9w== X-Forefront-Antispam-Report: CIP:77.74.96.169; CTRY:CH; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:securemail.duagon.com; PTR:169.96.74.77.ftth.as8758.net; CAT:NONE; SFS:(13230028)(346002)(39850400004)(376002)(136003)(396003)(451199021)(40470700004)(46966006)(36840700001)(2906002)(6512007)(40480700001)(81166007)(47076005)(36860700001)(2616005)(83380400001)(336012)(40460700003)(6486002)(70586007)(70206006)(4326008)(110136005)(54906003)(86362001)(316002)(82310400005)(36756003)(82740400003)(478600001)(1076003)(6506007)(5660300002)(186003)(26005)(8676002)(8936002)(41300700001)(107886003)(414714003); DIR:OUT; SFP:1102; X-OriginatorOrg: duagon.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 13:30:21.7933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 258f9141-1b8a-4818-2835-08db7d5bfba7 X-MS-Exchange-CrossTenant-Id: e5e7e96e-8a28-45d6-9093-a40dd5b51a57 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5e7e96e-8a28-45d6-9093-a40dd5b51a57; Ip=[77.74.96.169]; Helo=[securemail.duagon.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT054.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZR2P278MB1081 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The IP Core Z025 and Z057 have a register where the amount of UART ports is specified. Such register is located at offset 0x40. This patch fixes the way the UART ports is calculated by reading the actual register. Additionally a refactor was needed to achieve this so we can keep track of the UART line and its offset which also improves the remove callback. Co-developed-by: Jorge Sanjuan Garcia Signed-off-by: Jorge Sanjuan Garcia Signed-off-by: Javier Rodriguez --- drivers/tty/serial/8250/8250_men_mcb.c | 189 ++++++++++++++++++------- 1 file changed, 139 insertions(+), 50 deletions(-) diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c index a2cdaeb61e00..d6cfebb3ee8f 100644 --- a/drivers/tty/serial/8250/8250_men_mcb.c +++ b/drivers/tty/serial/8250/8250_men_mcb.c @@ -12,11 +12,42 @@ #define MEN_UART_ID_Z057 0x39 #define MEN_UART_ID_Z125 0x7d -#define MEN_UART_MEM_SIZE 0x10 +/* + * IP Cores Z025 and Z057 can have up to 4 UART + * The UARTs available are stored in a global + * register saved in physical address + 0x40 + * Is saved as follows: + * + * 7 0 + * +------+-------+-------+-------+-------+-------+-------+-------+ + * |UART4 | UART3 | UART2 | UART1 | U4irq | U3irq | U2irq | U1irq | + * +------+-------+-------+-------+-------+-------+-------+-------+ + */ +#define MEN_UART1_MASK 0x01 +#define MEN_UART2_MASK 0x02 +#define MEN_UART3_MASK 0x04 +#define MEN_UART4_MASK 0x08 + +#define MEN_Z125_UARTS_AVAILABLE 0x01 + +#define MEN_Z025_MAX_UARTS 4 +#define MEN_UART_MEM_SIZE 0x10 +#define MEM_UART_REGISTER_SIZE 0x01 +#define MEN_Z025_REGISTER_OFFSET 0x40 + +#define MEN_UART1_OFFSET 0 +#define MEN_UART2_OFFSET (MEN_UART1_OFFSET + MEN_UART_MEM_SIZE) +#define MEN_UART3_OFFSET (MEN_UART2_OFFSET + MEN_UART_MEM_SIZE) +#define MEN_UART4_OFFSET (MEN_UART3_OFFSET + MEN_UART_MEM_SIZE) + +#define MEN_READ_REGISTER(addr) readb((void *)addr) + +#define MAX_PORTS 4 struct serial_8250_men_mcb_data { - struct uart_8250_port uart; - int line; + int num_ports; + unsigned int line[MAX_PORTS]; + unsigned int offset[MAX_PORTS]; }; /* @@ -50,16 +81,82 @@ static u32 men_lookup_uartclk(struct mcb_device *mdev) return clkval; } -static int get_num_ports(struct mcb_device *mdev, - void __iomem *membase) +static int read_uarts_available_from_register(void __iomem *membase, + u8 *uarts_available) +{ + void __iomem *mem; + int reg_value; + + mem = membase + MEN_Z025_REGISTER_OFFSET; + + reg_value = MEN_READ_REGISTER(membase); + + *uarts_available = reg_value >> 4; + + return 0; +} + +static int read_serial_data(struct mcb_device *mdev, + void __iomem *membase, + struct serial_8250_men_mcb_data *serial_data) +{ + u8 uarts_available; + int count = 0; + int mask; + int res; + int i; + + res = read_uarts_available_from_register(membase, &uarts_available); + if (res < 0) + return res; + + for (i = 0; i < MAX_PORTS; i++) { + mask = 0x1 << i; + switch (uarts_available & mask) { + case MEN_UART1_MASK: + serial_data->offset[count] = MEN_UART1_OFFSET; + count++; + break; + case MEN_UART2_MASK: + serial_data->offset[count] = MEN_UART2_OFFSET; + count++; + break; + case MEN_UART3_MASK: + serial_data->offset[count] = MEN_UART3_OFFSET; + count++; + break; + case MEN_UART4_MASK: + serial_data->offset[count] = MEN_UART4_OFFSET; + count++; + break; + default: + return -EINVAL; + } + } + + if (count <= 0 || count > MAX_PORTS) { + dev_err(&mdev->dev, "unexpected number of ports: %u\n", + count); + return -ENODEV; + } + + serial_data->num_ports = count; + + return 0; +} + +static int init_serial_data(struct mcb_device *mdev, + void __iomem *membase, + struct serial_8250_men_mcb_data *serial_data) { switch (mdev->id) { case MEN_UART_ID_Z125: - return 1U; + serial_data->num_ports = 1; + serial_data->offset[0] = 0; + return 0; case MEN_UART_ID_Z025: - return readb(membase) >> 4; case MEN_UART_ID_Z057: - return 4U; + return read_serial_data(mdev, membase, serial_data); default: dev_err(&mdev->dev, "no supported device!\n"); return -ENODEV; @@ -69,11 +166,12 @@ static int get_num_ports(struct mcb_device *mdev, static int serial_8250_men_mcb_probe(struct mcb_device *mdev, const struct mcb_device_id *id) { + struct uart_8250_port uart; struct serial_8250_men_mcb_data *data; struct resource *mem; - int num_ports; int i; void __iomem *membase; + int res; mem = mcb_get_resource(mdev, IORESOURCE_MEM); if (mem == NULL) @@ -82,49 +180,46 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev, if (IS_ERR(membase)) return PTR_ERR_OR_ZERO(membase); - num_ports = get_num_ports(mdev, membase); - - dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n", - mdev->id, num_ports); - - if (num_ports <= 0 || num_ports > 4) { - dev_err(&mdev->dev, "unexpected number of ports: %u\n", - num_ports); - return -ENODEV; - } - - data = devm_kcalloc(&mdev->dev, num_ports, + data = devm_kzalloc(&mdev->dev, sizeof(struct serial_8250_men_mcb_data), GFP_KERNEL); if (!data) return -ENOMEM; + res = init_serial_data(mdev, membase, data); + if (res < 0) + return res; + + dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n", + mdev->id, data->num_ports); + mcb_set_drvdata(mdev, data); - for (i = 0; i < num_ports; i++) { - data[i].uart.port.dev = mdev->dma_dev; - spin_lock_init(&data[i].uart.port.lock); - - data[i].uart.port.type = PORT_16550; - data[i].uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ - | UPF_FIXED_TYPE; - data[i].uart.port.iotype = UPIO_MEM; - data[i].uart.port.uartclk = men_lookup_uartclk(mdev); - data[i].uart.port.regshift = 0; - data[i].uart.port.irq = mcb_get_irq(mdev); - data[i].uart.port.membase = membase; - data[i].uart.port.fifosize = 60; - data[i].uart.port.mapbase = (unsigned long) mem->start - + i * MEN_UART_MEM_SIZE; - data[i].uart.port.iobase = data[i].uart.port.mapbase; + for (i = 0; i < data->num_ports; i++) { + uart.port.dev = mdev->dma_dev; + spin_lock_init(&uart.port.lock); + + uart.port.type = PORT_16550; + uart.port.flags = UPF_SKIP_TEST | + UPF_SHARE_IRQ | + UPF_FIXED_TYPE; + uart.port.iotype = UPIO_MEM; + uart.port.uartclk = men_lookup_uartclk(mdev); + uart.port.regshift = 0; + uart.port.irq = mcb_get_irq(mdev); + uart.port.membase = membase; + uart.port.fifosize = 60; + uart.port.mapbase = (unsigned long) mem->start + + data->offset[i]; + uart.port.iobase = uart.port.mapbase; /* ok, register the port */ - data[i].line = serial8250_register_8250_port(&data[i].uart); - if (data[i].line < 0) { + data->line[i] = serial8250_register_8250_port(&uart); + if (data->line[i] < 0) { dev_err(&mdev->dev, "unable to register UART port\n"); - return data[i].line; + return data->line[i]; } - dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data[i].line); + dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data->line[i]); } return 0; @@ -132,20 +227,14 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev, static void serial_8250_men_mcb_remove(struct mcb_device *mdev) { - int num_ports, i; + int i; struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev); if (!data) return; - num_ports = get_num_ports(mdev, data[0].uart.port.membase); - if (num_ports <= 0 || num_ports > 4) { - dev_err(&mdev->dev, "error retrieving number of ports!\n"); - return; - } - - for (i = 0; i < num_ports; i++) - serial8250_unregister_port(data[i].line); + for (i = 0; i < data->num_ports; i++) + serial8250_unregister_port(data->line[i]); } static const struct mcb_device_id serial_8250_men_mcb_ids[] = { From patchwork Wed Jul 5 13:15:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Rodr=C3=ADguez_Barbarin=2C_Jos=C3=A9_Javier?= X-Patchwork-Id: 701453 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 2E8D0EB64DD for ; Wed, 5 Jul 2023 13:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbjGENaM (ORCPT ); Wed, 5 Jul 2023 09:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjGENaD (ORCPT ); Wed, 5 Jul 2023 09:30:03 -0400 Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01on2131.outbound.protection.outlook.com [40.107.23.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE80172B; Wed, 5 Jul 2023 06:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G0SPDFXW9gAskqM3xBT6zq4oExo4cox1IwDqU/HcNCc=; b=wgjKLn+31o3BPI1jvDEvv2Vhsw7Hk0QmOJePV+LVX7jKZH7sPy9WHGF089yM1h6kcmmDZKLKeXv9AYtR+uMjjXjKNiBHaZtE0kuUUD8Bd8a01UGQNSzHFOU7Jsd2wgel4YmpNmkP7+w9L4jcWIXrs3nkAWXY9z+KFWB6e4dK4ps= Received: from FR3P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::14) by ZRAP278MB0047.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:11::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:29:48 +0000 Received: from VE1EUR01FT019.eop-EUR01.prod.protection.outlook.com (2603:10a6:d10:95:cafe::3d) by FR3P281CA0141.outlook.office365.com (2603:10a6:d10:95::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:29:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 77.74.96.169) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 77.74.96.169 as permitted sender) receiver=protection.outlook.com; client-ip=77.74.96.169; helo=securemail.duagon.com; pr=C Received: from securemail.duagon.com (77.74.96.169) by VE1EUR01FT019.mail.protection.outlook.com (10.152.2.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:29:47 +0000 Received: from securemail (localhost [127.0.0.1]) by securemail.duagon.com (Postfix) with SMTP id 4Qx0rW2Yl5zxpF; Wed, 5 Jul 2023 15:29:47 +0200 (CEST) Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01lp2041.outbound.protection.outlook.com [104.47.22.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by securemail.duagon.com (Postfix) with ESMTPS; Wed, 5 Jul 2023 15:29:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G0SPDFXW9gAskqM3xBT6zq4oExo4cox1IwDqU/HcNCc=; b=wgjKLn+31o3BPI1jvDEvv2Vhsw7Hk0QmOJePV+LVX7jKZH7sPy9WHGF089yM1h6kcmmDZKLKeXv9AYtR+uMjjXjKNiBHaZtE0kuUUD8Bd8a01UGQNSzHFOU7Jsd2wgel4YmpNmkP7+w9L4jcWIXrs3nkAWXY9z+KFWB6e4dK4ps= Received: from BE1P281CA0021.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:15::7) by GV0P278MB1143.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:4c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:19 +0000 Received: from VE1EUR01FT026.eop-EUR01.prod.protection.outlook.com (2603:10a6:b10:15:cafe::13) by BE1P281CA0021.outlook.office365.com (2603:10a6:b10:15::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:15:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.79.222.204) smtp.mailfrom=duagon.com; dkim=pass (signature was verified) header.d=duagon.com;dmarc=pass action=none header.from=duagon.com; Received-SPF: Pass (protection.outlook.com: domain of duagon.com designates 20.79.222.204 as permitted sender) receiver=protection.outlook.com; client-ip=20.79.222.204; helo=de2-emailsignatures-cloud.codetwo.com; pr=C Received: from de2-emailsignatures-cloud.codetwo.com (20.79.222.204) by VE1EUR01FT026.mail.protection.outlook.com (10.152.2.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Wed, 5 Jul 2023 13:15:19 +0000 Received: from CHE01-ZR0-obe.outbound.protection.outlook.com (104.47.22.113) by de2-emailsignatures-cloud.codetwo.com with CodeTwo SMTP Server (TLS12) via SMTP; Wed, 05 Jul 2023 13:15:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ValJuxGp/DSiMN1xHdnzUkQzstd6AfuBdpEa9o45jL7+FA8XPAjIOfLPXLm5eOCsP0goTnTAz3CxScEgP+rDxU1I3ecmUnAGm2GCceKoA6I5wANZ6FioBA7Pbju2EfbvyBrWAz6aJc2dWUuy4pELmfcn4Kbx5Wpw5GcZTg2cbYVpp9JvD8JyR95DQWqhn3/V/klhSQdI28pGBWoGngyrn0qvfZsgznk5rcJUzcfc96sJzH69kugkC87hoNrDy5HsszTaXxFHdEF8Pt590d1v3lXGOW/wCmLqKk9JypOhGS9DjlnzjYJu4W84V9jCPQTto1F1Sz0yHhbT89bvUUmZ6w== 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=G0SPDFXW9gAskqM3xBT6zq4oExo4cox1IwDqU/HcNCc=; b=X+5/9k1fvHphVt62RDIwcLbWQjf8zsHc4a566eJeg5Zo9IYJoBAs2axsgim7lbS/LOeU8QB3AmXdW5lIq5r7sLk/Bb4RE0DwASkKs4rWDV+At5T6icdMA3BWO64rBhfDxha+VgiyoBz8P1YzIEsUnBweYWQdueqLgpep4KqZQnuQeRqH2F8rVVogNruasqdrEGbroCs4iuAJSfaPBRAhtYcs9XVYDAx4eGDLYjKspDw0Rml1Gj/MfCwKeQI8UPeXYTz+XBhupfqSfVplfy8KF0eTbCoXV6hW+7hVq2HhqfQFvLEg+57WBEK0Oz+ombzgxFITZKcjp6XeJPgYVYIU5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=duagon.com; dmarc=pass action=none header.from=duagon.com; dkim=pass header.d=duagon.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duagon.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G0SPDFXW9gAskqM3xBT6zq4oExo4cox1IwDqU/HcNCc=; b=wgjKLn+31o3BPI1jvDEvv2Vhsw7Hk0QmOJePV+LVX7jKZH7sPy9WHGF089yM1h6kcmmDZKLKeXv9AYtR+uMjjXjKNiBHaZtE0kuUUD8Bd8a01UGQNSzHFOU7Jsd2wgel4YmpNmkP7+w9L4jcWIXrs3nkAWXY9z+KFWB6e4dK4ps= Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:4f::13) by ZRAP278MB0875.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:4a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 13:15:15 +0000 Received: from GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620]) by GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM ([fe80::8c78:4a4d:bc93:c620%7]) with mapi id 15.20.6565.016; Wed, 5 Jul 2023 13:15:15 +0000 From: =?iso-8859-1?q?Rodr=EDguez_Barbarin=2C_Jos=E9_Javier?= To: "gregkh@linuxfoundation.org" , "jirislaby@kernel.org" CC: "morbidrsa@gmail.com" , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jth@kernel.org" , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jor?= =?iso-8859-1?q?ge?= , =?iso-8859-1?q?Rodr?= =?iso-8859-1?q?=EDguez_Barbarin=2C_Jos=E9_Javier?= , =?iso-8859-1?q?Sanju=E1n_Garc=EDa=2C_Jo?= =?iso-8859-1?q?rge?= Subject: [PATCH 3/3] 8250_men_mcb: Make UART config auto configurable Thread-Topic: [PATCH 3/3] 8250_men_mcb: Make UART config auto configurable Thread-Index: AQHZr0K8fcTuFeeK1UG0aZ2WCr9cvg== Date: Wed, 5 Jul 2023 13:15:14 +0000 Message-ID: <20230705131423.30552-4-josejavier.rodriguez@duagon.com> References: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> In-Reply-To: <20230705131423.30552-1-josejavier.rodriguez@duagon.com> Accept-Language: es-ES, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=duagon.com; x-ms-traffictypediagnostic: GV0P278MB0996:EE_|ZRAP278MB0875:EE_|VE1EUR01FT026:EE_|GV0P278MB1143:EE_|VE1EUR01FT019:EE_|ZRAP278MB0047:EE_ X-MS-Office365-Filtering-Correlation-Id: 15983490-9cba-4174-8caa-08db7d5be74d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: yY+6sxmOeqL9MDy1N2irpguXlz9oIECGi5rXaxzBsE2rWrZT/+F2Bc94qIuvJmXLgsAp40oplHi1SEHq1W1QxI7oLCaKXDKIfvyvzgQYz2PePLk/f0jgJEDynVxU8hRRUXHpK5Z7tYyOFY10nhsSiuHVWkM4BY6xP6YKx08dz2pDi4BPIUVoxRA3sI7bEPmq9yLKX9Ekfv7Qaz7yvMiHvRKHLosjjUIYza3GO3N37fa6AXFTWGsPtAXwH27FBHSlD5JoXTGcUb6bu/F9gvFpuHaKwUv1Iq+E+PmGZK3KfBvzlLZYnKKud18rZaEm5D+jaUfVqyCLyPeAA6Qd6c8Chp9I6kstJw69k2xaTkUVYgH/yVHc3csxafd3iSqJmkKvwoskN6PEXnE748aXsZPSPyT0PR8pv2ZDtGhmCprLFde9NCH778mWiNo7PftEW+xwJe2dWJdF4Gzd62brUC0kIefya7cFjYXQ3nn+HJVSd4DmMHX+fFF+WXnVfu/pbDnbB7jpDenmgVhqhLrmxMRRTK0suWOCKhHsYsMFy1VySg2K7tJdseDNGZKeM+jcNcHSHazLHLlu70gpspfCmzhTF4slTbYRz1805Dahgzy7kvlN1iRSX+jWSwtdiBrKuTvG X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV0P278MB0996.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(366004)(39850400004)(136003)(396003)(376002)(346002)(451199021)(76116006)(91956017)(66556008)(64756008)(4326008)(66476007)(66446008)(107886003)(122000001)(2616005)(38100700002)(38070700005)(86362001)(186003)(26005)(1076003)(66946007)(6506007)(83380400001)(478600001)(6512007)(6486002)(110136005)(36756003)(54906003)(41300700001)(8676002)(8936002)(2906002)(71200400001)(5660300002)(316002); DIR:OUT; SFP:1102; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZRAP278MB0875 X-CodeTwo-MessageID: a68b4dec-18bc-49a4-9442-9e90e5355dd3.20230705131516@de2-emailsignatures-cloud.codetwo.com X-CodeTwoProcessed: true X-EOPAttributedMessage: 1 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR01FT026.eop-EUR01.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9f388168-5750-4cef-c559-08db7d59def7 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: rRP6giMqTzfVd4EEHE9BKFQPRA44cdUnE0r+36vNedJUEfyso1BB7BT/0VGv/LTT91CRHURdG0w2DN9mSRKnyKAaUXjSVrTWSJn3dPe2lpMz+1V4xkiDUHq3K8sRECxSwqFK8zDsimka6+4+IYilhhwGkLWwxc6+j/rWNoC9alXLkseLG4ATP1HsWmeW2dNK+jWijxO9aGqtIcAHpFQj2sDMFLmUhKON+E7UwbjIsIdpAMwH6bWsQCuYzfG1iJVBp/h4iJIWOehpEsBx9xSuyER1EO3RtZVSDY53kJYf3J45Pxi3/DpMrdXh6MtX89xbXZmtNPC+RLrJFFqgRLUD9w1ssMN8J4tSt7/dr+Gv3cfLWKSkJ+gNE7zU4t0kiL3gZoI+SlHUfTUvhLrCYe87ZghP0NpPGkELd16qKDMTF0ewLZq5PiCwow7MvSG42YySaRG6X7EhqiI2/6VbO5cYaEE0pXik5/NatVRN3cE1U0KK4VYmdvtI1DnPYpIo9HGL0ajdIR8xyBE68fkT+0O8ug/I4mQscEAvfjLLWlxNqdJr7bk0n5eUsQGlXW1zX2tsHMEQM2YRBGE1TAYcpXKFEjEBgV0AJ99aJzp9L9L2fygvctLCl+uZUyWKcp/cq5Fqu9555EDEScaVa9FNRVkIPuZzycw1pXzkQR2SHwPwyOIukhgiCGUHS/7mNL5oxx+adBVKCHwPMf+NY7X6sQR+zw== X-Forefront-Antispam-Report-Untrusted: CIP:20.79.222.204; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:de2-emailsignatures-cloud.codetwo.com; PTR:de2-emailsignatures-cloud.codetwo.com; CAT:NONE; SFS:(13230028)(396003)(346002)(136003)(376002)(39850400004)(451199021)(36840700001)(46966006)(36756003)(86362001)(82310400005)(2906002)(5660300002)(40480700001)(47076005)(6512007)(186003)(336012)(36860700001)(83380400001)(6506007)(1076003)(26005)(107886003)(82740400003)(7596003)(7636003)(356005)(6486002)(54906003)(110136005)(70206006)(4326008)(2616005)(316002)(70586007)(8676002)(478600001)(8936002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV0P278MB1143 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR01FT019.eop-EUR01.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d7b282c6-47a3-4c41-f5ce-08db7d59e186 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Av/sZNBvqulMREBWFY2ro33pddPwPHHC1T+L1cnzjLcC8NK6arP4+jUbMWPfHXZG2qhwUEogt4Q2v+ASRoCgDj2SQU7sSA0DIVrpjnmhasirGF2KsQq7+dCDfkRbf68L7ZAf5iSvSS9IePCO0Qtex39sV+VZPgkIFghwR1GMW7ljVNB9/9qL+z/CyPqM1YQzaF/r7oURK/DChbdQptbQ2Rw3P954VD2SFWFWVWMU8WTTv7xuCzLN2eA4JHOtHiJ1chCoehgW0McUzC8wORYMt0KkusuDtmjZDY0FLPjIiHq27E5CXM6GEqTeJvznR8fvqwGS3NgLw6hqPtddU/9/Ibzj643zkdodZ9ZBdOLKxO5IXVjterUZZ3Hc8mUc7bZI79eEO8jXNpTGXMF3EG5xmfKOvIojCT77X5bjeCYZe5hiUX00jYSNWsIgYxVJBphsMHVMyz7xhjqhKqspJALQdgAkMXIl0Cwv9nhQNA8iH3FJIGf+XZUdE2xwrVqTve+8oj0oSWFH5795XGLCDHEyWuEQvqoXEwcFgJBCGzNyGT61qCqz4fcHk+IYwXtaDgMKxzwhQlWxOGFXAIWNYwfngw+yV1VueHJCUjZYNjZhiTPp0OMenlEKKiX88+uQvrTjGTPZY8xX1MQsHeHCNeK27wQg0/CVCX8x3tEb/RUMHRO2WNAggGYwJxwkEo7W80YWyHxsmjJ660sPe0sNo2IwNTIIeIHZvTtiLEcEvETh0/Pu+o34N3brwqGae43oaUj7 X-Forefront-Antispam-Report: CIP:77.74.96.169; CTRY:CH; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:securemail.duagon.com; PTR:169.96.74.77.ftth.as8758.net; CAT:NONE; SFS:(13230028)(396003)(346002)(376002)(39850400004)(136003)(451199021)(40470700004)(36840700001)(46966006)(82740400003)(6512007)(316002)(6486002)(86362001)(2906002)(40480700001)(4326008)(478600001)(70586007)(70206006)(40460700003)(5660300002)(36756003)(110136005)(54906003)(81166007)(336012)(2616005)(83380400001)(8676002)(82310400005)(8936002)(47076005)(36860700001)(186003)(1076003)(6506007)(107886003)(26005)(41300700001); DIR:OUT; SFP:1102; X-OriginatorOrg: duagon.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 13:29:47.6672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15983490-9cba-4174-8caa-08db7d5be74d X-MS-Exchange-CrossTenant-Id: e5e7e96e-8a28-45d6-9093-a40dd5b51a57 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5e7e96e-8a28-45d6-9093-a40dd5b51a57; Ip=[77.74.96.169]; Helo=[securemail.duagon.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT019.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZRAP278MB0047 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The UART ports created by this driver were not usable out of the box, so let the configuration be handled by the 8250 UART subsystem. This makes the implementation simpler and the UART port more usable. The 8250 UART subsystem will take care of requesting the memory resources, but the driver needs to first read the register where the num ports is set, so a request of the resource is needed before registering the UART port. Co-developed-by: Jorge Sanjuan Garcia Signed-off-by: Jorge Sanjuan Garcia Signed-off-by: Javier Rodriguez --- drivers/tty/serial/8250/8250_men_mcb.c | 43 ++++++++++++++------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c index d6cfebb3ee8f..c3143ffddea0 100644 --- a/drivers/tty/serial/8250/8250_men_mcb.c +++ b/drivers/tty/serial/8250/8250_men_mcb.c @@ -81,15 +81,28 @@ static u32 men_lookup_uartclk(struct mcb_device *mdev) return clkval; } -static int read_uarts_available_from_register(void __iomem *membase, +static int read_uarts_available_from_register(struct resource *mem_res, u8 *uarts_available) { void __iomem *mem; int reg_value; - mem = membase + MEN_Z025_REGISTER_OFFSET; + if (!request_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET, + MEM_UART_REGISTER_SIZE, KBUILD_MODNAME)) { + return -EBUSY; + } + + mem = ioremap(mem_res->start + MEN_Z025_REGISTER_OFFSET, + MEM_UART_REGISTER_SIZE); + if (IS_ERR(mem)) + return -ENOMEM; + + reg_value = MEN_READ_REGISTER(mem); + + iounmap(mem); - reg_value = MEN_READ_REGISTER(membase); + release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET, + MEM_UART_REGISTER_SIZE); *uarts_available = reg_value >> 4; @@ -97,7 +110,7 @@ static int read_uarts_available_from_register(void __iomem *membase, } static int read_serial_data(struct mcb_device *mdev, - void __iomem *membase, + struct resource *mem_res, struct serial_8250_men_mcb_data *serial_data) { u8 uarts_available; @@ -106,7 +119,7 @@ static int read_serial_data(struct mcb_device *mdev, int res; int i; - res = read_uarts_available_from_register(membase, &uarts_available); + res = read_uarts_available_from_register(mem_res, &uarts_available); if (res < 0) return res; @@ -146,7 +159,7 @@ static int read_serial_data(struct mcb_device *mdev, } static int init_serial_data(struct mcb_device *mdev, - void __iomem *membase, + struct resource *mem_res, struct serial_8250_men_mcb_data *serial_data) { switch (mdev->id) { @@ -156,7 +169,7 @@ static int init_serial_data(struct mcb_device *mdev, return 0; case MEN_UART_ID_Z025: case MEN_UART_ID_Z057: - return read_serial_data(mdev, membase, serial_data); + return read_serial_data(mdev, mem_res, serial_data); default: dev_err(&mdev->dev, "no supported device!\n"); return -ENODEV; @@ -170,15 +183,11 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev, struct serial_8250_men_mcb_data *data; struct resource *mem; int i; - void __iomem *membase; int res; mem = mcb_get_resource(mdev, IORESOURCE_MEM); if (mem == NULL) return -ENXIO; - membase = devm_ioremap_resource(&mdev->dev, mem); - if (IS_ERR(membase)) - return PTR_ERR_OR_ZERO(membase); data = devm_kzalloc(&mdev->dev, sizeof(struct serial_8250_men_mcb_data), @@ -186,7 +195,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev, if (!data) return -ENOMEM; - res = init_serial_data(mdev, membase, data); + res = init_serial_data(mdev, mem, data); if (res < 0) return res; @@ -196,22 +205,18 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev, mcb_set_drvdata(mdev, data); for (i = 0; i < data->num_ports; i++) { - uart.port.dev = mdev->dma_dev; + memset(&uart, 0, sizeof(struct uart_8250_port)); spin_lock_init(&uart.port.lock); - uart.port.type = PORT_16550; uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | - UPF_FIXED_TYPE; + UPF_BOOT_AUTOCONF | + UPF_IOREMAP; uart.port.iotype = UPIO_MEM; uart.port.uartclk = men_lookup_uartclk(mdev); - uart.port.regshift = 0; uart.port.irq = mcb_get_irq(mdev); - uart.port.membase = membase; - uart.port.fifosize = 60; uart.port.mapbase = (unsigned long) mem->start + data->offset[i]; - uart.port.iobase = uart.port.mapbase; /* ok, register the port */ data->line[i] = serial8250_register_8250_port(&uart);