From patchwork Tue Aug 14 08:08:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144124 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4049146ljj; Tue, 14 Aug 2018 01:10:46 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzvgJtWKEt8FSEYMmsg+R1ovTxqSD0/CRkkcsEW6rfq4wXePOvPBK8jkA+z7OV4J7jQ7v4u X-Received: by 2002:a63:67c3:: with SMTP id b186-v6mr20332433pgc.5.1534234246530; Tue, 14 Aug 2018 01:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534234246; cv=none; d=google.com; s=arc-20160816; b=jO3k07PA+SZJAsuQlELEHsgfOgsZgtzPxI1FCQ6KS1XLUm+aQorO/n+/ENj5ruvTj5 NC8xTYlozsCN7JBi1iSeV5YNpIbOBUJ9mabaVye6+cksGMuPXuw3hRw4inTjJe3Jp6U3 ua+qBQAxtdJlNuPxukqGjVkv0uUMHvdaIg9FZ96o+atghSbhCLFuG+du0iT97DdmrOGR 5TMWnCbRj5QAnkFsZuHJDUg1tJgolF0Rw+u/k08Yy+MwUOyTloIGm/g+NQyJmbFyBXOI bW1iELTN6k2C3zPZFnFYBm3cGLL5NhuZH3HqJRqzPT04HRa8m8M1d+2EW2uqrEmhk3oT 12Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=+lBvNY6uECsOfOkCcm8ZXKOBjqQCE3MzNG1fqnkE7po=; b=qRJ8GgDTNPc9VbXVrUizhr4V6Ag/zHdTADbJgORqFoird5qlssc5d8MIF/8nZt683w CM6w9cBIPZDNHrpNbYzpjh5ans+hWQsip0/7UQFcAIo2cMsS9KK2X8/JajqIOuEdZUeW E76MzNAg7vq0DWDi74/sHN7LYmMuNU8hL7xCHGcNH0/kemrC26PhAurEl+kj2huYwyeu FDc/ipGJi9iPEUwdty+dMt4BSyOIE9zJYk2J1OZIDv86HHYGc1x/lfPwT31pPAsFI3X/ 5sfYH5NgvTEdG7q6/iiFTq1UHXAlJHphllUnTtv12/dCTj77fAsrfZzXyzZmS7gRe1xw sT+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HOi84ilX; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 11-v6si18647063plb.383.2018.08.14.01.10.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 01:10:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HOi84ilX; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 45345210F157F; Tue, 14 Aug 2018 01:10:21 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5F14E21959CB2 for ; Tue, 14 Aug 2018 01:10:19 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id e11-v6so8033464plb.3 for ; Tue, 14 Aug 2018 01:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XHsReVnvsCSz2Wp52tStbNUTqg07RcGISkhjijctI0U=; b=HOi84ilX0tWCFMR81/OBae2PlMVzRVeygI6PFF5aCXKED+F4HPqjUR0V84T2sD/D6b VMc8HbKBUPy8+5Gzk9ZCnvxd4ix88XtcP9h2nWt9uCfRMNR7wZQz1UVDea8rUrXgz6Dr chHZsH+WIP3Q4SK3l3zJdEvN4vq0E4QdI4eXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XHsReVnvsCSz2Wp52tStbNUTqg07RcGISkhjijctI0U=; b=WK+aB50rGRHegzODj5hs7Nfj3xssfsQpP0VPB/4rvHB0PscR+TD3vKMOi3luCk1FHs paf3LkzoCrjizK+Ek/WTAe4yfYf29ftKrOhUzDng+LfjzSLOjfBIwi3Ig0oB+1SiLbCY R9bB95HNomaWaETl/4kIbfJB8AyhzCl6BBwbHQplEXLNlOjEo+3W2ISb1ESnP2f+eh8n vV2VZF4znH//0Eb4rHkel8MquOcoKtMSTLOrJbsK+MZbglfEL4aiFJuEYvaZYUYQDSJA mT4Gy0Ky/NFokVTm19EYxOO1CsH2ys22l6DYX9HoHJ9oNnSXJ4ImYQR34vkZQTrQ66sn Qo8Q== X-Gm-Message-State: AOUpUlHzLPWXuA+P8MF3fGcCM8JjmGK0ttZGuuOzotdA2fsGTw1Zslab /GYD0UEM0BwjLbc+NNsJWQQgjg== X-Received: by 2002:a17:902:262:: with SMTP id 89-v6mr19276773plc.221.1534234219058; Tue, 14 Aug 2018 01:10:19 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id h130-v6sm72905670pgc.88.2018.08.14.01.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Aug 2018 01:10:18 -0700 (PDT) From: Ming Huang To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org Date: Tue, 14 Aug 2018 16:08:36 +0800 Message-Id: <20180814080903.50466-17-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180814080903.50466-1-ming.huang@linaro.org> References: <20180814080903.50466-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 16/43] Hisilicon/D06: Add Debug Serial Port Init Driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangming23@huawei.com, xinliang.liu@linaro.org, john.garry@huawei.com, zhangjinsong2@huawei.com, guoheyi@huawei.com, huangdaode@hisilicon.com, michael.d.kinney@intel.com, lersek@redhat.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" From: Heyi Guo Hi1620 have two physical PL011 serial ports on the board, one for serial port console (described by ACPI SPCR) and the other for standard debug port (described by ACPI DBG2). This driver is to initialize the debug UART, not the serial console. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo --- Platform/Hisilicon/D06/D06.dsc | 1 + Platform/Hisilicon/D06/D06.fdf | 1 + Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf | 48 +++++++++++++++ Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.c | 64 ++++++++++++++++++++ 4 files changed, 114 insertions(+) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc index 9ca7160dad..20d2d2a1b4 100644 --- a/Platform/Hisilicon/D06/D06.dsc +++ b/Platform/Hisilicon/D06/D06.dsc @@ -422,6 +422,7 @@ # Memory test # MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf + Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/BdsDxe/BdsDxe.inf diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf index 07fe096f61..8cac126ccf 100644 --- a/Platform/Hisilicon/D06/D06.fdf +++ b/Platform/Hisilicon/D06/D06.fdf @@ -303,6 +303,7 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + INF Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf # # Build Shell from latest source code instead of prebuilt binary diff --git a/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf b/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf new file mode 100644 index 0000000000..8c91bdf0f4 --- /dev/null +++ b/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf @@ -0,0 +1,48 @@ +#/** @file +# +# Copyright (c) 2016 - 2018, Hisilicon Limited. All rights reserved. +# Copyright (c) 2016 - 2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = Pl011DebugSerialPortInitDxe + FILE_GUID = 16D53E86-7EA4-47bd-861F-511EA9B8ABE0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = SerialPortEntry + +[Sources.common] + Pl011DebugSerialPortInitDxe.c + + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Hisilicon/HisiPkg.dec + +[LibraryClasses] + BaseLib + UefiDriverEntryPoint + +[Pcd] + gArmPlatformTokenSpaceGuid.PL011UartClkInHz + gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + +[Depex] + TRUE + diff --git a/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.c b/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.c new file mode 100644 index 0000000000..8f83737327 --- /dev/null +++ b/Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.c @@ -0,0 +1,64 @@ +/** @file + + Copyright (c) 2016 - 2018, Hisilicon Limited. All rights reserved. + Copyright (c) 2016 - 2018, Linaro Limited. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include + +RETURN_STATUS +EFIAPI +DebugSerialPortInitialize ( + VOID + ) +{ + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + + BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth = 0; // Use default FIFO depth + Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity); + DataBits = FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits); + return PL011UartInitializePort ( + (UINTN)FixedPcdGet64 (PcdSerialDbgRegisterBase), + FixedPcdGet32 (PL011UartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); +} + +EFI_STATUS +SerialPortEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + Status = DebugSerialPortInitialize (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "CPU1 TB serial port init ERROR: %r\n", Status)); + } + return EFI_SUCCESS; +} +