From patchwork Thu Aug 23 16:07:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144950 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp314384ljw; Thu, 23 Aug 2018 09:09:15 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw9WX5jwzO+0P6LAFRhNMr33uhhAUGh3hl+qhBUx78UEskVaHxetBur2X7ezsUPjP9iONdq X-Received: by 2002:a17:902:bf41:: with SMTP id u1-v6mr19887972pls.222.1535040555221; Thu, 23 Aug 2018 09:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535040555; cv=none; d=google.com; s=arc-20160816; b=ze5gDJZnQbSfPCbiPHgJB45/q2bZnfaxiVLyQw3918ycxEA1MVIggi891SvPsurOOB lqrviSxJwF0rQxT3NqNB973CX6ovjSJWPBa9qK/gg4YgXHlvunSA3X+BKUnkDur1xq0i Br1GCiiVV+n2IWFNycxPA/51qqmWaJwROHrn8AIdc8Aks4l5deCMVtwznqvJvGozYcOp HquY0QhIVPy/WIreRqT947ou/+AlxbAbfJ57gzywyz9YxOiIr3b4wi9nEM5f9rZNiZTC SC6hm9abgL/9UNTTWAX0VotVsNTOgXsEWf//BDH6KZifX+BSPHGPUKXuTA2XA44DezbX zTFw== 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=awQlHshJ32x3O+js28wKyg5/hzXQq+NoPytXO25fXyA=; b=l1t6Wla8WrKoHD0gG0uXZ97V/8H2+BNsIVnCHlWhY2FISiyjTusIcMH5x8S6lzErJy v//K2iN2WsA0dNF/jr4eOdxA+YbQdy+G8rdo5G64vXHI10AdQUmmBCrsJy7f4U7RSMzi 7d7pqeolQgFGJaf3FqMIhwSex2+l94Q3EAHrfyNUA+kk/yJm0WIv9422ExrfCU/Yu3Xg UAAZgTSXNhFYmTdX7SQkvGgFycIJeBJllaFW2qcIgadzqYRg9SjspVlRTM0vtwv6yuUa eGDA9Eq4SjoNvBbi2//dYhYJjqTvwfQqOELKfXB3vpUpNkQHH4gya7RIGq7/Tpdr5YE4 EVTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jVoxyOtB; 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 c21-v6si1723637pgj.203.2018.08.23.09.09.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 09:09:15 -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=jVoxyOtB; 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 CD70E211069E3; Thu, 23 Aug 2018 09:09:14 -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::441; helo=mail-pf1-x441.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 E7E9521103DC5 for ; Thu, 23 Aug 2018 09:09:13 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id k21-v6so2972673pff.11 for ; Thu, 23 Aug 2018 09:09:13 -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=ZXe12Ww1qWlbz0fov7t/Z1gAcyTGsQY58NvzuRrAPb0=; b=jVoxyOtBvD5ZGQZwgUFPPCXZksdUBAjZjWM+SC6bto6SfWx+e4dH+eze/9DS34Wtpo Za/Ca7cx0xAnKA9iUf71P2gFKCqOlNEvnKzRmi5N+eRFXOQPToUe3rxzI0k4+kENHLkt pg2GrU6a5ujkj3STWe+mMewjOxc941UzsuAew= 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=ZXe12Ww1qWlbz0fov7t/Z1gAcyTGsQY58NvzuRrAPb0=; b=ji0fKen7K9ALENdSy6+3HTQgPZRt390xNS6Dc/j2SMclj7s3RZ40Vra1KCVXNlSB3W MbjJ7bUgOLe0VjuwU9CKFF1mIFIbRx7h+ZGLYo+ZKelsm5uRn7A8nVXv12a4RzAQn9AI unsp6c1y57nwdfXLyIyq1Jc9/gKrzlD2jxhHDyZypiTIdZfPSRxz17QGkelxQGBEAp2h 9iOH/7WFXB43ssuQWKhXcDii5AGFgIhGd5HFPL2SZ21GzyKvx0Mu3s4YXvgTChW5ULoQ 8SEa7ek7kbmMxtMC/Vj5JGFG+Hq2TOorHKXrc1+yMw8WAMftuD116C18mhh3jRTJ9dYy Qw5g== X-Gm-Message-State: APzg51A2nn5/s04Bj70Ty6GYp05i0vC/alS4jwin9ROlAh7vcAHg8S0z kaGPJ1luFKmFvVM/c+upT04RCQ== X-Received: by 2002:a17:902:145:: with SMTP id 63-v6mr8733511plb.103.1535040553476; Thu, 23 Aug 2018 09:09:13 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id d19-v6sm5788083pgv.61.2018.08.23.09.09.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Aug 2018 09:09:12 -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, 24 Aug 2018 00:07:24 +0800 Message-Id: <20180823160743.45638-13-ming.huang@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823160743.45638-1-ming.huang@linaro.org> References: <20180823160743.45638-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 12/31] 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, 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 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; +} +