From patchwork Tue Sep 19 13:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 113007 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4974628qgf; Tue, 19 Sep 2017 07:17:20 -0700 (PDT) X-Received: by 10.55.217.155 with SMTP id q27mr2080197qkl.323.1505830640684; Tue, 19 Sep 2017 07:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505830640; cv=none; d=google.com; s=arc-20160816; b=EFMrGhVWgB9BXTmQsKhx5/TvO8ujfjJ0BsPwpGX8JiJYJK6KDcd/FzLw9ZuYl6Pepz vN0CrlMOtzlfLDAHnWKRtPnSERM+FPhaoy29yxrDY7098FtOFw09eGwX/tf2mO6c7mk/ 0sfucHd6zLP/kJwAzA2VqIx5gcKbN0pJiurKgDWsu1JtBJRcbD62Mc040eKzvuIIx9Wh imXCYq9tUJmckBSjaTlAqdb1AlNZWsR18Ntfsm5AJ4xWcSDx/S0NYqu3pEdti1xbbnQ6 060cwuVIa8g6BwoHishIpAlGdifXr9UFXnJnpwRmtzUpBgBp82cUUv7B6iNAsdxR/N/C l+Pw== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=a2o0FJFG/La6E2sA/jdxW3hDVvpsuh0o96z6T/Sg7vY=; b=LSrOIg+OWb8khOaoXJqPW1sIe1gZUA7uBE34M/tVBRLB08c6JBF3zOi6z7NJHo8xS8 Uz47RtrLGJP14sjN640YVyBZ1KXLH7fCqVW2qHmVeHfnnJZGmcYbQZaD3VgA2vTNJkUt WmrZiYIu0AZLx1uCpy19KYf1L/wAE6oQ5Iv0R+C2dmVFNi8NY4xkIE/e+XqFOHneS668 PNJRB7ew7H/Go5++4WT5VeVM+oB4+QxVtS8OtNwwOrBr4iripiKJddzmdQfCO6U7zfgF WJiEeJBj8UZEU2BdwIIzy4gxsK+84G1SmY7YEUA+RL+PXeoGEa+Nv+SscS8aBhzcd/d3 hibw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i1si92214qkb.248.2017.09.19.07.17.20; Tue, 19 Sep 2017 07:17:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 457DE60665; Tue, 19 Sep 2017 14:17:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E319B64451; Tue, 19 Sep 2017 14:11:03 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6CC9262C59; Tue, 19 Sep 2017 14:06:00 +0000 (UTC) Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) by lists.linaro.org (Postfix) with ESMTPS id A111762C5C for ; Tue, 19 Sep 2017 14:05:41 +0000 (UTC) Received: by mail-pg0-f50.google.com with SMTP id d8so2054352pgt.4 for ; Tue, 19 Sep 2017 07:05:41 -0700 (PDT) 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=hYZIHUAzKsAyfYaM/i+j6X+lVDFWVmHL/tevuDW4EeI=; b=jEHN9LTravFkl5RsxDjcLMUX+EjBfbQcfsPLUlxZWH1ueHHd6Wk/6n1yJq9yIwW6Hu bzPaB2c0s2ok2SpBOQojO6HHgqantACQHAVtjOPp2+aTPoMaG+qHzIIb15xTG4VaS0BH XIoe7pIh0LX8Ta5tOljY8EyIl5skcfaaYEKQKCCDV7wAmcrKsXNXliG8OzGpxoHLWGms 7WAJwG6+3m8Ht0NF/7tGNVrVt5ukKP1AOD1vyojSeoHofWUhTW7yOEZcNKqMlD9zti93 ZGbORgrGOWVMaG/fPHoxG8qXFY953pzZ/wylakfKBbfJO+4UbnCUOifhIwjckwB0EZY+ +3qQ== X-Gm-Message-State: AHPjjUhrcuLcPy7nymGxByD0AsJBUpjgbSGeozE/QiC2bffr2uza78rl O39Gvwk32yEi+x4Er2hQJnZfBuuX X-Google-Smtp-Source: AOwi7QC3BUNSFZOotWU0kh3mz74Cjhqa2f+9BSSpECnpKuZ+CLwrgV6tuedWiRQ/cA93eyScQSM0cg== X-Received: by 10.84.235.65 with SMTP id g1mr1397668plt.353.1505829940836; Tue, 19 Sep 2017 07:05:40 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id 13sm4390439pfm.138.2017.09.19.07.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 07:05:40 -0700 (PDT) From: Heyi Guo To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, graeme.gregory@linaro.org Date: Tue, 19 Sep 2017 21:56:24 +0800 Message-Id: <1505829398-52214-19-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505829398-52214-1-git-send-email-heyi.guo@linaro.org> References: <1505829398-52214-1-git-send-email-heyi.guo@linaro.org> Cc: huangming23@huawei.com, zhangjinsong2@huawei.com, guoheyi@huawei.com, Chenhui Sun , wanghuiqiang@huawei.com Subject: [Linaro-uefi] [linaro-uefi v1 18/32] D05: add es3000 performance driver X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "For discussions about Linaro-related UEFI development. Not a substitute for edk2-devel." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" From: Chenhui Sun Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chenhui Sun --- .../Drivers/Es3000PerformanceDxe/Es3000Dxe.c | 137 +++++++++++++++++++++ .../Drivers/Es3000PerformanceDxe/Es3000Dxe.inf | 57 +++++++++ Platforms/Hisilicon/D05/D05.dsc | 1 + Platforms/Hisilicon/D05/D05.fdf | 3 +- 4 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.c create mode 100644 Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf diff --git a/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.c b/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.c new file mode 100644 index 0000000..4968f82 --- /dev/null +++ b/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.c @@ -0,0 +1,137 @@ +/** @file +* +* Copyright (c) 2016, Hisilicon Limited. All rights reserved. +* Copyright (c) 2016, 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 +#include +#include + +UINT64 PCIE_APB_SLVAE_BASE_1616[2][8] = {{0xa0090000, 0xa0200000, 0xa00a0000, 0xa00b0000, 0x8a0090000, 0x8a0200000, 0x8a00a0000, 0x8a00b0000}, + {0x600a0090000, 0x600a0200000, 0x600a00a0000, 0x600a00b0000, 0x700a0090000, 0x700a0200000, 0x700a00a0000, 0x700a00b0000},}; +UINT8 PCIE_ROOT_BRIDGE_BUS_NUM_1P[8] = {0x10, 0x21, 0x81, 0x30, 0x40, 0x1, 0x60, 0x70}; +UINT8 PCIE_ROOT_BRIDGE_BUS_NUM_2P[8] = {0x80, 0x90, 0x11, 0x40, 0x21, 0x31, 0x60, 0x70}; + +#define RegWrite(addr,data) (*(volatile UINT32*)(UINTN)(addr) = (data)) +#define RegRead(addr,data) ((data) = *(volatile UINT32*)(UINTN)(addr)) + + +VOID +EFIAPI +OemEs3000PerformaceOperation( + IN EFI_EVENT Event, + IN VOID *Context + ) + +{ + EFI_STATUS Status; + UINTN HandleIndex; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + EFI_PCI_IO_PROTOCOL *PciIo; + UINTN SegmentNumber; + UINTN BusNumber; + UINTN DeviceNumber; + UINTN FunctionNumber; + UINT16 DeviceId = 0; + UINT16 VenderId = 0; + UINT8 i = 0; + UINT32 Value = 0; + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciIoProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if(EFI_ERROR(Status)) { + DEBUG((EFI_D_ERROR, " Locate gEfiPciIoProtocol Failed.\n")); + //gBS->FreePool ((VOID *)HandleBuffer); + return; + } + DEBUG((EFI_D_ERROR, "HandleCount = %d\n", HandleCount)); + for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { + (VOID)gBS->HandleProtocol ( + HandleBuffer[HandleIndex], + &gEfiPciIoProtocolGuid, + (VOID **)&PciIo + ); + + (VOID)PciIo->GetLocation(PciIo,&SegmentNumber,&BusNumber,&DeviceNumber,&FunctionNumber); + + DEBUG((EFI_D_ERROR,"PCIe device plot in slot Seg %d bdf %d %d %d\r\n",SegmentNumber,BusNumber,DeviceNumber,FunctionNumber)); + (VOID)PciIo->Pci.Read(PciIo,EfiPciIoWidthUint16,PCI_DEVICE_ID_OFFSET,1,&DeviceId); + (VOID)PciIo->Pci.Read(PciIo,EfiPciIoWidthUint16,PCI_VENDOR_ID_OFFSET,1,&VenderId); + if((DeviceId == 0x0123) && (VenderId == 0x19e5)) { + if (SegmentNumber == 0) { + for(i = 0; i < 8; i ++) { + if (BusNumber == PCIE_ROOT_BRIDGE_BUS_NUM_1P[i]) + break; + } + } + if (SegmentNumber == 1) { + for(i = 0; i < 8; i ++) { + if (BusNumber == PCIE_ROOT_BRIDGE_BUS_NUM_2P[i]) + break; + } + } + DEBUG((EFI_D_ERROR,"find es3000...............\n")); + DEBUG((EFI_D_ERROR,"Segment = %d, i = %d, PCIE APB SLAVE BASE = %lx\n",SegmentNumber, i, PCIE_APB_SLVAE_BASE_1616[SegmentNumber][i])); + RegWrite((UINT64)PCIE_APB_SLVAE_BASE_1616[SegmentNumber][i] + 0x1110, 0x28002fff); + RegRead((UINT64)PCIE_APB_SLVAE_BASE_1616[SegmentNumber][i] + 0x1110, Value); + DEBUG((EFI_D_ERROR,"Read value = %lx\n",Value)); + DEBUG((EFI_D_ERROR, "Device Id = %x, Vender Id = %x\n",VenderId, DeviceId)); + + } + + } + + return; +} + +EFI_STATUS +EFIAPI +Es3000PerformanceDxeEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable) +{ + EFI_STATUS Status; + EFI_EVENT Event = NULL; + + // + // Register notify function + // + Status = gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + OemEs3000PerformaceOperation, + NULL, + &Event + ); + + if (EFI_ERROR(Status)) + { + DEBUG ((EFI_D_ERROR, "[%a:%d] - Es3000 performace createEvent failed: %r\n", __FUNCTION__, + __LINE__, Status)); + } + + return Status; +} + diff --git a/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf b/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf new file mode 100644 index 0000000..e0d3429 --- /dev/null +++ b/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf @@ -0,0 +1,57 @@ +#/** @file +# +# Copyright (c) 2015, Hisilicon Limited. All rights reserved. +# Copyright (c) 2015, 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 = 0x00010005 + BASE_NAME = Es3000Dxe + FILE_GUID = f99c606a-5826-11e6-b09e-bb93f4e4c402 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + + ENTRY_POINT = Es3000PerformanceDxeEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = AARCH64 +# + +[Sources.common] + Es3000Dxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ArmPkg/ArmPkg.dec + OpenPlatformPkg/Chips/Hisilicon/HisiPkg.dec + +[LibraryClasses] + UefiBootServicesTableLib + UefiDriverEntryPoint + DebugLib + BaseLib + PcdLib + CacheMaintenanceLib + +[Guids] + +[Protocols] + gEfiPciIoProtocolGuid + +[Pcd] + +[Depex] + gEfiPciIoProtocolGuid + diff --git a/Platforms/Hisilicon/D05/D05.dsc b/Platforms/Hisilicon/D05/D05.dsc index 8191459..8dfcca4 100644 --- a/Platforms/Hisilicon/D05/D05.dsc +++ b/Platforms/Hisilicon/D05/D05.dsc @@ -619,6 +619,7 @@ OpenPlatformPkg/Chips/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.inf OpenPlatformPkg/Platforms/Hisilicon/Binary/D05/Drivers/Sm750Dxe/UefiSmi.inf MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf + OpenPlatformPkg/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf OpenPlatformPkg/Chips/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClassDxe.inf diff --git a/Platforms/Hisilicon/D05/D05.fdf b/Platforms/Hisilicon/D05/D05.fdf index 3081058..82a6a7e 100644 --- a/Platforms/Hisilicon/D05/D05.fdf +++ b/Platforms/Hisilicon/D05/D05.fdf @@ -292,8 +292,9 @@ READ_LOCK_STATUS = TRUE # INF OpenPlatformPkg/Platforms/Hisilicon/Binary/D05/Drivers/Sm750Dxe/UefiSmi.inf INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf - INF OpenPlatformPkg/Platforms/Hisilicon/Binary/D05/Drivers/SasPlatform/SasPlatform.inf + INF OpenPlatformPkg/Chips/Hisilicon/Hi1610/Drivers/Es3000PerformanceDxe/Es3000Dxe.inf INF OpenPlatformPkg/Platforms/Hisilicon/Binary/D05/Drivers/Sas/SasDxeDriver.inf + INF OpenPlatformPkg/Platforms/Hisilicon/Binary/D05/Drivers/SasPlatform/SasPlatform.inf # # UEFI application (Shell Embedded Boot Loader) #