From nobody Tue Feb 10 05:45:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54011+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=nxp.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1581060242973566.5108450151859; Thu, 6 Feb 2020 23:24:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id OqPaYY1788612x6F5mlRtevr; Thu, 06 Feb 2020 23:24:02 -0800 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.1330.1581060240337512135 for ; Thu, 06 Feb 2020 23:24:02 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I5gqxhUfEVQcxthNHfD6PCnWXz5/aMiu58N1p1MRnIBLsSC6ZSW2j1xbpDqcrjzZ1V5fu0TyLkTldo7eYVBT0SbmyTTA2dzPInlPuDrbAOc/qal0JWqvHEPTqZVz5XcvbOa6hgvQEX8dLs1zQDpuwV6rc1AiPmG0bc0LX8uIczM78SUYSAf24T60gK3K168Yw2xsjtklxdIztJym44rZEu1xM/41kRQEU9fSyeOu2WQO2a10p5dRz+ypY9XKyiQttA3tzyIvyd7A5B0kCSPwglwi+Kx/+FjhvYkYZgQGVNH31O7sHEoEUbNNLTRqrnZndCYNLraZekVZZf/uADIB9Q== 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-SenderADCheck; bh=8CT0rKGxzX90bzUs50zKc1IQfdDkhVBcO14bI74DgHs=; b=TNXtRikns0LNBr0vmsebhBZgvAZIDB2FdPc3uBf+soUydyS36TCgzz7ora1MYKecZeGfGmwVLo9RJh0DRrdeSihLzx2gPDjVQl6Bj3E8GGFryNlubIDT9/vLVjEN7jV+glccCJi4DhG7vah6DPd7Trv2qESNsuIH4wMFbGRBzU0UIki/q8jS8ULZQSNfk+yX2f+renhU0bVNmsFxlW+QatNb3D2h6gCZHU1+nIFQBbojefalHO6USOcr2EACPU9kOw3As5nzghtLVj6FTgDL7RG+aJveqVL/L+0u81feJ1FFTBdUzEzNiijdrXHVXgQmT8xnSewZpIUmuj3NaYo60A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none X-Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com (10.168.65.10) by VI1PR0401MB2686.eurprd04.prod.outlook.com (10.168.67.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21; Fri, 7 Feb 2020 07:23:59 +0000 X-Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::8823:663d:c6ed:cbd6]) by VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::8823:663d:c6ed:cbd6%12]) with mapi id 15.20.2686.036; Fri, 7 Feb 2020 07:23:59 +0000 From: "Pankaj Bansal" To: Leif Lindholm , Meenakshi Aggarwal , Michael D Kinney , Varun Sethi Cc: devel@edk2.groups.io, Pankaj Bansal Subject: [edk2-devel] [PATCH 05/19] NXP/BaseSerialPortLib16550: remove SerialPortInitalize functionality Date: Fri, 7 Feb 2020 18:13:14 +0530 Message-Id: <20200207124328.8723-6-pankaj.bansal@nxp.com> In-Reply-To: <20200207124328.8723-1-pankaj.bansal@nxp.com> References: <20200207124328.8723-1-pankaj.bansal@nxp.com> X-ClientProxiedBy: PN1PR01CA0103.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00::19) To VI1PR0401MB2496.eurprd04.prod.outlook.com (2603:10a6:800:56::10) MIME-Version: 1.0 X-Received: from uefi-workstation.ap.freescale.net (92.120.1.69) by PN1PR01CA0103.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21 via Frontend Transport; Fri, 7 Feb 2020 07:23:57 +0000 X-Originating-IP: [92.120.1.69] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 35647384-2921-4172-9281-08d7ab9eb2c5 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2686:|VI1PR0401MB2686: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+54011+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: SkXcBZayRA2Ja7xlUHZM4vMJR7PRMaThPc88vUetjMJLake7hiqmrxFBz3A4UcBaBrrlVBnQJORHTHjRDRv+6fiA3JCBmg5REknlgHdYmsySUcLVOSysL/XQ1QPqUYMtg1md0LkvRMRCjt3H5BwV84lKpzxoArAm3LPIjLIneTqr8nJgZZuKAZFJWlyslqyNKbA1Vq6GdMrD6gvlCFhM3wGg6jIbXxFTR7JgVHDeT5c86sl29M0c+MuZ/ZcM0KyxVKXEOKM8zzG9ZjbpuCoglugbBKNX9DK5iKpUOHDF+EfdYB/9yc4b3a3FOnePoMKjXGAxVOI1hgY9BgxauuSUgFTrhPetu5fmNIBaJ8jwkzQclwdr4Pw/fD7vYvLVxlDQGhos1ijCxY82NqCEu2IzkvU4XlVhY2hF0/ui9s9AXpW92ivDX9A+pJQf1+FhK04B X-MS-Exchange-AntiSpam-MessageData: bk1LsTtJRQqp8beLMY82TeShA8qOH+ZnHR6zEzrHVnPYg7qw1IqEfyR7bjd9ZE6d8JNDrWhGt1DJoXmh3i50I0O7qvtk2iAYYk8WyL1C0V6u5aC4X/ZpRLF5OiQK1Akv4sWKIiF/sIXVeNnbfxNwGQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35647384-2921-4172-9281-08d7ab9eb2c5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2020 07:23:59.1708 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tiVcGbFQDJuyhTvXdV2cYBOj9piMgSFL6YmJPNTi9rhQII6PsMcW/mIyEwHhLF4+xdDjCU5jk2hPUHj1qgx+1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2686 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pankaj.bansal@nxp.com X-Gm-Message-State: j3GIwmexmDKUwyXPvB5KM01Mx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1581060242; bh=zaonJVbTSZ+k6JnU/g+CxfNwPDMqP4qwuGP4vlr0ocI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=EwhKvhpCWlOPIoc6zqorkF+JTkxU9VE84x0Gm7ziyOf5Cu5F1lxOcU4JPQMMKserZXa QCw636JOMcsqbqpv3BEI9acK/eVFlLVAIuxcZ36OVXkAsDcjw2Qe3evjwuaWBIpJtMtSt MIxfql79w9fA8HhU7r+3Y1j6qJeUJw5Q4cY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" SerialPortInitalize is called from DebugLib constructor. so this gets called for each of the module in system. now, during SerialPortInitalize, we need the Uart clock to set it's baud rate. This Uart clock retrieval is implemented in SocLib and it usually involves reading SysClock information (from FPGA or from clock generator) so it's an unnecessary overhead, that can be avoided because we have already initalized SerialPort in SEC phase. Therefore, return SUCCESS from SerialPortInitalize everytime, without doing anything. In SEC phase we use SerialPortSetAttributes with default parameters to mimic SerialPortInitalize. Signed-off-by: Pankaj Bansal --- .../BaseSerialPortLib16550.c | 109 ++++-------------- Silicon/NXP/Library/SocLib/Chassis2/Soc.c | 25 +++- Silicon/NXP/Library/SocLib/LS1043aSocLib.inf | 6 +- 3 files changed, 51 insertions(+), 89 deletions(-) diff --git a/Silicon/NXP/Library/BaseSerialPortLib16550/BaseSerialPortLib16= 550.c b/Silicon/NXP/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c index 2c5c54ac7d..6b2aa46ff6 100644 --- a/Silicon/NXP/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c +++ b/Silicon/NXP/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c @@ -176,92 +176,6 @@ SerialPortInitialize ( VOID ) { - UINTN SerialRegisterBase; - UINT32 Divisor; - UINT32 CurrentDivisor; - BOOLEAN Initialized; - UINT64 SerialClock; - - // - // Perform platform specific initialization required to enable use of th= e 16550 device - // at the location specified by PcdSerialUseMmio and PcdSerialRegisterBa= se. - // - SerialClock =3D GetBusFrequency (); - if (SerialClock =3D=3D 0) { - return EFI_DEVICE_ERROR; - } - - // - // Calculate divisor for baud generator - // Ref_Clk_Rate / Baud_Rate / 16 - // - Divisor =3D SerialClock / (PcdGet32 (PcdSerialBaudRate) * 16); - if ((SerialClock % (PcdGet32 (PcdSerialBaudRate) * 16)) >=3D PcdGet32 (P= cdSerialBaudRate) * 8) { - Divisor++; - } - - // - // Get the base address of the serial port in either I/O or MMIO space - // - SerialRegisterBase =3D GetSerialRegisterBase (); - if (SerialRegisterBase =3D=3D 0) { - return RETURN_DEVICE_ERROR; - } - - // - // See if the serial port is already initialized - // - Initialized =3D TRUE; - if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & 0x3F) != =3D (PcdGet8 (PcdSerialLineControl) & 0x3F)) { - Initialized =3D FALSE; - } - SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialP= ortReadRegister (SerialRegisterBase, R_UART_LCR) | B_UART_LCR_DLAB)); - CurrentDivisor =3D SerialPortReadRegister (SerialRegisterBase, R_UART_B= AUD_HIGH) << 8; - CurrentDivisor |=3D (UINT32) SerialPortReadRegister (SerialRegisterBase,= R_UART_BAUD_LOW); - SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialP= ortReadRegister (SerialRegisterBase, R_UART_LCR) & ~B_UART_LCR_DLAB)); - if (CurrentDivisor !=3D Divisor) { - Initialized =3D FALSE; - } - if (Initialized) { - return RETURN_SUCCESS; - } - - // - // Wait for the serial port to be ready. - // Verify that both the transmit FIFO and the shift register are empty. - // - while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UAR= T_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)); - - // - // Configure baud rate - // - SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB= ); - SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (= Divisor >> 8)); - SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (D= ivisor & 0xff)); - - // - // Clear DLAB and configure Data Bits, Parity, and Stop Bits. - // Strip reserved bits from PcdSerialLineControl - // - SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(PcdGet8= (PcdSerialLineControl) & 0x3F)); - - // - // Enable and reset FIFOs - // Strip reserved bits from PcdSerialFifoControl - // - SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, 0x00); - SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8= (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64))); - - // - // Set FIFO Polled Mode by clearing IER after setting FCR - // - SerialPortWriteRegister (SerialRegisterBase, R_UART_IER, 0x00); - - // - // Put Modem Control Register(MCR) into its reset state of 0x00. - // - SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, 0x00); - return RETURN_SUCCESS; } =20 @@ -785,6 +699,12 @@ SerialPortSetAttributes ( Divisor++; } =20 + // + // Wait for the serial port to be ready. + // Verify that both the transmit FIFO and the shift register are empty. + // + while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UAR= T_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)); + // // Configure baud rate // @@ -799,6 +719,23 @@ SerialPortSetAttributes ( Lcr =3D (UINT8) ((LcrParity << 3) | (LcrStop << 2) | LcrData); SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8) (Lcr & = 0x3F)); =20 + // + // Enable and reset FIFOs + // Strip reserved bits from PcdSerialFifoControl + // + SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, 0x00); + SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8= (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64))); + + // + // Set FIFO Polled Mode by clearing IER after setting FCR + // + SerialPortWriteRegister (SerialRegisterBase, R_UART_IER, 0x00); + + // + // Put Modem Control Register(MCR) into its reset state of 0x00. + // + SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, 0x00); + return RETURN_SUCCESS; } =20 diff --git a/Silicon/NXP/Library/SocLib/Chassis2/Soc.c b/Silicon/NXP/Librar= y/SocLib/Chassis2/Soc.c index bfb8b8cb33..5a1a7376cd 100644 --- a/Silicon/NXP/Library/SocLib/Chassis2/Soc.c +++ b/Silicon/NXP/Library/SocLib/Chassis2/Soc.c @@ -1,7 +1,7 @@ /** @Soc.c SoC specific Library containg functions to initialize various SoC compon= ents =20 - Copyright 2017-2019 NXP + Copyright 2017-2020 NXP =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -141,12 +141,33 @@ SocInit ( VOID ) { + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + UINT32 Timeout; + + BaudRate =3D FixedPcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth =3D 0; // Use default FIFO depth + Timeout =3D 0; + Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity); + DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits =3D (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits); + SmmuInit (); =20 // // Early init serial Port to get board information. // - SerialPortInitialize (); + SerialPortSetAttributes ( + &BaudRate, + &ReceiveFifoDepth, + &Timeout, + &Parity, + &DataBits, + &StopBits + ); DEBUG ((DEBUG_INIT, "\nUEFI firmware (version %s built at %a on %a)\n", (CHAR16*)PcdGetPtr (PcdFirmwareVersionString), __TIME__, __DATE_= _)); =20 diff --git a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf b/Silicon/NXP/Lib= rary/SocLib/LS1043aSocLib.inf index cb670a1279..3334d4d4f1 100644 --- a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf +++ b/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf @@ -1,6 +1,6 @@ # @file # -# Copyright 2017-2019 NXP +# Copyright 2017-2020 NXP # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -36,6 +36,10 @@ GCC:*_*_*_CC_FLAGS =3D -DCHASSIS2 =20 [FixedPcd] + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString gNxpQoriqLsTokenSpaceGuid.PcdClkBaseAddr gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54011): https://edk2.groups.io/g/devel/message/54011 Mute This Topic: https://groups.io/mt/71046325/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-