From patchwork Fri Aug 31 13:26:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 145619 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp783713ljw; Fri, 31 Aug 2018 06:28:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaPl50MR4+P78/LY1xE0YLm3ly/fDkJuNYCR9CZI8hCB2CnMcpHTP3bTcxfSpPezMCQBokL X-Received: by 2002:a63:5fc8:: with SMTP id t191-v6mr14438798pgb.183.1535722080138; Fri, 31 Aug 2018 06:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535722080; cv=none; d=google.com; s=arc-20160816; b=T05VHIS8SvGO342CK9w9eDHo1PTNmbAk0uQV3obLVgOKvTJayhkZCIOla2VcfjMnBo REGxU8UUzMqk/lRD8HxkL/L4tFN/unOANNWf3gqVs3vR+yoOroxHrvJuU/eNL7o2LFK6 ChgF8gzzwtr5Kxg29JHt6m+Rif3zOE0ADWiQVrYPDhFPez/hhgv0Xnpqaq/3qxqcS+Mk 5F+EnWRkq8XCDQanYir7PR5ceLgRv2mWdqUW0z0MRD7S9yQAOsFTOWJvpPcyFZCDy904 1fNZLvDmRzGqD4sQog7dbW5p3GisRHyhSKa5wSIQ24xsM2/nN0hmQ3hJLNi+XRWn0q+r Z0wg== 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=4z8MwRDiyPd0NC8OaYmBatcZLu/AAnYa/H6GNgEA3PE=; b=gLheq/YPknWy+2d90ZzlBDuFDxmoQ6WHBCq9oqGCW93h+67NxDq+QwHaBsGLq/EI5l WYcxmplAwBHnaiM7eTno/75MVO99WULS/usRS7/Kp4fqJIzM9S1sgjUm90vGYB/bsoDZ Liu2FBUmz1DDWqp4zDC1ktx7HsebEYwTMzuM9VvqHodEeyHWnfgLyYFDChl1nZRMLCW+ 8Q6Bzq0BOzvhVlV1rsx1F0Nq4wphEyEn2fDIHl06QxgvER00nuRyDlGC0t8+QYItYea3 rHnkTPuGwUolArk27/rTWYOCibK8M/j1YPcYmWCpmNYTguBcn8TiGK8VwL8qECwR0tc0 iSxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ia+TfZaQ; 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 e20-v6si7731701pgm.172.2018.08.31.06.27.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 06:28:00 -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=ia+TfZaQ; 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 0E5352110BD7B; Fri, 31 Aug 2018 06:27:59 -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:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (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 978102110BD79 for ; Fri, 31 Aug 2018 06:27:57 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 2-v6so4937684pgo.4 for ; Fri, 31 Aug 2018 06:27:57 -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=f1zocSoQEBe4oYVLgkTLysna1YT6HzJrI/RQa/MG0fo=; b=ia+TfZaQoY3Mesaxm9SS4OebfK4wldmJweeDK+HL25iC5E8FyOsKkmquVtHO2lF6Zj agHd5xScnUXOyo+PjUHQ0MctRbkf9mgMaxgCFU2814wR7XwiPNMRbDmu87zbdpg1bS/g xbMz15sBDvFACiwF+J88O+c4PDJTTlaGMjO9U= 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=f1zocSoQEBe4oYVLgkTLysna1YT6HzJrI/RQa/MG0fo=; b=ttj/oTac0jyLG1etsfQdGoFbVNntQdq9qRLFKBn8naMXstJiCANBxYYjZsaLcmGO/H nyfWANG4zz91lb3PImnyMSDcoDeQvUYXjF3dizr/jB+7qT+31gFCEITHCmgRBqQC7YlF 8AZ+myMj24oW4vPX/GosJj4+35G/wvDuMUkmxU09o5OwfXwyrfcdtO8hmMOUnDIKthyv LgN3PV86rON996pvjIhqSczHPNDHS/ZaPY250IruQgcuGlST4EUlxgaj1MTdiAsadFDQ X/5Y1KLz+tj97p2SWX4YGPQHXYSaDHdvV2h9RGC1bWQ1v0r6V4sof7XmrZK+Niq7Pk4R i8nQ== X-Gm-Message-State: APzg51AatzIcFNX7HtV0tZpsTIHOe85+TWagRfnGZKnGle+SM/v1FBbZ ZG86p96dRuoh9tW8HOlIfXA42g== X-Received: by 2002:a63:549:: with SMTP id 70-v6mr14697372pgf.385.1535722077232; Fri, 31 Aug 2018 06:27:57 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id l185-v6sm19081936pga.5.2018.08.31.06.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 06:27:56 -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: Fri, 31 Aug 2018 21:26:52 +0800 Message-Id: <20180831132710.23055-11-ming.huang@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180831132710.23055-1-ming.huang@linaro.org> References: <20180831132710.23055-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v5 10/28] Hisilicon/D06: Add Debug Serial Port Init Driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 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, zhangfeng56@huawei.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: Ming Huang Reviewed-by: Leif Lindholm --- 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.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc index ac47b36cde..a124c5541f 100644 --- a/Platform/Hisilicon/D06/D06.dsc +++ b/Platform/Hisilicon/D06/D06.dsc @@ -423,6 +423,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 5d6168f717..9a239a6a43 100644 --- a/Platform/Hisilicon/D06/D06.fdf +++ b/Platform/Hisilicon/D06/D06.fdf @@ -299,6 +299,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 # # 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; +} +