From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: tien.hock.loh@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 24 Apr 2019 01:32:07 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 01:32:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,389,1549958400"; d="scan'208";a="226205801" Received: from pg-nx14.altera.com ([10.104.4.29]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2019 01:32:04 -0700 From: "Loh, Tien Hock" To: devel@edk2.groups.io, thloh85@gmail.com Cc: "Tien Hock, Loh" , Jian J Wang , Hao Wu Subject: [PATCH 1/1] MdeModulePkg: BaseSerialPortLib16550: Add Mmio32 support Date: Wed, 24 Apr 2019 16:31:50 +0800 Message-Id: <1556094710-100310-1-git-send-email-tien.hock.loh@intel.com> X-Mailer: git-send-email 2.2.2 From: "Tien Hock, Loh" Some busses doesn't allow 8 bit MMIO read/write, this adds support for 32 bits read/write Signed-off-by: "Tien Hock, Loh" Cc: Jian J Wang Cc: Hao Wu -- v3 - Updates the Pcd to be UINT8 to allow more options such as 16 bits access in the future - Updated copyright date v2 - Updates the Pcd name to PcdSerialMmio32BitAccess and access 32 bits register if PcdSerialUseMmio and PcdSerialMmio32BitAccess is set --- .../Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c | 12 +++++++++++- .../BaseSerialPortLib16550/BaseSerialPortLib16550.inf | 3 ++- MdeModulePkg/MdeModulePkg.dec | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c index 34df34d..3a811c9 100644 --- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c +++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c @@ -2,7 +2,7 @@ 16550 UART Serial Port library functions (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
Copyright (c) 2018, AMD Incorporated. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -77,6 +77,11 @@ SerialPortReadRegister ( ) { if (PcdGetBool (PcdSerialUseMmio)) { + if (PcdGet8 (PcdSerialMmioAccessBits) == 8) { + return MmioRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride)); + } else if (PcdGet8 (PcdSerialMmioAccessBits) == 32) { + return (UINT8) MmioRead32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride)); + } return MmioRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride)); } else { return IoRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride)); @@ -104,6 +109,11 @@ SerialPortWriteRegister ( ) { if (PcdGetBool (PcdSerialUseMmio)) { + if (PcdGet8 (PcdSerialMmioAccessBits) == 8) { + return MmioWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value); + } else if (PcdGet8 (PcdSerialMmioAccessBits) == 32) { + return (UINT8) MmioWrite32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), (UINT8)Value); + } return MmioWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value); } else { return IoWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value); diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf index b60779c..d51921f 100644 --- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf +++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf @@ -1,7 +1,7 @@ ## @file # SerialPortLib instance for 16550 UART. # -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,6 +29,7 @@ BaseSerialPortLib16550.c [Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialMmioAccessBits ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index be84916..b1813a6 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1170,6 +1170,14 @@ # @Prompt Serial port registers use MMIO. gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE|BOOLEAN|0x00020000 + ## Indicates the access mode for 16550 serial port registers when they are in MMIO space. + # The PCD is only valid if PcdSerialUseMmio is set to TRUE. + # Default is 8-bit access mode.

+ # 8 - 16550 serial port MMIO registers are accessed in 8-bit width.
+ # 32 - 16550 serial port MMIO registers are accessed in 32-bit width.
+ # @Prompt Serial port MMIO registers access mode. + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialMmioAccessBits|32|UINT8|0x00020007 + ## Indicates if the 16550 serial port hardware flow control will be enabled. Default is FALSE.

# TRUE - 16550 serial port hardware flow control will be enabled.
# FALSE - 16550 serial port hardware flow control will be disabled.
-- 2.2.2