From patchwork Fri Nov 10 14:20:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118535 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257502edl; Fri, 10 Nov 2017 06:21:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMYld3kxwIWIlRh52BYqjvRIKHRN46Tn3fs2Z4hCGK4PgJz3WFObPZMKd4W0coEX0kW7wX0d X-Received: by 10.98.166.84 with SMTP id t81mr553065pfe.196.1510323714280; Fri, 10 Nov 2017 06:21:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323714; cv=none; d=google.com; s=arc-20160816; b=OnOGlXatdqZMrikja8aglbhlPOWeIxrjRBP8UleL98brjScdRCnhtmOz/nVWt+2IPX fbq6Ob3hgCAGct22IdCofe4nLR+9K7yRRIBp4XFKeAFQ7pYE0Ho5Br705sM6/yF5iEcz JJltAtDGpN3K4Ld2k1v4Inzk1UhoVjqloCnIjv3HG05o4TCqnOqX2RX9YT9btZjdBdiJ /pSfDSQ3uihZMOflWppr1sRqBSWYAPVYdcdZEy6PPbgrsIhFLj5ZCglxKRTlHVDhUxCF sRrLLQYEIapPlOvXTTmtZt8cXY2+OZwCechiaBMyc43+TNL6Q4jtYdkOtpjJUZQqrGiX mGng== 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=B4ef/rtddcAaQxn4cJsmqc5TEoy6phrQ3Vm7CGTMIi8=; b=pOduezN4dP7VY44IXProoWh8AEu3j9op/3L8hfyFYsPRNvN9VgXaMqfTU1XkEpRqTF VCR3FDitOONLJ5J7aReaO49p02XPDnaZ6ZZ/m4n0bzrakyJqkgkS9fVAc3VDqY1EeHbL SL+m5ZQg5iGChHr9YUh+2iIRsrsyDWRSb/oKYAiBwFMUWdKwZz+wnSTI2n57S73ZPPHu m22BX5xcNb9vxvZKc6IT5y+DGFDoEdX0spQb9VjorMLvkamro8Vad5VyOwS/kJI+2phf d8rVx459G8XKDrwz6wzIQXiKzNrK+8tXVS3vovXBySuj9mbldbGvuv1ROwXaMJRevGYD fNDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E4eIAtcB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y11si8881622plg.367.2017.11.10.06.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E4eIAtcB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 C479E20355229; Fri, 10 Nov 2017 06:17:50 -0800 (PST) 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=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 7026D21B00DC3 for ; Fri, 10 Nov 2017 06:17:49 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id b189so3034110wmd.4 for ; Fri, 10 Nov 2017 06:21:52 -0800 (PST) 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=jaAHqwCYSmoBAuDQiqkZpcNKbTsUOXWIQDilQly4WqQ=; b=E4eIAtcBlOWjqXOjjV07aPMO/r5/ISbEr7xDD87lkkCLQNdCfh18mxnl+EQU6UpHqI FHFan05/tbxnZ9OB9w3k4YZulTmbvXcYpFayP5693u60jaA8CUpI0Gwmogoo7h46kdNc CpCj3BJcpuZUmPvC2RdkVAHm1cCLo4Qpd96/Y= 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=jaAHqwCYSmoBAuDQiqkZpcNKbTsUOXWIQDilQly4WqQ=; b=QMja8eIcqHgDp6ZYMrtZwpwJx8dNeVRVmQpqBh91YuRJmNdOTy1EYiDTgKuQeOdnZq F3gOcxwPk+/On1UJC7kKApphcgvudK/VaipiBPRWtQOP42aNiY95YBQBqTIjCQFIJ3Lh NzNYPJWMlxLcBKGOXf5Or8kh9CMmpMI6PlE+3qL/69ROTKio6HAxg6OBD0UAn1B3hqKE nKpGJSfVfsaAGCptM0LBkqdRkJBwg6KUi5eZqrAx14z7jtY126aXJ+vYQUi8MSHs3JZg WWxjH6GWuFcxlLyxFKw5oYGJDznrzfqNIqvKR9xSzDerDlCPdj41MFOYzhQ0M8+MONBG sQnw== X-Gm-Message-State: AJaThX7qbUZ8xgoeNBLrybkOE/b88x+D/TcpE27jAPiXPWVtvXNnvYKy 0MJATfXrQ/r9eoph+VKvxOMKNeW9qkU= X-Received: by 10.28.87.17 with SMTP id l17mr374013wmb.158.1510323710787; Fri, 10 Nov 2017 06:21:50 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:49 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:54 +0000 Message-Id: <20171110142127.12018-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 01/34] Silicon/SynQuacer: add package with platform headers X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a package .DEC description for SynQuacer with an [Includes] section, and add header files containing descriptions of the platform's memory map and PCIe configuration. No code yet. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h | 60 +++++++++++++++++++ Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h | 63 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 20 +++++++ 3 files changed, 143 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h new file mode 100644 index 000000000000..f29a35809bac --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h @@ -0,0 +1,60 @@ +/** @file + Physical memory map for SynQuacer + + Copyright (c) 2017, Linaro Ltd. 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. + +**/ + +#ifndef _SYNQUACER_PLATFORM_MEMORYMAP_H_ +#define _SYNQUACER_PLATFORM_MEMORYMAP_H_ + +// Memory mapped SPI NOR +#define SYNQUACER_SPI_NOR_BASE 0x08000000 +#define SYNQUACER_SPI_NOR_SIZE SIZE_128MB + +// On-Chip non-secure ROM +#define SYNQUACER_NON_SECURE_ROM_BASE 0x1F000000 +#define SYNQUACER_NON_SECURE_ROM_SZ SIZE_512KB + +// On-Chip Peripherals +#define SYNQUACER_PERIPHERALS_BASE 0x20000000 +#define SYNQUACER_PERIPHERALS_SZ 0x0E000000 + +// On-Chip non-secure SRAM +#define SYNQUACER_NON_SECURE_SRAM_BASE 0x2E000000 +#define SYNQUACER_NON_SECURE_SRAM_SZ SIZE_64KB + +// GIC-500 +#define SYNQUACER_GIC500_DIST_BASE FixedPcdGet64 (PcdGicDistributorBase) +#define SYNQUACER_GIC500_DIST_SIZE SIZE_256KB +#define SYNQUACER_GIC500_RDIST_BASE FixedPcdGet64 (PcdGicRedistributorsBase) +#define SYNQUACER_GIC500_RDIST_SIZE SIZE_8MB + +// GPIO block +#define SYNQUACER_GPIO_BASE 0x51000000 +#define SYNQUACER_GPIO_SIZE SIZE_4KB + +// eMMC(SDH30) +#define SYNQUACER_EMMC_BASE 0x52300000 +#define SYNQUACER_EMMC_BASE_SZ SIZE_4KB + +#define SYNQUACER_EEPROM_BASE 0x10000000 +#define SYNQUACER_EEPROM_BASE_SZ SIZE_64KB + +// NETSEC +#define SYNQUACER_NETSEC1_BASE 0x522D0000 +#define SYNQUACER_NETSEC1_BASE_SZ SIZE_64KB + +// PCI +#define SYNQUACER_PCIE_BASE 0x58200000 +#define SYNQUACER_PCIE_SIZE 0x00200000 + +#endif diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h b/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h new file mode 100644 index 000000000000..d2a3f9acbf49 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h @@ -0,0 +1,63 @@ +/** @file + PCI memory configuration for SynQuacer + + Copyright (c) 2017, Linaro Ltd. 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. + +**/ + +#ifndef _SYNQUACER_PLATFORM_PCI_H_ +#define _SYNQUACER_PLATFORM_PCI_H_ + +#define SYNQUACER_PCI_SEG0_CONFIG_BASE 0x60000000 +#define SYNQUACER_PCI_SEG0_CONFIG_SIZE 0x07f00000 +#define SYNQUACER_PCI_SEG0_DBI_BASE 0x583d0000 +#define SYNQUACER_PCI_SEG0_EXS_BASE 0x58390000 + +#define SYNQUACER_PCI_SEG0_BUSNUM_MIN 0x0 +#define SYNQUACER_PCI_SEG0_BUSNUM_MAX 0x7e + +#define SYNQUACER_PCI_SEG0_PORTIO_MIN 0x0 +#define SYNQUACER_PCI_SEG0_PORTIO_MAX 0xffff +#define SYNQUACER_PCI_SEG0_PORTIO_SIZE 0x10000 +#define SYNQUACER_PCI_SEG0_PORTIO_MEMBASE 0x67f00000 +#define SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE SYNQUACER_PCI_SEG0_PORTIO_SIZE + +#define SYNQUACER_PCI_SEG0_MMIO32_MIN 0x68000000 +#define SYNQUACER_PCI_SEG0_MMIO32_MAX 0x6fffffff +#define SYNQUACER_PCI_SEG0_MMIO32_SIZE 0x08000000 + +#define SYNQUACER_PCI_SEG0_MMIO64_MIN 0x3e00000000 +#define SYNQUACER_PCI_SEG0_MMIO64_MAX 0x3effffffff +#define SYNQUACER_PCI_SEG0_MMIO64_SIZE 0x100000000 + +#define SYNQUACER_PCI_SEG1_CONFIG_BASE 0x70000000 +#define SYNQUACER_PCI_SEG1_CONFIG_SIZE 0x07f00000 +#define SYNQUACER_PCI_SEG1_DBI_BASE 0x583c0000 +#define SYNQUACER_PCI_SEG1_EXS_BASE 0x58380000 + +#define SYNQUACER_PCI_SEG1_BUSNUM_MIN 0x0 +#define SYNQUACER_PCI_SEG1_BUSNUM_MAX 0x7e + +#define SYNQUACER_PCI_SEG1_PORTIO_MIN 0x10000 +#define SYNQUACER_PCI_SEG1_PORTIO_MAX 0x1ffff +#define SYNQUACER_PCI_SEG1_PORTIO_SIZE 0x10000 +#define SYNQUACER_PCI_SEG1_PORTIO_MEMBASE 0x77f00000 +#define SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE SYNQUACER_PCI_SEG1_PORTIO_SIZE + +#define SYNQUACER_PCI_SEG1_MMIO32_MIN 0x78000000 +#define SYNQUACER_PCI_SEG1_MMIO32_MAX 0x7fffffff +#define SYNQUACER_PCI_SEG1_MMIO32_SIZE 0x08000000 + +#define SYNQUACER_PCI_SEG1_MMIO64_MIN 0x3f00000000 +#define SYNQUACER_PCI_SEG1_MMIO64_MAX 0x3fffffffff +#define SYNQUACER_PCI_SEG1_MMIO64_SIZE 0x100000000 + +#endif diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec new file mode 100644 index 000000000000..c3adf85d3562 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -0,0 +1,20 @@ +# +# Copyright (c) 2017, Linaro, Ltd. 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] + DEC_SPECIFICATION = 0x0001001A + PACKAGE_NAME = SynQuacer + PACKAGE_GUID = 9c782fd2-7db1-438d-b51c-2155cee2c5cc + PACKAGE_VERSION = 0.1 + +[Includes] + Include From patchwork Fri Nov 10 14:20:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118537 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257681edl; Fri, 10 Nov 2017 06:22:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMZjfY1Gw0r/5XXfJicGEmp7o28sHQDk2gjW74soOofz2oTOwaj93LIdxmKi6GW15UjGbu6M X-Received: by 10.98.13.8 with SMTP id v8mr559541pfi.180.1510323722951; Fri, 10 Nov 2017 06:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323722; cv=none; d=google.com; s=arc-20160816; b=MuS51H9HgScTeKepOC3VRZPYXijwF9tT7SmXIG5t/woMf4UJdcC7FzMDEuxbkHYbsI 2GpHZr6bn6b+EuO8TXF5iSTkhQXsREojXNPMoUx1rz4YRoKnj9PqqbtZ2JNv8i8Ms8Tk AqYh+EaFYqeWY1uLa4zVlqoZTwqC/5CWu1Dl3AfBe2VDbsBDInQReczrLDmpHde+jxRa yC88usxIeZE2AHbPfABrEQzPKOuZxc1YofQZzGE0DfGOGrKPLBHMoxfYzXoMp++H47c2 ZNZ7bNDasr5xiXFPP0x20CbN4Xo/vOZFJYUE0tD+KwtxTWMJ6KkP2i6XkeAFEeloP4vG Hmvg== 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=QYnsn3a9Zp1Ydv8PMXTHUJPQXmF88n0Qoo05rFkT1wM=; b=gxXSzyLiKP9JcLJgysxeKPGxuGfVi8WCDzsCyihmNcNWyfAP+ewkaEIfKZ843L3Hre I3pI4udlNyMvSYyN+f5yP7k92YNdAkXBntFjI8bCjYpBApDbqK8VoFM3v3FCBb7V3Ogs X5u7sMQNwc+MldTVKR7xwiGmCTymA4DBaQu+9BX6GslSQaXViwZQBOm/mf1GVGvEGRyJ MK48e/jFq+YInp2gSPJhXOmVAHDGqGz9cGn+87IvZXE8TizRFO4LOdiz+N0oB2+7/Elr JcVCTBgKNPyAtKbsufPjI0fR/XuNpRYzjjXiyK2g4WNGznqjz2yROPv2lJnLXnKoGSSn HGhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=U3+WgfPD; 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 i7si8512359pgs.125.2017.11.10.06.22.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:02 -0800 (PST) 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=U3+WgfPD; 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 55EF521B00DC9; Fri, 10 Nov 2017 06:17:58 -0800 (PST) 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=2a00:1450:400c:c0c::22f; helo=mail-wr0-x22f.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22f.google.com (mail-wr0-x22f.google.com [IPv6:2a00:1450:400c:c0c::22f]) (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 F35B821B00DC6 for ; Fri, 10 Nov 2017 06:17:55 -0800 (PST) Received: by mail-wr0-x22f.google.com with SMTP id k61so8744290wrc.4 for ; Fri, 10 Nov 2017 06:21:58 -0800 (PST) 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=7t9mfQRTkLG5WdP00Fcjt3l1wBPNOdFCaArzA3FV72M=; b=U3+WgfPDjaix4Hfkx/d0n/UoLui/6YPuHphlQ42LHDPqTpomVCrQhs5Op43Rgpc1tX eOebIzpWJ7KiZ0NFEwsjTFzdU51rlM/RxnN0QMe5A/VRJryPPYB9t3XOd6VSNNefz2KG 0b+mK8b2nBEj9NZYTgTkkOqiU4itUOPz6fGQQ= 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=7t9mfQRTkLG5WdP00Fcjt3l1wBPNOdFCaArzA3FV72M=; b=q+ADz/K0VwjKL0CjJdGGFFoe/DXSsCUXeCbaLfSGjrdLaXWOdWQQrRxzbirieg0/Mn xHCb7O6WytYpCIv80k4E6RrJS7VbSrlMoA+XruOdOOKTYD65wB7Ueh04doai7xK1eWf2 zq799Fzo+dq3LcsafwTW+yEqrw1QaQXzTcF6O+RV4+8aYL2JYhRIN+4iApuMZZRMl8Qu +u3GctCxmocROfK0MwJsg+2FJO0GBKZcoetam3mcQHymZNN2fuONPZEzDZduvJgtt++9 fW/LXz4wrxpj5wJ+/dXCwVZeOua77Y2iGLMTJGdfzq7dB/6X5TKtb0+Jk8OOKHr6KEEP +81w== X-Gm-Message-State: AJaThX6Cy1H2+ytoY8CD1q7XgPc3SJN+96Ta2iF188/oAhW67haNZugP 5Itjumn7hXJvczh8T1s2nEAa3OMd64A= X-Received: by 10.223.195.198 with SMTP id d6mr478093wrg.100.1510323714991; Fri, 10 Nov 2017 06:21:54 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:53 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:55 +0000 Message-Id: <20171110142127.12018-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 02/34] Silicon/Socionext: add driver for NETSEC network controller X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This adds the NetSecDxe driver provided by Socionext, but reworked extensively to improve compliance with the SimpleNetworkProtocol API, and to avoid uncached allocations for streaming DMA. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Tested-by: Leif Lindholm Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/ComponentName.c | 186 +++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/DriverBinding.c | 245 ++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c | 1056 ++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec | 46 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h | 118 ++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf | 70 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h | 736 ++++++++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h | 45 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_version.h | 24 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.c | 88 ++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.h | 52 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access.c | 1391 +++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access_internal.h | 111 ++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_gmac_access.c | 1454 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_internal.h | 210 +++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c | 1385 +++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc_internal.h | 38 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h | 219 +++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_f_gmac_4mt.h | 222 +++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_netsec.h | 368 +++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/ogma_config.h | 25 + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h | 263 ++++ Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep_uefi.c | 176 +++ 23 files changed, 8528 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/ComponentName.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/ComponentName.c new file mode 100644 index 000000000000..2d707d3bd954 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/ComponentName.c @@ -0,0 +1,186 @@ +/** @file + UEFI Component Name(2) protocol implementation for Netsec UEFI driver. + + Copyright (c) 2017, Linaro Ltd. 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 "NetsecDxe.h" + +STATIC EFI_UNICODE_STRING_TABLE mNetsecDriverNameTable[] = { + { + "en", + (CHAR16 *)L"Netsec GigE UEFI driver" + }, + { } +}; + +STATIC EFI_UNICODE_STRING_TABLE mNetsecControllerNameTable[] = { + { + "en", + (CHAR16 *)L"Netsec GigE Controller" + }, + { } +}; + +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 4646 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ +STATIC +EFI_STATUS +EFIAPI +NetsecGetDriverName ( + IN EFI_COMPONENT_NAME2_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ) +{ + return LookupUnicodeString2 (Language, + This->SupportedLanguages, + mNetsecDriverNameTable, + DriverName, + FALSE); +} + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 4646 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ +STATIC +EFI_STATUS +EFIAPI +NetsecGetControllerName ( + IN EFI_COMPONENT_NAME2_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ) +{ + if (ChildHandle != NULL) { + return EFI_UNSUPPORTED; + } + + return LookupUnicodeString2 (Language, + This->SupportedLanguages, + mNetsecControllerNameTable, + ControllerName, + FALSE); +} + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gNetsecDriverComponentName2 = { + NetsecGetDriverName, + NetsecGetControllerName, + "en" +}; diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/DriverBinding.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/DriverBinding.c new file mode 100644 index 000000000000..f489ee80b803 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/DriverBinding.c @@ -0,0 +1,245 @@ +/** @file + Device driver for the SynQuacer NETSEC GigE controller + + Copyright (c) 2017, Linaro Ltd. 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 "NetsecDxe.h" + +/** + Tests to see if this driver supports a given controller. + + @param This[in] A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param ControllerHandle[in] The handle of the controller to test. + @param RemainingDevicePath[in] The remaining device path. + (Ignored - this is not a bus driver.) + + @retval EFI_SUCCESS The driver supports this controller. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle is + already being managed by the driver specified + by This. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle is + not supported by the driver specified by This. + +**/ +EFI_STATUS +EFIAPI +NetsecDriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + NON_DISCOVERABLE_DEVICE *Dev; + EFI_STATUS Status; + + // + // Connect to the non-discoverable device + // + Status = gBS->OpenProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + (VOID **) &Dev, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER); + if (EFI_ERROR (Status)) { + return Status; + } + + if (CompareGuid (Dev->Type, &gNetsecNonDiscoverableDeviceGuid) && + Dev->DmaType == NonDiscoverableDeviceDmaTypeNonCoherent) { + Status = EFI_SUCCESS; + } else { + Status = EFI_UNSUPPORTED; + } + + // + // Clean up. + // + gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + This->DriverBindingHandle, + ControllerHandle); + + return Status; +} + + +/** + Starts a device controller or a bus controller. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param[in] ControllerHandle The handle of the device to start. This + handle must support a protocol interface that + supplies an I/O abstraction to the driver. + @param[in] RemainingDevicePath The remaining portion of the device path. + (Ignored - this is not a bus driver.) + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a + device error. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources. + +**/ +EFI_STATUS +EFIAPI +NetsecDriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return NetsecInit (This->DriverBindingHandle, ControllerHandle); +} + + +/** + Stops a device controller or a bus controller. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle + must support a bus specific I/O protocol for the + driver to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in + ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be + NULL if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device + error. + +**/ +EFI_STATUS +EFIAPI +NetsecDriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ) +{ + return NetsecRelease (This->DriverBindingHandle, ControllerHandle); +} + + +STATIC +EFI_DRIVER_BINDING_PROTOCOL gNetsecDriverBinding = { + NetsecDriverBindingSupported, + NetsecDriverBindingStart, + NetsecDriverBindingStop, + 0xa, + NULL, + NULL +}; + + +/** + The entry point of Netsec UEFI Driver. + + @param ImageHandle The image handle of the UEFI Driver. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The Driver or UEFI Driver exited normally. + @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than + SystemTable->Hdr.Revision. + +**/ +EFI_STATUS +EFIAPI +NetsecEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu); + ASSERT_EFI_ERROR (Status); + + // + // Add the driver to the list of drivers + // + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, SystemTable, &gNetsecDriverBinding, ImageHandle, + NULL, &gNetsecDriverComponentName2); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INIT | DEBUG_INFO, "*** Installed Netsec UEFI driver! ***\n")); + + return EFI_SUCCESS; +} + + +/** + Unload function for the Netsec UEFI Driver. + + @param ImageHandle[in] The allocated handle for the EFI image + + @retval EFI_SUCCESS The driver was unloaded successfully + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +NetsecUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + + // + // Retrieve all non-discoverable device handles in the handle database + // + Status = gBS->LocateHandleBuffer (ByProtocol, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Disconnect the driver from the handles in the handle database + // + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->DisconnectController (HandleBuffer[Index], + gImageHandle, + NULL); + } + + // + // Free the handle array + // + gBS->FreePool (HandleBuffer); + + // + // Uninstall protocols installed by the driver in its entrypoint + // + Status = gBS->UninstallMultipleProtocolInterfaces (ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gNetsecDriverBinding, + NULL + ); + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c new file mode 100644 index 000000000000..764c44bb3c87 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c @@ -0,0 +1,1056 @@ +/** @file + + Copyright (c) 2016 Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "NetsecDxe.h" + +EFI_CPU_ARCH_PROTOCOL *mCpu; + +STATIC +VOID +GetCurrentMacAddress ( + IN UINT64 EepromBase, + OUT UINT8 *Mac) +{ + Mac[0] = MmioRead8 (EepromBase + MAC_ADDRESS + 3); + Mac[1] = MmioRead8 (EepromBase + MAC_ADDRESS + 2); + Mac[2] = MmioRead8 (EepromBase + MAC_ADDRESS + 1); + Mac[3] = MmioRead8 (EepromBase + MAC_ADDRESS + 0); + Mac[4] = MmioRead8 (EepromBase + MAC_ADDRESS + 7); + Mac[5] = MmioRead8 (EepromBase + MAC_ADDRESS + 6); +} + +/* + * Probe() + */ +STATIC +EFI_STATUS +Probe ( + IN EFI_HANDLE Handle, + IN NETSEC_DRIVER *LanDriver + ) +{ + ogma_param_t Param; + ogma_err_t ogma_err; + UINT64 dmac_hm_cmd_base, dmac_mh_cmd_base, core_cmd_base; + UINT32 dmac_hm_cmd_size, dmac_mh_cmd_size, core_cmd_size; + UINT64 EepromBase; + + SetMem (&Param, sizeof (Param), 0); + + Param.use_gmac_flag = OGMA_TRUE; + + Param.use_jumbo_pkt_flag = FixedPcdGet8 (PcdJumboPacket); + + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].valid_flag = OGMA_TRUE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].little_endian_flag = OGMA_TRUE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].tmr_mode_flag = OGMA_FALSE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].entry_num = FixedPcdGet16 (PcdEncTxDescNum); + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].valid_flag = OGMA_TRUE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].little_endian_flag = OGMA_TRUE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].tmr_mode_flag = OGMA_FALSE; + Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].entry_num = FixedPcdGet16 (PcdDecRxDescNum); + + // phy-interface + Param.gmac_config.phy_interface = OGMA_PHY_INTERFACE_RGMII; + + // Read and save the Permanent MAC Address + EepromBase = LanDriver->Dev->Resources[1].AddrRangeMin; + GetCurrentMacAddress (EepromBase, LanDriver->SnpMode.PermanentAddress.Addr); + + LanDriver->SnpMode.CurrentAddress = LanDriver->SnpMode.PermanentAddress; + DEBUG ((DEBUG_NET | DEBUG_INFO, + "Netsec: HW MAC Address: %02x-%02x-%02x-%02x-%02x-%02x\n", + LanDriver->SnpMode.PermanentAddress.Addr[0], + LanDriver->SnpMode.PermanentAddress.Addr[1], + LanDriver->SnpMode.PermanentAddress.Addr[2], + LanDriver->SnpMode.PermanentAddress.Addr[3], + LanDriver->SnpMode.PermanentAddress.Addr[4], + LanDriver->SnpMode.PermanentAddress.Addr[5])); + + // + // The NETSEC microcode for the core engine and the TX and RX engines + // is loaded from a separate memory mapped ROM. + // + + // Get hm microcode's physical addresses + dmac_hm_cmd_base = MmioRead32 (EepromBase + HM_ME_ADDRESS_H); + dmac_hm_cmd_base <<= 32; + dmac_hm_cmd_base |= MmioRead32 (EepromBase + HM_ME_ADDRESS_L); + dmac_hm_cmd_size = MmioRead32 (EepromBase + HM_ME_SIZE); + + // Get mh microcode's physical addresses + dmac_mh_cmd_base = MmioRead32 (EepromBase + MH_ME_ADDRESS_H); + dmac_mh_cmd_base <<= 32; + dmac_mh_cmd_base |= MmioRead32 (EepromBase + MH_ME_ADDRESS_L); + dmac_mh_cmd_size = MmioRead32 (EepromBase + MH_ME_SIZE); + + // Get core microcode's physical addresses + core_cmd_base = MmioRead32 (EepromBase + PACKET_ME_ADDRESS); + core_cmd_size = MmioRead32 (EepromBase + PACKET_ME_SIZE); + + ogma_err = ogma_init ( + (VOID *)(UINTN)LanDriver->Dev->Resources[0].AddrRangeMin, + Handle, &Param, + (VOID *)dmac_hm_cmd_base, dmac_hm_cmd_size, + (VOID *)dmac_mh_cmd_base, dmac_mh_cmd_size, + (VOID *)core_cmd_base, core_cmd_size, + &LanDriver->Handle); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, "NETSEC: ogma_init() failed with error code %d\n", + ogma_err)); + return EFI_DEVICE_ERROR; + } + + LanDriver->PhyAddress = LanDriver->Dev->Resources[2].AddrRangeMin; + + ogma_enable_top_irq (LanDriver->Handle, + OGMA_TOP_IRQ_REG_NRM_RX | OGMA_TOP_IRQ_REG_NRM_TX); + + return EFI_SUCCESS; +} + +/* + * UEFI Stop() function + */ +STATIC +EFI_STATUS +EFIAPI +SnpStop ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp + ) +{ + NETSEC_DRIVER *LanDriver; + EFI_TPL SavedTpl; + EFI_STATUS Status; + + // Check Snp Instance + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + // Check state of the driver + switch (Snp->Mode->State) { + case EfiSimpleNetworkStarted: + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + gBS->CloseEvent (LanDriver->ExitBootEvent); + + // Change the state + Snp->Mode->State = EfiSimpleNetworkStopped; + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +/* + * UEFI Initialize() function + */ +STATIC +EFI_STATUS +EFIAPI +SnpInitialize ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp, + IN UINTN RxBufferSize OPTIONAL, + IN UINTN TxBufferSize OPTIONAL + ) +{ + NETSEC_DRIVER *LanDriver; + EFI_TPL SavedTpl; + EFI_STATUS Status; + + ogma_phy_link_status_t phy_link_status; + ogma_err_t ogma_err; + ogma_gmac_mode_t ogma_gmac_mode; + + // Check Snp Instance + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // Check that driver was started but not initialised + switch (Snp->Mode->State) { + case EfiSimpleNetworkStarted: + break; + case EfiSimpleNetworkInitialized: + DEBUG ((DEBUG_WARN, "NETSEC: Driver already initialized\n")); + ReturnUnlock (EFI_SUCCESS); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Find the LanDriver structure + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + // Clean all descriptors on the RX ring. + ogma_err = ogma_clean_rx_desc_ring (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_RX); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_clean_rx_desc_ring() failed with error code %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_clean_tx_desc_ring() failed with error code %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_clear_desc_ring_irq_status (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX, + OGMA_CH_IRQ_REG_EMPTY); + + // Start the RX queue + ogma_err = ogma_start_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_start_desc_ring(ring_id=%d) failed with error code %d\n", + OGMA_DESC_RING_ID_NRM_RX, + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_set_irq_coalesce_param (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_RX, + RXINT_PKTCNT, OGMA_FALSE, + RXINT_TMR_CNT_US); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_set_irq_coalesce_param() failed with error code %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_start_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_start_desc_ring(ring_id=%d) failed with error code %d\n", + OGMA_DESC_RING_ID_NRM_TX, + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_disable_desc_ring_irq (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX, + OGMA_CH_IRQ_REG_EMPTY); + + // Stop and restart the physical link + ogma_err = ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_stop_gmac() failed with error status %d\n", + ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_get_phy_link_status (LanDriver->Handle, LanDriver->PhyAddress, + &phy_link_status); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_get_phy_link_status() failed error code %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + SetMem (&ogma_gmac_mode, sizeof (ogma_gmac_mode_t), 0); + ogma_gmac_mode.link_speed = phy_link_status.link_speed; + ogma_gmac_mode.half_duplex_flag = (ogma_bool)phy_link_status.half_duplex_flag; + if ((!phy_link_status.half_duplex_flag) && FixedPcdGet8 (PcdFlowCtrl)) { + ogma_gmac_mode.flow_ctrl_enable_flag = FixedPcdGet8 (PcdFlowCtrl); + ogma_gmac_mode.flow_ctrl_start_threshold = FixedPcdGet16 (PcdFlowCtrlStartThreshold); + ogma_gmac_mode.flow_ctrl_stop_threshold = FixedPcdGet16 (PcdFlowCtrlStopThreshold); + ogma_gmac_mode.pause_time = FixedPcdGet16 (PcdPauseTime); + } + + ogma_err = ogma_set_gmac_mode (LanDriver->Handle, &ogma_gmac_mode); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_set_gmac() failed with error status %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_start_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_start_gmac() failed with error status %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Declare the driver as initialized + Snp->Mode->State = EfiSimpleNetworkInitialized; + Status = EFI_SUCCESS; + + DEBUG ((DEBUG_INFO | DEBUG_LOAD, "NETSEC: Driver started\n")); + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +/* + * UEFI Shutdown () function + */ +STATIC +EFI_STATUS +EFIAPI +SnpShutdown ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp + ) +{ + NETSEC_DRIVER *LanDriver; + EFI_TPL SavedTpl; + EFI_STATUS Status; + + // Check Snp Instance + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // First check that driver has already been initialized + switch (Snp->Mode->State) { + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStarted: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n")); + ReturnUnlock (EFI_DEVICE_ERROR); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver in stopped state\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Find the LanDriver structure + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE); + + ogma_stop_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX); + ogma_stop_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX); + + Snp->Mode->State = EfiSimpleNetworkStarted; + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +STATIC +VOID +EFIAPI +NotifyExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + EFI_STATUS Status; + + Snp = Context; + + if (Snp->Mode != EfiSimpleNetworkStopped) { + Status = SnpShutdown (Snp); + if (!EFI_ERROR (Status)) { + SnpStop (Snp); + } + } + gBS->CloseEvent (Event); +} + +/* + * UEFI Start() function + */ +STATIC +EFI_STATUS +EFIAPI +SnpStart ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp + ) +{ + EFI_SIMPLE_NETWORK_MODE *Mode; + EFI_TPL SavedTpl; + EFI_STATUS Status; + NETSEC_DRIVER *LanDriver; + + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + // Check Snp instance + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + Mode = Snp->Mode; + + // Check state of the driver + switch (Mode->State) { + case EfiSimpleNetworkStopped: + break; + case EfiSimpleNetworkStarted: + case EfiSimpleNetworkInitialized: + DEBUG ((DEBUG_WARN, "NETSEC: Driver already started\n")); + ReturnUnlock (EFI_ALREADY_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, + NotifyExitBoot, Snp, &LanDriver->ExitBootEvent); + ASSERT_EFI_ERROR (Status); + + // Change state + Mode->State = EfiSimpleNetworkStarted; + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; + +} + +/* + * UEFI ReceiveFilters() function + */ +STATIC +EFI_STATUS +EFIAPI +SnpReceiveFilters ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp, + IN UINT32 Enable, + IN UINT32 Disable, + IN BOOLEAN Reset, + IN UINTN NumMfilter OPTIONAL, + IN EFI_MAC_ADDRESS *Mfilter OPTIONAL + ) +{ + EFI_TPL SavedTpl; + EFI_STATUS Status; + + // Check Snp Instance + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // First check that driver has already been initialized + switch (Snp->Mode->State) { + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStarted: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n")); + ReturnUnlock (EFI_DEVICE_ERROR); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +/* + * UEFI GetStatus () function + */ +STATIC +EFI_STATUS +EFIAPI +SnpGetStatus ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp, + OUT UINT32 *IrqStat OPTIONAL, + OUT VOID **TxBuff OPTIONAL + ) +{ + NETSEC_DRIVER *LanDriver; + EFI_TPL SavedTpl; + EFI_STATUS Status; + pfdep_pkt_handle_t pkt_handle; + LIST_ENTRY *Link; + + ogma_phy_link_status_t phy_link_status; + ogma_err_t ogma_err; + + // Check preliminaries + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // Check that driver was started and initialised + switch (Snp->Mode->State) { + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStarted: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n")); + ReturnUnlock (EFI_DEVICE_ERROR); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Find the LanDriver structure + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + // Update the media status + ogma_err = ogma_get_phy_link_status (LanDriver->Handle, LanDriver->PhyAddress, + &phy_link_status); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_get_phy_link_status failed with error code: %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + Snp->Mode->MediaPresent = phy_link_status.up_flag; + + ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX); + + if (TxBuff != NULL) { + *TxBuff = NULL; + // + // Find a buffer in the list that has been released + // + for (Link = GetFirstNode (&LanDriver->TxBufferList); + !IsNull (&LanDriver->TxBufferList, Link); + Link = GetNextNode (&LanDriver->TxBufferList, Link)) { + + pkt_handle = BASE_CR (Link, PACKET_HANDLE, Link); + if (pkt_handle->Released) { + *TxBuff = pkt_handle->Buffer; + RemoveEntryList (Link); + FreePool (pkt_handle); + break; + } + } + } + + if (IrqStat != 0) { + *IrqStat = 0; + } + + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +/* + * UEFI Transmit() function + */ +STATIC +EFI_STATUS +EFIAPI +SnpTransmit ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp, + IN UINTN HdrSize, + IN UINTN BufSize, + IN VOID *BufAddr, + IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + IN EFI_MAC_ADDRESS *DstAddr OPTIONAL, + IN UINT16 *Protocol OPTIONAL + ) +{ + NETSEC_DRIVER *LanDriver; + EFI_TPL SavedTpl; + EFI_STATUS Status; + + ogma_tx_pkt_ctrl_t tx_pkt_ctrl; + ogma_frag_info_t scat_info; + ogma_uint16 tx_avail_num; + ogma_err_t ogma_err; + UINT16 Proto; + pfdep_pkt_handle_t pkt_handle; + + // Check preliminaries + if ((Snp == NULL) || (BufAddr == NULL)) { + DEBUG ((DEBUG_ERROR, + "NETSEC: SnpTransmit(): NULL Snp (%p) or BufAddr (%p)\n", Snp, BufAddr)); + return EFI_DEVICE_ERROR; + } + + pkt_handle = AllocateZeroPool (sizeof (*pkt_handle)); + if (pkt_handle == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + pkt_handle->Buffer = BufAddr; + pkt_handle->RecycleForTx = TRUE; + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // Check that driver was started and initialised + switch (Snp->Mode->State) { + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStarted: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n")); + ReturnUnlock (EFI_DEVICE_ERROR); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Find the LanDriver structure + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + ogma_err = ogma_clear_desc_ring_irq_status (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX, + OGMA_CH_IRQ_REG_EMPTY); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_clear_desc_ring_irq_status failed with error code: %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_clean_tx_desc_ring failed with error code: %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Ensure header is correct size if non-zero + if (HdrSize) { + if (HdrSize != Snp->Mode->MediaHeaderSize) { + DEBUG ((DEBUG_ERROR, "NETSEC: SnpTransmit(): Invalid HdrSize %d\n", + HdrSize)); + ReturnUnlock (EFI_INVALID_PARAMETER); + } + + if ((DstAddr == NULL) || (Protocol == NULL)) { + DEBUG ((DEBUG_ERROR, + "NETSEC: SnpTransmit(): NULL DstAddr %p or Protocol %p\n", + DstAddr, Protocol)); + ReturnUnlock (EFI_INVALID_PARAMETER); + } + + // Copy destination address + CopyMem (BufAddr, (VOID *)DstAddr, NET_ETHER_ADDR_LEN); + // Copy source address + CopyMem (BufAddr + NET_ETHER_ADDR_LEN, (VOID *)SrcAddr, NET_ETHER_ADDR_LEN); + // Copy protocol + Proto = HTONS (*Protocol); + CopyMem (BufAddr + (NET_ETHER_ADDR_LEN * 2), (VOID *)&Proto, + sizeof (UINT16)); + } + + Status = DmaMap (MapOperationBusMasterRead, BufAddr, &BufSize, + &scat_info.phys_addr, &pkt_handle->Mapping); + if (EFI_ERROR (Status)) { + goto ExitUnlock; + } + + scat_info.addr = BufAddr; + scat_info.len = BufSize; + + SetMem (&tx_pkt_ctrl, sizeof (ogma_tx_pkt_ctrl_t), 0); + + tx_pkt_ctrl.pass_through_flag = OGMA_TRUE; + tx_pkt_ctrl.target_desc_ring_id = OGMA_DESC_RING_ID_GMAC; + + // check empty slot + do { + tx_avail_num = ogma_get_tx_avail_num (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX); + } while (tx_avail_num < SCAT_NUM); + + // send + ogma_err = ogma_set_tx_pkt_data (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX, + &tx_pkt_ctrl, + SCAT_NUM, + &scat_info, + pkt_handle); + + if (ogma_err != OGMA_ERR_OK) { + DmaUnmap (pkt_handle->Mapping); + FreePool (pkt_handle); + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_set_tx_pkt_data failed with error code: %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // + // Queue the descriptor so we can release the buffer once it has been + // consumed by the hardware. + // + InsertTailList (&LanDriver->TxBufferList, &pkt_handle->Link); + + gBS->RestoreTPL (SavedTpl); + return EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + FreePool (pkt_handle); + gBS->RestoreTPL (SavedTpl); + return Status; +} + +/* + * UEFI Receive() function + */ +EFI_STATUS +EFIAPI +SnpReceive ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp, + OUT UINTN *HdrSize OPTIONAL, + IN OUT UINTN *BuffSize, + OUT VOID *Data, + OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + OUT EFI_MAC_ADDRESS *DstAddr OPTIONAL, + OUT UINT16 *Protocol OPTIONAL + ) +{ + EFI_TPL SavedTpl; + EFI_STATUS Status; + NETSEC_DRIVER *LanDriver; + + ogma_err_t ogma_err; + ogma_rx_pkt_info_t rx_pkt_info; + ogma_frag_info_t rx_data; + ogma_uint16 len; + pfdep_pkt_handle_t pkt_handle; + + // Check preliminaries + if ((Snp == NULL) || (Data == NULL)) { + return EFI_INVALID_PARAMETER; + } + + // Serialize access to data and registers + SavedTpl = gBS->RaiseTPL (TPL_CALLBACK); + + // Check that driver was started and initialised + switch (Snp->Mode->State) { + case EfiSimpleNetworkInitialized: + break; + case EfiSimpleNetworkStarted: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n")); + ReturnUnlock (EFI_DEVICE_ERROR); + case EfiSimpleNetworkStopped: + DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n")); + ReturnUnlock (EFI_NOT_STARTED); + default: + DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n", + (UINTN)Snp->Mode->State)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + // Find the LanDriver structure + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + if (ogma_get_rx_num (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX) > 0) { + + ogma_err = ogma_get_rx_pkt_data (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_RX, + &rx_pkt_info, &rx_data, &len, &pkt_handle); + if (ogma_err != OGMA_ERR_OK) { + DEBUG ((DEBUG_ERROR, + "NETSEC: ogma_get_rx_pkt_data failed with error code: %d\n", + (INT32)ogma_err)); + ReturnUnlock (EFI_DEVICE_ERROR); + } + + DmaUnmap (pkt_handle->Mapping); + pkt_handle->Mapping = NULL; + + CopyMem (Data, (VOID *)rx_data.addr, len); + *BuffSize = len; + + pfdep_free_pkt_buf (LanDriver->Handle, rx_data.len, rx_data.addr, + rx_data.phys_addr, PFDEP_TRUE, pkt_handle); + } else { + // not received any packets + ReturnUnlock (EFI_NOT_READY); + } + + if (HdrSize != NULL) { + *HdrSize = LanDriver->SnpMode.MediaHeaderSize; + } + + ogma_clear_desc_ring_irq_status (LanDriver->Handle, + OGMA_DESC_RING_ID_NRM_TX, + OGMA_CH_IRQ_REG_EMPTY); + + ogma_clean_tx_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX); + + ogma_enable_top_irq (LanDriver->Handle, + OGMA_TOP_IRQ_REG_NRM_TX | OGMA_TOP_IRQ_REG_NRM_RX); + + Status = EFI_SUCCESS; + + // Restore TPL and return +ExitUnlock: + gBS->RestoreTPL (SavedTpl); + return Status; +} + +EFI_STATUS +NetsecInit ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ) +{ + EFI_STATUS Status; + NETSEC_DRIVER *LanDriver; + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + EFI_SIMPLE_NETWORK_MODE *SnpMode; + + // Allocate Resources + LanDriver = AllocateZeroPool (sizeof (NETSEC_DRIVER)); + if (LanDriver == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gBS->OpenProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + (VOID **)&LanDriver->Dev, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER); + if (EFI_ERROR (Status)) { + goto FreeDevice; + } + + // Initialize pointers + Snp = &(LanDriver->Snp); + SnpMode = &(LanDriver->SnpMode); + Snp->Mode = SnpMode; + + // Set the signature of the LAN Driver structure + LanDriver->Signature = NETSEC_SIGNATURE; + + // Probe the device + Status = Probe (DriverBindingHandle, LanDriver); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "NETSEC:%a(): Probe failed with status %d\n", __FUNCTION__, Status)); + goto CloseDeviceProtocol; + } + + // Assign fields and func pointers + Snp->Revision = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION; + Snp->WaitForPacket = NULL; + Snp->Initialize = SnpInitialize; + Snp->Start = SnpStart; + Snp->Stop = SnpStop; + Snp->Reset = NULL; + Snp->Shutdown = SnpShutdown; + Snp->ReceiveFilters = SnpReceiveFilters; + Snp->StationAddress = NULL; + Snp->Statistics = NULL; + Snp->MCastIpToMac = NULL; + Snp->NvData = NULL; + Snp->GetStatus = SnpGetStatus; + Snp->Transmit = SnpTransmit; + Snp->Receive = SnpReceive; + + // Fill in simple network mode structure + SnpMode->State = EfiSimpleNetworkStopped; + SnpMode->HwAddressSize = NET_ETHER_ADDR_LEN; + SnpMode->MediaHeaderSize = sizeof (ETHER_HEAD); + SnpMode->MaxPacketSize = EFI_PAGE_SIZE; + + // Supported receive filters + SnpMode->ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | + EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST | + EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | + EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS | + EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; + + // Initially-enabled receive filters + SnpMode->ReceiveFilterSetting = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | + EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST | + EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST; + + // Netsec has 64bit hash table. We can filter an infinite MACs, but + // higher-level software must filter out any hash collisions. + SnpMode->MaxMCastFilterCount = MAX_MCAST_FILTER_CNT; + SnpMode->MCastFilterCount = 0; + ZeroMem (&SnpMode->MCastFilter, + MAX_MCAST_FILTER_CNT * sizeof (EFI_MAC_ADDRESS)); + + // Set the interface type (1: Ethernet or 6: IEEE 802 Networks) + SnpMode->IfType = NET_IFTYPE_ETHERNET; + + // Mac address is changeable + SnpMode->MacAddressChangeable = TRUE; + + // We can only transmit one packet at a time + SnpMode->MultipleTxSupported = FALSE; + + // MediaPresent checks for cable connection and partner link + SnpMode->MediaPresentSupported = TRUE; + SnpMode->MediaPresent = FALSE; + + // Set broadcast address + SetMem (&SnpMode->BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF); + + InitializeListHead (&LanDriver->TxBufferList); + + LanDriver->DevicePath.Netsec.Header.Type = MESSAGING_DEVICE_PATH; + LanDriver->DevicePath.Netsec.Header.SubType = MSG_MAC_ADDR_DP; + + SetDevicePathNodeLength (&LanDriver->DevicePath.Netsec.Header, + sizeof (LanDriver->DevicePath.Netsec)); + CopyMem (&LanDriver->DevicePath.Netsec.MacAddress, + &SnpMode->PermanentAddress, PXE_HWADDR_LEN_ETHER); + LanDriver->DevicePath.Netsec.IfType = SnpMode->IfType; + SetDevicePathEndNode (&LanDriver->DevicePath.End); + + // Initialise the protocol + Status = gBS->InstallMultipleProtocolInterfaces ( + &ControllerHandle, + &gEfiSimpleNetworkProtocolGuid, Snp, + &gEfiDevicePathProtocolGuid, &LanDriver->DevicePath, + NULL); + + LanDriver->ControllerHandle = ControllerHandle; + + // Say what the status of loading the protocol structure is + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: InstallMultipleProtocolInterfaces failed - %r\n", + __FUNCTION__, Status)); + ogma_terminate (LanDriver->Handle); + goto CloseDeviceProtocol; + } + return EFI_SUCCESS; + +CloseDeviceProtocol: + gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, DriverBindingHandle, + ControllerHandle); + +FreeDevice: + FreePool (LanDriver); + return Status; +} + +EFI_STATUS +NetsecRelease ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ) +{ + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + NETSEC_DRIVER *LanDriver; + EFI_STATUS Status; + + Status = gBS->HandleProtocol (ControllerHandle, + &gEfiSimpleNetworkProtocolGuid, + (VOID **)&Snp); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + LanDriver = INSTANCE_FROM_SNP_THIS (Snp); + + Status = gBS->UninstallMultipleProtocolInterfaces (ControllerHandle, + &gEfiSimpleNetworkProtocolGuid, Snp, + &gEfiDevicePathProtocolGuid, &LanDriver->DevicePath, + NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + if (Snp->Mode->State == EfiSimpleNetworkInitialized) { + SnpShutdown (Snp); + } + + ogma_terminate (LanDriver->Handle); + + gBS->CloseEvent (LanDriver->ExitBootEvent); + + Status = gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + DriverBindingHandle, + ControllerHandle); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + gBS->FreePool (LanDriver); + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec new file mode 100644 index 000000000000..3e7d832e62d5 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec @@ -0,0 +1,46 @@ +## @file +# +# Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+# Copyright (c) 2017, Linaro, Ltd. 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] + DEC_SPECIFICATION = 0x0001001A + PACKAGE_NAME = OpenPlatformDriversNetNetsecDxePkg + PACKAGE_GUID = bd8ddfdd-2e8d-4081-8117-99405df3ffc8 + PACKAGE_VERSION = 0.1 + + +################################################################################ +# +# Include Section - list of Include Paths that are provided by this package. +# Comments are used for Keywords and Module Types. +# +# Supported Module Types: +# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +################################################################################ + +[Guids.common] + gNetsecDxeTokenSpaceGuid = { 0x47d6c028, 0x2413, 0x416d, { 0xa8, 0xef, 0xe4, 0x5c, 0x58, 0x83, 0x5e, 0x49 }} + + gNetsecNonDiscoverableDeviceGuid = { 0x73596fa4, 0x2b09, 0x4965, { 0xa8, 0x05, 0x4a, 0x20, 0x7a, 0xf6, 0x75, 0x6c }} + +[PcdsFixedAtBuild.common] + # Netsec Ethernet Driver PCDs + gNetsecDxeTokenSpaceGuid.PcdEncTxDescNum|0x0|UINT16|0x00000002 + gNetsecDxeTokenSpaceGuid.PcdDecRxDescNum|0x0|UINT16|0x00000003 + gNetsecDxeTokenSpaceGuid.PcdJumboPacket|0x0|UINT8|0x00000004 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrl|0x0|UINT8|0x00000005 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold|0x0|UINT16|0x00000006 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold|0x0|UINT16|0x00000007 + gNetsecDxeTokenSpaceGuid.PcdPauseTime|0x0|UINT16|0x00000008 diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h new file mode 100644 index 000000000000..6aa7f1a1d107 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h @@ -0,0 +1,118 @@ +/** @file + + Copyright (c) 2016 Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef __NETSEC_DXE_H_ +#define __NETSEC_DXE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "netsec_for_uefi/netsec_sdk/include/ogma_api.h" +#include "netsec_for_uefi/pfdep.h" + +extern EFI_COMPONENT_NAME2_PROTOCOL gNetsecDriverComponentName2; + +/*--------------- Simple Network Driver entry point functions ----------------*/ + +// Refer to the Simple Network Protocol section (21.1) +// in the UEFI 2.3.1 Specification for documentation. + +#define ReturnUnlock(s) do { Status = (s); goto ExitUnlock; } while (0) + +/*------------------------------------------------------------------------------ + NETSEC Information Structure +------------------------------------------------------------------------------*/ + +#pragma pack(1) +typedef struct { + MAC_ADDR_DEVICE_PATH Netsec; + EFI_DEVICE_PATH_PROTOCOL End; +} NETSEC_DEVICE_PATH; +#pragma pack() + +typedef struct { + // Driver signature + UINT32 Signature; + EFI_HANDLE ControllerHandle; + + // EFI SNP protocol instances + EFI_SIMPLE_NETWORK_PROTOCOL Snp; + EFI_SIMPLE_NETWORK_MODE SnpMode; + + // EFI Snp statistics instance + EFI_NETWORK_STATISTICS Stats; + + // ogma handle + ogma_handle_t Handle; + + // List of submitted TX buffers + LIST_ENTRY TxBufferList; + + EFI_EVENT ExitBootEvent; + + NON_DISCOVERABLE_DEVICE *Dev; + + NETSEC_DEVICE_PATH DevicePath; + + UINTN PhyAddress; +} NETSEC_DRIVER; + +#define NETSEC_SIGNATURE SIGNATURE_32('n', 't', 's', 'c') +#define INSTANCE_FROM_SNP_THIS(a) CR((a), NETSEC_DRIVER, Snp, NETSEC_SIGNATURE) + +/*------------------------------------------------------------------------------ + +------------------------------------------------------------------------------*/ + +EFI_STATUS +NetsecInit ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ); + +EFI_STATUS +NetsecRelease ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ); + +#define MAC_ADDRESS 0x00 + +#define HM_ME_ADDRESS_H 0x08 +#define HM_ME_ADDRESS_L 0x0C +#define HM_ME_SIZE 0x10 + +#define MH_ME_ADDRESS_H 0x14 +#define MH_ME_ADDRESS_L 0x18 +#define MH_ME_SIZE 0x1C + +#define PACKET_ME_ADDRESS 0x20 +#define PACKET_ME_SIZE 0x24 + +#define SCAT_NUM 1 + +#define RXINT_TMR_CNT_US 0 +#define RXINT_PKTCNT 1 + +#endif diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf new file mode 100644 index 000000000000..55dfc48fd5a2 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf @@ -0,0 +1,70 @@ +## @file +# +# Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+# Copyright (c) 2017, Linaro, Ltd. 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 = NetsecDxe + FILE_GUID = a4eed3af-9837-46b3-9275-c71cb47071f9 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 0.1 + ENTRY_POINT = NetsecEntryPoint + UNLOAD = NetsecUnload + +[Sources] + ComponentName.c + DriverBinding.c + NetsecDxe.c + + netsec_for_uefi/pfdep_uefi.c + netsec_for_uefi/netsec_sdk/src/ogma_basic_access.c + netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access.c + netsec_for_uefi/netsec_sdk/src/ogma_gmac_access.c + netsec_for_uefi/netsec_sdk/src/ogma_misc.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + NetworkPkg/NetworkPkg.dec + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DevicePathLib + DmaLib + IoLib + NetLib + SynchronizationLib + TimerLib + UefiDriverEntryPoint + UefiLib + +[Guids] + gNetsecNonDiscoverableDeviceGuid + +[Protocols] + gEdkiiNonDiscoverableDeviceProtocolGuid ## TO_START + gEfiDevicePathProtocolGuid ## BY_START + gEfiSimpleNetworkProtocolGuid ## BY_START + +[FixedPcd] + gNetsecDxeTokenSpaceGuid.PcdDecRxDescNum + gNetsecDxeTokenSpaceGuid.PcdEncTxDescNum + gNetsecDxeTokenSpaceGuid.PcdFlowCtrl + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold + gNetsecDxeTokenSpaceGuid.PcdJumboPacket + gNetsecDxeTokenSpaceGuid.PcdPauseTime diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h new file mode 100644 index 000000000000..336325109e33 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h @@ -0,0 +1,736 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_API_H +#define OGMA_API_H + +#include "ogma_version.h" +#include "netsec_for_uefi/ogma_config.h" +#include "netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h" +#include "netsec_for_uefi/pfdep.h" +/** + * Check configuration macro settings. + */ +#ifdef OGMA_CONFIG_CLK_HZ +#if ( (OGMA_CONFIG_CLK_HZ < 0x200000) || (OGMA_CONFIG_CLK_HZ > 0x10000000) ) +#error "OGMA_CONFIG_CLK_HZ is not appropriate." +#endif /* ( (OGMA_CONFIG_CLK_HZ < 0x200000) || (OGMA_CONFIG_CLK_HZ > 0x10000000) ) */ +#else /* ! OGMA_CONFIG_CLK_HZ */ +#error "OGMA_CONFIG_CLK_HZ is not given." +#endif /* OGMA_CONFIG_CLK_HZ */ + +#ifndef OGMA_CONFIG_GMAC_CLK_HZ +#define OGMA_CONFIG_GMAC_CLK_HZ OGMA_CONFIG_CLK_HZ +#endif + +/** + * Number of hardware limits + */ + + +/** + * Number of Common Descriptor ring id + */ +#define OGMA_DESC_RING_ID_NRM_TX 0 +#define OGMA_DESC_RING_ID_NRM_RX 1 + +#define OGMA_DESC_RING_ID_GMAC 15 +#define OGMA_DESC_RING_ID_MAX 1 + +/** + * Numbre of TCP Segmentation length limits + */ +#define OGMA_TCP_SEG_LEN_MAX 1460 +#define OGMA_TCP_JUMBO_SEG_LEN_MAX 8960 + +/** + * Number of ER check result for received packet + */ +#define OGMA_RX_ER_RESULT_NG 0x1 +#define OGMA_RX_ER_RESULT_OK 0x0 + +/** + * Number of checksum calculation result for received packet + */ +#define OGMA_RX_CKSUM_RESULT_OK 0x1 +#define OGMA_RX_CKSUM_RESULT_NG 0x2 +#define OGMA_RX_CKSUM_RESULT_NOTAVAIL 0x0 + +/** + * Number of ErrorCode for received packet + */ +#define OGMA_RX_ERRCODE_HEADER_INCOMLETE_ERR 0x2 +#define OGMA_RX_ERRCODE_IP_HEADER_ERR 0x1 +#define OGMA_RX_ERRCODE_NONE 0x0 + +/** + * Number of top interrupt enable register bit field + */ +#define OGMA_TOP_IRQ_REG_ME_START (1UL << 20) +#define OGMA_TOP_IRQ_REG_MAC (1UL << 19) +#define OGMA_TOP_IRQ_REG_PKT (1UL << 18) +#define OGMA_TOP_IRQ_REG_BOOTCODE_TX (1UL << 5) +#define OGMA_TOP_IRQ_REG_NRM_RX (1UL << 1) +#define OGMA_TOP_IRQ_REG_NRM_TX (1UL << 0) + + +/** + * Number of top channel enable register bit field + */ +#define OGMA_CH_IRQ_REG_EMPTY (1UL << 17) +#define OGMA_CH_IRQ_REG_ERR (1UL << 16) +#define OGMA_CH_IRQ_REG_PKT_CNT (1UL << 15) +#define OGMA_CH_IRQ_REG_TIMEUP (1UL << 14) +#define OGMA_CH_IRQ_REG_RCV (OGMA_CH_IRQ_REG_PKT_CNT | OGMA_CH_IRQ_REG_TIMEUP) + +/** + * Number of top channel enable register bit field for F_NETSEC_C + */ +#define OGMA_CH_IRQ_REG_TX_DONE (1UL << 15) +#define OGMA_CH_IRQ_REG_SND (OGMA_CH_IRQ_REG_TX_DONE | OGMA_CH_IRQ_REG_TIMEUP) + + +/** + * Number of packet interrupt enable register bit field + */ +#define OGMA_PKT_IRQ_MAC_ER (1UL << 5) +#define OGMA_PKT_IRQ_JUMBO_ER (1UL << 4) +#define OGMA_PKT_IRQ_CHKSUM_ER (1UL << 3) +#define OGMA_PKT_IRQ_HD_INCOMPLETE (1UL << 2) +#define OGMA_PKT_IRQ_HD_ER (1UL << 1) +#define OGMA_PKT_IRQ_DRP_NO_MATCH (1UL << 0) + + +/** + * Number of mac irq enable register bit field + */ +#define OGMA_MAC_IRQ_INT_PMT (1UL << 31) +#define OGMA_MAC_IRQ_INT_SBD (1UL << 30) +#define OGMA_MAC_IRQ_INT_LPI (1UL << 29) +#define OGMA_MAC_IRQ_INT_MAC_TX_RX_INFO_INT (1UL << 27) +#define OGMA_MAC_IRQ_INT_LPI_TX_ENTRY (1UL << 26) +#define OGMA_MAC_IRQ_INT_LPI_RX_ENTRY (1UL << 25) +#define OGMA_MAC_IRQ_INT_LPI_TX_EXIT (1UL << 24) +#define OGMA_MAC_IRQ_INT_LPI_RX_EXIT (1UL << 23) + + +/** + * Number of SR IER register bit field + */ +#define OGMA_GMAC_INT_SBD_IRQ_SR_GLPII (1U << 30) +#define OGMA_GMAC_INT_SBD_IRQ_SR_TTI (1U << 29) +#define OGMA_GMAC_INT_SBD_IRQ_SR_GPI (1U << 28) +#define OGMA_GMAC_INT_SBD_IRQ_SR_GMI (1U << 27) +#define OGMA_GMAC_INT_SBD_IRQ_SR_GLI (1U << 26) +#define OGMA_GMAC_INT_SBD_IRQ_SR_NIS (1U << 16) +#define OGMA_GMAC_INT_SBD_IRQ_SR_AIS (1U << 15) +#define OGMA_GMAC_INT_SBD_IRQ_SR_ERI (1U << 14) +#define OGMA_GMAC_INT_SBD_IRQ_SR_FBI (1U << 13) +#define OGMA_GMAC_INT_SBD_IRQ_SR_ETI (1U << 10) +#define OGMA_GMAC_INT_SBD_IRQ_SR_RWT (1U << 9) +#define OGMA_GMAC_INT_SBD_IRQ_SR_RPS (1U << 8) +#define OGMA_GMAC_INT_SBD_IRQ_SR_RU (1U << 7) +#define OGMA_GMAC_INT_SBD_IRQ_SR_RI (1U << 6) +#define OGMA_GMAC_INT_SBD_IRQ_SR_UNF (1U << 5) +#define OGMA_GMAC_INT_SBD_IRQ_SR_OVF (1U << 4) +#define OGMA_GMAC_INT_SBD_IRQ_SR_TJT (1U << 3) +#define OGMA_GMAC_INT_SBD_IRQ_SR_TU (1U << 2) +#define OGMA_GMAC_INT_SBD_IRQ_SR_TPS (1U << 1) +#define OGMA_GMAC_INT_SBD_IRQ_SR_TI (1U << 0) +#define OGMA_GMAC_INT_SBD_IRQ_SR_WC_ALL ( OGMA_GMAC_INT_SBD_IRQ_SR_NIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_AIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ERI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_FBI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ETI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RWT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_UNF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_OVF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TJT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TI) + +#define OGMA_GMAC_INT_SBD_IRQ_SR_ALL ( OGMA_GMAC_INT_SBD_IRQ_SR_GLPII | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TTI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_GPI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_GMI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_GLI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_NIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_AIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ERI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_FBI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ETI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RWT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_UNF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_OVF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TJT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TI) + +#define OGMA_GMAC_INT_SBD_IRQ_IER_ALL ( OGMA_GMAC_INT_SBD_IRQ_SR_NIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_AIS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ERI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_FBI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_ETI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RWT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_RI | \ + OGMA_GMAC_INT_SBD_IRQ_SR_UNF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_OVF | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TJT | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TU | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TPS | \ + OGMA_GMAC_INT_SBD_IRQ_SR_TI) + +/** + * Number of ISR IMR register bit field + */ +#define OGMA_GMAC_INT_SBD_IRQ_ISR_LPII (1U << 10) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_TSI (1U << 9) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_COI (1U << 7) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_TI (1U << 6) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_RI (1U << 5) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_MI (1U << 4) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_PI (1U << 3) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_RGI (1U << 0) +#define OGMA_GMAC_INT_SBD_IRQ_ISR_ALL ( OGMA_GMAC_INT_SBD_IRQ_ISR_LPII | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_TSI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_COI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_TI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_RI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_MI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_PI | \ + OGMA_GMAC_INT_SBD_IRQ_ISR_RGI) + +/** + * Number of LPICSR register bit field + */ +#define OGMA_GMAC_LPICSR_REG_LPITXA (1U << 19) +#define OGMA_GMAC_LPICSR_REG_PLSEN (1U << 18) +#define OGMA_GMAC_LPICSR_REG_PLS (1U << 17) +#define OGMA_GMAC_LPICSR_REG_LPIEN (1U << 16) +#define OGMA_GMAC_LPICSR_REG_RLPIST (1U << 9) +#define OGMA_GMAC_LPICSR_REG_TLPIST (1U << 8) +#define OGMA_GMAC_LPICSR_REG_RLPIEX (1U << 3) +#define OGMA_GMAC_LPICSR_REG_RLPIEN (1U << 2) +#define OGMA_GMAC_LPICSR_REG_TLPIEX (1U << 1) +#define OGMA_GMAC_LPICSR_REG_TLPIEN (1U << 0) + +/** + * Number of RGSR register bit field + */ +#define OGMA_GMAC_RGSR_REG_LS (1U << 3) +#define OGMA_GMAC_RGSR_REG_LSP (1U << 1) +#define OGMA_GMAC_RGSR_REG_LM (1U << 0) + +/** + * Number of various limits + */ +#define OGMA_DESC_ENTRY_NUM_MIN 2 +#define OGMA_DESC_ENTRY_NUM_MAX 2047 +#define OGMA_INT_PKTCNT_MAX 2047 +#define OGMA_L4_MIN_LEN_MAX 64 + +/** + * Number of ogma phy interface setting + */ +#define OGMA_PHY_INTERFACE_GMII 0 +#define OGMA_PHY_INTERFACE_RGMII 1 +#define OGMA_PHY_INTERFACE_RMII 4 + +/** + * Number of ogma link speed setting + */ +#define OGMA_PHY_LINK_SPEED_1G 0 +#define OGMA_PHY_LINK_SPEED_100M 1U +#define OGMA_PHY_LINK_SPEED_10M 2U +#define OGMA_PHY_LINK_SPEED_100M_OR_10M 3U + +/** + * Number of flow control limits + */ +#define OGMA_FLOW_CTRL_START_THRESHOLD_MAX 95 +#define OGMA_FLOW_CTRL_STOP_THRESHOLD_MAX 95 +#define OGMA_FLOW_CTRL_PAUSE_TIME_MIN 5 + +enum ogma_err_e{ + OGMA_ERR_OK = 0, + OGMA_ERR_PARAM, + OGMA_ERR_ALLOC, + OGMA_ERR_BUSY, + OGMA_ERR_RANGE, + OGMA_ERR_DATA, + OGMA_ERR_NOTAVAIL, + OGMA_ERR_INTERRUPT, + OGMA_ERR_AGAIN, + OGMA_ERR_INVALID, +}; + +typedef void *ogma_handle_t; +typedef struct ogma_param_s ogma_param_t; +typedef struct ogma_pkt_ctrl_param_s ogma_pkt_ctrl_param_t; +typedef struct ogma_desc_ring_param_s ogma_desc_ring_param_t; +typedef enum ogma_err_e ogma_err_t; +typedef ogma_uint8 ogma_desc_ring_id_t; +typedef struct ogma_tx_pkt_ctrl_s ogma_tx_pkt_ctrl_t; +typedef struct ogma_rx_pkt_info_s ogma_rx_pkt_info_t; +typedef struct ogma_frag_info_s ogma_frag_info_t; +typedef struct ogma_gmac_config_s ogma_gmac_config_t; +typedef struct ogma_gmac_mode_s ogma_gmac_mode_t; + +struct ogma_gmac_config_s{ + ogma_uint8 phy_interface; +}; + +struct ogma_pkt_ctrl_param_s{ + ogma_uint log_chksum_er_flag:1; + ogma_uint log_hd_imcomplete_flag:1; + ogma_uint log_hd_er_flag:1; + ogma_uint drp_no_match_flag:1; +}; + +struct ogma_desc_ring_param_s{ + ogma_uint valid_flag:1; + ogma_uint little_endian_flag:1; + ogma_uint tmr_mode_flag:1; + ogma_uint16 entry_num; +}; + +struct ogma_param_s{ + + ogma_uint use_gmac_flag:1; + ogma_uint use_jumbo_pkt_flag:1; + ogma_pkt_ctrl_param_t pkt_ctrl_param; + ogma_desc_ring_param_t desc_ring_param[OGMA_DESC_RING_ID_MAX+1]; + ogma_gmac_config_t gmac_config; + ogma_uint8 mac_addr[6]; +}; + +struct ogma_tx_pkt_ctrl_s{ + ogma_uint pass_through_flag:1; + ogma_uint cksum_offload_flag:1; + ogma_uint tcp_seg_offload_flag:1; + ogma_desc_ring_id_t target_desc_ring_id; + ogma_uint16 tcp_seg_len; +}; + +struct ogma_rx_pkt_info_s{ + ogma_uint fragmented_flag:1; + ogma_uint err_flag:1; + ogma_uint rx_cksum_result:2; + ogma_uint8 err_code; +}; + +struct ogma_frag_info_s{ + pfdep_phys_addr_t phys_addr; + void *addr; + ogma_uint32 len; +}; + +struct ogma_gmac_mode_s{ + ogma_uint half_duplex_flag:1; + ogma_uint flow_ctrl_enable_flag:1; + ogma_uint8 link_speed; + ogma_uint16 flow_ctrl_start_threshold; + ogma_uint16 flow_ctrl_stop_threshold; + ogma_uint16 pause_time; +}; + +#ifdef OGMA_CONFIG_REC_STAT +typedef struct ogma_stat_info_s { + ogma_uint16 current_busy_entry_num[OGMA_DESC_RING_ID_MAX + 1]; + ogma_uint16 max_busy_entry_num[OGMA_DESC_RING_ID_MAX + 1]; +} ogma_stat_info_t; +#endif /* OGMA_CONFIG_REC_STAT */ + +typedef struct ogma_gmac_int_sbd_regs_s{ + ogma_uint32 base; + ogma_uint32 extended; +} ogma_gmac_int_sbd_regs_t; + +typedef struct ogma_phy_link_status_s{ + ogma_uint up_flag:1; + ogma_uint auto_nego_enable_flag:1; + ogma_uint auto_nego_complete_flag:1; + ogma_uint half_duplex_flag:1; + ogma_uint latched_link_down_flag:1; + ogma_uint lpi_capable_flag:1; + ogma_uint8 link_speed; +} ogma_phy_link_status_t; + +/************************** +*************************** +***************************/ + +ogma_err_t ogma_init ( + void *base_addr, + pfdep_dev_handle_t dev_handle, + const ogma_param_t *param_p, + const void *dma_hm_mc_addr, + ogma_uint32 dma_hm_mc_len, + const void *dma_mh_mc_addr, + ogma_uint32 dma_mh_mc_len, + const void *pktc_mc_addr, + ogma_uint32 pktc_mc_len, + ogma_handle_t *ogma_handle_p + ); + +void ogma_terminate ( + ogma_handle_t ogma_handle + ); + +ogma_err_t ogma_start_gmac ( + ogma_handle_t ogma_handle, + ogma_bool rx_flag, + ogma_bool tx_flag + ); + +ogma_err_t ogma_stop_gmac ( + ogma_handle_t ogma_handle, + ogma_bool rx_flag, + ogma_bool tx_flag + ); + +ogma_err_t ogma_set_gmac_mode ( + ogma_handle_t ogma_handle, + const ogma_gmac_mode_t *gmac_mode_p + ); + +void ogma_set_phy_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr, + ogma_uint16 value + ); + +ogma_uint16 ogma_get_phy_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr + ); + +ogma_err_t ogma_get_gmac_status ( + ogma_handle_t ogma_handle, + ogma_bool *valid_flag_p, + ogma_gmac_mode_t *gmac_mode_p, + ogma_bool *rx_running_flag_p, + ogma_bool *tx_running_flag_p + ); + +ogma_uint32 ogma_get_top_irq_enable ( + ogma_handle_t ogma_handle + ); + +ogma_uint32 ogma_get_top_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ); + +#define ogma_get_top_irq_status_non_clear(ogma_handle,mask_flag) \ +ogma_get_top_irq_status(ogma_handle,mask_flag) + +ogma_err_t ogma_clear_top_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ); + +ogma_uint32 ogma_get_desc_ring_irq_enable ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_uint32 ogma_get_desc_ring_irq_status ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_bool mask_flag + ); + +#define ogma_get_desc_ring_irq_status_non_clear(ogma_handle,ring_id,mask_flag) \ +ogma_get_desc_ring_irq_status(ogma_handle,ring_id,mask_flag) + + + +ogma_err_t ogma_clear_desc_ring_irq_status ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 value + ); + +ogma_uint32 ogma_get_pkt_irq_enable ( + ogma_handle_t ogma_handle + ); + +ogma_uint32 ogma_get_pkt_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ); + +#define ogma_get_pkt_irq_status_non_clear(ogma_handle,mask_flag) \ +ogma_get_pkt_irq_status(ogma_handle,mask_flag) + + +ogma_err_t ogma_clear_pkt_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ); + +/* ogma_desc_ring_access.c */ +ogma_err_t ogma_start_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_err_t ogma_stop_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_uint16 ogma_get_rx_num ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_uint16 ogma_get_tx_avail_num ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_err_t ogma_clean_tx_desc_ring( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_err_t ogma_clean_rx_desc_ring( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ); + +ogma_err_t ogma_set_tx_pkt_data ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + const ogma_tx_pkt_ctrl_t *tx_pkt_ctrl_p, + ogma_uint8 scat_num, + const ogma_frag_info_t *scat_info_p, + pfdep_pkt_handle_t pkt_handle + ); + +ogma_err_t ogma_get_rx_pkt_data ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_rx_pkt_info_t *rx_pkt_info_p, + ogma_frag_info_t *frag_info_p, + ogma_uint16 *len_p, + pfdep_pkt_handle_t *pkt_handle_p + ); + +ogma_err_t ogma_enable_top_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_disable_top_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_enable_desc_ring_irq ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_disable_desc_ring_irq ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_enable_pkt_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_disable_pkt_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +ogma_uint32 ogma_get_hw_ver ( + ogma_handle_t ogma_handle + ); + +ogma_uint32 ogma_get_mcr_ver ( + ogma_handle_t ogma_handle + ); + +/** + * Set up IRQ coalesce parameters. + * + * [Note] + * - This is a tentative implementation. + * Not tested enough. Use with care. + * + * - Call this function after every invocation of ogma_start_desc_ring() + * because ogma_start_desc_ring() resets IRQ coalesce settings. + * + */ +ogma_err_t ogma_set_irq_coalesce_param ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint16 int_pktcnt, + ogma_bool int_tmr_unit_ms_flag, + ogma_uint16 int_tmr_cnt + ); + +ogma_uint32 ogma_get_mac_irq_enable ( + ogma_handle_t ogma_handle + ); + + +ogma_uint32 ogma_get_mac_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ); + +#define ogma_get_mac_irq_status_non_clear(ogma_handle,mask_flag) \ +ogma_get_mac_irq_status(ogma_handle,mask_flag) + + +ogma_err_t ogma_clear_mac_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ); + +ogma_err_t ogma_enable_mac_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +ogma_err_t ogma_disable_mac_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ); + +#ifdef OGMA_CONFIG_REC_STAT +/** + * Get statistics information. + */ +ogma_err_t ogma_get_stat_info ( + ogma_handle_t ogma_handle, + ogma_stat_info_t *stat_info_p, + ogma_bool clear_flag + ); +#endif /* OGMA_CONFIG_REC_STAT */ + +ogma_err_t ogma_set_gmac_lpictrl_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ); + +ogma_err_t ogma_get_gmac_lpictrl_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p + ); + +ogma_err_t ogma_set_gmac_lpitimer_reg ( + ogma_handle_t ogma_handle, + ogma_uint16 ls_timer_ms, + ogma_uint16 tw_timer_ms + ); + +ogma_err_t ogma_get_gmac_lpitimer_reg ( + ogma_handle_t ogma_handle, + ogma_uint16 *ls_timer_ms_p, + ogma_uint16 *tw_timer_ms_p + ); + +void ogma_set_phy_mmd_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr, + ogma_uint16 value + ); + +ogma_uint16 ogma_get_phy_mmd_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ); + +ogma_err_t ogma_get_phy_link_status ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_phy_link_status_t *phy_link_status_p + ); + +ogma_gmac_int_sbd_regs_t ogma_get_gmac_int_sbd_irq_enable ( + ogma_handle_t ogma_handle + ); + +ogma_gmac_int_sbd_regs_t ogma_get_gmac_int_sbd_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ); + +#define ogma_get_gmac_int_sbd_irq_status_non_clear(ogma_handle,mask_flag) \ +ogma_get_gmac_int_sbd_irq_status(ogma_handle,mask_flag) + +ogma_err_t ogma_clear_gmac_int_sbd_irq_status ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ); + +ogma_err_t ogma_enable_gmac_int_sbd_irq ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ); + +ogma_err_t ogma_disable_gmac_int_sbd_irq ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ); + +ogma_err_t ogma_get_gmac_rgmii_status_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p + ); + +#ifdef OGMA_CONFIG_USE_READ_GMAC_STAT +ogma_err_t ogma_read_gmac_stat ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p, + ogma_bool reset_flag + ); +#endif /* OGMA_CONFIG_USE_READ_GMAC_STAT */ + +ogma_err_t ogma_reset_gmac_stat ( + ogma_handle_t ogma_handle + ); + +/************************** +*************************** +***************************/ + +#endif /* OGMA_API_H*/ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h new file mode 100644 index 000000000000..7c39b7c9cdd7 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h @@ -0,0 +1,45 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_BASIC_TYPE_H +#define OGMA_BASIC_TYPE_H +#include "netsec_for_uefi/pfdep.h" + +/** + * + */ +#define OGMA_TRUE PFDEP_TRUE +#define OGMA_FALSE PFDEP_FALSE + +/** + * OGMA SDK BASIC DATA TYPE + */ +typedef pfdep_int8 ogma_int8; +typedef pfdep_uint8 ogma_uint8; +typedef pfdep_int16 ogma_int16; +typedef pfdep_uint16 ogma_uint16; +typedef pfdep_int32 ogma_int32; +typedef pfdep_uint32 ogma_uint32; +typedef int ogma_int; +typedef unsigned int ogma_uint; +typedef pfdep_bool ogma_bool; +typedef pfdep_char ogma_char; + +#ifdef PFDEP_INT64_AVAILABLE +typedef signed long long ogma_int64; +typedef unsigned long long ogma_uint64; +#endif /* PFDEP_INT64_AVAILABLE*/ + +#endif /* OGMA_BASIC_TYPE_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_version.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_version.h new file mode 100644 index 000000000000..68882b6558af --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_version.h @@ -0,0 +1,24 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_VERSION_H +#define OGMA_VERSION_H + +#define OGMA_VER_NETSEC (0x00050050UL) + +#define OGMA_INVALID_VER 0x0 +#define OGMA_VER_MAJOR_NUM(x) ((x) & 0xffff0000UL) + +#endif /* OGMA_VERSION_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.c new file mode 100644 index 000000000000..7b399beaedb2 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.c @@ -0,0 +1,88 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "ogma_internal.h" +#include "ogma_basic_access.h" + +/********************************************************************** + * Function definitions + **********************************************************************/ + +void ogma_set_mac_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 addr, + ogma_uint32 value) +{ + + ogma_uint32 cmd; + + ogma_check_clk_supply( ctrl_p, OGMA_CLK_EN_REG_DOM_G); + + /* + * Argument check is omitted because this function is + * of private use only. + */ + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_DATA, + value); + + cmd = addr | OGMA_GMAC_CMD_ST_WRITE; + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_CMD, + cmd); + + /* + * Waits until BUSY bit is cleared. + */ + while ( ( ogma_read_reg( ctrl_p, + OGMA_REG_ADDR_MAC_CMD) + & OGMA_GMAC_CMD_ST_BUSY) + != 0) { + ; + } +} + +ogma_uint32 ogma_get_mac_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 addr) +{ + ogma_uint32 cmd; + + ogma_check_clk_supply( ctrl_p, OGMA_CLK_EN_REG_DOM_G); + + /* + * Argument check is omitted because this function is + * of private use only. + */ + + cmd = addr | OGMA_GMAC_CMD_ST_READ; + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_CMD, + cmd); + + /* + * Waits until BUSY bit is cleared. + */ + while ( ( ogma_read_reg( ctrl_p, + OGMA_REG_ADDR_MAC_CMD) + & OGMA_GMAC_CMD_ST_BUSY) + != 0) { + ; + } + return ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_DATA); +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.h new file mode 100644 index 000000000000..a81b9249f4a2 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_basic_access.h @@ -0,0 +1,52 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_BASIC_ACCESS_H +#define OGMA_BASIC_ACCESS_H + +#include "ogma_internal.h" + +static __inline void ogma_write_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 reg_addr, + ogma_uint32 value + ) +{ + + pfdep_iomem_write( (void *) ( ( pfdep_cpu_addr_t)ctrl_p->base_addr + + ( reg_addr << 2) ), + value); +} + +static __inline ogma_uint32 ogma_read_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 reg_addr + ) +{ + + return ( ogma_uint32)pfdep_iomem_read( (void *)( ( pfdep_cpu_addr_t)ctrl_p->base_addr + + ( reg_addr << 2) ) ); +} + +void ogma_set_mac_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 addr, + ogma_uint32 value); + +ogma_uint32 ogma_get_mac_reg ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 addr); + +#endif/* OGMA_BASIC_ACCESS_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access.c new file mode 100644 index 000000000000..a38aff3ce4a5 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access.c @@ -0,0 +1,1391 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "ogma_internal.h" +#include "ogma_basic_access.h" +#include "ogma_desc_ring_access_internal.h" + + +const ogma_uint32 ogma_desc_start_reg_addr_upper[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_DESC_START_UP, + OGMA_REG_ADDR_NRM_RX_DESC_START_UP, +}; + +const ogma_uint32 ogma_desc_start_reg_addr_lower[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_DESC_START_LW, + OGMA_REG_ADDR_NRM_RX_DESC_START_LW, +}; + +const ogma_uint32 desc_ring_irq_inten_reg_addr[OGMA_DESC_RING_ID_MAX + 1] = { + OGMA_REG_ADDR_NRM_TX_INTEN, + OGMA_REG_ADDR_NRM_RX_INTEN, +}; + +const ogma_uint32 desc_ring_irq_inten_set_reg_addr[OGMA_DESC_RING_ID_MAX + 1] = { + OGMA_REG_ADDR_NRM_TX_INTEN_SET, + OGMA_REG_ADDR_NRM_RX_INTEN_SET, +}; + +const ogma_uint32 desc_ring_irq_inten_clr_reg_addr[OGMA_DESC_RING_ID_MAX + 1] = { + OGMA_REG_ADDR_NRM_TX_INTEN_CLR, + OGMA_REG_ADDR_NRM_RX_INTEN_CLR, +}; + +static const ogma_uint32 int_tmr_reg_addr[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_TXINT_TMR, + OGMA_REG_ADDR_NRM_RX_RXINT_TMR, +}; + +static const ogma_uint32 rx_pkt_cnt_reg_addr[OGMA_DESC_RING_ID_MAX+1] = { + 0, + OGMA_REG_ADDR_NRM_RX_PKTCNT, +}; + +static const ogma_uint32 tx_pkt_cnt_reg_addr[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_PKTCNT, + 0, + +}; + +static const ogma_uint32 int_pkt_cnt_reg_addr[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_DONE_TXINT_PKTCNT, + OGMA_REG_ADDR_NRM_RX_RXINT_PKTCNT, +}; + +static const ogma_uint32 tx_done_pkt_cnt_reg_addr[OGMA_DESC_RING_ID_MAX+1] = { + OGMA_REG_ADDR_NRM_TX_DONE_PKTCNT, + 0, +}; + + +STATIC void ogma_set_tx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + const ogma_tx_pkt_ctrl_t *tx_pkt_ctrl_p, + ogma_bool first_flag, + ogma_bool last_flag, + ogma_bool trs_flag, + const ogma_frag_info_t *frag_info_p, + pfdep_pkt_handle_t pkt_handle); + +STATIC void ogma_set_rx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + const ogma_frag_info_t *frag_info_p, + pfdep_pkt_handle_t pkt_handle); + +STATIC void ogma_get_rx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + ogma_rx_pkt_info_t *rx_pkt_info_p, + ogma_frag_info_t *frag_info_p, + ogma_uint16 *len_p, + pfdep_pkt_handle_t *pkt_handle_p); + +STATIC void ogma_clean_tx_desc_ring_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +STATIC void ogma_clean_rx_desc_ring_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +STATIC void ogma_inc_desc_head_idx ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 increment); + +STATIC void ogma_inc_desc_tail_idx ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 increment); + +STATIC ogma_uint16 ogma_get_tx_avail_num_sub ( + ogma_ctrl_t *ctrl_p, + const ogma_desc_ring_t *desc_ring_p + ); + +STATIC ogma_uint16 ogma_get_tx_done_num_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +static __inline void ogma_desc_ring_cpy_to_mem( + void *dst_p, + void *src_p, + ogma_uint32 len) +{ + pfdep_memcpy(dst_p,src_p,len); +} + +static __inline void ogma_desc_ring_cpy_from_mem( + void *dst_p, + void *src_p, + ogma_uint32 len) +{ + pfdep_memcpy(dst_p,src_p,len); +} + +static __inline void ogma_desc_ring_memclr( + void *dst_p, + ogma_uint32 len) +{ + pfdep_memset(dst_p,0,len); +} + +/********************************************************************** + * Function definitions + **********************************************************************/ + +ogma_err_t ogma_alloc_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_id_t ring_id + ) +{ + + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_desc_ring_t *desc_ring_p = &ctrl_p->desc_ring[ring_id]; + ogma_desc_ring_param_t *desc_ring_param_p = &ctrl_p->desc_ring[ring_id].param; + pfdep_err_t pfdep_err; + + if ( ( ctrl_p->param.desc_ring_param[ring_id].valid_flag) && + ( ( ctrl_p->param.desc_ring_param[ring_id].entry_num < + OGMA_DESC_ENTRY_NUM_MIN) || + ( ctrl_p->param.desc_ring_param[ring_id].entry_num > + OGMA_DESC_ENTRY_NUM_MAX) ) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Please set entry_num between %d and %d.\n", + OGMA_DESC_ENTRY_NUM_MIN, OGMA_DESC_ENTRY_NUM_MAX); + return OGMA_ERR_PARAM; + } + + desc_ring_p->ring_id = ring_id; + + pfdep_memcpy( desc_ring_param_p, + &ctrl_p->param.desc_ring_param[ring_id], + sizeof( ogma_desc_ring_param_t) ); + + if ( !desc_ring_param_p->valid_flag) { + + desc_ring_p->desc_ring_phys_addr = ctrl_p->dummy_desc_entry_phys_addr; + + ogma_write_reg( ctrl_p, + ogma_desc_start_reg_addr_upper[ring_id], + (ogma_uint32)(desc_ring_p->desc_ring_phys_addr >> 32)); + ogma_write_reg( ctrl_p, + ogma_desc_start_reg_addr_lower[ring_id], + (ogma_uint32)desc_ring_p->desc_ring_phys_addr); + + return OGMA_ERR_OK; + } + + switch ( ring_id) { + case OGMA_DESC_RING_ID_NRM_TX: + desc_ring_p->tx_desc_ring_flag = OGMA_TRUE; + desc_ring_p->desc_entry_len = sizeof( ogma_tx_desc_entry_t); + break; + + case OGMA_DESC_RING_ID_NRM_RX: + desc_ring_p->rx_desc_ring_flag = OGMA_TRUE; + desc_ring_p->desc_entry_len = sizeof( ogma_rx_desc_entry_t); + break; + + default: + pfdep_assert(0); + } + + if ( ( pfdep_err = pfdep_init_hard_lock ( &desc_ring_p->inten_reg_hard_lock) ) + != PFDEP_ERR_OK) { + pfdep_memset( desc_ring_param_p, + 0, + sizeof( ogma_desc_ring_param_t) ); + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Failed to inten_reg_hard_lock's initialization.\n"); + return OGMA_ERR_ALLOC; + } + + if ( ( pfdep_err = pfdep_init_soft_lock ( &desc_ring_p->soft_lock) ) + != PFDEP_ERR_OK) { + pfdep_uninit_hard_lock ( &desc_ring_p->inten_reg_hard_lock); + pfdep_memset( desc_ring_param_p, + 0, + sizeof( ogma_desc_ring_param_t) ); + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Failed to soft_lock's initialization.\n"); + return OGMA_ERR_ALLOC; + } + + if ( ( pfdep_err = pfdep_dma_malloc ( + ( pfdep_dev_handle_t) ctrl_p->dev_handle, + ( pfdep_uint32) desc_ring_p->desc_entry_len * desc_ring_param_p->entry_num, + ( void **) &desc_ring_p->desc_ring_cpu_addr, + ( pfdep_phys_addr_t *) &desc_ring_p->desc_ring_phys_addr) ) + != PFDEP_ERR_OK) { + ogma_err = OGMA_ERR_ALLOC; + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Failed to desc_ring entry memory allocation.\n"); + goto err; + } + + ogma_desc_ring_memclr( + desc_ring_p->desc_ring_cpu_addr, + ( ogma_uint32)desc_ring_p->desc_entry_len * desc_ring_param_p->entry_num); + + ogma_write_reg( ctrl_p, + ogma_desc_start_reg_addr_upper[ring_id], + (ogma_uint32)(desc_ring_p->desc_ring_phys_addr >> 32)); + ogma_write_reg( ctrl_p, + ogma_desc_start_reg_addr_lower[ring_id], + (ogma_uint32)desc_ring_p->desc_ring_phys_addr); + + if ( ( desc_ring_p->frag_info_p = + pfdep_malloc( sizeof( ogma_frag_info_t) * desc_ring_param_p->entry_num) ) + == NULL) { + ogma_err = OGMA_ERR_ALLOC; + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Failed to fragment infomation memory allocation.\n"); + goto err; + } + + pfdep_memset( + desc_ring_p->frag_info_p, + 0, + sizeof( ogma_frag_info_t) * desc_ring_param_p->entry_num); + + if ( ( desc_ring_p->priv_data_p = + pfdep_malloc( sizeof( ogma_desc_entry_priv_t) * desc_ring_param_p->entry_num) ) + == NULL) { + ogma_err = OGMA_ERR_ALLOC; + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_alloc_desc_ring.\n" + "Failed to private data memory allocation.\n"); + goto err; + } + + pfdep_memset( + desc_ring_p->priv_data_p, + 0, + sizeof( ogma_desc_entry_priv_t) * desc_ring_param_p->entry_num); + + return OGMA_ERR_OK; + +err: + ogma_free_desc_ring( ctrl_p, desc_ring_p); + return ogma_err; +} + +void ogma_free_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + + if ( !desc_ring_p->param.valid_flag) { + return ; + } + if ( ogma_is_pkt_desc_ring ( desc_ring_p) ) { + if ( ( desc_ring_p->desc_ring_cpu_addr != NULL) && + ( desc_ring_p->frag_info_p != NULL) && + ( desc_ring_p->priv_data_p != NULL) ) { + ogma_uninit_pkt_desc_ring( ctrl_p, desc_ring_p); + } + } + if ( desc_ring_p->desc_ring_cpu_addr != NULL) { + pfdep_dma_free( ctrl_p->dev_handle, + ( ogma_uint32)desc_ring_p->desc_entry_len * + desc_ring_p->param.entry_num, + desc_ring_p->desc_ring_cpu_addr, + desc_ring_p->desc_ring_phys_addr); + } + + if ( desc_ring_p->frag_info_p != NULL) { + pfdep_free(desc_ring_p->frag_info_p); + } + + if ( desc_ring_p->priv_data_p != NULL) { + pfdep_free( desc_ring_p->priv_data_p); + } + + pfdep_uninit_hard_lock ( &desc_ring_p->inten_reg_hard_lock); + + pfdep_uninit_soft_lock ( &desc_ring_p->soft_lock); + + pfdep_memset( desc_ring_p, 0, sizeof( ogma_desc_ring_t) ); +} + +ogma_err_t ogma_setup_rx_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + ogma_uint16 idx; + ogma_frag_info_t frag_info= {0,0,0}; + + pfdep_err_t pfdep_err; + pfdep_pkt_handle_t tmp_pkt_handle; + + frag_info.len = ctrl_p->rx_pkt_buf_len; + + for ( idx = 0; idx < desc_ring_p->param.entry_num; idx++) { + if ( ( pfdep_err = pfdep_alloc_pkt_buf ( + ( pfdep_dev_handle_t)ctrl_p->dev_handle, + ( ogma_uint16)frag_info.len, + ( void **)&frag_info.addr, + ( pfdep_phys_addr_t *)&frag_info.phys_addr, + ( pfdep_pkt_handle_t *)&tmp_pkt_handle) ) + != PFDEP_ERR_OK) { + ogma_uninit_pkt_desc_ring( ctrl_p, desc_ring_p); + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_setup_rx_desc_ring.\n" + "Failed to rx packet memory allocation.\n"); + return OGMA_ERR_ALLOC; + } + ogma_set_rx_desc_entry( ctrl_p, + desc_ring_p, + idx, + &frag_info, + tmp_pkt_handle); + } + return OGMA_ERR_OK; +} + +void ogma_uninit_pkt_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + ogma_uint16 idx; + ogma_uint32 tmp; + ogma_bool last_flag; + + for ( idx = 0; idx < desc_ring_p->param.entry_num; idx++) { + if ( desc_ring_p->frag_info_p[idx].addr == NULL ) { + continue; + } + + tmp = ogma_get_desc_ring_attr(desc_ring_p, idx); + + last_flag = ( ( ( tmp >> 8) & 0x1) != 0); + + pfdep_free_pkt_buf ( + ctrl_p->dev_handle, + desc_ring_p->frag_info_p[idx].len, + desc_ring_p->frag_info_p[idx].addr, + desc_ring_p->frag_info_p[idx].phys_addr, + last_flag, + desc_ring_p->priv_data_p[idx].pkt_handle); + } + + /* clear frag_info_p */ + pfdep_memset( desc_ring_p->frag_info_p, + 0, + sizeof( ogma_frag_info_t) * desc_ring_p->param.entry_num); + + /* clear pkt_handle_p */ + pfdep_memset( desc_ring_p->priv_data_p, + 0, + sizeof( ogma_desc_entry_priv_t) * desc_ring_p->param.entry_num); + + /* clear desc ring entry*/ + ogma_desc_ring_memclr ( desc_ring_p->desc_ring_cpu_addr, + ( ogma_uint32)desc_ring_p->desc_entry_len * + desc_ring_p->param.entry_num); +} + +STATIC void ogma_set_tx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + const ogma_tx_pkt_ctrl_t *tx_pkt_ctrl_p, + ogma_bool first_flag, + ogma_bool last_flag, + ogma_bool trs_flag, + const ogma_frag_info_t *frag_info_p, + pfdep_pkt_handle_t pkt_handle + ) +{ + ogma_tx_desc_entry_t tx_desc_entry; + ogma_uint32 attr, i, *debug_desc_entry_p; + + ogma_check_desc_own_sanity(ctrl_p, desc_ring_p, idx, 0); + + pfdep_memset( &tx_desc_entry, 0, sizeof( ogma_tx_desc_entry_t) ); + + attr = ( 1UL << OGMA_TX_PKT_DESC_RING_OWN_FIELD) | + ( desc_ring_p->ring_id << OGMA_TX_PKT_DESC_RING_DRID_FIELD) | + ( tx_pkt_ctrl_p->pass_through_flag << + OGMA_TX_PKT_DESC_RING_PT_FIELD) | + ( tx_pkt_ctrl_p->target_desc_ring_id << + OGMA_TX_PKT_DESC_RING_TDRID_FIELD) | + ( first_flag << OGMA_TX_PKT_DESC_RING_FS_FIELD) | + ( last_flag << OGMA_TX_PKT_DESC_RING_LS_FIELD) | + ( tx_pkt_ctrl_p->cksum_offload_flag << + OGMA_TX_PKT_DESC_RING_CO_FIELD) | + ( tx_pkt_ctrl_p->tcp_seg_offload_flag << + OGMA_TX_PKT_DESC_RING_SO_FIELD) | + ( trs_flag << OGMA_TX_PKT_DESC_RING_TRS_FIELD); + + if ( idx == ( desc_ring_p->param.entry_num - 1) ) { + attr |= ( 0x1U << OGMA_TX_PKT_DESC_RING_LD_FIELD); /* LD = 1 */ + } + + tx_desc_entry.attr = attr; + + tx_desc_entry.data_buf_addr_upper = (ogma_uint32)(frag_info_p->phys_addr >> 32); + + tx_desc_entry.data_buf_addr_lower = (ogma_uint32)frag_info_p->phys_addr; + + tx_desc_entry.buf_len_info = + ( tx_pkt_ctrl_p->tcp_seg_len << 16) | frag_info_p->len; + + ogma_desc_ring_cpy_to_mem( ( (void *) ( ( pfdep_cpu_addr_t)desc_ring_p->desc_ring_cpu_addr + + desc_ring_p->desc_entry_len * idx) ), + ( void *)&tx_desc_entry, + desc_ring_p->desc_entry_len); + + debug_desc_entry_p = ( ogma_uint32 *)&tx_desc_entry; + + for ( i = 0; i < ( sizeof( ogma_tx_desc_entry_t) >> 2); i++) { + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "%08x\n", debug_desc_entry_p[i]); + } + + desc_ring_p->frag_info_p[idx].phys_addr = frag_info_p->phys_addr; + desc_ring_p->frag_info_p[idx].addr = frag_info_p->addr; + desc_ring_p->frag_info_p[idx].len = frag_info_p->len; + desc_ring_p->priv_data_p[idx].pkt_handle = pkt_handle; + +} + +STATIC void ogma_set_rx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + const ogma_frag_info_t *frag_info_p, + pfdep_pkt_handle_t pkt_handle + ) +{ + ogma_rx_desc_entry_t rx_desc_entry; + + ogma_check_desc_own_sanity(ctrl_p, desc_ring_p, idx, 0); + + pfdep_memset( &rx_desc_entry, 0, sizeof ( ogma_rx_desc_entry_t) ); + + rx_desc_entry.attr = ( 1UL << OGMA_RX_PKT_DESC_RING_OWN_FIELD) | + ( 1UL << OGMA_RX_PKT_DESC_RING_FS_FIELD) | + ( 1UL << OGMA_RX_PKT_DESC_RING_LS_FIELD) ; /* OWN = FS = LS = 1 */ + + rx_desc_entry.data_buf_addr_upper = (ogma_uint32)(frag_info_p->phys_addr >> 32); + + rx_desc_entry.data_buf_addr_lower = (ogma_uint32)frag_info_p->phys_addr; + + rx_desc_entry.buf_len_info = frag_info_p->len; + + if ( idx == ( desc_ring_p->param.entry_num - 1) ) { + rx_desc_entry.attr |= ( 0x1U << OGMA_RX_PKT_DESC_RING_LD_FIELD); /* LD = 1 */ + } + + ogma_desc_ring_cpy_to_mem( ( ( void *) ( ( pfdep_cpu_addr_t)desc_ring_p->desc_ring_cpu_addr + + desc_ring_p->desc_entry_len * idx + 4) ), + ( void *) ( ( pfdep_cpu_addr_t)&rx_desc_entry + 4), + ( ogma_uint32)( desc_ring_p->desc_entry_len - 4U) ); + + pfdep_write_mem_barrier(); + + ogma_desc_ring_cpy_to_mem( ( ( void *) ( ( pfdep_cpu_addr_t)desc_ring_p->desc_ring_cpu_addr + + desc_ring_p->desc_entry_len * idx) ), + ( void *)&rx_desc_entry, + 4); + + desc_ring_p->frag_info_p[idx].phys_addr = frag_info_p->phys_addr; + desc_ring_p->frag_info_p[idx].addr = frag_info_p->addr; + desc_ring_p->frag_info_p[idx].len = frag_info_p->len; + desc_ring_p->priv_data_p[idx].pkt_handle = pkt_handle; +} + +STATIC void ogma_get_rx_desc_entry ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + ogma_rx_pkt_info_t *rx_pkt_info_p, + ogma_frag_info_t *frag_info_p, + ogma_uint16 *len_p, + pfdep_pkt_handle_t *pkt_handle_p) +{ + ogma_uint32 *debug_desc_entry_p; + ogma_rx_desc_entry_t rx_desc_entry; + + ogma_check_desc_own_sanity( ctrl_p, desc_ring_p, idx, 0); + + pfdep_memset( &rx_desc_entry, 0, sizeof( ogma_rx_desc_entry_t) ); + pfdep_memset( rx_pkt_info_p, 0, sizeof( ogma_rx_pkt_info_t) ); + + ogma_desc_ring_cpy_from_mem( &rx_desc_entry, + (void *) ( ( pfdep_cpu_addr_t)desc_ring_p->desc_ring_cpu_addr + + desc_ring_p->desc_entry_len * idx), + desc_ring_p->desc_entry_len); + + debug_desc_entry_p = (ogma_uint32 *)&rx_desc_entry; + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "%08x\n", *debug_desc_entry_p); + + *len_p = rx_desc_entry.buf_len_info >> 16; + + rx_pkt_info_p->fragmented_flag = + ( rx_desc_entry.attr >> OGMA_RX_PKT_DESC_RING_FR_FIELD) & 0x1; /* FR*/ + + rx_pkt_info_p->err_flag = + ( rx_desc_entry.attr >> OGMA_RX_PKT_DESC_RING_ER_FIELD) & 0x1; /* ER */ + + rx_pkt_info_p->rx_cksum_result = + ( rx_desc_entry.attr >> OGMA_RX_PKT_DESC_RING_CO_FIELD) & 0x3; /* CO */ + + rx_pkt_info_p->err_code = + ( rx_desc_entry.attr >> OGMA_RX_PKT_DESC_RING_ERROR_CODE_FIELD) & + OGMA_RX_PKT_DESC_RING_ERROR_CODE_FIELD_MASK; /* Error Code */ + + pfdep_memcpy( frag_info_p, + &desc_ring_p->frag_info_p[idx], + sizeof(ogma_frag_info_t) ); + + *pkt_handle_p = desc_ring_p->priv_data_p[idx].pkt_handle; +} + +#ifdef OGMA_CONFIG_REC_STAT +STATIC __inline ogma_uint16 ogma_calc_busy_entry_num ( + ogma_uint16 head_idx, + ogma_uint16 tail_idx, + ogma_uint16 entry_num, + ogma_bool full_flag + ) +{ + + ogma_int16 busy_entry_num; + + if (full_flag) { + busy_entry_num = entry_num; + } else if (head_idx >= tail_idx) { + busy_entry_num = head_idx - tail_idx; + } else { + busy_entry_num = entry_num + head_idx - tail_idx; + } + + return busy_entry_num; + +} +#endif /* OGMA_CONFIG_REC_STAT */ + +STATIC void ogma_clean_tx_desc_ring_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + + ogma_uint32 tmp; + + ogma_get_tx_done_num_sub( ctrl_p, desc_ring_p); + + while( ( (desc_ring_p->tail_idx != desc_ring_p->head_idx) || + desc_ring_p->full_flag) && ( desc_ring_p->tx_done_num != 0) ) { + + tmp = ogma_get_desc_ring_attr(desc_ring_p, + desc_ring_p->tail_idx); + + pfdep_free_pkt_buf ( + ctrl_p->dev_handle, + desc_ring_p->frag_info_p[desc_ring_p->tail_idx].len, + desc_ring_p->frag_info_p[desc_ring_p->tail_idx].addr, + desc_ring_p->frag_info_p[desc_ring_p->tail_idx].phys_addr, + ( ( ( tmp >> OGMA_TX_PKT_DESC_RING_LS_FIELD) & 0x1) != 0), + desc_ring_p->priv_data_p[desc_ring_p->tail_idx].pkt_handle); + + pfdep_memset( &desc_ring_p->frag_info_p[desc_ring_p->tail_idx], + 0, + sizeof( ogma_frag_info_t) ); + + ogma_inc_desc_tail_idx( ctrl_p, desc_ring_p, 1); + + if ( ( tmp & ( 1UL << OGMA_TX_PKT_DESC_RING_LS_FIELD) ) != 0) { + + pfdep_assert( desc_ring_p->tx_done_num != 0); + + desc_ring_p->tx_done_num--; + + } + } + +} + +STATIC void ogma_clean_rx_desc_ring_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + + while( desc_ring_p->full_flag || + ( desc_ring_p->tail_idx != desc_ring_p->head_idx) ) { + + ogma_set_rx_desc_entry( + ctrl_p, + desc_ring_p, + desc_ring_p->tail_idx, + &desc_ring_p->frag_info_p[desc_ring_p->tail_idx], + desc_ring_p->priv_data_p[desc_ring_p->tail_idx].pkt_handle); + + --desc_ring_p->rx_num; + ogma_inc_desc_tail_idx( ctrl_p, desc_ring_p, 1); + } + + pfdep_assert( desc_ring_p->rx_num == 0);/* error check*/ + +} + +STATIC void ogma_inc_desc_head_idx ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 increment) +{ + ogma_uint32 sum; + + if ( ( desc_ring_p->tail_idx > desc_ring_p->head_idx) || + desc_ring_p->full_flag) { + pfdep_assert( increment <= + ( desc_ring_p->tail_idx - + desc_ring_p->head_idx)); + } else { + pfdep_assert( increment <= + ( desc_ring_p->param.entry_num + + desc_ring_p->tail_idx - + desc_ring_p->head_idx) ); + } + + sum = (ogma_uint32) desc_ring_p->head_idx + increment; + + if ( sum >= desc_ring_p->param.entry_num) { + sum -= desc_ring_p->param.entry_num; + } + + desc_ring_p->head_idx = ( ogma_uint16)sum; + + if ( desc_ring_p->head_idx == desc_ring_p->tail_idx) { + desc_ring_p->full_flag = OGMA_TRUE; + } + +} + +STATIC void ogma_inc_desc_tail_idx ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p, + ogma_uint16 increment) +{ + ogma_uint32 sum; + + if ( ( desc_ring_p->head_idx >= desc_ring_p->tail_idx) && + ( !desc_ring_p->full_flag) ) { + pfdep_assert( increment <= + ( desc_ring_p->head_idx - + desc_ring_p->tail_idx) ); + } else { + pfdep_assert( increment <= + ( desc_ring_p->param.entry_num + + desc_ring_p->head_idx - + desc_ring_p->tail_idx) ); + } + + sum = (ogma_uint32) desc_ring_p->tail_idx + increment; + + if ( sum >= desc_ring_p->param.entry_num) { + sum -= desc_ring_p->param.entry_num; + } + + desc_ring_p->tail_idx = ( ogma_uint16)sum; + + desc_ring_p->full_flag = OGMA_FALSE; +} + + +STATIC ogma_uint16 ogma_get_tx_avail_num_sub ( + ogma_ctrl_t *ctrl_p, + const ogma_desc_ring_t *desc_ring_p + ) +{ + ogma_uint16 tx_avail_num; + + if ( desc_ring_p->full_flag) { + + tx_avail_num = 0; + + } else if ( desc_ring_p->tail_idx > desc_ring_p->head_idx) { + + tx_avail_num = desc_ring_p->tail_idx - desc_ring_p->head_idx; + + } else { + + tx_avail_num = + desc_ring_p->param.entry_num + + desc_ring_p->tail_idx - + desc_ring_p->head_idx; + } + + return tx_avail_num; +} + +STATIC ogma_uint16 ogma_get_tx_done_num_sub ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ) +{ + ogma_uint32 value; + + value = ogma_read_reg ( ctrl_p, + tx_done_pkt_cnt_reg_addr[desc_ring_p->ring_id] ); + + desc_ring_p->tx_done_num += value; + + return desc_ring_p->tx_done_num; +} + + +ogma_err_t ogma_start_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + + pfdep_soft_lock_ctx_t soft_lock_ctx; + pfdep_err_t pfdep_err; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + if ( desc_ring_p->running_flag) { + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return OGMA_ERR_BUSY; + } + + if ( desc_ring_p->rx_desc_ring_flag) { + + ogma_write_reg ( ctrl_p, + desc_ring_irq_inten_set_reg_addr[ring_id], + OGMA_CH_IRQ_REG_RCV); + + ogma_write_reg ( ctrl_p, + int_pkt_cnt_reg_addr[ring_id], + 1); + } + + if ( desc_ring_p->tx_desc_ring_flag) { + + + value = OGMA_CH_IRQ_REG_EMPTY; + + + ogma_write_reg ( ctrl_p, + desc_ring_irq_inten_set_reg_addr[ring_id], + value); + + ogma_write_reg ( ctrl_p, + int_pkt_cnt_reg_addr[ring_id], + 1); + + } + + desc_ring_p->running_flag = OGMA_TRUE; + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + + return ogma_err; +} + + +ogma_err_t ogma_stop_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + pfdep_err_t pfdep_err; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( !ogma_is_pkt_desc_ring( &ctrl_p->desc_ring[ring_id] ) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + if ( !desc_ring_p->running_flag) { + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return OGMA_ERR_INVALID; + } + + value = ( OGMA_CH_IRQ_REG_RCV | + OGMA_CH_IRQ_REG_EMPTY | + OGMA_CH_IRQ_REG_SND); + + ogma_write_reg ( ctrl_p, + desc_ring_irq_inten_clr_reg_addr[ring_id], + value); + + desc_ring_p->running_flag = OGMA_FALSE; + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + + return OGMA_ERR_OK; +} + +ogma_uint16 ogma_get_rx_num ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + + ogma_uint32 result; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p = NULL; + ogma_desc_ring_id_t tmp_ring_id; + + pfdep_soft_lock_ctx_t soft_lock_ctx; + pfdep_err_t pfdep_err; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_rx_num.\n" + "Please set valid argument.\n"); + return 0; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_rx_num.\n" + "Please set valid argument.\n"); + return 0; + } + + tmp_ring_id = ring_id; + + if (! ctrl_p->desc_ring[tmp_ring_id].rx_desc_ring_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_rx_num.\n" + "Please select rx packet desc ring or bulk desc ring.\n"); + return 0; + } + + desc_ring_p = &ctrl_p->desc_ring[tmp_ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_rx_num.\n" + "Failed to get soft lock.\n"); + return 0; + } + + result = ogma_read_reg( ctrl_p, rx_pkt_cnt_reg_addr[tmp_ring_id]); + + desc_ring_p->rx_num += result; + + if ( desc_ring_p->rx_desc_ring_flag && ( result != 0) ) { + ogma_inc_desc_head_idx( ctrl_p, desc_ring_p, ( ogma_uint16)result); + } + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + + return desc_ring_p->rx_num; +} + + +ogma_uint16 ogma_get_tx_avail_num ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + + ogma_uint16 result; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_id_t tmp_ring_id; + ogma_desc_ring_t *desc_ring_p = NULL; + + pfdep_soft_lock_ctx_t soft_lock_ctx; + pfdep_err_t pfdep_err; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) || + ( !ctrl_p->desc_ring[ring_id].param.valid_flag) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_tx_avail_num.\n" + "Please select valid argument.\n"); + return 0; + } + + tmp_ring_id = ring_id; + + if (! ctrl_p->desc_ring[tmp_ring_id].tx_desc_ring_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_tx_avail_num.\n" + "Please select tx packet desc ring or bulk desc ring.\n"); + return 0; + } + + desc_ring_p = &ctrl_p->desc_ring[tmp_ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_tx_avail_num.\n" + "Failed to get soft lock.\n"); + return 0; + } + + if ( !desc_ring_p->running_flag) { + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_tx_avail_num.\n" + "Please select running desc ring.\n"); + return 0; + } + + result = ogma_get_tx_avail_num_sub( ctrl_p, desc_ring_p); + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return result; +} + +ogma_err_t ogma_clean_tx_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + + pfdep_err_t pfdep_err; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ctrl_p->desc_ring[ring_id].tx_desc_ring_flag) { + return OGMA_ERR_PARAM; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + ogma_clean_tx_desc_ring_sub(ctrl_p, desc_ring_p); + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return OGMA_ERR_OK; + + +} + +ogma_err_t ogma_clean_rx_desc_ring ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + + pfdep_err_t pfdep_err; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ctrl_p->desc_ring[ring_id].rx_desc_ring_flag) { + return OGMA_ERR_PARAM; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + ogma_clean_rx_desc_ring_sub(ctrl_p, desc_ring_p); + + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return OGMA_ERR_OK; + +} + +ogma_err_t ogma_set_tx_pkt_data ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + const ogma_tx_pkt_ctrl_t *tx_pkt_ctrl_p, + ogma_uint8 scat_num, + const ogma_frag_info_t *scat_info_p, + pfdep_pkt_handle_t pkt_handle + ) +{ + ogma_uint i; + ogma_uint16 tx_avail_num; + ogma_uint32 sum_len = 0; + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + + pfdep_err_t pfdep_err; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG, "%s call.\n", __func__); + + if ( ( ctrl_p == NULL) || + ( tx_pkt_ctrl_p == NULL) || + ( scat_info_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ctrl_p->desc_ring[ring_id].tx_desc_ring_flag) { + return OGMA_ERR_PARAM; + } + + { + if ( !ctrl_p->param.use_gmac_flag || + ( tx_pkt_ctrl_p->target_desc_ring_id != OGMA_DESC_RING_ID_GMAC) ) { + return OGMA_ERR_DATA; + } + } + + + if ( tx_pkt_ctrl_p->tcp_seg_offload_flag && + ( !tx_pkt_ctrl_p->cksum_offload_flag) ) { + return OGMA_ERR_DATA; + } + + if ( tx_pkt_ctrl_p->tcp_seg_offload_flag) { + + if ( tx_pkt_ctrl_p->tcp_seg_len == 0) { + return OGMA_ERR_DATA; + } + + if ( ctrl_p->param.use_jumbo_pkt_flag) { + if (tx_pkt_ctrl_p->tcp_seg_len > OGMA_TCP_JUMBO_SEG_LEN_MAX) { + return OGMA_ERR_DATA; + } + } else { + if (tx_pkt_ctrl_p->tcp_seg_len > OGMA_TCP_SEG_LEN_MAX) { + return OGMA_ERR_DATA; + } + } + + } else { + if ( tx_pkt_ctrl_p->tcp_seg_len != 0) { + return OGMA_ERR_DATA; + } + } + + + if ( scat_num == 0) { + return OGMA_ERR_RANGE; + } + + for ( i = 0; i < scat_num; i++) { + if ( ( scat_info_p[i].len == 0) || + ( scat_info_p[i].len > 0xffffU) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_set_tx_pkt_data.\n" + "Pleas check scat_info_p[%u].len.\n", + i); + return OGMA_ERR_DATA; + } + sum_len += scat_info_p[i].len; + } + + if ( !tx_pkt_ctrl_p->tcp_seg_offload_flag) { + + if ( ctrl_p->param.use_jumbo_pkt_flag) { + if ( sum_len > OGMA_MAX_TX_JUMBO_PKT_LEN) { + return OGMA_ERR_DATA; + } + } else { + if ( sum_len > OGMA_MAX_TX_PKT_LEN) { + return OGMA_ERR_DATA; + } + } + + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + if ( !desc_ring_p->running_flag) { + ogma_err = OGMA_ERR_NOTAVAIL; + goto end; + } + + tx_avail_num = ogma_get_tx_avail_num_sub( ctrl_p, desc_ring_p); + + if ( scat_num > tx_avail_num ) { + ogma_err = OGMA_ERR_BUSY; + goto end; + } + + for ( i = 0; i < scat_num; i++) { + + + ogma_set_tx_desc_entry( + ctrl_p, + desc_ring_p, + desc_ring_p->head_idx, + tx_pkt_ctrl_p, + ( i == 0), + ( i == ( scat_num - 1U) ), + OGMA_TRUE, + &scat_info_p[i], + pkt_handle); + ogma_inc_desc_head_idx( ctrl_p, desc_ring_p, 1); + } + + pfdep_write_mem_barrier(); + + ogma_write_reg( ctrl_p, + tx_pkt_cnt_reg_addr[ring_id], + (ogma_uint32)1); + +end: + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + + return ogma_err; +} + +ogma_err_t ogma_get_rx_pkt_data ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_rx_pkt_info_t *rx_pkt_info_p, + ogma_frag_info_t *frag_info_p, + ogma_uint16 *len_p, + pfdep_pkt_handle_t *pkt_handle_p + ) +{ + + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + ogma_frag_info_t tmp_frag_info; + + pfdep_err_t pfdep_err; + pfdep_pkt_handle_t tmp_pkt_handle; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG, "%s call.\n", __func__); + + if ( ( ctrl_p == NULL) || + ( rx_pkt_info_p == NULL) || + ( frag_info_p == NULL) || + ( len_p == NULL) || + ( pkt_handle_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ctrl_p->desc_ring[ring_id].rx_desc_ring_flag) { + return OGMA_ERR_PARAM; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + if ( ( pfdep_err = pfdep_acquire_soft_lock( + &desc_ring_p->soft_lock, + &soft_lock_ctx ) ) != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + if ( desc_ring_p->rx_num == 0 ) { + ogma_err = OGMA_ERR_INVALID; + goto end; + } + + tmp_frag_info.len = ctrl_p->rx_pkt_buf_len; + + pfdep_read_mem_barrier(); + + if ( ( pfdep_err = pfdep_alloc_pkt_buf ( + ctrl_p->dev_handle, + tmp_frag_info.len, + &tmp_frag_info.addr, + &tmp_frag_info.phys_addr, + &tmp_pkt_handle) ) != PFDEP_ERR_OK) { + ogma_set_rx_desc_entry( ctrl_p, + desc_ring_p, + desc_ring_p->tail_idx, + &desc_ring_p->frag_info_p[desc_ring_p->tail_idx], + desc_ring_p->priv_data_p[desc_ring_p->tail_idx].pkt_handle); + ogma_err = OGMA_ERR_ALLOC; + + } else { + + ogma_get_rx_desc_entry( ctrl_p, + desc_ring_p, + desc_ring_p->tail_idx, + rx_pkt_info_p, + frag_info_p, + len_p, + pkt_handle_p); + + + ogma_set_rx_desc_entry( ctrl_p, + desc_ring_p, + desc_ring_p->tail_idx, + &tmp_frag_info, + tmp_pkt_handle); + } + + ogma_inc_desc_tail_idx( ctrl_p, desc_ring_p, 1); + + --desc_ring_p->rx_num; + +end: + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + + return ogma_err; +} + +ogma_err_t ogma_set_irq_coalesce_param ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint16 int_pktcnt, + ogma_bool int_tmr_unit_ms_flag, + ogma_uint16 int_tmr_cnt + ) +{ + + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( ring_id > OGMA_DESC_RING_ID_MAX) ) { + return OGMA_ERR_PARAM; + } + + if ( int_pktcnt > OGMA_INT_PKTCNT_MAX) { + return OGMA_ERR_RANGE; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ogma_is_pkt_desc_ring( &ctrl_p->desc_ring[ring_id]) ) { + return OGMA_ERR_PARAM; + } + + ogma_write_reg( ctrl_p, + int_pkt_cnt_reg_addr[ring_id], + int_pktcnt); + + ogma_write_reg( ctrl_p, + int_tmr_reg_addr[ring_id], + ( ( ( ( ogma_uint32)int_tmr_unit_ms_flag) << 31) | + int_tmr_cnt) ); + + return ogma_err; + +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access_internal.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access_internal.h new file mode 100644 index 000000000000..34490e2d1c78 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_desc_ring_access_internal.h @@ -0,0 +1,111 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_DESC_RING_ACCESS_INTERNAL_H +#define OGMA_DESC_RING_ACCESS_INTERNAL_H + +#include "netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h" +#include "ogma_internal.h" + +#define OGMA_TX_PKT_DESC_RING_OWN_FIELD (31) +#define OGMA_TX_PKT_DESC_RING_LD_FIELD (30) +#define OGMA_TX_PKT_DESC_RING_DRID_FIELD (24) +#define OGMA_TX_PKT_DESC_RING_PT_FIELD (21) +#define OGMA_TX_PKT_DESC_RING_TDRID_FIELD (16) +#define OGMA_TX_PKT_DESC_RING_FS_FIELD (9) +#define OGMA_TX_PKT_DESC_RING_LS_FIELD (8) +#define OGMA_TX_PKT_DESC_RING_CO_FIELD (7) +#define OGMA_TX_PKT_DESC_RING_SO_FIELD (6) +#define OGMA_TX_PKT_DESC_RING_USRKEY_FIELD (5) +#define OGMA_TX_PKT_DESC_RING_TRS_FIELD (4) + +#define OGMA_RX_PKT_DESC_RING_OWN_FIELD (31) +#define OGMA_RX_PKT_DESC_RING_LD_FIELD (30) +#define OGMA_RX_PKT_DESC_RING_SDRID_FIELD (24) +#define OGMA_RX_PKT_DESC_RING_FR_FIELD (23) +#define OGMA_RX_PKT_DESC_RING_ER_FIELD (21) +#define OGMA_RX_PKT_DESC_RING_ERROR_CODE_FIELD (16) +#define OGMA_RX_PKT_DESC_RING_TDRID_FIELD (12) +#define OGMA_RX_PKT_DESC_RING_FS_FIELD (9) +#define OGMA_RX_PKT_DESC_RING_LS_FIELD (8) +#define OGMA_RX_PKT_DESC_RING_CO_FIELD (6) + +#define OGMA_RX_PKT_DESC_RING_ERROR_CODE_FIELD_MASK (0x3) + +#define OGMA_MAX_TX_PKT_LEN 1518U +#define OGMA_MAX_TX_JUMBO_PKT_LEN 9018U + +typedef struct ogma_tx_desc_entry_s ogma_tx_desc_entry_t; +typedef struct ogma_rx_desc_entry_s ogma_rx_desc_entry_t; + +struct ogma_tx_desc_entry_s{ + + ogma_uint32 attr; + + ogma_uint32 data_buf_addr_upper; + + ogma_uint32 data_buf_addr_lower; + + ogma_uint32 buf_len_info; +}; + +struct ogma_rx_desc_entry_s{ + + ogma_uint32 attr; + + ogma_uint32 data_buf_addr_upper; + + ogma_uint32 data_buf_addr_lower; + + ogma_uint32 buf_len_info; +}; + +static __inline ogma_bool ogma_is_pkt_desc_ring ( + const ogma_desc_ring_t *desc_ring_p + ) +{ + return ( desc_ring_p->rx_desc_ring_flag || + desc_ring_p->tx_desc_ring_flag); +} + +static __inline ogma_uint32 ogma_get_desc_ring_attr ( + const ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx + ) +{ + ogma_uint32 *addr = + (ogma_uint32 *) + ((pfdep_cpu_addr_t)desc_ring_p->desc_ring_cpu_addr + + desc_ring_p->desc_entry_len * idx); + + return *addr; +} + + + +static __inline void ogma_check_desc_own_sanity ( + ogma_ctrl_t *ctrl_p, + const ogma_desc_ring_t *desc_ring_p, + ogma_uint16 idx, + ogma_uint expected_own) +{ + ogma_uint32 tmp; + ( void)ctrl_p; /* Suppress compiler warning */ + + tmp = ogma_get_desc_ring_attr(desc_ring_p, idx); + pfdep_assert( ( tmp >> 31) == expected_own); +} + +#endif /* OGMA_DESC_RING_ACCESS_INTERNAL_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_gmac_access.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_gmac_access.c new file mode 100644 index 000000000000..d08bb53a54e8 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_gmac_access.c @@ -0,0 +1,1454 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "ogma_config.h" + +#include "ogma_internal.h" +#include "ogma_basic_access.h" + + +/********************************************************************** + * Constant definitions + **********************************************************************/ + +/** + * Clock range index for F_GMAC4MT::GAR::CR field. + */ +#if (OGMA_CONFIG_GMAC_CLK_HZ < 35 * OGMA_CLK_MHZ) +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_25_35_MHZ +#elif (OGMA_CONFIG_GMAC_CLK_HZ < 60 * OGMA_CLK_MHZ) +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_35_60_MHZ +#elif (OGMA_CONFIG_GMAC_CLK_HZ < 100 * OGMA_CLK_MHZ) +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_60_100_MHZ +#elif (OGMA_CONFIG_GMAC_CLK_HZ < 150 * OGMA_CLK_MHZ) +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_100_150_MHZ +#elif (OGMA_CONFIG_GMAC_CLK_HZ < 250 * OGMA_CLK_MHZ) +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_150_250_MHZ +#else +#define OGMA_CLOCK_RANGE_IDX OGMA_GMAC_GAR_REG_CR_250_300_MHZ +#endif + + +/********************************************************************** + * Local function declarations + **********************************************************************/ +static void ogma_set_phy_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr, + ogma_uint16 value + ); + +static ogma_uint16 ogma_get_phy_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr + ); + +#ifdef OGMA_CONFIG_USE_DUMP_GMAC_STAT +void ogma_dump_gmac_stat (ogma_ctrl_t *ctrl_p); +#endif /* OGMA_CONFIG_USE_DUMP_GMAC_STAT */ + +static void ogma_set_phy_target_mmd_reg_addr ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ); + +static void ogma_set_phy_mmd_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr, + ogma_uint16 value + ); + +static ogma_uint16 ogma_get_phy_mmd_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ); + +/********************************************************************** + * Function definitions + **********************************************************************/ + +ogma_err_t ogma_start_gmac ( + ogma_handle_t ogma_handle, + ogma_bool rx_flag, + ogma_bool tx_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + pfdep_err_t pfdep_err; + ogma_err_t ogma_err; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( !ctrl_p->gmac_mode_valid_flag) { + return OGMA_ERR_INVALID; + } + + if ( ( !rx_flag) && ( !tx_flag) ) { + return OGMA_ERR_OK; + } + + if ( ctrl_p->gmac_rx_running_flag && + ctrl_p->gmac_tx_running_flag) { + return OGMA_ERR_OK; + } + + + if ( ( rx_flag && ctrl_p->gmac_rx_running_flag) && + !tx_flag) { + return OGMA_ERR_OK; + } + + if ( ( tx_flag && ctrl_p->gmac_tx_running_flag) && + !rx_flag ) { + return OGMA_ERR_OK; + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "%s call.\n", __func__); + + if ( (! ctrl_p->gmac_rx_running_flag) && + (! ctrl_p->gmac_tx_running_flag) ) { + + /* Initializes F_GMAC4MT */ + if ( ctrl_p->gmac_mode.link_speed == + OGMA_PHY_LINK_SPEED_1G) { + /* Writes 0 to FGMAC4 MCR */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_MCR, + 0); + } else { + /* Writes PS bit to FGMAC4 MCR */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_MCR, + OGMA_GMAC_MCR_10M_HALF);/* 10M half Reset */ + } + + /* F_GMAC4MT soft reset*/ + if ( ( ogma_err = ogma_softreset_gmac( ctrl_p)) != OGMA_ERR_OK) { + return ogma_err; + } + + /* MAC desc soft reset */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_DESC_SOFT_RST, + OGMA_MAC_DESC_SOFT_RST_SOFT_RST); + + /* Wait MAC desc soft reset */ + pfdep_err = pfdep_msleep( 1); + + if ( pfdep_err == PFDEP_ERR_INTERRUPT) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_start_gmac.\n"); + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "Wait for MAC desc soft reset error.\n"); + + return OGMA_ERR_INTERRUPT; + } + + /* Check MAC desc soft reset done */ + if ( ( ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_DESC_SOFT_RST) & + OGMA_MAC_DESC_SOFT_RST_SOFT_RST) != 0) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "ogma_start_gmac():MAC desc soft reset timeout. Try Again.\n"); + + return OGMA_ERR_AGAIN; + } + + /* MAC desc init */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_DESC_INIT, + OGMA_MAC_DESC_INIT_REG_INIT); + + /* Wait MAC desc init done */ + pfdep_err = pfdep_msleep( 1); + + if ( pfdep_err == PFDEP_ERR_INTERRUPT) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_start_gmac().\n"); + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "Wait for MAC desc init done error.\n"); + + return OGMA_ERR_INTERRUPT; + } + + /* Check MAC desc init done */ + if ( ( ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_DESC_INIT) & + OGMA_MAC_DESC_INIT_REG_INIT) != 0) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "ogma_start_gmac():MAC desc init timeout. Try Again.\n"); + + return OGMA_ERR_AGAIN; + } + + /* set BMR */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_BMR, + OGMA_GMAC_BMR_REG_COMMON); + /* set RDLAR */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_RDLAR, + OGMA_GMAC_RDLAR_REG_COMMON); + /* set TDLAR*/ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_TDLAR, + OGMA_GMAC_TDLAR_REG_COMMON); + /* set MFFR*/ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_MFFR, + 0x80000001UL); + + /* calc MCR setting val */ + value = ( ctrl_p->gmac_mode.half_duplex_flag ? + OGMA_GMAC_MCR_REG_HALF_DUPLEX_COMMON : + OGMA_GMAC_MCR_REG_FULL_DUPLEX_COMMON); + + if ( ctrl_p->gmac_mode.link_speed != OGMA_PHY_LINK_SPEED_1G) { + value |= OGMA_GMAC_MCR_REG_PS; + } + + if ( ( ctrl_p->param.gmac_config.phy_interface != + OGMA_PHY_INTERFACE_GMII ) && + ( ctrl_p->gmac_mode.link_speed == OGMA_PHY_LINK_SPEED_100M) ) { + value |= OGMA_GMAC_MCR_REG_FES; + } + /* set CST bit */ + value |= OGMA_GMAC_MCR_REG_CST; + + /* set JE bit */ + value |= OGMA_GMAC_MCR_REG_JE; + + if ( ctrl_p->param.gmac_config.phy_interface == + OGMA_PHY_INTERFACE_RGMII) { + /* set ignore in-band-status watch option. force tx clk out. */ + value |= 0x40000000U; + } + + /* set MCR */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_MCR, + value); + + if ( ctrl_p->gmac_mode.flow_ctrl_enable_flag) { + /* Set Flow Control Threshold */ + value = + ( ctrl_p->gmac_mode.flow_ctrl_stop_threshold << 16) | + ctrl_p->gmac_mode.flow_ctrl_start_threshold; + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_FLOW_TH, + value); + /* Set Flow Control Threshold F_GMAC4MT*/ + value = + ( ctrl_p->gmac_mode.pause_time << 16) | + OGMA_GMAC_FCR_REG_RFE | + OGMA_GMAC_FCR_REG_TFE; + + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_FCR, + value); + } + + } + + if ( ( rx_flag && (! ctrl_p->gmac_rx_running_flag) ) || + ( tx_flag && (! ctrl_p->gmac_tx_running_flag) ) + ) { + /* Read F_GMAC4MT OMR*/ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_OMR); + + if ( rx_flag && (! ctrl_p->gmac_rx_running_flag) ) { + value |= OGMA_GMAC_OMR_REG_SR; + ctrl_p->gmac_rx_running_flag = OGMA_TRUE; + } + + if ( tx_flag && (! ctrl_p->gmac_tx_running_flag) ) { + value |= OGMA_GMAC_OMR_REG_ST; + ctrl_p->gmac_tx_running_flag = OGMA_TRUE; + } + + /* set OMR*/ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_OMR, + value); + + } + + return OGMA_ERR_OK; + +} + +ogma_err_t ogma_stop_gmac ( + ogma_handle_t ogma_handle, + ogma_bool rx_flag, + ogma_bool tx_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + + if ( ( !rx_flag) && ( !tx_flag) ) { + return OGMA_ERR_OK; + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "%s call.\n", __func__); + + if ( ( rx_flag && ctrl_p->gmac_rx_running_flag) || + ( tx_flag && ctrl_p->gmac_tx_running_flag) ) { + /* Read F_GMAC4MT OMR*/ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_OMR); + + if ( rx_flag && ctrl_p->gmac_rx_running_flag) { + value &= (~OGMA_GMAC_OMR_REG_SR); + ctrl_p->gmac_rx_running_flag = OGMA_FALSE; + } + + if ( tx_flag && ctrl_p->gmac_tx_running_flag) { + value &= (~OGMA_GMAC_OMR_REG_ST); + ctrl_p->gmac_tx_running_flag = OGMA_FALSE; + } + + /* set F_GMAC4MT OMR*/ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_OMR, + value); + } + +#ifdef OGMA_CONFIG_USE_DUMP_GMAC_STAT + ogma_dump_gmac_stat (ctrl_p); +#endif /* OGMA_CONFIG_USE_DUMP_GMAC_STAT */ + + + return OGMA_ERR_OK; + +} + +ogma_err_t ogma_set_gmac_mode ( + ogma_handle_t ogma_handle, + const ogma_gmac_mode_t *gmac_mode_p + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( gmac_mode_p == NULL) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + if ( ( ctrl_p->gmac_rx_running_flag) || + ( ctrl_p->gmac_tx_running_flag) ) { + return OGMA_ERR_BUSY; + } + + if ( ( gmac_mode_p->link_speed != OGMA_PHY_LINK_SPEED_1G ) && + ( gmac_mode_p->link_speed != OGMA_PHY_LINK_SPEED_100M) && + ( gmac_mode_p->link_speed != OGMA_PHY_LINK_SPEED_10M ) ) { + return OGMA_ERR_DATA; + } + + if ( ( gmac_mode_p->link_speed == OGMA_PHY_LINK_SPEED_1G) && + ( gmac_mode_p->half_duplex_flag) ) { + return OGMA_ERR_DATA; + } + + if ( gmac_mode_p->half_duplex_flag && + gmac_mode_p->flow_ctrl_enable_flag) { + return OGMA_ERR_DATA; + } + + if ( gmac_mode_p->flow_ctrl_enable_flag) { + + if ( ( gmac_mode_p->flow_ctrl_start_threshold == 0) || + ( gmac_mode_p->flow_ctrl_start_threshold > + OGMA_FLOW_CTRL_START_THRESHOLD_MAX) ) { + return OGMA_ERR_DATA; + } + + if ( ( gmac_mode_p->flow_ctrl_stop_threshold < + gmac_mode_p->flow_ctrl_start_threshold) || + ( gmac_mode_p->flow_ctrl_stop_threshold > + OGMA_FLOW_CTRL_STOP_THRESHOLD_MAX) ) { + return OGMA_ERR_DATA; + } + + if ( gmac_mode_p->pause_time < OGMA_FLOW_CTRL_PAUSE_TIME_MIN) { + return OGMA_ERR_DATA; + } + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "%s call.\n", __func__); + + pfdep_memcpy( ( void *)&ctrl_p->gmac_mode, + ( void *)gmac_mode_p, + sizeof( ogma_gmac_mode_t) ); + + ctrl_p->gmac_mode_valid_flag = OGMA_TRUE; + + + return OGMA_ERR_OK; + +} + +static void ogma_set_phy_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr, + ogma_uint16 value + ) +{ + + ogma_uint32 cmd; + + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_GDR, + value); + + cmd = ( ( phy_addr << OGMA_GMAC_GAR_REG_SHIFT_PA) | + ( reg_addr << OGMA_GMAC_GAR_REG_SHIFT_GR) | + ( OGMA_CLOCK_RANGE_IDX << OGMA_GMAC_GAR_REG_SHIFT_CR) | + OGMA_GMAC_GAR_REG_GW | + OGMA_GMAC_GAR_REG_GB); + + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_GAR, + cmd); + + while ( ( ogma_get_mac_reg( ctrl_p, OGMA_GMAC_REG_ADDR_GAR) & + OGMA_GMAC_GAR_REG_GB) + != 0) { + ; + } +} + +void ogma_set_phy_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr, + ogma_uint16 value + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if (( ctrl_p == NULL) + || ( !ctrl_p->param.use_gmac_flag) + || ( phy_addr >= 32) + || ( reg_addr >= 32) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_set_phy_reg.\nPlease set valid argument.\n"); + return; + } + + ogma_set_phy_reg_sub( ctrl_p, phy_addr, reg_addr, value); + +} + +static ogma_uint16 ogma_get_phy_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr + ) +{ + + ogma_uint32 cmd; + + cmd = ( ( phy_addr << OGMA_GMAC_GAR_REG_SHIFT_PA) | + ( reg_addr << OGMA_GMAC_GAR_REG_SHIFT_GR) | + ( OGMA_CLOCK_RANGE_IDX << OGMA_GMAC_GAR_REG_SHIFT_CR) | + OGMA_GMAC_GAR_REG_GB); + + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_GAR, + cmd); + + while ( ( ogma_get_mac_reg( ctrl_p, OGMA_GMAC_REG_ADDR_GAR) & + OGMA_GMAC_GAR_REG_GB) + != 0) { + ; + } + return (ogma_uint16)ogma_get_mac_reg( ctrl_p, OGMA_GMAC_REG_ADDR_GDR); + +} + +ogma_uint16 ogma_get_phy_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 reg_addr + ) +{ + ogma_uint16 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) + || ( !ctrl_p->param.use_gmac_flag) + || ( phy_addr >= 32) + || ( reg_addr >= 32) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_phy_reg.\nPlease set valid argument.\n"); + return 0; + } + + value = ogma_get_phy_reg_sub(ctrl_p, phy_addr, reg_addr); + + + return value; +} + +#if ( defined(OGMA_CONFIG_USE_READ_GMAC_STAT) || defined(OGMA_CONFIG_USE_DUMP_GMAC_STAT) ) +static const struct { + ogma_uint32 addr; + ogma_char *name_p; +} ogma_gmac_mmc_reg_info[] = { + {OGMA_GMAC_REG_ADDR_MMC_INTR_RX , "MMC_INTR_RX"}, + {OGMA_GMAC_REG_ADDR_MMC_INTR_TX , "MMC_INTR_TX"}, + {OGMA_GMAC_REG_ADDR_MMC_INTR_MASK_RX , "MMC_INTR_MASK_RX"}, + {OGMA_GMAC_REG_ADDR_MMC_INTR_MASK_TX , "MMC_INTR_MASK_TX"}, + {OGMA_GMAC_REG_ADDR_TXOCTETCOUNT_GB , "TXOCTETCOUNT_GB"}, + {OGMA_GMAC_REG_ADDR_TXFRAMECOUNT_GB , "TXFRAMECOUNT_GB"}, + {OGMA_GMAC_REG_ADDR_TXBROADCASTFRAMES_G , "TXBROADCASTFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_TXMULTICASTFRAMES_G , "TXMULTICASTFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_TX64OCTETS_GB , "TX64OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TX65TO127OCTETS_GB , "TX65TO127OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TX128TO255OCTETS_GB , "TX128TO255OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TX256TO511OCTETS_GB , "TX256TO511OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TX512TO1023OCTETS_GB, "TX512TO1023OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TX1024TOMAXOCTETS_GB, "TX1024TOMAXOCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_TXUNICASTFRAMES_GB , "TXUNICASTFRAMES_GB"}, + {OGMA_GMAC_REG_ADDR_TXMULTICASTFRAMES_GB, "TXMULTICASTFRAMES_GB"}, + {OGMA_GMAC_REG_ADDR_TXBROADCASTFRAMES_GB, "TXBROADCASTFRAMES_GB"}, + {OGMA_GMAC_REG_ADDR_TXUNDERFLOWERROR , "TXUNDERFLOWERROR"}, + {OGMA_GMAC_REG_ADDR_TXSINGLECOL_G , "TXSINGLECOL_G"}, + {OGMA_GMAC_REG_ADDR_TXMULTICOL_G , "TXMULTICOL_G"}, + {OGMA_GMAC_REG_ADDR_TXDEFERRED , "TXDEFERRED"}, + {OGMA_GMAC_REG_ADDR_TXLATECOL , "TXLATECOL"}, + {OGMA_GMAC_REG_ADDR_TXEXESSCOL , "TXEXESSCOL"}, + {OGMA_GMAC_REG_ADDR_TXCARRIERERRROR , "TXCARRIERERRROR"}, + {OGMA_GMAC_REG_ADDR_TXOCTETCOUNT_G , "TXOCTETCOUNT_G"}, + {OGMA_GMAC_REG_ADDR_TXFRAMECOUNT_G , "TXFRAMECOUNT_G"}, + {OGMA_GMAC_REG_ADDR_TXEXECESSDEF , "TXEXECESSDEF"}, + {OGMA_GMAC_REG_ADDR_TXPAUSEFRAMES , "TXPAUSEFRAMES"}, + {OGMA_GMAC_REG_ADDR_TXVLANFRAMES_G , "TXVLANFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_RXFRAMECOUNT_GB , "RXFRAMECOUNT_GB"}, + {OGMA_GMAC_REG_ADDR_RXOCTETCOUNT_GB , "RXOCTETCOUNT_GB"}, + {OGMA_GMAC_REG_ADDR_RXOCTETCOUNT_G , "RXOCTETCOUNT_G"}, + {OGMA_GMAC_REG_ADDR_RXBROADCASTFRAMES_G , "RXBROADCASTFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_RXMULTICASTFRAMES_G , "RXMULTICASTFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_RXCRCERROR , "RXCRCERROR"}, + {OGMA_GMAC_REG_ADDR_RXALLIGNMENTERROR , "RXALLIGNMENTERROR"}, + {OGMA_GMAC_REG_ADDR_RXRUNTERROR , "RXRUNTERROR"}, + {OGMA_GMAC_REG_ADDR_RXJABBERERROR , "RXJABBERERROR"}, + {OGMA_GMAC_REG_ADDR_RXUNDERSIZE_G , "RXUNDERSIZE_G"}, + {OGMA_GMAC_REG_ADDR_RXOVERSIZE_G , "RXOVERSIZE_G"}, + {OGMA_GMAC_REG_ADDR_RX64OCTETS_GB , "RX64OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RX65TO127OCTETS_GB , "RX65TO127OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RX128TO255OCTETS_GB , "RX128TO255OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RX256TO511OCTETS_GB , "RX256TO511OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RX512TO1023OCTETS_GB, "RX512TO1023OCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RX1024TOMAXOCTETS_GB, "RX1024TOMAXOCTETS_GB"}, + {OGMA_GMAC_REG_ADDR_RXUNICASTFRAMES_G , "RXUNICASTFRAMES_G"}, + {OGMA_GMAC_REG_ADDR_RXLENGTHERROR , "RXLENGTHERROR"}, + {OGMA_GMAC_REG_ADDR_RXOUTOFRANGETYPE , "RXOUTOFRANGETYPE"}, + {OGMA_GMAC_REG_ADDR_RXPAUSEFRAMES , "RXPAUSEFRAMES"}, + {OGMA_GMAC_REG_ADDR_RXFIFOOVERFLOW , "RXFIFOOVERFLOW"}, + {OGMA_GMAC_REG_ADDR_RXVLANFRAMES_GB , "RXVLANFRAMES_GB"}, + {OGMA_GMAC_REG_ADDR_RXWATCHDOGERROR , "RXWATCHDOGERROR"}, + {OGMA_GMAC_REG_ADDR_MMC_IPC_INTR_MASK_RX, "MMC_IPC_INTR_MASK_RX"}, + {OGMA_GMAC_REG_ADDR_MMC_IPC_INTR_RX , "MMC_IPC_INTR_RX"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_GD_FRMS , "RXIPV4_GD_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_HDRERR_FRMS , "RXIPV4_HDRERR_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_NOPAY_FRMS , "RXIPV4_NOPAY_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_FRAG_FRMS , "RXIPV4_FRAG_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_UDSBL_FRMS , "RXIPV4_UDSBL_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_GD_FRMS , "RXIPV6_GD_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_HDRERR_FRMS , "RXIPV6_HDRERR_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_NOPAY_FRMS , "RXIPV6_NOPAY_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXUDP_GD_FRMS , "RXUDP_GD_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXUDP_ERR_FRMS , "RXUDP_ERR_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXTCP_GD_FRMS , "RXTCP_GD_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXTCP_ERR_FRMS , "RXTCP_ERR_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXICMP_GD_FRMS , "RXICMP_GD_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXICMP_ERR_FRMS , "RXICMP_ERR_FRMS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_GD_OCTETS , "RXIPV4_GD_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_HDRERR_OCTETS, "RXIPV4_HDRERR_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_NOPAY_OCTETS , "RXIPV4_NOPAY_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_FRAG_OCTETS , "RXIPV4_FRAG_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV4_UDSBL_OCTETS , "RXIPV4_UDSBL_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_GD_OCTETS , "RXIPV6_GD_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_HDRERR_OCTETS, "RXIPV6_HDRERR_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXIPV6_NOPAY_OCTETS , "RXIPV6_NOPAY_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXUDP_GD_OCTETS , "RXUDP_GD_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXUDP_ERR_OCTETS , "RXUDP_ERR_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXTCP_GD_OCTETS , "RXTCP_GD_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXTCP_ERR_OCTETS , "RXTCP_ERR_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXICMP_GD_OCTETS , "RXICMP_GD_OCTETS"}, + {OGMA_GMAC_REG_ADDR_RXICMP_ERR_OCTETS , "RXICMP_ERR_OCTETS"} +}; +#endif /* ( defined(OGMA_CONFIG_USE_READ_GMAC_STAT) || defined(OGMA_CONFIG_USE_DUMP_GMAC_STAT) ) */ + +#ifdef OGMA_CONFIG_USE_DUMP_GMAC_STAT +void ogma_dump_gmac_stat (ogma_ctrl_t *ctrl_p) +{ + + ogma_uint i; + + pfdep_print(PFDEP_DEBUG_LEVEL_NOTICE, + "Dumping GMAC statistics registers(MMC registers):\n"); + + for (i = 0; + i < sizeof(ogma_gmac_mmc_reg_info)/sizeof(ogma_gmac_mmc_reg_info[0]); + i++) { + pfdep_print(PFDEP_DEBUG_LEVEL_NOTICE, + " %s => 0x%08x\n", + ogma_gmac_mmc_reg_info[i].name_p, + ( unsigned long)ogma_get_mac_reg(ctrl_p, + ogma_gmac_mmc_reg_info[i].addr)); + } + + + /* Reset all counters. */ + ogma_set_mac_reg(ctrl_p, OGMA_GMAC_REG_ADDR_MMC_CNTL, 1); + + +} + +#endif /* OGMA_CONFIG_USE_DUMP_GMAC_STAT */ + + +ogma_err_t ogma_get_gmac_status ( + ogma_handle_t ogma_handle, + ogma_bool *valid_flag_p, + ogma_gmac_mode_t *gmac_mode_p, + ogma_bool *rx_running_flag_p, + ogma_bool *tx_running_flag_p + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( valid_flag_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( ( ctrl_p == NULL) || + ( gmac_mode_p == NULL) || + ( rx_running_flag_p == NULL) || + ( tx_running_flag_p == NULL) ) { + *valid_flag_p = OGMA_FALSE; + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + *valid_flag_p = OGMA_FALSE; + return OGMA_ERR_NOTAVAIL; + } + + + *valid_flag_p = ctrl_p->gmac_mode_valid_flag; + + *rx_running_flag_p = ctrl_p->gmac_rx_running_flag; + *tx_running_flag_p = ctrl_p->gmac_tx_running_flag; + + pfdep_memcpy( ( void *)gmac_mode_p, + ( const void *)&ctrl_p->gmac_mode, + sizeof( ogma_gmac_mode_t) ); + + + return OGMA_ERR_OK; + +} + +static void ogma_set_phy_target_mmd_reg_addr ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ) +{ + ogma_uint32 cmd; + + /* set MMD ADDR */ + cmd = ( ogma_uint32)dev_addr; + + /*set command to MMD access control register */ + ogma_set_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_MMD_AC, cmd); + + /* set MMD access address data register Write reg_addr */ + ogma_set_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_MMD_AAD, reg_addr); + + /* write value to MMD ADDR */ + cmd = ( (1U << 14) | dev_addr); + + /* set command to MMD access control register */ + ogma_set_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_MMD_AC, cmd); +} + +static void ogma_set_phy_mmd_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr, + ogma_uint16 value + ) +{ + /* set target mmd reg_addr */ + ogma_set_phy_target_mmd_reg_addr( ctrl_p, + phy_addr, + dev_addr, + reg_addr); + + /* Write value to MMD access address data register */ + ogma_set_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_MMD_AAD, value); + +} + +static ogma_uint16 ogma_get_phy_mmd_reg_sub ( + ogma_ctrl_t *ctrl_p, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ) +{ + /* set target mmd reg_addr */ + ogma_set_phy_target_mmd_reg_addr( ctrl_p, + phy_addr, + dev_addr, + reg_addr); + + /* Read value for MMD access address data register */ + return ogma_get_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_MMD_AAD); +} + +ogma_err_t ogma_set_gmac_lpictrl_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* set value tp LSIPCR Register */ + ogma_set_mac_reg( ctrl_p, OGMA_GMAC_REG_ADDR_LPICSR, value); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_get_gmac_lpictrl_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( value_p == NULL) ){ + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Read LSIPCR Register */ + *value_p = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_LPICSR); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_set_gmac_lpitimer_reg ( + ogma_handle_t ogma_handle, + ogma_uint16 ls_timer_ms, + ogma_uint16 tw_timer_ms + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( ls_timer_ms > 1024U) { + return OGMA_ERR_RANGE; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* make LPICTR value*/ + value = ( ( ( ogma_uint32)ls_timer_ms << OGMA_GMAC_LPITCR_REG_LIT) | + ( tw_timer_ms << OGMA_GMAC_LPITCR_REG_TWT) ); + + /* Write timer value to LSIPCR Register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_LPITCR, + value); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_get_gmac_lpitimer_reg ( + ogma_handle_t ogma_handle, + ogma_uint16 *ls_timer_ms_p, + ogma_uint16 *tw_timer_ms_p + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( ls_timer_ms_p == NULL) || + ( tw_timer_ms_p == NULL) ) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Read timer value for LSIPCR Register */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_LPITCR); + + /* make ls_timer_ms value*/ + *ls_timer_ms_p = ( ogma_uint16)( ( value >> OGMA_GMAC_LPITCR_REG_LIT) & + OGMA_GMAC_LPITCR_REG_MASK_LIT); + + /* make tw_timer_ms value*/ + *tw_timer_ms_p = ( ogma_uint16)( ( value >> OGMA_GMAC_LPITCR_REG_TWT) & + OGMA_GMAC_LPITCR_REG_MASK_TWT); + + + return OGMA_ERR_OK; +} + +void ogma_set_phy_mmd_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr, + ogma_uint16 value + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return; + } + + if ( ( phy_addr > 31U) || + ( dev_addr > 31U) ) { + return; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return; + } + + ogma_set_phy_mmd_reg_sub ( ctrl_p, + phy_addr, + dev_addr, + reg_addr, + value); + + + return; +} + +ogma_uint16 ogma_get_phy_mmd_reg ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_uint8 dev_addr, + ogma_uint16 reg_addr + ) +{ + ogma_uint16 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return 0; + } + + if ( ( phy_addr > 31U) || + ( dev_addr > 31U) ) { + return 0; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return 0; + } + + value = ogma_get_phy_mmd_reg_sub ( ctrl_p, + phy_addr, + dev_addr, + reg_addr); + + + return value; +} + +ogma_err_t ogma_get_phy_link_status ( + ogma_handle_t ogma_handle, + ogma_uint8 phy_addr, + ogma_phy_link_status_t *phy_link_status_p + ) +{ + ogma_uint32 value, tmp, exp; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( phy_link_status_p == NULL) ){ + return OGMA_ERR_PARAM; + } + + if ( phy_addr >= 32) { + return OGMA_ERR_RANGE; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + pfdep_memset( phy_link_status_p, 0, sizeof( ogma_phy_link_status_t) ); + + /* Read PHY CONTROL Register */ + tmp = ogma_get_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_CONTROL); + + /* Read PHY STATUS Register */ + value = ogma_get_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_STATUS); + + /* check latched_link_down_flag */ + if ( ( value & ( 1U << OGMA_PHY_STATUS_REG_LINK_STATUS) ) == 0) { + phy_link_status_p->latched_link_down_flag = OGMA_TRUE; + + /* Read PHY STATUS Register */ + value = ogma_get_phy_reg_sub( ctrl_p, phy_addr, OGMA_PHY_REG_ADDR_STATUS); + + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "CONTROL Register value %08x\n", tmp); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "PHY STATUS register value %08x\n", value); + + /* Check Current Link Status */ + if ( ( value & ( 1U << OGMA_PHY_STATUS_REG_LINK_STATUS) ) != 0 ) { + phy_link_status_p->up_flag = OGMA_TRUE; + } + + /* check Auto-Negotiation Enable */ + if ( ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_AUTO_NEGO_ENABLE) ) != 0) && + ( ( value & ( 1U << OGMA_PHY_STATUS_REG_AUTO_NEGO_ABILITY) ) != 0) ) { + phy_link_status_p->auto_nego_enable_flag = OGMA_TRUE; + } + + /* Check Current Autonegotiation Complete Status */ + if ( phy_link_status_p->up_flag && + phy_link_status_p->auto_nego_enable_flag && + ( ( value & ( 1U << OGMA_PHY_STATUS_REG_AUTO_NEGO_COMP) ) != 0) ) { + phy_link_status_p->auto_nego_complete_flag = OGMA_TRUE; + } + + /* start Check Current Link Speed */ + if ( phy_link_status_p->up_flag) { + + if ( phy_link_status_p->auto_nego_enable_flag == OGMA_FALSE) { + + /* Speed check */ + if ( ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_SPEED_SELECTION_LSB) ) == 0) && + ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_SPEED_SELECTION_MSB) ) != 0) ) { + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_1G; + + } else if ( ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_SPEED_SELECTION_LSB) ) != 0) && + ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_SPEED_SELECTION_MSB) ) == 0) ) { + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_100M; + + } else { + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_10M; + } + + /* Duplex check */ + if ( ( tmp & ( 1U << OGMA_PHY_CONTROL_REG_DUPLEX_MODE) ) == 0) { + + phy_link_status_p->half_duplex_flag = OGMA_TRUE; + } + + } else if ( phy_link_status_p->auto_nego_complete_flag == OGMA_TRUE) { + /* case auto_nego_enable_flag TRUE && auto_nego_complete_flag TRUE */ + + /* Read MASTER-SLAVE Control Register */ + value = ogma_get_phy_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_REG_ADDR_MASTER_SLAVE_CONTROL); + + /* Read MASTER-SLAVE Status Register */ + tmp = ogma_get_phy_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_REG_ADDR_MASTER_SLAVE_STATUS); + + /* Check Current Link Speed */ + if ( ( ( value & ( 1U << OGMA_PHY_MSC_REG_1000BASE_FULL) ) != 0) && + ( ( tmp & ( 1U << OGMA_PHY_MSS_REG_LP_1000BASE_FULL) ) != 0) ) { + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_1G; + + } else if ( ( ( value & ( 1U << OGMA_PHY_MSC_REG_1000BASE_HALF) ) != 0) && + ( ( tmp & ( 1U << OGMA_PHY_MSS_REG_LP_1000BASE_HALF) ) != 0) ) { + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_1G; + + phy_link_status_p->half_duplex_flag = OGMA_TRUE; + + } else { + + /* Read Auto-Negotiation Advertisement register */ + value = ogma_get_phy_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_REG_ADDR_AUTO_NEGO_ABILTY); + + /* Read Auto-Negotiation Link Partner Base Page Ability register */ + tmp = ogma_get_phy_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_REG_ADDR_AUTO_NEGO_LINK_PATNER_ABILTY); + + value = ( ( ( value & tmp) >> OGMA_PHY_ANA_REG_TAF) & + OGMA_PHY_ANA_REG_TAF_MASK); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "TAF value %08x\n", value); + + if ( value & OGMA_PHY_TAF_REG_100BASE_FULL) { /* 100M full */ + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_100M; + + } else if ( value & OGMA_PHY_TAF_REG_100BASE_HALF) { /* 100M half */ + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_100M; + + phy_link_status_p->half_duplex_flag = OGMA_TRUE; + + } else if ( value & OGMA_PHY_TAF_REG_10BASE_FULL) { /* 10M full */ + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_10M; + + } else { /* value = OGMA_PHY_TAF_REG_10BASE_HALF 10M Half */ + + phy_link_status_p->link_speed = OGMA_PHY_LINK_SPEED_10M; + + phy_link_status_p->half_duplex_flag = OGMA_TRUE; + } + + } + } + } /* End Check Current Link Speed */ + + /* Check LPI Capable */ + if ( phy_link_status_p->up_flag && + phy_link_status_p->auto_nego_complete_flag && + phy_link_status_p->link_speed != OGMA_PHY_LINK_SPEED_10M && + phy_link_status_p->half_duplex_flag == OGMA_FALSE && + ctrl_p->param.gmac_config.phy_interface != OGMA_PHY_INTERFACE_RMII) { + + /* Read EEE advertisement register */ + value = ogma_get_phy_mmd_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_DEV_ADDR_AUTO_NEGO, + OGMA_PHY_AUTO_NEGO_REG_ADDR_EEE_ADVERTISE); + + /* Read EEE link partner ability register */ + tmp = ogma_get_phy_mmd_reg_sub( ctrl_p, + phy_addr, + OGMA_PHY_DEV_ADDR_AUTO_NEGO, + OGMA_PHY_AUTO_NEGO_REG_ADDR_EEE_LP_ABILITY); + + exp = ( ( phy_link_status_p->link_speed == OGMA_PHY_LINK_SPEED_1G) ? + OGMA_PHY_AUTO_NEGO_1000BASE_EEE: + OGMA_PHY_AUTO_NEGO_100BASE_EEE); + + /* Check EEE Advertise and EEE LP Ability */ + if ( ( value & tmp & exp) != 0 ) { + phy_link_status_p->lpi_capable_flag = OGMA_TRUE; + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "EEE advertisement register value %08x\n", + value); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "EEE link partner ability register value %08x\n", + tmp); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "EEE LPI EXP value %08x\n", + exp); + } + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->latched_link_down_flag %u\n", + phy_link_status_p->latched_link_down_flag); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->up_flag %u\n", + phy_link_status_p->up_flag); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->auto_nego_enable_flag %u\n", + phy_link_status_p->auto_nego_enable_flag); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->auto_nego_complete_flag %u\n", + phy_link_status_p->auto_nego_complete_flag); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->link_speed %u\n", + phy_link_status_p->link_speed); + + pfdep_print( PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED, + "phy_link_status_p->lpi_capable_flag %u\n", + phy_link_status_p->lpi_capable_flag); + + + return OGMA_ERR_OK; +} + +ogma_gmac_int_sbd_regs_t ogma_get_gmac_int_sbd_irq_enable ( + ogma_handle_t ogma_handle + ) +{ + ogma_gmac_int_sbd_regs_t gmac_int_sbd_regs = {0}; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return gmac_int_sbd_regs; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return gmac_int_sbd_regs; + } + + /* Read IER register */ + gmac_int_sbd_regs.base = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER); + /* Read IMR register */ + gmac_int_sbd_regs.extended = ( ( ~( ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR) ) ) & + OGMA_GMAC_INT_SBD_IRQ_ISR_ALL); + + + + return gmac_int_sbd_regs; +} + +ogma_gmac_int_sbd_regs_t ogma_get_gmac_int_sbd_irq_status_non_clear ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ) +{ + ogma_gmac_int_sbd_regs_t gmac_int_sbd_regs = {0}; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return gmac_int_sbd_regs; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return gmac_int_sbd_regs; + } + + /* Read SR register */ + gmac_int_sbd_regs.base = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_SR); + + /* Read ISR register */ + gmac_int_sbd_regs.extended = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_ISR); + + if ( mask_flag) { + + /* Read IER register */ + gmac_int_sbd_regs.base &= ( ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER) | + ( ~OGMA_GMAC_INT_SBD_IRQ_IER_ALL) ); + /* Read IMR register */ + gmac_int_sbd_regs.extended &= ( ( ~( ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR) ) ) & + OGMA_GMAC_INT_SBD_IRQ_ISR_ALL); + } + + + return gmac_int_sbd_regs; +} + +ogma_err_t ogma_clear_gmac_int_sbd_irq_status ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Write Clear SR register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_SR, + ( int_sbd_regs.base & OGMA_GMAC_INT_SBD_IRQ_SR_WC_ALL) ); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_enable_gmac_int_sbd_irq ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Read IER register for No Change Value Keep */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER); + /* Write IER register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER, + ( value | ( int_sbd_regs.base & OGMA_GMAC_INT_SBD_IRQ_IER_ALL) ) ); + + /* Read IMR register for No Change Value Keep */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR); + /* Write IMR register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR, + ( value & ( ~( int_sbd_regs.extended & + OGMA_GMAC_INT_SBD_IRQ_ISR_ALL) ) ) ); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_disable_gmac_int_sbd_irq ( + ogma_handle_t ogma_handle, + ogma_gmac_int_sbd_regs_t int_sbd_regs + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Read IER register for No Change Value Keep */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER); + /* Write IER register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IER, + ( value & ( ~(int_sbd_regs.base) ) ) ); + + /* Read IMR register for No Change Value Keep */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR); + /* Write IMR register */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_IMR, + ( value | ( int_sbd_regs.extended & + OGMA_GMAC_INT_SBD_IRQ_ISR_ALL) ) ); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_get_gmac_rgmii_status_reg ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( value_p == NULL) ){ + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->param.use_gmac_flag) { + return OGMA_ERR_NOTAVAIL; + } + + /* Read RGMII Status Register */ + *value_p = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_RSR); + + + return OGMA_ERR_OK; +} + +#ifdef OGMA_CONFIG_USE_READ_GMAC_STAT +ogma_err_t ogma_read_gmac_stat ( + ogma_handle_t ogma_handle, + ogma_uint32 *value_p, + ogma_bool reset_flag + ) +{ + + ogma_uint i; + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || + ( value_p == NULL) ) { + return OGMA_ERR_PARAM; + } + + + for ( i = 0; + i < sizeof(ogma_gmac_mmc_reg_info)/sizeof(ogma_gmac_mmc_reg_info[0] ); + i++) { + + value_p[i] = ogma_get_mac_reg(ctrl_p, + ogma_gmac_mmc_reg_info[i].addr); + } + + if ( reset_flag) { + /* Reset all counters. */ + ogma_set_mac_reg(ctrl_p, OGMA_GMAC_REG_ADDR_MMC_CNTL, 1); + } + + + return OGMA_ERR_OK; +} +#endif /* OGMA_CONFIG_USE_READ_GMAC_STAT */ + +ogma_err_t ogma_reset_gmac_stat ( + ogma_handle_t ogma_handle + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + + /* Reset all counters. */ + ogma_set_mac_reg(ctrl_p, OGMA_GMAC_REG_ADDR_MMC_CNTL, 1); + + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_softreset_gmac ( + ogma_ctrl_t *ctrl_p + ) +{ + ogma_uint32 value; + pfdep_err_t pfdep_err; + + /* F_GMAC4MT soft reset*/ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_BMR, + OGMA_GMAC_BMR_REG_RESET); + /* Wait soft reset */ + pfdep_err = pfdep_msleep( 1); + + if ( pfdep_err == PFDEP_ERR_INTERRUPT) { + + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "Wait for BMR soft reset error.\n"); + + return OGMA_ERR_INTERRUPT; + } + + /* Read F_GMAC4MT BMR */ + value = ogma_get_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_BMR); + + /* check software reset result*/ + if ( value & OGMA_GMAC_BMR_REG_SWR) { + return OGMA_ERR_AGAIN; + } + + return OGMA_ERR_OK; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_internal.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_internal.h new file mode 100644 index 000000000000..e2e25c71abaa --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_internal.h @@ -0,0 +1,210 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_INTERNAL_H +#define OGMA_INTERNAL_H +#include "netsec_for_uefi/netsec_sdk/include/ogma_api.h" +#include "ogma_reg.h" +#include "pfdep.h" + +/* Just a million to prevent typing errors. */ +#define OGMA_CLK_MHZ (1000000) + +#define OGMA_INSTANCE_NUM_MAX 1 + +#define OGMA_RX_PKT_BUF_LEN 1522 +#define OGMA_RX_JUMBO_PKT_BUF_LEN 9022 +#define OGMA_DUMMY_DESC_ENTRY_LEN 48 + +#define OGMA_REG_ADDR_CLK_EN OGMA_REG_ADDR_CLK_EN_0 + +extern const ogma_uint32 desc_ring_irq_inten_reg_addr[OGMA_DESC_RING_ID_MAX + 1]; +extern const ogma_uint32 desc_ring_irq_inten_set_reg_addr[OGMA_DESC_RING_ID_MAX + 1]; +extern const ogma_uint32 desc_ring_irq_inten_clr_reg_addr[OGMA_DESC_RING_ID_MAX + 1]; +extern const ogma_uint32 ogma_desc_start_reg_addr[OGMA_DESC_RING_ID_MAX+1]; + +typedef struct ogma_ctrl_s ogma_ctrl_t; +typedef struct ogma_desc_ring_s ogma_desc_ring_t; +typedef struct ogma_clk_ctrl_s ogma_clk_ctrl_t; +typedef union ogma_desc_entry_priv_u ogma_desc_entry_priv_t; + +struct ogma_clk_ctrl_s{ + ogma_uint8 mac_req_num; +}; + + +struct ogma_desc_ring_s{ + + ogma_desc_ring_id_t ring_id; + + ogma_desc_ring_param_t param; + + ogma_uint rx_desc_ring_flag:1; + + ogma_uint tx_desc_ring_flag:1; + + ogma_uint running_flag:1; + + ogma_uint full_flag:1; + + ogma_uint8 desc_entry_len; + + ogma_uint16 head_idx; + + ogma_uint16 tail_idx; + + ogma_uint16 rx_num; + + ogma_uint16 tx_done_num; + + pfdep_hard_lock_t inten_reg_hard_lock; + + pfdep_soft_lock_t soft_lock; + + void *desc_ring_cpu_addr; + + pfdep_phys_addr_t desc_ring_phys_addr; + + ogma_frag_info_t *frag_info_p; + + ogma_desc_entry_priv_t *priv_data_p; +}; + +struct ogma_ctrl_s{ + ogma_ctrl_t *next_p; + + ogma_uint core_enabled_flag:1; + + ogma_uint gmac_rx_running_flag:1; + + ogma_uint gmac_tx_running_flag:1; + + ogma_uint gmac_mode_valid_flag:1; + + ogma_uint normal_desc_ring_valid:1; + + void *base_addr; + + pfdep_dev_handle_t dev_handle; + + ogma_param_t param; + + ogma_clk_ctrl_t clk_ctrl; + + ogma_uint32 rx_pkt_buf_len; + + ogma_desc_ring_t desc_ring[OGMA_DESC_RING_ID_MAX+1]; + + ogma_gmac_mode_t gmac_mode; + + pfdep_hard_lock_t inten_reg_hard_lock; + + pfdep_hard_lock_t clk_ctrl_hard_lock; + + void *dummy_desc_entry_addr; + + pfdep_phys_addr_t dummy_desc_entry_phys_addr; + +#ifdef OGMA_CONFIG_REC_STAT + /** + * Statistics information. + * + * Note: Since mutual access exclusion is omitted, + * these values might be inaccurate. + */ + ogma_stat_info_t stat_info; +#endif /* OGMA_CONFIG_REC_STAT */ + +}; + +union ogma_desc_entry_priv_u{ + pfdep_pkt_handle_t pkt_handle; +}; + +/***************************************************************** + ***************************************************************** + *****************************************************************/ + +/** + * + */ +ogma_err_t ogma_alloc_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_id_t ring_idx + ); +/** + * + */ +void ogma_free_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +/** + * + */ +ogma_err_t ogma_setup_rx_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +/** + * + */ +void ogma_uninit_pkt_desc_ring ( + ogma_ctrl_t *ctrl_p, + ogma_desc_ring_t *desc_ring_p + ); + +/** + * + */ +void ogma_push_clk_req ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 domain + ); + +void ogma_pop_clk_req( + ogma_ctrl_t *ctrl_p, + ogma_uint32 domain + ); + + +ogma_err_t ogma_softreset_gmac ( + ogma_ctrl_t *ctrl_p + ); + +#ifdef OGMA_CONFIG_CHECK_CLK_SUPPLY +#include "ogma_basic_access.h" +/*include for ogma_read_reg*/ +static __inline void ogma_check_clk_supply ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 domain + ) +{ + ogma_uint32 value; + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_CLK_EN); + + pfdep_assert( ( ( value & domain ) == domain) ); +} + +#else + +#define ogma_check_clk_supply( ctrl_p, domain) + +#endif /* OGMA_CONFIG_CHECK_CLK_SUPPLY */ + +#endif /* OGMA_INTERNAL_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c new file mode 100644 index 000000000000..3c54c63126a7 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c @@ -0,0 +1,1385 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "ogma_config.h" +#include "ogma_internal.h" +#include "ogma_basic_access.h" +#include "ogma_misc_internal.h" + +#include + +ogma_global_t ogma_global = { + OGMA_FALSE, + 0, + NULL +}; + + +static const ogma_uint32 hw_ver_reg_addr = OGMA_REG_ADDR_HW_VER; +static const ogma_uint32 mc_ver_reg_addr = OGMA_REG_ADDR_MC_VER; + +static const ogma_uint32 desc_ring_irq_status_reg_addr[OGMA_DESC_RING_ID_MAX + 1] = { + OGMA_REG_ADDR_NRM_TX_STATUS, + OGMA_REG_ADDR_NRM_RX_STATUS, +}; + +static const ogma_uint32 desc_ring_config_reg_addr[OGMA_DESC_RING_ID_MAX + 1] = { + OGMA_REG_ADDR_NRM_TX_CONFIG, + OGMA_REG_ADDR_NRM_RX_CONFIG, + +}; + + +/* Internal function definition*/ +#ifndef OGMA_CONFIG_DISABLE_CLK_CTRL +STATIC void ogma_set_clk_en_reg ( + ogma_ctrl_t *ctrl_p + ); +#endif /* OGMA_CONFIG_DISABLE_CLK_CTRL */ +STATIC void ogma_global_init ( void); + +STATIC ogma_err_t ogma_probe_hardware ( + void *base_addr + ); + +STATIC void ogma_reset_hardware ( + ogma_ctrl_t *ctrl_p + ); + +STATIC void ogma_set_microcode( + ogma_ctrl_t *ctrl_p, + const void *dma_hm_mc_addr, + ogma_uint32 dma_hm_mc_len, + const void *dma_mh_mc_addr, + ogma_uint32 dma_mh_mc_len, + const void *pktc_mc_addr, + ogma_uint32 pktc_mc_len + ); + +STATIC ogma_uint32 ogma_calc_pkt_ctrl_reg_param ( + const ogma_pkt_ctrl_param_t *pkt_ctrl_param_p + ); + +STATIC void ogma_internal_terminate ( + ogma_ctrl_t *ctrl_p + ); + +#ifdef OGMA_CONFIG_DISABLE_CLK_CTRL + +#define ogma_set_clk_en_reg( ctrl_p) + +#else /* OGMA_CONFIG_DISABLE_CLK_CTRL */ +STATIC void ogma_set_clk_en_reg ( + ogma_ctrl_t *ctrl_p + ) +{ + ogma_uint32 value = 0; + + if ( ctrl_p->clk_ctrl.mac_req_num != 0) { + value |= OGMA_CLK_EN_REG_DOM_G; + } + + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_CLK_EN, value); +} +#endif /* OGMA_CONFIG_DISABLE_CLK_CTRL */ + +void ogma_push_clk_req ( + ogma_ctrl_t *ctrl_p, + ogma_uint32 domain + ) +{ + pfdep_hard_lock_ctx_t clk_ctrl_hard_lock_ctx; + + pfdep_acquire_hard_lock ( + &ctrl_p->clk_ctrl_hard_lock, + &clk_ctrl_hard_lock_ctx); + + if ( ( domain & OGMA_CLK_EN_REG_DOM_G) != 0) { + ++ctrl_p->clk_ctrl.mac_req_num; + } + + ogma_set_clk_en_reg( ctrl_p); + + pfdep_release_hard_lock( + &ctrl_p->clk_ctrl_hard_lock, + &clk_ctrl_hard_lock_ctx); +} + +void ogma_pop_clk_req( + ogma_ctrl_t *ctrl_p, + ogma_uint32 domain + ) +{ + pfdep_hard_lock_ctx_t clk_ctrl_hard_lock_ctx; + + pfdep_acquire_hard_lock( + &ctrl_p->clk_ctrl_hard_lock, + &clk_ctrl_hard_lock_ctx); + + if ( ( domain & OGMA_CLK_EN_REG_DOM_G) != 0) { + --ctrl_p->clk_ctrl.mac_req_num; + } + + ogma_set_clk_en_reg( ctrl_p); + + pfdep_release_hard_lock( + &ctrl_p->clk_ctrl_hard_lock, + &clk_ctrl_hard_lock_ctx); +} + +/* Internal function */ +STATIC void ogma_global_init ( void) +{ + ogma_global.valid_flag = OGMA_TRUE; +} + +STATIC ogma_err_t ogma_probe_hardware ( + void *base_addr + ) +{ + + ogma_uint32 value; + + /* Read HW_VER Register */ + value = pfdep_iomem_read((void *) + ((pfdep_cpu_addr_t)base_addr + + (OGMA_REG_ADDR_HW_VER << 2))); + + if ( value != OGMA_VER_NETSEC) { + pfdep_print(PFDEP_DEBUG_LEVEL_WARNING, + "Hardware version check warning. Actual:0x%08x, Expected:0x%08x\n", + (unsigned int)value, + (unsigned int)OGMA_VER_NETSEC); + } + + if ( OGMA_VER_MAJOR_NUM(value) != OGMA_VER_MAJOR_NUM(OGMA_VER_NETSEC) ) { + pfdep_print(PFDEP_DEBUG_LEVEL_FATAL, + "Hardware Major version check failed. Actual:0x%08x, Expected:0x%08x\n", + (unsigned int)OGMA_VER_MAJOR_NUM(value), + (unsigned int)OGMA_VER_MAJOR_NUM(OGMA_VER_NETSEC) ); + return OGMA_ERR_NOTAVAIL; + } + + /* Print hardware version information. */ + pfdep_print(PFDEP_DEBUG_LEVEL_NOTICE, + "NETSEC found. Hardware version: %08x\n", + value); + + + return OGMA_ERR_OK; +} + +STATIC void ogma_reset_hardware ( + ogma_ctrl_t *ctrl_p + ) +{ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_CLK_EN, + OGMA_CLK_EN_REG_DOM_ALL); + + + /* + * Stop dma engines if cores are enabled + */ + if (ogma_read_reg(ctrl_p, OGMA_REG_ADDR_DIS_CORE) == 0) { + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_DMA_HM_CTRL, + OGMA_DMA_CTRL_REG_STOP); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_DMA_MH_CTRL, + OGMA_DMA_CTRL_REG_STOP); + + while ( ( ogma_read_reg( ctrl_p, OGMA_REG_ADDR_DMA_HM_CTRL) + & OGMA_DMA_CTRL_REG_STOP) != 0) { + ; + } + + while ( ( ogma_read_reg( ctrl_p, OGMA_REG_ADDR_DMA_MH_CTRL) + & OGMA_DMA_CTRL_REG_STOP) != 0) { + ; + } + } + + if ( ctrl_p->param.use_gmac_flag) { + + /* Reset F_GMAC4MT */ + ogma_set_mac_reg( ctrl_p, + OGMA_GMAC_REG_ADDR_BMR, + OGMA_GMAC_BMR_REG_RESET); + + } + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_SOFT_RST, + OGMA_SOFT_RST_REG_RESET); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_SOFT_RST, + OGMA_SOFT_RST_REG_RUN); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_COM_INIT, + OGMA_COM_INIT_REG_ALL); + + while (ogma_read_reg(ctrl_p, OGMA_REG_ADDR_COM_INIT) != 0) { + ; + } + + if ( ctrl_p->param.use_gmac_flag) { + + + /* MAC desc init */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_DESC_INIT, + OGMA_MAC_DESC_INIT_REG_INIT); + + /* Wait MAC desc init done */ + while ( ( ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_DESC_INIT) + & OGMA_MAC_DESC_INIT_REG_INIT) != 0) { + ; + } + + + /* set MAC_INTF_SEL */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_INTF_SEL, + ctrl_p->param.gmac_config.phy_interface); + + + } +} + +#define OGMA_ROUND_UP(numerator,denominator) (((numerator) + (denominator)) - 1 / (denominator)) + +STATIC void ogma_set_microcode ( + ogma_ctrl_t *ctrl_p, + const void *dma_hm_mc_addr, + ogma_uint32 dma_hm_mc_len, + const void *dma_mh_mc_addr, + ogma_uint32 dma_mh_mc_len, + const void *pktc_mc_addr, + ogma_uint32 pktc_mc_len + ) +{ + ogma_uint i; + + const UINT32 *dmac_hm_cmd_data = (const UINT32 *)dma_hm_mc_addr; + const UINT32 *dmac_mh_cmd_data = (const UINT32 *)dma_mh_mc_addr; + const UINT32 *core_cmd_data = (const UINT32 *)pktc_mc_addr; + + /* Loads microcodes to microengines. */ + for( i = 0; i < dma_hm_mc_len; i++) { + UINT32 data = MmioRead32((UINTN)dmac_hm_cmd_data); + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_DMAC_HM_CMD_BUF, + data ); + dmac_hm_cmd_data++; + } + + for( i = 0; i < dma_mh_mc_len; i++) { + UINT32 data = MmioRead32((UINTN)dmac_mh_cmd_data); + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_DMAC_MH_CMD_BUF, + data ); + dmac_mh_cmd_data++; + } + + for( i = 0; i < pktc_mc_len; i++) { + UINT32 data = MmioRead32((UINTN)core_cmd_data); + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKTC_CMD_BUF, + data ); + core_cmd_data++; + } + +} + +STATIC ogma_uint32 ogma_calc_pkt_ctrl_reg_param ( + const ogma_pkt_ctrl_param_t *pkt_ctrl_param_p + ) +{ + ogma_uint32 param = 0; + + if ( pkt_ctrl_param_p->log_chksum_er_flag) { + param |= OGMA_PKT_CTRL_REG_LOG_CHKSUM_ER; + } + + if ( pkt_ctrl_param_p->log_hd_imcomplete_flag) { + param |= OGMA_PKT_CTRL_REG_LOG_HD_INCOMPLETE; + } + + if ( pkt_ctrl_param_p->log_hd_er_flag) { + param |= OGMA_PKT_CTRL_REG_LOG_HD_ER; + } + + if ( pkt_ctrl_param_p->drp_no_match_flag) { + param |= OGMA_PKT_CTRL_REG_DRP_NO_MATCH; + } + + return param; +} + +ogma_err_t ogma_init ( + void *base_addr, + pfdep_dev_handle_t dev_handle, + const ogma_param_t *param_p, + const void *dma_hm_mc_addr, + ogma_uint32 dma_hm_mc_len, + const void *dma_mh_mc_addr, + ogma_uint32 dma_mh_mc_len, + const void *pktc_mc_addr, + ogma_uint32 pktc_mc_len, + ogma_handle_t *ogma_handle_p + ) +{ + ogma_int i; + ogma_uint32 domain = 0, value; + ogma_err_t ogma_err; + ogma_ctrl_t *ctrl_p = NULL; + + ogma_bool inten_reg_hard_lock_init_flag = OGMA_FALSE; + ogma_bool clk_ctrl_hard_lock_init_flag = OGMA_FALSE; + + ogma_bool all_lock_init_done_flag = OGMA_FALSE; + + pfdep_err_t pfdep_err; + + if ( ( param_p == NULL) || + ( ogma_handle_p == NULL) ) { + return OGMA_ERR_PARAM; + } + + if ( ogma_global.list_entry_num + 1 > OGMA_INSTANCE_NUM_MAX) { + return OGMA_ERR_INVALID; + } + + if ((! param_p->desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].valid_flag) && + (! param_p->desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].valid_flag)) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Please set invalid packet desc_ring_param valid_flag.\n"); + return OGMA_ERR_DATA; + } + + if ( param_p->use_gmac_flag) { + if ( ( param_p->gmac_config.phy_interface != + OGMA_PHY_INTERFACE_GMII) && + ( param_p->gmac_config.phy_interface != + OGMA_PHY_INTERFACE_RGMII) && + ( param_p->gmac_config.phy_interface != + OGMA_PHY_INTERFACE_RMII) ) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Please set phy_interface to valid value.\n"); + return OGMA_ERR_DATA; + } + } else { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Please set use_gmac_flag OGMA_TRUE.\n"); + return OGMA_ERR_DATA; + } + + ogma_err = ogma_probe_hardware( base_addr); + + if ( ogma_err != OGMA_ERR_OK) { + return ogma_err; + } + + if ( !ogma_global.valid_flag) { + ogma_global_init(); + } + + if ( ( ctrl_p = pfdep_malloc( sizeof( ogma_ctrl_t) ) ) == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to ogma_handle memory allocation.\n"); + return OGMA_ERR_ALLOC; + } + + pfdep_memset( ctrl_p, 0, sizeof( ogma_ctrl_t) ); + + ctrl_p->base_addr = base_addr; + + ctrl_p->dev_handle = dev_handle; + + pfdep_memcpy( ( void *)&ctrl_p->param, + ( void *)param_p, + sizeof( ogma_param_t) ); + + /* Initialize hardware lock */ + pfdep_err = pfdep_init_hard_lock( &ctrl_p->inten_reg_hard_lock); + if ( pfdep_err != PFDEP_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to inten_reg_hard_lock's initialization.\n"); + ogma_err = OGMA_ERR_ALLOC; + goto err; + } + inten_reg_hard_lock_init_flag = OGMA_TRUE; + + pfdep_err = pfdep_init_hard_lock( &ctrl_p->clk_ctrl_hard_lock); + if ( pfdep_err != PFDEP_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to clk_ctrl_hard_lock's initialization.\n"); + ogma_err = OGMA_ERR_ALLOC; + goto err; + } + clk_ctrl_hard_lock_init_flag = OGMA_TRUE; + + all_lock_init_done_flag = OGMA_TRUE; + + pfdep_err = pfdep_dma_malloc( dev_handle, + OGMA_DUMMY_DESC_ENTRY_LEN, + &ctrl_p->dummy_desc_entry_addr, + &ctrl_p->dummy_desc_entry_phys_addr); + + if ( pfdep_err != PFDEP_ERR_OK) { + ogma_err = OGMA_ERR_ALLOC; + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to dummy_desc_entry's memory allocation.\n"); + goto err; + } + + /* clear dummy desc entry */ + pfdep_memset( ctrl_p->dummy_desc_entry_addr, + 0, + OGMA_DUMMY_DESC_ENTRY_LEN); + + ogma_reset_hardware( ctrl_p); + + if ( param_p->use_gmac_flag) { + domain |= OGMA_CLK_EN_REG_DOM_G; + } + + ogma_push_clk_req( ctrl_p, domain); + + /* set PKT_CTRL */ + value = ogma_calc_pkt_ctrl_reg_param( ¶m_p->pkt_ctrl_param); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKT_CTRL, + value); + + if ( param_p->use_jumbo_pkt_flag) { + + ctrl_p->rx_pkt_buf_len = OGMA_RX_JUMBO_PKT_BUF_LEN; + + value = ogma_read_reg( ctrl_p, + OGMA_REG_ADDR_PKT_CTRL); + + value |= OGMA_PKT_CTRL_REG_EN_JUMBO; + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKT_CTRL, + value); + } else { + + ctrl_p->rx_pkt_buf_len = OGMA_RX_PKT_BUF_LEN; + + } + + /* set pkt desc ring config */ + for ( i = 0; i <= OGMA_DESC_RING_ID_MAX; i++) { + if ( ctrl_p->param.desc_ring_param[i].valid_flag) { + value = + ( ctrl_p->param.desc_ring_param[i].tmr_mode_flag << + OGMA_REG_DESC_RING_CONFIG_TMR_MODE) | + ( ctrl_p->param.desc_ring_param[i].little_endian_flag << + OGMA_REG_DESC_RING_CONFIG_DAT_ENDIAN) ; + + ogma_write_reg( ctrl_p, + desc_ring_config_reg_addr[i], + value); + + } + } + + /* set microengines */ + ogma_set_microcode(ctrl_p, + dma_hm_mc_addr, + dma_hm_mc_len, + dma_mh_mc_addr, + dma_mh_mc_len, + pktc_mc_addr, + pktc_mc_len); + + /* alloc desc_ring*/ + for( i = 0; i <= OGMA_DESC_RING_ID_MAX; i++) { + ogma_err = ogma_alloc_desc_ring( ctrl_p, (ogma_desc_ring_id_t)i); + if ( ogma_err != OGMA_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to ring id NO.%d memory allocation.\n", + i); + goto err; + } + } + + if ( param_p->desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].valid_flag) { + if ( ( ogma_err = ogma_setup_rx_desc_ring( + ctrl_p, + &ctrl_p->desc_ring[OGMA_DESC_RING_ID_NRM_RX] ) ) + != OGMA_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to NRM_RX packet memory allocation.\n"); + goto err; + } + } + + /* microengines need domain G */ + ogma_push_clk_req( ctrl_p, OGMA_CLK_EN_REG_DOM_G); + + /* set DMA tmr ctrl*/ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_DMA_TMR_CTRL, + ( ogma_uint32)( ( OGMA_CONFIG_CLK_HZ / OGMA_CLK_MHZ) - 1) ); + + /* start microengines */ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_DIS_CORE, 0); + + if ( pfdep_msleep(1) != PFDEP_ERR_OK) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to waiting for microcode initialize end.\n"); + ogma_err = OGMA_ERR_INTERRUPT; + goto err; + } + + /* check microcode load end & start core */ + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_TOP_STATUS); + + if ( ( value & OGMA_TOP_IRQ_REG_ME_START) == 0) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_init.\n" + "Failed to microcode loading.\n"); + ogma_err = OGMA_ERR_INVALID; + goto err; + } + + /* clear microcode load end status */ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_TOP_STATUS, + OGMA_TOP_IRQ_REG_ME_START); + + ogma_pop_clk_req( ctrl_p, OGMA_CLK_EN_REG_DOM_G); + + ctrl_p->core_enabled_flag = OGMA_TRUE; + + ctrl_p->next_p = ogma_global.list_head_p; + + ogma_global.list_head_p = ctrl_p; + + ++ogma_global.list_entry_num; + + *ogma_handle_p = ctrl_p; + +#if 1 + { + +#define OGMA_PKT_CTRL_REG_MODE_TAIKI (1UL << 28) +#define OGMA_DMA_MH_CTRL_REG_MODE_TRANS (1UL << 20) +#define OGMA_TOP_IRQ_REG_MODE_TRANS_COMP (1UL << 4) +#define OGMA_MODE_TRANS_COMP_IRQ_T2N (1UL << 19) + + /* Read Pkt ctrl register */ + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_PKT_CTRL); + value |= OGMA_PKT_CTRL_REG_MODE_TAIKI; + + /* change to noromal mode */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_DMA_MH_CTRL, + OGMA_DMA_MH_CTRL_REG_MODE_TRANS); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKT_CTRL, + value); + + while ((ogma_read_reg(ctrl_p, OGMA_REG_ADDR_MODE_TRANS_COMP_STATUS) & + OGMA_MODE_TRANS_COMP_IRQ_T2N) == 0) { + ; + } + + } +#endif + + /* Print microcode version information. */ + pfdep_print(PFDEP_DEBUG_LEVEL_NOTICE, + "Microcode version: %08x\n", + ogma_read_reg( ctrl_p, + mc_ver_reg_addr) ); + + return OGMA_ERR_OK; + +err: + if ( !all_lock_init_done_flag) { + + + if ( clk_ctrl_hard_lock_init_flag) { + pfdep_uninit_hard_lock( &ctrl_p->clk_ctrl_hard_lock); + } + + if ( inten_reg_hard_lock_init_flag) { + pfdep_uninit_hard_lock( &ctrl_p->inten_reg_hard_lock); + } + + } else { + + ogma_internal_terminate( ctrl_p); + + } + + pfdep_free( ctrl_p); + + return ogma_err; +} + +STATIC void ogma_internal_terminate ( + ogma_ctrl_t *ctrl_p + ) +{ + ogma_int i; + + ogma_reset_hardware( ctrl_p); + + /* free desc_ring */ + for( i = 0; i <= OGMA_DESC_RING_ID_MAX; i++) { + ogma_free_desc_ring( ctrl_p, &ctrl_p->desc_ring[i] ); + } + + if ( ctrl_p->dummy_desc_entry_addr != NULL) { + pfdep_dma_free( ctrl_p->dev_handle, + OGMA_DUMMY_DESC_ENTRY_LEN, + ctrl_p->dummy_desc_entry_addr, + ctrl_p->dummy_desc_entry_phys_addr); + } + + pfdep_uninit_hard_lock ( &ctrl_p->inten_reg_hard_lock); + + + pfdep_uninit_hard_lock ( &ctrl_p->clk_ctrl_hard_lock); + +} + +void ogma_terminate ( + ogma_handle_t ogma_handle + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_ctrl_t *tmp_ctrl_p = NULL, *old_tmp_ctrl_p = NULL; + ogma_uint32 domain = 0; + + if ( ( ctrl_p == NULL) || + ( ogma_global.list_entry_num == 0) ) { + return; + } + + pfdep_assert( ogma_global.list_head_p != NULL); + + if ( ctrl_p->param.use_gmac_flag) { + domain |= OGMA_CLK_EN_REG_DOM_G; + } + + /* pop domain clock */ + ogma_pop_clk_req( ctrl_p, domain); + + tmp_ctrl_p = ogma_global.list_head_p; + + while(1) { + if ( tmp_ctrl_p == NULL) { + /* Could not found ctrl_p specified from the list */ + return; + } + if ( ctrl_p == tmp_ctrl_p) { + if ( old_tmp_ctrl_p != NULL) { + old_tmp_ctrl_p->next_p = ctrl_p->next_p; + } else { + ogma_global.list_head_p = ctrl_p->next_p; + } + break; + } + old_tmp_ctrl_p = tmp_ctrl_p; + tmp_ctrl_p = tmp_ctrl_p->next_p; + } + + ogma_internal_terminate( ctrl_p); + + --ogma_global.list_entry_num; + + pfdep_free( ctrl_p); + return; +} + +ogma_err_t ogma_enable_top_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + /* set irq_factor*/ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_TOP_INTEN_SET, irq_factor); + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_disable_top_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + /* clear irq_factor*/ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_TOP_INTEN_CLR, irq_factor); + + return OGMA_ERR_OK; +} + +ogma_err_t ogma_enable_desc_ring_irq ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 irq_factor + ) +{ + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + ogma_desc_ring_t *desc_ring_p; + + pfdep_err_t pfdep_err; + pfdep_soft_lock_ctx_t soft_lock_ctx; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_enable_desc_ring_irq.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + if ( ring_id > OGMA_DESC_RING_ID_MAX) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_enable_desc_ring_irq.\n" + "Please select ring id number between 0 and %d.\n", + OGMA_DESC_RING_ID_MAX); + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_enable_desc_ring_irq.\n" + "Please select valid desc ring.\n"); + return OGMA_ERR_NOTAVAIL; + } + + desc_ring_p = &ctrl_p->desc_ring[ring_id]; + + /* get soft lock */ + pfdep_err = pfdep_acquire_soft_lock ( + &desc_ring_p->soft_lock, + &soft_lock_ctx); + + if ( pfdep_err != PFDEP_ERR_OK) { + return OGMA_ERR_INTERRUPT; + } + + if ( !desc_ring_p->running_flag) { + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_enable_desc_ring_irq.\n" + "Please select running desc ring.\n"); + return OGMA_ERR_NOTAVAIL; + } + + /* set irq_factor*/ + ogma_write_reg( ctrl_p, + desc_ring_irq_inten_set_reg_addr[ring_id], + irq_factor); + + /* free soft_lock*/ + pfdep_release_soft_lock( &desc_ring_p->soft_lock, + &soft_lock_ctx); + return ogma_err; +} + +ogma_err_t ogma_disable_desc_ring_irq ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 irq_factor + ) +{ + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_disable_desc_ring_irq.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + if ( ring_id > OGMA_DESC_RING_ID_MAX) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_disable_desc_ring_irq.\n" + "Please select ring id number between 0 and %d.\n", + OGMA_DESC_RING_ID_MAX); + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_disable_desc_ring_irq.\n" + "Please select valid desc ring.\n"); + return OGMA_ERR_NOTAVAIL; + } + + /* Clear irq factor*/ + ogma_write_reg( ctrl_p, + desc_ring_irq_inten_clr_reg_addr[ring_id], + irq_factor); + + return ogma_err; +} + +ogma_err_t ogma_enable_pkt_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + /* set irq_factor*/ + ogma_write_reg( ctrl_p, OGMA_REG_ADDR_PKT_INTEN_SET, + ( irq_factor & OGMA_PKT_IRQ_ALL) ); + + return ogma_err; +} + +ogma_err_t ogma_disable_pkt_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return OGMA_ERR_PARAM; + } + + /* clear irq_factor*/ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKT_INTEN_CLR, + ( irq_factor & OGMA_PKT_IRQ_ALL) ); + + return ogma_err; +} + + +ogma_uint32 ogma_get_top_irq_enable ( + ogma_handle_t ogma_handle + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_top_irq_enable.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_TOP_INTEN); + + return value; + +} + + +ogma_uint32 ogma_get_top_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_top_irq_status.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_TOP_STATUS); + + if ( mask_flag) { + value &= ogma_read_reg( ctrl_p, OGMA_REG_ADDR_TOP_INTEN); + } + + return value; +} + +ogma_err_t ogma_clear_top_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_top_irq_status.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + /* Write clear irq top status */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_TOP_STATUS, + + ( value & OGMA_TOP_IRQ_REG_ME_START) ); + + return OGMA_ERR_OK; +} + +ogma_uint32 ogma_get_desc_ring_irq_enable ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_enable.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + if ( ring_id > OGMA_DESC_RING_ID_MAX) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_enable.\n" + "Please select ring id number between 0 and %d.\n", + OGMA_DESC_RING_ID_MAX); + return 0; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_enable.\n" + "Please select valid desc ring.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, + desc_ring_irq_inten_reg_addr[ring_id] ); + + return value; +} + + +ogma_uint32 ogma_get_desc_ring_irq_status ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_bool mask_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_status.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + if ( ring_id > OGMA_DESC_RING_ID_MAX) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_status.\n" + "Please select ring id number between 0 and %d.\n", + OGMA_DESC_RING_ID_MAX); + return 0; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_desc_ring_irq_status.\n" + "Please select valid desc ring.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, + desc_ring_irq_status_reg_addr[ring_id] ); + + if ( mask_flag) { + value &= ogma_read_reg( ctrl_p, + desc_ring_irq_inten_reg_addr[ring_id] ); + } + + return value; +} + + + +ogma_err_t ogma_clear_desc_ring_irq_status ( + ogma_handle_t ogma_handle, + ogma_desc_ring_id_t ring_id, + ogma_uint32 value + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_desc_ring_irq_status.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + if ( ring_id > OGMA_DESC_RING_ID_MAX) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_desc_ring_irq_status.\n" + "Please select ring id number between 0 and %d.\n", + OGMA_DESC_RING_ID_MAX); + return OGMA_ERR_PARAM; + } + + if ( !ctrl_p->desc_ring[ring_id].param.valid_flag) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_desc_ring_irq_status.\n" + "Please select valid desc ring.\n"); + return OGMA_ERR_NOTAVAIL; + } + + /* Write clear descring irq status */ + ogma_write_reg( ctrl_p, + desc_ring_irq_status_reg_addr[ring_id], + ( value & ( OGMA_CH_IRQ_REG_EMPTY | + OGMA_CH_IRQ_REG_ERR) ) ); + + return OGMA_ERR_OK; + +} + + +ogma_uint32 ogma_get_pkt_irq_enable ( + ogma_handle_t ogma_handle + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_pkt_irq_enable.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_PKT_INTEN); + + value &= OGMA_PKT_IRQ_ALL; + + return value; + +} + +ogma_uint32 ogma_get_pkt_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_pkt_irq_statusnon_clear.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_PKT_STATUS); + + if ( mask_flag) { + value &= ogma_read_reg( ctrl_p, OGMA_REG_ADDR_PKT_INTEN); + } + + return value; +} + +ogma_err_t ogma_clear_pkt_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_pkt_irq_status.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + /* Write clear irq pkt status */ + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_PKT_STATUS, + ( value & ( ( OGMA_PKT_IRQ_MAC_ER | + OGMA_PKT_IRQ_JUMBO_ER | + OGMA_PKT_IRQ_CHKSUM_ER | + OGMA_PKT_IRQ_HD_INCOMPLETE | + OGMA_PKT_IRQ_HD_ER | + OGMA_PKT_IRQ_DRP_NO_MATCH) ) ) ); + + return OGMA_ERR_OK; +} + +#ifdef OGMA_CONFIG_REC_STAT +ogma_err_t ogma_get_stat_info ( + ogma_handle_t ogma_handle, + ogma_stat_info_t *stat_info_p, + ogma_bool clear_flag + ) +{ + + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ( ctrl_p == NULL) || (stat_info_p == NULL) ) { + return OGMA_ERR_PARAM; + } + + pfdep_memcpy( stat_info_p, + &ctrl_p->stat_info, + sizeof( ogma_stat_info_t) ); + + + if ( clear_flag) { + pfdep_memset( &ctrl_p->stat_info, 0, sizeof( ogma_stat_info_t) ); + } + + return OGMA_ERR_OK; + +} +#endif /* OGMA_CONFIG_REC_STAT */ + +ogma_uint32 ogma_get_hw_ver ( + ogma_handle_t ogma_handle + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return 0; + } + + value = ogma_read_reg( ctrl_p, + hw_ver_reg_addr); + + return value; +} + + +ogma_uint32 ogma_get_mcr_ver ( + ogma_handle_t ogma_handle + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + return 0; + } + + value = ogma_read_reg( ctrl_p, + mc_ver_reg_addr); + + return value; +} + +ogma_uint32 ogma_get_mac_irq_enable ( + ogma_handle_t ogma_handle + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_ogma_get_mac_irq_enable.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_INTEN); + + + return value; +} + +ogma_uint32 ogma_get_mac_irq_status ( + ogma_handle_t ogma_handle, + ogma_bool mask_flag + ) +{ + ogma_uint32 value; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_get_mac_irq_status.\n" + "Please set valid ogma_handle.\n"); + return 0; + } + + + value = ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_STATUS); + + if ( mask_flag) { + value &= ogma_read_reg( ctrl_p, OGMA_REG_ADDR_MAC_INTEN); + } + + + return value; +} + +ogma_err_t ogma_clear_mac_irq_status ( + ogma_handle_t ogma_handle, + ogma_uint32 value + ) +{ + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_clear_mac_irq_status.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + + /* Commented out because no write-clear bit exists now. */ +#if 0 + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_STATUS, + ( value & /* T.B.D. */) ); +#endif + + + return OGMA_ERR_OK; + +} + +ogma_err_t ogma_enable_mac_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_uint32 value; + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + pfdep_hard_lock_ctx_t inten_reg_hard_lock_ctx; + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_enable_mac_irq.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + /* get inten_reg_hard_lock */ + pfdep_acquire_hard_lock( &ctrl_p->inten_reg_hard_lock, + &inten_reg_hard_lock_ctx); + + value = ogma_read_reg( ctrl_p, + OGMA_REG_ADDR_MAC_INTEN); + + value |= irq_factor; + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_INTEN, + value); + + + /* free inten_reg_hard_lock*/ + pfdep_release_hard_lock( &ctrl_p->inten_reg_hard_lock, + &inten_reg_hard_lock_ctx); + return ogma_err; +} + +ogma_err_t ogma_disable_mac_irq ( + ogma_handle_t ogma_handle, + ogma_uint32 irq_factor + ) +{ + ogma_uint32 value; + ogma_err_t ogma_err = OGMA_ERR_OK; + ogma_ctrl_t *ctrl_p = (ogma_ctrl_t *)ogma_handle; + + pfdep_hard_lock_ctx_t inten_reg_hard_lock_ctx; + + + if ( ctrl_p == NULL) { + pfdep_print( PFDEP_DEBUG_LEVEL_FATAL, + "An error occurred at ogma_disable_mac_irq.\n" + "Please set valid ogma_handle.\n"); + return OGMA_ERR_PARAM; + } + + /* get inten_reg_hard_lock */ + pfdep_acquire_hard_lock( &ctrl_p->inten_reg_hard_lock, + &inten_reg_hard_lock_ctx); + + value = ogma_read_reg( ctrl_p, + OGMA_REG_ADDR_MAC_INTEN); + + value &= (~irq_factor); + + ogma_write_reg( ctrl_p, + OGMA_REG_ADDR_MAC_INTEN, + value); + + + /* free inten_reg_hard_lock*/ + pfdep_release_hard_lock( &ctrl_p->inten_reg_hard_lock, + &inten_reg_hard_lock_ctx); + return ogma_err; + +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc_internal.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc_internal.h new file mode 100644 index 000000000000..3bbf8de57a8b --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc_internal.h @@ -0,0 +1,38 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_MISC_INTERNAL_H +#define OGMA_MISC_INTERNAL_H + +#include "netsec_for_uefi/netsec_sdk/include/ogma_basic_type.h" +#include "netsec_for_uefi/netsec_sdk/include/ogma_api.h" + +#define OGMA_CLK_EN_REG_DOM_ALL 0x24 + +#define OGMA_PKT_IRQ_ALL ( OGMA_PKT_IRQ_MAC_ER | OGMA_PKT_IRQ_JUMBO_ER | \ + OGMA_PKT_IRQ_CHKSUM_ER | OGMA_PKT_IRQ_HD_INCOMPLETE | \ + OGMA_PKT_IRQ_HD_ER | OGMA_PKT_IRQ_DRP_NO_MATCH) + +typedef struct ogma_global_s ogma_global_t; + +struct ogma_global_s{ + ogma_uint valid_flag:1; + + ogma_uint8 list_entry_num; + + ogma_ctrl_t *list_head_p; +}; + +#endif /* OGMA_MISC_INTERNAL_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h new file mode 100644 index 000000000000..910b37a25f14 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h @@ -0,0 +1,219 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_REG_H +#define OGMA_REG_H + +#include "ogma_reg_netsec.h" +#include "ogma_reg_f_gmac_4mt.h" + +/* aliases */ +#define OGMA_REG_ADDR_TOP_INTEN OGMA_REG_ADDR_TOP_INTEN_A +#define OGMA_REG_ADDR_TOP_INTEN_SET OGMA_REG_ADDR_TOP_INTEN_A_SET +#define OGMA_REG_ADDR_TOP_INTEN_CLR OGMA_REG_ADDR_TOP_INTEN_A_CLR +/* aliases end here */ + +/* need fixing */ +#define OGMA_REG_ADDR_DMAC_MH_CMD_BUF (0x87) + + +/*bit fields for PKT_CTRL*/ +#define OGMA_PKT_CTRL_REG_EN_JUMBO (1UL << 27) +#define OGMA_PKT_CTRL_REG_EN_BITPATF (1UL << 4 ) +#define OGMA_PKT_CTRL_REG_LOG_CHKSUM_ER (1UL << 3 ) +#define OGMA_PKT_CTRL_REG_LOG_HD_INCOMPLETE (1UL << 2 ) +#define OGMA_PKT_CTRL_REG_LOG_HD_ER (1UL << 1 ) +#define OGMA_PKT_CTRL_REG_DRP_NO_MATCH (1UL << 0 ) + +#define OGMA_CLK_EN_REG_DOM_G (1UL << 5) + +/************************************************************ + * Bit fields + ************************************************************/ +/* bit fields for com_init */ +#define OGMA_COM_INIT_REG_DB (1UL << 2) +#define OGMA_COM_INIT_REG_CLS (1UL << 1) +#define OGMA_COM_INIT_REG_ALL ( OGMA_COM_INIT_REG_CLS | OGMA_COM_INIT_REG_DB) + +/* bit fields for soft_rst */ +#define OGMA_SOFT_RST_REG_RESET (0) +#define OGMA_SOFT_RST_REG_RUN (1UL << 31) + +/* bit fields for dma_hm_ctrl */ +#define OGMA_DMA_CTRL_REG_STOP 1UL + +/* bit fields for gmac_cmd */ +#define OGMA_GMAC_CMD_ST_READ (0) +#define OGMA_GMAC_CMD_ST_WRITE (1UL << 28) +#define OGMA_GMAC_CMD_ST_BUSY (1UL << 31) + +/* bit fields for F_GMAC4MT BMR*/ +#define OGMA_GMAC_BMR_REG_COMMON (0x00412080) +#define OGMA_GMAC_BMR_REG_RESET (0x00020181) +#define OGMA_GMAC_BMR_REG_SWR (0x00000001) + +/* bit fields for F_GMAC4MT OMR*/ +#define OGMA_GMAC_OMR_REG_ST (1UL << 13) +#define OGMA_GMAC_OMR_REG_SR (1UL << 1) + +/* bit fields for F_GMAC4MT MCR*/ +#define OGMA_GMAC_MCR_REG_CST (1UL << 25) +#define OGMA_GMAC_MCR_REG_JE (1UL << 20) +#define OGMA_GMAC_MCR_REG_PS (1UL << 15) +#define OGMA_GMAC_MCR_REG_FES (1UL << 14) +#define OGMA_GMAC_MCR_REG_FULL_DUPLEX_COMMON (0x0000280c) +#define OGMA_GMAC_MCR_REG_HALF_DUPLEX_COMMON (0x0001a00c) + +#define OGMA_GMAC_MCR_1G_FULL ( OGMA_GMAC_MCR_REG_CST | \ + OGMA_GMAC_MCR_REG_FULL_DUPLEX_COMMON) + +#define OGMA_GMAC_MCR_100M_FULL ( OGMA_GMAC_MCR_REG_CST | \ + OGMA_GMAC_MCR_REG_PS | \ + OGMA_GMAC_MCR_REG_FES | \ + OGMA_GMAC_MCR_REG_FULL_DUPLEX_COMMON) + +#define OGMA_GMAC_MCR_100M_HALF ( OGMA_GMAC_MCR_REG_CST | \ + OGMA_GMAC_MCR_REG_FES | \ + OGMA_GMAC_MCR_REG_HALF_DUPLEX_COMMON) + +#define OGMA_GMAC_MCR_10M_FULL ( OGMA_GMAC_MCR_REG_CST | \ + OGMA_GMAC_MCR_REG_PS | \ + OGMA_GMAC_MCR_REG_FULL_DUPLEX_COMMON) + +#define OGMA_GMAC_MCR_10M_HALF ( OGMA_GMAC_MCR_REG_CST | \ + OGMA_GMAC_MCR_REG_HALF_DUPLEX_COMMON) + +/*bit fields for F_GMAC4MT FCR*/ +#define OGMA_GMAC_FCR_REG_RFE (1UL << 2) +#define OGMA_GMAC_FCR_REG_TFE (1UL << 1) + +/* bit fields for F_GMAC4MT GAR */ +#define OGMA_GMAC_GAR_REG_GW (1UL << 1) +#define OGMA_GMAC_GAR_REG_GB (1UL << 0) + +/* bit fields for F_GMAC4MT RDLAR*/ +#define OGMA_GMAC_RDLAR_REG_COMMON (0x00018000UL) + +/* bit fields for F_GMAC4MT TDLAR*/ +#define OGMA_GMAC_TDLAR_REG_COMMON (0x0001c000UL) + + +#define OGMA_GMAC_GAR_REG_SHIFT_PA (11) +#define OGMA_GMAC_GAR_REG_SHIFT_GR (6) +#define OGMA_GMAC_GAR_REG_SHIFT_CR (2) + +#define OGMA_GMAC_GAR_REG_CR_25_35_MHZ (2) +#define OGMA_GMAC_GAR_REG_CR_35_60_MHZ (3) +#define OGMA_GMAC_GAR_REG_CR_60_100_MHZ (0) +#define OGMA_GMAC_GAR_REG_CR_100_150_MHZ (1) +#define OGMA_GMAC_GAR_REG_CR_150_250_MHZ (4) +#define OGMA_GMAC_GAR_REG_CR_250_300_MHZ (5) + +/* bit fields for F_GMAC4MT LPITCR */ +#define OGMA_GMAC_LPITCR_REG_LIT (16) +#define OGMA_GMAC_LPITCR_REG_TWT (0) + +/* bit fileds mask for F_GMAC4MT LPITCR */ +#define OGMA_GMAC_LPITCR_REG_MASK_LIT (0x3ffU) +#define OGMA_GMAC_LPITCR_REG_MASK_TWT (0xffffU) + +/** + * PHY regtister Address + */ +#define OGMA_PHY_REG_ADDR_CONTROL 0 +#define OGMA_PHY_REG_ADDR_STATUS 1U +#define OGMA_PHY_REG_ADDR_AUTO_NEGO_ABILTY 4U +#define OGMA_PHY_REG_ADDR_AUTO_NEGO_LINK_PATNER_ABILTY 5U +#define OGMA_PHY_REG_ADDR_MASTER_SLAVE_CONTROL 9U +#define OGMA_PHY_REG_ADDR_MASTER_SLAVE_STATUS 10U +#define OGMA_PHY_REG_ADDR_MMD_AC 13U +#define OGMA_PHY_REG_ADDR_MMD_AAD 14U + +/* bit fields for PHY CONTROL Register */ +#define OGMA_PHY_CONTROL_REG_SPEED_SELECTION_MSB (6) +#define OGMA_PHY_CONTROL_REG_DUPLEX_MODE (8) +#define OGMA_PHY_CONTROL_REG_AUTO_NEGO_ENABLE (12) +#define OGMA_PHY_CONTROL_REG_SPEED_SELECTION_LSB (13) + +/* bit fields for PHY STATUS Register */ +#define OGMA_PHY_STATUS_REG_LINK_STATUS (2) +#define OGMA_PHY_STATUS_REG_AUTO_NEGO_ABILITY (3) +#define OGMA_PHY_STATUS_REG_AUTO_NEGO_COMP (5) + +/* bit fields for PHY MASTER-SLAVE Control Register */ +#define OGMA_PHY_MSC_REG_1000BASE_FULL (9) +#define OGMA_PHY_MSC_REG_1000BASE_HALF (8) + +/* bit fields for PHY MASTER-SLAVE Status Register */ +#define OGMA_PHY_MSS_REG_LP_1000BASE_FULL (11) +#define OGMA_PHY_MSS_REG_LP_1000BASE_HALF (10) + +/* bit fields for PHY Auto-Negotiation Advertisement Register */ +#define OGMA_PHY_ANA_REG_TAF (5) + +/* bit fileds mask for F_GMAC4MT LPITCR */ +#define OGMA_PHY_ANA_REG_TAF_MASK (0x7fU) + +/* bit fields for PHY Technology Ability Field */ +#define OGMA_PHY_TAF_REG_100BASE_FULL (1U << 3) +#define OGMA_PHY_TAF_REG_100BASE_HALF (1U << 2) +#define OGMA_PHY_TAF_REG_10BASE_FULL (1U << 1) +#define OGMA_PHY_TAF_REG_10BASE_HALF (1U << 0) + +/** + * PHY Device Address + */ +#define OGMA_PHY_DEV_ADDR_AUTO_NEGO (7U) + +/** + * PHY Register Address for Device Address 7 + */ +#define OGMA_PHY_AUTO_NEGO_REG_ADDR_EEE_ADVERTISE (60U) +#define OGMA_PHY_AUTO_NEGO_REG_ADDR_EEE_LP_ABILITY (61U) + +/* bit fields for PHY AutoNegotiation Field */ +#define OGMA_PHY_AUTO_NEGO_1000BASE_EEE (1U << 2) +#define OGMA_PHY_AUTO_NEGO_100BASE_EEE (1U << 1) + +/* bit fields for DESC RING CONFIG */ +#define OGMA_REG_DESC_RING_CONFIG_CFG_UP (31) +#define OGMA_REG_DESC_RING_CONFIG_CH_RST (30) +#define OGMA_REG_DESC_RING_CONFIG_TMR_MODE (4) +#define OGMA_REG_DESC_RING_CONFIG_DAT_ENDIAN (0) + + +/* bit fields for mac_desc_soft_rst */ +#define OGMA_MAC_DESC_SOFT_RST_SOFT_RST 1UL + +/* bit fields for mac_desc_init */ +#define OGMA_MAC_DESC_INIT_REG_INIT 1UL + +/* bit fields for dis_core */ +#define OGMA_DIS_CORE_REG_DIS_PCORE (1UL << 2) +#define OGMA_DIS_CORE_REG_DIS_MHCORE (1UL << 1) +#define OGMA_DIS_CORE_REG_DIS_HMCORE (1UL << 0) + +#define OGMA_DIS_CORE_REG_ALL ( OGMA_DIS_CORE_REG_DIS_HMCORE | \ + OGMA_DIS_CORE_REG_DIS_MHCORE | \ + OGMA_DIS_CORE_REG_DIS_PCORE) + +/* bit fields for dma_info */ +#define OGMA_DMA_INFO_REG_AXI_WRITE_BUSY (1UL << 3) +#define OGMA_DMA_INFO_REG_AXI_READ_BUSY (1UL << 2) + +#define OGMA_DMA_INFO_REG_AXI_BUSY ( OGMA_DMA_INFO_REG_AXI_WRITE_BUSY | \ + OGMA_DMA_INFO_REG_AXI_READ_BUSY) + +#endif /*OGMA_REG_H*/ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_f_gmac_4mt.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_f_gmac_4mt.h new file mode 100644 index 000000000000..e12b317218fb --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_f_gmac_4mt.h @@ -0,0 +1,222 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_REG_F_GMAC_4MT_H +#define OGMA_REG_F_GMAC_4MT_H + +/** + * GMAC register + */ +#define OGMA_GMAC_REG_ADDR_MCR (0x0000) +#define OGMA_GMAC_REG_ADDR_MFFR (0x0004) +#define OGMA_GMAC_REG_ADDR_MHTRH (0x0008) +#define OGMA_GMAC_REG_ADDR_MHTRL (0x000c) +#define OGMA_GMAC_REG_ADDR_GAR (0x0010) +#define OGMA_GMAC_REG_ADDR_GDR (0x0014) +#define OGMA_GMAC_REG_ADDR_FCR (0x0018) +#define OGMA_GMAC_REG_ADDR_VTR (0x001c) +#define OGMA_GMAC_REG_ADDR_RWFFR (0x0028) +#define OGMA_GMAC_REG_ADDR_PMTR (0x002c) +#define OGMA_GMAC_REG_ADDR_LPICSR (0x0030) +#define OGMA_GMAC_REG_ADDR_LPITCR (0x0034) +#define OGMA_GMAC_REG_ADDR_ISR (0x0038) +#define OGMA_GMAC_REG_ADDR_IMR (0x003c) +#define OGMA_GMAC_REG_ADDR_MAR0H (0x0040) +#define OGMA_GMAC_REG_ADDR_MAR0L (0x0044) +#define OGMA_GMAC_REG_ADDR_MAR1H (0x0048) +#define OGMA_GMAC_REG_ADDR_MAR1L (0x004c) +#define OGMA_GMAC_REG_ADDR_MAR2H (0x0050) +#define OGMA_GMAC_REG_ADDR_MAR2L (0x0054) +#define OGMA_GMAC_REG_ADDR_MAR3H (0x0058) +#define OGMA_GMAC_REG_ADDR_MAR3L (0x005c) +#define OGMA_GMAC_REG_ADDR_MAR4H (0x0060) +#define OGMA_GMAC_REG_ADDR_MAR4L (0x0064) +#define OGMA_GMAC_REG_ADDR_MAR5H (0x0068) +#define OGMA_GMAC_REG_ADDR_MAR5L (0x006c) +#define OGMA_GMAC_REG_ADDR_MAR6H (0x0070) +#define OGMA_GMAC_REG_ADDR_MAR6L (0x0074) +#define OGMA_GMAC_REG_ADDR_MAR7H (0x0078) +#define OGMA_GMAC_REG_ADDR_MAR7L (0x007c) +#define OGMA_GMAC_REG_ADDR_MAR8H (0x0080) +#define OGMA_GMAC_REG_ADDR_MAR8L (0x0084) +#define OGMA_GMAC_REG_ADDR_MAR9H (0x0088) +#define OGMA_GMAC_REG_ADDR_MAR9L (0x008c) +#define OGMA_GMAC_REG_ADDR_MAR10H (0x0090) +#define OGMA_GMAC_REG_ADDR_MAR10L (0x0094) +#define OGMA_GMAC_REG_ADDR_MAR11H (0x0098) +#define OGMA_GMAC_REG_ADDR_MAR11L (0x009c) +#define OGMA_GMAC_REG_ADDR_MAR12H (0x00a0) +#define OGMA_GMAC_REG_ADDR_MAR12L (0x00a4) +#define OGMA_GMAC_REG_ADDR_MAR13H (0x00a8) +#define OGMA_GMAC_REG_ADDR_MAR13L (0x00ac) +#define OGMA_GMAC_REG_ADDR_MAR14H (0x00b0) +#define OGMA_GMAC_REG_ADDR_MAR14L (0x00b4) +#define OGMA_GMAC_REG_ADDR_MAR15H (0x00b8) +#define OGMA_GMAC_REG_ADDR_MAR15L (0x00bc) +#define OGMA_GMAC_REG_ADDR_RSR (0x00d8) +#define OGMA_GMAC_REG_ADDR_TSCR (0x0700) +#define OGMA_GMAC_REG_ADDR_SSIR (0x0704) +#define OGMA_GMAC_REG_ADDR_STSR (0x0708) +#define OGMA_GMAC_REG_ADDR_STNR (0x070c) +#define OGMA_GMAC_REG_ADDR_STSUR (0x0710) +#define OGMA_GMAC_REG_ADDR_STNUR (0x0714) +#define OGMA_GMAC_REG_ADDR_TSAR (0x0718) +#define OGMA_GMAC_REG_ADDR_TTSR (0x071c) +#define OGMA_GMAC_REG_ADDR_TTNR (0x0720) +#define OGMA_GMAC_REG_ADDR_STHWSR (0x0724) +#define OGMA_GMAC_REG_ADDR_TSR (0x0728) +#define OGMA_GMAC_REG_ADDR_PPSCR (0x072c) +#define OGMA_GMAC_REG_ADDR_ANTR (0x0730) +#define OGMA_GMAC_REG_ADDR_ATSR (0x0734) +#define OGMA_GMAC_REG_ADDR_MAR16H (0x0800) +#define OGMA_GMAC_REG_ADDR_MAR16L (0x0804) +#define OGMA_GMAC_REG_ADDR_MAR17H (0x0808) +#define OGMA_GMAC_REG_ADDR_MAR17L (0x080c) +#define OGMA_GMAC_REG_ADDR_MAR18H (0x0810) +#define OGMA_GMAC_REG_ADDR_MAR18L (0x0814) +#define OGMA_GMAC_REG_ADDR_MAR19H (0x0818) +#define OGMA_GMAC_REG_ADDR_MAR19L (0x081c) +#define OGMA_GMAC_REG_ADDR_MAR20H (0x0820) +#define OGMA_GMAC_REG_ADDR_MAR20L (0x0824) +#define OGMA_GMAC_REG_ADDR_MAR21H (0x0828) +#define OGMA_GMAC_REG_ADDR_MAR21L (0x082c) +#define OGMA_GMAC_REG_ADDR_MAR22H (0x0830) +#define OGMA_GMAC_REG_ADDR_MAR22L (0x0834) +#define OGMA_GMAC_REG_ADDR_MAR23H (0x0838) +#define OGMA_GMAC_REG_ADDR_MAR23L (0x083c) +#define OGMA_GMAC_REG_ADDR_MAR24H (0x0840) +#define OGMA_GMAC_REG_ADDR_MAR24L (0x0844) +#define OGMA_GMAC_REG_ADDR_MAR25H (0x0848) +#define OGMA_GMAC_REG_ADDR_MAR25L (0x084c) +#define OGMA_GMAC_REG_ADDR_MAR26H (0x0850) +#define OGMA_GMAC_REG_ADDR_MAR26L (0x0854) +#define OGMA_GMAC_REG_ADDR_MAR27H (0x0858) +#define OGMA_GMAC_REG_ADDR_MAR27L (0x085c) +#define OGMA_GMAC_REG_ADDR_MAR28H (0x0860) +#define OGMA_GMAC_REG_ADDR_MAR28L (0x0864) +#define OGMA_GMAC_REG_ADDR_MAR29H (0x0868) +#define OGMA_GMAC_REG_ADDR_MAR29L (0x086c) +#define OGMA_GMAC_REG_ADDR_MAR30H (0x0870) +#define OGMA_GMAC_REG_ADDR_MAR30L (0x0874) +#define OGMA_GMAC_REG_ADDR_MAR31H (0x0878) +#define OGMA_GMAC_REG_ADDR_MAR31L (0x087c) + +/** + * GMAC MAC Management Counters(Option) register + */ +#define OGMA_GMAC_REG_ADDR_MMC_CNTL (0x0100) +#define OGMA_GMAC_REG_ADDR_MMC_INTR_RX (0x0104) +#define OGMA_GMAC_REG_ADDR_MMC_INTR_TX (0x0108) +#define OGMA_GMAC_REG_ADDR_MMC_INTR_MASK_RX (0x010c) +#define OGMA_GMAC_REG_ADDR_MMC_INTR_MASK_TX (0x0110) +#define OGMA_GMAC_REG_ADDR_TXOCTETCOUNT_GB (0x0114) +#define OGMA_GMAC_REG_ADDR_TXFRAMECOUNT_GB (0x0118) +#define OGMA_GMAC_REG_ADDR_TXBROADCASTFRAMES_G (0x011c) +#define OGMA_GMAC_REG_ADDR_TXMULTICASTFRAMES_G (0x0120) +#define OGMA_GMAC_REG_ADDR_TX64OCTETS_GB (0x0124) +#define OGMA_GMAC_REG_ADDR_TX65TO127OCTETS_GB (0x0128) +#define OGMA_GMAC_REG_ADDR_TX128TO255OCTETS_GB (0x012c) +#define OGMA_GMAC_REG_ADDR_TX256TO511OCTETS_GB (0x0130) +#define OGMA_GMAC_REG_ADDR_TX512TO1023OCTETS_GB (0x0134) +#define OGMA_GMAC_REG_ADDR_TX1024TOMAXOCTETS_GB (0x0138) +#define OGMA_GMAC_REG_ADDR_TXUNICASTFRAMES_GB (0x013c) +#define OGMA_GMAC_REG_ADDR_TXMULTICASTFRAMES_GB (0x0140) +#define OGMA_GMAC_REG_ADDR_TXBROADCASTFRAMES_GB (0x0144) +#define OGMA_GMAC_REG_ADDR_TXUNDERFLOWERROR (0x0148) +#define OGMA_GMAC_REG_ADDR_TXSINGLECOL_G (0x014c) +#define OGMA_GMAC_REG_ADDR_TXMULTICOL_G (0x0150) +#define OGMA_GMAC_REG_ADDR_TXDEFERRED (0x0154) +#define OGMA_GMAC_REG_ADDR_TXLATECOL (0x0158) +#define OGMA_GMAC_REG_ADDR_TXEXESSCOL (0x015c) +#define OGMA_GMAC_REG_ADDR_TXCARRIERERRROR (0x0160) +#define OGMA_GMAC_REG_ADDR_TXOCTETCOUNT_G (0x0164) +#define OGMA_GMAC_REG_ADDR_TXFRAMECOUNT_G (0x0168) +#define OGMA_GMAC_REG_ADDR_TXEXECESSDEF (0x016c) +#define OGMA_GMAC_REG_ADDR_TXPAUSEFRAMES (0x0170) +#define OGMA_GMAC_REG_ADDR_TXVLANFRAMES_G (0x0174) +#define OGMA_GMAC_REG_ADDR_RXFRAMECOUNT_GB (0x0180) +#define OGMA_GMAC_REG_ADDR_RXOCTETCOUNT_GB (0x0184) +#define OGMA_GMAC_REG_ADDR_RXOCTETCOUNT_G (0x0188) +#define OGMA_GMAC_REG_ADDR_RXBROADCASTFRAMES_G (0x018c) +#define OGMA_GMAC_REG_ADDR_RXMULTICASTFRAMES_G (0x0190) +#define OGMA_GMAC_REG_ADDR_RXCRCERROR (0x0194) +#define OGMA_GMAC_REG_ADDR_RXALLIGNMENTERROR (0x0198) +#define OGMA_GMAC_REG_ADDR_RXRUNTERROR (0x019c) +#define OGMA_GMAC_REG_ADDR_RXJABBERERROR (0x01a0) +#define OGMA_GMAC_REG_ADDR_RXUNDERSIZE_G (0x01a4) +#define OGMA_GMAC_REG_ADDR_RXOVERSIZE_G (0x01a8) +#define OGMA_GMAC_REG_ADDR_RX64OCTETS_GB (0x01ac) +#define OGMA_GMAC_REG_ADDR_RX65TO127OCTETS_GB (0x01b0) +#define OGMA_GMAC_REG_ADDR_RX128TO255OCTETS_GB (0x01b4) +#define OGMA_GMAC_REG_ADDR_RX256TO511OCTETS_GB (0x01b8) +#define OGMA_GMAC_REG_ADDR_RX512TO1023OCTETS_GB (0x01bc) +#define OGMA_GMAC_REG_ADDR_RX1024TOMAXOCTETS_GB (0x01c0) +#define OGMA_GMAC_REG_ADDR_RXUNICASTFRAMES_G (0x01c4) +#define OGMA_GMAC_REG_ADDR_RXLENGTHERROR (0x01c8) +#define OGMA_GMAC_REG_ADDR_RXOUTOFRANGETYPE (0x01cc) +#define OGMA_GMAC_REG_ADDR_RXPAUSEFRAMES (0x01d0) +#define OGMA_GMAC_REG_ADDR_RXFIFOOVERFLOW (0x01d4) +#define OGMA_GMAC_REG_ADDR_RXVLANFRAMES_GB (0x01d8) +#define OGMA_GMAC_REG_ADDR_RXWATCHDOGERROR (0x01dc) +#define OGMA_GMAC_REG_ADDR_MMC_IPC_INTR_MASK_RX (0x0200) +#define OGMA_GMAC_REG_ADDR_MMC_IPC_INTR_RX (0x0208) +#define OGMA_GMAC_REG_ADDR_RXIPV4_GD_FRMS (0x0210) +#define OGMA_GMAC_REG_ADDR_RXIPV4_HDRERR_FRMS (0x0214) +#define OGMA_GMAC_REG_ADDR_RXIPV4_NOPAY_FRMS (0x0218) +#define OGMA_GMAC_REG_ADDR_RXIPV4_FRAG_FRMS (0x021c) +#define OGMA_GMAC_REG_ADDR_RXIPV4_UDSBL_FRMS (0x0220) +#define OGMA_GMAC_REG_ADDR_RXIPV6_GD_FRMS (0x0224) +#define OGMA_GMAC_REG_ADDR_RXIPV6_HDRERR_FRMS (0x0228) +#define OGMA_GMAC_REG_ADDR_RXIPV6_NOPAY_FRMS (0x022c) +#define OGMA_GMAC_REG_ADDR_RXUDP_GD_FRMS (0x0230) +#define OGMA_GMAC_REG_ADDR_RXUDP_ERR_FRMS (0x0234) +#define OGMA_GMAC_REG_ADDR_RXTCP_GD_FRMS (0x0238) +#define OGMA_GMAC_REG_ADDR_RXTCP_ERR_FRMS (0x023c) +#define OGMA_GMAC_REG_ADDR_RXICMP_GD_FRMS (0x0240) +#define OGMA_GMAC_REG_ADDR_RXICMP_ERR_FRMS (0x0244) +#define OGMA_GMAC_REG_ADDR_RXIPV4_GD_OCTETS (0x0250) +#define OGMA_GMAC_REG_ADDR_RXIPV4_HDRERR_OCTETS (0x0254) +#define OGMA_GMAC_REG_ADDR_RXIPV4_NOPAY_OCTETS (0x0258) +#define OGMA_GMAC_REG_ADDR_RXIPV4_FRAG_OCTETS (0x025c) +#define OGMA_GMAC_REG_ADDR_RXIPV4_UDSBL_OCTETS (0x0260) +#define OGMA_GMAC_REG_ADDR_RXIPV6_GD_OCTETS (0x0264) +#define OGMA_GMAC_REG_ADDR_RXIPV6_HDRERR_OCTETS (0x0268) +#define OGMA_GMAC_REG_ADDR_RXIPV6_NOPAY_OCTETS (0x026c) +#define OGMA_GMAC_REG_ADDR_RXUDP_GD_OCTETS (0x0270) +#define OGMA_GMAC_REG_ADDR_RXUDP_ERR_OCTETS (0x0274) +#define OGMA_GMAC_REG_ADDR_RXTCP_GD_OCTETS (0x0278) +#define OGMA_GMAC_REG_ADDR_RXTCP_ERR_OCTETS (0x027c) +#define OGMA_GMAC_REG_ADDR_RXICMP_GD_OCTETS (0x0280) +#define OGMA_GMAC_REG_ADDR_RXICMP_ERR_OCTETS (0x0284) +/** + * GMAC DMA register + */ +#define OGMA_GMAC_REG_ADDR_BMR (0x1000) +#define OGMA_GMAC_REG_ADDR_TPDR (0x1004) +#define OGMA_GMAC_REG_ADDR_RPDR (0x1008) +#define OGMA_GMAC_REG_ADDR_RDLAR (0x100c) +#define OGMA_GMAC_REG_ADDR_TDLAR (0x1010) +#define OGMA_GMAC_REG_ADDR_SR (0x1014) +#define OGMA_GMAC_REG_ADDR_OMR (0x1018) +#define OGMA_GMAC_REG_ADDR_IER (0x101c) +#define OGMA_GMAC_REG_ADDR_MFOCR (0x1020) +#define OGMA_GMAC_REG_ADDR_RIWTR (0x1024) +#define OGMA_GMAC_REG_ADDR_AHBSR (0x102c) +#define OGMA_GMAC_REG_ADDR_CHTDR (0x1048) +#define OGMA_GMAC_REG_ADDR_CHRDR (0x104c) +#define OGMA_GMAC_REG_ADDR_CHTBAR (0x1050) +#define OGMA_GMAC_REG_ADDR_CHRBAR (0x1054) + +#endif /* OGMA_REG_F_GMAC_4MT_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_netsec.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_netsec.h new file mode 100644 index 000000000000..457be2aa0cba --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg_netsec.h @@ -0,0 +1,368 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_REG_NETSEC_H +#define OGMA_REG_NETSEC_H + +#define OGMA_REG_ADDR_SOFT_RST (0x41) +#define OGMA_REG_ADDR_COM_INIT (0x48) +#define OGMA_REG_ADDR_MC_BASE_ADDR (0x97) +#define OGMA_REG_ADDR_DMAC_HM_CMD_BUF (0x84) +#define OGMA_REG_ADDR_DMAC_MC_ADDR_MH (0x89) +#define OGMA_REG_ADDR_DMAC_MC_SIZE_MH (0x8A) +#define OGMA_REG_ADDR_PKTC_CMD_BUF (0x34) +#define OGMA_REG_ADDR_PKTC_MC_ADDR (0x5C) +#define OGMA_REG_ADDR_PKTC_MC_SIZE (0x5D) +#define OGMA_REG_ADDR_DIS_CORE (0x86) +#define OGMA_REG_ADDR_DMA_HM_CTRL (0x85) +#define OGMA_REG_ADDR_DMA_MH_CTRL (0x88) +#define OGMA_REG_ADDR_CLK_EN_0 (0x40) +#define OGMA_REG_ADDR_CLK_EN_1 (0x64) +#define OGMA_REG_ADDR_PKT_CTRL (0x50) +#define OGMA_REG_ADDR_NRM_TX_DESC_START_UP (0x10D) +#define OGMA_REG_ADDR_NRM_TX_DESC_START_LW (0x102) +#define OGMA_REG_ADDR_NRM_RX_DESC_START_UP (0x11D) +#define OGMA_REG_ADDR_NRM_RX_DESC_START_LW (0x112) +#define OGMA_REG_ADDR_TAIKI_RX_DESC_START_UP (0x12D) +#define OGMA_REG_ADDR_TAIKI_RX_DESC_START_LW (0x122) +#define OGMA_REG_ADDR_TAIKI_TX_DESC_START_UP (0x13D) +#define OGMA_REG_ADDR_TAIKI_TX_DESC_START_LW (0x132) +#define OGMA_REG_ADDR_MISC_RX_DESC_START_UP (0x14D) +#define OGMA_REG_ADDR_MISC_RX_DESC_START_LW (0x142) +#define OGMA_REG_ADDR_WL_NRM_TX_DESC_START_UP (0x15D) +#define OGMA_REG_ADDR_WL_NRM_TX_DESC_START_LW (0x152) +#define OGMA_REG_ADDR_WL_NRM_RX_DESC_START_UP (0x16D) +#define OGMA_REG_ADDR_WL_NRM_RX_DESC_START_LW (0x162) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_DESC_START_UP (0x17D) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_DESC_START_LW (0x172) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_DESC_START_UP (0x18D) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_DESC_START_LW (0x182) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_DESC_START_UP (0x19D) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_DESC_START_LW (0x192) +#define OGMA_REG_ADDR_WL_TAIKI_TX_DESC_START_UP (0x1AD) +#define OGMA_REG_ADDR_WL_TAIKI_TX_DESC_START_LW (0x1A2) +#define OGMA_REG_ADDR_WL_TAIKI_RX_DESC_START_UP (0x1BD) +#define OGMA_REG_ADDR_WL_TAIKI_RX_DESC_START_LW (0x1B2) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_DESC_START_UP (0x1CD) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_DESC_START_LW (0x1C2) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_DESC_START_UP (0x1DD) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_DESC_START_LW (0x1D2) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_DESC_START_UP (0x1ED) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_DESC_START_LW (0x1E2) +#define OGMA_REG_ADDR_DEC_PKT_TX_DESC_START_UP (0x20D) +#define OGMA_REG_ADDR_DEC_PKT_TX_DESC_START_LW (0x202) +#define OGMA_REG_ADDR_ENC_PKT_RX_DESC_START_UP (0x21D) +#define OGMA_REG_ADDR_ENC_PKT_RX_DESC_START_LW (0x212) +#define OGMA_REG_ADDR_ENC_TLS_TX_DESC_START_UP (0x22D) +#define OGMA_REG_ADDR_ENC_TLS_TX_DESC_START_LW (0x222) +#define OGMA_REG_ADDR_DEC_TLS_TX_DESC_START_UP (0x23D) +#define OGMA_REG_ADDR_DEC_TLS_TX_DESC_START_LW (0x232) +#define OGMA_REG_ADDR_ENC_TLS_RX_DESC_START_UP (0x24D) +#define OGMA_REG_ADDR_ENC_TLS_RX_DESC_START_LW (0x242) +#define OGMA_REG_ADDR_DEC_TLS_RX_DESC_START_UP (0x25D) +#define OGMA_REG_ADDR_DEC_TLS_RX_DESC_START_LW (0x252) +#define OGMA_REG_ADDR_ENC_RAW_TX_DESC_START_UP (0x26D) +#define OGMA_REG_ADDR_ENC_RAW_TX_DESC_START_LW (0x262) +#define OGMA_REG_ADDR_DEC_RAW_TX_DESC_START_UP (0x27D) +#define OGMA_REG_ADDR_DEC_RAW_TX_DESC_START_LW (0x272) +#define OGMA_REG_ADDR_ENC_RAW_RX_DESC_START_UP (0x28D) +#define OGMA_REG_ADDR_ENC_RAW_RX_DESC_START_LW (0x282) +#define OGMA_REG_ADDR_DEC_RAW_RX_DESC_START_UP (0x29D) +#define OGMA_REG_ADDR_DEC_RAW_RX_DESC_START_LW (0x292) +#define OGMA_REG_ADDR_NRM_TX_CONFIG (0x10C) +#define OGMA_REG_ADDR_NRM_RX_CONFIG (0x11C) +#define OGMA_REG_ADDR_TAIKI_RX_CONFIG (0x12C) +#define OGMA_REG_ADDR_TAIKI_TX_CONFIG (0x13C) +#define OGMA_REG_ADDR_MISC_RX_CONFIG (0x14C) +#define OGMA_REG_ADDR_WL_NRM_TX_CONFIG (0x15C) +#define OGMA_REG_ADDR_WL_NRM_RX_CONFIG (0x16C) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_CONFIG (0x17C) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_CONFIG (0x18C) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_CONFIG (0x19C) +#define OGMA_REG_ADDR_WL_TAIKI_TX_CONFIG (0x1AC) +#define OGMA_REG_ADDR_WL_TAIKI_RX_CONFIG (0x1BC) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_CONFIG (0x1CC) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_CONFIG (0x1DC) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_CONFIG (0x1EC) +#define OGMA_REG_ADDR_DEC_PKT_TX_CONFIG (0x20C) +#define OGMA_REG_ADDR_ENC_PKT_RX_CONFIG (0x21C) +#define OGMA_REG_ADDR_ENC_TLS_TX_CONFIG (0x22C) +#define OGMA_REG_ADDR_DEC_TLS_TX_CONFIG (0x23C) +#define OGMA_REG_ADDR_ENC_TLS_RX_CONFIG (0x24C) +#define OGMA_REG_ADDR_DEC_TLS_RX_CONFIG (0x25C) +#define OGMA_REG_ADDR_ENC_RAW_TX_CONFIG (0x26C) +#define OGMA_REG_ADDR_DEC_RAW_TX_CONFIG (0x27C) +#define OGMA_REG_ADDR_ENC_RAW_RX_CONFIG (0x28C) +#define OGMA_REG_ADDR_DEC_RAW_RX_CONFIG (0x29C) +#define OGMA_REG_ADDR_DMA_TMR_CTRL (0x83) +#define OGMA_REG_ADDR_TOP_STATUS (0x80) +#define OGMA_REG_ADDR_TOP_INTEN_A (0x81) +#define OGMA_REG_ADDR_TOP_INTEN_A_SET (0x8D) +#define OGMA_REG_ADDR_TOP_INTEN_A_CLR (0x8E) +#define OGMA_REG_ADDR_TOP_INTEN_B (0x8F) +#define OGMA_REG_ADDR_TOP_INTEN_B_SET (0x90) +#define OGMA_REG_ADDR_TOP_INTEN_B_CLR (0x91) +#define OGMA_REG_ADDR_PKT_STATUS (0x3) +#define OGMA_REG_ADDR_PKT_INTEN (0x4) +#define OGMA_REG_ADDR_PKT_INTEN_SET (0x7) +#define OGMA_REG_ADDR_PKT_INTEN_CLR (0x8) +#define OGMA_REG_ADDR_TLS_STATUS (0x5) +#define OGMA_REG_ADDR_TLS_INTEN (0x6) +#define OGMA_REG_ADDR_TLS_INTEN_SET (0x9) +#define OGMA_REG_ADDR_TLS_INTEN_CLR (0xA) +#define OGMA_REG_ADDR_SLAVE_0_STATUS (0xB) +#define OGMA_REG_ADDR_SLAVE_0_INTEN (0xC) +#define OGMA_REG_ADDR_SLAVE_0_INTEN_SET (0xD) +#define OGMA_REG_ADDR_SLAVE_0_INTEN_CLR (0xE) +#define OGMA_REG_ADDR_SLAVE_1_STATUS (0xF) +#define OGMA_REG_ADDR_SLAVE_1_INTEN (0x10) +#define OGMA_REG_ADDR_SLAVE_1_INTEN_SET (0x11) +#define OGMA_REG_ADDR_SLAVE_1_INTEN_CLR (0x12) +#define OGMA_REG_ADDR_MAC_STATUS (0x409) +#define OGMA_REG_ADDR_MAC_INTEN (0x40A) +#define OGMA_REG_ADDR_MAC_TX_RX_INFO_STATUS (0x486) +#define OGMA_REG_ADDR_MAC_TX_RX_INFO_INTEN (0x487) +#define OGMA_REG_ADDR_NRM_TX_STATUS (0x100) +#define OGMA_REG_ADDR_NRM_TX_INTEN (0x101) +#define OGMA_REG_ADDR_NRM_TX_INTEN_SET (0x10A) +#define OGMA_REG_ADDR_NRM_TX_INTEN_CLR (0x10B) +#define OGMA_REG_ADDR_NRM_RX_STATUS (0x110) +#define OGMA_REG_ADDR_NRM_RX_INTEN (0x111) +#define OGMA_REG_ADDR_NRM_RX_INTEN_SET (0x11A) +#define OGMA_REG_ADDR_NRM_RX_INTEN_CLR (0x11B) +#define OGMA_REG_ADDR_TAIKI_RX_STATUS (0x120) +#define OGMA_REG_ADDR_TAIKI_RX_INTEN (0x121) +#define OGMA_REG_ADDR_TAIKI_RX_INTEN_SET (0x12A) +#define OGMA_REG_ADDR_TAIKI_RX_INTEN_CLR (0x12B) +#define OGMA_REG_ADDR_TAIKI_TX_STATUS (0x130) +#define OGMA_REG_ADDR_TAIKI_TX_INTEN (0x131) +#define OGMA_REG_ADDR_TAIKI_TX_INTEN_SET (0x13A) +#define OGMA_REG_ADDR_TAIKI_TX_INTEN_CLR (0x13B) +#define OGMA_REG_ADDR_MISC_RX_STATUS (0x140) +#define OGMA_REG_ADDR_MISC_RX_INTEN (0x141) +#define OGMA_REG_ADDR_MISC_RX_INTEN_SET (0x14A) +#define OGMA_REG_ADDR_MISC_RX_INTEN_CLR (0x14B) +#define OGMA_REG_ADDR_WL_NRM_TX_STATUS (0x150) +#define OGMA_REG_ADDR_WL_NRM_TX_INTEN (0x151) +#define OGMA_REG_ADDR_WL_NRM_TX_INTEN_SET (0x15A) +#define OGMA_REG_ADDR_WL_NRM_TX_INTEN_CLR (0x15B) +#define OGMA_REG_ADDR_WL_NRM_RX_STATUS (0x160) +#define OGMA_REG_ADDR_WL_NRM_RX_INTEN (0x161) +#define OGMA_REG_ADDR_WL_NRM_RX_INTEN_SET (0x16A) +#define OGMA_REG_ADDR_WL_NRM_RX_INTEN_CLR (0x16B) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_STATUS (0x170) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_INTEN (0x171) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_INTEN_SET (0x17A) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_INTEN_CLR (0x17B) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_STATUS (0x180) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_INTEN (0x181) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_INTEN_SET (0x18A) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_INTEN_CLR (0x18B) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_STATUS (0x190) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_INTEN (0x191) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_INTEN_SET (0x19A) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_INTEN_CLR (0x19B) +#define OGMA_REG_ADDR_WL_TAIKI_TX_STATUS (0x1A0) +#define OGMA_REG_ADDR_WL_TAIKI_TX_INTEN (0x1A1) +#define OGMA_REG_ADDR_WL_TAIKI_TX_INTEN_SET (0x1AA) +#define OGMA_REG_ADDR_WL_TAIKI_TX_INTEN_CLR (0x1AB) +#define OGMA_REG_ADDR_WL_TAIKI_RX_STATUS (0x1B0) +#define OGMA_REG_ADDR_WL_TAIKI_RX_INTEN (0x1B1) +#define OGMA_REG_ADDR_WL_TAIKI_RX_INTEN_SET (0x1BA) +#define OGMA_REG_ADDR_WL_TAIKI_RX_INTEN_CLR (0x1BB) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_STATUS (0x1C0) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_INTEN (0x1C1) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_INTEN_SET (0x1CA) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_INTEN_CLR (0x1CB) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_STATUS (0x1D0) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_INTEN (0x1D1) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_INTEN_SET (0x1DA) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_INTEN_CLR (0x1DB) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_STATUS (0x1E0) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_INTEN (0x1E1) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_INTEN_SET (0x1EA) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_INTEN_CLR (0x1EB) +#define OGMA_REG_ADDR_DEC_TX_STATUS (0x200) +#define OGMA_REG_ADDR_DEC_TX_INTEN (0x201) +#define OGMA_REG_ADDR_DEC_TX_INTEN_SET (0x20A) +#define OGMA_REG_ADDR_DEC_TX_INTEN_CLR (0x20B) +#define OGMA_REG_ADDR_ENC_RX_STATUS (0x210) +#define OGMA_REG_ADDR_ENC_RX_INTEN (0x211) +#define OGMA_REG_ADDR_ENC_RX_INTEN_SET (0x21A) +#define OGMA_REG_ADDR_ENC_RX_INTEN_CLR (0x21B) +#define OGMA_REG_ADDR_ENC_TLS_TX_STATUS (0x220) +#define OGMA_REG_ADDR_ENC_TLS_TX_INTEN (0x221) +#define OGMA_REG_ADDR_ENC_TLS_TX_INTEN_SET (0x22A) +#define OGMA_REG_ADDR_ENC_TLS_TX_INTEN_CLR (0x22B) +#define OGMA_REG_ADDR_DEC_TLS_TX_STATUS (0x230) +#define OGMA_REG_ADDR_DEC_TLS_TX_INTEN (0x231) +#define OGMA_REG_ADDR_DEC_TLS_TX_INTEN_SET (0x23A) +#define OGMA_REG_ADDR_DEC_TLS_TX_INTEN_CLR (0x23B) +#define OGMA_REG_ADDR_ENC_TLS_RX_STATUS (0x240) +#define OGMA_REG_ADDR_ENC_TLS_RX_INTEN (0x241) +#define OGMA_REG_ADDR_ENC_TLS_RX_INTEN_SET (0x24A) +#define OGMA_REG_ADDR_ENC_TLS_RX_INTEN_CLR (0x24B) +#define OGMA_REG_ADDR_DEC_TLS_RX_STATUS (0x250) +#define OGMA_REG_ADDR_DEC_TLS_RX_INTEN (0x251) +#define OGMA_REG_ADDR_DEC_TLS_RX_INTEN_SET (0x25A) +#define OGMA_REG_ADDR_DEC_TLS_RX_INTEN_CLR (0x25B) +#define OGMA_REG_ADDR_ENC_RAW_TX_STATUS (0x260) +#define OGMA_REG_ADDR_ENC_RAW_TX_INTEN (0x261) +#define OGMA_REG_ADDR_ENC_RAW_TX_INTEN_SET (0x26A) +#define OGMA_REG_ADDR_ENC_RAW_TX_INTEN_CLR (0x26B) +#define OGMA_REG_ADDR_DEC_RAW_TX_STATUS (0x270) +#define OGMA_REG_ADDR_DEC_RAW_TX_INTEN (0x271) +#define OGMA_REG_ADDR_DEC_RAW_TX_INTEN_SET (0x27A) +#define OGMA_REG_ADDR_DEC_RAW_TX_INTEN_CLR (0x27B) +#define OGMA_REG_ADDR_ENC_RAW_RX_STATUS (0x280) +#define OGMA_REG_ADDR_ENC_RAW_RX_INTEN (0x281) +#define OGMA_REG_ADDR_ENC_RAW_RX_INTEN_SET (0x28A) +#define OGMA_REG_ADDR_ENC_RAW_RX_INTEN_CLR (0x28B) +#define OGMA_REG_ADDR_DEC_RAW_RX_STATUS (0x290) +#define OGMA_REG_ADDR_DEC_RAW_RX_INTEN (0x291) +#define OGMA_REG_ADDR_DEC_RAW_RX_INTEN_SET (0x29A) +#define OGMA_REG_ADDR_DEC_RAW_RX_INTEN_CLR (0x29B) +#define OGMA_REG_ADDR_NRM_TX_PKTCNT (0x104) +#define OGMA_REG_ADDR_TAIKI_TX_PKTCNT (0x134) +#define OGMA_REG_ADDR_WL_NRM_TX_PKTCNT (0x154) +#define OGMA_REG_ADDR_WL_TAIKI_TX_PKTCNT (0x1A4) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_PKTCNT (0x174) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_PKTCNT (0x1C4) +#define OGMA_REG_ADDR_DEC_PKT_TX_PKTCNT (0x204) +#define OGMA_REG_ADDR_ENC_TLS_TX_PKTCNT (0x224) +#define OGMA_REG_ADDR_DEC_TLS_TX_PKTCNT (0x234) +#define OGMA_REG_ADDR_ENC_RAW_TX_PKTCNT (0x264) +#define OGMA_REG_ADDR_DEC_RAW_TX_PKTCNT (0x274) +#define OGMA_REG_ADDR_NRM_TX_DONE_PKTCNT (0x105) +#define OGMA_REG_ADDR_TAIKI_TX_DONE_PKTCNT (0x135) +#define OGMA_REG_ADDR_WL_NRM_TX_DONE_PKTCNT (0x155) +#define OGMA_REG_ADDR_WL_TAIKI_TX_DONE_PKTCNT (0x1A5) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_DONE_PKTCNT (0x175) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_DONE_PKTCNT (0x1C5) +#define OGMA_REG_ADDR_DEC_PKT_TX_DONE_PKTCNT (0x205) +#define OGMA_REG_ADDR_ENC_TLS_TX_DONE_PKTCNT (0x225) +#define OGMA_REG_ADDR_DEC_TLS_TX_DONE_PKTCNT (0x235) +#define OGMA_REG_ADDR_ENC_RAW_TX_DONE_PKTCNT (0x265) +#define OGMA_REG_ADDR_DEC_RAW_TX_DONE_PKTCNT (0x275) +#define OGMA_REG_ADDR_NRM_TX_DONE_TXINT_PKTCNT (0x106) +#define OGMA_REG_ADDR_TAIKI_TX_DONE_TXINT_PKTCNT (0x136) +#define OGMA_REG_ADDR_WL_NRM_TX_DONE_TXINT_PKTCNT (0x156) +#define OGMA_REG_ADDR_WL_TAIKI_TX_DONE_TXINT_PKTCNT (0x1A6) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_DONE_TXINT_PKTCNT (0x176) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_DONE_TXINT_PKTCNT (0x1C6) +#define OGMA_REG_ADDR_DEC_PKT_TX_DONE_TXINT_PKTCNT (0x206) +#define OGMA_REG_ADDR_ENC_TLS_TX_DONE_TXINT_PKTCNT (0x226) +#define OGMA_REG_ADDR_DEC_TLS_TX_DONE_TXINT_PKTCNT (0x236) +#define OGMA_REG_ADDR_ENC_RAW_TX_DONE_TXINT_PKTCNT (0x266) +#define OGMA_REG_ADDR_DEC_RAW_TX_DONE_TXINT_PKTCNT (0x276) +#define OGMA_REG_ADDR_NRM_TX_TMR (0x107) +#define OGMA_REG_ADDR_TAIKI_TX_TMR (0x137) +#define OGMA_REG_ADDR_WL_NRM_TX_TMR (0x157) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_TMR (0x177) +#define OGMA_REG_ADDR_WL_TAIKI_TX_TMR (0x1A7) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_TMR (0x1C7) +#define OGMA_REG_ADDR_DEC_TX_TMR (0x207) +#define OGMA_REG_ADDR_NRM_TX_TXINT_TMR (0x108) +#define OGMA_REG_ADDR_TAIKI_TX_TXINT_TMR (0x138) +#define OGMA_REG_ADDR_WL_NRM_TX_TXINT_TMR (0x158) +#define OGMA_REG_ADDR_WL_NRM_CMD_TX_TXINT_TMR (0x178) +#define OGMA_REG_ADDR_WL_TAIKI_TX_TXINT_TMR (0x1A8) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_TX_TXINT_TMR (0x1C8) +#define OGMA_REG_ADDR_DEC_TX_TXINT_TMR (0x208) +#define OGMA_REG_ADDR_NRM_RX_PKTCNT (0x115) +#define OGMA_REG_ADDR_TAIKI_RX_PKTCNT (0x125) +#define OGMA_REG_ADDR_MISC_RX_PKTCNT (0x145) +#define OGMA_REG_ADDR_WL_NRM_RX_PKTCNT (0x165) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_PKTCNT (0x185) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_PKTCNT (0x195) +#define OGMA_REG_ADDR_WL_TAIKI_RX_PKTCNT (0x1B5) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_PKTCNT (0x1D5) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_PKTCNT (0x1E5) +#define OGMA_REG_ADDR_ENC_PKT_RX_PKTCNT (0x215) +#define OGMA_REG_ADDR_ENC_TLS_RX_PKTCNT (0x245) +#define OGMA_REG_ADDR_DEC_TLS_RX_PKTCNT (0x255) +#define OGMA_REG_ADDR_ENC_RAW_RX_PKTCNT (0x285) +#define OGMA_REG_ADDR_DEC_RAW_RX_PKTCNT (0x295) +#define OGMA_REG_ADDR_NRM_RX_RXINT_PKTCNT (0x116) +#define OGMA_REG_ADDR_TAIKI_RXINT_PKTCNT (0x126) +#define OGMA_REG_ADDR_MISC_RXINT_PKTCNT (0x146) +#define OGMA_REG_ADDR_WL_NRM_RXINT_PKTCNT (0x166) +#define OGMA_REG_ADDR_WL_NRM_CMD_RXINT_PKTCNT (0x186) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RXINT_PKTCNT (0x196) +#define OGMA_REG_ADDR_WL_TAIKI_RXINT_PKTCNT (0x1B6) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RXINT_PKTCNT (0x1D6) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RXINT_PKTCNT (0x1E6) +#define OGMA_REG_ADDR_ENC_PKT_RXINT_PKTCNT (0x216) +#define OGMA_REG_ADDR_ENC_TLS_RXINT_PKTCNT (0x246) +#define OGMA_REG_ADDR_DEC_TLS_RXINT_PKTCNT (0x256) +#define OGMA_REG_ADDR_ENC_RAW_RXINT_PKTCNT (0x286) +#define OGMA_REG_ADDR_DEC_RAW_RXINT_PKTCNT (0x296) +#define OGMA_REG_ADDR_NRM_RX_TMR (0x117) +#define OGMA_REG_ADDR_TAIKI_RX_TMR (0x127) +#define OGMA_REG_ADDR_MISC_RX_TMR (0x147) +#define OGMA_REG_ADDR_WL_NRM_RX_TMR (0x167) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_TMR (0x187) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_TMR (0x197) +#define OGMA_REG_ADDR_WL_TAIKI_RX_TMR (0x1B7) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_TMR (0x1D7) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_TMR (0x1E7) +#define OGMA_REG_ADDR_NRM_RX_RXINT_TMR (0x118) +#define OGMA_REG_ADDR_TAIKI_RX_RXINT_TMR (0x128) +#define OGMA_REG_ADDR_MISC_RX_RXINT_TMR (0x148) +#define OGMA_REG_ADDR_WL_NRM_RX_RXINT_TMR (0x168) +#define OGMA_REG_ADDR_WL_NRM_CMD_RX_RXINT_TMR (0x188) +#define OGMA_REG_ADDR_WL_NRM_EVENT_RX_RXINT_TMR (0x198) +#define OGMA_REG_ADDR_WL_TAIKI_RX_RXINT_TMR (0x1B8) +#define OGMA_REG_ADDR_WL_TAIKI_CMD_RX_RXINT_TMR (0x1D8) +#define OGMA_REG_ADDR_WL_TAIKI_EVENT_RX_RXINT_TMR (0x1E8) +#define OGMA_REG_ADDR_PODB_CMD_ST (0x20) +#define OGMA_REG_ADDR_PODB_DATA (0x21) +#define OGMA_REG_ADDR_CLS_VAL_CMD (0x2A) +#define OGMA_REG_ADDR_CLS_VAL_DATA (0x2B) +#define OGMA_REG_ADDR_CLS_CMD_ST (0x2C) +#define OGMA_REG_ADDR_CLS_DATA (0x2D) +#define OGMA_REG_ADDR_SADB_CMD_ST (0x2E) +#define OGMA_REG_ADDR_SADB_DATA (0x2F) +#define OGMA_REG_ADDR_MAC_CMD (0x471) +#define OGMA_REG_ADDR_MAC_DATA (0x470) +#define OGMA_REG_ADDR_MAC_FLOW_TH (0x473) +#define OGMA_REG_ADDR_MAC_INTF_SEL (0x475) +#define OGMA_REG_ADDR_MAC_TX_TSTAMP_LW (0x476) +#define OGMA_REG_ADDR_MAC_TX_TSTAMP_UP (0x477) +#define OGMA_REG_ADDR_MAC_CAP_TSTAMP_UP (0x478) +#define OGMA_REG_ADDR_MAC_CAP_TSTAMP_LW (0x479) +#define OGMA_REG_ADDR_MAC_TSTAM_CAP (0x47A) +#define OGMA_REG_ADDR_MAC_SNAP_TRIG (0x47B) +#define OGMA_REG_ADDR_MAC_SEC_CNT (0x47C) +#define OGMA_REG_ADDR_MAC_DESC_INIT (0x47F) +#define OGMA_REG_ADDR_MAC_TX_TS_GET (0x480) +#define OGMA_REG_ADDR_MAC_DESC_SOFT_RST (0x481) +#define OGMA_REG_ADDR_IV_INIT_VAL (0x45) +#define OGMA_REG_ADDR_MAC_ADD_UP (0x43) +#define OGMA_REG_ADDR_MAC_ADD_LW (0x44) +#define OGMA_REG_ADDR_ST_INFO_ST_UP (0x65) +#define OGMA_REG_ADDR_ST_INFO_ST_LW (0x66) +#define OGMA_REG_ADDR_ST_INFO_SIZE (0x67) +#define OGMA_REG_ADDR_ST_INFO_TX_ST (0x68) +#define OGMA_REG_ADDR_LOGIC_GR_ID (0x69) +#define OGMA_REG_ADDR_ST_FOR_PBC (0x6A) +#define OGMA_REG_ADDR_ALARM_INFO (0x6B) +#define OGMA_REG_ADDR_MC_VER (0x8B) +#define OGMA_REG_ADDR_HW_VER (0x8C) + +#define OGMA_REG_ADDR_MODE_TRANS_COMP_STATUS (0x140) + +#endif /* OGMA_REG_F_TAIKI_H */ + diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/ogma_config.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/ogma_config.h new file mode 100644 index 000000000000..1caf64e30623 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/ogma_config.h @@ -0,0 +1,25 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef OGMA_CONFIG_H +#define OGMA_CONFIG_H + +#define OGMA_CONFIG_CLK_HZ 125000000UL +#define OGMA_CONFIG_GMAC_CLK_HZ 125000000UL +#define OGMA_CONFIG_CHECK_CLK_SUPPLY + +#define OGMA_CONFIG_USE_READ_GMAC_STAT + +#endif /* OGMA_CONFIG_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h new file mode 100644 index 000000000000..d31a9c48bafc --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h @@ -0,0 +1,263 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef PFDEP_H +#define PFDEP_H + +#include +#include +#include +#include + +#include + +extern EFI_CPU_ARCH_PROTOCOL *mCpu; + +/********************************************************************** + * Constant definitions + **********************************************************************/ +#define PFDEP_INT64_AVAILABLE + +/********************************************************************** + * Elementary type definitions + **********************************************************************/ +typedef INT8 pfdep_int8; +typedef UINT8 pfdep_uint8; +typedef INT16 pfdep_int16; +typedef UINT16 pfdep_uint16; +typedef INT32 pfdep_int32; +typedef UINT32 pfdep_uint32; +typedef INT64 pfdep_int64; +typedef UINT64 pfdep_uint64; +typedef BOOLEAN pfdep_bool; +typedef CHAR8 pfdep_char; + +#define PFDEP_TRUE ((pfdep_bool)1) +#define PFDEP_FALSE ((pfdep_bool)0) + + +/********************************************************************** + * Complex type definitions + **********************************************************************/ + +typedef enum pfdep_err_e { + PFDEP_ERR_OK = 0, + PFDEP_ERR_PARAM, + PFDEP_ERR_ALLOC, + PFDEP_ERR_INTERRUPT +} pfdep_err_t; + + +typedef struct { + LIST_ENTRY Link; + VOID *Buffer; + VOID *Mapping; + BOOLEAN RecycleForTx; + BOOLEAN Released; +} PACKET_HANDLE; + +typedef VOID *pfdep_dev_handle_t; +typedef PACKET_HANDLE *pfdep_pkt_handle_t; +typedef EFI_PHYSICAL_ADDRESS pfdep_phys_addr_t; +typedef UINT64 pfdep_cpu_addr_t; + +typedef int pfdep_hard_lock_t; +typedef int pfdep_soft_lock_t; + +typedef BOOLEAN pfdep_hard_lock_ctx_t; +typedef int pfdep_soft_lock_ctx_t; + +typedef unsigned int pfdep_debug_level_t; + +#define PFDEP_DEBUG_LEVEL_FATAL ((pfdep_debug_level_t)1) +#define PFDEP_DEBUG_LEVEL_WARNING ((pfdep_debug_level_t)2) +#define PFDEP_DEBUG_LEVEL_NOTICE ((pfdep_debug_level_t)3) +#define PFDEP_DEBUG_LEVEL_DEBUG ((pfdep_debug_level_t)4) +#define PFDEP_DEBUG_LEVEL_DEBUG_DETAILED ((pfdep_debug_level_t)5) +#define PFDEP_DEBUG_LEVEL_DEBUG_MORE_DETAILED ((pfdep_debug_level_t)6) + +/********************************************************************** + * Variable declarations + **********************************************************************/ +extern pfdep_debug_level_t pfdep_debug_level; /* defined in pfdep_uefi.c */ + + +/********************************************************************** + * Function declarations + **********************************************************************/ + +static __inline pfdep_uint32 pfdep_iomem_read(void *addr) +{ + return *((volatile pfdep_uint32 *)(addr)); +} + +static __inline void pfdep_iomem_write(void *addr, pfdep_uint32 val) +{ + *((volatile pfdep_uint32 *)(addr)) = val; + + +} + +#define pfdep_read_mem_barrier() MemoryFence() +#define pfdep_write_mem_barrier() MemoryFence() +#define pfdep_mem_barrier() MemoryFence() + +void *pfdep_malloc(pfdep_uint32 len); + +void pfdep_free(void *addr); + +pfdep_err_t pfdep_dma_malloc ( + pfdep_dev_handle_t dev_handle, + pfdep_uint32 len, + void **addr_p, + pfdep_phys_addr_t *phys_addr_p + ); + +void pfdep_dma_free ( + pfdep_dev_handle_t dev_handle, + pfdep_uint32 len, + void *addr, + pfdep_phys_addr_t phys_addr + ); + +pfdep_err_t pfdep_alloc_pkt_buf ( + pfdep_dev_handle_t dev_handle, + pfdep_uint16 len, + void **addr_p, + pfdep_phys_addr_t *phys_addr_p, + pfdep_pkt_handle_t *pkt_handle_p + ); + +void pfdep_free_pkt_buf ( + pfdep_dev_handle_t dev_handle, + pfdep_uint16 len, + void *addr, + pfdep_phys_addr_t phys_addr, + pfdep_bool last_flag, + pfdep_pkt_handle_t pkt_handle + ); + +static __inline pfdep_err_t pfdep_init_hard_lock(pfdep_hard_lock_t *hard_lock_p) +{ + (void)hard_lock_p; /* suppress compiler warning */ + return PFDEP_ERR_OK; +} + +static __inline void pfdep_uninit_hard_lock(pfdep_hard_lock_t *hard_lock_p) +{ + (void)hard_lock_p; /* suppress compiler warning */ + return; +} + +static __inline void pfdep_acquire_hard_lock ( + pfdep_hard_lock_t *hard_lock_p, /* not used */ + pfdep_hard_lock_ctx_t *ctx_p + ) +{ + (void)hard_lock_p; /* suppress compiler warning */ + + *ctx_p = SaveAndDisableInterrupts(); +} + + +static __inline void pfdep_release_hard_lock ( + pfdep_hard_lock_t *hard_lock_p, /* not used */ + pfdep_hard_lock_ctx_t *ctx_p + ) +{ + (void)hard_lock_p; /* suppress compiler warning */ + + SetInterruptState(*ctx_p); +} + +static __inline pfdep_err_t pfdep_init_soft_lock ( + pfdep_soft_lock_t *soft_lock_p + ) +{ + *soft_lock_p = 0; /* suppress compiler warning */ + + return PFDEP_ERR_OK; +} + +static __inline void pfdep_uninit_soft_lock ( + pfdep_soft_lock_t *soft_lock_p + ) +{ + (void)soft_lock_p; /* suppress compiler warning */ + + return; +} + +static __inline pfdep_err_t pfdep_acquire_soft_lock ( + pfdep_soft_lock_t *soft_lock_p, + pfdep_soft_lock_ctx_t *ctx_p + ) +{ + (void)soft_lock_p; /* suppress compiler warning */ + (void)ctx_p; /* suppress compiler warning */ + + return PFDEP_ERR_OK; +} + +static __inline void pfdep_release_soft_lock ( + pfdep_soft_lock_t *soft_lock_p, + pfdep_soft_lock_ctx_t *ctx_p + ) +{ + (void)soft_lock_p; /* suppress compiler warning */ + (void)ctx_p; /* suppress compiler warning */ +} + + +static __inline void pfdep_memcpy(void *dst_p, const void *src_p, pfdep_uint32 len) +{ + CopyMem (dst_p, src_p, (UINTN)len); +} + +static __inline void pfdep_memset(void *dst_p, pfdep_uint8 c, pfdep_uint32 len) +{ + SetMem (dst_p, (UINTN)len, c); +} + +static __inline pfdep_err_t pfdep_msleep(pfdep_uint32 wait_ms) +{ + + MicroSecondDelay ((UINTN)wait_ms * 1000); + + return PFDEP_ERR_OK; +} + +#define pfdep_print(level,...) \ +do { \ + if (level <= pfdep_debug_level) { \ + DEBUG ((DEBUG_INFO, "[NETSEC] " __VA_ARGS__)); \ + } \ +} while (0) + + +static __inline pfdep_debug_level_t pfdep_get_debug_level(void) +{ + return pfdep_debug_level; +} + +static __inline void pfdep_set_debug_level(pfdep_debug_level_t level) +{ + pfdep_debug_level = level; +} + + +#define pfdep_assert(cond) ASSERT(cond) + +#endif /* PFDEP_H */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep_uefi.c b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep_uefi.c new file mode 100644 index 000000000000..b43d1aaff037 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep_uefi.c @@ -0,0 +1,176 @@ +/** @file + + Copyright (c) 2016 - 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "pfdep.h" + +#include +#include +#include +#include +#include + +/********************************************************************** + * Variable definitions + **********************************************************************/ +pfdep_debug_level_t pfdep_debug_level = PFDEP_DEBUG_LEVEL_NOTICE; + + +/********************************************************************** + * Function definitions + **********************************************************************/ + +VOID* +pfdep_malloc ( + IN pfdep_uint32 len + ) +{ + return AllocatePool (len); +} + +VOID +pfdep_free ( + IN VOID *addr + ) +{ + FreePool (addr); +} + +pfdep_err_t +pfdep_dma_malloc ( + IN pfdep_dev_handle_t dev_handle, + IN pfdep_uint32 len, + OUT VOID **addr_p, + OUT pfdep_phys_addr_t *phys_addr_p + ) +{ + EFI_STATUS Status; + UINTN NumPages; + UINTN NumBytes; + VOID **Mapping; + + NumPages = EFI_SIZE_TO_PAGES (ALIGN_VARIABLE(len) + sizeof *Mapping); + Status = DmaAllocateBuffer (EfiBootServicesData, NumPages, addr_p); + if (EFI_ERROR (Status)) { + return PFDEP_ERR_ALLOC; + } + + // + // Stash the address of the MAPINFO struct at the end of the buffer, + // but make sure it appears aligned (the memory may be mapped uncached) + // + Mapping = (VOID **)((UINTN)*addr_p + ALIGN_VARIABLE(len)); + + NumBytes = EFI_PAGES_TO_SIZE (NumPages); + Status = DmaMap (MapOperationBusMasterCommonBuffer, *addr_p, &NumBytes, + phys_addr_p, Mapping); + + if (EFI_ERROR (Status) || NumBytes < len) { + DmaFreeBuffer (NumPages, *addr_p); + return PFDEP_ERR_ALLOC; + } + + return PFDEP_ERR_OK; +} + +VOID +pfdep_dma_free ( + IN pfdep_dev_handle_t dev_handle, + IN pfdep_uint32 len, + IN VOID *addr, + IN pfdep_phys_addr_t phys_addr + ) +{ + VOID *Mapping; + + Mapping = *(VOID **)((UINTN)addr + ALIGN_VARIABLE(len)); + + DmaUnmap (Mapping); + DmaFreeBuffer (EFI_SIZE_TO_PAGES (ALIGN_VARIABLE(len) + sizeof Mapping), + addr); +} + +// +// On the receive path, we allocate a new packet and link it into the RX ring +// before returning the received packet to the caller. This means we perform +// one allocation and one free operation for each buffer received. +// So let's cache a single packet, and get rid of most of the alloc/free +// overhead on the RX path. +// +STATIC pfdep_pkt_handle_t mSparePacketBuffer; +STATIC UINT32 mSparePacketBufferSize; + +pfdep_err_t +pfdep_alloc_pkt_buf ( + IN pfdep_dev_handle_t dev_handle, + IN pfdep_uint16 len, + OUT VOID **addr_p, + OUT pfdep_phys_addr_t *phys_addr_p, + OUT pfdep_pkt_handle_t *pkt_handle_p + ) +{ + EFI_STATUS Status; + UINTN NumBytes; + + NumBytes = ALIGN_VALUE (len, mCpu->DmaBufferAlignment); + + if (InterlockedCompareExchange32 (&mSparePacketBufferSize, len, 0) == len) { + *pkt_handle_p = mSparePacketBuffer; + } else { + *pkt_handle_p = AllocateZeroPool (NumBytes + sizeof(PACKET_HANDLE) + + (mCpu->DmaBufferAlignment - 8)); + if (*pkt_handle_p == NULL) { + return PFDEP_ERR_ALLOC; + } + + (*pkt_handle_p)->Buffer = ALIGN_POINTER (*pkt_handle_p, + mCpu->DmaBufferAlignment); + } + + *addr_p = (*pkt_handle_p)->Buffer; + Status = DmaMap (MapOperationBusMasterWrite, *addr_p, &NumBytes, phys_addr_p, + &(*pkt_handle_p)->Mapping); + if (EFI_ERROR (Status) || NumBytes < len) { + FreePool (*pkt_handle_p); + return PFDEP_ERR_ALLOC; + } + return PFDEP_ERR_OK; +} + +VOID +pfdep_free_pkt_buf ( + IN pfdep_dev_handle_t dev_handle, + IN pfdep_uint16 len, + IN VOID *addr, + IN pfdep_phys_addr_t phys_addr, + IN pfdep_bool last_flag, + IN pfdep_pkt_handle_t pkt_handle + ) +{ + if (last_flag != PFDEP_TRUE) { + return; + } + + if (pkt_handle->Mapping != NULL) { + DmaUnmap (pkt_handle->Mapping); + } + + if (pkt_handle->RecycleForTx) { + pkt_handle->Released = TRUE; + } else if (!InterlockedCompareExchange32 (&mSparePacketBufferSize, 0, len)) { + mSparePacketBuffer = pkt_handle; + } else { + FreePool (pkt_handle); + } +} From patchwork Fri Nov 10 14:20:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118536 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257657edl; Fri, 10 Nov 2017 06:22:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMbPKHqo9gBilG+PJBSDNqJ8DEz10hK3HUCDvTcs/vBVnGkCyWvuYxiYVCk/4vyrB6w+RbvT X-Received: by 10.159.206.137 with SMTP id bg9mr517005plb.95.1510323721648; Fri, 10 Nov 2017 06:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323721; cv=none; d=google.com; s=arc-20160816; b=kKG3AJkSSpZB+LrVas3SoCRc6iNsVGi1vRfajVnChX4c0S9IsRS8sDzdgh7a6GZbaL a96wFIGaIut41U/C1kuoHrA0ZE4sndYM2Eu49s0bfzqgW/3qTVAmzOYMVMKz9wzK/gws QywjZBg0gve1Y8uU77OWqRHKdqpK9AF/vLypS0jKdkQDujAhotZ2YlxOWZvlFJV/mlF3 QO3lBhkWL7x6JIkRCLaTgDOsZ2kBb9k0gUmr92CGlJOFjJz9YqkMrep72f6SEaa5sO+m OM2QOVBurN5VCQITiQmHn3P0fVrXJ7G7ISG9Dvr6zEIeBpmrRsLy3hxqrNEMWVyJqc1W gvCQ== 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=mRkclSg7SoqcJQoI18Tm8iWhlqU6Zoo3uKFrh3f3gbk=; b=pKyMSt42/xBIz39pe1aHxnPmKJrZ9mBew3Gct+j8V33uGS6Q74g+23bOUH8LTtIKoU PDn/A3yQGcNq4bvNDeoKjc/owAS5BGSTW+/0QRkjxKROAw1peOklDlp9qWxIDxzU2+M4 5IE5a8hZcRsCEMnltRQV6y6nXDgqqSy4BT/NLqCR8ceiY0Y7Pjv81H8YmdvFykuhbl1A wqiTN2xeyHkv3wQZouFPS3xHd1R+1BH9vD1sbQk1dGhe2dnZgKHneYULk7AaJWCVcWBr Z09l8ClAJ0h0B0HgqeVPZv+1Ol5cW7z0gA152ncccbsssBcQKflKnRAMjVaUXdsk9xvu eXDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XtEayIQw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id w11si9750456plq.805.2017.11.10.06.22.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XtEayIQw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 0AE992035522C; Fri, 10 Nov 2017 06:17:58 -0800 (PST) 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=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 5A9D621B00DC8 for ; Fri, 10 Nov 2017 06:17:56 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id k61so8744318wrc.4 for ; Fri, 10 Nov 2017 06:21:59 -0800 (PST) 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=P/tdm3SiCEkh4UACJCMKTJ86wKzG+V8L7SY7FRldEDc=; b=XtEayIQwzRCNKC+J5ZXdjIzwPr1fkb60fsG+mmfFksH9qA4cdC2brVLTV5rgFOWUoH eG2S89dCjAkt74gUTFxMdy6eJv6ZsJcBOizKNJKbjlYqzQiFFuMIxsVcv90E2ZnKyogR ofFm85qMITRttce3jpm2mdJVGtYZGqYzqWJzo= 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=P/tdm3SiCEkh4UACJCMKTJ86wKzG+V8L7SY7FRldEDc=; b=D7UT6zk8omaMsHdgg3adn3ezoges0W3vVVHbcSPEBxNMuJIjONsnL9S2sVUQWIYrp4 yswYApugO8lpv9BZCFotm6MYDRZRsWyE0qyxCMaxwuKcwz9VhEVgSMGvRlAqVQFlo0uv KxSf//MEA1E5f3p9IVxkkOZX3VjsH8ADkFz0xhcWXh3FV/eeydPiILiEFDtbnpztP+qs PYs/b6mahc0iyrHtLBH40ncc0o5eR7IbsO1VaQfDx7Lnfi5IhThkbFumuSSnGsam/jQf /lzyax8ibPauMcQHje5FOVxKFChDpqtolalkGH4wi1Vvg/PFW2RFs4JfQtil5qD8NZCt RrWQ== X-Gm-Message-State: AJaThX5V9e4gmq1jBoa3HxA9fePEFryibC3vTuMK5QI7vUKLnGxmS2uL uKSxSBHObqIWQFDkp9znLx2h61LzkSc= X-Received: by 10.223.156.138 with SMTP id d10mr474791wre.214.1510323717398; Fri, 10 Nov 2017 06:21:57 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:56 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:56 +0000 Message-Id: <20171110142127.12018-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 03/34] Silicon/Socionext: add PlatformPeilib implementation for SynQuacer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Create a specialized PlatformPeiLib implementation that invokes the platform specific firmware interface (currently, just a data structure left in SRAM) to set the ARM standard PcdSystemMemoryBase|Size PCDs, and expose the information via a newly added DramInfo PPI. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- v4: remove code to copy the compressed FV to DRAM, this is no longer necessary now that we have figured out how to map the NOR flash cacheable Silicon/Socionext/SynQuacer/Include/Platform/DramInfo.h | 30 +++++ Silicon/Socionext/SynQuacer/Include/Ppi/DramInfo.h | 64 ++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c | 123 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf | 50 ++++++++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 9 ++ 5 files changed, 276 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/DramInfo.h b/Silicon/Socionext/SynQuacer/Include/Platform/DramInfo.h new file mode 100644 index 000000000000..f7691bdade4a --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Include/Platform/DramInfo.h @@ -0,0 +1,30 @@ +/** @file + Data structure for passing DRAM information from lower level firmware + + Copyright (c) 2017, Linaro Ltd. 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. + +**/ + +#ifndef _SYNQUACER_PLATFORM_DRAM_INFO_H_ +#define _SYNQUACER_PLATFORM_DRAM_INFO_H_ + +typedef struct { + UINT64 Base; + UINT64 Size; +} DRAM_INFO_ENTRY; + +typedef struct { + UINT32 NumRegions; + UINT32 Reserved; + DRAM_INFO_ENTRY Entry[3]; +} DRAM_INFO; + +#endif diff --git a/Silicon/Socionext/SynQuacer/Include/Ppi/DramInfo.h b/Silicon/Socionext/SynQuacer/Include/Ppi/DramInfo.h new file mode 100644 index 000000000000..6453e121317d --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Include/Ppi/DramInfo.h @@ -0,0 +1,64 @@ +/** @file + DRAM info PPI to retrieve DRAM information from lower level firmware + + Copyright (c) 2017, Linaro Ltd. 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. + +**/ + +#ifndef _SYNQUACER_DRAMINFO_PPI_ +#define _SYNQUACER_DRAMINFO_PPI_ + +#define SYNQUACER_DRAMINFO_PPI_GUID \ + { 0x3e1d7356, 0xdda4, 0x4b1a, { 0x93, 0x46, 0xbf, 0x89, 0x1c, 0x86, 0x46, 0xcc } } + +/** + Retrieve the number of discontiguous DRAM regions + + @param[out] RegionCount The number of available DRAM regions + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER RegionCount == NULL + +**/ +typedef +EFI_STATUS +(EFIAPI * DRAMINFO_GET_REGION_COUNT) ( + OUT UINTN *RegionCount + ); + +/** + Retrieve the base and size of a DRAM region + + @param[in] RegionIndex The 0-based index of the region to retrieve + @param[out] Base The base of the requested region + @param[out] Size The size of the requested region + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER Base == NULL or Size == NULL + @retval EFI_NOT_FOUND No region exists with index >= RegionIndex + +**/ +typedef +EFI_STATUS +(EFIAPI * DRAMINFO_GET_REGION) ( + IN UINTN RegionIndex, + OUT UINT64 *Base, + OUT UINT64 *Size + ); + +typedef struct { + DRAMINFO_GET_REGION_COUNT GetRegionCount; + DRAMINFO_GET_REGION GetRegion; +} SYNQUACER_DRAM_INFO_PPI; + +extern EFI_GUID gSynQuacerDramInfoPpiGuid; + +#endif diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c new file mode 100644 index 000000000000..358dd5a91f08 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c @@ -0,0 +1,123 @@ +/** @file +* +* Copyright (c) 2011-2014, ARM 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 +#include +#include + +STATIC +CONST DRAM_INFO *mDramInfo = (VOID *)(UINTN)FixedPcdGet64 (PcdDramInfoBase); + +/** + Retrieve the number of discontiguous DRAM regions + + @param[out] RegionCount The number of available DRAM regions + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER RegionCount == NULL + +**/ +STATIC +EFI_STATUS +EFIAPI +GetDramRegionCount ( + OUT UINTN *RegionCount + ) +{ + if (RegionCount == NULL) { + return EFI_INVALID_PARAMETER; + } + + *RegionCount = mDramInfo->NumRegions; + + return EFI_SUCCESS; +} + +/** + Retrieve the base and size of a DRAM region + + @param[in] RegionIndex The 0-based index of the region to retrieve + @param[out] Base The base of the requested region + @param[out] Size The size of the requested region + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER Base == NULL or Size == NULL + @retval EFI_NOT_FOUND No region exists with index >= RegionIndex + +**/ +STATIC +EFI_STATUS +EFIAPI +GetDramRegion ( + IN UINTN RegionIndex, + OUT UINT64 *Base, + OUT UINT64 *Size + ) +{ + if (Base == NULL || Size == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (RegionIndex >= mDramInfo->NumRegions) { + return EFI_NOT_FOUND; + } + + *Base = mDramInfo->Entry[RegionIndex].Base; + *Size = mDramInfo->Entry[RegionIndex].Size; + + return EFI_SUCCESS; +} + +STATIC SYNQUACER_DRAM_INFO_PPI mDramInfoPpi = { + GetDramRegionCount, + GetDramRegion +}; + +STATIC CONST EFI_PEI_PPI_DESCRIPTOR mDramInfoPpiDescriptor = { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gSynQuacerDramInfoPpiGuid, + &mDramInfoPpi +}; + +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ) +{ + EFI_STATUS Status; + + ASSERT (mDramInfo->NumRegions > 0); + + // + // Record the first region into PcdSystemMemoryBase and PcdSystemMemorySize. + // This is the region we will use for UEFI itself. + // + Status = PcdSet64S (PcdSystemMemoryBase, mDramInfo->Entry[0].Base); + ASSERT_EFI_ERROR (Status); + + Status = PcdSet64S (PcdSystemMemorySize, mDramInfo->Entry[0].Size); + ASSERT_EFI_ERROR (Status); + + BuildFvHob (FixedPcdGet64 (PcdFvBaseAddress), FixedPcdGet32 (PcdFvSize)); + + return PeiServicesInstallPpi (&mDramInfoPpiDescriptor); +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf new file mode 100644 index 000000000000..70eb715d44e3 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf @@ -0,0 +1,50 @@ +#/** @file +# +# Copyright (c) 2017, Linaro, Ltd. 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 = SynQuacerPlatformPeiLib + FILE_GUID = 86537337-b62b-4dcd-846f-033a6a8355e0 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = PlatformPeiLib + +[Sources] + SynQuacerPlatformPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + HobLib + MemoryAllocationLib + PcdLib + PeiServicesLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmTokenSpaceGuid.PcdFvSize + gSynQuacerTokenSpaceGuid.PcdDramInfoBase + +[Ppis] + gSynQuacerDramInfoPpiGuid ## PRODUCES + +[Pcd] + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmTokenSpaceGuid.PcdSystemMemorySize diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec index c3adf85d3562..1249ce688600 100644 --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -18,3 +18,12 @@ [Defines] [Includes] Include + +[Guids] + gSynQuacerTokenSpaceGuid = { 0x4d04555b, 0xdfdc, 0x418a, { 0x8a, 0xab, 0x07, 0xce, 0xef, 0x46, 0x82, 0xbb } } + +[Ppis] + gSynQuacerDramInfoPpiGuid = { 0x3e1d7356, 0xdda4, 0x4b1a, { 0x93, 0x46, 0xbf, 0x89, 0x1c, 0x86, 0x46, 0xcc } } + +[PcdsFixedAtBuild] + gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0|UINT64|0x00000001 From patchwork Fri Nov 10 14:20:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118538 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257788edl; Fri, 10 Nov 2017 06:22:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMYwIP6hxw20pAeA35c73Mac22+rlNqgK+NaGOV2acSLyy6MQZc44bf9J+fVVEM5DGHx1hdY X-Received: by 10.98.202.131 with SMTP id y3mr528564pfk.199.1510323729382; Fri, 10 Nov 2017 06:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323729; cv=none; d=google.com; s=arc-20160816; b=cN4KEOWwOBhMRcNgQhjw0kc4Y/9MYgkmp6OVaowwb25MIoY49gPzjOJkiz6eESX8DE 5szyd4vmP+86K6IeUECoBgi0d5FF2NtxG7OGj3OiaIKQJb+JzDbfjWs5YBIM0QjEPLhE NsMMeI1xV1+Yl2Ivpdm1vLmrvCLKmHoK45PCNiEltlQ1yJJkANhK6poVyQSwW46RHNfN 3Go/7A0SUt4LQZ9klfx4Z91tfSyjVpV8ihxS3gk/bt35bNPbwfj0HD3Ns3x1HoxKWqgA WlLT0Mfe+RZwpMXbuwck0M5VdT2qnvr0Sfb7hEaiEtXp+H3IqqBiKsiBI/DfVfmvc6At OzfQ== 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=eG7hBLLz3pNtma9al1Sh5+DjYyPED1S3Qx6oLZ2J3tU=; b=XYTGFfAQxYBmNMCMl5m77Iztk9gNr3tUsz/rfgYhP4nIAyROEVIw4vMHpeEsbPlM2M C0nbTaAb1BTwzJF/8LWZOKujjul2qn1cfMTJ/TuSOj4rX/xAB1SpE7EOel7L+J1KxoxW Vr7paDkLjxPqpMbZI+D+eFDcFWgFmyFbKwrRBRLraSJQg2i8va20svKjLU7SITKD55ir lOmxH+Q0yNqKgp51vRNuH39WZCJ4P7eMAO4aiecHaiUh0mjbdHH/g39HkqRksUCvh1mB q1kF+gZHd/y+XKAeh3SDh5B4FfTCrRqtkGmaccvHlMjLp/QfDl7nwjWXRAKBRAgL01X+ wtmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I3akhPv/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id z188si8602244pgb.121.2017.11.10.06.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I3akhPv/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 CD90721B00DCC; Fri, 10 Nov 2017 06:17:59 -0800 (PST) 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=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 F2F8A2035521F for ; Fri, 10 Nov 2017 06:17:58 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id r68so6055198wmr.0 for ; Fri, 10 Nov 2017 06:22:01 -0800 (PST) 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=/1fqbGb9r6GsQY8j9YGPb5EXzLZFFkjBUbuaMa2wm1E=; b=I3akhPv/gHKIhBwMeumE+heZ48Z6eAMk19aDDas8pDDtYI+FA/RvzI/71sNX48E0Ax g/XQhlwsNwUMLcBmWiU0Bhr+SvTmR6l0OkCNLQmC6jzr8TyMEv2voF77ZixWDJPQhDMM m1zufeKEybu01tCBVX5DMufq3Reg1ali6zUmE= 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=/1fqbGb9r6GsQY8j9YGPb5EXzLZFFkjBUbuaMa2wm1E=; b=pnE3zS6CGMHIk2+Q9qliLk9Jm9LYq8Q4jUfNxLa23AkDZkecbjSE4hw35M0q2CW7X+ CSyI72/Sdq547j+dwlRNGCe6FKs+4L75yPupfKfGGNKrLtAAGeRHz1aSsU9Vpui5Ph9E t5jtSDJOPuDFYE+OyCZBSPXrP/ps/tQD60G8/3Gpn1pTSwGV85bUqUMvRRf6xi9ZybTb ofT0UzkRSpSjl7Dxfc4B2OBJ1a493iHgOwf6SHpqrkKS0wfDOnoVdG+XEq6wqu2TLf+L H4ZigN3ARdcwysSRWP6UlBje5sv0WWcG1KubchDIm+nrwAbjkJo+tpFle3rO03ooCQdM cAyA== X-Gm-Message-State: AJaThX5B7/7jftCWfqbSo0XXrfH4dOa0dRg7umOvsz6tx1XM5GAHiqPG 0/SbTiu5XouFD3G7l2yCidlQ6a+W9bM= X-Received: by 10.28.193.66 with SMTP id r63mr375449wmf.18.1510323719888; Fri, 10 Nov 2017 06:21:59 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:59 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:57 +0000 Message-Id: <20171110142127.12018-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 04/34] Silicon/SynQuacer: implement a platform DXE driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This implements a driver that will take care of platform specific initialization, such as declaring non-discoverable devices, and installing the device tree blob as a configuration table. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 122 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 55 +++++++++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 3 + 3 files changed, 180 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c new file mode 100644 index 000000000000..9639ffffc09f --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -0,0 +1,122 @@ +/** @file + SynQuacer DXE platform driver. + + Copyright (c) 2017, Linaro, Ltd. 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 + +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mNetsecDesc[] = { + { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + SYNQUACER_NETSEC1_BASE, // AddrRangeMin + SYNQUACER_NETSEC1_BASE + + SYNQUACER_NETSEC1_BASE_SZ - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_NETSEC1_BASE_SZ, // AddrLen + }, { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + FixedPcdGet32 (PcdNetsecEepromBase), // AddrRangeMin + FixedPcdGet32 (PcdNetsecEepromBase) + + SYNQUACER_EEPROM_BASE_SZ - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_EEPROM_BASE_SZ, // AddrLen + }, { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + FixedPcdGet32 (PcdNetsecPhyAddress), // AddrRangeMin + FixedPcdGet32 (PcdNetsecPhyAddress), // AddrRangeMax + 0, // AddrTranslationOffset + 1, // AddrLen + }, { + ACPI_END_TAG_DESCRIPTOR // Desc + } +}; + +STATIC +EFI_STATUS +RegisterNetsec ( + VOID + ) +{ + NON_DISCOVERABLE_DEVICE *Device; + EFI_STATUS Status; + EFI_HANDLE Handle; + + Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device)); + if (Device == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Device->Type = &gNetsecNonDiscoverableDeviceGuid; + Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent; + Device->Resources = mNetsecDesc; + + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces (&Handle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, Device, + NULL); + if (EFI_ERROR (Status)) { + goto FreeDevice; + } + return EFI_SUCCESS; + +FreeDevice: + FreePool (Device); + + return Status; +} + +EFI_STATUS +EFIAPI +PlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + VOID *Dtb; + UINTN DtbSize; + + Dtb = NULL; + Status = DtPlatformLoadDtb (&Dtb, &DtbSize); + if (!EFI_ERROR (Status)) { + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb); + } + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: failed to install FDT configuration table - %r\n", __FUNCTION__, + Status)); + } + + return RegisterNetsec (); +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf new file mode 100644 index 000000000000..25e6248f1c61 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -0,0 +1,55 @@ +## @file +# +# Component description file for the SynQuacer DXE platform driver. +# +# Copyright (c) 2017, Linaro, Ltd. 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 = PlatformDxe + FILE_GUID = ac422cc1-d916-489a-b165-536fdfc633c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformDxeEntryPoint + +[Sources] + PlatformDxe.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DtPlatformDtbLoaderLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Guids] + gFdtTableGuid + gNetsecNonDiscoverableDeviceGuid + +[Protocols] + gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES + +[FixedPcd] + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress + +[Depex] + TRUE diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec index 1249ce688600..1a683b81521b 100644 --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -27,3 +27,6 @@ [Ppis] [PcdsFixedAtBuild] gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0|UINT64|0x00000001 + + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0|UINT32|0x00000002 + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|0|UINT8|0x00000003 From patchwork Fri Nov 10 14:20:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118539 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257868edl; Fri, 10 Nov 2017 06:22:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMYYeW19j4H6bzc/l/ZVrXChSm1DNbh0B+CmGf+/0Fd/Lp99GrGqOEuKRetIHpVvPWIk+GID X-Received: by 10.159.211.67 with SMTP id g3mr512676plp.381.1510323734505; Fri, 10 Nov 2017 06:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323734; cv=none; d=google.com; s=arc-20160816; b=AbuQz2Y1qLAisF9XDqQKRFueaZIEGwyGifTbunkJhYnlu2SPRi9IGPI/LPwPUbI9SN tFdRw2nwI1nbVOj8UOSyg8QY1cSrz8gQYgNirvkrMhOLFn2ww+xJDeIddeRsvpzrOPyF KojAxXktUoezkY40xmZMEXv/WVZDDy7pofux7+/q0l2i4Cg/yuChKEf49gWEMSZ5W2qv MisJFa5nEizGwj0h6YHEyb6O0e90UDQFM1Prh+xQ4SCaHhiBg9CGivsbuBTW3fMuOeG2 2haCyAeqPguigwTiK93bg5BrvxESgCLwZUQDN1bIDY57zYNxaYBwJmNdZtpqR9KEsfgu PNtA== 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=VqjFn9AQIB3Yffc16F82qvax/TBslrjgf6V1S+RZmjU=; b=aHgw5JWiY3kbanSyXscRway+WelUqzyKrNUhtBe5YqPzb8YPNqdl/UVnCQJMD1nvve Cv/FOr4eUDWorRtxip4YTV65aBMtqUaBxmRiGhJWNHtUPk+ckEyk92rdKVyswR06o4Gi +cWJ3kL+BcCzYagLkMXm06bisjgNjh5vNGyiaokjnddB1CKzNqf5FF0fyMeI6GvksLOZ cS1SwLL/1MUsJ1b7F2LcHEnQvjNZa4bhjNoB24dlZLVmVC8aP8qAIga0RF2ir+Nzd19+ WyXNQLollbFhO9/bm/zz7KPCjMbiAk9ZbkpjI/tCKSN2t0+C+rgVN7KL3C+lau0NUQL4 YfCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eNg0HiYm; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id d24si6999310pls.749.2017.11.10.06.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eNg0HiYm; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 167CC20355233; Fri, 10 Nov 2017 06:18:02 -0800 (PST) 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=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::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 AC58121B00DD1 for ; Fri, 10 Nov 2017 06:18:00 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id p96so8730408wrb.7 for ; Fri, 10 Nov 2017 06:22:03 -0800 (PST) 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=U67r50UwZSV/fEsjjvwoEwhQu1TSMUrN2gYfR6y8SOg=; b=eNg0HiYmE7LPeBG+mBhlLNfTkHb7iG7fC/6f2mrV4wdm9ENTVtyjcoNsxb/uX6DjZg LkmbtgxgJg2NuGlWY/tM33oAti6wf21tDJDj0z8AoWy7ZYuFltg/3r2hO1FGFFbKeQYF h5nlHPKlXkIJCEGn9w/sfd4yfMsNB4Q3FmpS0= 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=U67r50UwZSV/fEsjjvwoEwhQu1TSMUrN2gYfR6y8SOg=; b=kWTyKyOEcGGL7CZF51wqyXTPqf6sGapeIAPtTwTv7oMxSklvtz9gV4GwqZ163CbZ4G fMd8HrpAZz0dCbINn6HTril4fgN1fVG4NOCbGwPPTY6Zn49eIl29h1X1gRL0f4WVfu4Q Nrj3ci48TtnnZedjBssuVGwt12BGc0v+L+ImTBln6JOqASiN6Pcp1u+JE+OBFdw/4i+l YbCYq8788J7TdbASbvysqwAOLzuCH1iduyGiSd1c76cikxs+z1SR8RGwAzlyzBbhlGzh 05YTpEyBW3bTGkJGBp9IH93mrRiTVXLDSF9QrqujOAS64ReA4Av/9VB4ExxXg2s6xAEs y4iA== X-Gm-Message-State: AJaThX7ColhOmACGR2cm8laGmfRGfEe+mEh3nR5d4KsCEHfcWxl4tTju 7f4kooJISeQY+zSTFPo4iOwf8a24kU0= X-Received: by 10.223.179.194 with SMTP id x2mr486025wrd.266.1510323721998; Fri, 10 Nov 2017 06:22:01 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:01 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:58 +0000 Message-Id: <20171110142127.12018-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 05/34] Silicon/SynQuacer: add MemoryInitPeiLib implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement MemoryInitPeiLib based on the newly added DramInfo PPI, which retrieves the DRAM information from lower level firmware. Note that the firmware volumes in SPI NOR are mapped with different attributes: the FV containing the PEI modules that may execute in place is mapped as uncached memory, given that it requires executable permissions. The FV containing the compressed DXE modules is mapped with device attributes for performance (!), and copied into DRAM by the platform PEIM once permanent memory is installed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- v4: use non-shareable writeback cacheable memory type for SPI NOR and EEPROM add GPIO block Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 186 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf | 65 +++++++ 2 files changed, 251 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c new file mode 100644 index 000000000000..30b42080d515 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -0,0 +1,186 @@ +/** @file +* +* Copyright (c) 2011-2015, ARM Limited. All rights reserved. +* Copyright (c) 2017, Linaro, Ltd. 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 + +#include +#include + +#include + +#define ARM_MEMORY_REGION(Base, Size) \ + { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK } + +#define ARM_UNCACHED_REGION(Base, Size) \ + { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED } + +#define ARM_DEVICE_REGION(Base, Size) \ + { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_DEVICE } + +#define ARM_CACHED_DEVICE_REGION(Base, Size) \ + { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE } + +VOID +BuildMemoryTypeInformationHob ( + VOID + ); + +STATIC CONST EFI_RESOURCE_ATTRIBUTE_TYPE mDramResourceAttributes = + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED; + +STATIC CONST ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = { + // Memory mapped SPI NOR flash + ARM_CACHED_DEVICE_REGION (FixedPcdGet64 (PcdFdBaseAddress), + FixedPcdGet32 (PcdFdSize)), + + // SynQuacer OnChip peripherals + ARM_DEVICE_REGION (SYNQUACER_PERIPHERALS_BASE, + SYNQUACER_PERIPHERALS_SZ), + + // SynQuacer OnChip non-secure SRAM + ARM_CACHED_DEVICE_REGION (SYNQUACER_NON_SECURE_SRAM_BASE, + SYNQUACER_NON_SECURE_SRAM_SZ), + + // SynQuacer GIC-500 + ARM_DEVICE_REGION (SYNQUACER_GIC500_DIST_BASE, SYNQUACER_GIC500_DIST_SIZE), + ARM_DEVICE_REGION (SYNQUACER_GIC500_RDIST_BASE, SYNQUACER_GIC500_RDIST_SIZE), + + // SynQuacer eMMC(SDH30) + ARM_DEVICE_REGION (SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ), + + // SynQuacer GPIO block + ARM_DEVICE_REGION (SYNQUACER_GPIO_BASE, SYNQUACER_GPIO_SIZE), + + // SynQuacer EEPROM - could point to NOR flash as well + ARM_CACHED_DEVICE_REGION (FixedPcdGet32 (PcdNetsecEepromBase), + SYNQUACER_EEPROM_BASE_SZ), + + // SynQuacer NETSEC + ARM_DEVICE_REGION (SYNQUACER_NETSEC1_BASE, SYNQUACER_NETSEC1_BASE_SZ), + + // PCIe control registers + ARM_DEVICE_REGION (SYNQUACER_PCIE_BASE, SYNQUACER_PCIE_SIZE), + + // PCIe config space + ARM_DEVICE_REGION (SYNQUACER_PCI_SEG0_CONFIG_BASE, + SYNQUACER_PCI_SEG0_CONFIG_SIZE), + ARM_DEVICE_REGION (SYNQUACER_PCI_SEG1_CONFIG_BASE, + SYNQUACER_PCI_SEG1_CONFIG_SIZE), + + // PCIe I/O space + ARM_DEVICE_REGION (SYNQUACER_PCI_SEG0_PORTIO_MEMBASE, + SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE), + ARM_DEVICE_REGION (SYNQUACER_PCI_SEG1_PORTIO_MEMBASE, + SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE), +}; + +STATIC +EFI_STATUS +DeclareDram ( + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryTable + ) +{ + SYNQUACER_DRAM_INFO_PPI *DramInfo; + EFI_STATUS Status; + UINTN Idx; + UINTN RegionCount; + UINT64 Base; + UINT64 Size; + ARM_MEMORY_REGION_DESCRIPTOR *DramDescriptor; + + Status = PeiServicesLocatePpi (&gSynQuacerDramInfoPpiGuid, 0, NULL, + (VOID **)&DramInfo); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = DramInfo->GetRegionCount (&RegionCount); + if (EFI_ERROR (Status)) { + return Status; + } + + *VirtualMemoryTable = AllocatePool (sizeof (mVirtualMemoryTable) + + (RegionCount + 1) * + sizeof (ARM_MEMORY_REGION_DESCRIPTOR)); + if (*VirtualMemoryTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyMem (*VirtualMemoryTable, mVirtualMemoryTable, + sizeof (mVirtualMemoryTable)); + + DramDescriptor = *VirtualMemoryTable + ARRAY_SIZE (mVirtualMemoryTable); + + for (Idx = 0; Idx < RegionCount; Idx++, DramDescriptor++) { + Status = DramInfo->GetRegion (Idx, &Base, &Size); + ASSERT_EFI_ERROR (Status); + + BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, + mDramResourceAttributes, Base, Size); + + DramDescriptor->PhysicalBase = Base; + DramDescriptor->VirtualBase = Base; + DramDescriptor->Length = Size; + DramDescriptor->Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; + } + + DramDescriptor->PhysicalBase = 0; + DramDescriptor->VirtualBase = 0; + DramDescriptor->Length = 0; + DramDescriptor->Attributes = 0; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +MemoryPeim ( + IN EFI_PHYSICAL_ADDRESS UefiMemoryBase, + IN UINT64 UefiMemorySize + ) +{ + EFI_STATUS Status; + ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; + + Status = DeclareDram (&VirtualMemoryTable); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = ArmConfigureMmu (VirtualMemoryTable, NULL, NULL); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) { + // Optional feature that helps prevent EFI memory map fragmentation. + BuildMemoryTypeInformationHob (); + } + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf new file mode 100644 index 000000000000..161072a33d99 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf @@ -0,0 +1,65 @@ +#/** @file +# +# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2017, Linaro, Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerMemoryInitPeiLib + FILE_GUID = c69d3ce7-098c-4fcd-afb4-15fb05a39308 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = MemoryInitPeiLib|SEC PEIM + +[Sources] + SynQuacerMemoryInitPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + ArmLib + ArmMmuLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + PeiServicesLib + +[FeaturePcd] + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdBaseAddress + gArmTokenSpaceGuid.PcdFdSize + gArmTokenSpaceGuid.PcdGicDistributorBase + gArmTokenSpaceGuid.PcdGicRedistributorsBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase + +[Pcd] + gArmTokenSpaceGuid.PcdSystemMemoryBase + +[Ppis] + gSynQuacerDramInfoPpiGuid ## CONSUMES + +[Depex] + gSynQuacerDramInfoPpiGuid From patchwork Fri Nov 10 14:20:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118540 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257964edl; Fri, 10 Nov 2017 06:22:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMb+cS888CEeKuCTC8KRrsloY4ww36S4VUrF+BipRujRXEC7OCMRW12k1J0+5UJwd5XyOx1V X-Received: by 10.98.71.194 with SMTP id p63mr580472pfi.26.1510323738531; Fri, 10 Nov 2017 06:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323738; cv=none; d=google.com; s=arc-20160816; b=MwrBvt9Sl9raq7edH4ut8hvc12/Bd/RVl8rf6jbmQIem9FaRFez6Es6VftDoiPFNp9 /0vqJxx+LBwQKgW0Vd25fNI55PPnuXYjVR0Sc5TLwBr2cIJDZMq2uJ4KJ2EDLB5XAjuw 6C8kHKvF+clMjeUnenD34EGEPNd+V6x0/c5cq3BJvO19UYOVUA4q/NQJVSY+6op5GCjD +Gen79rpY/uZphSXqvMRPuHgJ0I/qniSGo34+uXvYkUdRlRFx8L+1ZIHGs8NKJjrLlx+ JAxTpIVrUBenAsAT1n1WlJp0YbaT9dUXafKjYC/cx7auHTWTzQqtjkGKoXxxb9etKsHJ lY7g== 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=nW0gEjaiXuTJw7nx9H53ii813sAYfStSvLtKjX5BPb8=; b=K5PT/mWgSEr6YZlYjXXhOJs4HHrCU3x3Sw4cWRnI2q5BuCeszPL0t2PGu4JTlc57lj qEgFkdNF7PzB3RfEQ7wVP7bKh+t+KcRPlfk5AzcHzbpClVZFcahJsD9uwM6NOyQoG2gl L3sLxjwQN+CM8OLbxTL+ozEUswHkuqWD6FP7Gw8iS7SY02NVNkZoNgDmfN3IY34wj1wD ra8Y0ph5qTrenQ6U6QeMpfmCdb3kUIAS2CpAtrN0+txDLopfndEiALrmC/xRO/f3P9tm TQqWLKzaJpK7fkch+oE3QkMAyT2Tbs/zP2+b1BBpUWdqgs1qwuqQgwVQw3vCrFiNkt+6 VZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G8yq/TPh; 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 d127si8805303pgc.372.2017.11.10.06.22.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:18 -0800 (PST) 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=G8yq/TPh; 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 543B8203555E5; Fri, 10 Nov 2017 06:18:06 -0800 (PST) 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=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 03DD321B00DD1 for ; Fri, 10 Nov 2017 06:18:03 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id u97so8769005wrc.1 for ; Fri, 10 Nov 2017 06:22:07 -0800 (PST) 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=zh6iJ68dwouT2JugMBN+SSYvfc9gZcJFuJ3AwEjSzjw=; b=G8yq/TPhuh2tGqMsVKCVAJ4efUeYsL8aDGJ4/fP0zJg6jqIaxPZMrYcXwser2RM4A5 oLJ458F5drRBFcDlIVY9la6jBLhWyT9lKUQtiSfN37ggcu/MJbO9sFjDsPpi0hZxqtm0 91/cw1Uh/mJL54pWX/tW3r29hzLbcqdK/cs/M= 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=zh6iJ68dwouT2JugMBN+SSYvfc9gZcJFuJ3AwEjSzjw=; b=mQ0xh/vqzHAbmTUWv6NUdhV43QhHUBmfNfj12jzHUFYebXnC9unLY/oHj4UMj0ovdy 1/v8CFXFcNzrFVBBWUEowkRFQx+7Mwq8sD0zSM1TaXtQysL20OPPt1vYnKzBBiUz4goF 4ZCgldkqhdhxgKam022YfC64yEKqZQDLkkOppkTPzrAmgtsWz48btqaZaao5gfF+Sbz/ yBjxb/TluWvb6483M4kxZh4p8yePffO4btqabble2swJnIwAQ1T4JJNADEob/Uypkp7I bcQ3cKwiOoQdrOwekK+eEXWvaF5d1FOx4XO6S2iWJuy0wHOZnHN6l4B0nVJHNMk0kNHj n/gA== X-Gm-Message-State: AJaThX5qoZxUVjpXgZLfBZkecDsvMEBd6kmr5qnrrgOiwKp1od6t3Q9+ ObjGqNrLQGLmcDfPot9URhmh1JO3VGA= X-Received: by 10.223.162.152 with SMTP id s24mr478832wra.151.1510323724640; Fri, 10 Nov 2017 06:22:04 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:03 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:59 +0000 Message-Id: <20171110142127.12018-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 06/34] Platform: add support for Socionext SynQuacer eval board X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This is a barebones port based on the .DSC/.FDF and ArmPlatformLib code provided by Socionext. It can boot into the UiApp menu screen or the UEFI Shell, but lacks support for any peripherals. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 440 ++++++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 273 ++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerLib/AArch64/SynQuacerHelper.S | 87 ++++ Silicon/Socionext/SynQuacer/Library/SynQuacerLib/Arm/SynQuacerHelper.S | 87 ++++ Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacer.c | 125 ++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf | 43 ++ 6 files changed, 1055 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc new file mode 100644 index 000000000000..59c55fe13af1 --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -0,0 +1,440 @@ +# +# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2017, 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 Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + PLATFORM_NAME = SynQuacerEvalBoard + PLATFORM_GUID = a8180daa-fb8b-11e5-ab24-9fc3167c073d + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x0001001B + OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME) + SUPPORTED_ARCHITECTURES = AARCH64|ARM + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + FLASH_DEFINITION = Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf + +[BuildOptions] + RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 + +[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION] + GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 + +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] + GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000 + GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000 + +[LibraryClasses.common] + ArmPlatformLib|Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf + ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + + TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf + +!if $(TARGET) == RELEASE + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!else + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!endif + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + + BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf + + # Networking Requirements + NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf + DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf + UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf + IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf + + # ARM Architectural Libraries + CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf + DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf + CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf + ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf + ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf + ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf + + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf + PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf + CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf + UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf + + # BDS Libraries + UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf + PlatformBootManagerLib|ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf + BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf + CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf + + PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf + DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf + DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf + SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf + PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf + + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf + + NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf + +[LibraryClasses.common.SEC] + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf + ArmGicArchLib|ArmPkg/Library/ArmGicArchSecLib/ArmGicArchSecLib.inf + +[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM] + PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf + PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf + ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf + PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf + +[LibraryClasses.common.PEI_CORE] + PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf + +[LibraryClasses.common.PEIM] + PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf + MemoryInitPeiLib|Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf + PlatformPeiLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf + +[LibraryClasses.common.DXE_CORE] + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf + MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf + DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf + ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf + PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf + +[LibraryClasses.common.DXE_DRIVER] + SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf + PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + +[LibraryClasses.common.UEFI_APPLICATION] + PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + + # UiApp dependencies + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + + ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf + ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf + ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + +[LibraryClasses.common.DXE_RUNTIME_DRIVER] + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf + +################################################################################ +# +# Pcd Section - list of all EDK II PCD Entries defined by this Platform +# +################################################################################ + +[PcdsFeatureFlag] + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE + + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE + gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE + +[PcdsFixedAtBuild.common] + gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"Linaro" + + # non-secure SRAM + gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x2E000000 + gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0xFFC0 + gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0x2E00FFC0 + + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40 + + # 12x 2-core processor clusters + gArmPlatformTokenSpaceGuid.PcdCoreCount|2 + gArmPlatformTokenSpaceGuid.PcdClusterCount|12 + gArmTokenSpaceGuid.PcdArmPrimaryCore|0x0 +!if $(ARCH) == AARCH64 + gArmTokenSpaceGuid.PcdVFPEnabled|1 +!endif + + ## PL011 - Serial Terminal + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x2a400000 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0 + gArmPlatformTokenSpaceGuid.PL011UartInteger|0 + gArmPlatformTokenSpaceGuid.PL011UartFractional|0 + gArmPlatformTokenSpaceGuid.PL011UartClkInHz|62500000 + + # + # ARM Generic Interrupt Controller + # + gArmTokenSpaceGuid.PcdGicDistributorBase|0x30000000 + gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x30400000 + + # + # Generic watchdog + # + gArmTokenSpaceGuid.PcdGenericWatchdogControlBase|0x2a440000 + gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase|0x2a450000 + + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000 + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF + gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0 + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320 + + # DEBUG_ASSERT_ENABLED 0x01 + # DEBUG_PRINT_ENABLED 0x02 + # DEBUG_CODE_ENABLED 0x04 + # CLEAR_MEMORY_ENABLED 0x08 + # ASSERT_BREAKPOINT_ENABLED 0x10 + # ASSERT_DEADLOOP_ENABLED 0x20 +!if $(TARGET) == RELEASE + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21 +!else + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x3f +!endif + + # DEBUG_INIT 0x00000001 // Initialization + # DEBUG_WARN 0x00000002 // Warnings + # DEBUG_LOAD 0x00000004 // Load events + # DEBUG_FS 0x00000008 // EFI File system + # DEBUG_POOL 0x00000010 // Alloc & Free (pool) + # DEBUG_PAGE 0x00000020 // Alloc & Free (page) + # DEBUG_INFO 0x00000040 // Informational debug messages + # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers + # DEBUG_VARIABLE 0x00000100 // Variable + # DEBUG_BM 0x00000400 // Boot Manager + # DEBUG_BLKIO 0x00001000 // BlkIo Driver + # DEBUG_NET 0x00004000 // SNP Driver + # DEBUG_UNDI 0x00010000 // UNDI Driver + # DEBUG_LOADFILE 0x00020000 // LoadFile + # DEBUG_EVENT 0x00080000 // Event messages + # DEBUG_GCD 0x00100000 // Global Coherency Database changes + # DEBUG_CACHE 0x00200000 // Memory range cachability changes + # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may + # // significantly impact boot performance + # DEBUG_ERROR 0x80000000 // Error + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + + # + # Optional feature to help prevent EFI memory map fragments + # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob + # Values are in EFI Pages (4K). DXE Core will make sure that + # at least this much of each type of memory can be allocated + # from a single memory range. This way you only end up with + # maximum of two fragements for each type in the memory map + # (the memory used, and the free memory that was prereserved + # but not used). + # + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|2000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|1000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|2000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|20000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0 + + gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE + + # use the TTY terminal type + gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4 + + # GUID of the UI app + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } + + # + # Enable strict image permissions for all images. (This applies + # only to images that were built with >= 4 KB section alignment.) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy|0x3 + + # + # Enable NX memory protection for all non-code regions, including OEM and OS + # reserved ones, with the exception of LoaderData regions, of which OS loaders + # (i.e., GRUB) may assume that its contents are executable. + # + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC000000000007FD1 + + # + # Enable the non-executable DXE stack. (This gets set up by DxeIpl) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE + +[PcdsPatchableInModule] + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 + +[PcdsDynamicExDefault.common.DEFAULT] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xf7, 0x89, 0x9b, 0xe9, 0x20, 0xc1, 0x25, 0x4b, 0x4d, 0xb1, 0x83, 0x94, 0xed, 0xb0, 0xb4, 0xf5} + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0xe5, 0x4c, 0xb9, 0x50, 0x63, 0x8b, 0x49, 0x48, 0xf4, 0x8a, 0xea, 0x47, 0x93, 0x56, 0xf0, 0xe3} + +[PcdsDynamicHii] + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|30 + +[PcdsDynamicDefault] + gArmTokenSpaceGuid.PcdSystemMemoryBase|0x0000000000000000 + gArmTokenSpaceGuid.PcdSystemMemorySize|0xFFFFFFFFFFFFFFFF + +################################################################################ +# +# Components Section - list of all EDK II Modules needed by this Platform +# +################################################################################ +[Components.common] + # + # PEI Phase modules + # + ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + MdeModulePkg/Core/Pei/PeiMain.inf + MdeModulePkg/Universal/PCD/Pei/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + ArmPlatformPkg/PlatformPei/PlatformPeim.inf + ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + ArmPkg/Drivers/CpuPei/CpuPei.inf + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { + + NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf + } + + # + # DXE + # + MdeModulePkg/Core/Dxe/DxeMain.inf { + + NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F + } + + # + # Architectural Protocols + # + ArmPkg/Drivers/CpuDxe/CpuDxe.inf + ArmPkg/Drivers/ArmGic/ArmGicDxe.inf + EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf + MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf + EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { + + ## TODO + RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf + } + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf + MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf + ArmPkg/Drivers/TimerDxe/TimerDxe.inf + MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf + ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf + MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf + + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf + MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf + MdeModulePkg/Logo/LogoDxe.inf + + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + + # + # UEFI application (Shell Embedded Boot Loader) + # + ShellPkg/Application/Shell/Shell.inf { + + ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf + NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf + NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf + NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf + HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf + ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf + + + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE + } + + # + # Generic BDS + # + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf + MdeModulePkg/Universal/BdsDxe/BdsDxe.inf + MdeModulePkg/Application/UiApp/UiApp.inf { + + NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf + NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf + NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf + } + + # + # Platform driver + # + Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf new file mode 100644 index 000000000000..cc5377b1413f --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -0,0 +1,273 @@ +# +# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2017, 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. +# + +################################################################################ +# +# FD Section +# The [FD] Section is made up of the definition statements and a +# description of what goes into the Flash Device Image. Each FD section +# defines one flash "device" image. A flash device image may be one of +# the following: Removable media bootable image (like a boot floppy +# image,) an Option ROM image (that would be "flashed" into an add-in +# card,) a System "Flash" image (that would be burned into a system's +# flash) or an Update ("Capsule") image that will be used to update and +# existing system flash. +# +################################################################################ + +[FD.BL33_AP_UEFI] +BaseAddress = 0xE0000000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. +Size = 0x00200000|gArmTokenSpaceGuid.PcdFdSize # The size in bytes of the FLASH Device +ErasePolarity = 1 + +# This one is tricky, it must be: BlockSize * NumBlocks = Size +BlockSize = 0x00010000 +NumBlocks = 0x20 + +################################################################################ +# +# Following are lists of FD Region layout which correspond to the locations of different +# images within the flash device. +# +# Regions must be defined in ascending order and may not overlap. +# +# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by +# the pipe "|" character, followed by the size of the region, also in hex with the leading +# "0x" characters. Like: +# Offset|Size +# PcdOffsetCName|PcdSizeCName +# RegionType +# +################################################################################ + +0x00000000|0x001C0000 +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize +FV = FVMAIN_COMPACT + +################################################################################ +# +# FV Section +# +# [FV] section is used to define what components or modules are placed within a flash +# device file. This section also defines order the components and modules are positioned +# within the image. The [FV] section consists of define statements, set statements and +# module statements. +# +################################################################################ + +[FV.FvMain] +FvNameGuid = 89cc2ab6-b847-475f-93e2-819603c3d15a +BlockSize = 0x40 +NumBlocks = 0 # This FV gets compressed so make it just big enough +FvAlignment = 8 # FV alignment and FV attributes setting. +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF MdeModulePkg/Core/Dxe/DxeMain.inf + + # + # PI DXE Drivers producing Architectural Protocols (EFI Services) + # + INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf + INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf + INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf + INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf + INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf + INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf + INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf + + INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf + INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf + INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf + INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf + INF MdeModulePkg/Logo/LogoDxe.inf + INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf + + # + # UEFI applications + # + INF ShellPkg/Application/Shell/Shell.inf + + # + # Generic BDS + # + INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf + INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf + INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf + INF MdeModulePkg/Application/UiApp/UiApp.inf + + # + # Platform driver + # + INF Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf + +[FV.FVMAIN_COMPACT] +FvAlignment = 16 +BlockSize = 0x10000 +NumBlocks = 0 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + INF MdeModulePkg/Core/Pei/PeiMain.inf + INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf + INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf + INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + INF ArmPkg/Drivers/CpuPei/CpuPei.inf + INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + + FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { + SECTION FV_IMAGE = FVMAIN + } + } + + +################################################################################ +# +# Rules are use with the [FV] section's module INF type to define +# how an FFS file is created for a given INF file. The following Rule are the default +# rules for the different module type. User can add the customized rules to define the +# content of the FFS file. +# +################################################################################ + + +############################################################################ +# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section # +############################################################################ +# +#[Rule.Common.DXE_DRIVER] +# FILE DRIVER = $(NAMED_GUID) { +# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex +# COMPRESS PI_STD { +# GUIDED { +# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi +# UI STRING="$(MODULE_NAME)" Optional +# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) +# } +# } +# } +# +############################################################################ + +[Rule.Common.SEC] + FILE SEC = $(NAMED_GUID) RELOCS_STRIPPED FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.PEI_CORE] + FILE PEI_CORE = $(NAMED_GUID) FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING ="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM] + FILE PEIM = $(NAMED_GUID) FIXED { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM.TIANOCOMPRESSED] + FILE PEIM = $(NAMED_GUID) DEBUG_MYTOOLS_IA32 { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + } + +[Rule.Common.DXE_CORE] + FILE DXE_CORE = $(NAMED_GUID) { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.DXE_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.DXE_RUNTIME_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_APPLICATION] + FILE APPLICATION = $(NAMED_GUID) { + UI STRING ="$(MODULE_NAME)" Optional + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.UEFI_DRIVER.BINARY] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional |.depex + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + +[Rule.Common.UEFI_APPLICATION.BINARY] + FILE APPLICATION = $(NAMED_GUID) { + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/AArch64/SynQuacerHelper.S b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/AArch64/SynQuacerHelper.S new file mode 100644 index 000000000000..65059db9c8d2 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/AArch64/SynQuacerHelper.S @@ -0,0 +1,87 @@ +/** @file + * + * Copyright (c) 2013-2014, ARM Limited. All rights reserved. + * Copyright (c) 2017, 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 + +.text +.align 3 + +GCC_ASM_EXPORT(ArmPlatformPeiBootAction) +GCC_ASM_EXPORT(ArmPlatformGetCorePosition) +GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId) +GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) + +// +// First platform specific function to be called in the PEI phase +// +// This function is actually the first function called by the PrePi +// or PrePeiCore modules. It allows to retrieve arguments passed to +// the UEFI firmware through the CPU registers. +// +ASM_PFX(ArmPlatformPeiBootAction): + ret + +// +// Return the core position from the value of its MpId register +// +// This function returns the core position from the position 0 in the processor. +// This function might be called from assembler before any stack is set. +// +// @return Return the core position +// +//UINTN +//ArmPlatformGetCorePosition ( +// IN UINTN MpId +// ); +// With this function: CorePos = (ClusterId * 2) + CoreId +ASM_PFX(ArmPlatformGetCorePosition): + and x1, x0, #ARM_CORE_MASK + and x0, x0, #ARM_CLUSTER_MASK + add x0, x1, x0, LSR #7 + ret + +// +// Return the MpId of the primary core +// +// This function returns the MpId of the primary core. +// This function might be called from assembler before any stack is set. +// +// @return Return the MpId of the primary core +// +//UINTN +//ArmPlatformGetPrimaryCoreMpId ( +// VOID +// ); +ASM_PFX(ArmPlatformGetPrimaryCoreMpId): + mov w0, FixedPcdGet32 (PcdArmPrimaryCore) + ret + +// +// Return a non-zero value if the callee is the primary core +// +// This function returns a non-zero value if the callee is the primary core. +// The primary core is the core responsible to initialize the hardware and run UEFI. +// This function might be called from assembler before any stack is set. +// +// @return Return a non-zero value if the callee is the primary core. +// +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ASM_PFX(ArmPlatformIsPrimaryCore): + mov w0, #1 + ret diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/Arm/SynQuacerHelper.S b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/Arm/SynQuacerHelper.S new file mode 100644 index 000000000000..81980c580381 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/Arm/SynQuacerHelper.S @@ -0,0 +1,87 @@ +/** @file + * + * Copyright (c) 2013-2014, ARM Limited. All rights reserved. + * Copyright (c) 2017, 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 + +.text +.align 3 + +GCC_ASM_EXPORT(ArmPlatformPeiBootAction) +GCC_ASM_EXPORT(ArmPlatformGetCorePosition) +GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId) +GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) + +// +// First platform specific function to be called in the PEI phase +// +// This function is actually the first function called by the PrePi +// or PrePeiCore modules. It allows to retrieve arguments passed to +// the UEFI firmware through the CPU registers. +// +ASM_PFX(ArmPlatformPeiBootAction): + bx lr + +// +// Return the core position from the value of its MpId register +// +// This function returns the core position from the position 0 in the processor. +// This function might be called from assembler before any stack is set. +// +// @return Return the core position +// +//UINTN +//ArmPlatformGetCorePosition ( +// IN UINTN MpId +// ); +// With this function: CorePos = (ClusterId * 2) + CoreId +ASM_PFX(ArmPlatformGetCorePosition): + and r1, r0, #ARM_CORE_MASK + and r0, r0, #ARM_CLUSTER_MASK + add r0, r1, r0, LSR #7 + bx lr + +// +// Return the MpId of the primary core +// +// This function returns the MpId of the primary core. +// This function might be called from assembler before any stack is set. +// +// @return Return the MpId of the primary core +// +//UINTN +//ArmPlatformGetPrimaryCoreMpId ( +// VOID +// ); +ASM_PFX(ArmPlatformGetPrimaryCoreMpId): + ldr r0, =FixedPcdGet32 (PcdArmPrimaryCore) + bx lr + +// +// Return a non-zero value if the callee is the primary core +// +// This function returns a non-zero value if the callee is the primary core. +// The primary core is the core responsible to initialize the hardware and run UEFI. +// This function might be called from assembler before any stack is set. +// +// @return Return a non-zero value if the callee is the primary core. +// +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ASM_PFX(ArmPlatformIsPrimaryCore): + mov r0, #1 + bx lr diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacer.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacer.c new file mode 100644 index 000000000000..4da0200279cd --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacer.c @@ -0,0 +1,125 @@ +/** @file + * + * Copyright (c) 2013-2014, ARM Limited. All rights reserved. + * Copyright (c) 2017, 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 + +STATIC ARM_CORE_INFO mSynQuacerInfoTable[] = { + { 0x0, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 0, Core 0 + { 0x0, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 0, Core 1 + { 0x1, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 1, Core 0 + { 0x1, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 1, Core 1 + { 0x2, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 2, Core 0 + { 0x2, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 2, Core 1 + { 0x3, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 3, Core 0 + { 0x3, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 3, Core 1 + { 0x4, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 4, Core 0 + { 0x4, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 4, Core 1 + { 0x5, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 5, Core 0 + { 0x5, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 5, Core 1 + { 0x6, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 6, Core 0 + { 0x6, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 6, Core 1 + { 0x7, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 7, Core 0 + { 0x7, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 7, Core 1 + { 0x8, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 8, Core 0 + { 0x8, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 8, Core 1 + { 0x9, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 9, Core 0 + { 0x9, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 9, Core 1 + { 0xa, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 10, Core 0 + { 0xa, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 10, Core 1 + { 0xb, 0x0, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 11, Core 0 + { 0xb, 0x1, 0x0, 0x0, 0x0, (UINT64)0xFFFFFFFF }, // Cluster 11, Core 1 +}; + +/** + Return the current Boot Mode + + This function returns the boot reason on the platform + + @return Return the current Boot Mode of the platform + +**/ +EFI_BOOT_MODE +ArmPlatformGetBootMode ( + VOID + ) +{ + return BOOT_WITH_FULL_CONFIGURATION; +} + +/** + Initialize controllers that must setup in the normal world + + This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim + in the PEI phase. + +**/ +RETURN_STATUS +ArmPlatformInitialize ( + IN UINTN MpId + ) +{ + return RETURN_SUCCESS; +} + +/** + Initialize the system (or sometimes called permanent) memory + + This memory is generally represented by the DRAM. + +**/ +VOID +ArmPlatformInitializeSystemMemory ( + VOID + ) +{ +} + +STATIC +EFI_STATUS +PrePeiCoreGetMpCoreInfo ( + OUT UINTN *CoreCount, + OUT ARM_CORE_INFO **ArmCoreTable + ) +{ + *CoreCount = ARRAY_SIZE (mSynQuacerInfoTable); + *ArmCoreTable = mSynQuacerInfoTable; + + return EFI_SUCCESS; +} + +STATIC ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { + PrePeiCoreGetMpCoreInfo +}; + +STATIC EFI_PEI_PPI_DESCRIPTOR mPlatformPpiTable[] = { + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gArmMpCoreInfoPpiGuid, + &mMpCoreInfoPpi + } +}; + +VOID +ArmPlatformGetPlatformPpiList ( + OUT UINTN *PpiListSize, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiList + ) +{ + *PpiListSize = sizeof mPlatformPpiTable; + *PpiList = mPlatformPpiTable; +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf new file mode 100644 index 000000000000..ad3859e3ad77 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf @@ -0,0 +1,43 @@ +# +# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2017, 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 = 0x00010019 + BASE_NAME = SynQuacerLib + FILE_GUID = 8301a0ab-dd8d-476d-8170-1e34b51490d3 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmPlatformLib + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + +[Sources.common] + SynQuacer.c + +[Sources.AARCH64] + AArch64/SynQuacerHelper.S | GCC + +[Sources.ARM] + Arm/SynQuacerHelper.S | GCC + +[Ppis] + gArmMpCoreInfoPpiGuid + +[FixedPcd] + gArmTokenSpaceGuid.PcdArmPrimaryCore From patchwork Fri Nov 10 14:21:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118541 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258047edl; Fri, 10 Nov 2017 06:22:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMaMXcvxF9RG1UOPTbCgWJRC29F30wHSAZScL+Zp3XN0+OCBSMrTn7urqr/sXeYrLxqk1mlG X-Received: by 10.99.127.4 with SMTP id a4mr497445pgd.418.1510323742346; Fri, 10 Nov 2017 06:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323742; cv=none; d=google.com; s=arc-20160816; b=QCypjy56Se0vip60iFfkqSp5Fkgk7FysEZSysOkg9Bbapf/+UD1UV1a2v9ucs9M0H3 Bt7BuEA03WYQbKxQyTkugLLYg8k/A1KPBKAMsNIqmFIyW/MIsay5TSWnycgkWI478Pz2 2mg+1HWfd8cODXYnXZ3nB9kApZP9nUW0dFnR+WocIaKkwZmCzSO7Iltx1o8VOEsGlpLN FnRcb4n7LN/16a6Gp7QEe0BDLz4cBfaJUhqwRpSzF+koCUpYbhxlIHZTkTZbDlESujyP WeVF/q0fVK+wI201JFdMzngINmHp3xKB7+f8riF7RDcp66KoKVx/XbE34o8AE72hzZGO d34w== 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=kxGhvQNJzhUQYLiQ6wasDM+JvJlp6YqBOifQrgtn7SU=; b=OSc3UIDicR8YqKvEDRz1S3nZEk5K87H8iI60Wwi7nv8VwJZ+EGa9+8hWCeJytbwOnc v+ZDWggCXhckLnVwx0/rnuOAJBQJFYH5xyGfJdJlva4wtQqXIcq4SBEbLQki5ih83pCp l7cXRnWMqXjjEqs4g8txYyQQR4AJxILYjwvATtZ9TAH4ptvRwddVDPqzcLa4jV8ki7JR rCS9/O9enha/wQOB4ah35ttwiQIWynxWp7AfWNsSIYgtNTyGS/ZYsTODpF4XNR34H7Ky m6y3YH2WVnwpiuqAV4BHu6mdL9piVMxRVfKKSIUAmKoC/aRItExp/5b5vxR3mzkcRJdx zzXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jW0uwY2X; 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 26si9620286pfl.261.2017.11.10.06.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:22 -0800 (PST) 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=jW0uwY2X; 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 911D1203555F4; Fri, 10 Nov 2017 06:18:10 -0800 (PST) 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=2a00:1450:400c:c0c::22c; helo=mail-wr0-x22c.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22c.google.com (mail-wr0-x22c.google.com [IPv6:2a00:1450:400c:c0c::22c]) (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 30BB321B00DC5 for ; Fri, 10 Nov 2017 06:18:08 -0800 (PST) Received: by mail-wr0-x22c.google.com with SMTP id y9so8756704wrb.2 for ; Fri, 10 Nov 2017 06:22:11 -0800 (PST) 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=GzjhBVUd4XTvoe2tdr05v+yUMA4jhEqTOMH1QCdrjxw=; b=jW0uwY2XZAfzydaDc1kgwM9xJguo0jznn3W5ilMz7YWBxcEfRL3loNxmWlLIoFlcU8 T55jp/CFqLtCOW7xTIE/q7oTt3zRlAx/itbGP0b4BOWO03ot2IiGLGMLx2u4GcIG7xR9 toHQwxzAxqM+BvuZRASupItwuYXmVDYRRlCe8= 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=GzjhBVUd4XTvoe2tdr05v+yUMA4jhEqTOMH1QCdrjxw=; b=O/Qs75b1xIZD0S4MHbmHskVlq7QndlZDZfw+znzuY/pWQdVMYXZy7RUhJ5ht5L4425 1wsp9fa+WxTZkefeyO5a/x8pV0oYNEMbfmpeO/qsJYGPc0axGB26Xdyyz3atKeKpV/ln kQU3VyBoIgSTkx7vjXcRnnhUf/dCK3CWE/8LZlbu7yaK770bdZ8Tf/2u+R3uqm/HQ6S8 XlYvPMi7m/ZojfcXA4qejMDjtogLfF6G8+ZPDxde3qXVO/DJZVV8HnN4g/rosOs7yvKW mi3FB7mJNkXIQATo76iyNgjdyJTy5wXf94J6dLhxN0BUPccI9RiKq57q2ljX25H9lb8H bgPg== X-Gm-Message-State: AJaThX7oo2yVUiFVsgsPVilOrg2/mF9b7SN4EIDQxRQoRrEuk5DQZp20 wPDWhnYlX9JsaqUeNpId9xwuDh8ywMk= X-Received: by 10.223.184.125 with SMTP id u58mr476637wrf.33.1510323727521; Fri, 10 Nov 2017 06:22:07 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:06 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:00 +0000 Message-Id: <20171110142127.12018-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 07/34] Silicon/SynQuacer: implement PciSegmentLib to support dual RCs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Having two distinct root complexes is not supported by the standard set of PciLib/PciExpressLib/PciSegmentLib, so let's reimplement one of the latter specifically for this platform (and forget about the others). This also allows us to implement the Synopsys Designware PCIe specific workaround for PCI config space accesses to devices 1 and up on bus 0. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/PciSegmentLib.c | 1398 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf | 35 + 2 files changed, 1433 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/PciSegmentLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/PciSegmentLib.c new file mode 100644 index 000000000000..62f3b2015d2b --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/PciSegmentLib.c @@ -0,0 +1,1398 @@ +/** @file + PCI Segment Library for SynQuacer SoC with multiple RCs + + Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 + +typedef enum { + PciCfgWidthUint8 = 0, + PciCfgWidthUint16, + PciCfgWidthUint32, + PciCfgWidthMax +} PCI_CFG_WIDTH; + +/** + Assert the validity of a PCI Segment address. + A valid PCI Segment address should not contain 1's in bits 28..31 and 48..63 + + @param A The address to validate. + @param M Additional bits to assert to be zero. + +**/ +#define ASSERT_INVALID_PCI_SEGMENT_ADDRESS(A,M) \ + ASSERT (((A) & (0xffff0000f0000000ULL | (M))) == 0) + +STATIC +UINT64 +PciSegmentLibGetConfigBase ( + IN UINT64 Address + ) +{ + switch ((UINT16)(Address >> 32)) { + case 0: + return SYNQUACER_PCI_SEG0_CONFIG_BASE; + case 1: + return SYNQUACER_PCI_SEG1_CONFIG_BASE; + default: + ASSERT (FALSE); + } + + return 0; +} + +/** + Internal worker function to read a PCI configuration register. + + @param Address The address that encodes the PCI Bus, Device, Function and + Register. + @param Width The width of data to read + + @return The value read from the PCI configuration register. + +**/ +STATIC +UINT32 +PciSegmentLibReadWorker ( + IN UINT64 Address, + IN PCI_CFG_WIDTH Width + ) +{ + UINT64 Base; + + Base = PciSegmentLibGetConfigBase (Address); + + // ignore devices > 0 on bus 0 + if ((Address & 0xff00000) == 0 && (Address & 0xf8000) != 0) { + return 0xffffffff; + } + + switch (Width) { + case PciCfgWidthUint8: + return MmioRead8 (Base + (UINT32)Address); + case PciCfgWidthUint16: + return MmioRead16 (Base + (UINT32)Address); + case PciCfgWidthUint32: + return MmioRead32 (Base + (UINT32)Address); + default: + ASSERT (FALSE); + } + + return 0; +} + +/** + Internal worker function to writes a PCI configuration register. + + @param Address The address that encodes the PCI Bus, Device, Function and + Register. + @param Width The width of data to write + @param Data The value to write. + + @return The value written to the PCI configuration register. + +**/ +STATIC +UINT32 +PciSegmentLibWriteWorker ( + IN UINT64 Address, + IN PCI_CFG_WIDTH Width, + IN UINT32 Data + ) +{ + UINT64 Base; + + Base = PciSegmentLibGetConfigBase (Address); + + // ignore devices > 0 on bus 0 + if ((Address & 0xff00000) == 0 && (Address & 0xf8000) != 0) { + return Data; + } + + switch (Width) { + case PciCfgWidthUint8: + MmioWrite8 (Base + (UINT32)Address, Data); + break; + case PciCfgWidthUint16: + MmioWrite16 (Base + (UINT32)Address, Data); + break; + case PciCfgWidthUint32: + MmioWrite32 (Base + (UINT32)Address, Data); + break; + default: + ASSERT (FALSE); + } + + return Data; +} + +/** + Register a PCI device so PCI configuration registers may be accessed after + SetVirtualAddressMap(). + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Bus, Device, Function and + Register. + + @retval RETURN_SUCCESS The PCI device was registered for runtime access. + @retval RETURN_UNSUPPORTED An attempt was made to call this function + after ExitBootServices(). + @retval RETURN_UNSUPPORTED The resources required to access the PCI device + at runtime could not be mapped. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to + complete the registration. + +**/ +RETURN_STATUS +EFIAPI +PciSegmentRegisterForRuntimeAccess ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); + return RETURN_UNSUPPORTED; +} + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, + and Register. + + @return The 8-bit PCI configuration register specified by Address. + +**/ +UINT8 +EFIAPI +PciSegmentRead8 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); + + return (UINT8) PciSegmentLibReadWorker (Address, PciCfgWidthUint8); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the value specified by Value. + Value is returned. This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentWrite8 ( + IN UINT64 Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); + + return (UINT8) PciSegmentLibWriteWorker (Address, PciCfgWidthUint8, Value); +} + +/** + Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by OrData, + and writes the result to the 8-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentOr8 ( + IN UINT64 Address, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, (UINT8) (PciSegmentRead8 (Address) | OrData)); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + and writes the result to the 8-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentAnd8 ( + IN UINT64 Address, + IN UINT8 AndData + ) +{ + return PciSegmentWrite8 (Address, (UINT8) (PciSegmentRead8 (Address) & AndData)); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value, + followed a bitwise OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + performs a bitwise OR between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentAndThenOr8 ( + IN UINT64 Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, (UINT8) ((PciSegmentRead8 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldRead8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (PciSegmentRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldWrite8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciSegmentWrite8 ( + Address, + BitFieldWrite8 (PciSegmentRead8 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldOr8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 ( + Address, + BitFieldOr8 (PciSegmentRead8 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldAnd8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciSegmentWrite8 ( + Address, + BitFieldAnd8 (PciSegmentRead8 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldAndThenOr8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 ( + Address, + BitFieldAndThenOr8 (PciSegmentRead8 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + + @return The 16-bit PCI configuration register specified by Address. + +**/ +UINT16 +EFIAPI +PciSegmentRead16 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1); + + return (UINT16) PciSegmentLibReadWorker (Address, PciCfgWidthUint16); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the value specified by Value. + Value is returned. This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param Value The value to write. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +PciSegmentWrite16 ( + IN UINT64 Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1); + + return (UINT16) PciSegmentLibWriteWorker (Address, PciCfgWidthUint16, Value); +} + +/** + Performs a bitwise OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentOr16 ( + IN UINT64 Address, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, (UINT16) (PciSegmentRead16 (Address) | OrData)); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + and writes the result to the 16-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentAnd16 ( + IN UINT64 Address, + IN UINT16 AndData + ) +{ + return PciSegmentWrite16 (Address, (UINT16) (PciSegmentRead16 (Address) & AndData)); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value, + followed a bitwise OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + performs a bitwise OR between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentAndThenOr16 ( + IN UINT64 Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, (UINT16) ((PciSegmentRead16 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldRead16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (PciSegmentRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldWrite16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciSegmentWrite16 ( + Address, + BitFieldWrite16 (PciSegmentRead16 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by OrData, + and writes the result to the 16-bit PCI configuration register specified by Address. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldOr16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 ( + Address, + BitFieldOr16 (PciSegmentRead16 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, + and writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by OrData, + and writes the result to the 16-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param StartBit The ordinal of the least significant bit in the bit field. + The ordinal of the least significant bit in a byte is bit 0. + @param EndBit The ordinal of the most significant bit in the bit field. + The ordinal of the most significant bit in a byte is bit 7. + @param AndData The value to AND with the read value from the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldAnd16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciSegmentWrite16 ( + Address, + BitFieldAnd16 (PciSegmentRead16 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldAndThenOr16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 ( + Address, + BitFieldAndThenOr16 (PciSegmentRead16 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, + and Register. + + @return The 32-bit PCI configuration register specified by Address. + +**/ +UINT32 +EFIAPI +PciSegmentRead32 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); + + return PciSegmentLibReadWorker (Address, PciCfgWidthUint32); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the value specified by Value. + Value is returned. This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param Value The value to write. + + @return The parameter of Value. + +**/ +UINT32 +EFIAPI +PciSegmentWrite32 ( + IN UINT64 Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); + + return PciSegmentLibWriteWorker (Address, PciCfgWidthUint32, Value); +} + +/** + Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by OrData, + and writes the result to the 32-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, and Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentOr32 ( + IN UINT64 Address, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) | OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + and writes the result to the 32-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, + and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentAnd32 ( + IN UINT64 Address, + IN UINT32 AndData + ) +{ + return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) & AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value, + followed a bitwise OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by AndData, + performs a bitwise OR between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit PCI configuration register specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, Function, + and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentAndThenOr32 ( + IN UINT64 Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 (Address, (PciSegmentRead32 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldRead32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (PciSegmentRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldWrite32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciSegmentWrite32 ( + Address, + BitFieldWrite32 (PciSegmentRead32 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldOr32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 ( + Address, + BitFieldOr32 (PciSegmentRead32 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + + Reads the 32-bit PCI configuration register specified by Address, performs a bitwise + AND between the read result and the value specified by AndData, and writes the result + to the 32-bit PCI configuration register specified by Address. The value written to + the PCI configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in AndData are stripped. + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldAnd32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciSegmentWrite32 ( + Address, + BitFieldAnd32 (PciSegmentRead32 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldAndThenOr32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 ( + Address, + BitFieldAndThenOr32 (PciSegmentRead32 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If any reserved bits in StartAddress are set, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress The starting address that encodes the PCI Segment, Bus, + Device, Function and Register. + @param Size The size in bytes of the transfer. + @param Buffer The pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciSegmentReadBuffer ( + IN UINT64 StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return Size; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & BIT0) != 0) { + // + // Read a byte if StartAddress is byte aligned + // + *(volatile UINT8 *)Buffer = PciSegmentRead8 (StartAddress); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) { + // + // Read a word if StartAddress is word aligned + // + WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress)); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Read as many double words as possible + // + WriteUnaligned32 (Buffer, PciSegmentRead32 (StartAddress)); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Read the last remaining word if exist + // + WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress)); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Read the last remaining byte if exist + // + *(volatile UINT8 *)Buffer = PciSegmentRead8 (StartAddress); + } + + return ReturnValue; +} + + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If any reserved bits in StartAddress are set, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress The starting address that encodes the PCI Segment, Bus, + Device, Function and Register. + @param Size The size in bytes of the transfer. + @param Buffer The pointer to a buffer containing the data to write. + + @return The parameter of Size. + +**/ +UINTN +EFIAPI +PciSegmentWriteBuffer ( + IN UINT64 StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return 0; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & BIT0) != 0) { + // + // Write a byte if StartAddress is byte aligned + // + PciSegmentWrite8 (StartAddress, *(UINT8*)Buffer); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) { + // + // Write a word if StartAddress is word aligned + // + PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer)); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Write as many double words as possible + // + PciSegmentWrite32 (StartAddress, ReadUnaligned32 (Buffer)); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Write the last remaining word if exist + // + PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer)); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Write the last remaining byte if exist + // + PciSegmentWrite8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf new file mode 100644 index 000000000000..27bfb4eb6f12 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf @@ -0,0 +1,35 @@ +## @file +# PCI Segment Library for SynQuacer SoC with multiple RCs +# +# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, Linaro Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerPciSegmentLib + FILE_GUID = 1299f005-a30b-47d3-9003-24a91f100840 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = PciSegmentLib + +[Sources] + PciSegmentLib.c + +[Packages] + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib From patchwork Fri Nov 10 14:21:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118542 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258125edl; Fri, 10 Nov 2017 06:22:26 -0800 (PST) X-Google-Smtp-Source: AGs4zMY3KoypU4trJfgiFGOKtJzcyoYqsCxlb5WgyVyb6C58SAtGXR8Da3f/pqRX4ac7X7yZTWew X-Received: by 10.159.229.136 with SMTP id az8mr507192plb.423.1510323746575; Fri, 10 Nov 2017 06:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323746; cv=none; d=google.com; s=arc-20160816; b=Etmv+6KGKGoj6CWlSzPNK26eebZaDkgNr9s84s09glLvKYA7bfdoFNfAWABVqEDeNN 5rrSZ4d2PuIiQMn/xToazscer8TIX1MKzWUEnT9qZVmddmQ0vLxU/ogyZ+ZFiq35F49x 3LJ4qXebMakH0b3/+u1PN51rEu8H0t+LNAnWJPr5g9lCdyDhxkiU2KTqG9dNdUmTDCmF TfuFLZ+3rbY+7rZ9bNYCZpDjrTE/5sB00YWlbjVJ4QRgHW8xZz+7kQyBrLmuAE4XE0u9 K1Sx4JnnaqHbdz//1Q0ww2yQV9vCEpgI9i+lG3ghq34wk0hhltEYpM5u4Wg0G4ZwR3Uj otfA== 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=gW4170+nnuVTL2jUmKOxx8KpXlMAG/v0/hQLwEhhXcA=; b=YWtsJCILD6OQmH66aR6EWsR0Do9uz3AejyGjhWdGE3EdPHpcyci5QK4d81GY3ZSxbQ G2hOR9mYiUwj+JMN/i0Z0T50yWUNam3ZBwTJhb95MyESd9oZX2auT27SqFykJRRXWQpI QWm+UFQ5gdRK101Y3SmoeMgrv9HRKivqlovNJ3mJ0q1pQFxsMxh1xSYfU7qocdwKAyKD dXM/7KZAxmFH3xoCpRgkktBFpsxzkir1QkQABEg5VOiSV2s5MiztDFY+s1KnX4XKeGcs X0qr+Lbk1HXb7NPBE43yvRrqsc6nbsM3VASNy0oA1sfri9fldocinizYN6wr+FncH1xm R2tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cANCj/Ad; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id t64si8589396pgc.697.2017.11.10.06.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cANCj/Ad; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 D45E1203555E4; Fri, 10 Nov 2017 06:18:12 -0800 (PST) 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=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 2CD8521B00DC5 for ; Fri, 10 Nov 2017 06:18:09 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id g141so3057399wmg.2 for ; Fri, 10 Nov 2017 06:22:12 -0800 (PST) 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=ACAMJqt9Rdw3VZMqAYgqIRallUo8p7mAcieIMqKoz3A=; b=cANCj/AdabO4vTFdO0w3i3s2KEw383lLvqtAoO/osXMgoypi/F99GDgEXA9BWfRKdj 7aWayhaLL+5uuybPBg/En/sLMkRaV92RjZNVlzLDTZ/PPU6lecy0K/1C9rj9VC+LUuQO Lc7Ht1DwCDjeD6o/3ZY7KUWNgxy9a8V8pJHl4= 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=ACAMJqt9Rdw3VZMqAYgqIRallUo8p7mAcieIMqKoz3A=; b=dDa7v4MAQhX2eBIWSmZ3akZ7grb8r9tK36C2SEhY+C6jEOThp5yzb/fSNhHusa3pJd up4/3OUjV6LsFkIoPEtBl4aEI+e/dcHAApIcEVpQKP7HcrJDoDMYCcps5Wc8cIokwvCO D6UtMQlnFNRrd28Ak6cCWjNJ7QQBWPNVQjmgjBCpvxxesHE+BV590KHLhprzm1RsINOX X5VduOCy7iQeGkIrWAmmYvvTqSvUVwx2bOOQvP0mY1Vvw2qkXTZ1oxqwnT93aLNAX5KP kT31sCFDoT+9bRBYEMPoYq8JMzxYe0RqTcBWZkN1GqcW8qyNRXFAGBwWotVvQJlzxNdp xQJw== X-Gm-Message-State: AJaThX4GgFwUpq5/3Un6bDckvp6x6Kh533KLRBxEAQ27zsf+trYAgKJ/ PUTbRbCr4DzSKXs745gYj7gotPQi8X0= X-Received: by 10.28.87.17 with SMTP id l17mr374855wmb.158.1510323730219; Fri, 10 Nov 2017 06:22:10 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:09 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:01 +0000 Message-Id: <20171110142127.12018-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 08/34] Silicon/SynQuacer: implement PciHostBridgeLib support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement the glue library that exposes the PCIe root complexes to the generic PCI host bridge driver. Since that driver is the first one to access the PCI config space, put the low level init code for the RCs into this library's constructor. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c | 225 +++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf | 50 +++ Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c | 390 ++++++++++++++++++++ 3 files changed, 665 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c new file mode 100644 index 000000000000..42cdce24b2c4 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c @@ -0,0 +1,225 @@ +/** @file + PCI Host Bridge Library instance for Socionext SynQuacer ARM SOC + + Copyright (c) 2017, Linaro Ltd. 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 +#include +#include + +#pragma pack(1) +typedef struct { + ACPI_HID_DEVICE_PATH AcpiDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH; +#pragma pack () + +STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[] = { + { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8) + } + }, + EISA_PNP_ID (0x0A08), // PCI Express + 0 + }, + + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } + }, + { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8)(sizeof(ACPI_HID_DEVICE_PATH)), + (UINT8)(sizeof(ACPI_HID_DEVICE_PATH) >> 8) + } + }, + EISA_PNP_ID (0x0A08), // PCI Express + 1 + }, + + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } + } +}; + +GLOBAL_REMOVE_IF_UNREFERENCED +CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = { + L"Mem", L"I/O", L"Bus" +}; + +#ifndef MDE_CPU_ARM +#define PCI_ALLOCATION_ATTRIBUTES EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | \ + EFI_PCI_HOST_BRIDGE_MEM64_DECODE +#else +#define PCI_ALLOCATION_ATTRIBUTES EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM +#endif + +STATIC PCI_ROOT_BRIDGE mPciRootBridges[] = { + { + 0, // Segment + 0, // Supports + 0, // Attributes + TRUE, // DmaAbove4G + FALSE, // NoExtendedConfigSpace + FALSE, // ResourceAssigned + PCI_ALLOCATION_ATTRIBUTES, // AllocationAttributes + { SYNQUACER_PCI_SEG0_BUSNUM_MIN, + SYNQUACER_PCI_SEG0_BUSNUM_MAX }, // Bus + { SYNQUACER_PCI_SEG0_PORTIO_MIN, + SYNQUACER_PCI_SEG0_PORTIO_MAX }, // Io + { SYNQUACER_PCI_SEG0_MMIO32_MIN, + SYNQUACER_PCI_SEG0_MMIO32_MAX }, // Mem + { SYNQUACER_PCI_SEG0_MMIO64_MIN, + SYNQUACER_PCI_SEG0_MMIO64_MAX }, // MemAbove4G + { MAX_UINT64, 0x0 }, // PMem + { MAX_UINT64, 0x0 }, // PMemAbove4G + (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath[0] + }, { + 1, // Segment + 0, // Supports + 0, // Attributes + TRUE, // DmaAbove4G + FALSE, // NoExtendedConfigSpace + FALSE, // ResourceAssigned + PCI_ALLOCATION_ATTRIBUTES, // AllocationAttributes + { SYNQUACER_PCI_SEG1_BUSNUM_MIN, + SYNQUACER_PCI_SEG1_BUSNUM_MAX }, // Bus + { SYNQUACER_PCI_SEG1_PORTIO_MIN, + SYNQUACER_PCI_SEG1_PORTIO_MAX }, // Io + { SYNQUACER_PCI_SEG1_MMIO32_MIN, + SYNQUACER_PCI_SEG1_MMIO32_MAX }, // Mem + { SYNQUACER_PCI_SEG1_MMIO64_MIN, + SYNQUACER_PCI_SEG1_MMIO64_MAX }, // MemAbove4G + { MAX_UINT64, 0x0 }, // PMem + { MAX_UINT64, 0x0 }, // PMemAbove4G + (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath[1] + } +}; + +/** + Return all the root bridge instances in an array. + + @param Count Return the count of root bridge instances. + + @return All the root bridge instances in an array. + The array should be passed into PciHostBridgeFreeRootBridges() + when it's not used. +**/ +PCI_ROOT_BRIDGE * +EFIAPI +PciHostBridgeGetRootBridges ( + OUT UINTN *Count + ) +{ + *Count = ARRAY_SIZE (mPciRootBridges); + + return mPciRootBridges; +} + +/** + Free the root bridge instances array returned from PciHostBridgeGetRootBridges(). + + @param Bridges The root bridge instances array. + @param Count The count of the array. +**/ +VOID +EFIAPI +PciHostBridgeFreeRootBridges ( + PCI_ROOT_BRIDGE *Bridges, + UINTN Count + ) +{ +} + +/** + Inform the platform that the resource conflict happens. + + @param HostBridgeHandle Handle of the Host Bridge. + @param Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the resources + for all the root bridges. The resource for each root + bridge is terminated with END descriptor and an + additional END is appended indicating the end of the + entire resources. The resource descriptor field + values follow the description in + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeResourceConflict ( + EFI_HANDLE HostBridgeHandle, + VOID *Configuration + ) +{ + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; + UINTN RootBridgeIndex; + DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n")); + + RootBridgeIndex = 0; + Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; + while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) { + DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); + for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) { + ASSERT (Descriptor->ResType < + ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr)); + DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n", + mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType], + Descriptor->AddrLen, Descriptor->AddrRangeMax + )); + if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) { + DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n", + Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, + ((Descriptor->SpecificFlag & + EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE + ) != 0) ? L" (Prefetchable)" : L"" + )); + } + } + // + // Skip the END descriptor for root bridge + // + ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR); + Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( + (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 + ); + } +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf new file mode 100644 index 000000000000..08484f4f8b1a --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf @@ -0,0 +1,50 @@ +## @file +# PCI Host Bridge Library instance for Socionext SynQuacer ARM SOC +# +# Copyright (c) 2017, Linaro Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerPciHostBridgeLib + FILE_GUID = fdc92446-65bc-4f86-b4a0-014a2119a732 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = PciHostBridgeLib|DXE_DRIVER + CONSTRUCTOR = SynQuacerPciHostBridgeLibConstructor + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 +# + +[Sources] + SynQuacerPciHostBridgeLib.c + SynQuacerPciHostBridgeLibConstructor.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + ArmLib + DebugLib + DevicePathLib + MemoryAllocationLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdPciIoTranslation diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c new file mode 100644 index 000000000000..b5bfea8e0e75 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c @@ -0,0 +1,390 @@ +/** @file + PCI Host Bridge Library instance for Socionext SynQuacer ARM SOC + + Copyright (c) 2017, Linaro Ltd. 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 + +#define IATU_VIEWPORT_OFF 0x900 +#define IATU_VIEWPORT_INBOUND BIT31 +#define IATU_VIEWPORT_OUTBOUND 0 +#define IATU_VIEWPORT_REGION_INDEX(Idx) ((Idx) & 7) + +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0 0x904 +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM 0x0 +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_IO 0x2 +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG0 0x4 +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG1 0x5 + +#define IATU_REGION_CTRL_2_OFF_OUTBOUND_0 0x908 +#define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN BIT31 +#define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_CFG_SHIFT_MODE BIT28 + +#define IATU_LWR_BASE_ADDR_OFF_OUTBOUND_0 0x90C +#define IATU_UPPER_BASE_ADDR_OFF_OUTBOUND_0 0x910 +#define IATU_LIMIT_ADDR_OFF_OUTBOUND_0 0x914 +#define IATU_LWR_TARGET_ADDR_OFF_OUTBOUND_0 0x918 +#define IATU_UPPER_TARGET_ADDR_OFF_OUTBOUND_0 0x91C + +#define CORE_CONTROL 0x000 +#define APP_LTSSM_ENABLE BIT4 +#define DEVICE_TYPE (BIT3 | BIT2 | BIT1 | BIT0) + +#define AXI_CLK_STOP 0x004 +#define DBI_ACLK_STOP BIT8 +#define SLV_ACLK_STOP BIT4 +#define MSTR_ACLK_STOP BIT0 +#define DBI_CSYSREQ_REG BIT9 +#define SLV_CSYSREQ_REG BIT5 +#define MSTR_CSYSREQ_REG BIT1 + +#define RESET_CONTROL_1 0x00C +#define PERST_N_O_REG BIT5 +#define PERST_N_I_REG BIT4 +#define BUTTON_RST_N_REG BIT1 +#define PWUP_RST_N_REG BIT0 + +#define RESET_CONTROL_2 0x010 + +#define RESET_SELECT_1 0x014 +#define SQU_RST_SEL BIT29 +#define PHY_RST_SEL BIT28 +#define PWR_RST_SEL BIT24 +#define STI_RST_SEL BIT20 +#define N_STI_RST_SEL BIT16 +#define CORE_RST_SEL BIT12 +#define PERST_SEL BIT4 +#define BUTTON_RST_SEL BIT1 +#define PWUP_RST_SEL BIT0 + +#define RESET_SELECT_2 0x018 +#define DBI_ARST_SEL BIT8 +#define SLV_ARST_SEL BIT4 +#define MSTR_ARST_SEL BIT0 + +#define EM_CONTROL 0x030 +#define PRE_DET_STT_REG BIT4 + +#define EM_SELECT 0x034 +#define PRE_DET_STT_SEL BIT4 + +#define PM_CONTROL_2 0x050 +#define SYS_AUX_PWR_DET BIT8 + +#define PHY_CONFIG_COM_6 0x114 +#define PIPE_PORT_SEL (BIT1 | BIT0) + +#define LINK_MONITOR 0x210 +#define SMLH_LINK_UP BIT0 + +#define LINK_CAPABILITIES_REG 0x07C +#define PCIE_CAP_MAX_LINK_WIDTH (BIT7 | BIT6 | BIT5 | BIT4) +#define PCIE_CAP_MAX_LINK_SPEED (BIT3 | BIT2 | BIT1 | BIT0) + +#define LINK_CONTROL_LINK_STATUS_REG 0x080 +#define PCIE_CAP_NEGO_LINK_WIDTH (BIT23 | BIT22 | BIT21 | BIT20) +#define PCIE_CAP_LINK_SPEED (BIT19 | BIT18 | BIT17 | BIT16) + +#define TYPE1_CLASS_CODE_REV_ID_REG 0x008 +#define BASE_CLASS_CODE 0xFF000000 +#define BASE_CLASS_CODE_VALUE 0x06 +#define SUBCLASS_CODE 0x00FF0000 +#define SUBCLASS_CODE_VALUE 0x04 +#define PROGRAM_INTERFACE 0x0000FF00 +#define PROGRAM_INTERFACE_VALUE 0x00 + +#define MISC_CONTROL_1_OFF 0x8BC +#define DBI_RO_WR_EN BIT0 + +STATIC +VOID +ConfigureWindow ( + IN EFI_PHYSICAL_ADDRESS DbiBase, + IN UINTN Index, + IN UINT64 CpuBase, + IN UINT64 PciBase, + IN UINT64 Size, + IN UINTN Type, + IN UINTN EnableFlags + ) +{ + ArmDataMemoryBarrier (); + + MmioWrite32 (DbiBase + IATU_VIEWPORT_OFF, + IATU_VIEWPORT_OUTBOUND | IATU_VIEWPORT_REGION_INDEX (Index)); + + ArmDataMemoryBarrier (); + + MmioWrite32 (DbiBase + IATU_LWR_BASE_ADDR_OFF_OUTBOUND_0, + (UINT32)(CpuBase & 0xFFFFFFFF)); + MmioWrite32 (DbiBase + IATU_UPPER_BASE_ADDR_OFF_OUTBOUND_0, + (UINT32)(CpuBase >> 32)); + MmioWrite32 (DbiBase + IATU_LIMIT_ADDR_OFF_OUTBOUND_0, + (UINT32)(CpuBase + Size - 1)); + MmioWrite32 (DbiBase + IATU_LWR_TARGET_ADDR_OFF_OUTBOUND_0, + (UINT32)(PciBase & 0xFFFFFFFF)); + MmioWrite32 (DbiBase + IATU_UPPER_TARGET_ADDR_OFF_OUTBOUND_0, + (UINT32)(PciBase >> 32)); + MmioWrite32 (DbiBase + IATU_REGION_CTRL_1_OFF_OUTBOUND_0, + Type); + MmioWrite32 (DbiBase + IATU_REGION_CTRL_2_OFF_OUTBOUND_0, + IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN | EnableFlags); +} + +STATIC +VOID +SnPcieSetData ( + EFI_PHYSICAL_ADDRESS Base, + UINT32 Offset, + UINT32 Mask, + UINT32 In + ) +{ + UINT32 Data; + UINT32 Shift; + + Shift = 1; + if (In) { + while (!(Mask & Shift)) + Shift <<= 1; + Data = (MmioRead32 (Base + Offset) & ~Mask) | (In * Shift); + } else { + Data = MmioRead32 (Base + Offset) & ~Mask; + } + + MmioWrite32 (Base + Offset, Data); +} + +STATIC +UINT32 +SnPcieReadData ( + EFI_PHYSICAL_ADDRESS Base, + UINT32 Offset, + UINT32 Mask + ) +{ + UINT32 Shift; + + Shift = 0; + while (!(Mask & 1)) { + Mask >>= 1; + Shift++; + } + + return (MmioRead32 (Base + Offset) >> Shift) & Mask; +} + +STATIC +VOID +SnDbiRoWrEn ( + IN EFI_PHYSICAL_ADDRESS DbiBase, + IN INTN MaxLinkWidth, + IN INTN MaxLinkSpeed + ) +{ + SnPcieSetData (DbiBase, MISC_CONTROL_1_OFF, DBI_RO_WR_EN, 1); + + SnPcieSetData (DbiBase, LINK_CAPABILITIES_REG, PCIE_CAP_MAX_LINK_WIDTH, MaxLinkWidth); + SnPcieSetData (DbiBase, LINK_CAPABILITIES_REG, PCIE_CAP_MAX_LINK_SPEED, MaxLinkSpeed); + + SnPcieSetData (DbiBase, TYPE1_CLASS_CODE_REV_ID_REG, BASE_CLASS_CODE, BASE_CLASS_CODE_VALUE); + SnPcieSetData (DbiBase, TYPE1_CLASS_CODE_REV_ID_REG, SUBCLASS_CODE, SUBCLASS_CODE_VALUE); + SnPcieSetData (DbiBase, TYPE1_CLASS_CODE_REV_ID_REG, PROGRAM_INTERFACE, PROGRAM_INTERFACE_VALUE); + + SnPcieSetData (DbiBase, MISC_CONTROL_1_OFF, DBI_RO_WR_EN, 0); +} + +STATIC +VOID +PciInitController ( + IN EFI_PHYSICAL_ADDRESS ExsBase, + IN EFI_PHYSICAL_ADDRESS DbiBase, + IN EFI_PHYSICAL_ADDRESS ConfigBase, + IN EFI_PHYSICAL_ADDRESS IoMemBase, + IN CONST PCI_ROOT_BRIDGE *RootBridge + ) +{ + SnPcieSetData (ExsBase, EM_SELECT, PRE_DET_STT_SEL, 0); + SnPcieSetData (ExsBase, EM_CONTROL, PRE_DET_STT_REG, 0); + SnPcieSetData (ExsBase, EM_CONTROL, PRE_DET_STT_REG, 1); + + // 1: Assert all PHY / LINK resets + SnPcieSetData (ExsBase, RESET_SELECT_1 , PERST_SEL , 0); + SnPcieSetData (ExsBase, RESET_CONTROL_1, PERST_N_I_REG , 0); + SnPcieSetData (ExsBase, RESET_CONTROL_1, PERST_N_O_REG , 0); + + // Device Reset(PERST#) is effective afrer Set device_type (RC) + SnPcieSetData (ExsBase, RESET_SELECT_1 , PWUP_RST_SEL , 0); + SnPcieSetData (ExsBase, RESET_CONTROL_1, PWUP_RST_N_REG, 0); + SnPcieSetData (ExsBase, RESET_SELECT_1 , BUTTON_RST_SEL , 0); + SnPcieSetData (ExsBase, RESET_CONTROL_1, BUTTON_RST_N_REG, 0); + SnPcieSetData (ExsBase, RESET_SELECT_1 , PWR_RST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_2 , MSTR_ARST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_2 , SLV_ARST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_2 , DBI_ARST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_1 , CORE_RST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_1 , STI_RST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_1 , N_STI_RST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_1 , SQU_RST_SEL , 1); + SnPcieSetData (ExsBase, RESET_SELECT_1 , PHY_RST_SEL , 1); + + // 2: Set P_app_ltssm_enable='0' for reprogramming before linkup. + SnPcieSetData (ExsBase, CORE_CONTROL, APP_LTSSM_ENABLE, 0); + + // 3: Set device_type (RC) + SnPcieSetData (ExsBase, CORE_CONTROL, DEVICE_TYPE, 4); + + // 4: Set Bifurcation 1=disable 4=able + // 5: Supply Reference (It has executed) + // 6: Wait for 10usec (Reference Clocks is stable) + // 7 De assert PERST# */ + SnPcieSetData (ExsBase, RESET_CONTROL_1, PERST_N_I_REG, 1); + SnPcieSetData (ExsBase, RESET_CONTROL_1, PERST_N_O_REG, 1); + + // 8 Assert SYS_AUX_PWR_DET + SnPcieSetData(ExsBase, PM_CONTROL_2, SYS_AUX_PWR_DET, 1); + + // 9 Supply following clocks + SnPcieSetData (ExsBase, AXI_CLK_STOP, MSTR_CSYSREQ_REG, 1); + SnPcieSetData (ExsBase, AXI_CLK_STOP, MSTR_ACLK_STOP, 0); + SnPcieSetData (ExsBase, AXI_CLK_STOP, SLV_CSYSREQ_REG, 1); + SnPcieSetData (ExsBase, AXI_CLK_STOP, SLV_ACLK_STOP, 0); + SnPcieSetData (ExsBase, AXI_CLK_STOP, DBI_CSYSREQ_REG, 1); + SnPcieSetData (ExsBase, AXI_CLK_STOP, DBI_ACLK_STOP, 0); + + // 10 De assert PHY reset + // 11 De assert LINK's PMC reset + SnPcieSetData (ExsBase, RESET_CONTROL_1, PWUP_RST_N_REG, 1); + SnPcieSetData (ExsBase, RESET_CONTROL_1, BUTTON_RST_N_REG, 1); + // 12 PHY auto + // 13 Wrapper auto + // 14-17 PHY auto + // 18 Wrapper auto + // 19 Update registers through DBI AXI Slave interface + SnDbiRoWrEn (DbiBase, 4 /* lanes */, /* Gen */ 2); + + // + // ECAM shift mode uses bits [27:12] of the untranslated address as + // B/D/F identifiers. This only works as expected if the base of the + // region is aligned to 256 MB, or the effective bus numbers will be + // out of sync with the bus base and limit values we chose. + // + ASSERT ((ConfigBase % SIZE_256MB) == RootBridge->Bus.Base * SIZE_1MB); + + MmioOr32 (DbiBase + PCI_COMMAND_OFFSET, EFI_PCI_COMMAND_IO_SPACE | + EFI_PCI_COMMAND_MEMORY_SPACE | + EFI_PCI_COMMAND_BUS_MASTER); + + // Region 0: MMIO32 range + ConfigureWindow (DbiBase, 0, + RootBridge->Mem.Base, + RootBridge->Mem.Base, + RootBridge->Mem.Limit - RootBridge->Mem.Base + 1, + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM, + 0); + + // Region 1: Type 0 config space + ConfigureWindow (DbiBase, 1, + ConfigBase + RootBridge->Bus.Base * SIZE_1MB, + 0x0, + SIZE_64KB, + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG0, + IATU_REGION_CTRL_2_OFF_OUTBOUND_0_CFG_SHIFT_MODE); + + // Region 2: Type 1 config space + ConfigureWindow (DbiBase, 2, + ConfigBase + RootBridge->Bus.Base * SIZE_1MB + SIZE_64KB, + 0x0, + (RootBridge->Bus.Limit - RootBridge->Bus.Base + 1) * SIZE_1MB - SIZE_64KB, + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG1, + IATU_REGION_CTRL_2_OFF_OUTBOUND_0_CFG_SHIFT_MODE); + + // Region 3: port I/O range + ConfigureWindow (DbiBase, 3, + IoMemBase, + RootBridge->Io.Base, + RootBridge->Io.Limit - RootBridge->Io.Base + 1, + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_IO, + 0); + + // Region 4: MMIO64 range + if (RootBridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_MEM64_DECODE) { + ConfigureWindow (DbiBase, 4, + RootBridge->MemAbove4G.Base, + RootBridge->MemAbove4G.Base, + RootBridge->MemAbove4G.Limit - RootBridge->MemAbove4G.Base + 1, + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM, + 0); + } + + // enable link + if (SnPcieReadData (ExsBase, CORE_CONTROL, APP_LTSSM_ENABLE) == 0) { + SnPcieSetData (ExsBase, CORE_CONTROL, APP_LTSSM_ENABLE, 1); + } +} + +STATIC CONST struct { + EFI_PHYSICAL_ADDRESS DbiBase; + EFI_PHYSICAL_ADDRESS ExsBase; + EFI_PHYSICAL_ADDRESS ConfigBase; + EFI_PHYSICAL_ADDRESS IoMemBase; +} mBaseAddresses [] = { + { + SYNQUACER_PCI_SEG0_DBI_BASE, + SYNQUACER_PCI_SEG0_EXS_BASE, + SYNQUACER_PCI_SEG0_CONFIG_BASE, + SYNQUACER_PCI_SEG0_PORTIO_MEMBASE + }, + { + SYNQUACER_PCI_SEG1_DBI_BASE, + SYNQUACER_PCI_SEG1_EXS_BASE, + SYNQUACER_PCI_SEG1_CONFIG_BASE, + SYNQUACER_PCI_SEG1_PORTIO_MEMBASE + }, +}; + + +EFI_STATUS +EFIAPI +SynQuacerPciHostBridgeLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + PCI_ROOT_BRIDGE *RootBridges; + UINTN Count; + UINTN Idx; + + RootBridges = PciHostBridgeGetRootBridges (&Count); + ASSERT (Count == ARRAY_SIZE(mBaseAddresses)); + if (Count != ARRAY_SIZE(mBaseAddresses)) { + return EFI_INVALID_PARAMETER; + } + + for (Idx = 0; Idx < Count; Idx++) { + PciInitController (mBaseAddresses[Idx].ExsBase, + mBaseAddresses[Idx].DbiBase, + mBaseAddresses[Idx].ConfigBase, + mBaseAddresses[Idx].IoMemBase, + &RootBridges[Idx]); + } + + return EFI_SUCCESS; +} From patchwork Fri Nov 10 14:21:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118543 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258207edl; Fri, 10 Nov 2017 06:22:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMY6iGW7kQXzEL8F3Fn507I9shLssRB99eetbuBE7nUQXVfPkaBsjn2MUy0V+87+y26LYpWt X-Received: by 10.98.68.8 with SMTP id r8mr526453pfa.161.1510323750094; Fri, 10 Nov 2017 06:22:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323750; cv=none; d=google.com; s=arc-20160816; b=hKz/W2aqq534ZlT+o+D575FSRLh66pR2V97wrjXZ1Nl6EAbSP/RcL+MWMjHghkRDV7 7sHul/N2Pi0a77gGJfVglzuDfsb3tEWK2POWDJROPeXbHJr+tsRn8Z+8VP3uKmnRdLFE ZopyZM4yoZRdc4gmPiqgYeEcsLlRwkkG1MNbf13yAvpEXWuJd2DeQK/6r4maTrJNdbcU TVdEWEiiO9RqmKwH/QrDRqiPiEuU7ZkvSHKwEvEEHrIWOC66VUwFq9CxoEQOZqFylBxx pNxxj+byjKwscuhY6nB8Hiz+npU/ZoG6z38jdRqdy8ZxVEDmo3iQLYC/7a12u4HOG9vV LFPQ== 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=9uQKiCyxa00tXjgK5987QP64zVk01SSCEmVaxvsnwTg=; b=NDxQuo1QhDFRU5Tv3o9xOecucsPfFX5Yiy4Tk+ifK012oZ2XGbvwjHE5/fHvYgZ226 tHTqPbrtXtWkpbDGDZuWHQjBd03CJl5YkuaYEf6q6iN47t3c4jv52bgR3H6tNK9nvTMd s472YFRJKJSbUEZ/nBFkJ7wuWViMEtdxCkMkQ6rMfG2B4Ed9dasyumbVGVvTT0BqbMQv kbnv/k10L5PKDOgfl1pF/tU57DcSnIXlPTGtUY9JrMJEdW9z8UAnffSuxwZxrJR+6JGF Evwli0S10WC3CRWd3leeG+mffUmDKoPm0FwqWuqTZhOa5ygIY6i8AFpheKy1BLR2JwJ0 xTGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BVbZQyhi; 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 s6si8910168pgn.363.2017.11.10.06.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:30 -0800 (PST) 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=BVbZQyhi; 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 1D42820355602; Fri, 10 Nov 2017 06:18:15 -0800 (PST) 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=2a00:1450:400c:c09::232; helo=mail-wm0-x232.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 EE5B8203555E4 for ; Fri, 10 Nov 2017 06:18:11 -0800 (PST) Received: by mail-wm0-x232.google.com with SMTP id b189so3036260wmd.4 for ; Fri, 10 Nov 2017 06:22:14 -0800 (PST) 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=izCcAKdikZRpqSrThy/b4l9NtBZra9yueAjF6RJTiGY=; b=BVbZQyhiUDBPECcQBf8BdPMPJscZZpWEYSmx9xFM3jhLrwMIvSi1dvE27JRC0I/dyc nVVuo6ZNvBjwU0QIJZC9Rb1o9G1RCqKmVn4r/pvCI0bhvNhnNFP5EObPhR0oHX8Y7Se+ Y5I12mMJAYjlFJsao0vqrwR3CYlhy7WzTHg/I= 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=izCcAKdikZRpqSrThy/b4l9NtBZra9yueAjF6RJTiGY=; b=daTHV/ZSS6sokRwBjfsj5tiuLLza1hzaJe1V0I7dKtdrDYXSooZvLcv3TAO3tnYtO8 wqU3r08wyJ7N5HJdDhB/D1LGiILu+2+85DgbFK8HB+zhI95NM9/DYxOUgkV/OWkuIJr7 TTsvE5gI+Fz4V17AKLvhh7N+RJEIw3iECBFoX0iA2wQvBrm3QB41oHKAdFeRvVdb8VzY 8E1Evg7QKktRTDsIUCyL7GEEtZCtfj+j3GDwgDvIhUZFZv9RkVhHB5iYB7ji4N5obbyy QqhuusGB1dzlM2WV7IOyeXTjtudzNXw4JAGx0JjtVTBbYccmDche0xrFV0/3SNXsJTTX 4p4w== X-Gm-Message-State: AJaThX6Z2vUdDdfyGIAjIkWKY1ry7ZdqomyjFtj4W9sAu5Yz8HmP7wnY 7omosh0LTxkIYm4E/JxIttddNtBZ4Gw= X-Received: by 10.28.131.200 with SMTP id f191mr385008wmd.39.1510323732831; Fri, 10 Nov 2017 06:22:12 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:11 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:02 +0000 Message-Id: <20171110142127.12018-10-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 09/34] Silicon/SynQuacer: implement EFI_CPU_IO2_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The SynQuacer SOC has two separate PCIe RCs, which means there is no single value for the translation offset between I/O port accesses and MMIO accesses. So add a special implementation of EFI_CPU_IO2_PROTOCOL that takes the two disjoint I/O windows into account. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c | 590 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf | 50 ++ 2 files changed, 640 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c new file mode 100644 index 000000000000..6ef44b11bb7d --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c @@ -0,0 +1,590 @@ +/** @file + Produces the CPU I/O 2 Protocol. + +Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2017, Linaro Ltd. 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 + +#define MAX_IO_PORT_ADDRESS SYNQUACER_PCI_SEG1_PORTIO_MAX + +// +// Handle for the CPU I/O 2 Protocol +// +STATIC EFI_HANDLE mHandle = NULL; + +// +// Lookup table for increment values based on transfer widths +// +STATIC CONST UINT8 mInStride[] = { + 1, // EfiCpuIoWidthUint8 + 2, // EfiCpuIoWidthUint16 + 4, // EfiCpuIoWidthUint32 + 8, // EfiCpuIoWidthUint64 + 0, // EfiCpuIoWidthFifoUint8 + 0, // EfiCpuIoWidthFifoUint16 + 0, // EfiCpuIoWidthFifoUint32 + 0, // EfiCpuIoWidthFifoUint64 + 1, // EfiCpuIoWidthFillUint8 + 2, // EfiCpuIoWidthFillUint16 + 4, // EfiCpuIoWidthFillUint32 + 8 // EfiCpuIoWidthFillUint64 +}; + +// +// Lookup table for increment values based on transfer widths +// +STATIC CONST UINT8 mOutStride[] = { + 1, // EfiCpuIoWidthUint8 + 2, // EfiCpuIoWidthUint16 + 4, // EfiCpuIoWidthUint32 + 8, // EfiCpuIoWidthUint64 + 1, // EfiCpuIoWidthFifoUint8 + 2, // EfiCpuIoWidthFifoUint16 + 4, // EfiCpuIoWidthFifoUint32 + 8, // EfiCpuIoWidthFifoUint64 + 0, // EfiCpuIoWidthFillUint8 + 0, // EfiCpuIoWidthFillUint16 + 0, // EfiCpuIoWidthFillUint32 + 0 // EfiCpuIoWidthFillUint64 +}; + +/** + Check parameters to a CPU I/O 2 Protocol service request. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The parameters for this request pass the checks. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +STATIC +EFI_STATUS +CpuIoCheckParameter ( + IN BOOLEAN MmioOperation, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + UINT64 MaxCount; + UINT64 Limit; + + // + // Check to see if Buffer is NULL + // + if (Buffer == NULL) { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Width is in the valid range + // + if ((UINT32)Width >= EfiCpuIoWidthMaximum) { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + // + // For FIFO type, the target address won't increase during the access, + // so treat Count as 1 + // + if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) { + Count = 1; + } + + // + // Check to see if Width is in the valid range for I/O Port operations + // + Width = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03); + if (!MmioOperation && (Width == EfiCpuIoWidthUint64)) { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Address is aligned + // + if ((Address & (UINT64)(mInStride[Width] - 1)) != 0) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + + // + // Check to see if any address associated with this transfer exceeds the maximum + // allowed address. The maximum address implied by the parameters passed in is + // Address + Size * Count. If the following condition is met, then the transfer + // is not supported. + // + // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 + // + // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count + // can also be the maximum integer value supported by the CPU, this range + // check must be adjusted to avoid all oveflow conditions. + // + // The following form of the range check is equivalent but assumes that + // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). + // + Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); + if (Count == 0) { + if (Address > Limit) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + } else { + MaxCount = RShiftU64 (Limit, Width); + if (MaxCount < (Count - 1)) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + } + + // + // Check to see if Buffer is aligned + // + if (((UINTN)Buffer & ((MIN (sizeof (UINTN), mInStride[Width]) - 1))) != 0) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Reads memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +STATIC +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + *Uint8Buffer = MmioRead8 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint64) { + *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); + } + } + return EFI_SUCCESS; +} + +/** + Writes memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +STATIC +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + MmioWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint64) { + MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); + } + } + return EFI_SUCCESS; +} + +/** + Reads I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +STATIC +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + if ((Address >= SYNQUACER_PCI_SEG0_PORTIO_MIN) && + (Address <= SYNQUACER_PCI_SEG0_PORTIO_MAX)) { + Address += SYNQUACER_PCI_SEG0_PORTIO_MEMBASE; + } else if ((Address >= SYNQUACER_PCI_SEG1_PORTIO_MIN) && + (Address <= SYNQUACER_PCI_SEG1_PORTIO_MAX)) { + Address += SYNQUACER_PCI_SEG1_PORTIO_MEMBASE; + + } else { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03); + + for (Uint8Buffer = Buffer; Count > 0; + Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + *Uint8Buffer = MmioRead8 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); + } + } + + return EFI_SUCCESS; +} + +/** + Write I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +STATIC +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + // + // Make sure the parameters are valid + // + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + if ((Address >= SYNQUACER_PCI_SEG0_PORTIO_MIN) && + (Address <= SYNQUACER_PCI_SEG0_PORTIO_MAX)) { + Address += SYNQUACER_PCI_SEG0_PORTIO_MEMBASE; + } else if ((Address >= SYNQUACER_PCI_SEG1_PORTIO_MIN) && + (Address <= SYNQUACER_PCI_SEG1_PORTIO_MAX)) { + Address += SYNQUACER_PCI_SEG1_PORTIO_MEMBASE; + + } else { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03); + + for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; + Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + MmioWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } + } + + return EFI_SUCCESS; +} + +// +// CPU I/O 2 Protocol instance +// +STATIC EFI_CPU_IO2_PROTOCOL mCpuIo2 = { + { + CpuMemoryServiceRead, + CpuMemoryServiceWrite + }, + { + CpuIoServiceRead, + CpuIoServiceWrite + } +}; + + +/** + The user Entry Point for module CpuIo2Dxe. The user code starts with this function. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +SynQuacerPciCpuIo2Initialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIo2ProtocolGuid); + Status = gBS->InstallMultipleProtocolInterfaces ( + &mHandle, + &gEfiCpuIo2ProtocolGuid, &mCpuIo2, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf new file mode 100644 index 000000000000..04d418a2a0c9 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf @@ -0,0 +1,50 @@ +## @file +# Produces the CPU I/O 2 Protocol by using the services of the I/O Library. +# +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2017, Linaro Ltd. 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 = SynQuacerPciCpuIo2Dxe + FILE_GUID = cee8beea-507a-49f4-a3d7-d1100a2008cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = SynQuacerPciCpuIo2Initialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 +# + +[Sources] + SynQuacerPciCpuIo2Dxe.c + +[Packages] + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib + PcdLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiCpuIo2ProtocolGuid ## PRODUCES + +[Depex] + TRUE From patchwork Fri Nov 10 14:21:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118544 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258302edl; Fri, 10 Nov 2017 06:22:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMbqTLnXTABjb6paaINY3P77z7qKYO5DLS7+N850bfEEQuhnIE171lalwc6jHQyvJUP449tJ X-Received: by 10.84.234.199 with SMTP id i7mr522531plt.15.1510323754837; Fri, 10 Nov 2017 06:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323754; cv=none; d=google.com; s=arc-20160816; b=nbQwAbb6MqmBm1kwFN6Q7phSGqZMQH8nvfBue1w5OFu4S2+A6CXCXSmNbzFfGfH9fP b+x6ozYyhCOydp0e3X5lDMtzCBAW6MbLkWAowwmvhFExoZ5q9DxApJmVHVWh/aOwgP9M EU0UEj+SLOtDT577F0QRivvuUJn9zVsQPpZ8zRrZKkUVmKp0VP6peJxDEfGvN4h+TEE2 dFVFFbsiX4JmO0RUfODOqyDUjkfi3a076deTZgbf9ZxtIXYKAohVk7UlsiJJk5rsTj6c ZyCx59D2C+8hMBmGiIUeydJzHSNEhKQ2gyF+SeA2Daw6YJZ8j/c26YY6ZBpv+7Bwaw2g wrhg== 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=iFPm67INv+Nmu7FaCVE+akmZ21dRLQMqnahe9OgkLn0=; b=0oX0nOAyniKbt7Bki3vbi7/3560fygUjqUTjKPKRBFg5Mv7PLf4V1aGI2tuyFSY0oI P2HW/CnJlT+2XlocjiKnXM5xjCngP4LYJlsp+zDwbab+90YSuA8rxCBxj8MlPYuytiQd JOjhYd6fDm6RXMlP1yKWuk3fxxF0W6yfgLhH9BybGeefhBEO8D7Z1OjmMOZk19fqJ5Kv utVYQvC4WOjcK5lxpa1HxQmSIBOQ9UV0Wskzg94YmxekSSudKZSc51s1X5hFOHR/FT/x qxoIZdabHw+hLM3eY2ETTc2mlvmcm5aGukOFDp7bNENSkCd1+/MTcVDb6I4T08pEwt/A JCoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c2gEOsZZ; 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 f5si9096724plo.19.2017.11.10.06.22.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:34 -0800 (PST) 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=c2gEOsZZ; 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 5528221B00DE1; Fri, 10 Nov 2017 06:18:15 -0800 (PST) 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=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 03BA321B00DDB for ; Fri, 10 Nov 2017 06:18:13 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id b189so3054959wmd.4 for ; Fri, 10 Nov 2017 06:22:17 -0800 (PST) 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=A2wHrCaHaQqqVGNGv8u5ZLl17wFLCoK8lKQJLnLOAjU=; b=c2gEOsZZiM/6kxcWPZRyGKjZjIzA2NqNgPope5VsGMlkqBbZiPal3nOYgVL60Fw4VT Djd7ZG/Pv7vnU4jrUW/wsEL/YRTyXqfm6qUExJNT9H7n/ML/bSNa2CQqznJ+yZ9R7qMH 7irb6PkRoYCtSdUJVRAE2SzTWwMSfnlydUXZs= 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=A2wHrCaHaQqqVGNGv8u5ZLl17wFLCoK8lKQJLnLOAjU=; b=XO1PgHILmp1Kr4oWIoP0vER35O7qTjtyDVGzTw4EY79/0InNSwWMFxzcTSQqZ0mla1 vXZnkaSk7CUVahm3gthGq1A/nX+PdEMd40YXrlJ1mKUfFaEB3yTESnYa4SxVoaiH5KGc g/4NQnhsTZw14/izPuiFzgvRvayEOeM5daW0yCk1KMvdcDrTvWx3ks6A70+HOripT1Qh TVdwKSFNgTHphjkYcRE1NOnS1BIuKHY3ehbolWgeaVmGbtYKGXEGwOK3IUb2qRrYjR7y 3jpW5IJS1+RY/P8lGvgvlgZuMs7vTpwExHBLf9GVRs7H3wYjHSNd9U5vFR/YtPPlJPRs jpQA== X-Gm-Message-State: AJaThX7R3ZMH12GCsYkOs6ABXGZ8W2MhSgBaDPRqVf9RmWik5w8mqgeA FAy7uNIqh7Kv9wqh54w7ibjRHBKxTvI= X-Received: by 10.28.147.84 with SMTP id v81mr367954wmd.102.1510323735388; Fri, 10 Nov 2017 06:22:15 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:14 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:03 +0000 Message-Id: <20171110142127.12018-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 10/34] Platform/SynQuacerEvalBoard: add PCI support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Wire up the various drivers and libraries for the SynQuacerEvalBoard platform. Also enable the usual PCI suspects: XHCI, SATA and NVME, and the various bus, partition and file system drivers that we need to make use of PCIe devices. Given how PCI support enables USB support too, and taking the lack of a RNG on this SoC into account, let's enable the ChaosKey driver as well. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 52 ++++++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 41 +++++++++++++++ 2 files changed, 93 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 59c55fe13af1..126a588de587 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -100,6 +100,7 @@ [LibraryClasses.common] DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf + UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf # BDS Libraries UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf @@ -153,6 +154,12 @@ [LibraryClasses.common.DXE_DRIVER] SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + # + # PCI + # + PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf + PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf + [LibraryClasses.common.UEFI_APPLICATION] PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf @@ -196,6 +203,7 @@ [PcdsFixedAtBuild.common] gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0x2E00FFC0 gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40 + gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|24 # 12x 2-core processor clusters gArmPlatformTokenSpaceGuid.PcdCoreCount|2 @@ -438,3 +446,47 @@ [Components.common] # Platform driver # Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf + + # + # PCI + # + Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F + } + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf + MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf + MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + + # + # AHCI Support + # + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # + # USB + # + MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf + + # + # FAT filesystem + GPT/MBR partitioning + # + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + + # + # RNG + # + Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index cc5377b1413f..b72a8ef664c3 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -133,6 +133,47 @@ [FV.FvMain] # INF Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf + # + # PCI + # + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf + INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf + INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf + INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf + INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + + # + # AHCI Support + # + INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # + # USB + # + INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf + + # + # FAT filesystem + GPT/MBR partitioning + # + INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf + INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + INF FatPkg/EnhancedFatDxe/Fat.inf + + # + # RNG + # + INF Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf + [FV.FVMAIN_COMPACT] FvAlignment = 16 BlockSize = 0x10000 From patchwork Fri Nov 10 14:21:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118545 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258361edl; Fri, 10 Nov 2017 06:22:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYBNOIqk2DSGyy6P8kQ+003fh+CV3vKi8my4MGWCtZu1WhVo6f5aOGo/lznkU10LJJn4iX8 X-Received: by 10.159.229.203 with SMTP id t11mr551131plq.190.1510323758619; Fri, 10 Nov 2017 06:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323758; cv=none; d=google.com; s=arc-20160816; b=dVOlRgO1YqpXn92Q1Xs+6owl0Ifz2zMChdfzIpZ4F4CunHhQ9AhNUA7jD2NrCC+J27 QQu25RiQpxwep9RTUk7zD4DxdrJvgdxpoWeEILqaMBt6kQsP4ZlmgrYyGkAZctNnzCCm GoCLVeSsD2NKwYCQ/UgZ/I+llgihW8hXsHPe01iBX9cc4onkD4JjFXTCWdzuVnWf31OS n5LZzM9LjVd0L5cagmQflfIK9QLRwqK+VLRktWy0pqQA6nOBbvgco+FjARt0Flj3NrFJ xIQ2WETRMAcyp7N186qhCX+tMfOrLbhXfVPi3Tc2XD3T8JBWKzoPqfWyLhJwlGpc8v1/ zv2w== 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=da8AnVCt9CEBKGvM2i0csvHQxuisonuRT839cJXLWzU=; b=Tuk57CjVGHkS2dRqEaa4T2WdiM7geP3rTk+7N/n5sabhUqm1tYGdobCkGPOE4slP2A ULKzBfcsJ0qXJZCRW4BkvSaLbxRyZ2LmxijAdvd77jfU2W9/G/vyf5eSJmRABqVUrGRD UHioMsJgpKFCbjdiQc3EJ6cLkKnZZMoVe+TcvEfhWdiMfAbaCGSX3C/3bzIUT5Jr3ySc qNF4ymIkUIuHZ3APetE2y7IqFT2Z4Lckc4hSiZO6DMr7u0sbFcx/qL+1bFRT+0zxsawI pVud6uIwzq+Mv8izSfzUxlirv3y0D4PBE3oTfZJs08DZb0zywLbN3+KZ6eRPEEoA0jYp G9Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=htUYHn7F; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id m13si368519pln.97.2017.11.10.06.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=htUYHn7F; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 8E4EC203555F8; Fri, 10 Nov 2017 06:18:18 -0800 (PST) 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=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 7D16F21B00DE5 for ; Fri, 10 Nov 2017 06:18:16 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id y42so8765375wrd.3 for ; Fri, 10 Nov 2017 06:22:19 -0800 (PST) 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=JJ7T7q9GA/zE7n7i5It2m4PvCeH3l2zh8mE/fZOBjCI=; b=htUYHn7FCrfp/9g+vstoK6lTnup1Jod+EaThVBCr6Z8nLzWtn0dd9BE9GcKJrMqSP5 FAjTRma8l7PVt6IO3JHzA7d8Wa5Py8YZhGVT++nysdaSDaLDEZk2X/hr7apzqX8uXHzw dr21XPsEc3yrBA+m+J28WNxmVavRRKnQeEmHY= 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=JJ7T7q9GA/zE7n7i5It2m4PvCeH3l2zh8mE/fZOBjCI=; b=oqAw+zeUuiF94VdZoqJl7aoaRqbsqgbI5UT/3uJc1hh7z9Y4G3A/DHeWOjhggsIFxm 0RrgrIse9xlwcKiKoaTh9oKCQS79ZkLa89JAG3F0JYm7dw7aoKnyuXVl78PkD2qD2lLd UqBltSTaMmhw50g7CKe/xlZapEfkvjJoyhzLRmIRyn/w6nP+k0rSHc4K2BOktdAUnr8F 1h8GOa/rzpYMd9wia2eR2nWGd78jZHCU+nr1iXxCFexuG/gsA/08maM8O1A8ixE2enud AFiaMbJBthTw2O4h/LqRNob0z5sF5zXtI8pKJCaGpbJS+M/U40ictfveBF1N9kpxkkef n1TQ== X-Gm-Message-State: AJaThX6J9GD4go+LPzKCRRHK+7FhMrturianej+YBxZ9+hEBQdQ/695q 4XwbzK/K06aQpU1kZMR+8iY6BoHAKVY= X-Received: by 10.223.185.121 with SMTP id b54mr456619wrg.264.1510323737897; Fri, 10 Nov 2017 06:22:17 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:17 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:04 +0000 Message-Id: <20171110142127.12018-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 11/34] Platform/SynQuacerEvalBoard: add NETSEC driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add the NETSEC driver to the SynQuacerEvalBoard platform. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 46 ++++++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 24 ++++++++++ 2 files changed, 70 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 126a588de587..f6a1d1ad8eda 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -114,6 +114,9 @@ [LibraryClasses.common] SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf + HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf + TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf @@ -233,6 +236,22 @@ [PcdsFixedAtBuild.common] gArmTokenSpaceGuid.PcdGenericWatchdogControlBase|0x2a440000 gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase|0x2a450000 + # + # NETSEC Info + # + gNetsecDxeTokenSpaceGuid.PcdEncTxDescNum|128 + gNetsecDxeTokenSpaceGuid.PcdDecRxDescNum|128 + gNetsecDxeTokenSpaceGuid.PcdJumboPacket|0 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrl|0 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold|36 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold|48 + gNetsecDxeTokenSpaceGuid.PcdPauseTime|256 + + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0x10000000 + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|1 + + gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 @@ -490,3 +509,30 @@ [Components.common] # RNG # Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf + + # + # Networking stack + # + MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf + MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf + MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf + MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf + MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf + MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf + MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf + MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf + NetworkPkg/Ip6Dxe/Ip6Dxe.inf + NetworkPkg/TcpDxe/TcpDxe.inf + NetworkPkg/Udp6Dxe/Udp6Dxe.inf + NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf + NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf + NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf + NetworkPkg/IScsiDxe/IScsiDxe.inf + NetworkPkg/DnsDxe/DnsDxe.inf + NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf + NetworkPkg/HttpDxe/HttpDxe.inf + NetworkPkg/HttpBootDxe/HttpBootDxe.inf + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf { + + DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf + } diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index b72a8ef664c3..d87829b18902 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -174,6 +174,30 @@ [FV.FvMain] # INF Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf + # + # Networking stack + # + INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf + INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf + INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf + INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf + INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf + INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf + INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf + INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf + INF NetworkPkg/Ip6Dxe/Ip6Dxe.inf + INF NetworkPkg/TcpDxe/TcpDxe.inf + INF NetworkPkg/Udp6Dxe/Udp6Dxe.inf + INF NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf + INF NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf + INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf + INF NetworkPkg/IScsiDxe/IScsiDxe.inf + INF NetworkPkg/DnsDxe/DnsDxe.inf + INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf + INF NetworkPkg/HttpDxe/HttpDxe.inf + INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf + INF Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf + [FV.FVMAIN_COMPACT] FvAlignment = 16 BlockSize = 0x10000 From patchwork Fri Nov 10 14:21:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118546 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258445edl; Fri, 10 Nov 2017 06:22:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMZfl5hBkM0ySkLM9j3iqSkQ7QZEiQlXQxXK5OyJj3l9fBLejDtNaBi2GRRf1KWGwGkD7Ha9 X-Received: by 10.99.119.79 with SMTP id s76mr519184pgc.192.1510323762828; Fri, 10 Nov 2017 06:22:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323762; cv=none; d=google.com; s=arc-20160816; b=BcbMmK86biVfXdgAm2WQ98FRC9UrMP9z65jNINta8eHnz2vV3qDakbDdo9qOdaSyCm Y6i7AQfD5KYvclsQKX3omJNid6GOcWFoQrQp2z/ThODr3mO8DXOmD0ix1YO03sPhFWoU MKoy5JGZEZ3EzUj7+i8W1p/+e1jbltiPdmy89+t3nB9RWp8oB5k1lOYMUYD8Mtn0n23s a9WkUBprbKevZ9pWoLPXTtniv8AWPOBscIyipihZRwRfLn+Gjdddi2daRi6w8RuZAo7A +sHZE41TqaI029iRUpzz24gq4vnfOW4SUuYk4iqf49w5FqAywnnK2DKZdLzJAZ3EeLB6 jYNA== 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=1p0OkbG7IcGx+3j7g7M+7Q4QtBaJMRmpDAu/3syJqc8=; b=bkZ6YhZRJl5wXCn6xt6PrlUIO2ho9TNycAN33WHWSbfTwesrHkyyqCl+UuwZG21xLo xxRTOfM7fCV8+wNyqY9Db+Lo6mH3c/X9DTMefkOuCkMMZbdLa+FJGKDPKStQuLOWBX4B pSIl8X/QSW9BYxn3fd2LtMeT4cyDIVkFRvADm3sJLNqjKaLFMBg5mUQahExHoDnIURvA SX+/cw0+80erd0/71WdaO4y2M0ZO3qmxFtfLQFgv7kNqKO1Fwfznd9El8ty6/+XHVGGx WpyLpIoeFx4ZTsQv/cWWhFgVZ4aKSFa4ZYlmx7curPw3HBydvcgCAa+mOxIF2lsiPxi0 koSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eUFYxP9r; 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 x124si9514801pfx.301.2017.11.10.06.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:42 -0800 (PST) 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=eUFYxP9r; 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 C40ED20355601; Fri, 10 Nov 2017 06:18:20 -0800 (PST) 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=2a00:1450:400c:c09::244; helo=mail-wm0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 3C97D21B00DE6 for ; Fri, 10 Nov 2017 06:18:19 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id b189so3055439wmd.4 for ; Fri, 10 Nov 2017 06:22:22 -0800 (PST) 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=3ZYOtXl+qz5jetX1oIUTRS6NBSaOg7PPEsyxogE2a14=; b=eUFYxP9r59sH1BYShfsLn7cJl1tQkXSIetlg4InRwMQUVHZwAkWnqJzEQe9WZRITvQ YrsUScnV7XAQ6q8vyaFqJiQ29M5lL2qOHB8uhw7H4OzjOA5A01bfNHHAuJEHinDpAQkk xaYAl0NeJgwFuxy7URHUVagc53I27j2a8yuuo= 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=3ZYOtXl+qz5jetX1oIUTRS6NBSaOg7PPEsyxogE2a14=; b=WEuwll0WBWGlFagB4sCorNzXECOnfVuEkc8E0jY+oxI0tiATnX8PagPeX7mpWr9mzG KaH0YYPye7UEjIvNWgoFcjh11GxvTBQ2E9wudh9oxeRBUhani2s6wl/ZCQcQ0yreNnO7 yyrD8vESm+VD8zGL0oDuDCI2qfVlzLKfyWWvVbZFVc18bVUoD9Y/LADyVf/JPipDGIVw mLoFy/r3g4XGcrrwUbrKSF0qmypgktKmC9k8oM0Tx664HMhoMVXnqoBz5q+zzd/bwdks bMgkuJRSX1oCdNhK7Wk/tvYfefVpaFWfPK3QdEyHXLbVObnGMP13+YpSibUU7ujkaSxW BPdA== X-Gm-Message-State: AJaThX5sdUuyalvdrHzdcW6udvuyOvtUchvxEzGKTKQhAqiFCJYwyRRn Ujev+jGC+y9L99Fz91LCSTQiVCij9Fk= X-Received: by 10.28.169.198 with SMTP id s189mr338530wme.65.1510323740276; Fri, 10 Nov 2017 06:22:20 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:19 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:05 +0000 Message-Id: <20171110142127.12018-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 12/34] Silicon/SynQuacer: add device tree support for eval board X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a device tree description of the SynQuacer SoC, and expose it for the SynQuacerEvalBoard platforms. This includes the menu option in the UEFI boot menu to switch between ACPI and DT. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 6 + Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 11 + Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 514 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts | 21 + Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf | 33 ++ 5 files changed, 585 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index f6a1d1ad8eda..60a53dd797ed 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -154,6 +154,7 @@ [LibraryClasses.common.DXE_CORE] PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf [LibraryClasses.common.DXE_DRIVER] + DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf @@ -536,3 +537,8 @@ [Components.common] DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf } + + # + # DT support + # + Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index d87829b18902..c10e333efd43 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -1,3 +1,4 @@ + # # Copyright (c) 2013-2014, ARM Limited. All rights reserved. # Copyright (c) 2017, Linaro Limited. All rights reserved. @@ -198,6 +199,11 @@ [FV.FvMain] INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf INF Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf + # + # DT support + # + INF RuleOverride = DTB Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf + [FV.FVMAIN_COMPACT] FvAlignment = 16 BlockSize = 0x10000 @@ -336,3 +342,8 @@ [Rule.Common.UEFI_APPLICATION.BINARY] UI STRING="$(MODULE_NAME)" Optional VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) } + +[Rule.Common.USER_DEFINED.DTB] + FILE FREEFORM = $(NAMED_GUID) { + RAW BIN |.dtb + } diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi new file mode 100644 index 000000000000..f89e722219ad --- /dev/null +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -0,0 +1,514 @@ +/** @file + * Copyright (c) 2017, 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. + */ + +#define GIC_SPI 0 +#define GIC_PPI 1 + +#define IRQ_TYPE_NONE 0 +#define IRQ_TYPE_EDGE_RISING 1 +#define IRQ_TYPE_EDGE_FALLING 2 +#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) +#define IRQ_TYPE_LEVEL_HIGH 4 +#define IRQ_TYPE_LEVEL_LOW 8 + +/ { + #address-cells = <2>; + #size-cells = <2>; + interrupt-parent = <&gic>; + dma-ranges = <0x0 0x0 0x0 0x0 0x100 0x0>; + + aliases { + serial0 = &soc_uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x1>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU2: cpu@100 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU3: cpu@101 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x101>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU4: cpu@200 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x200>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU5: cpu@201 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x201>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU6: cpu@300 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x300>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU7: cpu@301 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x301>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU8: cpu@400 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x400>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU9: cpu@401 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x401>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU10: cpu@500 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x500>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU11: cpu@501 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x501>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU12: cpu@600 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x600>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU13: cpu@601 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x601>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU14: cpu@700 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x700>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU15: cpu@701 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x701>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU16: cpu@800 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x800>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU17: cpu@801 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x801>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU18: cpu@900 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x900>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU19: cpu@901 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0x901>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU20: cpu@a00 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0xa00>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU21: cpu@a01 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0xa01>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU22: cpu@b00 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0xb00>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + CPU23: cpu@b01 { + device_type = "cpu"; + compatible = "arm,cortex-a53","arm,armv8"; + reg = <0xb01>; + enable-method = "psci"; + //cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; + }; + + cpu-map { + cluster0 { + core0 { + cpu = <&CPU0>; + }; + core1 { + cpu = <&CPU1>; + }; + }; + cluster1 { + core0 { + cpu = <&CPU2>; + }; + core1 { + cpu = <&CPU3>; + }; + }; + cluster2 { + core0 { + cpu = <&CPU4>; + }; + core1 { + cpu = <&CPU5>; + }; + }; + cluster3 { + core0 { + cpu = <&CPU6>; + }; + core1 { + cpu = <&CPU7>; + }; + }; + cluster4 { + core0 { + cpu = <&CPU8>; + }; + core1 { + cpu = <&CPU9>; + }; + }; + cluster5 { + core0 { + cpu = <&CPU10>; + }; + core1 { + cpu = <&CPU11>; + }; + }; + cluster6 { + core0 { + cpu = <&CPU12>; + }; + core1 { + cpu = <&CPU13>; + }; + }; + cluster7 { + core0 { + cpu = <&CPU14>; + }; + core1 { + cpu = <&CPU15>; + }; + }; + cluster8 { + core0 { + cpu = <&CPU16>; + }; + core1 { + cpu = <&CPU17>; + }; + }; + cluster9 { + core0 { + cpu = <&CPU18>; + }; + core1 { + cpu = <&CPU19>; + }; + }; + cluster10 { + core0 { + cpu = <&CPU20>; + }; + core1 { + cpu = <&CPU21>; + }; + }; + cluster11 { + core0 { + cpu = <&CPU22>; + }; + core1 { + cpu = <&CPU23>; + }; + }; + }; + }; + + idle-states { + entry-method = "arm,psci"; + + CPU_SLEEP_0: cpu-sleep-0 { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0010000>; + entry-latency-us = <300>; + exit-latency-us = <1200>; + min-residency-us = <2000>; + local-timer-stop; + }; + + CLUSTER_SLEEP_0: cluster-sleep-0 { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1010000>; + entry-latency-us = <400>; + exit-latency-us = <1200>; + min-residency-us = <2500>; + local-timer-stop; + }; + }; + + gic: interrupt-controller@30000000 { + compatible = "arm,gic-v3"; + reg = <0x0 0x30000000 0x0 0x10000>, // GICD + <0x0 0x30400000 0x0 0x300000>, // GICR + <0x0 0x2c000000 0x0 0x2000>, // GICC + <0x0 0x2c010000 0x0 0x1000>, // GICH + <0x0 0x2c020000 0x0 0x2000>; // GICV + #interrupt-cells = <3>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + interrupt-controller; + interrupts = ; + + its: gic-its@30020000 { + compatible = "arm,gic-v3-its"; + reg = <0x0 0x30020000 0x0 0x20000>; + #msi-cells = <1>; + msi-controller; + socionext,synquacer-pre-its = <0x58000000 0x200000>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupts = , // secure + , // non-secure + , // virtual + ; // HYP + }; + + mmio-timer@2a810000 { + compatible = "arm,armv7-timer-mem"; + reg = <0x0 0x2a810000 0x0 0x10000>; + clock-frequency = <100000000>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + frame@2a830000 { + frame-number = <0>; + interrupts = ; + reg = <0x0 0x2a830000 0x0 0x10000>; + }; + }; + + pmu { + compatible = "arm,armv8-pmuv3"; + interrupts = ; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + }; + + mailbox: mhu@45000000 { + compatible = "arm,mhu", "arm,primecell"; + reg = <0x0 0x45000000 0x0 0x1000>; + interrupts = , + ; /* Non-Sec */ + interrupt-names = "mhu_lpri_rx", "mhu_hpri_rx"; + #mbox-cells = <1>; + clocks = <&clk_apb>; + clock-names = "apb_pclk"; + }; + + sram: sram@45200000 { + compatible = "mmio-sram"; + reg = <0x0 0x45200000 0x0 0x200>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x0 0x45200000 0x200>; + + cpu_scp_hpri: scp-shmem@0 { + reg = <0x0 0x200>; + }; + }; + + scpi { + compatible = "arm,scpi"; + mboxes = <&mailbox 1>; + shmem = <&cpu_scp_hpri>; + }; + + clk_uart: refclk62500khz { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <62500000>; + clock-output-names = "uartclk"; + }; + + clk_apb: refclk100mhz { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <100000000>; + clock-output-names = "apb_pclk"; + }; + + soc_uart0: uart@2a400000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x0 0x2a400000 0x0 0x1000>; + interrupts = ; + clocks = <&clk_uart &clk_apb>; + clock-names = "uartclk", "apb_pclk"; + }; + + clk_netsec: refclk125mhz { + compatible = "fixed-clock"; + clock-frequency = <125000000>; + #clock-cells = <0>; + }; + + eth0: netsec@522D0000 { + compatible = "socionext,synquacer-netsec"; + reg = <0 0x522d0000 0x0 0x10000>, + <0 FixedPcdGet32 (PcdNetsecEepromBase) 0x0 0x10000>; + interrupts = ; + clocks = <&clk_netsec>; + phy-mode = "rgmii"; + max-speed = <1000>; + max-frame-size = <9000>; + phy-handle = <ðphy0>; + + #address-cells = <1>; + #size-cells = <0>; + + ethphy0: ethernet-phy { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = ; + }; + }; + + smmu: iommu@582c0000 { + compatible = "arm,mmu-500", "arm,smmu-v2"; + reg = <0x0 0x582c0000 0x0 0x10000>; + #global-interrupts = <1>; + interrupts = , + , + ; + #iommu-cells = <1>; + status = "disabled"; + }; + + pcie0: pcie@60000000 { + compatible = "socionext,synquacer-pcie-ecam", "snps,dw-pcie-ecam"; + device_type = "pci"; + reg = <0x0 0x60000000 0x0 0x7f00000>; + bus-range = <0x0 0x7e>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x1000000 0x00 0x00000000 0x00 0x67f00000 0x0 0x00010000>, + <0x2000000 0x00 0x68000000 0x00 0x68000000 0x0 0x08000000>, + <0x3000000 0x3e 0x00000000 0x3e 0x00000000 0x1 0x00000000>; + + #interrupt-cells = <0x1>; + interrupt-map-mask = <0x0 0x0 0x0 0x0>; + interrupt-map = <0x0 0x0 0x0 0x0 &gic 0x0 0x0 GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>; + + msi-map = <0x000 &its 0x0 0x7f00>; + dma-coherent; + }; + + pcie1: pcie@70000000 { + compatible = "socionext,synquacer-pcie-ecam", "snps,dw-pcie-ecam"; + device_type = "pci"; + reg = <0x0 0x70000000 0x0 0x7f00000>; + bus-range = <0x0 0x7e>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x1000000 0x00 0x00010000 0x00 0x77f00000 0x0 0x00010000>, + <0x2000000 0x00 0x78000000 0x00 0x78000000 0x0 0x08000000>, + <0x3000000 0x3f 0x00000000 0x3f 0x00000000 0x1 0x00000000>; + + #interrupt-cells = <0x1>; + interrupt-map-mask = <0x0 0x0 0x0 0x0>; + interrupt-map = <0x0 0x0 0x0 0x0 &gic 0x0 0x0 GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>; + + msi-map = <0x0 &its 0x10000 0x7f00>; + dma-coherent; + }; +}; diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts new file mode 100644 index 000000000000..cda72fdf2f99 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts @@ -0,0 +1,21 @@ +/** @file + * Copyright (c) 2017, 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. + */ + +/dts-v1/; + +#include "SynQuacer.dtsi" + +/ { + model = "SynQuacer Evaluation Board"; + compatible = "socionext,synquacer-eval-board", "socionext,synquacer"; +}; diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf new file mode 100644 index 000000000000..af9a283e67a2 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf @@ -0,0 +1,33 @@ +## @file +# +# Device tree description of the SynQuacer platform +# +# Copyright (c) 2017, Linaro Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerDeviceTree + FILE_GUID = 25462CDA-221F-47DF-AC1D-259CFAA4E326 # gDtPlatformDefaultDtbFileGuid + MODULE_TYPE = USER_DEFINED + VERSION_STRING = 1.0 + +[Sources] + SynQuacerEvalBoard.dts + +[Packages] + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[FixedPcd] + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress From patchwork Fri Nov 10 14:21:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118547 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258547edl; Fri, 10 Nov 2017 06:22:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMaBChbFFg8mgwGzzskvY19bG1JQ/eWp6roFlNo2tyATHTLXYV+gHRQ2jPsXtDINcqs1RSYB X-Received: by 10.99.155.25 with SMTP id r25mr408061pgd.397.1510323767692; Fri, 10 Nov 2017 06:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323767; cv=none; d=google.com; s=arc-20160816; b=R//pUX5Ll0dc5TNThqe0eUsdDr9UYZkXSA7DznqTywYr69xROK000N5bhHM2EiuKkw 9ZHB+SNNV3uKYfW4nyXfO2JUJ1bM+RfCfHhJvbDHhV3UAKNnaLu4dFOLlZz72DOciAUW /diB4h7xXWan1TWpzvJIx6oRWiZNhf/MiukB1PpkExlDu7BLgt7kFFQo1BkBGOkotEs+ XjbkDu0nEQVdNFcwBl/AwZ3bAyf4v/lDtdDG/w8ChMOfZorOHCVlYuKH1cCxv2sCK5bA 4lp7uQhTXKkXbUwmHAe79LvbbZO6uJLQhyueaw4Dk4TSGyAuEs3DvYA+HZ+oL2DX7RvA gx+A== 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=dfqGwnTDfGtgbhq6vl+ebxR3oga7vc7RWkclsqa0J9c=; b=TvefdQgAhP0M0Nqh9t0HgwmDf5UG+Y76FY1VQfXTxfSFOKA07wnszTRhlLLgj8eTOt sF3vgZKtisQmWbMNCa9+1oroZp1cuKnb+/6JozfEczsSouy2SU3Vm3oe7JbFWpuWk/nH 2rWBFx2ccbk64A4wRowHfDrq+64T/UiNNQXRsSEL0ZMhnr0kHvjPCH1bVrgN2H9lT96a y1vRc8sQEkAVBPGJE8M4Go9lwk2DjZDmZniKCILuK0lNncjXKEIFSN6a6PjzEExoX7xx k2CH4deubbrLlleZpMoJRsTnkc88fSd0wYXsZtIj39himdlGmal2D5InpfDM0e5APjXv J8vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VJFu+66g; 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 f17si9056949pga.566.2017.11.10.06.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:47 -0800 (PST) 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=VJFu+66g; 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 09B522035561B; Fri, 10 Nov 2017 06:18:22 -0800 (PST) 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=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 73D5821B00DE8 for ; Fri, 10 Nov 2017 06:18:21 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id t139so3093400wmt.1 for ; Fri, 10 Nov 2017 06:22:24 -0800 (PST) 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=IPr7AbXPPgixWsBE7QeQvFZqBjvEI/igEvxr7mqMwYs=; b=VJFu+66gg+jI9SqIkGLz9rL87Wgdf0PRZPwiy5rfdAtXrKhnXKZFJQBqfPYrdDBBPw 8PYBeyI3LmcDEcQyw4ZS9/Ww1oUUCAsoyD2u9lOynLluWRMH6KJHn6GtxRO1SSURkUqB 5yvg9QOaTka/7Ns4js4k2tS0p4BQSvpKD12QY= 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=IPr7AbXPPgixWsBE7QeQvFZqBjvEI/igEvxr7mqMwYs=; b=BbapwXR8NkSpczOdxpyr1bdpyUFRms8Usq/DMUX0wNekxljyCOadli/13+eGOt5r+r X3hRI4kYksju3lAHcn2aodkVwVV7FtS1FHDEdoha7XPKEXHK/hiNHs03H3X45Kv2Qoy4 21beweBVCKIAcc/SyEyeM+J09MkXLX9OKmX0FhNhnuNHxSy73/4vxmQhIjvTGMkp8cBX iRtiS29klc2bQSPW/lwPWm5lwqvV94hW5jWXgv0ldaDZsxSoWH5uYAK0RqeHI+lSM2x5 rmHuxq8lhAMNXA/gxW0ZuKM6gm6kGeKV40/qvJTX+1gyEuYHJAhc8jpWU1cuay+LeoL7 TR2Q== X-Gm-Message-State: AJaThX6cLVhhvhPzX/GV8f3WaAgvyMhRChFsQXJlt5iJcAOZaFEl7I2d MJE8LwTbvwYD/QRaYYi7RVeHM135RaI= X-Received: by 10.28.32.136 with SMTP id g130mr398686wmg.102.1510323742836; Fri, 10 Nov 2017 06:22:22 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:22 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:06 +0000 Message-Id: <20171110142127.12018-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 13/34] Silicon/SynQuacer: add NorFlashPlatformLib implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add the platform glue for the NOR flash driver. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c | 70 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf | 41 ++++++++++++ 2 files changed, 111 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c new file mode 100644 index 000000000000..816d8ba33f8c --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c @@ -0,0 +1,70 @@ +/** @file + + Copyright (c) 2011-2014, ARM Ltd. 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 + +STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = { + { + // UEFI code region + SYNQUACER_SPI_NOR_BASE, // device base + FixedPcdGet64 (PcdFdBaseAddress), // region base + FixedPcdGet32 (PcdFdSize), // region size + SIZE_64KB, // block size + { + 0x19c118b0, 0xc423, 0x42be, { 0xb8, 0x0f, 0x70, 0x6f, 0x1f, 0xcb, 0x59, 0x9a } + } + }, + { + // Environment variable region + SYNQUACER_SPI_NOR_BASE, // device base + FixedPcdGet32 (PcdFlashNvStorageVariableBase), // region base + FixedPcdGet32 (PcdFlashNvStorageVariableSize) + + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize), // region size + SIZE_64KB, // block size + { + 0x3105bd7a, 0x82c3, 0x486f, { 0xb1, 0x03, 0x1e, 0x09, 0x54, 0xec, 0x85, 0x75 } + } + }, +}; + +EFI_STATUS +NorFlashPlatformInitialization ( + VOID + ) +{ + return EFI_SUCCESS; +} + +EFI_STATUS +NorFlashPlatformGetDevices ( + OUT NOR_FLASH_DESCRIPTION **NorFlashDevices, + OUT UINT32 *Count + ) +{ + if (NorFlashDevices == NULL || + Count == NULL) { + return EFI_INVALID_PARAMETER; + } + + *Count = ARRAY_SIZE (mNorFlashDevices); + *NorFlashDevices = mNorFlashDevices; + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf new file mode 100644 index 000000000000..2a8fd209f5e3 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf @@ -0,0 +1,41 @@ +#/** @file +# +# Copyright (c) 2011 - 2014, ARM Ltd. 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 = NorFlashSynQuacerLib + FILE_GUID = 8279227C-C555-4D75-B439-D8A959635CDD + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = NorFlashPlatformLib + +[Sources] + NorFlashSynQuacer.c + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + ArmPkg/ArmPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdBaseAddress + gArmTokenSpaceGuid.PcdFdSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize From patchwork Fri Nov 10 14:21:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118549 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258728edl; Fri, 10 Nov 2017 06:22:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMZUZuq3YRY5XoyfAYYKhSFEUd0g9N7xdGZ9EeFQR1OWytteLsHTXPvA6aIzIMA0pzRqGNd/ X-Received: by 10.101.88.140 with SMTP id d12mr528946pgu.166.1510323777969; Fri, 10 Nov 2017 06:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323777; cv=none; d=google.com; s=arc-20160816; b=Cy0kNINJmRHLVmLTfjx79SIuyRJCpvy0remEgj3ZOyVGCcbbrwoEz4Q+wM7ogJVGoM 4/RVf/oGXnT911bNohQd5RAUyW/WjyGBj3XX38wnX9EasCXVZ/0o2roAo45n7Xcc84zt WY65XUNUjJZ4d5LYPr/KjHVgO5x2u6muRCsIwkWsrp7oeOSjQHBsjbJ25V6q+5rPSk47 xFM3iPl7YE1CZ1g+i3785gl8bqFl+5wr1adtRvPDAw9u9Cpd1PDq1mB/8I14o1ikf/x3 zQEKd5nEzk36u/tkEZuWOyhqhSC9S69jtvwK9VL/1NRBbJWqjjgaNIczmzS4Pqf9FRrW yECQ== 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=RyAWFdfb1Y/LQlMX4fG8d0JHv/Os3bp1/Ty+ddxUHW0=; b=C0Bkz7Pq6MgGpg0qj7sJ2R8eQRqcbVpRA4z8mLIVSdq8I80q6uyGHN10rlskxoGgF/ LUJuwk8dQJO8PaJsujmPvUY4fxfXCxuiWJepxmINvbqOvQhO8NBmgTjMD5wuK5zE0Gm+ lKQDFzLhSBbZCZWJ9ORwQadBAoInd7jVDUbrpNN6z7AfKDw6z1CkiHguLtlqbCTIeZnU BZ/A+RQKcnwzmh38DALHjhp21BU5oZe0nbx101QRC9sHurXBa5PI07vS+K5gH0xJkK2n eaMCBji+DJ1U1YKiHkhEHDQFkema/IGs5ifXCByYgtSbNpyAmAFlX6uHyHTD2IrmzLi1 1gJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cWCNSE5h; 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 f4si9344725plm.686.2017.11.10.06.22.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:57 -0800 (PST) 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=cWCNSE5h; 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 8978121B00DED; Fri, 10 Nov 2017 06:18:29 -0800 (PST) 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=2a00:1450:400c:c09::236; helo=mail-wm0-x236.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (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 9CAA42035521F for ; Fri, 10 Nov 2017 06:18:27 -0800 (PST) Received: by mail-wm0-x236.google.com with SMTP id b14so3076856wme.2 for ; Fri, 10 Nov 2017 06:22:30 -0800 (PST) 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=6NMko+aqQ3Hhzkwh1umNcS39/nZ+CB7CxTesMNOhM/4=; b=cWCNSE5hrcTIDoCWFWGNMC7gifyJ0l+T6pdLlBDu3WM0BP5jg3hrsmUCmZukoRoT1u qn4OydAVh+HRlyFhyrzObDmLKlrux2tq/DvvF96KfxciPeQEiPAeXhApu9+nMA6SoPV0 l+7GOd3S0Dv5b/ESw7WV0/7DhmcZOXUtbZkvA= 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=6NMko+aqQ3Hhzkwh1umNcS39/nZ+CB7CxTesMNOhM/4=; b=Lji/0e1hNcUUQJ9p8+vgKhwUFRr8SVQ3gARcsgDLuzR8rhQyH/FV2k3QCxbmk2KEoa HuLnkSb/6VHZcs9OLXTQjuDiIwFM/gWRm8vsUacHDbeKNeo4ZOqmoP2jUZe3Ojknfwc9 K/15nz/9r1xHxm8z0HmEUmZ5N0g9CQCozjHmjg44EAxDdct00pCifr4rVzy5PRcVP/ys M0sUvdZLleGQJlqoMkdCSJFd7tELaevloIu03rjyACCWvKsQ+7D/kbHpdVAx5NZFbeMC kG1GtzurnhIcNKXGnGB7SA3f6nLkYmg7oR1OXVgUrH7OevxfiwQsphNEHLm4dGTTiPJA 2Z6A== X-Gm-Message-State: AJaThX61MYqw0Sekgu5Y078R+PnvU2mXjFv1j0akY74sNJw+vlIY8fhs CAK6itBJ2zwBakK5HZS5EDDb8Yupzj4= X-Received: by 10.28.87.17 with SMTP id l17mr375507wmb.158.1510323746314; Fri, 10 Nov 2017 06:22:26 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:25 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:07 +0000 Message-Id: <20171110142127.12018-15-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 14/34] Silicon/Socionext: add driver for SPI NOR flash X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" From: Pipat Methavanitpong This imports the driver sources provided by Socionext for the FIP006 SPI NOR flash device found on SynQuacer SoCs. It has been slightly tweaked to bring it up to date with the changes made on the EDK2 side since it was forked. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pipat Methavanitpong [various tweaks and bugfixes] Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- v4: incorporate feedback from Leif, with the exception of subjective feedback (i.e., 'this function is too long'), addressing of which would make this driver deviate more from the driver it as based on in ArmPlatformPkg, making it less likely we can ever merge these into a unified NOR flash driver. Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec | 31 + Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf | 81 ++ Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Reg.h | 244 ++++ Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c | 138 ++ Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c | 1391 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h | 357 +++++ Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c | 853 ++++++++++++ 7 files changed, 3095 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Acked-by: Leif Lindholm diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec new file mode 100644 index 000000000000..aec95bc82387 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec @@ -0,0 +1,31 @@ +## @file +# Socionext FIP006 High-Speed SPI Controller with NOR Flash Driver +# +# Copyright (c) 2017, Socionext Inc. 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] + DEC_SPECIFICATION = 0x0001001A + PACKAGE_NAME = Fip006DxePkg + PACKAGE_GUID = ABC7870B-FE82-4DAD-8179-FEC5F5194FA0 + PACKAGE_VERSION = 0.1 + +[Guids] + gFip006DxeTokenSpaceGuid = {0x4D45399E, 0x98F9, 0x4127, {0x8F, 0xB9,0xF8, 0xDE, 0x22, 0xA1, 0x09, 0x2C}} + +[PcdsFixedAtBuild] + gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress|0x0|UINT32|0x00000001 + gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress|0x0|UINT32|0x00000002 + gFip006DxeTokenSpaceGuid.PcdN25qSlaveId|0x0|UINT8|0x00000003 + gFip006DxeTokenSpaceGuid.PcdN25qBlockSize|256|UINT32|0x00000004 + gFip006DxeTokenSpaceGuid.PcdN25qBlockCount|524288|UINT32|0x00000005 + diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf new file mode 100644 index 000000000000..62f81cfe33cd --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf @@ -0,0 +1,81 @@ +## @file +# Socionext FIP006 High-Speed SPI Controller with NOR Flash Driver +# +# Copyright (c) 2017, Socionext Inc. All rights reserved.
+# Copyright (c) 2017, Linaro, Ltd. 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 = Fip006Dxe + FILE_GUID = 44F7D21F-C36F-4766-BC5B-C72E97E6897B + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 0.1 + ENTRY_POINT = NorFlashInitialise + +[Sources] + NorFlashBlockIoDxe.c + NorFlashDxe.c + NorFlashFvbDxe.c + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + DevicePathLib + DxeServicesTableLib + HobLib + IoLib + MemoryAllocationLib + NorFlashInfoLib + NorFlashPlatformLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + UefiRuntimeLib + UefiRuntimeServicesTableLib + +[Guids] + gEfiAuthenticatedVariableGuid + gEfiEventVirtualAddressChangeGuid + gEfiSystemNvDataFvGuid + gEfiVariableGuid + +[Protocols] + gEfiBlockIoProtocolGuid + gEfiDevicePathProtocolGuid + gEfiDiskIoProtocolGuid + gEfiFirmwareVolumeBlockProtocolGuid + +[FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress + gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress + +[Depex] + # + # NorFlashDxe must be loaded before VariableRuntimeDxe in case empty flash needs populating with default values + # + BEFORE gVariableRuntimeDxeFileGuid diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Reg.h b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Reg.h new file mode 100644 index 000000000000..3d758dc492f6 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Reg.h @@ -0,0 +1,244 @@ +/** @file + Socionext FIP006 Register List + + Copyright (c) 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef __EFI_FIP006_REG_H__ +#define __EFI_FIP006_REG_H__ + +#define FIP006_REG_MCTRL 0x00 // Module Control +typedef union { + UINT32 Raw : 32; + struct { + BOOLEAN MEN : 1; + BOOLEAN CSEN : 1; +#define MCTRL_CSEN_DIRECT 0 +#define MCTRL_CSEN_CS 1 + BOOLEAN CDSS : 1; +#define MCTRL_CDSS_IHCLK 0 +#define MCTRL_CDSS_IPCLK 1 + BOOLEAN MES : 1; +#define MCTRL_MES_READY 1 + UINT8 : 4; + UINT8 : 8; + UINT8 : 8; + UINT8 : 8; + }; +} FIP006_MCTRL; + +#define FIP006_REG_PCC0 0x04 // Peripheral Communication Control 0 +#define FIP006_REG_PCC1 0x08 // Peripheral Communication Control 1 +#define FIP006_REG_PCC2 0x0C // Peripheral Communication Control 2 +#define FIP006_REG_PCC3 0x10 // Peripheral Communication Control 3 +typedef union { + UINT32 Raw : 32; + struct { + BOOLEAN CPHA : 1; + BOOLEAN CPOL : 1; + BOOLEAN ACES : 1; + BOOLEAN RTM : 1; + BOOLEAN SSPOL : 1; + UINT8 SS2CD : 2; + BOOLEAN SDIR : 1; +#define PCC_SDIR_MS_BIT 0 +#define PCC_SDIR_LS_BIT 1 + BOOLEAN SENDIAN : 1; +#define PCC_SENDIAN_BIG 0 +#define PCC_SENDIAN_LITTLE 1 + UINT8 CDRS : 7; + BOOLEAN SAFESYNC : 1; + UINT8 WRDSEL : 4; + UINT8 RDDSEL : 2; + UINT8 : 1; + UINT8 : 8; + } Reg; +} FIP006_PCC; +typedef FIP006_PCC FIP006_PCC0, FIP006_PCC1, FIP006_PCC2, FIP006_PCC3; + +#define FIP006_REG_TXF 0x14 // Tx Interrupt Flag +#define TXF_TSSRS BIT6 +#define TXF_TFMTS BIT5 +#define TXF_TFLETS BIT4 +#define TXF_TFUS BIT3 +#define TXF_TFOS BIT2 +#define TXF_TFES BIT1 +#define TXF_TFFS BIT0 + +#define FIP006_REG_TXE 0x18 // Tx Interrupt Enable +#define TXE_TSSRE BIT6 +#define TXE_TFMTE BIT5 +#define TXE_TFLETE BIT4 +#define TXE_TFUE BIT3 +#define TXE_TFOE BIT2 +#define TXE_TFEE BIT1 +#define TXE_TFFE BIT0 + +#define FIP006_REG_TXC 0x1C // Tx Interrupt Clear +#define TXC_TSSRC BIT6 +#define TXC_TFMTC BIT5 +#define TXC_TFLETC BIT4 +#define TXC_TFUC BIT3 +#define TXC_TFOC BIT2 +#define TXC_TFEC BIT1 +#define TXC_TFFC BIT0 + +#define FIP006_REG_RXF 0x20 // Rx Interrupt Flag +#define RXF_RSSRS BIT6 +#define RXF_RFMTS BIT5 +#define RXF_RFLETS BIT4 +#define RXF_RFUS BIT3 +#define RXF_RFOS BIT2 +#define RXF_RFES BIT1 +#define RXF_RFFS BIT0 + +#define FIP006_REG_RXE 0x24 // Rx Interrupt Enable +#define RXE_RSSRE BIT6 +#define RXE_RFMTE BIT5 +#define RXE_RFLETE BIT4 +#define RXE_RFUE BIT3 +#define RXE_RFOE BIT2 +#define RXE_RFEE BIT1 +#define RXE_RFFE BIT0 + +#define FIP006_REG_RXC 0x28 // Rx Interrupt Clear +#define RXC_RSSRC BIT6 +#define RXC_RFMTC BIT5 +#define RXC_RFLETC BIT4 +#define RXC_RFUC BIT3 +#define RXC_RFOC BIT2 +#define RXC_RFEC BIT1 +#define RXC_RFFC BIT0 + +#define FIP006_REG_FAULTF 0x2C // Error Interrupt Status +#define FAULTF_DRCBSFS BIT4 +#define FAULTF_DWCBSFS BIT3 +#define FAULTF_PVFS BIT2 +#define FAULTF_WAFS BIT1 +#define FAULTF_UMAFS BIT0 + +#define FIP006_REG_FAULTC 0x30 // Error Interrupt Clear +#define FAULTC_DRCBSFC BIT4 +#define FAULTC_DWCBSFC BIT3 +#define FAULTC_PVFC BIT2 +#define FAULTC_WAFC BIT1 +#define FAULTC_UMAFC BIT0 + +#define FIP006_REG_DM_CFG 0x34 // Direct Mode DMA Configuration +#define DM_CFG_MSTARTEN BIT2 +#define DM_CFG_SSDC BIT1 + +#define FIP006_REG_DM_DMA 0x35 // Direct Mode DMA Enable +#define DM_DMA_TXDMAEN BIT1 +#define DM_DMA_RXDMAEN BIT0 + +#define FIP006_REG_DM_START 0x38 // Direct Mode Start Transmission +#define DM_START BIT0 +#define FIP006_REG_DM_STOP 0x39 // Direct Mode Stop Transmission +#define DM_STOP BIT0 + +#define FIP006_REG_DM_PSEL 0x3A // Direct Mode Peripheral Select +#define DM_PSEL (BIT1 | BIT0) + +#define FIP006_REG_DM_TRP 0x3B // Direct Mode Transmission Protocol +#define DM_TRP (BIT3 | BIT2 | BIT1 | BIT0) + +#define FIP006_REG_DM_BCC 0x3C // Direct Mode Byte Count Control +#define FIP006_REG_DM_BCS 0x3E // Direct Mode Byte Count Status + +#define FIP006_REG_DM_STATUS 0x40 // Direct Mode Status +#define DM_STATUS_TXFLEVEL (BIT20 | BIT19 | BIT18 | BIT17 | BIT16) +#define DM_STATUS_RXFLEVEL (BIT20 | BIT19 | BIT18 | BIT17 | BIT16) +#define DM_STATUS_TXACTIVE BIT1 +#define DM_STATUS_RXACTIVE BIT0 + +#define FIP006_REG_FIFO_CFG 0x4C // FIFO Configuration +#define FIFO_CFG_TXFLSH BIT12 +#define FIFO_CFG_RXFLSH BIT11 +#define FIFO_CFG_TXCTRL BIT10 +#define FIFO_CFG_FWIDTH (BIT9 | BIT8) +#define FIFO_CFG_TXFTH (BIT7 | BIT6 | BIT5 | BIT4) +#define FIFO_CFG_RXFTH (BIT3 | BIT2 | BIT1 | BIT0) + +#define FIP006_REG_FIFO_TX 0x50 // 16 32-bit Tx FIFO +#define FIP006_REG_FIFO_RX 0x90 // 16 32-bit Rx FIFO + +#define FIP006_REG_CS_CFG 0xD0 // Command Sequencer Configuration +typedef union { + UINT32 Raw : 32; + struct { + BOOLEAN SRAM : 1; +#define CS_CFG_SRAM_RO 0 +#define CS_CFG_SRAM_RW 1 + UINT8 MBM : 2; +#define CS_CFG_MBM_SINGLE 0 +#define CS_CFG_MBM_DUAL 1 +#define CS_CFG_MBM_QUAD 2 + BOOLEAN SPICHNG : 1; + BOOLEAN BOOTEN : 1; + BOOLEAN BSEL : 1; + UINT8 : 2; + BOOLEAN SSEL0EN : 1; + BOOLEAN SSEL1EN : 1; + BOOLEAN SSEL2EN : 1; + BOOLEAN SSEL3EN : 1; + UINT8 : 4; + BOOLEAN MSEL : 4; + UINT8 : 4; + UINT8 : 8; + } Reg; +} FIP006_CS_CFG; + +#define FIP006_REG_CS_ITIME 0xD4 // Command Sequencer Idle Timer +typedef union { + UINT32 Raw : 32; + struct { + UINT16 ITIME : 16; + UINT16 : 16; + } Reg; +} FIP006_CS_ITIME; +#define FIP006_REG_CS_AEXT 0xD8 // Command Sequencer Address Extension +typedef union { + UINT32 Raw : 32; + struct { + UINT16 : 13; + UINT32 AEXT : 19; + } Reg; +} FIP006_CS_AEXT; + +#define FIP006_REG_CS_RD 0xDC // Command Sequencer Read Control +#define CS_RD_DEPTH 8 +#define FIP006_REG_CS_WR 0xEC // Command Sequencer Write Control +#define CS_WR_DEPTH 8 +typedef union { + UINT16 Raw : 16; + struct { + BOOLEAN DEC : 1; + UINT8 TRP : 2; + BOOLEAN CONT : 1; + UINT8 : 4; + union { + UINT8 Data : 8; + struct { + UINT8 Data : 3; + UINT8 : 5; + } Cmd; + } Payload; + } Reg; +} FIP006_CS_CMD; +typedef FIP006_CS_CMD FIP006_CS_RD, FIP006_CS_WR; + +#define FIP006_REG_MID 0xFC // Command Sequencer Module ID +typedef UINT32 FIP006_MID; + +#endif diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c new file mode 100644 index 000000000000..b41f5003217c --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c @@ -0,0 +1,138 @@ +/** @file NorFlashBlockIoDxe.c + + Copyright (c) 2011-2013, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "NorFlashDxe.h" + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset +// +EFI_STATUS +EFIAPI +NorFlashBlockIoReset ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ) +{ + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_BLKIO_THIS(This); + + DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n", + This->Media->MediaId)); + + return NorFlashReset (Instance); +} + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoReadBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer + ) +{ + NOR_FLASH_INSTANCE *Instance; + EFI_STATUS Status; + EFI_BLOCK_IO_MEDIA *Media; + + if (This == NULL) { + return EFI_INVALID_PARAMETER; + } + + Instance = INSTANCE_FROM_BLKIO_THIS(This); + Media = This->Media; + + DEBUG ((DEBUG_BLKIO, + "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes " + "(%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer)); + + if (!Media) { + Status = EFI_INVALID_PARAMETER; + } else if (!Media->MediaPresent) { + Status = EFI_NO_MEDIA; + } else if (Media->MediaId != MediaId) { + Status = EFI_MEDIA_CHANGED; + } else if ((Media->IoAlign > 2) && + (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) { + Status = EFI_INVALID_PARAMETER; + } else { + Status = NorFlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer); + } + + return Status; +} + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoWriteBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + IN VOID *Buffer + ) +{ + NOR_FLASH_INSTANCE *Instance; + EFI_STATUS Status; + + Instance = INSTANCE_FROM_BLKIO_THIS(This); + + DEBUG ((DEBUG_BLKIO, + "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes " + "(%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer)); + + if( !This->Media->MediaPresent ) { + Status = EFI_NO_MEDIA; + } else if( This->Media->MediaId != MediaId ) { + Status = EFI_MEDIA_CHANGED; + } else if( This->Media->ReadOnly ) { + Status = EFI_WRITE_PROTECTED; + } else { + Status = NorFlashWriteBlocks (Instance,Lba,BufferSizeInBytes,Buffer); + } + + return Status; +} + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoFlushBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This + ) +{ + // No Flush required for the NOR Flash driver + // because cache operations are not permitted. + + DEBUG ((DEBUG_BLKIO, + "NorFlashBlockIoFlushBlocks: Function NOT IMPLEMENTED (not required).\n")); + + // Nothing to do so just return without error + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c new file mode 100644 index 000000000000..a521b1f3d167 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c @@ -0,0 +1,1391 @@ +/** @file NorFlashDxe.c + + Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 "NorFlashDxe.h" + +STATIC EFI_EVENT mNorFlashVirtualAddrChangeEvent; + +// +// Global variable declarations +// +STATIC NOR_FLASH_INSTANCE **mNorFlashInstances; +STATIC UINT32 mNorFlashDeviceCount; + +STATIC CONST UINT16 mFip006NullCmdSeq[] = { + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), + CSDC (CSDC_END, CSDC_CONT_NON_CONTINUOUS, CSDC_TRP_MBM, CSDC_DEC_DECODE), +}; + +STATIC CONST CSDC_DEFINITION mN25qCSDCDefTable[] = { + // Identification Operations + { SPINOR_OP_RDID, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + // Register Operations + { SPINOR_OP_RDSR, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_WRSR, FALSE, FALSE, FALSE, TRUE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_RD_ARRAY, TRUE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_RDFSR, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_RD_NVCFG, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_RD_VCR, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_RD_EVCR, FALSE, FALSE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + // Read Operations + { SPINOR_OP_READ_4B, TRUE, TRUE, FALSE, FALSE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + // Write Operations + { SPINOR_OP_PP, TRUE, FALSE, FALSE, TRUE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, + { SPINOR_OP_PP_1_1_4, TRUE, FALSE, FALSE, TRUE, CS_CFG_MBM_QUAD, + CSDC_TRP_SINGLE }, + // Erase Operations + { SPINOR_OP_SE, FALSE, FALSE, FALSE, TRUE, CS_CFG_MBM_SINGLE, + CSDC_TRP_SINGLE }, +}; + +STATIC +EFI_STATUS +NorFlashSetHostCSDC ( + IN NOR_FLASH_INSTANCE *Instance, + IN BOOLEAN ReadWrite, + IN CONST UINT16 CSDC[ARRAY_SIZE (mFip006NullCmdSeq)] + ) +{ + EFI_PHYSICAL_ADDRESS Dst; + UINTN Index; + + Dst = Instance->HostRegisterBaseAddress + + (ReadWrite ? FIP006_REG_CS_WR : FIP006_REG_CS_RD); + for (Index = 0; Index < ARRAY_SIZE (mFip006NullCmdSeq); Index++) { + MmioWrite16 (Dst + (Index << 1), CSDC[Index]); + } + return EFI_SUCCESS; +} + +STATIC +CONST CSDC_DEFINITION * +NorFlashGetCmdDef ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINT8 Code + ) +{ + CONST CSDC_DEFINITION *Cmd; + UINTN Index; + + Cmd = NULL; + for (Index = 0; Index < Instance->CmdTableSize; Index++) { + if (Code == Instance->CmdTable[Index].Code) { + Cmd = &Instance->CmdTable[Index]; + break; + } + } + return Cmd; +} + +STATIC +EFI_STATUS +GenCSDC ( + IN UINT8 Cmd, + IN BOOLEAN AddrAccess, + IN BOOLEAN AddrMode4Byte, + IN BOOLEAN HighZ, + IN UINT8 TransferMode, + OUT UINT16 *CmdSeq + ) +{ + UINTN Index; + + if (!CmdSeq) { + return EFI_INVALID_PARAMETER; + } + + Index = 0; + CopyMem (CmdSeq, mFip006NullCmdSeq, sizeof (mFip006NullCmdSeq)); + + CmdSeq[Index++] = CSDC (Cmd, CSDC_CONT_NON_CONTINUOUS, TransferMode, + CSDC_DEC_LEAVE_ASIS); + if (AddrAccess) { + if (AddrMode4Byte) { + CmdSeq[Index++] = CSDC (CSDC_ADDRESS_31_24, CSDC_CONT_NON_CONTINUOUS, + TransferMode, CSDC_DEC_DECODE); + } + CmdSeq[Index++] = CSDC (CSDC_ADDRESS_23_16, CSDC_CONT_NON_CONTINUOUS, + TransferMode, CSDC_DEC_DECODE); + CmdSeq[Index++] = CSDC (CSDC_ADDRESS_15_8, CSDC_CONT_NON_CONTINUOUS, + TransferMode, CSDC_DEC_DECODE); + CmdSeq[Index++] = CSDC (CSDC_ADDRESS_7_0, CSDC_CONT_NON_CONTINUOUS, + TransferMode, CSDC_DEC_DECODE); + } + if (HighZ) { + CmdSeq[Index++] = CSDC (CSDC_HIGH_Z, CSDC_CONT_NON_CONTINUOUS, + TransferMode, CSDC_DEC_DECODE); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +NorFlashSetHostCommand ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINT8 Code + ) +{ + CONST CSDC_DEFINITION *Cmd; + UINT16 CSDC[ARRAY_SIZE (mFip006NullCmdSeq)]; + + Cmd = NorFlashGetCmdDef (Instance, Code); + if (Cmd == NULL) { + return EFI_INVALID_PARAMETER; + } + GenCSDC ( + Cmd->Code, + Cmd->AddrAccess, + Cmd->AddrMode4Byte, + Cmd->HighZ, + Cmd->CsdcTrp, + CSDC + ); + NorFlashSetHostCSDC (Instance, Cmd->ReadWrite, CSDC); + return EFI_SUCCESS; +} + +STATIC +UINT8 +NorFlashReadStatusRegister ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + UINT8 StatusRegister; + + NorFlashSetHostCommand (Instance, SPINOR_OP_RDSR); + StatusRegister = MmioRead8 (Instance->RegionBaseAddress); + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + return StatusRegister; +} + +STATIC +EFI_STATUS +NorFlashWaitProgramErase ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + BOOLEAN SRegDone; + BOOLEAN FSRegDone; + + DEBUG ((DEBUG_BLKIO, "NorFlashWaitProgramErase()\n")); + + do { + SRegDone = (NorFlashReadStatusRegister (Instance) & SPINOR_SR_WIP) == 0; + FSRegDone = TRUE; + if (Instance->Flags & NOR_FLASH_POLL_FSR) { + NorFlashSetHostCommand (Instance, SPINOR_OP_RDFSR); + FSRegDone = (MmioRead8 (Instance->RegionBaseAddress) & + SPINOR_FSR_READY) != 0; + } + } while (!SRegDone || !FSRegDone); + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + return EFI_SUCCESS; +} + +// TODO: implement lock checking +STATIC +BOOLEAN +NorFlashBlockIsLocked ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + return FALSE; +} + +// TODO: implement sector unlocking +STATIC +EFI_STATUS +NorFlashUnlockSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +NorFlashUnlockSingleBlockIfNecessary ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + EFI_STATUS Status; + + Status = EFI_SUCCESS; + + if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) { + Status = NorFlashUnlockSingleBlock (Instance, BlockAddress); + } + + return Status; +} + +STATIC +EFI_STATUS +NorFlashEnableWrite ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + EFI_STATUS Status; + UINT8 StatusRegister; + UINTN Retry; + + DEBUG ((DEBUG_BLKIO, "NorFlashEnableWrite()\n")); + + Status = EFI_DEVICE_ERROR; + Retry = NOR_FLASH_ERASE_RETRY; + + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + while (Retry > 0 && EFI_ERROR (Status)) { + MmioWrite8 (Instance->RegionBaseAddress, SPINOR_OP_WREN); + MemoryFence (); + StatusRegister = NorFlashReadStatusRegister (Instance); + Status = (StatusRegister & BIT1) ? EFI_SUCCESS : EFI_DEVICE_ERROR; + Retry--; + } + return Status; +} + +STATIC +EFI_STATUS +NorFlashDisableWrite ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + EFI_STATUS Status; + UINT8 StatusRegister; + UINTN Retry; + + DEBUG ((DEBUG_BLKIO, "NorFlashDisableWrite()\n")); + + Status = EFI_DEVICE_ERROR; + Retry = NOR_FLASH_ERASE_RETRY; + + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + while (Retry > 0 && EFI_ERROR (Status)) { + MmioWrite8 (Instance->RegionBaseAddress, SPINOR_OP_WRDIS); + MemoryFence (); + StatusRegister = NorFlashReadStatusRegister (Instance); + Status = (StatusRegister & BIT1) ? EFI_DEVICE_ERROR : EFI_SUCCESS; + Retry--; + } + return Status; +} + +/** + * The following function presumes that the block has already been unlocked. + **/ +STATIC +EFI_STATUS +NorFlashEraseSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + + DEBUG ((DEBUG_BLKIO, "NorFlashEraseSingleBlock(BlockAddress=0x%08x)\n", + BlockAddress)); + + if (EFI_ERROR (NorFlashEnableWrite (Instance))) { + return EFI_DEVICE_ERROR; + } + + // + // The virtual address chosen by the OS may have a different offset modulo + // 16 MB than the physical address, so we need to subtract the region base + // address before we can mask off a block index. Note that the relative + // offset between device base address and region base address may have changed + // as well, so we cannot use the device base address directly. + // + if (EfiAtRuntime()) { + BlockAddress -= Instance->RegionBaseAddress; + BlockAddress += Instance->OffsetLba * Instance->Media.BlockSize; + } + + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + MmioWrite32 (Instance->DeviceBaseAddress, + SwapBytes32 (BlockAddress & 0x00FFFFFF) | SPINOR_OP_SE); + NorFlashWaitProgramErase (Instance); + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + + if (EFI_ERROR (NorFlashDisableWrite (Instance))) { + return EFI_DEVICE_ERROR; + } + return EFI_SUCCESS; +} + +/** + * This function unlock and erase an entire NOR Flash block. + **/ +EFI_STATUS +NorFlashUnlockAndEraseSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + EFI_STATUS Status; + UINTN Index; + EFI_TPL OriginalTPL; + BOOLEAN InterruptsEnabled; + + OriginalTPL = 0; + InterruptsEnabled = FALSE; + + if (!EfiAtRuntime ()) { + // Raise TPL to TPL_HIGH to stop anyone from interrupting us. + OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); + } else { + InterruptsEnabled = SaveAndDisableInterrupts (); + } + + Index = 0; + // The block erase might fail a first time (SW bug ?). Retry it ... + do { + // Unlock the block if we have to + Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress); + if (EFI_ERROR (Status)) { + break; + } + Status = NorFlashEraseSingleBlock (Instance, BlockAddress); + Index++; + } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED)); + + if (Index == NOR_FLASH_ERASE_RETRY) { + DEBUG ((DEBUG_ERROR, + "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", + BlockAddress,Index)); + } + + if (!EfiAtRuntime ()) { + // Interruptions can resume. + gBS->RestoreTPL (OriginalTPL); + } else if (InterruptsEnabled) { + SetInterruptState (TRUE); + } + + return Status; +} + +STATIC +EFI_STATUS +NorFlashWriteSingleWord ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN WordAddress, + IN UINT32 WriteData + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_BLKIO, + "NorFlashWriteSingleWord(WordAddress=0x%08x, WriteData=0x%08x)\n", + WordAddress, WriteData)); + + Status = EFI_SUCCESS; + + if (EFI_ERROR (NorFlashEnableWrite (Instance))) { + return EFI_DEVICE_ERROR; + } + NorFlashSetHostCommand (Instance, SPINOR_OP_PP); + MmioWrite32 (WordAddress, WriteData); + NorFlashWaitProgramErase (Instance); + + NorFlashDisableWrite (Instance); + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + return Status; +} + +STATIC +EFI_STATUS +NorFlashWriteFullBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINT32 *DataBuffer, + IN UINT32 BlockSizeInWords + ) +{ + EFI_STATUS Status; + UINTN WordAddress; + UINT32 WordIndex; + UINTN BlockAddress; + EFI_TPL OriginalTPL; + BOOLEAN InterruptsEnabled; + + Status = EFI_SUCCESS; + OriginalTPL = 0; + InterruptsEnabled = FALSE; + + // Get the physical address of the block + BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, + BlockSizeInWords * 4); + + // Start writing from the first address at the start of the block + WordAddress = BlockAddress; + + if (!EfiAtRuntime ()) { + // Raise TPL to TPL_HIGH to stop anyone from interrupting us. + OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); + } else { + InterruptsEnabled = SaveAndDisableInterrupts (); + } + + Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", + BlockAddress)); + goto EXIT; + } + + for (WordIndex=0; + WordIndex < BlockSizeInWords; + WordIndex++, DataBuffer++, WordAddress += 4) { + Status = NorFlashWriteSingleWord (Instance, WordAddress, *DataBuffer); + if (EFI_ERROR (Status)) { + goto EXIT; + } + } + +EXIT: + if (!EfiAtRuntime ()) { + // Interruptions can resume. + gBS->RestoreTPL (OriginalTPL); + } else if (InterruptsEnabled) { + SetInterruptState (TRUE); + } + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", + WordAddress, Status)); + } + return Status; +} + +EFI_STATUS +NorFlashWriteBlocks ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + IN VOID *Buffer + ) +{ + UINT32 *pWriteBuffer; + EFI_STATUS Status = EFI_SUCCESS; + EFI_LBA CurrentBlock; + UINT32 BlockSizeInWords; + UINT32 NumBlocks; + UINT32 BlockCount; + + // The buffer must be valid + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Instance->Media.ReadOnly == TRUE) { + return EFI_WRITE_PROTECTED; + } + + // We must have some bytes to read + DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", + BufferSizeInBytes)); + if (BufferSizeInBytes == 0) { + return EFI_BAD_BUFFER_SIZE; + } + + // The size of the buffer must be a multiple of the block size + DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", + Instance->Media.BlockSize)); + if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { + return EFI_BAD_BUFFER_SIZE; + } + + // All blocks must be within the device + NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ; + + DEBUG ((DEBUG_BLKIO, + "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, + Instance->Media.LastBlock, Lba)); + + if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { + DEBUG ((DEBUG_ERROR, + "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n")); + return EFI_INVALID_PARAMETER; + } + + ASSERT (((UINTN)Buffer % sizeof (UINT32)) == 0); + + BlockSizeInWords = Instance->Media.BlockSize / 4; + + // Because the target *Buffer is a pointer to VOID, we must put + // all the data into a pointer to a proper data type, so use *ReadBuffer + pWriteBuffer = (UINT32 *)Buffer; + + CurrentBlock = Lba; + for (BlockCount = 0; + BlockCount < NumBlocks; + BlockCount++, CurrentBlock++, pWriteBuffer += BlockSizeInWords) { + + DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Writing block #%d\n", + (UINTN)CurrentBlock)); + + Status = NorFlashWriteFullBlock (Instance, CurrentBlock, pWriteBuffer, + BlockSizeInWords); + + if (EFI_ERROR (Status)) { + break; + } + } + + DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Exit Status = \"%r\".\n", Status)); + return Status; +} + +EFI_STATUS +NorFlashReadBlocks ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer + ) +{ + UINT32 NumBlocks; + UINTN StartAddress; + + DEBUG ((DEBUG_BLKIO, + "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n", + BufferSizeInBytes, Instance->Media.BlockSize, Instance->Media.LastBlock, + Lba)); + + // The buffer must be valid + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Return if we have not any byte to read + if (BufferSizeInBytes == 0) { + return EFI_SUCCESS; + } + + // The size of the buffer must be a multiple of the block size + if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { + return EFI_BAD_BUFFER_SIZE; + } + + // All blocks must be within the device + NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ; + + if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { + DEBUG ((DEBUG_ERROR, + "NorFlashReadBlocks: ERROR - Read will exceed last block\n")); + return EFI_INVALID_PARAMETER; + } + + // Get the address to start reading from + StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, + Instance->Media.BlockSize); + + // Put the device into Read Array mode + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + + // Readout the data + CopyMem(Buffer, (UINTN *)StartAddress, BufferSizeInBytes); + + return EFI_SUCCESS; +} + +EFI_STATUS +NorFlashRead ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer + ) +{ + UINTN StartAddress; + + // The buffer must be valid + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // Return if we have not any byte to read + if (BufferSizeInBytes == 0) { + return EFI_SUCCESS; + } + + if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > + Instance->Size) { + DEBUG ((DEBUG_ERROR, + "NorFlashRead: ERROR - Read will exceed device size.\n")); + return EFI_INVALID_PARAMETER; + } + + // Get the address to start reading from + StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, + Instance->Media.BlockSize); + + // Put the device into Read Array mode + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + + // Readout the data + CopyMem (Buffer, (UINTN *)(StartAddress + Offset), BufferSizeInBytes); + + return EFI_SUCCESS; +} + +/* + Write a full or portion of a block. It must not span block boundaries; + that is, Offset + *NumBytes <= Instance->Media.BlockSize. +*/ +EFI_STATUS +NorFlashWriteSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +{ + EFI_STATUS TempStatus; + UINT32 Tmp; + UINT32 TmpBuf; + UINT32 WordToWrite; + UINT32 Mask; + BOOLEAN DoErase; + UINTN BytesToWrite; + UINTN CurOffset; + UINTN WordAddr; + UINTN BlockSize; + UINTN BlockAddress; + UINTN PrevBlockAddress; + + PrevBlockAddress = 0; + + if (!Instance->Initialized && Instance->Initialize) { + Instance->Initialize(Instance); + } + + DEBUG ((DEBUG_BLKIO, + "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", + Lba, Offset, *NumBytes, Buffer)); + + // Detect WriteDisabled state + if (Instance->Media.ReadOnly == TRUE) { + DEBUG ((DEBUG_ERROR, + "NorFlashWriteSingleBlock: ERROR - Can not write: Device is in WriteDisabled state.\n")); + // It is in WriteDisabled state, return an error right away + return EFI_ACCESS_DENIED; + } + + // Cache the block size to avoid de-referencing pointers all the time + BlockSize = Instance->Media.BlockSize; + + // The write must not span block boundaries. + // We need to check each variable individually because adding two large + // values together overflows. + if (Offset >= BlockSize || + *NumBytes > BlockSize || + (Offset + *NumBytes) > BlockSize) { + DEBUG ((DEBUG_ERROR, + "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", + Offset, *NumBytes, BlockSize )); + return EFI_BAD_BUFFER_SIZE; + } + + // We must have some bytes to write + if (*NumBytes == 0) { + DEBUG ((DEBUG_ERROR, + "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", + Offset, *NumBytes, BlockSize )); + return EFI_BAD_BUFFER_SIZE; + } + + // Pick 128bytes as a good start for word operations as opposed to erasing the + // block and writing the data regardless if an erase is really needed. + // It looks like most individual NV variable writes are smaller than 128bytes. + if (*NumBytes <= 128) { + // Check to see if we need to erase before programming the data into NOR. + // If the destination bits are only changing from 1s to 0s we can just write. + // After a block is erased all bits in the block is set to 1. + // If any byte requires us to erase we just give up and rewrite all of it. + DoErase = FALSE; + BytesToWrite = *NumBytes; + CurOffset = Offset; + + while (BytesToWrite > 0) { + // Read full word from NOR, splice as required. A word is the smallest + // unit we can write. + TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof(Tmp), + &Tmp); + if (EFI_ERROR (TempStatus)) { + return EFI_DEVICE_ERROR; + } + + // Physical address of word in NOR to write. + WordAddr = (CurOffset & ~(0x3)) + + GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, + BlockSize); + + // The word of data that is to be written. + TmpBuf = *((UINT32*)(Buffer + (*NumBytes - BytesToWrite))); + + // First do word aligned chunks. + if ((CurOffset & 0x3) == 0) { + if (BytesToWrite >= 4) { + // Is the destination still in 'erased' state? + if (~Tmp != 0) { + // Check to see if we are only changing bits to zero. + if ((Tmp ^ TmpBuf) & TmpBuf) { + DoErase = TRUE; + break; + } + } + // Write this word to NOR + WordToWrite = TmpBuf; + CurOffset += sizeof(TmpBuf); + BytesToWrite -= sizeof(TmpBuf); + } else { + // BytesToWrite < 4. Do small writes and left-overs + Mask = ~((~0) << (BytesToWrite * 8)); + // Mask out the bytes we want. + TmpBuf &= Mask; + // Is the destination still in 'erased' state? + if ((Tmp & Mask) != Mask) { + // Check to see if we are only changing bits to zero. + if ((Tmp ^ TmpBuf) & TmpBuf) { + DoErase = TRUE; + break; + } + } + // Merge old and new data. Write merged word to NOR + WordToWrite = (Tmp & ~Mask) | TmpBuf; + CurOffset += BytesToWrite; + BytesToWrite = 0; + } + } else { + // Do multiple words, but starting unaligned. + if (BytesToWrite > (4 - (CurOffset & 0x3))) { + Mask = ((~0) << ((CurOffset & 0x3) * 8)); + // Mask out the bytes we want. + TmpBuf &= Mask; + // Is the destination still in 'erased' state? + if ((Tmp & Mask) != Mask) { + // Check to see if we are only changing bits to zero. + if ((Tmp ^ TmpBuf) & TmpBuf) { + DoErase = TRUE; + break; + } + } + // Merge old and new data. Write merged word to NOR + WordToWrite = (Tmp & ~Mask) | TmpBuf; + BytesToWrite -= (4 - (CurOffset & 0x3)); + CurOffset += (4 - (CurOffset & 0x3)); + } else { + // Unaligned and fits in one word. + Mask = (~((~0) << (BytesToWrite * 8))) << ((CurOffset & 0x3) * 8); + // Mask out the bytes we want. + TmpBuf = (TmpBuf << ((CurOffset & 0x3) * 8)) & Mask; + // Is the destination still in 'erased' state? + if ((Tmp & Mask) != Mask) { + // Check to see if we are only changing bits to zero. + if ((Tmp ^ TmpBuf) & TmpBuf) { + DoErase = TRUE; + break; + } + } + // Merge old and new data. Write merged word to NOR + WordToWrite = (Tmp & ~Mask) | TmpBuf; + CurOffset += BytesToWrite; + BytesToWrite = 0; + } + } + + // + // Write the word to NOR. + // + + BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, + BlockSize); + if (BlockAddress != PrevBlockAddress) { + TempStatus = NorFlashUnlockSingleBlockIfNecessary (Instance, + BlockAddress); + if (EFI_ERROR (TempStatus)) { + return EFI_DEVICE_ERROR; + } + PrevBlockAddress = BlockAddress; + } + TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite); + if (EFI_ERROR (TempStatus)) { + return EFI_DEVICE_ERROR; + } + } + // Exit if we got here and could write all the data. Otherwise do the + // Erase-Write cycle. + if (!DoErase) { + return EFI_SUCCESS; + } + } + + // Check we did get some memory. Buffer is BlockSize. + if (Instance->ShadowBuffer == NULL) { + DEBUG ((DEBUG_ERROR, "FvbWrite: ERROR - Buffer not ready\n")); + return EFI_DEVICE_ERROR; + } + + // Read NOR Flash data into shadow buffer + TempStatus = NorFlashReadBlocks (Instance, Lba, BlockSize, + Instance->ShadowBuffer); + if (EFI_ERROR (TempStatus)) { + // Return one of the pre-approved error statuses + return EFI_DEVICE_ERROR; + } + + // Put the data at the appropriate location inside the buffer area + CopyMem ((VOID*)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes); + + // Write the modified buffer back to the NorFlash + TempStatus = NorFlashWriteBlocks (Instance, Lba, BlockSize, + Instance->ShadowBuffer); + if (EFI_ERROR (TempStatus)) { + // Return one of the pre-approved error statuses + return EFI_DEVICE_ERROR; + } + + return EFI_SUCCESS; +} + +/* + Although DiskIoDxe will automatically install the DiskIO protocol whenever + we install the BlockIO protocol, its implementation is sub-optimal as it reads + and writes entire blocks using the BlockIO protocol. In fact we can access + NOR flash with a finer granularity than that, so we can improve performance + by directly producing the DiskIO protocol. +*/ + +/** + Read BufferSize bytes from Offset into Buffer. + + @param This Protocol instance pointer. + @param MediaId Id of the media, changes every time the media is + replaced. + @param Offset The starting byte offset to read from + @param BufferSize Size of Buffer + @param Buffer Buffer containing read data + + @retval EFI_SUCCESS The data was read correctly from the device. + @retval EFI_DEVICE_ERROR The device reported an error while performing + the read. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. + @retval EFI_INVALID_PARAMETER The read request contains device addresses that + are not valid for the device. + +**/ +STATIC +EFI_STATUS +EFIAPI +NorFlashDiskIoReadDisk ( + IN EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 DiskOffset, + IN UINTN BufferSize, + OUT VOID *Buffer + ) +{ + NOR_FLASH_INSTANCE *Instance; + UINT32 BlockSize; + UINT32 BlockOffset; + EFI_LBA Lba; + + Instance = INSTANCE_FROM_DISKIO_THIS(This); + + if (MediaId != Instance->Media.MediaId) { + return EFI_MEDIA_CHANGED; + } + + BlockSize = Instance->Media.BlockSize; + Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); + + return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer); +} + +/** + Writes a specified number of bytes to a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be written. + @param Offset The starting byte offset on the logical block I/O device to + write. + @param BufferSize The size in bytes of Buffer. The number of bytes to write + to the device. + @param Buffer A pointer to the buffer containing the data to be written. + + @retval EFI_SUCCESS The data was written correctly to the device. + @retval EFI_WRITE_PROTECTED The device can not be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing + the write. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. + @retval EFI_INVALID_PARAMETER The write request contains device addresses that + are not valid for the device. + +**/ +STATIC +EFI_STATUS +EFIAPI +NorFlashDiskIoWriteDisk ( + IN EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 DiskOffset, + IN UINTN BufferSize, + IN VOID *Buffer + ) +{ + NOR_FLASH_INSTANCE *Instance; + UINT32 BlockSize; + UINT32 BlockOffset; + EFI_LBA Lba; + UINTN RemainingBytes; + UINTN WriteSize; + EFI_STATUS Status; + + Instance = INSTANCE_FROM_DISKIO_THIS(This); + + if (MediaId != Instance->Media.MediaId) { + return EFI_MEDIA_CHANGED; + } + + BlockSize = Instance->Media.BlockSize; + Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); + + RemainingBytes = BufferSize; + + // Write either all the remaining bytes, or the number of bytes that bring + // us up to a block boundary, whichever is less. + // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the next + // block boundary (even if it is already on one). + WriteSize = MIN (RemainingBytes, + ((DiskOffset | (BlockSize - 1)) + 1) - DiskOffset); + + do { + if (WriteSize == BlockSize) { + // Write a full block + Status = NorFlashWriteFullBlock (Instance, Lba, Buffer, + BlockSize / sizeof (UINT32)); + } else { + // Write a partial block + Status = NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &WriteSize, + Buffer); + } + if (EFI_ERROR (Status)) { + return Status; + } + // Now continue writing either all the remaining bytes or single blocks. + RemainingBytes -= WriteSize; + Buffer = (UINT8 *) Buffer + WriteSize; + Lba++; + BlockOffset = 0; + WriteSize = MIN (RemainingBytes, BlockSize); + } while (RemainingBytes); + + return Status; +} + +STATIC CONST NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { + NOR_FLASH_SIGNATURE, // Signature + NULL, // Handle ... NEED TO BE FILLED + + FALSE, // Initialized + NULL, // Initialize + + 0, // HostRegisterBaseAddress ... NEED TO BE FILLED + 0, // DeviceBaseAddress ... NEED TO BE FILLED + 0, // RegionBaseAddress ... NEED TO BE FILLED + 0, // Size ... NEED TO BE FILLED + 0, // StartLba + 0, // OffsetLba + + { + EFI_BLOCK_IO_PROTOCOL_REVISION2, // Revision + NULL, // Media ... NEED TO BE FILLED + NorFlashBlockIoReset, // Reset; + NorFlashBlockIoReadBlocks, // ReadBlocks + NorFlashBlockIoWriteBlocks, // WriteBlocks + NorFlashBlockIoFlushBlocks // FlushBlocks + }, // BlockIoProtocol + + { + 0, // MediaId ... NEED TO BE FILLED + FALSE, // RemovableMedia + TRUE, // MediaPresent + FALSE, // LogicalPartition + FALSE, // ReadOnly + FALSE, // WriteCaching; + 0, // BlockSize ... NEED TO BE FILLED + 4, // IoAlign + 0, // LastBlock ... NEED TO BE FILLED + 0, // LowestAlignedLba + 1, // LogicalBlocksPerPhysicalBlock + }, //Media; + + { + EFI_DISK_IO_PROTOCOL_REVISION, // Revision + NorFlashDiskIoReadDisk, // ReadDisk + NorFlashDiskIoWriteDisk // WriteDisk + }, + { + FvbGetAttributes, // GetAttributes + FvbSetAttributes, // SetAttributes + FvbGetPhysicalAddress, // GetPhysicalAddress + FvbGetBlockSize, // GetBlockSize + FvbRead, // Read + FvbWrite, // Write + FvbEraseBlocks, // EraseBlocks + NULL, //ParentHandle + }, // FvbProtoccol; + + NULL, // ShadowBuffer + { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)sizeof(VENDOR_DEVICE_PATH), + (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8) + } + }, + { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } + } + }, // DevicePath + + NULL, // CmdTable + 0, // CmdTableSize + 0 // Flags +}; + +STATIC +EFI_STATUS +NorFlashCreateInstance ( + IN UINTN HostRegisterBase, + IN UINTN NorFlashDeviceBase, + IN UINTN NorFlashRegionBase, + IN UINTN NorFlashSize, + IN UINT32 MediaId, + IN UINT32 BlockSize, + IN BOOLEAN HasVarStore, + IN CONST GUID *NorFlashGuid, + IN CONST CSDC_DEFINITION *CommandTable, + IN UINTN CommandTableSize, + OUT NOR_FLASH_INSTANCE** NorFlashInstance + ) +{ + EFI_STATUS Status; + NOR_FLASH_INSTANCE* Instance; + UINT8 JedecId[3]; + + ASSERT(NorFlashInstance != NULL); + + Instance = AllocateRuntimeCopyPool (sizeof mNorFlashInstanceTemplate, + &mNorFlashInstanceTemplate); + if (Instance == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Instance->HostRegisterBaseAddress = HostRegisterBase; + Instance->DeviceBaseAddress = NorFlashDeviceBase; + Instance->RegionBaseAddress = NorFlashRegionBase; + Instance->Size = NorFlashSize; + + Instance->BlockIoProtocol.Media = &Instance->Media; + Instance->Media.MediaId = MediaId; + Instance->Media.BlockSize = BlockSize; + Instance->Media.LastBlock = (NorFlashSize / BlockSize) - 1; + Instance->OffsetLba = (NorFlashRegionBase - NorFlashDeviceBase) / BlockSize; + + CopyGuid (&Instance->DevicePath.Vendor.Guid, NorFlashGuid); + + Instance->CmdTable = CommandTable; + Instance->CmdTableSize = CommandTableSize; + NorFlashReset (Instance); + + NorFlashReadID (Instance, JedecId); + + DEBUG_CODE_BEGIN (); + { + NOR_FLASH_INFO *FlashInfo; + + Status = NorFlashGetInfo (JedecId, &FlashInfo, FALSE); + if (EFI_ERROR (Status)) { + goto FreeInstance; + } + + NorFlashPrintInfo (FlashInfo); + FreePool (FlashInfo); + } + DEBUG_CODE_END (); + + Instance->Flags = 0; + if (JedecId[0] == NOR_FLASH_ID_STMICRO) { + Instance->Flags = NOR_FLASH_POLL_FSR; + } + + Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);; + if (Instance->ShadowBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto FreeInstance; + } + + if (HasVarStore) { + Instance->Initialize = NorFlashFvbInitialize; + } + + Status = gBS->InstallMultipleProtocolInterfaces ( + &Instance->Handle, + &gEfiDevicePathProtocolGuid, &Instance->DevicePath, + &gEfiFirmwareVolumeBlockProtocolGuid, &Instance->FvbProtocol, + NULL + ); + if (EFI_ERROR (Status)) { + goto FreeInstance; + } + + *NorFlashInstance = Instance; + return EFI_SUCCESS; + +FreeInstance: + FreePool (Instance); + return Status; +} + +EFI_STATUS +NorFlashReset ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + FIP006_CS_CFG CsCfg; + + DEBUG ((DEBUG_BLKIO, "NorFlashReset()\n")); + CsCfg.Raw = MmioRead32 (Instance->HostRegisterBaseAddress + + FIP006_REG_CS_CFG); + CsCfg.Reg.MBM = CS_CFG_MBM_SINGLE; + CsCfg.Reg.SRAM = CS_CFG_SRAM_RW; + MmioWrite32 (Instance->HostRegisterBaseAddress + FIP006_REG_CS_CFG, + CsCfg.Raw); + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq); + return EFI_SUCCESS; +} + +EFI_STATUS +NorFlashReadID ( + IN NOR_FLASH_INSTANCE *Instance, + OUT UINT8 JedecId[3] + ) +{ + if (Instance == NULL || JedecId == NULL) { + return EFI_INVALID_PARAMETER; + } + + NorFlashSetHostCommand (Instance, SPINOR_OP_RDID); + JedecId[0] = MmioRead8 (Instance->DeviceBaseAddress); + JedecId[1] = MmioRead8 (Instance->DeviceBaseAddress + 1); + JedecId[2] = MmioRead8 (Instance->DeviceBaseAddress + 2); + NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B); + return EFI_SUCCESS; +} + +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +STATIC +VOID +EFIAPI +NorFlashVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + UINTN Index; + + for (Index = 0; Index < mNorFlashDeviceCount; Index++) { + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->HostRegisterBaseAddress); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->DeviceBaseAddress); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->RegionBaseAddress); + + // Convert BlockIo protocol + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.Reset); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks); + + // Convert Fvb + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetAttributes); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetBlockSize); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetPhysicalAddress); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.Read); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.SetAttributes); + EfiConvertPointer (0x0, + (VOID**)&mNorFlashInstances[Index]->FvbProtocol.Write); + + if (mNorFlashInstances[Index]->ShadowBuffer != NULL) { + EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->ShadowBuffer); + } + + EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->CmdTable); + } + + return; +} + +EFI_STATUS +EFIAPI +NorFlashInitialise ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS HostRegisterBaseAddress; + UINT32 Index; + NOR_FLASH_DESCRIPTION* NorFlashDevices; + BOOLEAN ContainVariableStorage; + + // Register HSSPI FIP006 register region + HostRegisterBaseAddress = PcdGet32 (PcdFip006DxeRegBaseAddress); + + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + HostRegisterBaseAddress, SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes ( + HostRegisterBaseAddress, SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); + + Status = NorFlashPlatformInitialization (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "NorFlashInitialise: Fail to initialize Nor Flash devices\n")); + return Status; + } + + // Initialize NOR flash instances + Status = NorFlashPlatformGetDevices (&NorFlashDevices, &mNorFlashDeviceCount); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR,"NorFlashInitialise: Fail to get Nor Flash devices\n")); + return Status; + } + + mNorFlashInstances = AllocateRuntimePool (sizeof(NOR_FLASH_INSTANCE*) * + mNorFlashDeviceCount); + + for (Index = 0; Index < mNorFlashDeviceCount; Index++) { + // Check if this NOR Flash device contain the variable storage region + ContainVariableStorage = + (NorFlashDevices[Index].RegionBaseAddress <= + PcdGet32 (PcdFlashNvStorageVariableBase)) && + (PcdGet32 (PcdFlashNvStorageVariableBase) + + PcdGet32 (PcdFlashNvStorageVariableSize) <= + NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].Size); + + Status = NorFlashCreateInstance ( + HostRegisterBaseAddress, + NorFlashDevices[Index].DeviceBaseAddress, + NorFlashDevices[Index].RegionBaseAddress, + NorFlashDevices[Index].Size, + Index, + NorFlashDevices[Index].BlockSize, + ContainVariableStorage, + &NorFlashDevices[Index].Guid, + mN25qCSDCDefTable, + ARRAY_SIZE (mN25qCSDCDefTable), + &mNorFlashInstances[Index] + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "NorFlashInitialise: Fail to create instance for NorFlash[%d]\n", + Index)); + } + } + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + NorFlashVirtualNotifyEvent, NULL, + &gEfiEventVirtualAddressChangeGuid, + &mNorFlashVirtualAddrChangeEvent); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h new file mode 100644 index 000000000000..5e1e6adecf67 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h @@ -0,0 +1,357 @@ +/** @file NorFlashDxe.h + + Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef __NOR_FLASH_DXE_H__ +#define __NOR_FLASH_DXE_H__ + + +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "Fip006Reg.h" + +#define NOR_FLASH_ERASE_RETRY 10 + +#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) \ + ((BaseAddr) + (UINTN)((Lba) * (LbaSize))) + +#define NOR_FLASH_SIGNATURE SIGNATURE_32('S', 'n', 'o', 'r') +#define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, \ + NOR_FLASH_SIGNATURE) +#define INSTANCE_FROM_BLKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, BlockIoProtocol,\ + NOR_FLASH_SIGNATURE) +#define INSTANCE_FROM_DISKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, DiskIoProtocol, \ + NOR_FLASH_SIGNATURE) + +#define CSDC(Data, Cont, Trp, Dec) \ + (((Data) << 8) | (((Cont) & 1) << 3) | (((Trp) & 3) << 1) | ((Dec) & 1)) + +#define CSDC_TRP_MBM 0 +#define CSDC_TRP_DUAL 1 +#define CSDC_TRP_QUAD 2 +#define CSDC_TRP_SINGLE 3 + +#define CSDC_DEC_LEAVE_ASIS 0 +#define CSDC_DEC_DECODE 1 + +#define CSDC_CONT_NON_CONTINUOUS 0 +#define CSDC_CONT_CONTINUOUS 1 + +#define CSDC_ADDRESS_7_0 0x0 +#define CSDC_ADDRESS_15_8 0x1 +#define CSDC_ADDRESS_23_16 0x2 +#define CSDC_ADDRESS_31_24 0x3 +#define CSDC_HIGH_Z 0x4 +#define CSDC_END 0x7 + +typedef struct { + UINT8 Code; + BOOLEAN AddrAccess; + BOOLEAN AddrMode4Byte; + BOOLEAN HighZ; + BOOLEAN ReadWrite; + UINT8 CscfgMbm; + UINT8 CsdcTrp; +} CSDC_DEFINITION; + +typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; + +typedef EFI_STATUS (*NOR_FLASH_INITIALIZE) (NOR_FLASH_INSTANCE* Instance); + +typedef struct { + VENDOR_DEVICE_PATH Vendor; + EFI_DEVICE_PATH_PROTOCOL End; +} NOR_FLASH_DEVICE_PATH; + +struct _NOR_FLASH_INSTANCE { + UINT32 Signature; + EFI_HANDLE Handle; + + BOOLEAN Initialized; + NOR_FLASH_INITIALIZE Initialize; + + UINTN HostRegisterBaseAddress; + UINTN DeviceBaseAddress; + UINTN RegionBaseAddress; + UINTN Size; + EFI_LBA StartLba; + EFI_LBA OffsetLba; + + EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; + EFI_BLOCK_IO_MEDIA Media; + EFI_DISK_IO_PROTOCOL DiskIoProtocol; + + EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; + VOID* ShadowBuffer; + + NOR_FLASH_DEVICE_PATH DevicePath; + + CONST CSDC_DEFINITION *CmdTable; + UINTN CmdTableSize; + + UINT32 Flags; +#define NOR_FLASH_POLL_FSR BIT0 +}; + +EFI_STATUS +NorFlashReadCfiData ( + IN UINTN DeviceBaseAddress, + IN UINTN CFI_Offset, + IN UINT32 NumberOfBytes, + OUT UINT32 *Data + ); + +EFI_STATUS +NorFlashWriteBuffer ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN TargetAddress, + IN UINTN BufferSizeInBytes, + IN UINT32 *Buffer + ); + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset +// +EFI_STATUS +EFIAPI +NorFlashBlockIoReset ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoReadBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer +); + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoWriteBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + IN VOID *Buffer +); + +// +// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks +// +EFI_STATUS +EFIAPI +NorFlashBlockIoFlushBlocks ( + IN EFI_BLOCK_IO_PROTOCOL *This +); + +// +// NorFlashFvbDxe.c +// + +EFI_STATUS +EFIAPI +NorFlashFvbInitialize ( + IN NOR_FLASH_INSTANCE* Instance + ); + +EFI_STATUS +EFIAPI +FvbGetAttributes( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + OUT EFI_FVB_ATTRIBUTES_2 *Attributes + ); + +EFI_STATUS +EFIAPI +FvbSetAttributes( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes + ); + +EFI_STATUS +EFIAPI +FvbGetPhysicalAddress( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + OUT EFI_PHYSICAL_ADDRESS *Address + ); + +EFI_STATUS +EFIAPI +FvbGetBlockSize( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumberOfBlocks + ); + +EFI_STATUS +EFIAPI +FvbRead( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN OUT UINT8 *Buffer + ); + +EFI_STATUS +EFIAPI +FvbWrite( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ); + +EFI_STATUS +EFIAPI +FvbEraseBlocks( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + ... + ); + +// +// NorFlashDxe.c +// + +EFI_STATUS +NorFlashUnlockAndEraseSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ); + +EFI_STATUS +NorFlashWriteSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ); + +EFI_STATUS +NorFlashWriteBlocks ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + IN VOID *Buffer + ); + +EFI_STATUS +NorFlashReadBlocks ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer + ); + +EFI_STATUS +NorFlashRead ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN UINTN BufferSizeInBytes, + OUT VOID *Buffer + ); + +EFI_STATUS +NorFlashWrite ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ); + +EFI_STATUS +NorFlashReset ( + IN NOR_FLASH_INSTANCE *Instance + ); + +EFI_STATUS +NorFlashReadID ( + IN NOR_FLASH_INSTANCE *Instance, + OUT UINT8 JedecId[3] + ); + +#define SPINOR_SR_WIP BIT0 // Write in progress +#define SPINOR_FSR_READY BIT7 // Flag Status Register: ready + +#define SPINOR_OP_WREN 0x06 // Write enable +#define SPINOR_OP_WRDIS 0x04 // Write enable +#define SPINOR_OP_RDSR 0x05 // Read status register +#define SPINOR_OP_WRSR 0x01 // Write status register 1 byte +#define SPINOR_OP_RDSR2 0x3f // Read status register 2 +#define SPINOR_OP_WRSR2 0x3e // Write status register 2 +#define SPINOR_OP_READ 0x03 // Read data bytes (low frequency) +#define SPINOR_OP_READ_FAST 0x0b // Read data bytes (high frequency) +#define SPINOR_OP_READ_1_1_2 0x3b // Read data bytes (Dual Output SPI) +#define SPINOR_OP_READ_1_2_2 0xbb // Read data bytes (Dual I/O SPI) +#define SPINOR_OP_READ_1_1_4 0x6b // Read data bytes (Quad Output SPI) +#define SPINOR_OP_READ_1_4_4 0xeb // Read data bytes (Quad I/O SPI) +#define SPINOR_OP_PP 0x02 // Page program (up to 256 bytes) +#define SPINOR_OP_PP_1_1_4 0x32 // Quad page program +#define SPINOR_OP_PP_1_4_4 0x38 // Quad page program +#define SPINOR_OP_BE_4K 0x20 // Erase 4KiB block +#define SPINOR_OP_BE_4K_PMC 0xd7 // Erase 4KiB block on PMC chips +#define SPINOR_OP_BE_32K 0x52 // Erase 32KiB block +#define SPINOR_OP_CHIP_ERASE 0xc7 // Erase whole flash chip +#define SPINOR_OP_SE 0xd8 // Sector erase (usually 64KiB) +#define SPINOR_OP_RDID 0x9f // Read JEDEC ID +#define SPINOR_OP_RDSFDP 0x5a // Read SFDP +#define SPINOR_OP_RDCR 0x35 // Read configuration register +#define SPINOR_OP_RDFSR 0x70 // Read flag status register +#define SPINOR_OP_READ_4B 0x13 // Read data bytes (low frequency) +#define SPINOR_OP_READ_FAST_4B 0x0c // Read data bytes (high frequency) +#define SPINOR_OP_READ_1_1_2_4B 0x3c // Read data bytes (Dual Output SPI) +#define SPINOR_OP_READ_1_2_2_4B 0xbc // Read data bytes (Dual I/O SPI) +#define SPINOR_OP_READ_1_1_4_4B 0x6c // Read data bytes (Quad Output SPI) +#define SPINOR_OP_READ_1_4_4_4B 0xec // Read data bytes (Quad I/O SPI) +#define SPINOR_OP_PP_4B 0x12 // Page program (up to 256 bytes) +#define SPINOR_OP_PP_1_1_4_4B 0x34 // Quad page program +#define SPINOR_OP_PP_1_4_4_4B 0x3e // Quad page program +#define SPINOR_OP_BE_4K_4B 0x21 // Erase 4KiB block +#define SPINOR_OP_BE_32K_4B 0x5c // Erase 32KiB block +#define SPINOR_OP_SE_4B 0xdc // Sector erase (usually 64KiB) +#define SPINOR_OP_RD_ARRAY 0xe8 // Read array +#define SPINOR_OP_RD_NVCFG 0xb5 // Read non-volatile config register +#define SPINOR_OP_RD_VCR 0x85 // Read VCR register +#define SPINOR_OP_RD_EVCR 0x65 // Read EVCR register + +#endif /* __NOR_FLASH_DXE_H__ */ diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c new file mode 100644 index 000000000000..acc9490b9a5f --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c @@ -0,0 +1,853 @@ +/** @file NorFlashFvbDxe.c + + Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2017, Socionext Inc. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 +#include +#include + +#include "NorFlashDxe.h" + +STATIC EFI_EVENT mFvbVirtualAddrChangeEvent; +STATIC UINTN mFlashNvStorageVariableBase; + +/// +/// The Firmware Volume Block Protocol is the low-level interface +/// to a firmware volume. File-level access to a firmware volume +/// should not be done using the Firmware Volume Block Protocol. +/// Normal access to a firmware volume must use the Firmware +/// Volume Protocol. Typically, only the file system driver that +/// produces the Firmware Volume Protocol will bind to the +/// Firmware Volume Block Protocol. +/// + +/** + Initialises the FV Header and Variable Store Header + to support variable operations. + + @param[in] Ptr - Location to initialise the headers + +**/ +STATIC +EFI_STATUS +InitializeFvAndVariableStoreHeaders ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + EFI_STATUS Status; + VOID* Headers; + UINTN HeadersLength; + EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader; + VARIABLE_STORE_HEADER *VariableStoreHeader; + + if (!Instance->Initialized && Instance->Initialize) { + Instance->Initialize (Instance); + } + + HeadersLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + + sizeof(VARIABLE_STORE_HEADER); + Headers = AllocateZeroPool(HeadersLength); + + // + // EFI_FIRMWARE_VOLUME_HEADER + // + FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Headers; + CopyGuid (&FirmwareVolumeHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid); + FirmwareVolumeHeader->FvLength = + PcdGet32(PcdFlashNvStorageVariableSize) + + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + + PcdGet32(PcdFlashNvStorageFtwSpareSize); + FirmwareVolumeHeader->Signature = EFI_FVH_SIGNATURE; + FirmwareVolumeHeader->Attributes = EFI_FVB2_READ_ENABLED_CAP | + EFI_FVB2_READ_STATUS | + EFI_FVB2_STICKY_WRITE | + EFI_FVB2_MEMORY_MAPPED | + EFI_FVB2_ERASE_POLARITY | + EFI_FVB2_WRITE_STATUS | + EFI_FVB2_WRITE_ENABLED_CAP; + + FirmwareVolumeHeader->HeaderLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + + sizeof(EFI_FV_BLOCK_MAP_ENTRY); + FirmwareVolumeHeader->Revision = EFI_FVH_REVISION; + FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1; + FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize; + FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0; + FirmwareVolumeHeader->BlockMap[1].Length = 0; + FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ( + (UINT16*)FirmwareVolumeHeader, + FirmwareVolumeHeader->HeaderLength); + + // + // VARIABLE_STORE_HEADER + // + VariableStoreHeader = (VOID *)((UINTN)Headers + + FirmwareVolumeHeader->HeaderLength); + CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); + VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - + FirmwareVolumeHeader->HeaderLength; + VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; + VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; + + // Install the combined super-header in the NorFlash + Status = FvbWrite (&Instance->FvbProtocol, 0, 0, &HeadersLength, Headers); + + FreePool (Headers); + return Status; +} + +/** + Check the integrity of firmware volume header. + + @param[in] FwVolHeader - A pointer to a firmware volume header + + @retval EFI_SUCCESS - The firmware volume is consistent + @retval EFI_NOT_FOUND - The firmware volume has been corrupted. + +**/ +EFI_STATUS +ValidateFvHeader ( + IN NOR_FLASH_INSTANCE *Instance + ) +{ + UINT16 Checksum; + EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; + VARIABLE_STORE_HEADER *VariableStoreHeader; + UINTN VariableStoreLength; + UINTN FvLength; + + FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress; + + FvLength = PcdGet32(PcdFlashNvStorageVariableSize) + + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + + PcdGet32(PcdFlashNvStorageFtwSpareSize); + + // + // Verify the header revision, header signature, length + // Length of FvBlock cannot be 2**64-1 + // HeaderLength cannot be an odd number + // + if ( (FwVolHeader->Revision != EFI_FVH_REVISION) + || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) + || (FwVolHeader->FvLength != FvLength) + ) + { + DEBUG ((DEBUG_INFO, "%a: No Firmware Volume header present\n", + __FUNCTION__)); + return EFI_NOT_FOUND; + } + + // Check the Firmware Volume Guid + if (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid)) { + DEBUG ((DEBUG_INFO, "%a: Firmware Volume Guid non-compatible\n", + __FUNCTION__)); + return EFI_NOT_FOUND; + } + + // Verify the header checksum + Checksum = CalculateSum16((UINT16*)FwVolHeader, FwVolHeader->HeaderLength); + if (Checksum != 0) { + DEBUG ((DEBUG_INFO, "%a: FV checksum is invalid (Checksum:0x%X)\n", + __FUNCTION__, Checksum)); + return EFI_NOT_FOUND; + } + + VariableStoreHeader = (VOID *)((UINTN)FwVolHeader + + FwVolHeader->HeaderLength); + + // Check the Variable Store Guid + if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && + !CompareGuid (&VariableStoreHeader->Signature, + &gEfiAuthenticatedVariableGuid)) { + DEBUG ((DEBUG_INFO, "%a: Variable Store Guid non-compatible\n", + __FUNCTION__)); + return EFI_NOT_FOUND; + } + + VariableStoreLength = PcdGet32 (PcdFlashNvStorageVariableSize) - + FwVolHeader->HeaderLength; + if (VariableStoreHeader->Size != VariableStoreLength) { + DEBUG ((DEBUG_INFO, "%a: Variable Store Length does not match\n", + __FUNCTION__)); + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} + +/** + The GetAttributes() function retrieves the attributes and + current settings of the block. + + @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the attributes and + current settings are returned. + Type EFI_FVB_ATTRIBUTES_2 is defined in + EFI_FIRMWARE_VOLUME_HEADER. + + @retval EFI_SUCCESS The firmware volume attributes were returned. + + **/ +EFI_STATUS +EFIAPI +FvbGetAttributes( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + OUT EFI_FVB_ATTRIBUTES_2 *Attributes + ) +{ + EFI_FVB_ATTRIBUTES_2 FlashFvbAttributes; + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS(This); + + FlashFvbAttributes = EFI_FVB2_READ_ENABLED_CAP | EFI_FVB2_READ_STATUS | + EFI_FVB2_STICKY_WRITE | EFI_FVB2_MEMORY_MAPPED | + EFI_FVB2_ERASE_POLARITY; + + // Check if it is write protected + if (!Instance->Media.ReadOnly) { + FlashFvbAttributes |= EFI_FVB2_WRITE_STATUS | EFI_FVB2_WRITE_ENABLED_CAP; + } + + *Attributes = FlashFvbAttributes; + + DEBUG ((DEBUG_BLKIO, "FvbGetAttributes(0x%X)\n", *Attributes)); + + return EFI_SUCCESS; +} + +/** + The SetAttributes() function sets configurable firmware volume attributes + and returns the new settings of the firmware volume. + + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Attributes On input, Attributes is a pointer to + EFI_FVB_ATTRIBUTES_2 that contains the desired + firmware volume settings. + On successful return, it contains the new + settings of the firmware volume. + + @retval EFI_SUCCESS The firmware volume attributes were returned. + + @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with + the capabilities as declared in the firmware + volume header. + + **/ +EFI_STATUS +EFIAPI +FvbSetAttributes( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes + ) +{ + DEBUG ((DEBUG_BLKIO, "FvbSetAttributes(0x%X) is not supported\n", + *Attributes)); + return EFI_UNSUPPORTED; +} + +/** + The GetPhysicalAddress() function retrieves the base address of + a memory-mapped firmware volume. This function should be called + only for memory-mapped firmware volumes. + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Address Pointer to a caller-allocated + EFI_PHYSICAL_ADDRESS that, on successful + return from GetPhysicalAddress(), contains the + base address of the firmware volume. + + @retval EFI_SUCCESS The firmware volume base address was returned. + + @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped. + + **/ +EFI_STATUS +EFIAPI +FvbGetPhysicalAddress ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + OUT EFI_PHYSICAL_ADDRESS *Address + ) +{ + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS(This); + + DEBUG ((DEBUG_BLKIO, "FvbGetPhysicalAddress(BaseAddress=0x%08x)\n", + Instance->RegionBaseAddress)); + + ASSERT(Address != NULL); + + *Address = Instance->RegionBaseAddress; + return EFI_SUCCESS; +} + +/** + The GetBlockSize() function retrieves the size of the requested + block. It also returns the number of additional blocks with + the identical size. The GetBlockSize() function is used to + retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER). + + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Lba Indicates the block whose size to return + + @param BlockSize Pointer to a caller-allocated UINTN in which + the size of the block is returned. + + @param NumberOfBlocks Pointer to a caller-allocated UINTN in + which the number of consecutive blocks, + starting with Lba, is returned. All + blocks in this range have a size of + BlockSize. + + + @retval EFI_SUCCESS The firmware volume base address was returned. + + @retval EFI_INVALID_PARAMETER The requested LBA is out of range. + + **/ +EFI_STATUS +EFIAPI +FvbGetBlockSize ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumberOfBlocks + ) +{ + EFI_STATUS Status; + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS(This); + + DEBUG ((DEBUG_BLKIO, + "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, + Instance->Media.BlockSize, Instance->Media.LastBlock)); + + if (Lba > Instance->Media.LastBlock) { + DEBUG ((DEBUG_ERROR, + "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba (%ld).\n", + Lba, Instance->Media.LastBlock)); + Status = EFI_INVALID_PARAMETER; + } else { + // This is easy because in this platform each NorFlash device has equal sized blocks. + *BlockSize = (UINTN) Instance->Media.BlockSize; + *NumberOfBlocks = (UINTN) (Instance->Media.LastBlock - Lba + 1); + + DEBUG ((DEBUG_BLKIO, + "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize, + *NumberOfBlocks)); + + Status = EFI_SUCCESS; + } + + return Status; +} + +/** + Reads the specified number of bytes into a buffer from the specified block. + + The Read() function reads the requested number of bytes from the + requested block and stores them in the provided buffer. + Implementations should be mindful that the firmware volume + might be in the ReadDisabled state. If it is in this state, + the Read() function must return the status code + EFI_ACCESS_DENIED without modifying the contents of the + buffer. The Read() function must also prevent spanning block + boundaries. If a read is requested that would span a block + boundary, the read must read up to the boundary but not + beyond. The output parameter NumBytes must be set to correctly + indicate the number of bytes actually read. The caller must be + aware that a read may be partially completed. + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Lba The starting logical block index from which to read + + @param Offset Offset into the block at which to begin reading. + + @param NumBytes Pointer to a UINTN. + At entry, *NumBytes contains the total size of the + buffer. + At exit, *NumBytes contains the total number of + bytes read. + + @param Buffer Pointer to a caller-allocated buffer that will be + used to hold the data that is read. + + @retval EFI_SUCCESS The firmware volume was read successfully, and + contents are in Buffer. + + @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. + On output, NumBytes contains the total number of + bytes returned in Buffer. + + @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state. + + @retval EFI_DEVICE_ERROR The block device is not functioning correctly and + could not be read. + + **/ +EFI_STATUS +EFIAPI +FvbRead ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN OUT UINT8 *Buffer + ) +{ + EFI_STATUS TempStatus; + UINTN BlockSize; + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS(This); + + DEBUG ((DEBUG_BLKIO, + "FvbRead(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", + Instance->StartLba + Lba, Offset, *NumBytes, Buffer)); + + if (!Instance->Initialized && Instance->Initialize) { + Instance->Initialize(Instance); + } + + TempStatus = EFI_SUCCESS; + + // Cache the block size to avoid de-referencing pointers all the time + BlockSize = Instance->Media.BlockSize; + + DEBUG ((DEBUG_BLKIO, + "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", + Offset, *NumBytes, BlockSize )); + + // The read must not span block boundaries. + // We need to check each variable individually because adding two large + // values together overflows. + if (Offset >= BlockSize || + *NumBytes > BlockSize || + (Offset + *NumBytes) > BlockSize) { + DEBUG ((DEBUG_ERROR, + "FvbRead: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", + Offset, *NumBytes, BlockSize )); + return EFI_BAD_BUFFER_SIZE; + } + + // We must have some bytes to read + if (*NumBytes == 0) { + return EFI_BAD_BUFFER_SIZE; + } + + // Decide if we are doing full block reads or not. + if (*NumBytes % BlockSize != 0) { + TempStatus = NorFlashRead (Instance, Instance->StartLba + Lba, Offset, + *NumBytes, Buffer); + if (EFI_ERROR (TempStatus)) { + return EFI_DEVICE_ERROR; + } + } else { + // Read NOR Flash data into shadow buffer + TempStatus = NorFlashReadBlocks (Instance, Instance->StartLba + Lba, + BlockSize, Buffer); + if (EFI_ERROR (TempStatus)) { + // Return one of the pre-approved error statuses + return EFI_DEVICE_ERROR; + } + } + return EFI_SUCCESS; +} + +/** + Writes the specified number of bytes from the input buffer to the block. + + The Write() function writes the specified number of bytes from + the provided buffer to the specified block and offset. If the + firmware volume is sticky write, the caller must ensure that + all the bits of the specified range to write are in the + EFI_FVB_ERASE_POLARITY state before calling the Write() + function, or else the result will be unpredictable. This + unpredictability arises because, for a sticky-write firmware + volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY + state but cannot flip it back again. Before calling the + Write() function, it is recommended for the caller to first call + the EraseBlocks() function to erase the specified block to + write. A block erase cycle will transition bits from the + (NOT)EFI_FVB_ERASE_POLARITY state back to the + EFI_FVB_ERASE_POLARITY state. Implementations should be + mindful that the firmware volume might be in the WriteDisabled + state. If it is in this state, the Write() function must + return the status code EFI_ACCESS_DENIED without modifying the + contents of the firmware volume. The Write() function must + also prevent spanning block boundaries. If a write is + requested that spans a block boundary, the write must store up + to the boundary but not beyond. The output parameter NumBytes + must be set to correctly indicate the number of bytes actually + written. The caller must be aware that a write may be + partially completed. All writes, partial or otherwise, must be + fully flushed to the hardware before the Write() service + returns. + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. + + @param Lba The starting logical block index to write to. + + @param Offset Offset into the block at which to begin writing. + + @param NumBytes The pointer to a UINTN. + At entry, *NumBytes contains the total size of the + buffer. + At exit, *NumBytes contains the total number of + bytes actually written. + + @param Buffer The pointer to a caller-allocated buffer that + contains the source for the write. + + @retval EFI_SUCCESS The firmware volume was written successfully. + + @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. + On output, NumBytes contains the total number of + bytes actually written. + + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. + + @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be + written. + + + **/ +EFI_STATUS +EFIAPI +FvbWrite ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +{ + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS (This); + + return NorFlashWriteSingleBlock (Instance, Instance->StartLba + Lba, Offset, + NumBytes, Buffer); +} + +/** + Erases and initialises a firmware volume block. + + The EraseBlocks() function erases one or more blocks as denoted + by the variable argument list. The entire parameter list of + blocks must be verified before erasing any blocks. If a block is + requested that does not exist within the associated firmware + volume (it has a larger index than the last block of the + firmware volume), the EraseBlocks() function must return the + status code EFI_INVALID_PARAMETER without modifying the contents + of the firmware volume. Implementations should be mindful that + the firmware volume might be in the WriteDisabled state. If it + is in this state, the EraseBlocks() function must return the + status code EFI_ACCESS_DENIED without modifying the contents of + the firmware volume. All calls to EraseBlocks() must be fully + flushed to the hardware before the EraseBlocks() service + returns. + + @param This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL + instance. + + @param ... The variable argument list is a list of tuples. + Each tuple describes a range of LBAs to erase + and consists of the following: + - An EFI_LBA that indicates the starting LBA + - A UINTN that indicates the number of blocks + to erase. + + The list is terminated with an + EFI_LBA_LIST_TERMINATOR. + + @retval EFI_SUCCESS The erase request successfully completed. + + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled + state. + + @retval EFI_DEVICE_ERROR The block device is not functioning correctly + and could not be written. + The firmware device may have been partially + erased. + + @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable + argument list do not exist in the firmware + volume. + + **/ +EFI_STATUS +EFIAPI +FvbEraseBlocks ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, + ... + ) +{ + EFI_STATUS Status; + VA_LIST Args; + UINTN BlockAddress; // Physical address of Lba to erase + EFI_LBA StartingLba; // Lba from which we start erasing + UINTN NumOfLba; // Number of Lba blocks to erase + NOR_FLASH_INSTANCE *Instance; + + Instance = INSTANCE_FROM_FVB_THIS(This); + + DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks()\n")); + + Status = EFI_SUCCESS; + + // Detect WriteDisabled state + if (Instance->Media.ReadOnly) { + // Firmware volume is in WriteDisabled state + DEBUG ((DEBUG_ERROR, + "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n")); + return EFI_ACCESS_DENIED; + } + + // Before erasing, check the entire list of parameters to ensure + // all specified blocks are valid + + VA_START (Args, This); + do { + // Get the Lba from which we start erasing + StartingLba = VA_ARG (Args, EFI_LBA); + + // Have we reached the end of the list? + if (StartingLba == EFI_LBA_LIST_TERMINATOR) { + //Exit the while loop + break; + } + + // How many Lba blocks are we requested to erase? + NumOfLba = VA_ARG (Args, UINT32); + + // All blocks must be within range + DEBUG ((DEBUG_BLKIO, + "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%d - 1 ) > LastBlock=%ld.\n", + Instance->StartLba + StartingLba, NumOfLba, Instance->Media.LastBlock)); + if (NumOfLba == 0 || + (Instance->StartLba + StartingLba + NumOfLba - 1) > + Instance->Media.LastBlock) { + VA_END (Args); + DEBUG ((DEBUG_ERROR, + "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n")); + Status = EFI_INVALID_PARAMETER; + goto EXIT; + } + } while (TRUE); + VA_END (Args); + + // + // To get here, all must be ok, so start erasing + // + VA_START (Args, This); + do { + // Get the Lba from which we start erasing + StartingLba = VA_ARG (Args, EFI_LBA); + + // Have we reached the end of the list? + if (StartingLba == EFI_LBA_LIST_TERMINATOR) { + // Exit the while loop + break; + } + + // How many Lba blocks are we requested to erase? + NumOfLba = VA_ARG (Args, UINT32); + + // Go through each one and erase it + while (NumOfLba > 0) { + + // Get the physical address of Lba to erase + BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, + Instance->StartLba + StartingLba, + Instance->Media.BlockSize); + + // Erase it + DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", + Instance->StartLba + StartingLba, BlockAddress)); + Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); + if (EFI_ERROR(Status)) { + VA_END (Args); + Status = EFI_DEVICE_ERROR; + goto EXIT; + } + + // Move to the next Lba + StartingLba++; + NumOfLba--; + } + } while (TRUE); + VA_END (Args); + +EXIT: + return Status; +} + +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +STATIC +VOID +EFIAPI +FvbVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID**)&mFlashNvStorageVariableBase); + return; +} + +EFI_STATUS +EFIAPI +NorFlashFvbInitialize ( + IN NOR_FLASH_INSTANCE* Instance + ) +{ + EFI_STATUS Status; + UINT32 FvbNumLba; + EFI_BOOT_MODE BootMode; + UINTN RuntimeMmioRegionSize; + UINTN BlockSize; + + DEBUG ((DEBUG_BLKIO,"NorFlashFvbInitialize\n")); + + BlockSize = Instance->Media.BlockSize; + + // FirmwareVolumeHeader->FvLength is declared to have the Variable area + // AND the FTW working area AND the FTW Spare contiguous. + ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) + + PcdGet32(PcdFlashNvStorageVariableSize) == + PcdGet32(PcdFlashNvStorageFtwWorkingBase)); + ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) + + PcdGet32(PcdFlashNvStorageFtwWorkingSize) == + PcdGet32(PcdFlashNvStorageFtwSpareBase)); + + // Check if the size of the area is at least one block size + ASSERT((PcdGet32(PcdFlashNvStorageVariableSize) > 0) && + (PcdGet32(PcdFlashNvStorageVariableSize) / BlockSize > 0)); + ASSERT((PcdGet32(PcdFlashNvStorageFtwWorkingSize) > 0) && + (PcdGet32(PcdFlashNvStorageFtwWorkingSize) / BlockSize > 0)); + ASSERT((PcdGet32(PcdFlashNvStorageFtwSpareSize) > 0) && + (PcdGet32(PcdFlashNvStorageFtwSpareSize) / BlockSize > 0)); + + // Ensure the Variable areas are aligned on block size boundaries + ASSERT((PcdGet32(PcdFlashNvStorageVariableBase) % BlockSize) == 0); + ASSERT((PcdGet32(PcdFlashNvStorageFtwWorkingBase) % BlockSize) == 0); + ASSERT((PcdGet32(PcdFlashNvStorageFtwSpareBase) % BlockSize) == 0); + + + Instance->Initialized = TRUE; + mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase); + + // Set the index of the first LBA for the FVB + Instance->StartLba = (PcdGet32 (PcdFlashNvStorageVariableBase) - + Instance->RegionBaseAddress) / BlockSize; + + BootMode = GetBootModeHob (); + if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) { + Status = EFI_INVALID_PARAMETER; + } else { + // Determine if there is a valid header at the beginning of the NorFlash + Status = ValidateFvHeader (Instance); + } + + // Install the Default FVB header if required + if (EFI_ERROR(Status)) { + // There is no valid header, so time to install one. + DEBUG ((DEBUG_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__)); + DEBUG ((DEBUG_INFO, "%a: Installing a correct one for this volume.\n", + __FUNCTION__)); + + // Erase all the NorFlash that is reserved for variable storage + FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + + PcdGet32(PcdFlashNvStorageFtwSpareSize)) / + Instance->Media.BlockSize; + + Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, + EFI_LBA_LIST_TERMINATOR); + if (EFI_ERROR(Status)) { + return Status; + } + + // Install all appropriate headers + Status = InitializeFvAndVariableStoreHeaders (Instance); + if (EFI_ERROR(Status)) { + return Status; + } + } + + // + // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME + // + RuntimeMmioRegionSize = Instance->Size; + + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, + Instance->RegionBaseAddress, RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); + + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, + Instance->DeviceBaseAddress, SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes (Instance->RegionBaseAddress, + RuntimeMmioRegionSize, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes (Instance->DeviceBaseAddress, + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + FvbVirtualNotifyEvent, + NULL, + &gEfiEventVirtualAddressChangeGuid, + &mFvbVirtualAddrChangeEvent + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} From patchwork Fri Nov 10 14:21:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118548 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258652edl; Fri, 10 Nov 2017 06:22:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMbvSlVyt1oLtcuFyT5uAlQlryrrhyka7q8hVCNB85rIn1UNJSuxyO/wFZacwEoWKp3/sMhl X-Received: by 10.98.133.28 with SMTP id u28mr513780pfd.241.1510323773063; Fri, 10 Nov 2017 06:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323773; cv=none; d=google.com; s=arc-20160816; b=KKF1DDIFNZDU7GGla4qqQNTB6EMd/8wQO2RuDjRm9zvMFi8dM0fFtkqc51Tz/FXG/T qaSwuTzN4KKAOhB2VWbSqdKrAzSYf+sTRJW9YWrsZGhGLsU6Th4+pCod+Ga+9lQsobwN wliOlAeAhydMa6Tbu/eUufnxpTXudRG4QmjdPTxrbksTkF3DC8/nSFgjXPLRdZPpQY9a Caynqg/lutdJym3oX/nkD8T9RYo42S167gT8XILh5qcdCzp8QrQlQvGHpAu63drsoY3s RmFvEGDiMrL30Gl0tGVVjNTXst5s2EcJe2c9Ishycu1VFfp3mdKHrJlanJLIP071MKMg bE/A== 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=E8r/LPsn9ZeSTJOcpqr5L35bipVC4G2UX8jt12nQp1o=; b=CMwGNJwQiduMh78FcF2BmEMN/oXdXugm42Zzva0+MFiG3nEe0/WeliZ4xIwu0Dhsj1 hPnXVFDCYjyIf6yVnxXjjy4Y24FhcHetlKdvFEDJ9dNfoKGnXYsD50XbQ3uyUqrQL402 Aj6mLqkqj8sQsAmFkTVqUpew/kvYqcTcradkC2P/hXlxhY2m73wIgKBCj3xLGMNJ8EgS Hmb2HZSkp11sq1n7XCL+gBK1hOiGc3sfeVvCZtlu3QCRNy/ZomYmx8WvDl1fwR3phwpT 9mOW4UlobVpiIos3vlVjZw8AEYsPhilqgylkaS4mrgDQetdOH6e9rXNZOtH/5tcO4Ra1 9uJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Uq4AVIgU; 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 p66si8415326pga.805.2017.11.10.06.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:53 -0800 (PST) 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=Uq4AVIgU; 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 455F82035561C; Fri, 10 Nov 2017 06:18:28 -0800 (PST) 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=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 63BE220359A64 for ; Fri, 10 Nov 2017 06:18:27 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id b189so3056270wmd.4 for ; Fri, 10 Nov 2017 06:22:30 -0800 (PST) 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=uWhLWYK/RH6Cwj/lfojmq3aYUGCEgQJS5To2C5lybdY=; b=Uq4AVIgURNOrhk81YXrRpFTD0Gd8psfDElFc0xhyQNIWkIRyMhFvi1l87Obos4MSWp IMEbNxpASWj/4/LCTepLu1K1gpiU/SzWQa5XJMRZEoKAhU48iyq/vLBcEE4hawn93N9U LAISPPhoCp/OXm0tbPBEIe2y8HcaTCwjKja0s= 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=uWhLWYK/RH6Cwj/lfojmq3aYUGCEgQJS5To2C5lybdY=; b=Jwzz6DzmZHQOEdM09IUkymxbEYnfpZjndwR11QkYPBVxsmiqpMuVqNHTucQD26cb8Z iG1NVuDPRq3VuGgeD0pXiupJvDPi28x98IVz53yRaHUwI7cG4MOKnpAgHrJdwRWQ29FF GW3YtppQ5Rw6c9a2kisa1Lh/RfvldxCRjiP2Xx3UOeq9efSBiTjcrCcJLEgteE9h9mwS Rdt3sQlDnEiWqdM2GL3AsVPtWgA7mJLRaGY9ccalZ6JdX3t+ZDNwEzEmeWO9KoSWRfLl FZGXAWHmeWPBqzEM0iWwIJ7jZrnF7UOJ0u/Z4sEdUnsUvbfSpY5yWWZeRRVmN7Db67GY QPzw== X-Gm-Message-State: AJaThX5aNaEZxkOn+2ZA4r1/uanKrXHgg3eW3YtTAlaaM+AXxxc/qNZ8 8z/KutUHtXJdYfqthjfMRuhHAa1b1sM= X-Received: by 10.28.103.8 with SMTP id b8mr424037wmc.70.1510323748798; Fri, 10 Nov 2017 06:22:28 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:28 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:08 +0000 Message-Id: <20171110142127.12018-16-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 15/34] Platform/SynQuacer: incorporate NOR flash and variable drivers X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Wire up the non-volatile EFI variable store support, by switching from the emulation driver to the real one, and enabling the prerequisite FTW and NOR flash drivers. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 30 +++++++++++++++++++- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 9 ++++-- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 12 ++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf | 3 ++ 4 files changed, 51 insertions(+), 3 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 60a53dd797ed..2d107f13f352 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -341,6 +341,19 @@ [PcdsFixedAtBuild.common] # gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE + # + # Variable store + # + gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress|0x54800000 + gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress|0x08000000 + + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x08400000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00010000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x08410000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00010000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x08420000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000 + [PcdsPatchableInModule] gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 @@ -407,7 +420,6 @@ [Components.common] MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf ArmPkg/Drivers/TimerDxe/TimerDxe.inf - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf @@ -426,6 +438,22 @@ [Components.common] } # + # Variable services + # + Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf { + + NorFlashPlatformLib|Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf + } + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { + + AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf + TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf + VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf + } + + # # UEFI application (Shell Embedded Boot Loader) # ShellPkg/Application/Shell/Shell.inf { diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index c10e333efd43..ac5c458134b0 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -1,4 +1,3 @@ - # # Copyright (c) 2013-2014, ARM Limited. All rights reserved. # Copyright (c) 2017, Linaro Limited. All rights reserved. @@ -101,7 +100,6 @@ [FV.FvMain] INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf - INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf @@ -116,6 +114,13 @@ [FV.FvMain] INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf # + # Variable services + # + INF Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + + # # UEFI applications # INF ShellPkg/Application/Shell/Shell.inf diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index 30b42080d515..b682d631d0c2 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -97,6 +97,18 @@ STATIC CONST ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = { SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE), ARM_DEVICE_REGION (SYNQUACER_PCI_SEG1_PORTIO_MEMBASE, SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE), + + // variable store + ARM_DEVICE_REGION (FixedPcdGet32 (PcdFip006DxeRegBaseAddress), + EFI_PAGE_SIZE), + ARM_DEVICE_REGION (FixedPcdGet32 (PcdFip006DxeMemBaseAddress), + EFI_PAGE_SIZE), + ARM_DEVICE_REGION (FixedPcdGet32 (PcdFlashNvStorageVariableBase), + FixedPcdGet32 (PcdFlashNvStorageVariableSize)), + ARM_DEVICE_REGION (FixedPcdGet32 (PcdFlashNvStorageFtwWorkingBase), + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize)), + ARM_DEVICE_REGION (FixedPcdGet32 (PcdFlashNvStorageFtwSpareBase), + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)), }; STATIC diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf index 161072a33d99..db3e3b3792e4 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf @@ -29,6 +29,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec Silicon/Socionext/SynQuacer/SynQuacer.dec [LibraryClasses] @@ -53,6 +54,8 @@ [FixedPcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress + gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase [Pcd] From patchwork Fri Nov 10 14:21:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118550 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2258946edl; Fri, 10 Nov 2017 06:23:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMYw9ypbI7eiFa2lQVU47pmqk1veiU7ulmoHO+jrsHhRdjL94jBSaajezd/3ogwxeTEr3lLd X-Received: by 10.99.110.197 with SMTP id j188mr528018pgc.34.1510323788269; Fri, 10 Nov 2017 06:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323788; cv=none; d=google.com; s=arc-20160816; b=wqTMybiFp++NwhPhfOgRXoMSWnt/+3Hvbxw2ZqPcDudHFu1Q1M2oA8FhlZbnczQAf1 ilwDIO0VS+Z1zF6FsNJgvBSk1N8lzX+2R6/n7E/PyDfGZWGJlmZNJ2aGIk7nGLR/w1el DB4OxXC9PrGN0V+UFm0z3a6qD/7ikLexYCbE8vpSvt8bEPq3PoKukcvDtWqrlN4AHNt1 oWgmpz6aWrXm3cKZtQRQXxFUcqUXgylekMxv5eRwp8Dn2nekj+V/SmkMVahCnvXp2vS2 pNPf6DxrQak67DP+P7PhVxz7zD+1AEWGiZ6qtow3booO6Ha51tq6X55q8IpNzhdYrjjE 6h+A== 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=iO9PcgEvCsOD5SHT9ob2Ms2gyh/pQGaQ9nrqX/apqeM=; b=xXoW0FE/rvZrcYmU7A7pdxo8j30/nkC+2QtSHeIWZWRB1kNpZqSieZP/mcijNZc1dq MXmjHVOz65X5TJd5nkRALMBnTukobF1Pl6YPilHKX5bT7y3lHWGmoHl6ZvLNuDvBMxM9 xkI6SepoERo4vuyA8WM3/3EgYe6pB5MaBxR6ASA6LVhSLJCOUTAvLty1kJ8V9fjcI5zL nGzkGbkHmpevpCRV/U7KcvX4ayrxWKt3UY7Mqqhkf65Q6pCVKKn7cMaOSSVHaVgJJidX VvHWCmkWx7XBmLif5bTc8cpy3cs9NW5JJ3/4hDsqN9W6GFmokY3fbs70Iha9mtpMhB9v ezAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G4NLn6/P; 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 w12si9009130pgp.482.2017.11.10.06.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:08 -0800 (PST) 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=G4NLn6/P; 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 EC92A20355206; Fri, 10 Nov 2017 06:18:31 -0800 (PST) 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=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 8090B2035D0F1 for ; Fri, 10 Nov 2017 06:18:29 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id r68so3084690wmr.1 for ; Fri, 10 Nov 2017 06:22:32 -0800 (PST) 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=F+2516Ub3p/EZc47xRz2y9cdDIyvuoDj3fQ3P0BsbzM=; b=G4NLn6/P5jKjoriZ8c/bLAa+9pMNfoAenVvFIlRcJNSW6ECfS7IQw7o/LlQiCtMKif SKUAc82UVI7AOGxA88ymAbxuSCbKyrq5QJYF7WSQY/3MF5UZlj6J5ajkjojb7XtJd+MC SxyF49AP819aSMBGNOySTmJrR8SPAb1NzM+3A= 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=F+2516Ub3p/EZc47xRz2y9cdDIyvuoDj3fQ3P0BsbzM=; b=bLVOs1fAD9hhoAs9wnMnwOf93kGduyPYX47SUW4xT97G747TFJBT+F12U1pE5Etq8+ zNP14jInrQ4CP9SgKXzyJFtEv+0IYim/r5GvuNoDJVlSgIzDbzszLQWqqxZoqTwWA7BY LbOeHfSkzTRnAVsdBchecOUtrVMygMyXkQtm+HgreQfD53YXJwMUsXxw1QF9pN6eXLtr L9tL3fub8AyNObTJuYEp3gCYrep7yRfmEEmg8uOWC6jd31Pi0tg1919EFBITCC3LreyF bCpDi8ysFrlg0kqNBEsrGJIAHrDGEDWJX923p04D147fZzAWYo6lMY5AzNGCV9V4wlHB j4ww== X-Gm-Message-State: AJaThX6Qkf/iCyoTIOsBfYlAWGywLHDF17mB0wJGAm4JEOKhaJ47KknB ZkruHFXlwb9OIZ0Fvlk2blBIJ/dWpIA= X-Received: by 10.28.131.200 with SMTP id f191mr385783wmd.39.1510323750868; Fri, 10 Nov 2017 06:22:30 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:30 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:09 +0000 Message-Id: <20171110142127.12018-17-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 16/34] Silicon/SynQuacer: implement PlatformFlashAccessLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In order to support capsule update, implement PlatformFlashAccessLib that exposes write access to the UEFI NOR partition. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c | 251 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf | 38 +++ 2 files changed, 289 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c new file mode 100644 index 000000000000..5a67f8c00995 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c @@ -0,0 +1,251 @@ +/** @file + Platform flash device access library for Socionext SynQuacer + + Copyright (c) 2016, Linaro, Ltd. 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 + +/** + Gets firmware volume block handle by given address. + + This function gets firmware volume block handle whose + address range contains the parameter Address. + + @param[in] Address Address which should be contained + by returned FVB handle. + @param[out] FvbHandle Pointer to FVB handle for output. + + @retval EFI_SUCCESS FVB handle successfully returned. + @retval EFI_NOT_FOUND Failed to find FVB handle by address. + +**/ +STATIC +EFI_STATUS +GetFvbByAddress ( + IN EFI_PHYSICAL_ADDRESS Address, + OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **OutFvb, + OUT EFI_PHYSICAL_ADDRESS *FvbBaseAddress + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; + EFI_FVB_ATTRIBUTES_2 Attributes; + + // + // Locate all handles with Firmware Volume Block protocol + // + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiFirmwareVolumeBlockProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + // + // Traverse all the handles, searching for the one containing parameter Address + // + for (Index = 0; Index < HandleCount; Index += 1) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiFirmwareVolumeBlockProtocolGuid, + (VOID **) &Fvb + ); + if (EFI_ERROR (Status)) { + Status = EFI_NOT_FOUND; + break; + } + // + // Checks if the address range of this handle contains parameter Address + // + Status = Fvb->GetPhysicalAddress (Fvb, FvbBaseAddress); + if (EFI_ERROR (Status)) { + continue; + } + + // + // Check if this FVB is writable: DXE core produces FVB protocols for + // firmware volumes as well. + // + Status = Fvb->GetAttributes (Fvb, &Attributes); + if (EFI_ERROR (Status) || !(Attributes & EFI_FVB2_WRITE_STATUS)) { + DEBUG ((DEBUG_INFO, + "%a: ignoring read-only FVB protocol implementation\n", + __FUNCTION__)); + continue; + } + + FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) *FvbBaseAddress); + if ((Address >= *FvbBaseAddress) && (Address <= (*FvbBaseAddress + FwVolHeader->FvLength))) { + *OutFvb = Fvb; + Status = EFI_SUCCESS; + break; + } + + Status = EFI_NOT_FOUND; + } + + FreePool (HandleBuffer); + return Status; +} + +/** + Perform flash write operation. + + @param[in] FirmwareType The type of firmware. + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] FlashAddressType The type of flash device address. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +PerformFlashWrite ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length + ) +{ + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_STATUS Status; + UINTN BlockSize; + UINTN NumberOfBlocks; + EFI_LBA Lba; + EFI_PHYSICAL_ADDRESS FvbBaseAddress; + UINTN NumBytes; + + if (FlashAddressType != FlashAddressTypeAbsoluteAddress) { + DEBUG ((DEBUG_ERROR, "%a: only FlashAddressTypeAbsoluteAddress supported\n", + __FUNCTION__)); + + return EFI_INVALID_PARAMETER; + } + + if (FirmwareType != PlatformFirmwareTypeSystemFirmware) { + DEBUG ((DEBUG_ERROR, + "%a: only PlatformFirmwareTypeSystemFirmware supported\n", + __FUNCTION__)); + + return EFI_INVALID_PARAMETER; + } + + // + // Locate the gEfiFirmwareVolumeBlockProtocolGuid implementation + // that covers the system firmware + // + Fvb = NULL; + Status = GetFvbByAddress (FlashAddress, &Fvb, &FvbBaseAddress); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: failed to locate FVB handle for address 0x%llx - %r\n", + __FUNCTION__, FlashAddress, Status)); + return Status; + } + + Status = Fvb->GetBlockSize(Fvb, 0, &BlockSize, &NumberOfBlocks); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to get FVB blocksize - %r\n", + __FUNCTION__, Status)); + return Status; + } + + if ((Length % BlockSize) != 0) { + DEBUG ((DEBUG_ERROR, + "%a: Length 0x%lx is not a multiple of the blocksize 0x%lx\n", + __FUNCTION__, Length, BlockSize)); + return EFI_INVALID_PARAMETER; + } + + Lba = (FlashAddress - FvbBaseAddress) / BlockSize; + if (Lba > NumberOfBlocks - 1) { + DEBUG ((DEBUG_ERROR, + "%a: flash device with non-uniform blocksize not supported\n", + __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + // + // Remap the region as device rather than uncached. + // + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, + FlashAddress, Length, EFI_MEMORY_UC); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: gDS->AddMemorySpace () failed - %r\n", + __FUNCTION__, Status)); + } + + Status = gDS->SetMemorySpaceAttributes (FlashAddress, Length, EFI_MEMORY_UC); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: gDS->SetMemorySpaceAttributes () failed - %r\n", + __FUNCTION__, Status)); + return Status; + } + + // + // Erase the region + // + DEBUG ((DEBUG_INFO, "%a: erasing 0x%llx bytes at address %llx (LBA 0x%lx)\n", + __FUNCTION__, Length, FlashAddress, Lba)); + + Status = Fvb->EraseBlocks (Fvb, Lba, Length / BlockSize, + EFI_LBA_LIST_TERMINATOR); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fvb->EraseBlocks () failed - %r\n", + __FUNCTION__, Status)); + return Status; + } + + while (Length > 0) { + // + // Write the new data + // + DEBUG ((DEBUG_INFO, "%a: writing 0x%llx bytes at LBA 0x%lx\n", + __FUNCTION__, BlockSize, Lba)); + + NumBytes = BlockSize; + Status = Fvb->Write (Fvb, Lba, 0, &NumBytes, Buffer); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: write of LBA 0x%lx failed - %r (NumBytes == 0x%lx)\n", + __FUNCTION__, Lba, Status, NumBytes)); + } + + Buffer += BlockSize; + Length -= BlockSize; + Lba++; + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf new file mode 100644 index 000000000000..33f4795ddcf9 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf @@ -0,0 +1,38 @@ +## @file +# Platform flash device access library. +# +# Copyright (c) 2017, Linaro, Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerPlatformFlashAccessLib + FILE_GUID = b4e7f39f-ab67-4318-b1ad-c1e211304f0b + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = PlatformFlashAccessLib|DXE_DRIVER + +[Sources] + SynQuacerPlatformFlashAccessLib.c + +[Packages] + MdePkg/MdePkg.dec + SignedCapsulePkg/SignedCapsulePkg.dec + +[Protocols] + gEfiFirmwareVolumeBlockProtocolGuid + +[LibraryClasses] + BaseMemoryLib + DebugLib + DxeServicesTableLib + UefiBootServicesTableLib + From patchwork Fri Nov 10 14:21:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118551 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259081edl; Fri, 10 Nov 2017 06:23:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMYC1NnmWdQnWfD8XGeRa3MCqI0xX2qYWFmc4BbZ9jVRPd8n34zUGKPIwPsIGJe/Knubzv1V X-Received: by 10.98.109.134 with SMTP id i128mr578701pfc.66.1510323795309; Fri, 10 Nov 2017 06:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323795; cv=none; d=google.com; s=arc-20160816; b=GVGNrYcSPOZepmPLP8SmPlGCVRk3CwuOruLep1+2wn3Gtp6cE7tQa7SZaOJ0LhSNyy 3EVRmdvDswWp9zs67AxT87csMdfEOQChttTxc8ztc2zM8u0h+PolBwT82LG36wmmIDbj 70QyT5jVKGq46iH+YoQt0KV+vSHj0lpRvF5aVYddmO6NHw3AZrmDoFbWZmuo3ebO1lOX 5vU1FCnWQjAWAaUOxIaJGPyAEwq5fRWTVGoRxMw+utNk88lUiO9GFrp76uviDEm5rDxB ft7BK3sQH7Dd1S/GW0hcvA5UUlDTN/W58gnbPkd2aCeVuNSJPGg6VwiHn150uWTzT+hx fVmA== 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=yte71l5BIM/24m36b030FA9HFkPND331D8k+RtIhUuU=; b=H2d9G8EPq2MUSCDy9WMSHchRwNLuNL2vRjOmkkM7SJgou6dSCmp8K3wyB0T6pCQaFh yitQfx7cyCLvUdq+wi0HtomYMCBjSd14bs2jd5EUHCfAb099dfwpfslESCY0gzKflnMm LiP4YD34CIY6hGh3bU3IMslhBGS0Ao9w0b6oj/r6XhgHTwayZOdjyj3oon7NKAztrDVH KzizVkZ6fZQigr1jntMSh0nTL3DbK7n3jMA9lJNRrCY7twDK7dB8aFIDV7ZbJHt5zCdP 4e7VojJ7AT7Aug/ZnCVeEo9E0eG01niehTRAXQ/+60P6g471Tcg+rWL6uh5LAQB8bp1C Gy5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RBYBWJot; 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 p3si8723924pgs.362.2017.11.10.06.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:15 -0800 (PST) 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=RBYBWJot; 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 3E1F920355229; Fri, 10 Nov 2017 06:18:34 -0800 (PST) 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=2a00:1450:400c:c09::244; helo=mail-wm0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 6902320355206 for ; Fri, 10 Nov 2017 06:18:31 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id p75so3073553wmg.3 for ; Fri, 10 Nov 2017 06:22:34 -0800 (PST) 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=Y5UDfaBTsgJADu7C8mSV3x8sjiF3kUBLpPWCg6uNqFI=; b=RBYBWJotL7cL0n6E8dMboQFOnTr7eCFT9n2m+sWV/c2Cszq6w/pTtU1Csta4NuvKys cN6y94ZgNexrDHbb9GupiBj9qs+VURGsYABKCQJ7Mwg8TuX6epUKx203/Tzv9vCcG8D6 SGt2vSR1sxPPefXs6ksCX5HRtISMmgDtwSbNU= 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=Y5UDfaBTsgJADu7C8mSV3x8sjiF3kUBLpPWCg6uNqFI=; b=V4KrkePhqLkmKEOTwCzIggz6HNssibkGc0NwhIdn6Nmn7kEnwSddQnimFa90+Vs6Hp iAnjNNNgaS249u/R2L2w210u6YUuj2kG1HNrJAIPJjywLCfPESngEYye4WKW8EWB/dfN sK866MCVIGdjFcTIrCAYn3p25Aps0O8b4+y1dVA+4d5l4VCS45YffIQryDws4xurde+9 D3Ri5T4PSZcc545ooR27ulOeGI18fajzyGra608dXssVE5AYSLNu177TYFX9/jQHuSwq 2haMwmbpKKUEL5rNy+vxzq+azlMbpYp12TQcxqztA77ReFcy2kptl5OgBd+ae65uaAxo cWRQ== X-Gm-Message-State: AJaThX6rsPK2gTmX5yUdZhBYQvjSVo0/fB+6gQMuqcfalCjP15i1q2EL awN16JEGpuU5fETf7UnaM83+wqJ/LD0= X-Received: by 10.28.61.213 with SMTP id k204mr355921wma.110.1510323752865; Fri, 10 Nov 2017 06:22:32 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:32 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:10 +0000 Message-Id: <20171110142127.12018-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 17/34] SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add support for dealing with capsules left in memory by the OS before reboot. This needs to be done early, before the memory is reused, which is why the initial handling must reside here. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 52 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf | 4 +- 2 files changed, 55 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index b682d631d0c2..b44c58d61062 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -22,10 +22,12 @@ #include #include #include +#include #include #include +#include #include #define ARM_MEMORY_REGION(Base, Size) \ @@ -177,6 +179,11 @@ MemoryPeim ( { EFI_STATUS Status; ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; + EFI_PEI_SERVICES **PeiServices; + PEI_CAPSULE_PPI *Capsule; + VOID *CapsuleBuffer; + UINTN CapsuleBufferLength; + BOOLEAN HaveCapsule; Status = DeclareDram (&VirtualMemoryTable); ASSERT_EFI_ERROR (Status); @@ -184,12 +191,57 @@ MemoryPeim ( return Status; } + PeiServices = (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (); + ASSERT (PeiServices != NULL); + + Status = PeiServicesLocatePpi (&gPeiCapsulePpiGuid, 0, NULL, + (VOID **)&Capsule); + ASSERT_EFI_ERROR (Status); + + // + // Check for persistent capsules + // + HaveCapsule = FALSE; + Status = Capsule->CheckCapsuleUpdate (PeiServices); + if (!EFI_ERROR (Status)) { + + // + // Coalesce the capsule into unused memory. CreateState() below will copy + // it to a properly allocated buffer. + // + CapsuleBuffer = (VOID *)PcdGet64 (PcdSystemMemoryBase); + CapsuleBufferLength = UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase); + + PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); + + Status = Capsule->Coalesce (PeiServices, &CapsuleBuffer, + &CapsuleBufferLength); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", + __FUNCTION__, CapsuleBuffer, CapsuleBufferLength)); + HaveCapsule = TRUE; + } else { + DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status == %r)\n", + __FUNCTION__, Status)); + } + } + Status = ArmConfigureMmu (VirtualMemoryTable, NULL, NULL); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } + if (HaveCapsule) { + Status = Capsule->CreateState (PeiServices, CapsuleBuffer, + CapsuleBufferLength); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: Capsule->CreateState failed (Status == %r)\n", + __FUNCTION__, Status)); + } + } + if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) { // Optional feature that helps prevent EFI memory map fragmentation. BuildMemoryTypeInformationHob (); diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf index db3e3b3792e4..6c3420a525d6 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf @@ -39,6 +39,7 @@ [LibraryClasses] DebugLib MemoryAllocationLib PeiServicesLib + PeiServicesTablePointerLib [FeaturePcd] gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob @@ -62,7 +63,8 @@ [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase [Ppis] + gPeiCapsulePpiGuid ## CONSUMES gSynQuacerDramInfoPpiGuid ## CONSUMES [Depex] - gSynQuacerDramInfoPpiGuid + gPeiCapsulePpiGuid AND gSynQuacerDramInfoPpiGuid From patchwork Fri Nov 10 14:21:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118552 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259171edl; Fri, 10 Nov 2017 06:23:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMaHhFbK64TCs1RDzDCTE458qftFdpaFUeUolIw4gC5VXq6hlJrfyMkZiHQHfTGpL3sr5Ktv X-Received: by 10.98.71.194 with SMTP id p63mr583729pfi.26.1510323800946; Fri, 10 Nov 2017 06:23:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323800; cv=none; d=google.com; s=arc-20160816; b=ToTNBVkFsNwB4BRrFPEJQhOGi+4OrYJ4zhZmeGkwwu/b2KM2whhEda4usBZ7B3nk8F wpZI9VqtEwOAVN3+hluk6m0mUtQK4/CsQ3jj/Tu3XRMF5usFETcM+NJbvJQGOj9KaJNI w/wqwWn8yxdSUqtWRLPkBYzwMlKbhnolXAYclFISP0gvUZND5dPoIZ22yMhbrI1Jd2zs zuZdtyoyaFpQ2ySJbOC03F24wRps327eC0QyGI51m9u3/21jnuiYddesu5N+4rq6SDwC 39y6bePRSHDgmuYwDKv8GUSAG/jN46snrh65gAfwgy2S54QZrQxaVya2WhApgRCkpNi+ B9aw== 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=JsWlIOGDyxaqlODPMWo0zbI7ymW4VL3j2Re80qsf3SU=; b=tlPAqZyEx6Q7D8dBQGa+WB44gxkJdTwtGX6cMT/xBwH4McGafY8XyI0/RbZYpySycP ZJRx9zszQY3huoesX0jDh4Pevrwz8TxKGepzk/E8KG1uPfKVVk7M/XuFXa+hH2/LlH6u HQ6fL+4gIFkqOkrJzdMdNS27UR58HzgRrN7zge/nFeY7nxynFKOswPQ8i2sNLFF0l2qC NaOC+DbnVCRdBFejeVpjYQK45SNACMmLO4vwdCJxxWyohCL0YxsO0XXqI59obFHb+8HE aE3dexye7Q+RSiKKSg7L1gcFu3ehZmXWXkzuGYdGPY4OoGYamZ6P4ltqu3wDUUkGxDeo y7YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=K/ztwDsn; 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 i2si9565296pfi.269.2017.11.10.06.23.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:20 -0800 (PST) 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=K/ztwDsn; 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 7ABA420355611; Fri, 10 Nov 2017 06:18:36 -0800 (PST) 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=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 BA96C20355611 for ; Fri, 10 Nov 2017 06:18:33 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id b9so3061413wmh.5 for ; Fri, 10 Nov 2017 06:22:36 -0800 (PST) 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=/3GtAw7s3Hma2V99L6iBjEKGx61koDqVHDemNVtOD2Q=; b=K/ztwDsnvQI/WpPzKA0/A4HUojKb4z+KJRDRauFul44OvKhcuqHq43b8QJB1Fh2vPS dUMiA+vzqfdjQwhX66i2JkHZO8aqBNqsDgPx7Gu/6ApEH0OeNWiyOHDF72T9A5Y9LNea +wSBB89iDgTGXfaQNq33A15zYmXPdNJPQElXI= 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=/3GtAw7s3Hma2V99L6iBjEKGx61koDqVHDemNVtOD2Q=; b=GiXv1RVEsx59kvGT9nxf0WxcwTftqzWUk7Gh83y6SPc7GNJre0DcxBd6EKygvy/Tlc IPTvmeu+yAJyX+MJScReNoxbvNx8bCFkumeWCKGrWvqjytzmX8bpR9OX1wkCnPHt41HX GN+WW1RbYqf0vjaiN5KW0YqtKL0tFe/9f3aWsT5/5TbcJDrjh7+Tifb3OMw/KoPb9VWm iINiT5o+OG3d1S0jO6FbXAhtg1ORM6KFC+4HCPEV90QfuPBkW3scMXm+0yBGCzkHULsI mbTlBl4FiQq0T0mohE5aaS+uh8zmxfBjKkTDIgzCMGgs00fg4snYdUEFGUHBawKsjg6i LRIQ== X-Gm-Message-State: AJaThX7Y6RTTD2HVL3+Ts7k/c0Kska6O1nfn4AqOJp5kRrweRpUTPEXr +umcpOJGJ6qIoM8GmRCyEKLpfaLyqig= X-Received: by 10.28.2.213 with SMTP id 204mr394093wmc.106.1510323755139; Fri, 10 Nov 2017 06:22:35 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:34 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:11 +0000 Message-Id: <20171110142127.12018-19-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 18/34] Socionext/SynQuacerEvalBoard: wire up basic capsule support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 7 ++++++- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 2d107f13f352..0f60bb65a11b 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -157,6 +157,7 @@ [LibraryClasses.common.DXE_DRIVER] DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf # # PCI @@ -182,7 +183,7 @@ [LibraryClasses.common.UEFI_APPLICATION] [LibraryClasses.common.DXE_RUNTIME_DRIVER] BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf ################################################################################ @@ -198,6 +199,8 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|TRUE + [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"Linaro" @@ -388,7 +391,9 @@ [Components.common] ArmPlatformPkg/PlatformPei/PlatformPeim.inf ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf ArmPkg/Drivers/CpuPei/CpuPei.inf + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + MdeModulePkg/Universal/CapsulePei/CapsulePei.inf MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index ac5c458134b0..c099c3dd8d2f 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -235,7 +235,9 @@ [FV.FVMAIN_COMPACT] INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf + INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + INF MdeModulePkg/Universal/CapsulePei/CapsulePei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { From patchwork Fri Nov 10 14:21:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118553 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259257edl; Fri, 10 Nov 2017 06:23:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMb+RChNVKS7tJ0IyvQjNDUZahMxntDH+1ONCIQ3+S8WVaPLfY3SoUqfFI6fBsEqh77RgEDR X-Received: by 10.98.89.82 with SMTP id n79mr531049pfb.133.1510323805601; Fri, 10 Nov 2017 06:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323805; cv=none; d=google.com; s=arc-20160816; b=tfMt/50S8QoPpBzRFwAQzopN+9j6ZbIHv1TB0pho1gruYlvNn/0ACdl78KlsbSFjOE SGQ+RuTyf5I51o7EK+RtLnp5URUzitQXT74Hc4N5MgWSJpUWLdkNbz2yzLLS/8llz323 7Rh7ESbMk1osF0LPz5BXwhBA21V0t4RYD8Qlc+gNs+GCBUht+21m/toY1SpHjY9oQWYy PjVaOFNWZgRb4aaPO+I0gRkxo7gjD5+UYwSlbdzHb57spw/EJ5Y493gONPl4/G69sGlK RYgO7snuRecQnKx4d64s0ymaUWMHx+JdVR0v5NeXVZX+pTzySjri+oc+7OpSs+evqcUv 38mg== 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=t8KTGgpyB+VKDdC6W9HFOCgi82RpDdIbNsI2j8gMvQQ=; b=EhHdXoLS8IqPJk2M80kY/cQP03D3D1VoB857YId6llDqFvoFy4c6WYZwGgfp4u7ZdP euePhJEZ/cG75DZLtkb9ZDaH7wKnqgNT7SeD/rWLc0se3uYCUUyqOZZACS5IktUBBuej O7FNCeTijfsqL7KqfKDvMnObjM9IrvMnIKRjstMkdhTP8uCZGE2H3biJhREPf5878fqt eHat5G+WdWDiyJB1XhbjrNdwoEp7/P5nLwb0oFvgQoLxXU6vJh60TwecpHEryjxauE5N tr4E7oKe8wxdoaK951BIKrQSCv4McQpTtb4f5RsoaEAMEWJu1XPfqxvdYltQ49k+Ybme m9VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fmpjCTDb; 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 f8si9074651pgn.420.2017.11.10.06.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:25 -0800 (PST) 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=fmpjCTDb; 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 BA28E2035D0F1; Fri, 10 Nov 2017 06:18:37 -0800 (PST) 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=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 20C0621B00DF6 for ; Fri, 10 Nov 2017 06:18:36 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id b9so3061662wmh.5 for ; Fri, 10 Nov 2017 06:22:39 -0800 (PST) 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=yte7/lc315mQgJmsxKa22JfVTiRtUcaSwPYvaAcuyVI=; b=fmpjCTDbDXQ/rb7fHwRnsKBe0CS7mxHd8EKqjAyj0Pof7huchDY8WnEDyy0gGtKgcL F1oBtAGTs6BOxAsr43Mm3w8rsjEPh2hdmz9NAJFNoKLVfEORjhXB5iVw2jG20gdnBBzo XEzHwnh0tC4if6bozG5NluR/tJd/b5Wbu/hTc= 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=yte7/lc315mQgJmsxKa22JfVTiRtUcaSwPYvaAcuyVI=; b=rSj2f0Wak/qK+qR8+gADgkwXamR43gLfVaUuMHWyoyh6yXfowBOQGHAUaOMggPMvbQ DXVzGCkizCT4lo4RjSod8m+2IkOdfOQGVF7LtpJbYVSZ+g0yQWkM+U7infUOXkH0EpkY SYUwZpGK2vx9r32qi8DyyEEqmQ5XIGRwmxyBMsSPtZICR9XHwonDMeDHHDl3fWXy/BRQ pOZ+S8QeSLMkKhLvvba83oF0K5939vqkAPhhbgGqVqZFOHFyZ9typREu4p6WtIlJe7UF XN3omCRDTf/f6jr6lQV9zfi0XDPNC14XAzmWgcm8ZZBBvkHTJYGZIW43NONHjK3JGZHy Pk2g== X-Gm-Message-State: AJaThX6U3paviRgbZYF6/v5ljFjsIQJ/iEyPYA9AHQcIYDPKP/zNZ+fC Iuq+QWdrC68l1q2Tthb1PY3m6e0lec0= X-Received: by 10.28.142.20 with SMTP id q20mr352990wmd.37.1510323757592; Fri, 10 Nov 2017 06:22:37 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:36 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:12 +0000 Message-Id: <20171110142127.12018-20-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 19/34] Socionext/SynQuacerEvalBoard: switch to execute in place X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Now that we switched to PrePeiCore, we can execute the firmware image in place, using a stack and temporary heap in non-secure SRAM. This allows us to query the secure firmware for the size and placement of DRAM, and also allows the use of capsules for firmware update. NOTE: this requires ARM Trusted Firmware to be built with PRELOADED_BL33_BASE set to the base of UEFI in the NOR flash, 0x820_0000 in our case. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index c099c3dd8d2f..80cbcdad18aa 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -26,7 +26,7 @@ ################################################################################ [FD.BL33_AP_UEFI] -BaseAddress = 0xE0000000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. +BaseAddress = 0x08200000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. Size = 0x00200000|gArmTokenSpaceGuid.PcdFdSize # The size in bytes of the FLASH Device ErasePolarity = 1 From patchwork Fri Nov 10 14:21:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118554 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259345edl; Fri, 10 Nov 2017 06:23:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYV0R7QwesjMCYRTD7Mp25yPOAT4nBzNtQA5mruYYj6FMpTKUYo3JKP0uAfUoNVd3x8wmax X-Received: by 10.98.182.15 with SMTP id j15mr546256pff.47.1510323810437; Fri, 10 Nov 2017 06:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323810; cv=none; d=google.com; s=arc-20160816; b=aPPwRAghmRjHBlcoBvceMvoTTB1R1I3avdDGOLrhgNeqa92odgrz4HjPpEmYYTCP1F mSWh00UPEaYl0MKRVL2iJqeyXp9CdkgyAWRZGdY+ScVjKA/JeaxijxQPi7SQsdH+ru5x EEUabTr/KdjU8ZcTnPVcGMzMRB99YcEXz4k/dMdzQQEOlA7fpREQHCJqh1cYA5hqxCB+ d+gffswpZvbEERUoMbK37s7KUFwjnkuwIT+qXKGoPVSjiQh0N/NW4Cw6EGaMKoSumG8v PaPtr+22qJnHOgATQiXJmyw9KqyIaJgXHBIN3UroRuHkAgpV4t7GG82L0kfKLn840tYM WKcQ== 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=EbsG0jzsjJIGd4mWC1mYdsoYxHvk5zWn/8Qnxb2d2wQ=; b=Fce247M59BNwQZx6RGfOki3Ecuo2gNWSEsJXa8CWCejjdoKgpem3yHy/sjeUYoYuUi isak4BkPQMYrnJOtrGCbLx+Dx1Y3ejKwIkBH8hHlvDmA9JPf5cZcWU77UyzW9YsUd5vw lW3OBFBuSXp7FKE1QeptJjYjHIM51SYYr43dabt25hcUvG3KUEdkGSw9YFFs8ZJiv8aC a6IXwjG7VZ46pf6+nBl5ekOqkbsdo37P1xutg0FF3GiHd9/5HuvMcpTu4U6D2PyrZdOQ /4GT+Esu8fXjWn8w4ytsR9ZrllxwnCgsXaW2vAYONjxnC6HEwsSN9ehk0R1uz3SJypeE Hu6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N6LrU72r; 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 u127si8766457pgc.803.2017.11.10.06.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:30 -0800 (PST) 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=N6LrU72r; 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 06EEF21B00DFB; Fri, 10 Nov 2017 06:18:41 -0800 (PST) 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=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (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 13E8A21B00DFB for ; Fri, 10 Nov 2017 06:18:39 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id p96so8732081wrb.7 for ; Fri, 10 Nov 2017 06:22:42 -0800 (PST) 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=boWWqecd+7kUxvmheoruCw0JbR40q2gXN8HWKWfLNZs=; b=N6LrU72rnrXaNIiFOSjm+HaOGNPzbIdJKaAYqA2u/mgwI8VyrWhTfG4ZUJhk0LlF+G 50PBr2QvYZu9vTmrPeP8UNLKEup01YbGu9z8I9dLWpzOZWIIryZo9aH4UmwsA/1RNHZR xphBv5GU7iusyshVZhEljOTwwvFgnObHXvzjw= 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=boWWqecd+7kUxvmheoruCw0JbR40q2gXN8HWKWfLNZs=; b=fRIpsVH9sB0WhTlRRw7U14di+G1SnE2fqddcLVkPuDG5bT8Efh86kg3/jqqb25AuTu LAI0pRlKrehyzLKpfUMSIxDJlPsW8nFM2CS8tYlEivTRUoQrhKLUYrJ46Ym8pAEnbIne bbCmrgceL05WrSqK0lR/RD1XU6elF9G+0IPrarDDQ56bLXwKt32tqghl+A1bpoyGoEur g791B5Kn6qGcwRpcS871BoK1sGG7qVb8+anFaiILAC5eyt4MgcLT3MGZlOS3Yu9Ug3ee 4ldHY/dvFh1zDXxpysrJQeQXd9skpdidV4V8tUAHkw+8zB8aLeeBhri29TIpfhp3wjOk 7Z7Q== X-Gm-Message-State: AJaThX53XZb4q8q5BOPxmqztXJesJP31530DWuvvneDMaWx/McdGJRUT dhK1xrUFShD7Usg1T5rbNItKkj35aRM= X-Received: by 10.223.168.23 with SMTP id l23mr461579wrc.15.1510323760287; Fri, 10 Nov 2017 06:22:40 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:39 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:13 +0000 Message-Id: <20171110142127.12018-21-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 20/34] Platform/SynQuacerEvalBoard: add signed capsule update support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add all the boilerplate to make the SPI NOR image updateable using signed capsules and the FMP protocol. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 20 +++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 86 ++++++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 46 +++++++++++ Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 68 ++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc | 80 ++++++++++++++++++ Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 25 ++++++ 6 files changed, 325 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 0f60bb65a11b..4630d78bce93 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -120,6 +120,10 @@ [LibraryClasses.common] NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf + NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf [LibraryClasses.common.SEC] @@ -157,7 +161,15 @@ [LibraryClasses.common.DXE_DRIVER] DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + + # + # Firmware update + # CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf + PlatformFlashAccessLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf # # PCI @@ -575,3 +587,11 @@ [Components.common] # DT support # Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf + + # + # Firmware update + # + Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index 80cbcdad18aa..365085c8f243 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -209,6 +209,16 @@ [FV.FvMain] # INF RuleOverride = DTB Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.inf + # + # Firmware update + # + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + FILE FREEFORM = PCD(gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiPkcs7TestPublicKeyFileGuid) { + SECTION RAW = BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer + SECTION UI = "Pkcs7TestRoot" + } + [FV.FVMAIN_COMPACT] FvAlignment = 16 BlockSize = 0x10000 @@ -238,6 +248,7 @@ [FV.FVMAIN_COMPACT] INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf INF MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + INF RuleOverride = FMP_IMAGE_DESC Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { @@ -246,6 +257,72 @@ [FV.FVMAIN_COMPACT] } } +[FV.CapsuleDispatchFv] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + +INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf + +[FV.SystemFirmwareUpdateCargo] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + FILE RAW = e99b89f7-c120-4b25-4db1-8394edb0b4f5 { # PcdEdkiiSystemFirmwareFileGuid + FD = BL33_AP_UEFI + } + + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid + FV = CapsuleDispatchFv + } + + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid + Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini + } + +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = 50b94ce5-8b63-4849-8af4-ea479356f0e3 # PcdSystemFmpCapsuleImageTypeIdGuid +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 +MONOTONIC_COUNT = 0x1 +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 + +FV = SystemFirmwareUpdateCargo + +[Capsule.SynQuacerFirmwareUpdateCapsuleFmpPkcs7] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + +FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 ################################################################################ # @@ -354,3 +431,12 @@ [Rule.Common.USER_DEFINED.DTB] FILE FREEFORM = $(NAMED_GUID) { RAW BIN |.dtb } + +[Rule.Common.PEIM.FMP_IMAGE_DESC] + FILE PEIM = $(NAMED_GUID) { + RAW BIN |.acpi + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } diff --git a/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf new file mode 100644 index 000000000000..f5272c0f0d37 --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf @@ -0,0 +1,46 @@ +## @file +# System Firmware descriptor. +# +# Copyright (c) 2016, Intel Corporation. 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 = SystemFirmwareDescriptor + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry + +[Sources] + SystemFirmwareDescriptorTable.aslc + SystemFirmwareDescriptorPei.c + +[Packages] + ArmPkg/ArmPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + SignedCapsulePkg/SignedCapsulePkg.dec + +[LibraryClasses] + DebugLib + PcdLib + PeimEntryPoint + PeiServicesLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdSize + +[Pcd] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor + +[Depex] + TRUE diff --git a/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c new file mode 100644 index 000000000000..f89d9f4842fe --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c @@ -0,0 +1,68 @@ +/** @file + System Firmware descriptor producer. + + Copyright (c) 2016, Intel Corporation. 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 + +/** + Entrypoint for SystemFirmwareDescriptor PEIM. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS PPI successfully installed. +**/ +EFI_STATUS +EFIAPI +SystemFirmwareDescriptorPeimEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; + UINTN Size; + UINTN Index; + UINT32 AuthenticationStatus; + + // + // Search RAW section. + // + Index = 0; + while (TRUE) { + Status = PeiServicesFfsFindSectionData3(EFI_SECTION_RAW, Index, FileHandle, + (VOID **)&Descriptor, &AuthenticationStatus); + if (EFI_ERROR(Status)) { + // Should not happen, must something wrong in FDF. + ASSERT(FALSE); + return EFI_NOT_FOUND; + } + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { + break; + } + Index++; + } + + DEBUG((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", + Descriptor->Length)); + + Size = Descriptor->Length; + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); + + return EFI_SUCCESS; +} diff --git a/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc new file mode 100644 index 000000000000..3413f76f95c7 --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc @@ -0,0 +1,80 @@ +/** @file + System Firmware descriptor. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 + +#define PACKAGE_VERSION 0xFFFFFFFF +#define PACKAGE_VERSION_STRING L"Unknown" + +#define CURRENT_FIRMWARE_VERSION 0x00000001 +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000001" +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 + +#define IMAGE_ID SIGNATURE_64('S', 'N', 'I', 'S', 'Y', 'N', 'Q', 'U') +#define IMAGE_ID_STRING L"Socionext SynQuacer EVB" + +// PcdSystemFmpCapsuleImageTypeIdGuid +#define IMAGE_TYPE_ID_GUID { 0x50b94ce5, 0x8b63, 0x4849, { 0x8a, 0xf4, 0xea, 0x47, 0x93, 0x56, 0xf0, 0xe3 } } + +typedef struct { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; + // real string data + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING)/sizeof(CHAR16)]; + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING)/sizeof(CHAR16)]; + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING)/sizeof(CHAR16)]; +} IMAGE_DESCRIPTOR; + +STATIC IMAGE_DESCRIPTOR mImageDescriptor = +{ + { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, + sizeof(EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), + sizeof(IMAGE_DESCRIPTOR), + PACKAGE_VERSION, // PackageVersion + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName + 1, // ImageIndex; + {0x0}, // Reserved + IMAGE_TYPE_ID_GUID, // ImageTypeId; + IMAGE_ID, // ImageId; + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; + CURRENT_FIRMWARE_VERSION, // Version; + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; + {0x0}, // Reserved2 + FixedPcdGet32(PcdFdSize), // Size; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; + 0x0, // Compatibilities; + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; + 0x00000000, // LastAttemptVersion; + 0, // LastAttemptStatus; + {0x0}, // Reserved3 + 0, // HardwareInstance; + }, + // real string data + {IMAGE_ID_STRING}, + {CURRENT_FIRMWARE_VERSION_STRING}, + {PACKAGE_VERSION_STRING}, +}; + +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; diff --git a/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini new file mode 100644 index 000000000000..f3983da961f1 --- /dev/null +++ b/Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini @@ -0,0 +1,25 @@ +## @file +# +# Copyright (c) 2016, Intel Corporation. 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. +# +## + +[Head] +NumOfUpdate = 1 +NumOfRecovery = 0 +Update0 = SynQuacerFvMain + +[SynQuacerFvMain] +FirmwareType = 0 # SystemFirmware +AddressType = 1 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x08200000 # Base address offset on flash +Length = 0x001C0000 # Length +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image +FileGuid = e99b89f7-c120-4b25-4db1-8394edb0b4f5 # PcdEdkiiSystemFirmwareFileGuid From patchwork Fri Nov 10 14:21:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118555 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259441edl; Fri, 10 Nov 2017 06:23:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMYM96sTOJevr2f8cSsWXt/nZoOriN+P7lsEBvq5v0dav55wec00YgnYq5t82KINW40o1C43 X-Received: by 10.159.216.140 with SMTP id s12mr555603plp.318.1510323815518; Fri, 10 Nov 2017 06:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323815; cv=none; d=google.com; s=arc-20160816; b=Gn1RIGinVHFWrGA4lMSmEdAN/6FoUWFBKi+1tdgX8nuNx7v7GQlzYQcgQp+ilzOe3f s+fUR0hNodab7XguvRy2glU5w18Inogmq8Sx5xuPXLTAwM4CaZ9psDJMkYSMBXhpAVEL JiDMgE2khOKf9aCJx/fZ8TdZAIk64aPdM0uyAUIc/WumVh/e1RiOhXc6m0Z9j7rN6cA5 BarSTwt/advv1wHNxMWYX8Vi84Z/n9BEu0GyFPe6EMgkenhtJDtvqwFjWtuE8loNKtM0 nhsfexwwAES8cZck2YUaAXlFqCM1L/hcdNEZwPYCsMFMJY8b/XYtn4H5yFStJmplkOKG IuiA== 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=IxSthMBTB9dqkYGIlt29hXhnSOsk9JT02z2J3LtOXSA=; b=zsVg7lCPF6x+U1lGJkxNGbckm0LF7NyW+hmDg3AZG5rFzUk1CavB8W12l7S/S4S/57 cxRmk2/L0p3sCXGzGQaSBdl2CdBujsxT0q91yFabRvAd7dhe9mv8TT+S4hDCoBJCiQBj mJm2KmC94HpnN/jHK0U2o4DavRrt7gXaoLnXh/CHoBuoELvCPpk306zBpGZb3qztkV3v fREJe1iAVp62kDWSvrAotfWZ4wCFy7j3+eYeeBHpYAVDPlb6ba/F+Bbh0sV4i/cSHvPr ffEyKGpyEZZLQbZYcCr+pHUYuBkxO7t+dbj7llZURiNtnny5gwTqqtfcJJbXcEdJC/3/ Vz2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XL4pv01Q; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 198si8615123pgd.292.2017.11.10.06.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XL4pv01Q; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 3C71E2035522C; Fri, 10 Nov 2017 06:18:42 -0800 (PST) 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=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::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 9CDD82035521F for ; Fri, 10 Nov 2017 06:18:40 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id y9so8758086wrb.2 for ; Fri, 10 Nov 2017 06:22:43 -0800 (PST) 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=its2kpmC9jMrjP++ef6qSkrsn5mU0zjDLrsOXXhd76s=; b=XL4pv01QhoAWCXvESwNLC2KnGUaPrYWqeCFZ0QBhA6DppcMDzw7Z8HzcKOGuH4YbX4 1F6eyJpqcfpEEmsqv2Dszw5Xkb0lqxsFZb/tO5vGgwkn2ss62g5h5Iw2BFQv9KwHME+C pjYT7gesSFDsjMfdsMvNiei6C9ju53Sgu4/Yk= 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=its2kpmC9jMrjP++ef6qSkrsn5mU0zjDLrsOXXhd76s=; b=nGK/xNsqH3yxnSSuj9Znd50WuN45C7dKYbwuhvo2ziFwsjb0HBQuKFsBg8YGHhUYkA JEKBpuG9DsQqYvJAQGKEOjgnhZ6J3KsFwtUhwFBGlHoaVLwZzt2md/8qEQMzK4UPIOOH SWb1TFRSX/0d+wojeO9bLuMzWao0k5D6jEYqk1gkMuJVBpRL3AGWXIZUifpwygN+ffVv Kutj1l32jlC7h/+QXiwAEjWsg/ZDwpo31eQrqRgHpiwYmtjNJyxcKq7Ezfzm1v6Wif8z krlwuhpIGDLZI26uZcTAxGXReEJSVdS7n4w4X4QN6K9Rov+OupnpTMCRySS4EkRmUzYV Xm3Q== X-Gm-Message-State: AJaThX76N9SmayiQ96I2PiNqcj0drxvLlZkHqk2FNVXQX8Nm+cY2vY0C z4exuMtffM426r/AGqh/0XyTpz3N/8s= X-Received: by 10.223.160.230 with SMTP id n35mr517395wrn.116.1510323762112; Fri, 10 Nov 2017 06:22:42 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:14 +0000 Message-Id: <20171110142127.12018-22-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 21/34] Silicon/SynQuacerPciHostBridgeLib: add workaround to support 32-bit only cards X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement workaround suggested by Socionext to get legacy endpoints with 32-bit BARs working. This fixes the issue on Developer Box with the onboard ASM1061 SATA controller. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c index b5bfea8e0e75..1bbef5b6cf98 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c @@ -32,10 +32,13 @@ #define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_IO 0x2 #define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG0 0x4 #define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG1 0x5 +#define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TH BIT12 #define IATU_REGION_CTRL_2_OFF_OUTBOUND_0 0x908 #define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN BIT31 #define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_CFG_SHIFT_MODE BIT28 +#define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_MSG_CODE_32BIT 0xF +#define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_MSG_CODE_64BIT 0xFF #define IATU_LWR_BASE_ADDR_OFF_OUTBOUND_0 0x90C #define IATU_UPPER_BASE_ADDR_OFF_OUTBOUND_0 0x910 @@ -297,8 +300,9 @@ PciInitController ( RootBridge->Mem.Base, RootBridge->Mem.Base, RootBridge->Mem.Limit - RootBridge->Mem.Base + 1, - IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM, - 0); + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM | + IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TH, + IATU_REGION_CTRL_2_OFF_OUTBOUND_0_MSG_CODE_32BIT); // Region 1: Type 0 config space ConfigureWindow (DbiBase, 1, From patchwork Fri Nov 10 14:21:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118556 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259542edl; Fri, 10 Nov 2017 06:23:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMbHF+Wmx+HFePLV2df7uBmoaV7303nEuqVaeNX0x8IMrELtUf5F3oPDrcbs+vVVENipOhGu X-Received: by 10.99.124.27 with SMTP id x27mr519085pgc.304.1510323820197; Fri, 10 Nov 2017 06:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323820; cv=none; d=google.com; s=arc-20160816; b=esk38TuFY5c/+shn/E8RK1E6TIwxhPN5rAZi77E09KBsGNJObIG1sbLH0BAVICEnJ1 MN0H9e0tpFXB2y2OALOEAC4hVhjsyQNxX5pOG97F+pk0ZycfQzdS/tV7p29VhIYL0IxQ 3jAAUyIu7ZwnAFH68ObR7e+Q1PD7QRrHsTFdBPEy/R0tDdgkFS2hkGZaRutHdmWZiJWb 9hpHJk5OZLtE719jzp9aQpbmygE8tcmGjDLq4RHsep0khqLxt2N0YbDATOYMoH0o1MOs DYQqe+Ppfjr8gG3lIEm05BYY5QcdavwzIicLL4eB77NqDUv01fVr3ZxSRB08z34O7iEf fYAw== 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=aA5kUqMnNJlWbGrhKTNJXKZGtFt/qgEvXjYG2F+ST38=; b=vj11zkGx6TFEPtj6xwMR1nv08dCQV+da2G53QkgL2hG/Wc9FgQm8A3edGAuu/2jDqr FrpQDrOTie3FVhKuUdApWZfOq2ZihZXPSYljrpXkxFMa1F0iUMPjsB47WAM0pvpqHm/b AHdivmkp2qXQKJ8VMYRUowLthHaQ65iIXJ7F3L2K9L3DynuG5byAe0SaQSiRW2z2LIe+ 98ACbTl490fZzFLRZVWmXxR0CXmPq+i5pInvUoDYXTF7LfikUAJ8pNAPVvMjHMAAkcNI HrwuatV7gWf2hUestMdMOd6fgDCParytr7qXhxNe0C9x44jaGKQOi/f/+5VSwbmOhQUD UGtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=C5c2cfDJ; 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 1si8938185plw.224.2017.11.10.06.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:40 -0800 (PST) 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=C5c2cfDJ; 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 763F82035D0E6; Fri, 10 Nov 2017 06:18:46 -0800 (PST) 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=2a00:1450:400c:c09::22c; helo=mail-wm0-x22c.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (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 E58B920359A64 for ; Fri, 10 Nov 2017 06:18:44 -0800 (PST) Received: by mail-wm0-x22c.google.com with SMTP id b9so3062534wmh.5 for ; Fri, 10 Nov 2017 06:22:47 -0800 (PST) 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=WoCzmAHgZOUQcuBgIYlUNLimHkEKwZzA3TxqcOs21Xc=; b=C5c2cfDJrZVNNzX6yOHbk74VE8rrhDQydE8/sKykn0pGuvtrT7ZGTXmFXPVo2R9Qhy PuOSNU5S0eZOVfPzCZzJRXepDmSBW57luBQFnLtjMwh0JmLz65Hq4FxXmlC02z7b6ltr AhieBSkotKM7KtSthljbmlR2V4sj51oUuItgU= 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=WoCzmAHgZOUQcuBgIYlUNLimHkEKwZzA3TxqcOs21Xc=; b=AKn2bzzykQtmdBXVKIdOLbq49oo8l+CFEZKB07HhvfuiJL7nyN0ZT9SQAcitkgN7Il w75yL1ZMcUsFDotCHYUwy+PckXAE9ICnKr94xi5mlVzsCp+XHVno6ic2KFiygB420OKm WhCVyBo6pK4GT0h0c2qO5+abb7U53DuWY39nqLIMwFXLbqhY1DPhxypwThd1ce1nmONV nsSYVatFY4VyYEtKYWhogX9o80F1KagHdoZvO6uCPQkhGEstCourrXmTjWNWR8tNxGGp CWWPHNiAiSjvqcSUlHNHgqbZNGAQwnT57VtE6odE9CMVlmlVLDWpwVfiUobnqq8jQ1hV sKPA== X-Gm-Message-State: AJaThX4NQEkIXhvpdo6LBo+vA50Mo0mMF2IT/9hTpD71jH36SETu0aud BYE6BT4/G9OpwODMbNDToZ9qUejXEmc= X-Received: by 10.28.147.84 with SMTP id v81mr369118wmd.102.1510323765041; Fri, 10 Nov 2017 06:22:45 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:44 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:15 +0000 Message-Id: <20171110142127.12018-23-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 22/34] Platform/Socionext: add support for Socionext Developer Box rev 0.1 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This adds support for the first working sample of the MZSC2AM board, revision 0.1 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 613 ++++++++++++++++++++ Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 455 +++++++++++++++ Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 46 ++ Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 68 +++ Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc | 80 +++ Platform/Socionext/DeveloperBox/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 25 + Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts | 21 + Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf | 33 ++ 8 files changed, 1341 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc new file mode 100644 index 000000000000..676a9e71fa8a --- /dev/null +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -0,0 +1,613 @@ +# +# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2017, 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 Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + PLATFORM_NAME = DeveloperBox + PLATFORM_GUID = d32612b4-e1c5-431f-823a-fa1aa7b9deb7 + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x0001001B + OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME) + SUPPORTED_ARCHITECTURES = AARCH64|ARM + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + FLASH_DEFINITION = Platform/Socionext/DeveloperBox/DeveloperBox.fdf + +[BuildOptions] + RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 + +[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION] + GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 + +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] + GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000 + GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000 + +[LibraryClasses.common] + ArmPlatformLib|Silicon/Socionext/SynQuacer/Library/SynQuacerLib/SynQuacerLib.inf + ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + + TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf + +!if $(TARGET) == RELEASE + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!else + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!endif + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + + BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf + + # Networking Requirements + NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf + DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf + UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf + IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf + + # ARM Architectural Libraries + CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf + DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf + CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf + ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf + ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf + ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf + + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf + PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf + CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf + UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf + UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf + + # BDS Libraries + UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf + PlatformBootManagerLib|ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf + BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf + CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + + PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf + DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf + DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf + SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf + PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf + + HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf + TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf + + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf + + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf + + NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf + +[LibraryClasses.common.SEC] + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf + ArmGicArchLib|ArmPkg/Library/ArmGicArchSecLib/ArmGicArchSecLib.inf + +[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM] + PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf + PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf + ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf + PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf + +[LibraryClasses.common.PEI_CORE] + PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf + +[LibraryClasses.common.PEIM] + PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf + MemoryInitPeiLib|Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf + PlatformPeiLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf + +[LibraryClasses.common.DXE_CORE] + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf + MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf + DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf + ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf + PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf + +[LibraryClasses.common.DXE_DRIVER] + DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf + SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf + PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + + # + # Firmware update + # + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf + PlatformFlashAccessLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf + + # + # PCI + # + PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf + PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf + +[LibraryClasses.common.UEFI_APPLICATION] + PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + + # UiApp dependencies + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + + ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf + ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf + ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + +[LibraryClasses.common.DXE_RUNTIME_DRIVER] + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf + ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + +################################################################################ +# +# Pcd Section - list of all EDK II PCD Entries defined by this Platform +# +################################################################################ + +[PcdsFeatureFlag] + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE + + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE + gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE + + # + # This requires support in ARM Trusted Firmware and SCP for warm reset, + # so disable for now + # + gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE + + # needed for NFIT tables installed by RamDiskDxe + gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE + +[PcdsFixedAtBuild.common] + gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"Linaro" + + # non-secure SRAM + gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x2E000000 + gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0xFFC0 + gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0x2E00FFC0 + + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40 + gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|24 + + gArmPlatformTokenSpaceGuid.PcdCoreCount|2 + gArmPlatformTokenSpaceGuid.PcdClusterCount|12 + gArmTokenSpaceGuid.PcdArmPrimaryCore|0x0 +!if $(ARCH) == AARCH64 + gArmTokenSpaceGuid.PcdVFPEnabled|1 +!endif + + ## PL011 - Serial Terminal + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x2a400000 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0 + gArmPlatformTokenSpaceGuid.PL011UartInteger|0 + gArmPlatformTokenSpaceGuid.PL011UartFractional|0 + gArmPlatformTokenSpaceGuid.PL011UartClkInHz|62500000 + + # + # ARM Generic Interrupt Controller + # + gArmTokenSpaceGuid.PcdGicDistributorBase|0x30000000 + gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x30400000 + + # + # Generic watchdog + # + gArmTokenSpaceGuid.PcdGenericWatchdogControlBase|0x2a440000 + gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase|0x2a450000 + + # + # NETSEC Info + # + gNetsecDxeTokenSpaceGuid.PcdEncTxDescNum|128 + gNetsecDxeTokenSpaceGuid.PcdDecRxDescNum|128 + gNetsecDxeTokenSpaceGuid.PcdJumboPacket|0 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrl|0 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold|36 + gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold|48 + gNetsecDxeTokenSpaceGuid.PcdPauseTime|256 + + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0x08080000 + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|7 + + gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE + + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000 + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF + gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0 + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320 + + # DEBUG_ASSERT_ENABLED 0x01 + # DEBUG_PRINT_ENABLED 0x02 + # DEBUG_CODE_ENABLED 0x04 + # CLEAR_MEMORY_ENABLED 0x08 + # ASSERT_BREAKPOINT_ENABLED 0x10 + # ASSERT_DEADLOOP_ENABLED 0x20 +!if $(TARGET) == RELEASE + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21 +!else + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x3f +!endif + + # DEBUG_INIT 0x00000001 // Initialization + # DEBUG_WARN 0x00000002 // Warnings + # DEBUG_LOAD 0x00000004 // Load events + # DEBUG_FS 0x00000008 // EFI File system + # DEBUG_POOL 0x00000010 // Alloc & Free (pool) + # DEBUG_PAGE 0x00000020 // Alloc & Free (page) + # DEBUG_INFO 0x00000040 // Informational debug messages + # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers + # DEBUG_VARIABLE 0x00000100 // Variable + # DEBUG_BM 0x00000400 // Boot Manager + # DEBUG_BLKIO 0x00001000 // BlkIo Driver + # DEBUG_NET 0x00004000 // SNP Driver + # DEBUG_UNDI 0x00010000 // UNDI Driver + # DEBUG_LOADFILE 0x00020000 // LoadFile + # DEBUG_EVENT 0x00080000 // Event messages + # DEBUG_GCD 0x00100000 // Global Coherency Database changes + # DEBUG_CACHE 0x00200000 // Memory range cachability changes + # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may + # // significantly impact boot performance + # DEBUG_ERROR 0x80000000 // Error + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + + # + # Optional feature to help prevent EFI memory map fragments + # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob + # Values are in EFI Pages (4K). DXE Core will make sure that + # at least this much of each type of memory can be allocated + # from a single memory range. This way you only end up with + # maximum of two fragements for each type in the memory map + # (the memory used, and the free memory that was prereserved + # but not used). + # + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|2000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|1000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|2000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|20000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0 + + gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE + + # use the TTY terminal type + gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4 + + # GUID of the UI app + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } + + # + # Enable strict image permissions for all images. (This applies + # only to images that were built with >= 4 KB section alignment.) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy|0x3 + + # + # Enable NX memory protection for all non-code regions, including OEM and OS + # reserved ones, with the exception of LoaderData regions, of which OS loaders + # (i.e., GRUB) may assume that its contents are executable. + # + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC000000000007FD1 + + # + # Enable the non-executable DXE stack. (This gets set up by DxeIpl) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE + + # + # Variable store + # + gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress|0x54800000 + gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress|0x08000000 + + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x08400000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00010000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x08410000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00010000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x08420000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000 + + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"SNI " + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId|0x52434155514e5953 # SYNQUACR + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId|0x4f524e4c # LNRO + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision|1 + +[PcdsPatchableInModule] + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 + +[PcdsDynamicExDefault.common.DEFAULT] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xf7, 0x89, 0x9b, 0xe9, 0x20, 0xc1, 0x25, 0x4b, 0x4d, 0xb1, 0x83, 0x94, 0xed, 0xb0, 0xb4, 0xf5} + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0xe5, 0x4c, 0xb9, 0x50, 0x63, 0x8b, 0x49, 0x48, 0x8a, 0xf4, 0xea, 0x47, 0x93, 0x56, 0xf0, 0xe3} + +[PcdsDynamicHii] + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|30 + +[PcdsDynamicDefault] + gArmTokenSpaceGuid.PcdSystemMemoryBase|0x0000000000000000 + gArmTokenSpaceGuid.PcdSystemMemorySize|0xFFFFFFFFFFFFFFFF + +################################################################################ +# +# Components Section - list of all EDK II Modules needed by this Platform +# +################################################################################ +[Components.common] + # + # PEI Phase modules + # + ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + MdeModulePkg/Core/Pei/PeiMain.inf + MdeModulePkg/Universal/PCD/Pei/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + ArmPlatformPkg/PlatformPei/PlatformPeim.inf + ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + ArmPkg/Drivers/CpuPei/CpuPei.inf + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { + + NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf + } + + # + # DXE + # + MdeModulePkg/Core/Dxe/DxeMain.inf { + + NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F + } + + # + # Architectural Protocols + # + ArmPkg/Drivers/CpuDxe/CpuDxe.inf + ArmPkg/Drivers/ArmGic/ArmGicDxe.inf + EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf + MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf + EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { + + ## TODO + RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf + } + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf + MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf + ArmPkg/Drivers/TimerDxe/TimerDxe.inf + ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf + MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf + + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf + MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf + MdeModulePkg/Logo/LogoDxe.inf + + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + + # + # Variable services + # + Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf { + + NorFlashPlatformLib|Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf + } + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { + + AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf + TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf + VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf + } + + # + # UEFI application (Shell Embedded Boot Loader) + # + ShellPkg/Application/Shell/Shell.inf { + + ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf + NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf + NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf + NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf + NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf + HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf + ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf + + + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE + } + + # + # Generic BDS + # + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf + MdeModulePkg/Universal/BdsDxe/BdsDxe.inf + MdeModulePkg/Application/UiApp/UiApp.inf { + + NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf + NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf + NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf + } + + # + # PCI + # + Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { +!if $(TARGET) != RELEASE + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F +!endif + } + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf + MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf + MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + # + # AHCI Support + # + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # + # USB + # + MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf + + # + # FAT filesystem + GPT/MBR partitioning + # + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + + # + # RNG + # + Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf + + # + # Platform driver + # + Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf + + # + # Networking stack + # + MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf + MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf + MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf + MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf + MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf + MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf + MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf + MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf + NetworkPkg/Ip6Dxe/Ip6Dxe.inf + NetworkPkg/TcpDxe/TcpDxe.inf + NetworkPkg/Udp6Dxe/Udp6Dxe.inf + NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf + NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf + NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf + NetworkPkg/IScsiDxe/IScsiDxe.inf + NetworkPkg/DnsDxe/DnsDxe.inf + NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf + NetworkPkg/HttpDxe/HttpDxe.inf + NetworkPkg/HttpBootDxe/HttpBootDxe.inf + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf { + + DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf + } + + # + # DT support + # + Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf + + # + # Firmware update + # + Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf new file mode 100644 index 000000000000..83e8a01cfb18 --- /dev/null +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf @@ -0,0 +1,455 @@ +# +# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2017, 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. +# + +################################################################################ +# +# FD Section +# The [FD] Section is made up of the definition statements and a +# description of what goes into the Flash Device Image. Each FD section +# defines one flash "device" image. A flash device image may be one of +# the following: Removable media bootable image (like a boot floppy +# image,) an Option ROM image (that would be "flashed" into an add-in +# card,) a System "Flash" image (that would be burned into a system's +# flash) or an Update ("Capsule") image that will be used to update and +# existing system flash. +# +################################################################################ + +[FD.SPI_NOR_IMAGE] +BaseAddress = 0x08180000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. +Size = 0x00280000|gArmTokenSpaceGuid.PcdFdSize # The size in bytes of the FLASH Device +ErasePolarity = 1 + +# This one is tricky, it must be: BlockSize * NumBlocks = Size +BlockSize = 0x00010000 +NumBlocks = 0x28 + +################################################################################ +# +# Following are lists of FD Region layout which correspond to the locations of different +# images within the flash device. +# +# Regions must be defined in ascending order and may not overlap. +# +# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by +# the pipe "|" character, followed by the size of the region, also in hex with the leading +# "0x" characters. Like: +# Offset|Size +# PcdOffsetCName|PcdSizeCName +# RegionType +# +################################################################################ + +0x00000000|0x00080000 +FILE = Platform/Socionext/DeveloperBox/fip_all_arm_tf.bin + +0x00080000|0x00200000 +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize +FV = FVMAIN_COMPACT + +################################################################################ +# +# FV Section +# +# [FV] section is used to define what components or modules are placed within a flash +# device file. This section also defines order the components and modules are positioned +# within the image. The [FV] section consists of define statements, set statements and +# module statements. +# +################################################################################ + +[FV.FvMain] +FvNameGuid = 89cc2ab6-b847-475f-93e2-819603c3d15a +BlockSize = 0x40 +NumBlocks = 0 # This FV gets compressed so make it just big enough +FvAlignment = 8 # FV alignment and FV attributes setting. +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF MdeModulePkg/Core/Dxe/DxeMain.inf + + # + # PI DXE Drivers producing Architectural Protocols (EFI Services) + # + INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf + INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf + INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf + INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf + INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf + INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf + + INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf + INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf + INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf + INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf + INF MdeModulePkg/Logo/LogoDxe.inf + INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf + + # + # Variable services + # + INF Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + + # + # UEFI applications + # + INF ShellPkg/Application/Shell/Shell.inf + + # + # Generic BDS + # + INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf + INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf + INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf + INF MdeModulePkg/Application/UiApp/UiApp.inf + + # + # PCI + # + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.inf + INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf + INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf + INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf + INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + # + # AHCI Support + # + INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # + # USB + # + INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf + + # + # FAT filesystem + GPT/MBR partitioning + # + INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf + INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + + # + # RNG + # + INF Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf + + # + # Platform driver + # + INF Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf + + # + # Networking stack + # + INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf + INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf + INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf + INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf + INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf + INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf + INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf + INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf + INF NetworkPkg/Ip6Dxe/Ip6Dxe.inf + INF NetworkPkg/TcpDxe/TcpDxe.inf + INF NetworkPkg/Udp6Dxe/Udp6Dxe.inf + INF NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf + INF NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf + INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf + INF NetworkPkg/IScsiDxe/IScsiDxe.inf + INF NetworkPkg/DnsDxe/DnsDxe.inf + INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf + INF NetworkPkg/HttpDxe/HttpDxe.inf + INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf + INF Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf + + # + # DT support + # + INF RuleOverride = DTB Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf + + # + # Firmware update + # + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + FILE FREEFORM = PCD(gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiPkcs7TestPublicKeyFileGuid) { + SECTION RAW = BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer + SECTION UI = "Pkcs7TestRoot" + } + +[FV.FVMAIN_COMPACT] +FvAlignment = 16 +BlockSize = 0x10000 +NumBlocks = 0 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + INF MdeModulePkg/Core/Pei/PeiMain.inf + INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf + INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf + INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + INF ArmPkg/Drivers/CpuPei/CpuPei.inf + INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf + INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + INF MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf + INF RuleOverride = FMP_IMAGE_DESC Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + + FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { + SECTION FV_IMAGE = FVMAIN + } + } + +[FV.CapsuleDispatchFv] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf + +[FV.SystemFirmwareUpdateCargo] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + FILE RAW = e99b89f7-c120-4b25-4db1-8394edb0b4f5 { # PcdEdkiiSystemFirmwareFileGuid + FD = SPI_NOR_IMAGE + } + + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid + FV = CapsuleDispatchFv + } + + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid + Platform/Socionext/DeveloperBox/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini + } + INF RuleOverride = FMP_IMAGE_DESC Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = 50b94ce5-8b63-4849-8af4-ea479356f0e3 # PcdSystemFmpCapsuleImageTypeIdGuid +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 +MONOTONIC_COUNT = 0x1 +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 + + FV = SystemFirmwareUpdateCargo + +[Capsule.SynQuacerFirmwareUpdateCapsuleFmpPkcs7] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 + +################################################################################ +# +# Rules are use with the [FV] section's module INF type to define +# how an FFS file is created for a given INF file. The following Rule are the default +# rules for the different module type. User can add the customized rules to define the +# content of the FFS file. +# +################################################################################ + + +############################################################################ +# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section # +############################################################################ +# +#[Rule.Common.DXE_DRIVER] +# FILE DRIVER = $(NAMED_GUID) { +# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex +# COMPRESS PI_STD { +# GUIDED { +# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi +# UI STRING="$(MODULE_NAME)" Optional +# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) +# } +# } +# } +# +############################################################################ + +[Rule.Common.SEC] + FILE SEC = $(NAMED_GUID) RELOCS_STRIPPED FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.PEI_CORE] + FILE PEI_CORE = $(NAMED_GUID) FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING ="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM] + FILE PEIM = $(NAMED_GUID) FIXED { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM.TIANOCOMPRESSED] + FILE PEIM = $(NAMED_GUID) DEBUG_MYTOOLS_IA32 { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + } + +[Rule.Common.DXE_CORE] + FILE DXE_CORE = $(NAMED_GUID) { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.DXE_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.DXE_RUNTIME_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_APPLICATION] + FILE APPLICATION = $(NAMED_GUID) { + UI STRING ="$(MODULE_NAME)" Optional + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.UEFI_DRIVER.BINARY] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional |.depex + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + +[Rule.Common.UEFI_APPLICATION.BINARY] + FILE APPLICATION = $(NAMED_GUID) { + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + +[Rule.Common.USER_DEFINED.ACPITABLE] + FILE FREEFORM = $(NAMED_GUID) { + RAW ACPI |.acpi + RAW ASL |.aml + } + +[Rule.Common.USER_DEFINED.DTB] + FILE FREEFORM = $(NAMED_GUID) { + RAW BIN |.dtb + } + +[Rule.Common.PEIM.FMP_IMAGE_DESC] + FILE PEIM = $(NAMED_GUID) { + RAW BIN |.acpi + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } diff --git a/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf new file mode 100644 index 000000000000..f5272c0f0d37 --- /dev/null +++ b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf @@ -0,0 +1,46 @@ +## @file +# System Firmware descriptor. +# +# Copyright (c) 2016, Intel Corporation. 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 = SystemFirmwareDescriptor + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry + +[Sources] + SystemFirmwareDescriptorTable.aslc + SystemFirmwareDescriptorPei.c + +[Packages] + ArmPkg/ArmPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + SignedCapsulePkg/SignedCapsulePkg.dec + +[LibraryClasses] + DebugLib + PcdLib + PeimEntryPoint + PeiServicesLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdSize + +[Pcd] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor + +[Depex] + TRUE diff --git a/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c new file mode 100644 index 000000000000..f89d9f4842fe --- /dev/null +++ b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c @@ -0,0 +1,68 @@ +/** @file + System Firmware descriptor producer. + + Copyright (c) 2016, Intel Corporation. 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 + +/** + Entrypoint for SystemFirmwareDescriptor PEIM. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS PPI successfully installed. +**/ +EFI_STATUS +EFIAPI +SystemFirmwareDescriptorPeimEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; + UINTN Size; + UINTN Index; + UINT32 AuthenticationStatus; + + // + // Search RAW section. + // + Index = 0; + while (TRUE) { + Status = PeiServicesFfsFindSectionData3(EFI_SECTION_RAW, Index, FileHandle, + (VOID **)&Descriptor, &AuthenticationStatus); + if (EFI_ERROR(Status)) { + // Should not happen, must something wrong in FDF. + ASSERT(FALSE); + return EFI_NOT_FOUND; + } + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { + break; + } + Index++; + } + + DEBUG((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", + Descriptor->Length)); + + Size = Descriptor->Length; + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); + + return EFI_SUCCESS; +} diff --git a/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc new file mode 100644 index 000000000000..bc47e696da7a --- /dev/null +++ b/Platform/Socionext/DeveloperBox/SystemFirmwareDescriptor/SystemFirmwareDescriptorTable.aslc @@ -0,0 +1,80 @@ +/** @file + System Firmware descriptor. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. 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 + +#define PACKAGE_VERSION 0xFFFFFFFF +#define PACKAGE_VERSION_STRING L"Unknown" + +#define CURRENT_FIRMWARE_VERSION 0x00000001 +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000001" +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 + +#define IMAGE_ID SIGNATURE_64('S', 'N', 'D', 'E', 'V', 'B', 'O', 'X') +#define IMAGE_ID_STRING L"Socionext Developer Box" + +// PcdSystemFmpCapsuleImageTypeIdGuid +#define IMAGE_TYPE_ID_GUID { 0x50b94ce5, 0x8b63, 0x4849, { 0x8a, 0xf4, 0xea, 0x47, 0x93, 0x56, 0xf0, 0xe3 } } + +typedef struct { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; + // real string data + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING)/sizeof(CHAR16)]; + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING)/sizeof(CHAR16)]; + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING)/sizeof(CHAR16)]; +} IMAGE_DESCRIPTOR; + +STATIC IMAGE_DESCRIPTOR mImageDescriptor = +{ + { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, + sizeof(EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), + sizeof(IMAGE_DESCRIPTOR), + PACKAGE_VERSION, // PackageVersion + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName + 1, // ImageIndex; + {0x0}, // Reserved + IMAGE_TYPE_ID_GUID, // ImageTypeId; + IMAGE_ID, // ImageId; + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; + CURRENT_FIRMWARE_VERSION, // Version; + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; + {0x0}, // Reserved2 + FixedPcdGet32(PcdFdSize), // Size; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; + 0x0, // Compatibilities; + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; + 0x00000000, // LastAttemptVersion; + 0, // LastAttemptStatus; + {0x0}, // Reserved3 + 0, // HardwareInstance; + }, + // real string data + IMAGE_ID_STRING, + CURRENT_FIRMWARE_VERSION_STRING, + PACKAGE_VERSION_STRING, +}; + +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; diff --git a/Platform/Socionext/DeveloperBox/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Socionext/DeveloperBox/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini new file mode 100644 index 000000000000..1f77aeab5049 --- /dev/null +++ b/Platform/Socionext/DeveloperBox/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini @@ -0,0 +1,25 @@ +## @file +# +# Copyright (c) 2016, Intel Corporation. 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. +# +## + +[Head] +NumOfUpdate = 1 +NumOfRecovery = 0 +Update0 = SynQuacerFvMain + +[SynQuacerFvMain] +FirmwareType = 0 # SystemFirmware +AddressType = 1 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x08180000 # Base address offset on flash +Length = 0x00240000 # Length +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image +FileGuid = e99b89f7-c120-4b25-4db1-8394edb0b4f5 # PcdEdkiiSystemFirmwareFileGuid diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts new file mode 100644 index 000000000000..9e0acd593311 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts @@ -0,0 +1,21 @@ +/** @file + * Copyright (c) 2017, 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. + */ + +/dts-v1/; + +#include "SynQuacer.dtsi" + +/ { + model = "Socionext Developer Box"; + compatible = "socionext,developer-box", "socionext,synquacer"; +}; diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf new file mode 100644 index 000000000000..a460a6d4eb5d --- /dev/null +++ b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf @@ -0,0 +1,33 @@ +## @file +# +# Device tree description of the Socionext Developer Box platform +# +# Copyright (c) 2017, Linaro Ltd. 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 = 0x00010019 + BASE_NAME = SynQuacerDeviceTree + FILE_GUID = 25462CDA-221F-47DF-AC1D-259CFAA4E326 # gDtPlatformDefaultDtbFileGuid + MODULE_TYPE = USER_DEFINED + VERSION_STRING = 1.0 + +[Sources] + DeveloperBox.dts + +[Packages] + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[FixedPcd] + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress From patchwork Fri Nov 10 14:21:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118557 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259635edl; Fri, 10 Nov 2017 06:23:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMY7cz9AaC/6RTHk6UNULJeV93N6S5z97VSv+zqb1G/FvhM/QyNfJHZS/Z5xpZbqR+0I7wJF X-Received: by 10.84.224.202 with SMTP id k10mr510187pln.403.1510323825641; Fri, 10 Nov 2017 06:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323825; cv=none; d=google.com; s=arc-20160816; b=L89uuEfE74uTTQgE+kusgvmeQ6oLIOli9kW/U2ifnsUp3lX25zdI7dAKPFiEAHglAg 9mERgFyhSwuEuYG0akuRWCjhGr9xjJW7/Q5cR3GS+G0F6O8lcHfnl4dAGiPOFY7QNoph uXdzgZP6ljjZvE6CSdJhqCt3Xsvfv0SKv4JT+782suuTmVLbRNOI5CTtcLygrRxnupOS MRaavpjNR/CdNQz2YqsgHDUL5lHT2IPJ2G2/GYw+lPIBq3SSBK17YzLaH8TeSNXaPNtU /1rVyDY9OYgpolvxTIMki4znBO9kWvyg+x78HCpICjc3mCEgOIfevIYz3ftYI+voOT// /uKg== 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=8Ouqh+TDELXROtfza9pzc0U5AZglRlEYuLW5G+q/ZO8=; b=jplS0YdvaHWmjmFMXPDQq6EWfVg0baD6l5Igot2gSdQwRwemP/DCFpJmfH9jN6Wndp EjSZe7pxXjDX8p58Q0Juxo/NK9HrpcWkCwE/xPJXSf0NrTRA1JVZpekE9VZ9Jfc+JiZx ZZ+fTmPFaYfqarUNHu/u9imUGRigR4pSASddkm8PR2HyqLYDac/mN9WWAdGF3qu7M4UN DLsrt6c+LfzSRKjb69PsguKB2zBpCY00vWZhiDi1kCvyjNTBtLEVEEkeWW3rJefnB7ot ENSC+h2wWoGcigdCo+jnHHIxBOlOgE4tBi5f0EDiyHFTqgYqJQQJFwjgMGY5otKunXGw ywnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HVEPuOSn; 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 a34si8915389pld.559.2017.11.10.06.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:45 -0800 (PST) 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=HVEPuOSn; 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 B0D6C21B00DFF; Fri, 10 Nov 2017 06:18:46 -0800 (PST) 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=2a00:1450:400c:c09::244; helo=mail-wm0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 C8F1B20359A64 for ; Fri, 10 Nov 2017 06:18:45 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id b189so3039523wmd.4 for ; Fri, 10 Nov 2017 06:22:48 -0800 (PST) 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=DVXMj2+tyl2tW/oBih8jTAoQw66D1f1IKdPX4w8f5wk=; b=HVEPuOSngdQQmwv+T4muKSET/OOyMRCsywYTM/sxcWrfrqepOFCSMBO4Ch+KAb8mF9 1ov7kO17uwrbD82Y0jMnPfhVWay4IzM5sXkvQOicMcYV3ewKlMoBv1s1ZfFpwhOlyb3i 15EFXr/K0fPWOibiZR1BhNmzI0g10cxa20SMM= 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=DVXMj2+tyl2tW/oBih8jTAoQw66D1f1IKdPX4w8f5wk=; b=TM5DsKx7wASzd9GnE8iBqno/U7KiANLF+voPx+Y0q5uBSXb9vUIUejNOjIlHNhBmTa C34FgN6rgcbNEQxI9BJkoq+JdRn2NaN8tAmweqnc0TvpMEcKG4MkQUztbHmUaph9Squb 2TnqRfSK0KNxB5pcnbvu89RilRXOBchmlHYS4zWAiUqJnhLABApDSVmt71tXwnFkYINb pMFURcaqEVF6oslzKi1c4y/S7YA/tiHLzQ0vvniSDhZRVLdYQ/sXGQwT9ZjxxZOU3m6d I9Peki1Y/xp5w+xL77GLN5JqsDTFcHhypweeHK4P+JX5JlxHYKeXMc09GKypc2ucv5Se Y8eA== X-Gm-Message-State: AJaThX4eOO07f0nA2DvZk9aBFqZzB0ObEH0o0USzYE6+JWyBZUPToyII q+Xo+frYLZHT2PJElvWua87qyKkZvhQ= X-Received: by 10.28.54.89 with SMTP id d86mr350717wma.101.1510323767311; Fri, 10 Nov 2017 06:22:47 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:46 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:16 +0000 Message-Id: <20171110142127.12018-24-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 23/34] Platform/DeveloperBox: add ConsolePrefDxe driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In order to improve the 'out of the box' experience when booting this system with a monitor and keyboard attached, include the serial console preference driver that prevents the installer GUI to only appear on the serial port in this case. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 8 ++++++++ Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 5 +++++ 2 files changed, 13 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc index 676a9e71fa8a..10d070773cdc 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -600,6 +600,14 @@ [Components.common] } # + # Console preference selection + # + EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf { + + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf + } + + # # DT support # Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf index 83e8a01cfb18..6cc523fac4f3 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf @@ -210,6 +210,11 @@ [FV.FvMain] INF Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.inf # + # Console preference selection + # + INF EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf + + # # DT support # INF RuleOverride = DTB Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.inf From patchwork Fri Nov 10 14:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118558 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259725edl; Fri, 10 Nov 2017 06:23:50 -0800 (PST) X-Google-Smtp-Source: AGs4zMbRrZXFZfayBKCC7xE0BRF7XQA5k2Rhc/xpw2sAdf47mIK/IFlONpu6UqyCpyre87BK4d0J X-Received: by 10.99.123.14 with SMTP id w14mr469487pgc.387.1510323830384; Fri, 10 Nov 2017 06:23:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323830; cv=none; d=google.com; s=arc-20160816; b=j5NAuhcOn5ooDHl2wOSFiETrU/F12dhCB6OVzIE9zWpKzFSV5eGIHUsmRTZDcjwZgB KdaQt3Sw9YFVXwZhO3DzlQVIEw6VejvcZ3Z1WQCMY/MAhtt9dlD6AXUqeLDHxDIvlRMz 5hKh7Q+YZch2FgZeHHS6VBXLMBAUs9/gfS7EIk7UwUuDRKQ/29bWk2mIL5haHBMtCIuM LWktiv2qy4DSHNOc7BqReIlCBtQH77oRDUEJVdMDAcpPsM8/AJeqbanGINqQ835jdrBM +vvOFBEZ0zQHWLUtxXEuzNkFlk5MRpbighsv3ciuYEephrzkHpzX/pC6RlSVcufh+HGf uQyA== 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=iVDv39jFBlLWD7gM7MT57kMnUojTNeMrTFDbYdMtel4=; b=Zq3hA6dZL8XABt+ctai+vUVnRZ0VURI+Xxdl36hFPIXFEa7gwgRO48EVLYQIJR2N8t hrL5Bnn6j0FawnF7n+tGQvFH+8p/7f4kTUU81e4rjNdWoLYcbY2lomOJ5rEcfRO6BiYm 1wMtX66uuHNycYUTMCGk3cjh196PoHzmxwFlaS8u+4NT0ckY5OLtYuWxkRA/JSCZgzml fOY4rAqlL66Ebohw/j/NRTfSQYEHM0J0UBW2kYyhE95PojaP4g0WN6QKEYBbK+V5IUBu 7kjWNitJ+JcOFTRIMojrhw3CffkU+nxrgKEGRu2Eh1g/AbaotKzNn9QZBlFhQxmWb8ht ZlDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kqOc+vm7; 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 r39si8925776pld.493.2017.11.10.06.23.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:50 -0800 (PST) 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=kqOc+vm7; 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 E887B2035D0E3; Fri, 10 Nov 2017 06:18:49 -0800 (PST) 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=2a00:1450:400c:c09::244; helo=mail-wm0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 42B4A2035521F for ; Fri, 10 Nov 2017 06:18:48 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id t139so3095995wmt.1 for ; Fri, 10 Nov 2017 06:22:51 -0800 (PST) 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=2+NrkXNjPu2QqN2RvVtFItDj77TGk3/ZimULNsl7cac=; b=kqOc+vm7XQPj/CX8zHdJiV6i0X5r+Tg4SU26PkgpIvxtny13eoeyqn/OxBc6xkd9nE RsdXOtxRdrK32mrXZXaSK0RWDbX/mHFOnaFRDOQzvaNNxJ4zKDGoJAHjS5ledLCjHVK+ zCYBo2q5KuM63PFoI90NjMK/LRK0pNiqUiXyY= 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=2+NrkXNjPu2QqN2RvVtFItDj77TGk3/ZimULNsl7cac=; b=PtB6J9IimHM8iyzKQ+CRaNyOeAwvOKT7fPS3d76Mu8zFSYSMRitbLGfWyZh8Erwj/x 9BDKoqFiREsDHdmeW2cBDWBVWdOXzdyvbJubwg+IKplONxc/qabSNgnOkabMacvgfFJu HzkXE2fboqL6Q875wmV5EF2XAj6fAwl6Mm0BJovrgfHKwCB8PY3WiH5t8ykqECn8s+59 12JSd9Wdr9e2zasDp9rWuE0Dx6ngwJzjdp3FpQ6NNGD1WCqjG2SLMUL0wY0x1gmX9o66 Sxy6FIE9NL2JginbnsTPoNJORrSkIqMpLYm3WU35PyTo/Hyc3WPXKZ4ED2PRxwo42pmf SdVA== X-Gm-Message-State: AJaThX5JVDGeAJ6XsInc9SSrCUmm71CTzZfK0NCwwZREfyA2L2Egkeqt AxCO6onoTKG6JRnyVuW7JvO0J4+fTF0= X-Received: by 10.28.139.144 with SMTP id n138mr392362wmd.78.1510323769712; Fri, 10 Nov 2017 06:22:49 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:48 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:17 +0000 Message-Id: <20171110142127.12018-25-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 24/34] Silicon/SynQuacer: add description of GPIO block to device tree X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a description of the SoCs GPIO controller as well as a description of DIP switch block #3, which is wired to GPIOs 0 - 7, both on the evaluation board as well as the Developer Box. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- v4: replace pin 'hogs' with descriptive names of all the pins, including PD8 which has been repurposed as the power button on v0.2 of the schematics Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts | 11 +++++++++++ Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 12 ++++++++++++ Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts | 11 +++++++++++ 3 files changed, 34 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts index 9e0acd593311..6ae7d5f300b6 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts +++ b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts @@ -19,3 +19,14 @@ model = "Socionext Developer Box"; compatible = "socionext,developer-box", "socionext,synquacer"; }; + +&gpio { + gpio-line-names = "DSW3-PIN1", "DSW3-PIN2", "DSW3-PIN3", "DSW3-PIN4", + "DSW3-PIN5", "DSW3-PIN6", "DSW3-PIN7", "DSW3-PIN8", + "PSIN#", "PWROFF#", "GPIO-A", "GPIO-B", + "GPIO-C", "GPIO-D", "PCIE1EXTINT", "PCIE0EXTINT", + "PHY2-INT#", "PHY1-INT#", "GPIO-E", "GPIO-F", + "GPIO-G", "GPIO-H", "GPIO-I", "GPIO-J", + "GPIO-K", "GPIO-L", "PEC-PD26", "PEC-PD27", + "PEC-PD28", "PEC-PD29", "PEC-PD30", "PEC-PD31"; +}; diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi index f89e722219ad..966952b9a224 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -21,6 +21,9 @@ #define IRQ_TYPE_LEVEL_HIGH 4 #define IRQ_TYPE_LEVEL_LOW 8 +#define GPIO_ACTIVE_HIGH 0 +#define GPIO_ACTIVE_LOW 1 + / { #address-cells = <2>; #size-cells = <2>; @@ -511,4 +514,13 @@ msi-map = <0x0 &its 0x10000 0x7f00>; dma-coherent; }; + + gpio: gpio@51000000 { + compatible = "socionext,synquacer-gpio", "fujitsu,mb86s70-gpio"; + reg = <0x0 0x51000000 0x0 0x100>; + gpio-controller; + #gpio-cells = <2>; + clocks = <&clk_apb>; + base = <0>; + }; }; diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts index cda72fdf2f99..7de7db182b27 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacerEvalBoard.dts @@ -19,3 +19,14 @@ model = "SynQuacer Evaluation Board"; compatible = "socionext,synquacer-eval-board", "socionext,synquacer"; }; + +&gpio { + gpio-line-names = "DSW3-PIN1", "DSW3-PIN2", "DSW3-PIN3", "DSW3-PIN4", + "DSW3-PIN5", "DSW3-PIN6", "DSW3-PIN7", "DSW3-PIN8", + "PEC-PD8", "PEC-PD9", "PEC-PD10", "PEC-PD11", + "NC", "NC", "PCIE1EXTINT", "PCIE0EXTINT", + "PHY_P2_2", "PHY_P1_2", "NC", "NC", + "NC", "NC", "NC", "NC", + "NC", "NC", "PEC-PD26", "PEC-PD27", + "PEC-PD28", "PEC-PD29", "PEC-PD30", "PEC-PD31"; +}; From patchwork Fri Nov 10 14:21:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118559 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259808edl; Fri, 10 Nov 2017 06:23:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMb0zCw3JyeeoYHGuQGE7zZBVBV9lTfJdXWcvFj9dS5dpjHyzsUZHCE2VEvMc5gLmo0zmRWJ X-Received: by 10.101.82.8 with SMTP id o8mr519203pgp.422.1510323834496; Fri, 10 Nov 2017 06:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323834; cv=none; d=google.com; s=arc-20160816; b=kcMD7HoKqYDdY8wxKG9Jrl0mqJ8vBiZQ+7xOB3urKU49/Kx+oHAvCbo2153Xhl++S7 ORYdCAdDJCcZANEW7XBova4pknqJfRT69rucxhTNlwtEVCUOwwyqwU+jSZC/6CTtMQ0B ayrtch0lZ86rY2u7fgQG67YKmHLbtK5yLhJs2MTQiLo1oLLyc0ROcUVGLqhPLIv05lli cEFm8ISkr36AEYRd5rz9sgBTGRNzBCni6dqlUcb9pBhDiBCijFnJ0pBbrvjyzf5+OJc8 KShQY8ZKV/Y4pZZHWGQf/WCXzCiQN4WNgVAbMH2cgJEcXMGS/vZqIk4W0KruV9X/VTeC wilA== 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=VlVJGCG5rYLrc7qcPxX/mRWoZ7/EXqygO8Npcml/h0U=; b=l2Go4d8AAfDh1ARxxceryuz4fFaTcajDPqTEEYXsC5J1+JPC4RIiQ9MvK5kFGKJ9zg DtkWipCnFrjZNSM1Rp1uSEapJvlhw4LWGz7785sGYHYY5G7RU6m/iqnoOzrLaJo3VObO 7vP25QHUGWrCS76W9sq4n5cLQGTn08QLSLCtbdEu+C5r8OvcuO7gLemGG/uHKHwvJFhl P2/GQPBTP+4/FJRMszBE5+WTQW1vZ+V58u8mCErNTFpuGx1W6hibAqGipfWSmRw0R8sL XxVLwzvuE4otTQR0cmxI1fhfQPMNmhuwAEu/JvpsXVBSdxImFUEI3k8nvpwi9PSo9Zoy yTCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=A8kGKN3q; 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 1si9246863ple.401.2017.11.10.06.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:54 -0800 (PST) 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=A8kGKN3q; 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 2E2242035D109; Fri, 10 Nov 2017 06:18:52 -0800 (PST) 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=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 C81DC2035D109 for ; Fri, 10 Nov 2017 06:18:50 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id b189so3058581wmd.4 for ; Fri, 10 Nov 2017 06:22:53 -0800 (PST) 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=D/lo3+We393RGnUgMK5IzlPp2B1tmvDhuP+Cc93HWwY=; b=A8kGKN3qFVK6riNAZHgiapH05KROsbJWdYrz8WsqY4uEbZkMumCOuZN0DG/3zdCYpZ lAdD/TVq9Wz3TJ9yh+Bs0Pynj13XDVaUA07bGiNxnd804FsY74UJwWYXLUwkSyuzI/H3 iOQzZEsi7hrzlSpcpURQiO4pUzMsV1BnwuR6A= 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=D/lo3+We393RGnUgMK5IzlPp2B1tmvDhuP+Cc93HWwY=; b=O/chZ/dwuWrADi/5VcJlDCJRBtNthEw5Ur+uI2ZwNgy1brOv+5PLMCmbzfkOh1lRIn 1XbOS05luYK7OprO+BoAszhGKuaXGS96oW3ov2KNnXQTK9mVdXooEkf1c3Aag2xL4OvQ /qH4AyIPZt2HU3N105rciO3E8vVLOLLrWXR0gW2pw9AJr4kkPrT3YljYh5gUhgZ/YJuP wsp/gdHqxwXkhQGiWS7H/2JlDSpr7M5A2llPiN6arNaNuF3GVs0aVwK0+LdmGZOON6/3 wrtnJq/ob/xOZOlSpG34u48cQ2ks2LfWwoFC8OW06NIBP18gXkNdfwLlr4eJorRcL6o7 Gb5Q== X-Gm-Message-State: AJaThX5VjgzASCHIcAvSpydls01jxXfKrlx5Uwpuwep07VRfkTABqkcy V6FGFRvEastAiApRB0NN8D4D4SJThcE= X-Received: by 10.28.142.20 with SMTP id q20mr353575wmd.37.1510323772124; Fri, 10 Nov 2017 06:22:52 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:51 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:18 +0000 Message-Id: <20171110142127.12018-26-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 25/34] Silicon/SynQuacer: add description of EXIU to the device tree X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a DT node for the external interrupt unit (EXIU), which handles interrupts from GPIO lines. We need OS support for this for things like PHY interrupts and a 'wake' button. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi index 966952b9a224..e72db377bc39 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -523,4 +523,13 @@ clocks = <&clk_apb>; base = <0>; }; + + exiu: interrupt-controller@510c0000 { + compatible = "socionext,synquacer-exiu"; + reg = <0x0 0x510c0000 0x0 0x20>; + interrupt-controller; + interrupt-parent = <&gic>; + #interrupt-cells = <3>; + socionext,spi-base = <112>; + }; }; From patchwork Fri Nov 10 14:21:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118560 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259883edl; Fri, 10 Nov 2017 06:23:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMZbYhCbI2b5eopH01d/RmcX0rOnfD3OuzK0sQdOULBeY27uXTOhZUbXAX81uVN/dvLmKawp X-Received: by 10.99.189.18 with SMTP id a18mr522009pgf.168.1510323838538; Fri, 10 Nov 2017 06:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323838; cv=none; d=google.com; s=arc-20160816; b=RBf9KXoGIQA/cFopoFn179bCz6oXD2WDeYF2hn/b//VVay6ApuKGWeiBp/jXllm4M8 2AqmDp5Z9Rhf1FY9rLn4eJCUfXCoNdIQXIGGA2Ofvj5ODwljOGlHM4QroOLBVHxkyjA1 44f1wRcNQYjd4pRO9E23mUs7j+ccFmeRAmGpJqSNjQy2XKIVYnM+0TSIFfG5svHijxQD +5E0Aq/DZuKihJ9G9uYkxrtKjw0Z/5s6+FKGVvNZ+3dZt5bzFJff3DmgH6Or3mfbH7Oo D2v6fZwW9jC4Nv82nS0/EwR7r31jS1BYw+AXXstF9jdyEOfpOyCSdp78z79S8BR5IEb+ oEkw== 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=OmvsrIAkIgjqm83/XLSoGUSEti/sUCflZqGj4RbghiY=; b=pWoxSraXb00NCzgAe/PaFYc2L5W6CVkaD7ntUoDu0Cd+929kW6eg0r8lmnr6W/hGLb 4/kb6uyt9pkmQmTGZlalLm6R2RfxBAHNMDlYV2eVFyQ1WSB4cVF+uvFbZ4J9+KvsEvpO T7sI6KZaTTpF4opxzjD13kpmbuC2cOXM5N+3AmXkp4qaZ3x/XhM1YR3YI1+ukAjSK6cC kLYHQtxCei/wGtOiN1D2kZ7FFgYHufXzgLiMCpGDdM4Ic1c3gqLqoEYdGbzkYQdUlNQV Jug0WlvVJ+Kgqw0DLcwSumRhE95Y4Nn4edoNE4I/JbTWs92hHk/x6Hxir+xowkGoSyMU NLzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ji0p192s; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 129si8529437pgi.726.2017.11.10.06.23.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ji0p192s; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 669722035522E; Fri, 10 Nov 2017 06:18:55 -0800 (PST) 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=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 37E622035521F for ; Fri, 10 Nov 2017 06:18:53 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id r68so6058157wmr.0 for ; Fri, 10 Nov 2017 06:22:56 -0800 (PST) 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=2j6jrZsJ+Me82rmvZCrCaGtWmj08YhcSV+W4KHRzXUs=; b=ji0p192sp+o+ybBrXFzV8mdZmEGCZA20tuHuuwT6EA8V3hc6jY8HrLrwt84SDZgRba vndip7Dece9x3DxA8jeUU7TUmS9mGScgjphXV3/eIISKhgUV7xzgPfZ8RA2mxU3hr4D9 xVTr5rcbAzFJvZYL+lWR2GS9HFHD32dH0CBiY= 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=2j6jrZsJ+Me82rmvZCrCaGtWmj08YhcSV+W4KHRzXUs=; b=YOFZ3Eilap2afoIXkjxeH/ieBqmN5udyIhcohq5p7bHV1NxyNL1tQD2eOAZY0Y3VQr SjrHs++FULhjdBTI9eSw0pJD8iJlc4WfpkneB9EsvdmjJbgE0d1zoRpAlwEAkNatThcD frNnl10GtQ/IuN3UrRb7LpHO9mDsPWj7o9KDYrXBAXF/iRqXt+ovsaV5wQWBoygasPaL hqchv0J5ydP4ZbrLbg8rBYvITJ/sTkRnxtTtJEP9CN5SVRrkRd3v+VhhKjiJfzoRW8en 9DAEUFoY5zfkpwE7maGGKS5C3pNUZ75uAU8D39hXpioIq3trLjiUOPcyPW4bSYZvbT/s MUYA== X-Gm-Message-State: AJaThX6S1Ho5Z4lbnby6IRyjkwjorIPmMUJPkRG7Zg0IqsUPt/Jpk3hr fvvgXYQGJ+DVoOt4Vq+UxEUfnC53Ne8= X-Received: by 10.28.60.68 with SMTP id j65mr368848wma.16.1510323774674; Fri, 10 Nov 2017 06:22:54 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:53 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:19 +0000 Message-Id: <20171110142127.12018-27-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 26/34] Silicon/SynQuacer: add DT description of the SDHCI controller X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Describe the SynQuacer SoC's eMMC controller in DT so the OS can attach to it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi index e72db377bc39..cf06acc75297 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -532,4 +532,30 @@ #interrupt-cells = <3>; socionext,spi-base = <112>; }; + + clk_alw_b_0: bclk200 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <200000000>; + clock-output-names = "sd_bclk"; + }; + + clk_alw_c_0: sd4clk800 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <800000000>; + clock-output-names = "sd_sd4clk"; + }; + + sdhci@52300000 { + compatible = "socionext,synquacer-sdhci", "fujitsu,mb86s70-sdhci-3.0"; + reg = <0 0x52300000 0x0 0x1000>; + interrupts = , + ; + bus-width = <8>; + cap-mmc-highspeed; + fujitsu,cmd-dat-delay-select; + clocks = <&clk_alw_c_0 &clk_alw_b_0>; + clock-names = "core", "iface"; + }; }; From patchwork Fri Nov 10 14:21:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118561 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2259968edl; Fri, 10 Nov 2017 06:24:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMZbbjcME45bbUQxFCAMcAEJfCZyguqSGRW+S6s1M6hsNClYo+xv4upuCW49ojRTOIqCVNjv X-Received: by 10.99.111.67 with SMTP id k64mr518348pgc.234.1510323843049; Fri, 10 Nov 2017 06:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323843; cv=none; d=google.com; s=arc-20160816; b=EjfeXDOyJ9oM9PjuCkJ4u7HP70J8sQucPYzsqn7XAmwenZbYvrqfWfoz4p8+DjWpZ7 G/tPuDcpMcDF1xcgTM9eLd6TIZeHKi8AUChXiyLUCJ+0WvgoWeiT3IGymB7/Gjg+d27u Pk5uP4046PL7zboBkekMWJhxpxwgLo3+ohhIAoTsXzZzlkjFiA3VOFiyv8JpqC/xzT7O oAZB907OHRyBydB7NrwJOpTZ7B2mK7ANZUlV4eFiS+b45ZgVQEvh+LgPlti1MaU/4EBe mSp7d4tcO2TzYFlcirMt9htsislLFs6j9crRwTW4MwZz7z+UswVGByAxa22YEngeV6sV zYRA== 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=neQWtWlZj1ZvAzV3AC7Q5TzAbUnv7cTi+IwTTSfhW2k=; b=rv5beBTY/FReaDRwFcWesKGT2H2d4DtGVf9W0bCS5ya4iyMIIKYZJaAny8o8hDjZz3 CjCyk+ZPdq8QwArnbT19WDc/5ghWDfzOjGZ1Di89hHmcic7WTm83H4ps9wmOSyuX4zgm 64Y1ZeUXGPrrpufgEcNa2lAgMBXvQ5mo1tJFfhK+gwaCO2nvAaLxCXnPhnEzB1bWNbh3 rro/SyyJ5rdm683MbY35jQaL+xAhNvGQekJJ2JwNZQqQAwDwDUef5Y8e4SYztotyr3we hWOg3kdCsnOfdf0WHEZX4ZtaDqwrNSnl6N9APfHues0YLpuatpP9AYABHlkGyrD9HPPS FLSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=J360xsYi; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id s188si8536832pgb.646.2017.11.10.06.24.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=J360xsYi; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 9D2C72035D11E; Fri, 10 Nov 2017 06:18:56 -0800 (PST) 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=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (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 C262A2035521F for ; Fri, 10 Nov 2017 06:18:55 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id u40so8734492wrf.10 for ; Fri, 10 Nov 2017 06:22:58 -0800 (PST) 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=hXUK7Wt8oFn9cCETSDa4FUJWSJBLAiRuW2w82ob6f0U=; b=J360xsYi2Fd2eBGOBqPfaSSS2/IKBxDAAj5EIOVZEZi2Q0HGXR1GcBC+H1Wj68otQB 66ZPs6nsjqycCyCvTYy9109t9oDa1xI7zBcyI7maWM2E/20iCNJy+4S/AfwDxMoMaqbS acy2QyIBVbcKf7FO0Gq/EcdWnxNGuFaDIoLZk= 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=hXUK7Wt8oFn9cCETSDa4FUJWSJBLAiRuW2w82ob6f0U=; b=Pz5w5A5Cny4LgyTN4lK5ge8IBVFperbzcqDejhaSeI7sZXfOM6D3J0wfChMouY0bYm h3HLFiO1f0rlcVb9hvZrmKB8h674ecVkHC4a+twBRJSlKduA9/O8V23QwszHOA7ypV9N wUfCdGH72NJ1ww/f3VMBacJK3r+yWdAfKN0twveYAO9C/yl0WSH9poNlOGQjLiy6tgNf W4wflG+gcfIX7zln8Iyx498PWV5wjEC1pze0Avl0N1vWuR7kECWVkpZ2LwjVMSn0OpTi QFjp7SFWuZZfijQ7xk6CK2StNZBVolWtvasm6YXC3x2IG242/quvduQDJ6eEAM8LwPeP RT4A== X-Gm-Message-State: AJaThX6r07bwfEMXupyouRKHn8RbNF+0bhk+/fRC02Oju2Ty3OJ+ZGQO OYdO2eF4k1Ix7sTGLzF0GYnHaT5jjZA= X-Received: by 10.223.182.73 with SMTP id i9mr484010wre.113.1510323777118; Fri, 10 Nov 2017 06:22:57 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:56 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:20 +0000 Message-Id: <20171110142127.12018-28-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 27/34] Silicon/SynQuacerMemoryInitPeiLib: ignore capsules when clearing NVRAM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In preparation of adding support for setting a DIP switch to clear the EFI variable store, update the early capsule handling logic to take the boot mode into account. This is necessary for two reasons: - we override the boot mode when a capsule is detected, - the capsule detection itself involves reading a EFI variable, which we shouldn't be doing if the varstore may be in a bad state. So factor out the initial capsule check (to keep the code understandable) and only perform it if we are not booting in 'clear NVRAM' mode. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 68 +++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) -- 2.11.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/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index b44c58d61062..63c441872da7 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -170,6 +170,44 @@ DeclareDram ( return EFI_SUCCESS; } +STATIC +BOOLEAN +CheckCapsule ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CAPSULE_PPI *Capsule, + IN EFI_PHYSICAL_ADDRESS UefiMemoryBase, + OUT VOID **CapsuleBuffer, + OUT UINTN *CapsuleBufferLength + ) +{ + EFI_STATUS Status; + + Status = Capsule->CheckCapsuleUpdate (PeiServices); + if (!EFI_ERROR (Status)) { + + // + // Coalesce the capsule into unused memory. CreateState() below will copy + // it to a properly allocated buffer. + // + *CapsuleBuffer = (VOID *)PcdGet64 (PcdSystemMemoryBase); + *CapsuleBufferLength = UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase); + + PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); + + Status = Capsule->Coalesce (PeiServices, CapsuleBuffer, + CapsuleBufferLength); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", + __FUNCTION__, *CapsuleBuffer, *CapsuleBufferLength)); + return TRUE; + } else { + DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status == %r)\n", + __FUNCTION__, Status)); + } + } + return FALSE; +} + EFI_STATUS EFIAPI MemoryPeim ( @@ -184,6 +222,7 @@ MemoryPeim ( VOID *CapsuleBuffer; UINTN CapsuleBufferLength; BOOLEAN HaveCapsule; + EFI_BOOT_MODE BootMode; Status = DeclareDram (&VirtualMemoryTable); ASSERT_EFI_ERROR (Status); @@ -199,31 +238,14 @@ MemoryPeim ( ASSERT_EFI_ERROR (Status); // - // Check for persistent capsules + // Check for persistent capsules, unless we are booting with default + // settings. // HaveCapsule = FALSE; - Status = Capsule->CheckCapsuleUpdate (PeiServices); - if (!EFI_ERROR (Status)) { - - // - // Coalesce the capsule into unused memory. CreateState() below will copy - // it to a properly allocated buffer. - // - CapsuleBuffer = (VOID *)PcdGet64 (PcdSystemMemoryBase); - CapsuleBufferLength = UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase); - - PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); - - Status = Capsule->Coalesce (PeiServices, &CapsuleBuffer, - &CapsuleBufferLength); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", - __FUNCTION__, CapsuleBuffer, CapsuleBufferLength)); - HaveCapsule = TRUE; - } else { - DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status == %r)\n", - __FUNCTION__, Status)); - } + Status = PeiServicesGetBootMode (&BootMode); + if (!EFI_ERROR (Status) && BootMode != BOOT_WITH_DEFAULT_SETTINGS) { + HaveCapsule = CheckCapsule (PeiServices, Capsule, UefiMemoryBase, + &CapsuleBuffer, &CapsuleBufferLength); } Status = ArmConfigureMmu (VirtualMemoryTable, NULL, NULL); From patchwork Fri Nov 10 14:21:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118562 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260035edl; Fri, 10 Nov 2017 06:24:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMbcqHdP6nnmIkhEh5GIShQxRIbrg2/ND1bMeWMVGSwGZa0sa5YCbZV97mnOEuzTdKxQVNN5 X-Received: by 10.84.171.132 with SMTP id l4mr541125plb.396.1510323847357; Fri, 10 Nov 2017 06:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323847; cv=none; d=google.com; s=arc-20160816; b=dVCY3MsFAEmPLyU5VZyo4cOtSinmhj0PxMpWVmNCFplPP0WKcs2KEAVv8qpYtvyoeC tMhmVB6hctpYYDY814J4CAJhImeWVi/QhbXpV6QiYPuN+Ozj7eSMbIJR8wHzh865WTHx jFv4dOvxC9uLq6w+uVreJZVLmJvDDkMoKQQ/k4kcWFXmenR9AAQ1eLdstY/9bawidFou 9idG3XGhyxNEhf3zkBW4y3NCFC6cnOG2S+2ED5eMp1cBUZVZEb+mpu83/TAnTNSC31UN KaV9aJ8MCxud4jW+Bsup07dZ1+HyEdcj9WXTnm7tWrFDPKIKDu+AIkF7WJ1I0DwH9F1W iXwA== 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=BZb4bSx4DEp47ZEJ7WF/zm3L8VJ8DWHhKijugfscm6o=; b=07+cK2ahcPumdvT055SBtFRQ9i9ZfA5dmIbeDCwDEv6ES4DWZDk3JSdr3/q9j9DjXw Lxt4YpqZYxYp44J/y1HRVo5mMaIaNgS/zdAeciD2vsYslJ+ouCqMpbedceAlmSC9QzDh YCH08yR74VbPArUvJhpQkrS95RSHd9dWbbaoCf0skdT+e+96UD9VDmnwCdNWsGOxriUF SRdfZ5yM2fUaT+uob1rrghPkRQTCL0CnMTwKNYuXjTTOvnIXtfrCWJ41zVegDIny51HW feCt30V0E0/itNYJSITibwLNPCiXvYVazoSvK8a3LWUpq7E3zSup50TKlyvUaOvBGzjM Z4Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ONK8ReIf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id a14si5221247pgv.479.2017.11.10.06.24.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ONK8ReIf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 D767E203555E3; Fri, 10 Nov 2017 06:18:58 -0800 (PST) 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=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::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 C686C2035522D for ; Fri, 10 Nov 2017 06:18:57 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id 15so8748167wrb.5 for ; Fri, 10 Nov 2017 06:23:00 -0800 (PST) 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=KTsafCwkTqW3gueFe7vbZCrWCLlwBtcQ1VmtcCg0mI4=; b=ONK8ReIf/Zvss27wQc0US+BgVoBYiXE1Dx9DFX3Od6B8ymot0u+MG0jV+q47y9esFJ BI8u+vhSwBBZLCcZdiK11Bu5WlT5E7ALjXA28bR8Pa51PBzoHkbTsaLvG6YF/DEhqxJf ika1OaZCEWlDzV2XTp5ZMWFMH/q+OlLu93r8M= 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=KTsafCwkTqW3gueFe7vbZCrWCLlwBtcQ1VmtcCg0mI4=; b=DZJWpeXHAkJ0aPeHJkrG4ml8MwJexbYEN/VO4m+w+uFkLgRO/BBGnRDAnIQF2H5diL RScLj9DxqG77RTpQ6fjGn8FOO8FFUd9HY54g3u2hjJgVo0V/vGnWwnBdgaHFPKJ8leCV sfcGpbM3eNwrBmhFPxMrLFiPB3yppVLf1miVqSAhz6yhnAz/rroe0fIN6Jssi30FaiCv ujf0C1fBTFjQ91wSiqP61bzp62Jm+q1vLsHQNZJbkrpprLLGf7SRdv/RH2Ng5RAkhUCv zsBWUovlPQIcy6BcYuBgRuQO0XqppRCObUH5EA2oAyCOkj9HLmWZOTzMZVBmeg7qdMng IsQw== X-Gm-Message-State: AJaThX45C7DPItde+pPNFyqZSOuR1lNvBk4pFWIKGzZmJhscsrfPYk4D /E1bOAYIPMS17Bw8MvWe3cQqT0Ed06k= X-Received: by 10.223.156.138 with SMTP id d10mr477708wre.214.1510323779157; Fri, 10 Nov 2017 06:22:59 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:58 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:21 +0000 Message-Id: <20171110142127.12018-29-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 28/34] Silicon/SynQuacer: implement PEIM that exposes GPIO PPI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In order to be able to sample the state of the DIP switches at early boot on the Developer Box platform, implement the GPIO PPI based on the GPIO block that is implemented in the SynQuacer SoC. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.c | 203 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf | 47 +++++ 2 files changed, 250 insertions(+) -- 2.11.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/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.c new file mode 100644 index 000000000000..24d08b4e5899 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.c @@ -0,0 +1,203 @@ +/** @file + + Copyright (c) 2017, Linaro, Ltd. 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 + +#define PDR(x) (SYNQUACER_GPIO_BASE + 4 * (GPIO_PIN (x) >> 3)) +#define DDR(x) (SYNQUACER_GPIO_BASE + 0x10 + 4 * (GPIO_PIN (x) >> 3)) +#define PFR(x) (SYNQUACER_GPIO_BASE + 0x20 + 4 * (GPIO_PIN (x) >> 3)) + +#define GPIO_BIT(x) (1U << (GPIO_PIN (x) % 8)) + +STATIC CONST UINTN mGpioPinCount = 32; + +/** + + Gets the state of a GPIO pin + + @param This Pointer to protocol + @param Gpio Which pin to read + @param Value State of the pin + + @retval EFI_SUCCESS GPIO state returned in Value + @retval EFI_INVALID_PARAMETER Value is NULL + @retval EFI_NOT_FOUND Pin does not exit + +**/ +STATIC +EFI_STATUS +EFIAPI +GpioGet ( + IN EMBEDDED_GPIO_PPI *This, + IN EMBEDDED_GPIO_PIN Gpio, + OUT UINTN *Value + ) +{ + if (Value == NULL) { + return EFI_INVALID_PARAMETER; + } + if (GPIO_PORT (Gpio) > 0 || GPIO_PIN (Gpio) >= mGpioPinCount) { + return EFI_NOT_FOUND; + } + + *Value = ((MmioRead32 (PDR (GPIO_PIN (Gpio))) & GPIO_BIT (Gpio)) != 0); + + return EFI_SUCCESS; +} + +/** + + Sets the state of a GPIO pin + + @param This Pointer to protocol + @param Gpio Which pin to modify + @param Mode Mode to set + + @retval EFI_SUCCESS GPIO set as requested + @retval EFI_INVALID_PARAMETER Invalid mode + @retval EFI_NOT_FOUND Pin does not exit + +**/ +STATIC +EFI_STATUS +EFIAPI +GpioSet ( + IN EMBEDDED_GPIO_PPI *This, + IN EMBEDDED_GPIO_PIN Gpio, + IN EMBEDDED_GPIO_MODE Mode + ) +{ + if (GPIO_PORT (Gpio) > 0 || GPIO_PIN (Gpio) >= mGpioPinCount) { + return EFI_NOT_FOUND; + } + + switch (Mode) { + case GPIO_MODE_INPUT: + MmioAnd32 (DDR (GPIO_PIN (Gpio)), ~GPIO_BIT (Gpio)); + break; + + case GPIO_MODE_OUTPUT_0: + MmioOr32 (DDR (GPIO_PIN (Gpio)), GPIO_BIT (Gpio)); + MmioAnd32 (PDR (GPIO_PIN (Gpio)), ~GPIO_BIT (Gpio)); + break; + + case GPIO_MODE_OUTPUT_1: + MmioOr32 (DDR (GPIO_PIN (Gpio)), GPIO_BIT (Gpio)); + MmioOr32 (PDR (GPIO_PIN (Gpio)), GPIO_BIT (Gpio)); + break; + + default: + return EFI_INVALID_PARAMETER; + } + return EFI_SUCCESS; +} + + +/** + + Gets the mode (function) of a GPIO pin + + @param This Pointer to protocol + @param Gpio Which pin + @param Mode Pointer to output mode value + + @retval EFI_SUCCESS Mode value retrieved + @retval EFI_INVALID_PARAMETER Mode is NULL + @retval EFI_NOT_FOUND Pin does not exit + +**/ +STATIC +EFI_STATUS +EFIAPI +GpioGetMode ( + IN EMBEDDED_GPIO_PPI *This, + IN EMBEDDED_GPIO_PIN Gpio, + OUT EMBEDDED_GPIO_MODE *Mode + ) +{ + if (Mode == NULL) { + return EFI_INVALID_PARAMETER; + } + if (GPIO_PORT (Gpio) > 0 || GPIO_PIN (Gpio) >= mGpioPinCount) { + return EFI_NOT_FOUND; + } + + if (!(MmioRead32 (DDR (GPIO_PIN (Gpio))) & GPIO_BIT (Gpio))) { + *Mode = GPIO_MODE_INPUT; + } else if (!(MmioRead32 (PDR (GPIO_PIN (Gpio))) & GPIO_BIT (Gpio))) { + *Mode = GPIO_MODE_OUTPUT_0; + } else { + *Mode = GPIO_MODE_OUTPUT_1; + } + return EFI_SUCCESS; +} + + +/** + + Sets the pull-up / pull-down resistor of a GPIO pin + + @param This Pointer to PPI + @param Gpio Port/pin index + @param Pull The pullup/pulldown mode to set + + @retval EFI_SUCCESS Mode was set + @retval EFI_NOT_FOUND Pin does not exist + @retval EFI_UNSUPPORTED Action not supported + +**/ +STATIC +EFI_STATUS +EFIAPI +GpioSetPull ( + IN EMBEDDED_GPIO_PPI *This, + IN EMBEDDED_GPIO_PIN Gpio, + IN EMBEDDED_GPIO_PULL Pull + ) +{ + if (Pull != GPIO_PULL_NONE) { + return EFI_UNSUPPORTED; + } + if (GPIO_PORT (Gpio) > 0 || GPIO_PIN (Gpio) >= mGpioPinCount) { + return EFI_NOT_FOUND; + } + return EFI_SUCCESS; +} + +STATIC EMBEDDED_GPIO_PPI mGpioPpi = { + GpioGet, + GpioSet, + GpioGetMode, + GpioSetPull, +}; + +STATIC CONST EFI_PEI_PPI_DESCRIPTOR mEmbeddedGpioPpiDescriptor = { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEdkiiEmbeddedGpioPpiGuid, + &mGpioPpi +}; + +EFI_STATUS +EFIAPI +SynQuacerGpioPeiEntryPoint ( + IN EFI_PEI_FILE_HANDLE FfsHeader, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + return PeiServicesInstallPpi (&mEmbeddedGpioPpiDescriptor); +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf new file mode 100644 index 000000000000..dbb5e9d4c53a --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf @@ -0,0 +1,47 @@ +#/* @file +# +# Copyright (c) 2017, Linaro, Ltd. 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 = SynQuacerGpioPei + FILE_GUID = 55a981a5-f371-4ba3-93a5-37fa0ca95089 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = SynQuacerGpioPeiEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = AARCH64 +# +# + +[Sources] + SynQuacerGpioPei.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + IoLib + PeimEntryPoint + PeiServicesLib + +[Ppis] + gEdkiiEmbeddedGpioPpiGuid ## PRODUCES + +[Depex] + TRUE From patchwork Fri Nov 10 14:21:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118563 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260114edl; Fri, 10 Nov 2017 06:24:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMYiEkEkU+WZ5GFG7rS4rJbpukx4n6ClYIFBsWmesFUM+NqjgbqEwxkhEEJejWfs2xXFpiRB X-Received: by 10.159.206.132 with SMTP id bg4mr538283plb.129.1510323851956; Fri, 10 Nov 2017 06:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323851; cv=none; d=google.com; s=arc-20160816; b=Lsfez6F0xXUYXByVJc93K00D6AwVN1HcGa/79AGzWYBluxDvxoylxrOS2DRmpKH8xq ch3bXs/DW4wTVciCTfPj5Uw2dBsEGjzzE1tQwTa0oXwZSX3nZeTaXDp019OwBoSsMv+U NQYgZNUh6SiF5LYdmfr6VQtjaljyr9vNllP7ddAzvtkbpdop51Kdka/TsbO23MgrX9nH Roci3MrlG2FZC1D6KJzxyNpGQu3wgqPau4n2imu5PNPPb/v2hz1PoJf5zIAs8lP4ubLa BLSrX9BPNukCEUhzvq/NWTRl4HOGeXowIK6qh8mqdtFBSR1WfzrqrO9JGToHhy7NdLSL qu1A== 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=nvkfGOP9vcvt1fLxDr6loa/RZTxXLs2llIxN55aL3SM=; b=I8UZnzs5e9urKuhqxwkJUmy/ADEKyhGh1hnDAUyVuzs7XRzlQCdh3WjGxY75Iz2wIE PV7b7/o+9wVhjXGwYfZDo1hzQAIpiI7VfR6C5ZIjMReXp+LC0HMPGSlZp3Ggcd2tp/Kj iOGMERdtXWHkuJgTWY1JA5jzwOlHSeRVJT5QBEzK7h38QkwncmR/z65ZlX8TVUR/bmIE FPlt/W9Anv8OGlu5UpdgbhbF6ChIs/XO7luAlGCcf1uOcRexkuszxH0fZ6LYOQS3uf+7 8g0ZX9TGOdql9Tgn8Q3SIDcrHa3Ruxb1L3CcgkR2onuUVxUS1eNzS/GBQheljHlyzk9B ixSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AZmys0Za; 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 x11si9020437pln.594.2017.11.10.06.24.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:11 -0800 (PST) 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=AZmys0Za; 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 1BC0E21B00DCD; Fri, 10 Nov 2017 06:19:02 -0800 (PST) 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=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (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 57C392035521F for ; Fri, 10 Nov 2017 06:19:00 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id o88so8730722wrb.6 for ; Fri, 10 Nov 2017 06:23:03 -0800 (PST) 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=utU/oYwGPR8ChvpyfEuVaX8F0NduZ0m3rHgPWM0QRMo=; b=AZmys0ZappghXYI9QyKzApGWJSGRJ9t7QaNpwH55cFH19l7aZ57JEMxcnXNhddZuvM 3+m6i+0+Kc92PgRlNxG6XZMJmNv/R08/M1ouE9e04eqqnDmNvNpFS2UPaaYk+EIK3BZJ BbJK6EunSnT+QfkHVJKGec//Ape3D0hJhAFbA= 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=utU/oYwGPR8ChvpyfEuVaX8F0NduZ0m3rHgPWM0QRMo=; b=eyzQl3jan5UswQdYFL2skrI32vjZlgWZvhAyjL2Wn0k50C21DC+mHK1PzRKmZU9RxV nrAQEa/viYbe9yUjvOydkGQPXfcAFs9FwuzOmmQ1/deY9KYR6tEFTP7T0HtDf4mayBLf htttk+cTXnKUFtlEtkwT4OPd0fon+yZ+/vgqWipqMnJNHfuSIPbWCZECfj5y4Nm0moAc +/k8VowM3cqpWXoyNE0JZPRpBSu3T1BWF6vBtQwUj3QLuyqpElqv2F6zAYCutJF2RQPk 0JhbWhKLTedZKIUMMOmVGOiTnHkOQnJy/xjZHCjFq+vPNlzrTAYXYVEiF3Sxq7BBFomm VyZQ== X-Gm-Message-State: AJaThX5e02r6fIVOdpBIaVdnwCqY8/eGB9inMxmUGsOhfmWxJuQsdNkK g+93+QA3jBrymnJCeKlsufKf/EPZNyE= X-Received: by 10.223.188.147 with SMTP id g19mr503851wrh.250.1510323781768; Fri, 10 Nov 2017 06:23:01 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:00 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:22 +0000 Message-Id: <20171110142127.12018-30-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 29/34] Silicon/SynQuacer: implement 'clear NVRAM' feature using a DIP switch X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Ordinary computers typically have a physical switch or jumper on the board that allows non-volatile settings to be cleared. Let's implement the same using DIP switch #1 on block #3, and clear the EFI variable store if it is set to ON at boot time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 4 ++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 4 ++++ Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 1 + Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c | 25 +++++++++++++++++++- Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf | 6 +++++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 2 ++ 6 files changed, 41 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc index 10d070773cdc..af978db2c034 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -381,6 +381,9 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId|0x4f524e4c # LNRO gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision|1 + # set DIP switch DSW3-PIN1 to clear the varstore + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0 + [PcdsPatchableInModule] gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 @@ -418,6 +421,7 @@ [Components.common] MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf MdeModulePkg/Universal/Variable/Pei/VariablePei.inf MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 4630d78bce93..4034bcfe82c5 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -369,6 +369,9 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x08420000 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000 + # set DIP switch DSW3-PIN1 to clear the varstore + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0 + [PcdsPatchableInModule] gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 @@ -406,6 +409,7 @@ [Components.common] MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf MdeModulePkg/Universal/Variable/Pei/VariablePei.inf MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index 365085c8f243..4577bd316a1f 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -248,6 +248,7 @@ [FV.FVMAIN_COMPACT] INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf INF MdeModulePkg/Universal/CapsulePei/CapsulePei.inf + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf INF RuleOverride = FMP_IMAGE_DESC Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c index 358dd5a91f08..bd8ee7a368f5 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c @@ -21,6 +21,7 @@ #include #include #include +#include #include STATIC @@ -103,10 +104,32 @@ PlatformPeim ( VOID ) { - EFI_STATUS Status; + EMBEDDED_GPIO_PPI *Gpio; + EFI_STATUS Status; + UINTN Value; ASSERT (mDramInfo->NumRegions > 0); + Status = PeiServicesLocatePpi (&gEdkiiEmbeddedGpioPpiGuid, 0, NULL, + (VOID **)&Gpio); + ASSERT_EFI_ERROR (Status); + + Status = Gpio->Set (Gpio, FixedPcdGet32 (PcdClearSettingsGpioPin), + GPIO_MODE_INPUT); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to set GPIO as input - %r\n", __FUNCTION__, + Status)); + } else { + Status = Gpio->Get (Gpio, FixedPcdGet32 (PcdClearSettingsGpioPin), &Value); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to get GPIO state - %r\n", __FUNCTION__, + Status)); + } else if (Value > 0) { + DEBUG ((DEBUG_INFO, "%a: clearing NVRAM\n", __FUNCTION__)); + PeiServicesSetBootMode (BOOT_WITH_DEFAULT_SETTINGS); + } + } + // // Record the first region into PcdSystemMemoryBase and PcdSystemMemorySize. // This is the region we will use for UEFI itself. diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf index 70eb715d44e3..a6501fb205e1 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf @@ -25,6 +25,7 @@ [Sources] [Packages] ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -40,11 +41,16 @@ [LibraryClasses] [FixedPcd] gArmTokenSpaceGuid.PcdFvBaseAddress gArmTokenSpaceGuid.PcdFvSize + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin gSynQuacerTokenSpaceGuid.PcdDramInfoBase [Ppis] + gEdkiiEmbeddedGpioPpiGuid ## CONSUMES gSynQuacerDramInfoPpiGuid ## PRODUCES [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase gArmTokenSpaceGuid.PcdSystemMemorySize + +[Depex] + gEdkiiEmbeddedGpioPpiGuid diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec index 1a683b81521b..c11550469cd0 100644 --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -30,3 +30,5 @@ [PcdsFixedAtBuild] gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0|UINT32|0x00000002 gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|0|UINT8|0x00000003 + + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0|UINT32|0x00000004 From patchwork Fri Nov 10 14:21:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118564 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260216edl; Fri, 10 Nov 2017 06:24:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMa16RUuuDrZQLVrXUYSDoBAKmVgFJOiQ7p9+mzp3uJ7bPygrE23Zer/QTMpsFf7q8mhhGBd X-Received: by 10.99.7.143 with SMTP id 137mr519546pgh.158.1510323856660; Fri, 10 Nov 2017 06:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323856; cv=none; d=google.com; s=arc-20160816; b=pPsvpSVE1MJr5/+CZKoU0XNhk1pdKpqOCZQzE4zijF/m5xrUieN3RPdXLyhM3tdNzi OCnKgK6ET13uYj6QTZYhuHMbcnni8Xt1sQwVW7CPW62Cyt4ztIky08gS+OwHyqtlj7In vCes6JKSeTsXZCrZDMdIJ9g+H2nr03FzK1SRuxg/dFu3PSfTxsgz0ZxzJRgSGwNDGNQt RTDdbnfBeZl4FQGWZZSYkD06QvU6ZodXoQgLhGrSq2JYIX/FLU1ACKAAWgwFHxf8htlU PHVUIFboOMQ1rZaBCt68GV4scJdcW7BFVNZNqzkh7080toa5iGn7HzJQJUYY1SqWzaeT 6Jyg== 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=0mjQm15i2h5beMAK4E4C+5100cHdyjO+YnERqlErlWE=; b=EeT4rmGyjmCYJ9bls3oTnQLka7kRFPkU3Y/g/GTxHk6Xfyv3gqFa2FhDUcDEc+SRFy zGOfodwtUQD82IdmxqovELnkDOJcT0dPzrdduEqCUc3l5xF6Lbeqr/MM3v6aMl+raiJI BG8lCLSSk+gxeDeNqX5A71g8USYsAF8BJsjFor6fsjHsmqHtI5W/zIqi1N6PM186yQtm nPZ25aBYIWyU3uTnFX7ONNV1Z5iVmGbmXdBkDDf7CunlSYMjnY4H1Eyj0EfgSs6jrpZc TkN92eangyW6qiM5ZZrLx+bzm8mwoDQwXs1Sn4sP7qu9o7b0SvwPkqt7aAcUjBuKN42h KIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OG2gueba; 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 n24si3091172pgc.513.2017.11.10.06.24.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:16 -0800 (PST) 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=OG2gueba; 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 532052035522D; Fri, 10 Nov 2017 06:19:05 -0800 (PST) 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=2a00:1450:400c:c0c::22a; helo=mail-wr0-x22a.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) (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 645E02035521F for ; Fri, 10 Nov 2017 06:19:03 -0800 (PST) Received: by mail-wr0-x22a.google.com with SMTP id y9so8759076wrb.2 for ; Fri, 10 Nov 2017 06:23:06 -0800 (PST) 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=e3K58HrjrmdSMtq0A0DHavVB1aAcVIY7TVXFAbC1i/w=; b=OG2guebaBuQ/KECQ4efxqP6eW9VBmtD7LPLuNa6nDtLY5+3SgK8Bf5huFSGXoL6eoo zEN3OzZ5UWsj6enOWoCc4WjL9dpJLe5X+OPSZIcomdhLsBP7dh1oCs71zu4OB4nnwzhO ONH34OtyWJuocu3iu5HsZUL9tohiOJW17qE+c= 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=e3K58HrjrmdSMtq0A0DHavVB1aAcVIY7TVXFAbC1i/w=; b=PVVOk3UQscbqTsR1kSKHPWVVayOJ4qYI4AEjG2h1OTnrgmVo0zxeJVuOGLvDRRiMXN p6JsaNP/F/Q/R8UtcEVsKU4z+p9l+xU08U8uWib5zv8/P9UM7ykklqKO5ldbGCP9BeHZ TkqIwEhUwzhkk1Z9UhDXsCtxi3GuQwzB11u9B9gv5smPj3yZZP+P960z/Qrgp7icAFfj yd+XnVR3M78APJ+aht2zdCAyK/3w5JTYr4S4WwK/Iohl8ZdZZ5n24qut4Zhe+3osufDW XyKNnVF5b4wQ0Rgy7GUX84aJ+TQwPwlhGB9ANWMPMxx33deCfeaTIaoCKfOCRKnFGIPx 560w== X-Gm-Message-State: AJaThX6+HVzsWb0ALNz0MfVouKgXN0XWqruCJYj8dXeiTHHFM1yx9cxw Dq/pX6NEuKu4YgKZZ8qbbRz9iw8rTuQ= X-Received: by 10.223.162.152 with SMTP id s24mr481693wra.151.1510323784475; Fri, 10 Nov 2017 06:23:04 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:03 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:23 +0000 Message-Id: <20171110142127.12018-31-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 30/34] Silicon/NXP: add RTC support library for PCF8563 I2C IP X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a RealTimeClockLib implementation for the NXP PCF8563 as used on the Socionext Developer Box board. Note that the standard I2C protocol stack does not support runtime use, so this driver invokes the I2C master protocol directly. This requires support from the platform side as well, and so this driver will only attach to a I2C master that has the gPcf8563RealTimeClockLibI2cMasterProtolGuid protocol installed on its handle. It is up to the platform to ensure that the driver producing the I2C master protocol in question is runtime capable, and is not shared with the I2C protocol stack (i.e., it should not have the I2C Bus Configuration Management protocol installed as well). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c | 402 ++++++++++++++++++++ Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec | 29 ++ Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf | 52 +++ 3 files changed, 483 insertions(+) -- 2.11.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/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c new file mode 100644 index 000000000000..67f8e7de4025 --- /dev/null +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c @@ -0,0 +1,402 @@ +/** @file + + Copyright (c) 2017, Linaro, Ltd. 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 + +#define SLAVE_ADDRESS (FixedPcdGet8 (PcdI2cSlaveAddress)) +#define PCF8563_DATA_REG_OFFSET 0x2 + +#define PCF8563_SECONDS_MASK 0x7f +#define PCF8563_MINUTES_MASK 0x7f +#define PCF8563_HOURS_MASK 0x3f +#define PCF8563_DAYS_MASK 0x3f +#define PCF8563_WEEKDAYS_MASK 0x07 +#define PCF8563_MONTHS_MASK 0x1f +#define PCF8563_CENTURY_MASK 0x80 + +// +// The PCF8563 has a 'century' flag, which means it could theoretically span +// 200 years. However, it treats all years divisible by 4 as leap years, +// including the years 1900 and 2100 (which are not leap years), so the only +// sane base year is 2000 (which was a leap year). +// +#define EPOCH_BASE 2000 + +STATIC EFI_HANDLE mI2cMasterHandle; +STATIC VOID *mDriverEventRegistration; +STATIC EFI_I2C_MASTER_PROTOCOL *mI2cMaster; +STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; + +#pragma pack(1) +typedef struct { + UINT8 VL_seconds; + UINT8 Minutes; + UINT8 Hours; + UINT8 Days; + UINT8 Weekdays; + UINT8 Century_months; + UINT8 Years; +} RTC_DATETIME; + +typedef struct { + UINT8 Reg; + RTC_DATETIME DateTime; +} RTC_SET_DATETIME_PACKET; +#pragma pack() + +typedef struct { + UINTN OperationCount; + EFI_I2C_OPERATION SetAddressOp; + EFI_I2C_OPERATION GetDateTimeOp; +} RTC_GET_I2C_REQUEST; + +typedef EFI_I2C_REQUEST_PACKET RTC_SET_I2C_REQUEST; +/** + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + + @param Time A pointer to storage to receive a snapshot of + the current time. + @param Capabilities An optional pointer to a buffer to receive the + real time clock device's capabilities. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER Time is NULL. + @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware + error. + +**/ +EFI_STATUS +EFIAPI +LibGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +{ + RTC_GET_I2C_REQUEST Op; + RTC_DATETIME DateTime; + EFI_STATUS Status; + UINT8 Reg; + + if (Time == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (mI2cMaster == NULL) { + return EFI_DEVICE_ERROR; + } + + Reg = PCF8563_DATA_REG_OFFSET; + + Op.OperationCount = 2; + + Op.SetAddressOp.Flags = 0; + Op.SetAddressOp.LengthInBytes = 1; + Op.SetAddressOp.Buffer = &Reg; + + Op.GetDateTimeOp.Flags = I2C_FLAG_READ; + Op.GetDateTimeOp.LengthInBytes = sizeof (RTC_DATETIME); + Op.GetDateTimeOp.Buffer = (VOID *)&DateTime; + + Status = mI2cMaster->StartRequest (mI2cMaster, SLAVE_ADDRESS, + (VOID *)&Op, NULL, NULL); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + Time->Second = BcdToDecimal8 (DateTime.VL_seconds & PCF8563_SECONDS_MASK); + Time->Minute = BcdToDecimal8 (DateTime.Minutes & PCF8563_MINUTES_MASK); + Time->Hour = BcdToDecimal8 (DateTime.Hours & PCF8563_HOURS_MASK); + Time->Day = BcdToDecimal8 (DateTime.Days & PCF8563_DAYS_MASK); + Time->Month = BcdToDecimal8 (DateTime.Century_months & PCF8563_MONTHS_MASK); + Time->Year = BcdToDecimal8 (DateTime.Years) + EPOCH_BASE; + + if (DateTime.Century_months & PCF8563_CENTURY_MASK) { + Time->Year += 100; + } + + if (Capabilities != NULL) { + Capabilities->Resolution = 1; + Capabilities->Accuracy = 0; + Capabilities->SetsToZero = TRUE; + } + return EFI_SUCCESS; +} + + +/** + Sets the current local time and date information. + + @param Time A pointer to the current time. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER A time field is out of range. + @retval EFI_DEVICE_ERROR The time could not be set due due to hardware + error. + +**/ +EFI_STATUS +EFIAPI +LibSetTime ( + IN EFI_TIME *Time + ) +{ + RTC_SET_I2C_REQUEST Op; + RTC_SET_DATETIME_PACKET Packet; + EFI_STATUS Status; + + if (mI2cMaster == NULL) { + return EFI_DEVICE_ERROR; + } + + Packet.DateTime.VL_seconds = DecimalToBcd8 (Time->Second); + Packet.DateTime.Minutes = DecimalToBcd8 (Time->Minute); + Packet.DateTime.Hours = DecimalToBcd8 (Time->Hour); + Packet.DateTime.Days = DecimalToBcd8 (Time->Day); + Packet.DateTime.Weekdays = 0; + Packet.DateTime.Century_months = DecimalToBcd8 (Time->Month); + Packet.DateTime.Years = DecimalToBcd8 (Time->Year % 100); + if (Time->Year >= EPOCH_BASE + 100) { + if (Time->Year >= EPOCH_BASE + 200) { + return EFI_DEVICE_ERROR; + } + Packet.DateTime.Century_months |= PCF8563_CENTURY_MASK; + } + + Packet.Reg = PCF8563_DATA_REG_OFFSET; + + Op.OperationCount = 1; + Op.Operation[0].Flags = 0; + Op.Operation[0].LengthInBytes = sizeof (RTC_SET_DATETIME_PACKET); + Op.Operation[0].Buffer = (VOID *)&Packet; + + Status = mI2cMaster->StartRequest (mI2cMaster, SLAVE_ADDRESS, + (VOID *)&Op, NULL, NULL); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + return EFI_SUCCESS; +} + + +/** + Returns the current wakeup alarm clock setting. + + @param Enabled Indicates if the alarm is currently enabled or + disabled. + @param Pending Indicates if the alarm signal is pending and + requires acknowledgement. + @param Time The current alarm setting. + + @retval EFI_SUCCESS The alarm settings were returned. + @retval EFI_INVALID_PARAMETER Any parameter is NULL. + @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a + hardware error. + @retval EFI_UNSUPPORTED A wakeup timer is not supported on this + platform. + +**/ +EFI_STATUS +EFIAPI +LibGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +{ + // + // Currently unimplemented. The PCF8563 does not support setting the alarm + // for an arbitrary date/time, but only for a minute/hour/day/weekday + // combination. It should also depend on a platform specific setting that + // indicates whether the PCF8563's interrupt line is connected in a way that + // allows it to power up the system in the first place. + // + return EFI_UNSUPPORTED; +} + + +/** + Sets the system wakeup alarm clock time. + + @param Enabled Enable or disable the wakeup alarm. + @param Time If Enable is TRUE, the time to set the wakeup + alarm for. + + @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was + enabled. If Enable is FALSE, then the wakeup + alarm was disabled. + @retval EFI_INVALID_PARAMETER A time field is out of range. + @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a + hardware error. + @retval EFI_UNSUPPORTED A wakeup timer is not supported on this + platform. + +**/ +EFI_STATUS +EFIAPI +LibSetWakeupTime ( + IN BOOLEAN Enabled, + OUT EFI_TIME *Time + ) +{ + // see comment above + return EFI_UNSUPPORTED; +} + +STATIC +VOID +DriverRegistrationEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_HANDLE Handle[2]; + UINTN BufferSize; + EFI_STATUS Status; + EFI_I2C_MASTER_PROTOCOL *I2cMaster; + UINTN BusFrequency; + + // + // Try to connect the newly registered driver to our handle. + // + do { + BufferSize = sizeof (EFI_HANDLE); + Status = gBS->LocateHandle (ByRegisterNotify, + &gEfiDriverBindingProtocolGuid, + mDriverEventRegistration, + &BufferSize, + Handle); + if (EFI_ERROR (Status)) { + if (Status != EFI_NOT_FOUND) { + DEBUG ((DEBUG_WARN, "%a: gBS->LocateHandle () returned %r\n", + __FUNCTION__, Status)); + } + break; + } + + // + // Check if we can connect our handle to this driver. + // + Handle[1] = NULL; + Status = gBS->ConnectController (mI2cMasterHandle, Handle, NULL, FALSE); + if (EFI_ERROR (Status)) { + continue; + } + + DEBUG ((DEBUG_INFO, "%a: found I2C master!\n", __FUNCTION__)); + + gBS->CloseEvent (Event); + + Status = gBS->OpenProtocol (mI2cMasterHandle, &gEfiI2cMasterProtocolGuid, + (VOID **)&I2cMaster, gImageHandle, NULL, + EFI_OPEN_PROTOCOL_EXCLUSIVE); + ASSERT_EFI_ERROR (Status); + + Status = I2cMaster->Reset (I2cMaster); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: I2CMaster->Reset () failed - %r\n", + __FUNCTION__, Status)); + break; + } + + BusFrequency = FixedPcdGet16 (PcdI2cBusFrequency); + Status = I2cMaster->SetBusFrequency (I2cMaster, &BusFrequency); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: I2CMaster->SetBusFrequency () failed - %r\n", + __FUNCTION__, Status)); + break; + } + + mI2cMaster = I2cMaster; + break; + } while (TRUE); +} + +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +LibRtcVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID **)&mI2cMaster); +} + +/** + Library entry point + + @param ImageHandle Handle that identifies the loaded image. + @param SystemTable System Table for this image. + + @retval EFI_SUCCESS The operation completed successfully. + +**/ +EFI_STATUS +EFIAPI +LibRtcInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + + // + // Find the handle that marks the controller + // that will provide the I2C master protocol. + // + BufferSize = sizeof (EFI_HANDLE); + Status = gBS->LocateHandle (ByProtocol, + &gPcf8563RealTimeClockLibI2cMasterProtolGuid, NULL, + &BufferSize, &mI2cMasterHandle); + ASSERT_EFI_ERROR (Status); + + // + // Register a protocol registration notification callback on the driver + // binding protocol so we can attempt to connect our I2C master to it + // as soon as it appears. + // + EfiCreateProtocolNotifyEvent ( + &gEfiDriverBindingProtocolGuid, + TPL_CALLBACK, + DriverRegistrationEvent, + NULL, + &mDriverEventRegistration); + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + LibRtcVirtualNotifyEvent, NULL, + &gEfiEventVirtualAddressChangeGuid, + &mRtcVirtualAddrChangeEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec new file mode 100644 index 000000000000..3fefa64eefdf --- /dev/null +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec @@ -0,0 +1,29 @@ +#/** @file +# +# Copyright (c) 2017, Linaro, Ltd. 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] + DEC_SPECIFICATION = 0x0001001A + PACKAGE_NAME = Pcf8563RealTimeClockLib + PACKAGE_GUID = 44d63668-c86b-446a-b303-f3a5176702aa + PACKAGE_VERSION = 0.1 + +[Guids] + gPcf8563RealTimeClockLibTokenSpaceGuid = { 0xaaf5b169, 0x93a0, 0x4d60, { 0xba, 0xe4, 0x06, 0x07, 0x92, 0x8e, 0x63, 0xdd }} + +[Protocols] + gPcf8563RealTimeClockLibI2cMasterProtolGuid = { 0xa6af18ae, 0x3bd5, 0x4af9, { 0xbb, 0x6a, 0xdb, 0x85, 0x07, 0x62, 0x81, 0x38 }} + +[PcdsFixedAtBuild] + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cSlaveAddress|0x51|UINT8|0x00000001 + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cBusFrequency|400000|UINT32|0x00000002 diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf new file mode 100644 index 000000000000..e1e001162144 --- /dev/null +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf @@ -0,0 +1,52 @@ +#/** @file +# +# Copyright (c) 2017, Linaro, Ltd. 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 = Pcf8563RealTimeClockLib + FILE_GUID = 1e3d33f3-a671-4116-bd81-6b435296c1e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = RealTimeClockLib + +[Sources.common] + Pcf8563RealTimeClockLib.c + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + IoLib + UefiBootServicesTableLib + UefiLib + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid + +[Protocols] + gEfiDriverBindingProtocolGuid ## CONSUMES + gEfiI2cMasterProtocolGuid ## CONSUMES + gPcf8563RealTimeClockLibI2cMasterProtolGuid ## CONSUMES + +[FixedPcd] + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cSlaveAddress + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cBusFrequency + +[Depex] + gPcf8563RealTimeClockLibI2cMasterProtolGuid From patchwork Fri Nov 10 14:21:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118565 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260302edl; Fri, 10 Nov 2017 06:24:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMaeqS5cIqAd6QBa87dLVNMB+Ngc2DZmD1mpnM2cIqWkm+8YHOVvSHwgJQSVNbJR9ZRL/ao+ X-Received: by 10.84.214.150 with SMTP id j22mr541716pli.408.1510323862007; Fri, 10 Nov 2017 06:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323862; cv=none; d=google.com; s=arc-20160816; b=XKw4XkmKCLCiDZIVT1ESneM2h4BJX/4n204/fg0n0gu2AeHr/lAIllAQjMldfFrKvM gSTcdKy9P3N0GgaqQsU5VHBW/GNZG54vJGnakkWVgqVYsQz4DkhPKwCraEsMthna8FpY buwwzKebgglOmhHAMpgP7bA2fkmKOEHuIQgcLNgjvnb60AZE4kmGq5A0Lxvu+0yfBlQU SXt2BRybWnfXfn3tYkDbPdvtvcIx5+5jJTv7gKl3Jv5tQ1DeUtzVo8t/P8xxOrNtFCPs k+KkSwUj3KTYFk4HjjfHRxF8mEpUPTJ6UDIGwpgsxqpV9gXbja6j1G67yK0dY4EjeS68 TX4g== 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=m6nNSM6WB0GxTknJfRQJkSETUrgnOcXsCjNFhG5KQGk=; b=IiL0dJXzfyhR5c3oI30v4IsTLnUWZjvK6P0IH3xHE6452X0Hc6CBSMdoArMhZ8mbq2 PuaxsDC9pGT8hbURtu7AZYXVvNqs8Bk2mnZCiVwKjyx15e1PRXMwJcOeGatDcpq52CiH cxBPKZMzdQkzMZD5cDc6Z5nqblS4qoCN7u098E9PfHAiy70khXQu5BX8f0uq5IstH9Na 3x0qSQnBk8MrBhq+dNMoDrqJ1MzhpW8v33lKa8Baw4Dg/aKgc9em0V7XNeuLmfgSfgWb mr7IzBIDjiD5zod62WLT5zhWTL6LJYh6S9jNZGhNEHNUGREPiEowkgk4cpC+JGtOXMdV N5xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YJ0ixxKF; 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 a14si5221672pgv.479.2017.11.10.06.24.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:21 -0800 (PST) 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=YJ0ixxKF; 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 8E03821C913C7; Fri, 10 Nov 2017 06:19:08 -0800 (PST) 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=2a00:1450:400c:c0c::22f; helo=mail-wr0-x22f.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22f.google.com (mail-wr0-x22f.google.com [IPv6:2a00:1450:400c:c0c::22f]) (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 2EADA21C913BF for ; Fri, 10 Nov 2017 06:19:06 -0800 (PST) Received: by mail-wr0-x22f.google.com with SMTP id j23so8740779wra.9 for ; Fri, 10 Nov 2017 06:23:09 -0800 (PST) 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=m7AYTN9pbZbAewJXHaZ4Mfagc+ryWhmyd0nb82FjVBU=; b=YJ0ixxKFj51uyADfaBzKbW4lfHXg4sgNbrThclpzmlhdKbF0C7gKS/+uVHfxRiC1ot g7UGsMKLsOj+Qznh4iB6zpd1lRgfEn4lMxUx8O3isIshc/nktqmgwXa51dUlzZZg2JZZ S8FC2DCQCd3L3OmtlOP3WE39udTBgsMrPsmUc= 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=m7AYTN9pbZbAewJXHaZ4Mfagc+ryWhmyd0nb82FjVBU=; b=GILP81w8P3adOfi1MiOSzd5uIgRwSNwQHc4qUCNBQIkp3+3reqfHQPBxuzJ0QfBpop 3cEpqA6fHVmXgeHeM47IqMG03DzTU9K5vQcZqFICLFLUS4kZCO35JkwWOFlBZI5YuLhP 0MNQ3z1FNkfGu6sqYF3OwX5NK6uHJeetqtnSoqn8H+P2xSaXInf7b35gb87mf+5HiKBN LIHXlWoa02TtT2lXtFZr3xLUBb51j1fSIyYFm2zQ+mMA7Qn/RhfJ7MPEk+BMU10TIS+1 zLeOfL6cG+R/8v0UtH8d0uik51mbxFiYY1wqQ8npDnuv85LqigMV/81FhP6IPlymlop3 hv0w== X-Gm-Message-State: AJaThX4INrtEGPBmhVT7oiWxy/0mJtPk6uE1sxwIXZ88xCJpRRE1Eo01 1ggsBAFNyWDZRDd+jNNL06hR4+BqLC0= X-Received: by 10.223.185.121 with SMTP id b54mr458772wrg.264.1510323786851; Fri, 10 Nov 2017 06:23:06 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:06 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:24 +0000 Message-Id: <20171110142127.12018-32-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 31/34] Silicon/Socionext: implement I2C master protocol for SynQuacer I2C X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a driver that produces the I2C master protocol on top of the I2C controllers that are implemented in the SynQuacer Socionext SoC. Note that this supports two modes simultaneously: I2C controllers that are only usable at boot time, and usable via the I2C protocol stack, and I2C controllers that are dedicated for the RTC or other runtime components. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/ComponentName.c | 185 ++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/DriverBinding.c | 238 ++++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c | 586 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.h | 162 ++++++ Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf | 59 ++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 5 + 6 files changed, 1235 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/ComponentName.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/ComponentName.c new file mode 100644 index 000000000000..8d7aa417505b --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/ComponentName.c @@ -0,0 +1,185 @@ +/** @file + + Copyright (c) 2017, Linaro Ltd. 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 "SynQuacerI2cDxe.h" + +STATIC EFI_UNICODE_STRING_TABLE mSynQuacerI2cDriverNameTable[] = { + { + "en", + (CHAR16 *)L"Socionext SynQuacer I2C Driver" + }, + { } +}; + +STATIC EFI_UNICODE_STRING_TABLE mSynQuacerI2cControllerNameTable[] = { + { + "en", + (CHAR16 *)L"Socionext SynQuacer I2C Controller" + }, + { } +}; + +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 4646 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerI2cGetDriverName ( + IN EFI_COMPONENT_NAME2_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ) +{ + return LookupUnicodeString2 (Language, + This->SupportedLanguages, + mSynQuacerI2cDriverNameTable, + DriverName, + FALSE); +} + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 4646 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerI2cGetControllerName ( + IN EFI_COMPONENT_NAME2_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ) +{ + if (ChildHandle != NULL) { + return EFI_UNSUPPORTED; + } + + return LookupUnicodeString2 (Language, + This->SupportedLanguages, + mSynQuacerI2cControllerNameTable, + ControllerName, + FALSE); +} + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gSynQuacerI2cDriverComponentName2 = { + SynQuacerI2cGetDriverName, + SynQuacerI2cGetControllerName, + "en" +}; diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/DriverBinding.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/DriverBinding.c new file mode 100644 index 000000000000..22e53408f419 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/DriverBinding.c @@ -0,0 +1,238 @@ +/** @file + + Copyright (c) 2017, Linaro Ltd. 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 "SynQuacerI2cDxe.h" + +/** + Tests to see if this driver supports a given controller. + + @param This[in] A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param ControllerHandle[in] The handle of the controller to test. + @param RemainingDevicePath[in] The remaining device path. + (Ignored - this is not a bus driver.) + + @retval EFI_SUCCESS The driver supports this controller. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle is + already being managed by the driver specified + by This. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle is + not supported by the driver specified by This. + +**/ +EFI_STATUS +EFIAPI +SynQuacerI2cDriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + NON_DISCOVERABLE_DEVICE *Dev; + EFI_STATUS Status; + + // + // Connect to the USB stack + // + Status = gBS->OpenProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + (VOID **) &Dev, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER); + if (EFI_ERROR (Status)) { + return Status; + } + + if (CompareGuid (Dev->Type, &gSynQuacerNonDiscoverableI2cMasterGuid) || + CompareGuid (Dev->Type, &gSynQuacerNonDiscoverableRuntimeI2cMasterGuid)) { + Status = EFI_SUCCESS; + } else { + Status = EFI_UNSUPPORTED; + } + + // + // Clean up. + // + gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + This->DriverBindingHandle, + ControllerHandle); + + return Status; +} + + +/** + Starts a device controller or a bus controller. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param[in] ControllerHandle The handle of the device to start. This + handle must support a protocol interface that + supplies an I/O abstraction to the driver. + @param[in] RemainingDevicePath The remaining portion of the device path. + (Ignored - this is not a bus driver.) + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a + device error. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources. + +**/ +EFI_STATUS +EFIAPI +SynQuacerI2cDriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return SynQuacerI2cInit (This->DriverBindingHandle, ControllerHandle); +} + + +/** + Stops a device controller or a bus controller. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL + instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle + must support a bus specific I/O protocol for the + driver to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in + ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be + NULL if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device + error. + +**/ +EFI_STATUS +EFIAPI +SynQuacerI2cDriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ) +{ + return SynQuacerI2cRelease (This->DriverBindingHandle, ControllerHandle); +} + + +STATIC EFI_DRIVER_BINDING_PROTOCOL gSynQuacerI2cDriverBinding = { + SynQuacerI2cDriverBindingSupported, + SynQuacerI2cDriverBindingStart, + SynQuacerI2cDriverBindingStop, + 0xa, + NULL, + NULL +}; + + +/** + The entry point of I2c UEFI Driver. + + @param ImageHandle The image handle of the UEFI Driver. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The Driver or UEFI Driver exited normally. + @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than + SystemTable->Hdr.Revision. + +**/ +EFI_STATUS +EFIAPI +SynQuacerI2cDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Add the driver to the list of drivers + // + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, SystemTable, &gSynQuacerI2cDriverBinding, ImageHandle, + NULL, &gSynQuacerI2cDriverComponentName2); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO, "*** Installed SynQuacer I2C UEFI driver! ***\n")); + + return EFI_SUCCESS; +} + + +/** + Unload function for the I2c UEFI Driver. + + @param ImageHandle[in] The allocated handle for the EFI image + + @retval EFI_SUCCESS The driver was unloaded successfully + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +SynQuacerI2cDxeUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + + // + // Retrieve all USB I/O handles in the handle database + // + Status = gBS->LocateHandleBuffer (ByProtocol, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Disconnect the driver from the handles in the handle database + // + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->DisconnectController (HandleBuffer[Index], + gImageHandle, + NULL); + } + + // + // Free the handle array + // + gBS->FreePool (HandleBuffer); + + // + // Uninstall protocols installed by the driver in its entrypoint + // + Status = gBS->UninstallMultipleProtocolInterfaces (ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gSynQuacerI2cDriverBinding, + NULL + ); + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c new file mode 100644 index 000000000000..0a2d0528e0a7 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c @@ -0,0 +1,586 @@ +/** @file + + Copyright (c) 2017, Linaro, Ltd. 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 "SynQuacerI2cDxe.h" + +#define __DEBUG(x) do { if (!EfiAtRuntime()) DEBUG (x); } while (0) + +// +// We cannot use Stall () or timer events at runtime, so we need to busy-wait +// for the controller to signal the completion interrupts. This value was +// arbitrarily chosen, and does not appear to produce any premature timeouts +// nor does it result in noticeable stalls in case of bus errors. +// +#define WAIT_FOR_INTERRUPT_TIMEOUT 50000 + +/** + Set the frequency for the I2C clock line. + + This routine must be called at or below TPL_NOTIFY. + + The software and controller do a best case effort of using the specified + frequency for the I2C bus. If the frequency does not match exactly then + the I2C master protocol selects the next lower frequency to avoid + exceeding the operating conditions for any of the I2C devices on the bus. + For example if 400 KHz was specified and the controller's divide network + only supports 402 KHz or 398 KHz then the I2C master protocol selects 398 + KHz. If there are not lower frequencies available, then return + EFI_UNSUPPORTED. + + @param[in] This Pointer to an EFI_I2C_MASTER_PROTOCOL structure + @param[in] BusClockHertz Pointer to the requested I2C bus clock frequency + in Hertz. Upon return this value contains the + actual frequency in use by the I2C controller. + + @retval EFI_SUCCESS The bus frequency was set successfully. + @retval EFI_ALREADY_STARTED The controller is busy with another transaction. + @retval EFI_INVALID_PARAMETER BusClockHertz is NULL + @retval EFI_UNSUPPORTED The controller does not support this frequency. + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerI2cSetBusFrequency ( + IN CONST EFI_I2C_MASTER_PROTOCOL *This, + IN OUT UINTN *BusClockHertz + ) +{ + SYNQUACER_I2C_MASTER *I2c; + UINT8 Ccr, Csr; + + I2c = SYNQUACER_I2C_FROM_THIS (This); + + if (BusClockHertz == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (*BusClockHertz >= F_I2C_SPEED_FM) { + if (REFCLK_RATE <= F_I2C_CLK_RATE_18M) { + Ccr = F_I2C_CCR_CS_FAST_MAX_18M (REFCLK_RATE); + Csr = F_I2C_CSR_CS_FAST_MAX_18M (REFCLK_RATE); + } else { + Ccr = F_I2C_CCR_CS_FAST_MIN_18M (REFCLK_RATE); + Csr = F_I2C_CSR_CS_FAST_MIN_18M (REFCLK_RATE); + } + + // Set Clock and enable, Set fast mode + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CCR, + Ccr | F_I2C_CCR_FM | F_I2C_CCR_EN); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CSR, Csr); + + *BusClockHertz = F_I2C_SPEED_FM; + + } else if (*BusClockHertz >= F_I2C_SPEED_SM) { + if (REFCLK_RATE <= F_I2C_CLK_RATE_18M) { + Ccr = F_I2C_CCR_CS_STANDARD_MAX_18M (REFCLK_RATE); + Csr = F_I2C_CSR_CS_STANDARD_MAX_18M (REFCLK_RATE); + } else { + Ccr = F_I2C_CCR_CS_STANDARD_MIN_18M (REFCLK_RATE); + Csr = F_I2C_CSR_CS_STANDARD_MIN_18M (REFCLK_RATE); + } + + // Set Clock and enable, Set standard mode + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CCR, Ccr | F_I2C_CCR_EN); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CSR, Csr); + + *BusClockHertz = F_I2C_SPEED_SM; + } else { + return EFI_UNSUPPORTED; + } + + MemoryFence (); + + return EFI_SUCCESS; +} + +/** + Reset the I2C controller and configure it for use + + This routine must be called at or below TPL_NOTIFY. + + The I2C controller is reset. The caller must call SetBusFrequench() after + calling Reset(). + + @param[in] This Pointer to an EFI_I2C_MASTER_PROTOCOL structure. + + @retval EFI_SUCCESS The reset completed successfully. + @retval EFI_ALREADY_STARTED The controller is busy with another transaction. + @retval EFI_DEVICE_ERROR The reset operation failed. + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerI2cReset ( + IN CONST EFI_I2C_MASTER_PROTOCOL *This + ) +{ + SYNQUACER_I2C_MASTER *I2c; + + I2c = SYNQUACER_I2C_FROM_THIS (This); + + // Disable the clock + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CCR, 0); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_CSR, 0); + + MemoryFence (); + + // Set own Address + MmioWrite8 (I2c->MmioBase + F_I2C_REG_ADR, 0); + + // Set PCLK frequency + MmioWrite8 (I2c->MmioBase + F_I2C_REG_FSR, F_I2C_BUS_CLK_FR (REFCLK_RATE)); + + // clear IRQ (INT=0, BER=0), Interrupt Disable + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, 0); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BC2R, 0); + + MemoryFence (); + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +SynQuacerI2cMasterStart ( + IN SYNQUACER_I2C_MASTER *I2c, + IN UINTN SlaveAddress, + IN EFI_I2C_OPERATION *Op + ) +{ + UINT8 Bsr; + UINT8 Bcr; + + if (Op->Flags & I2C_FLAG_READ) { + MmioWrite8 (I2c->MmioBase + F_I2C_REG_DAR, (SlaveAddress << 1) | 1); + } else { + MmioWrite8 (I2c->MmioBase + F_I2C_REG_DAR, SlaveAddress << 1); + } + + __DEBUG ((DEBUG_INFO, "%a: slave:0x%02x\n", __FUNCTION__, SlaveAddress)); + + Bsr = MmioRead8 (I2c->MmioBase + F_I2C_REG_BSR); + Bcr = MmioRead8 (I2c->MmioBase + F_I2C_REG_BCR); + + if ((Bsr & F_I2C_BSR_BB) && !(Bcr & F_I2C_BCR_MSS)) { + __DEBUG ((DEBUG_INFO, "%a: bus is busy\n", __FUNCTION__)); + return EFI_ALREADY_STARTED; + } + + if (Bsr & F_I2C_BSR_BB) { // Bus is busy + __DEBUG ((DEBUG_INFO, "%a: Continuous Start\n", __FUNCTION__)); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, Bcr | F_I2C_BCR_SCC); + } else { + if (Bcr & F_I2C_BCR_MSS) { + __DEBUG ((DEBUG_WARN, "%a: is not in master mode\n", __FUNCTION__)); + return EFI_DEVICE_ERROR; + } + __DEBUG ((DEBUG_INFO, "%a: Start Condition\n", __FUNCTION__)); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, + Bcr | F_I2C_BCR_MSS | F_I2C_BCR_INTE | F_I2C_BCR_BEIE); + } + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +WaitForInterrupt ( + IN SYNQUACER_I2C_MASTER *I2c + ) +{ + UINT8 Bsr; + UINTN Timeout = WAIT_FOR_INTERRUPT_TIMEOUT; + + do { + MemoryFence (); + + Bsr = MmioRead8 (I2c->MmioBase + F_I2C_REG_BCR); + if (Bsr & F_I2C_BCR_INT) { + return EFI_SUCCESS; + } + } while (Timeout--); + + return EFI_DEVICE_ERROR; +} + +/** + Start an I2C transaction on the host controller. + + This routine must be called at or below TPL_NOTIFY. For synchronous + requests this routine must be called at or below TPL_CALLBACK. + + This function initiates an I2C transaction on the controller. To + enable proper error handling by the I2C protocol stack, the I2C + master protocol does not support queuing but instead only manages + one I2C transaction at a time. This API requires that the I2C bus + is in the correct configuration for the I2C transaction. + + The transaction is performed by sending a start-bit and selecting the + I2C device with the specified I2C slave address and then performing + the specified I2C operations. When multiple operations are requested + they are separated with a repeated start bit and the slave address. + The transaction is terminated with a stop bit. + + When Event is NULL, StartRequest operates synchronously and returns + the I2C completion status as its return value. + + When Event is not NULL, StartRequest synchronously returns EFI_SUCCESS + indicating that the I2C transaction was started asynchronously. The + transaction status value is returned in the buffer pointed to by + I2cStatus upon the completion of the I2C transaction when I2cStatus + is not NULL. After the transaction status is returned the Event is + signaled. + + Note: The typical consumer of this API is the I2C host protocol. + Extreme care must be taken by other consumers of this API to prevent + confusing the third party I2C drivers due to a state change at the + I2C device which the third party I2C drivers did not initiate. I2C + platform specific code may use this API within these guidelines. + + @param[in] This Pointer to an EFI_I2C_MASTER_PROTOCOL structure. + @param[in] SlaveAddress Address of the device on the I2C bus. Set the + I2C_ADDRESSING_10_BIT when using 10-bit addresses, + clear this bit for 7-bit addressing. Bits 0-6 + are used for 7-bit I2C slave addresses and bits + 0-9 are used for 10-bit I2C slave addresses. + @param[in] RequestPacket Pointer to an EFI_I2C_REQUEST_PACKET + structure describing the I2C transaction. + @param[in] Event Event to signal for asynchronous transactions, + NULL for synchronous transactions + @param[out] I2cStatus Optional buffer to receive the I2C transaction + completion status + + @retval EFI_SUCCESS The asynchronous transaction was successfully + started when Event is not NULL. + @retval EFI_SUCCESS The transaction completed successfully when + Event is NULL. + @retval EFI_ALREADY_STARTED The controller is busy with another transaction. + @retval EFI_BAD_BUFFER_SIZE The RequestPacket->LengthInBytes value is too + large. + @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the + transaction. + @retval EFI_INVALID_PARAMETER RequestPacket is NULL + @retval EFI_NOT_FOUND Reserved bit set in the SlaveAddress parameter + @retval EFI_NO_RESPONSE The I2C device is not responding to the slave + address. EFI_DEVICE_ERROR will be returned if + the controller cannot distinguish when the NACK + occurred. + @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C transaction + @retval EFI_UNSUPPORTED The controller does not support the requested + transaction. + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerI2cStartRequest ( + IN CONST EFI_I2C_MASTER_PROTOCOL *This, + IN UINTN SlaveAddress, + IN EFI_I2C_REQUEST_PACKET *RequestPacket, + IN EFI_EVENT Event OPTIONAL, + OUT EFI_STATUS *I2cStatus OPTIONAL + ) +{ + SYNQUACER_I2C_MASTER *I2c; + UINTN Idx; + EFI_I2C_OPERATION *Op; + UINTN BufIdx; + EFI_STATUS Status; + EFI_TPL Tpl; + BOOLEAN AtRuntime; + UINT8 Bsr; + UINT8 Bcr; + + I2c = SYNQUACER_I2C_FROM_THIS (This); + + // + // We can only do synchronous operations at runtime + // + AtRuntime = EfiAtRuntime (); + if (AtRuntime && Event != NULL) { + return EFI_UNSUPPORTED; + } + + if (!AtRuntime) { + Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + } + + for (Idx = 0, Op = RequestPacket->Operation, Status = EFI_SUCCESS; + Idx < RequestPacket->OperationCount && !EFI_ERROR (Status); + Idx++, Op++) { + + Status = SynQuacerI2cMasterStart (I2c, SlaveAddress, Op); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = WaitForInterrupt (I2c); + if (EFI_ERROR (Status)) { + __DEBUG ((DEBUG_WARN, "%a: Timeout waiting for interrupt - %r\n", + Status)); + break; + } + + if (MmioRead8 (I2c->MmioBase + F_I2C_REG_BSR) & F_I2C_BSR_LRB) { + __DEBUG ((DEBUG_WARN, "%a: No ack received - %r\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + break; + } + + BufIdx = 0; + do { + Bsr = MmioRead8 (I2c->MmioBase + F_I2C_REG_BSR); + Bcr = MmioRead8 (I2c->MmioBase + F_I2C_REG_BCR); + + if (Bcr & F_I2C_BCR_BER) { + __DEBUG ((DEBUG_WARN, "%a: Bus error detected\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + break; + } + + if ((Bsr & F_I2C_BSR_AL) || !(Bcr & F_I2C_BCR_MSS)) { + __DEBUG ((DEBUG_WARN, "%a: Arbitration lost\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + break; + } + + if (Op->Flags & I2C_FLAG_READ) { + if (BufIdx == Op->LengthInBytes - 1) { + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, + F_I2C_BCR_MSS | F_I2C_BCR_INTE | F_I2C_BCR_BEIE); + } else { + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, + F_I2C_BCR_MSS | F_I2C_BCR_INTE | F_I2C_BCR_BEIE | F_I2C_BCR_ACK); + } + + Status = WaitForInterrupt (I2c); + if (EFI_ERROR (Status)) { + __DEBUG ((DEBUG_WARN, "%a: Timeout waiting for interrupt - %r\n", + __FUNCTION__, Status)); + break; + } + + if (!(MmioRead8 (I2c->MmioBase + F_I2C_REG_BSR) & F_I2C_BSR_FBT)) { + Op->Buffer [BufIdx++] = MmioRead8 (I2c->MmioBase + F_I2C_REG_DAR); + } + } else { + MmioWrite8 (I2c->MmioBase + F_I2C_REG_DAR, Op->Buffer [BufIdx++]); + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, + F_I2C_BCR_MSS | F_I2C_BCR_INTE | F_I2C_BCR_BEIE); + + Status = WaitForInterrupt (I2c); + if (EFI_ERROR (Status)) { + __DEBUG ((DEBUG_WARN, "%a: Timeout waiting for interrupt - %r\n", + __FUNCTION__, Status)); + break; + } + + if (MmioRead8 (I2c->MmioBase + F_I2C_REG_BSR) & F_I2C_BSR_LRB) { + __DEBUG ((DEBUG_WARN, "%a: No ack received\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + break; + } + } + } while (BufIdx < Op->LengthInBytes); + } + + // Stop the transfer + MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, 0); + + if (!AtRuntime) { + gBS->RestoreTPL (Tpl); + } + + if (Event) { + *I2cStatus = Status; + gBS->SignalEvent (Event); + } + return Status; +} + +STATIC CONST EFI_I2C_CONTROLLER_CAPABILITIES mI2cControllerCapabilities = { + sizeof (EFI_I2C_CONTROLLER_CAPABILITIES), // StructureSizeInBytes + MAX_UINT32, // MaximumReceiveBytes + MAX_UINT32, // MaximumTransmitBytes + MAX_UINT32, // MaximumTotalBytes +}; + +STATIC +VOID +EFIAPI +SynQuacerI2cVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + SYNQUACER_I2C_MASTER *I2c = Context; + + EfiConvertPointer (0x0, (VOID **)&I2c->I2cMaster.SetBusFrequency); + EfiConvertPointer (0x0, (VOID **)&I2c->I2cMaster.Reset); + EfiConvertPointer (0x0, (VOID **)&I2c->I2cMaster.StartRequest); + EfiConvertPointer (0x0, (VOID **)&I2c->I2cMaster.I2cControllerCapabilities); + EfiConvertPointer (0x0, (VOID **)&I2c->MmioBase); +} + +EFI_STATUS +SynQuacerI2cInit ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ) +{ + EFI_STATUS Status; + NON_DISCOVERABLE_DEVICE *Dev; + SYNQUACER_I2C_MASTER *I2c; + BOOLEAN Runtime; + + Status = gBS->OpenProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + (VOID **)&Dev, DriverBindingHandle, + ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); + if (EFI_ERROR (Status)) { + return Status; + } + + Runtime = CompareGuid (Dev->Type, + &gSynQuacerNonDiscoverableRuntimeI2cMasterGuid); + + // Allocate Resources + if (Runtime) { + I2c = AllocateRuntimeZeroPool (sizeof (SYNQUACER_I2C_MASTER)); + } else { + I2c = AllocateZeroPool (sizeof (SYNQUACER_I2C_MASTER)); + } + if (I2c == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto CloseProtocol; + } + + I2c->Signature = SYNQUACER_I2C_SIGNATURE; + I2c->I2cMaster.SetBusFrequency = SynQuacerI2cSetBusFrequency; + I2c->I2cMaster.Reset = SynQuacerI2cReset; + I2c->I2cMaster.StartRequest = SynQuacerI2cStartRequest; + I2c->I2cMaster.I2cControllerCapabilities = &mI2cControllerCapabilities; + I2c->MmioBase = Dev->Resources[0].AddrRangeMin; + I2c->Dev = Dev; + + if (Runtime) { + I2c->Runtime = TRUE; + + // Declare the controller as EFI_MEMORY_RUNTIME + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + Dev->Resources[0].AddrRangeMin, + Dev->Resources[0].AddrLen, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + if (EFI_ERROR (Status)) { + __DEBUG ((DEBUG_WARN, "%a: failed to add memory space - %r\n", + __FUNCTION__, Status)); + } + + Status = gDS->SetMemorySpaceAttributes ( + Dev->Resources[0].AddrRangeMin, + Dev->Resources[0].AddrLen, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + if (EFI_ERROR (Status)) { + goto FreeDevice; + } + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + SynQuacerI2cVirtualNotifyEvent, I2c, + &gEfiEventVirtualAddressChangeGuid, + &I2c->VirtualAddressChangeEvent); + if (EFI_ERROR (Status)) { + goto FreeDevice; + } + } + + CopyGuid (&I2c->DevicePath.Vendor.Guid, &gEfiCallerIdGuid); + I2c->DevicePath.MmioBase = I2c->MmioBase; + SetDevicePathNodeLength (&I2c->DevicePath.Vendor, + sizeof (I2c->DevicePath) - sizeof (I2c->DevicePath.End)); + SetDevicePathEndNode (&I2c->DevicePath.End); + + Status = gBS->InstallMultipleProtocolInterfaces (&ControllerHandle, + &gEfiI2cMasterProtocolGuid, &I2c->I2cMaster, + &gEfiDevicePathProtocolGuid, &I2c->DevicePath, + NULL); + if (EFI_ERROR (Status)) { + goto CloseEvent; + } + return EFI_SUCCESS; + +CloseEvent: + if (Runtime) { + gBS->CloseEvent (I2c->VirtualAddressChangeEvent); + } + +FreeDevice: + FreePool (I2c); + +CloseProtocol: + gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + DriverBindingHandle, + ControllerHandle); + return Status; +} + +EFI_STATUS +SynQuacerI2cRelease ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ) +{ + EFI_I2C_MASTER_PROTOCOL *I2cMaster; + SYNQUACER_I2C_MASTER *I2c; + EFI_STATUS Status; + + Status = gBS->HandleProtocol (ControllerHandle, + &gEfiI2cMasterProtocolGuid, + (VOID **)&I2cMaster); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + I2c = SYNQUACER_I2C_FROM_THIS (I2cMaster); + + Status = gBS->UninstallMultipleProtocolInterfaces (ControllerHandle, + &gEfiI2cMasterProtocolGuid, I2cMaster, + &gEfiDevicePathProtocolGuid, &I2c->DevicePath, + NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + if (I2c->Runtime) { + gBS->CloseEvent (I2c->VirtualAddressChangeEvent); + } + + Status = gBS->CloseProtocol (ControllerHandle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + DriverBindingHandle, + ControllerHandle); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + gBS->FreePool (I2c); + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.h b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.h new file mode 100644 index 000000000000..8c3d7ef67103 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.h @@ -0,0 +1,162 @@ +/** @file + + Copyright (c) 2017, Linaro, Ltd. 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. + +**/ + +#ifndef __SYNQUACER_I2C_DXE_H__ +#define __SYNQUACER_I2C_DXE_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +extern EFI_COMPONENT_NAME2_PROTOCOL gSynQuacerI2cDriverComponentName2; + +#define SYNQUACER_I2C_SIGNATURE SIGNATURE_32 ('S', 'I', '2', 'C') +#define SYNQUACER_I2C_FROM_THIS(a) CR (a, SYNQUACER_I2C_MASTER, \ + I2cMaster, SYNQUACER_I2C_SIGNATURE) + +#pragma pack(1) +typedef struct { + VENDOR_DEVICE_PATH Vendor; + UINT64 MmioBase; + EFI_DEVICE_PATH_PROTOCOL End; +} SYNQUACER_I2C_DEVICE_PATH; +#pragma pack() + +typedef struct { + UINT32 Signature; + EFI_I2C_MASTER_PROTOCOL I2cMaster; + EFI_PHYSICAL_ADDRESS MmioBase; + SYNQUACER_I2C_DEVICE_PATH DevicePath; + NON_DISCOVERABLE_DEVICE *Dev; + EFI_EVENT VirtualAddressChangeEvent; + BOOLEAN Runtime; +} SYNQUACER_I2C_MASTER; + +EFI_STATUS +SynQuacerI2cInit ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ); + +EFI_STATUS +SynQuacerI2cRelease ( + IN EFI_HANDLE DriverBindingHandle, + IN EFI_HANDLE ControllerHandle + ); + +#define REFCLK_RATE FixedPcdGet32 (PcdI2cReferenceClock) + +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + +#define F_I2C_SPEED_SM 100000 +#define F_I2C_SPEED_FM 400000 + +// I2C register adress definitions +#define F_I2C_REG_BSR (0x00 << 2) // Bus Status Regster +#define F_I2C_REG_BCR (0x01 << 2) // Bus Control Register +#define F_I2C_REG_CCR (0x02 << 2) // Clock Control Register +#define F_I2C_REG_ADR (0x03 << 2) // Address Register +#define F_I2C_REG_DAR (0x04 << 2) // Data Register +#define F_I2C_REG_CSR (0x05 << 2) // Expansion CS Register +#define F_I2C_REG_FSR (0x06 << 2) // Bus Clock Frequency Register +#define F_I2C_REG_BC2R (0x07 << 2) // Bus Control 2 Register + +// I2C register bit definitions +#define F_I2C_BSR_FBT BIT0 // First Byte Transfer +#define F_I2C_BSR_GCA BIT1 // General Call Address +#define F_I2C_BSR_AAS BIT2 // Address as Slave +#define F_I2C_BSR_TRX BIT3 // Transfer/Receive +#define F_I2C_BSR_LRB BIT4 // Last Received Bit +#define F_I2C_BSR_AL BIT5 // Arbitration Lost +#define F_I2C_BSR_RSC BIT6 // Repeated Start Condition +#define F_I2C_BSR_BB BIT7 // Bus Busy + +#define F_I2C_BCR_INT BIT0 // Interrupt +#define F_I2C_BCR_INTE BIT1 // Interrupt Enable +#define F_I2C_BCR_GCAA BIT2 // General Call Access Acknowledge +#define F_I2C_BCR_ACK BIT3 // Acknowledge +#define F_I2C_BCR_MSS BIT4 // Master Slave Select +#define F_I2C_BCR_SCC BIT5 // Start Condition Continue +#define F_I2C_BCR_BEIE BIT6 // Bus Error Interrupt Enable +#define F_I2C_BCR_BER BIT7 // Bus Error + +#define F_I2C_CCR_CS_MASK 0x1f // CCR Clock Period Select +#define F_I2C_CCR_EN BIT5 // Enable +#define F_I2C_CCR_FM BIT6 // Speed Mode Select + +#define F_I2C_CSR_CS_MASK 0x3f // CSR Clock Period Select + +#define F_I2C_BC2R_SCLL BIT0 // SCL Low Drive +#define F_I2C_BC2R_SDAL BIT1 // SDA Low Drive +#define F_I2C_BC2R_SCLS BIT4 // SCL Status +#define F_I2C_BC2R_SDAS BIT5 // SDA Status + +// PCLK frequency +#define F_I2C_BUS_CLK_FR(rate) ((rate) / 20000000 + 1) + +#define F_I2C_MIN_CLK_RATE (14 * 1000000) // min frequency 14 MHz +#define F_I2C_MAX_CLK_RATE (200 * 1000000) // max frequency 200 MHz +#define F_I2C_CLK_RATE_18M (18 * 1000000) // threshold freq 18 MHz + +// STANDARD MODE frequency +#define F_I2C_CLK_MASTER_STANDARD(rate) \ + DIV_ROUND_UP (DIV_ROUND_UP ((rate), 100000) - 2, 2) + +// FAST MODE frequency +#define F_I2C_CLK_MASTER_FAST(rate) \ + DIV_ROUND_UP ((DIV_ROUND_UP ((rate), 400000) - 2) * 2, 3) + +// (clkrate <= 18000000) +// calculate the value of CS bits in CCR register in standard mode +#define F_I2C_CCR_CS_STANDARD_MAX_18M(rate) \ + ((F_I2C_CLK_MASTER_STANDARD (rate) - 65) & F_I2C_CCR_CS_MASK) + +// calculate the value of CS bits in CSR register in standard mode +#define F_I2C_CSR_CS_STANDARD_MAX_18M(rate) 0x00 + +// calculate the value of CS bits in CCR register in fast mode +#define F_I2C_CCR_CS_FAST_MAX_18M(rate) \ + ((F_I2C_CLK_MASTER_FAST (rate) - 1) & F_I2C_CCR_CS_MASK) + +// calculate the value of CS bits in CSR register in fast mode +#define F_I2C_CSR_CS_FAST_MAX_18M(rate) 0x00 + +// (clkrate > 18000000) +// calculate the value of CS bits in CCR register in standard mode */ +#define F_I2C_CCR_CS_STANDARD_MIN_18M(rate) \ + ((F_I2C_CLK_MASTER_STANDARD (rate) - 1) & F_I2C_CCR_CS_MASK) + +// calculate the value of CS bits in CSR register in standard mode +#define F_I2C_CSR_CS_STANDARD_MIN_18M(rate) \ + (((F_I2C_CLK_MASTER_STANDARD (rate) - 1) >> 5) & F_I2C_CSR_CS_MASK) + +// calculate the value of CS bits in CCR register in fast mode +#define F_I2C_CCR_CS_FAST_MIN_18M(rate) \ + ((F_I2C_CLK_MASTER_FAST (rate) - 1) & F_I2C_CCR_CS_MASK) + +/* calculate the value of CS bits in CSR register in fast mode */ +#define F_I2C_CSR_CS_FAST_MIN_18M(rate) \ + (((F_I2C_CLK_MASTER_FAST (rate) - 1) >> 5) & F_I2C_CSR_CS_MASK) + +#endif diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf new file mode 100644 index 000000000000..fa715366878c --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf @@ -0,0 +1,59 @@ +#/** @file +# +# Copyright (c) 2017, Linaro, Ltd. 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 = SynQuacerI2cDxe + FILE_GUID = ab5ed376-dd38-4d22-ae89-b645a4a3236e + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = SynQuacerI2cDxeEntryPoint + UNLOAD = SynQuacerI2cDxeUnload + +[Sources.common] + ComponentName.c + DriverBinding.c + SynQuacerI2cDxe.c + SynQuacerI2cDxe.h + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DevicePathLib + DxeServicesTableLib + IoLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiLib + UefiDriverEntryPoint + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid + gSynQuacerNonDiscoverableI2cMasterGuid + gSynQuacerNonDiscoverableRuntimeI2cMasterGuid + +[Protocols] + gEdkiiNonDiscoverableDeviceProtocolGuid ## TO_START + gEfiI2cMasterProtocolGuid ## BY_START + +[FixedPcd] + gSynQuacerTokenSpaceGuid.PcdI2cReferenceClock + +[Depex] + TRUE diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec index c11550469cd0..76a9b70bc81e 100644 --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -22,6 +22,9 @@ [Includes] [Guids] gSynQuacerTokenSpaceGuid = { 0x4d04555b, 0xdfdc, 0x418a, { 0x8a, 0xab, 0x07, 0xce, 0xef, 0x46, 0x82, 0xbb } } + gSynQuacerNonDiscoverableI2cMasterGuid = { 0x364ee675, 0x9e44, 0x42b7, { 0xa5, 0xe4, 0x92, 0x84, 0xdb, 0x85, 0xda, 0x09 } } + gSynQuacerNonDiscoverableRuntimeI2cMasterGuid = { 0x5f35aa9b, 0x8c6f, 0x4828, { 0xbd, 0x44, 0x7c, 0xc0, 0xeb, 0x2d, 0xfe, 0xb9 } } + [Ppis] gSynQuacerDramInfoPpiGuid = { 0x3e1d7356, 0xdda4, 0x4b1a, { 0x93, 0x46, 0xbf, 0x89, 0x1c, 0x86, 0x46, 0xcc } } @@ -32,3 +35,5 @@ [PcdsFixedAtBuild] gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|0|UINT8|0x00000003 gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0|UINT32|0x00000004 + + gSynQuacerTokenSpaceGuid.PcdI2cReferenceClock|62500000|UINT32|0x00000005 From patchwork Fri Nov 10 14:21:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118566 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260400edl; Fri, 10 Nov 2017 06:24:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMZvsCK5sDKioZHFIpsrP7RbXCojKwjac5HqOxE8JB8y98a4aNK0zTe9DtyGfhB7jd10Vwix X-Received: by 10.84.192.3 with SMTP id b3mr571239pld.118.1510323867779; Fri, 10 Nov 2017 06:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323867; cv=none; d=google.com; s=arc-20160816; b=Luw4sc42wR+4AAw/wX2JCngPw5vdnTInQ6vZQMNoT1ug/E/E1zDUEQk31y5SK/4oHO Nr2v6jHS+PdbwixlEtW1deE3mEV5Qe6kH/ekqtXrFdHs3ZwkxqTbMdIz+ZeFvAyESqYk ThWYZGrNG4FTsGrmlOjXXKNhk3vnBvuN+WtIB5mrnint5WbrWYaVQI9g8qQImdrPMw8o ji6owLWvmukDTxuYoejCfMucAa9TlfKVotywtbcMDt1D7ele5BZHOeCAeMxY9aGD446+ Fk0ksUEHG7UZVyvY39gC9ATJhzjQ/cFnzhnS5Vz4ebBOQ2H3KKKSIiMRGFu9H1BXKvKN VxUA== 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=O9rHCpHlT0cH6+aopAFJtV3zpx8HFunYBPGdBa/1sfk=; b=WJiFe6j7ZeqivYnfsDb36SIl90aiCS79cq8a4lytimXxk1035Ak/+EgEgNWEKhVE67 9B3hYl/lxulsspE+zuq+znm91q8b7v9sFHZXIDlqYynW4Itq+fcctX3MKbOJ74huI2xO 5aYyuLtZ5vt8ezrnEEmIXZZ/UWMjZVTHQbgrRRFH9Ve8NLA/x510LilrzF+htQXahHlO ufY9CeeQJeyOzC3861Z6EozdDOIcgBEI1l+ByDZdv466gVEMfG0SIgIFgA+FvP6+FkcQ K75ABHSHhxRT3nJhtN7xac/h6czGxd737JhseoY2NOif29CV+tBNkXkB5rynjgu5XMsy 5v/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=R9fl76WU; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id n9si6583441pgu.602.2017.11.10.06.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=R9fl76WU; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 D3C0F21CEB12B; Fri, 10 Nov 2017 06:19:09 -0800 (PST) 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=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 B224E2035521F for ; Fri, 10 Nov 2017 06:19:07 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id b9so3109934wmh.0 for ; Fri, 10 Nov 2017 06:23:10 -0800 (PST) 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=KKbri4hWnPJ9Kh9/tzd5UCM6oboYaRITbQ/vW5IbZpA=; b=R9fl76WUEel40sxleSLWbaFqaIrOgX1TaDOlV5cyHLFHxPcrvwJpkQrjvzgdb8gXIk NZtzWnuRyP86aP64mN5tp8xAlgD4/gXooSNOGyqBB0jO43cLEjbJ1FqC3th3JyKAR/Rb wCC2TjOgakIq5UujPus0H9xHXgCSO9TKwa07w= 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=KKbri4hWnPJ9Kh9/tzd5UCM6oboYaRITbQ/vW5IbZpA=; b=brsm16nHPHgaOsp5jn4ad6VZzL5US1mBAZ3rc4Hgg5MdIcYWXs3M1fgNHk7UwLh9fc pgeoKEQnE1kq5Ljrmfpn8bEGIzZJyY884fmFye9FkTySINf6Imde2xI+agCpJ87U9g21 ZoAEKL06IKhtGlUtVw0dLrkTM85oGD9A8FJCgOcq4Dn2jJaLFQdmUhMUu+Py3ZR0zSsF s741O/9FtzJESBtTj1e432UIQfMXk5WAsTYJUAv7UsJ59x0Eo38/vxwznCkupfsPvmmQ sGOD7hn12vMvJtwzQXknu5FwPBEGy1BVaMw8D4MUqxv6zP6TE6g/TYUE0QPPQ++redm6 mtuQ== X-Gm-Message-State: AJaThX6uUPG+gKgtxe2ALtkXDHzhmnrof50AqgyhIWE3psF8jFwS4tGy bB7xwDZ1AQGmMuaP+Wh4a9tomxHmnrs= X-Received: by 10.28.175.73 with SMTP id y70mr402165wme.21.1510323789114; Fri, 10 Nov 2017 06:23:09 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:08 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:25 +0000 Message-Id: <20171110142127.12018-33-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 32/34] Platform/DeveloperBox: wire up RTC support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add the drivers, library resolutions and PCD settings to enable RTC support on DeveloperBox. Also, update PlatformDxe to register the non-discoverable device handles for both I2C controllers. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 8 ++- Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 5 ++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 76 +++++++++++++++++--- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 6 +- Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h | 8 +++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 4 ++ 6 files changed, 96 insertions(+), 11 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc index af978db2c034..cd4eb79b35bf 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -446,8 +446,7 @@ [Components.common] MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { - ## TODO - RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf + RealTimeClockLib|Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf } MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf @@ -623,3 +622,8 @@ [Components.common] MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf + + # + # I2C + # + Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf index 6cc523fac4f3..8443986fc3e7 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf @@ -229,6 +229,11 @@ [FV.FvMain] SECTION UI = "Pkcs7TestRoot" } + # + # I2C + # + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf + [FV.FVMAIN_COMPACT] FvAlignment = 16 BlockSize = 0x10000 diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c index 9639ffffc09f..070e6be92edd 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -62,27 +62,61 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mNetsecDesc[] = { } }; +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c0Desc[] = { + { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + SYNQUACER_I2C0_BASE, // AddrRangeMin + SYNQUACER_I2C0_BASE + SYNQUACER_I2C0_SIZE - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_I2C0_SIZE, // AddrLen + }, { + ACPI_END_TAG_DESCRIPTOR // Desc + } +}; + +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc[] = { + { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + SYNQUACER_I2C1_BASE, // AddrRangeMin + SYNQUACER_I2C1_BASE + SYNQUACER_I2C1_SIZE - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_I2C1_SIZE, // AddrLen + }, { + ACPI_END_TAG_DESCRIPTOR // Desc + } +}; + STATIC EFI_STATUS -RegisterNetsec ( - VOID +RegisterDevice ( + IN EFI_GUID *TypeGuid, + IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc, + OUT EFI_HANDLE *Handle ) { NON_DISCOVERABLE_DEVICE *Device; EFI_STATUS Status; - EFI_HANDLE Handle; Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device)); if (Device == NULL) { return EFI_OUT_OF_RESOURCES; } - Device->Type = &gNetsecNonDiscoverableDeviceGuid; + Device->Type = TypeGuid; Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent; - Device->Resources = mNetsecDesc; + Device->Resources = Desc; - Handle = NULL; - Status = gBS->InstallMultipleProtocolInterfaces (&Handle, + Status = gBS->InstallMultipleProtocolInterfaces (Handle, &gEdkiiNonDiscoverableDeviceProtocolGuid, Device, NULL); if (EFI_ERROR (Status)) { @@ -106,6 +140,7 @@ PlatformDxeEntryPoint ( EFI_STATUS Status; VOID *Dtb; UINTN DtbSize; + EFI_HANDLE Handle; Dtb = NULL; Status = DtPlatformLoadDtb (&Dtb, &DtbSize); @@ -118,5 +153,30 @@ PlatformDxeEntryPoint ( Status)); } - return RegisterNetsec (); + Handle = NULL; + Status = RegisterDevice (&gNetsecNonDiscoverableDeviceGuid, mNetsecDesc, + &Handle); + ASSERT_EFI_ERROR (Status); + + Handle = NULL; + Status = RegisterDevice (&gSynQuacerNonDiscoverableRuntimeI2cMasterGuid, + mI2c0Desc, &Handle); + ASSERT_EFI_ERROR (Status); + + // + // Install the PCF8563 I2C Master protocol on this handle so the RTC driver + // can identify it as the I2C master it can invoke directly, rather than + // through the I2C driver stack (which cannot be used at runtime) + // + Status = gBS->InstallProtocolInterface (&Handle, + &gPcf8563RealTimeClockLibI2cMasterProtolGuid, + EFI_NATIVE_INTERFACE, NULL); + ASSERT_EFI_ERROR (Status); + + Handle = NULL; + Status = RegisterDevice (&gSynQuacerNonDiscoverableI2cMasterGuid, mI2c1Desc, + &Handle); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; } diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf index 25e6248f1c61..478e0c7d33e9 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -29,6 +29,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -43,9 +44,12 @@ [LibraryClasses] [Guids] gFdtTableGuid gNetsecNonDiscoverableDeviceGuid + gSynQuacerNonDiscoverableI2cMasterGuid + gSynQuacerNonDiscoverableRuntimeI2cMasterGuid [Protocols] - gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES + gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES + gPcf8563RealTimeClockLibI2cMasterProtolGuid ## PRODUCES [FixedPcd] gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h index f29a35809bac..3c7bd58866cc 100644 --- a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h +++ b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h @@ -42,6 +42,14 @@ #define SYNQUACER_GPIO_BASE 0x51000000 #define SYNQUACER_GPIO_SIZE SIZE_4KB +// I2C0 block +#define SYNQUACER_I2C0_BASE 0x51200000 +#define SYNQUACER_I2C0_SIZE SIZE_4KB + +// I2C1 block +#define SYNQUACER_I2C1_BASE 0x51210000 +#define SYNQUACER_I2C1_SIZE SIZE_4KB + // eMMC(SDH30) #define SYNQUACER_EMMC_BASE 0x52300000 #define SYNQUACER_EMMC_BASE_SZ SIZE_4KB diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index 63c441872da7..38cb731f92cb 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -82,6 +82,10 @@ STATIC CONST ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = { ARM_CACHED_DEVICE_REGION (FixedPcdGet32 (PcdNetsecEepromBase), SYNQUACER_EEPROM_BASE_SZ), + // SynQuacer I2C + ARM_DEVICE_REGION (SYNQUACER_I2C0_BASE, SYNQUACER_I2C0_SIZE), + ARM_DEVICE_REGION (SYNQUACER_I2C1_BASE, SYNQUACER_I2C1_SIZE), + // SynQuacer NETSEC ARM_DEVICE_REGION (SYNQUACER_NETSEC1_BASE, SYNQUACER_NETSEC1_BASE_SZ), From patchwork Fri Nov 10 14:21:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118567 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260495edl; Fri, 10 Nov 2017 06:24:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMY22Hjq6hIQEbzmi1GWJTyi/ye1HjCvuLHqi1+7+fKOqzOzy8s4MfLNps+20WfKjGrjJ8HQ X-Received: by 10.98.110.73 with SMTP id j70mr566662pfc.146.1510323873128; Fri, 10 Nov 2017 06:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323873; cv=none; d=google.com; s=arc-20160816; b=uFQcmyXZDBfKBzRTBmmi0DQsBDlhYryuD5AF5hmi66P68wCVmmrVR8vnBOW+cmEYhh JBRyplGbRL6JcWpPedtMLfvUmHuCTPcaCXoRjzG8ncDVDsgMJbF4itx7+zCwgEkdqrpX 9MdM/apfKw+14AgCTE/kshSvOm6/weDxLFQFIW34yil9Rys5CRG/18VMVgzG70L45KXi SN1Tt6pOLB1vIHmNRcNsQD1QKmAdvfD9CP+dLGi79tRIr/RH13s68nAuuOicn4JlJLWR CXxWiad3HUFLlN2YnLHZF1PnUVXF/G6rn7wO+r9CsvrOh524Jhr9V2j5g+kECzwCRy/W XX8g== 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=7vovIjxNRRqYG8dQ4ctEyQbb7/zylKqJW/QPM+clPjo=; b=MmE2eTGGVYw6I3wDTWExgcVBjbuDxxdMAzF6OOCMMLNSqeaSYeQNIuJHivQbkFeJ0Y s5Ds9P3MKdz1dL6+FkvJLSOnpMWLAyhuR1S5heFjAR3MJGemg+57prgo+Ocye03N4xpZ zs2WWLBYgY262YlnucWd3SSuV0wxyqwykJldRpxZEjayNissUmM+VU6ovD3w4QKVdAiD X06ukMqKc1SViE/75v8aQa0Gp7khAvhwQ/5mUJdUHtIKAeaYlJ8mHxrgkGR8wFouteK7 9YMkVG/x2MXx7x3kNiOj7S42bFvrkYCoMciJQVodarBi8d65wupcjTqVtyUQmOxqHA+0 iFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=T7KStdbr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id p73si9628038pfi.83.2017.11.10.06.24.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=T7KStdbr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 1443C203555F4; Fri, 10 Nov 2017 06:19:11 -0800 (PST) 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=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 3F44A21C913BF for ; Fri, 10 Nov 2017 06:19:10 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id z3so3084937wme.5 for ; Fri, 10 Nov 2017 06:23:13 -0800 (PST) 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=NxxVmO3SpEVEBOoJpHdUhtAdYI4ZpKTp4/SmvO5j2+Y=; b=T7KStdbr0NVm0Sgut+LgP/MGY2bCphqc6ucrUfRNgycS6LtHk8OgqPCo1lqy7ZS0nk dKn5XGj6uIT61WvOltnkbtwQ2T82Bs0wh5sneyeBhYX5stNtyw4IvmC9ojIbt0sLLjTo +R/48FKCFWi1ahmbMAL7NjMpao/kG3pnwkOk4= 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=NxxVmO3SpEVEBOoJpHdUhtAdYI4ZpKTp4/SmvO5j2+Y=; b=Nk37Unh2o+YhwCNsjHZGtu0D3yELGlskhXLCyB4njkKEDg8S0XWKGA7Gfs8qB7Pze0 t3a011nScnyqG8qgPDDj6OnswiSkRFPTEyTOtllVw8DWW1D90xdztV4GmpCKJGhNb1nC ByAaJpQQISRuxNFxvme9f3xUxgxFKFyqz5uqJw9C5pEMi2cJlz/h7JRLHy5zcxBbgkMV 9BsJAKfhjgrC0pm9HZ5S89NKLWi+BKxggtX9/maCxx5rrDJZkq0wgzldCinM+04ZtJq3 sqItevMjSG/w0TuJlA8+i3YFRpop6R5W82oL1K0Vz9GHJ/R3rMmAq1RFip4w745FgKhW H6uA== X-Gm-Message-State: AJaThX4sD0zEZaMwfs/sZHNbluelcDnhci0UddbSpoYb3rcvF/H0hFRi YAkkiwoGz1AxTfViCcnSobYlAv0NBLQ= X-Received: by 10.28.185.196 with SMTP id j187mr350169wmf.97.1510323791655; Fri, 10 Nov 2017 06:23:11 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.23.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:10 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:26 +0000 Message-Id: <20171110142127.12018-34-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 33/34] Platform/DeveloperBox: add description of power button to DT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add the power button as a gpio-keys KEY_POWER button, and mark it as a wakeup source so it can be used under the OS both as a 'sleep' and as a 'wake' button. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.11.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/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts index 6ae7d5f300b6..d2cd7ef90e6f 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts +++ b/Silicon/Socionext/SynQuacer/DeviceTree/DeveloperBox.dts @@ -15,9 +15,23 @@ #include "SynQuacer.dtsi" +#define KEY_POWER 116 + / { model = "Socionext Developer Box"; compatible = "socionext,developer-box", "socionext,synquacer"; + + gpio-keys { + compatible = "gpio-keys"; + interrupt-parent = <&exiu>; + + power { + label = "Power Button"; + linux,code = ; + interrupts = ; + wakeup-source; + }; + }; }; &gpio { From patchwork Fri Nov 10 14:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118568 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2260594edl; Fri, 10 Nov 2017 06:24:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMbUlifmBcvSObpIYZlFCEcl8XuvvclyFA58b+fVu34nQDRd/0XFi/4RhY2VoWhnl8xLnw3t X-Received: by 10.98.217.17 with SMTP id s17mr593861pfg.2.1510323878463; Fri, 10 Nov 2017 06:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323878; cv=none; d=google.com; s=arc-20160816; b=GcCzmlIi7wLW736CKo1Dovynn4mgPKBB3BF4BeO19DdYK8TX9C0jgcCkqbhKntWI8Z ZHjDbBHRBwOF8JFiv//xyYBdL5qKlV+nGZkIF4s6n9JB0hEvTkkBl0memYzBDGma23MV rQGlr4CWQB61WRaWxaCzzCBlhvjagEw74M6pBJ4jSLWhXEoRUe5j088q5EKuHEs8dLCv 3R8OfcAzxCYjP+PStzCbNuc7r4hGVoKhkZpfAKtdAG8gsEQpT2gsHn7RoRJcVlj7r+zK c1eh2k8eW3Rk2DuZpK9nKZogTmaceC1eQnCxJ2/pRQyct4J/qiELzyO4EvK6ZuyvFg4k b2Iw== 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=wPdWKEQv0gLzYGgJ8g/JQ+GtNAXqFQqTkOiZVDvJ5AI=; b=ZnZA8ni0WWSNXTVzSBXlUtzrGkkDFwGKwwELjeYME8hc73aCGT87WTsAZcNuVYq/j3 40n5Px0OD4k6rVTeJy03lY0oeOED6wezRV2gc9EUq4e3svojuGzMrwobRYBNwZybNV8q 1oIaCtod/KmWmVHx/teEl0PuMgNMX600GjDGouJSpGGNOmklOr4qFldbRN0jdARYuy/k xFSC8MR0pFyK9i4obpHbMt8LVSfk6Cq4pVGJLJL005HRin+v0BP3rK9qRw0o9DyYdO5M Vi4crpOzp7duBdyaEMKrMegXP1P33qsw9clOOFCHm0gGwxWyEbouRz6OnbmsVOo//tLN e9yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Vz4rQ7sx; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id f190si8840654pgc.559.2017.11.10.06.24.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:24:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Vz4rQ7sx; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 4C32D220DB763; Fri, 10 Nov 2017 06:19:14 -0800 (PST) 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=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 8FF67220DB761 for ; Fri, 10 Nov 2017 06:19:12 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id j15so8736585wre.8 for ; Fri, 10 Nov 2017 06:23:15 -0800 (PST) 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=fbNX5zQuo/y2btChAzc7RgfpgHxOhmWRm+ykeqQbVEA=; b=Vz4rQ7sxyiJF+GNKItPHbP5Z/nIRmOcnaiwWCY/8nnG7OjiSD+cbjMN2BtLuJtWL90 vDrVAFf+YqXHoLogeUxjiVvrsihE3cuEb7zNYh5GVBnFmny+JlBOvmbAe/yt0ZwaWeqD eVKjL281XMYdaxmOISDfucXI3I4wYjEoJFp/8= 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=fbNX5zQuo/y2btChAzc7RgfpgHxOhmWRm+ykeqQbVEA=; b=U5PoXX4ndxIWKTGlLO29CjW9oYdx/iHiGDb1N3Tzyvnk78ZcSnNSEk4C2gfMfUN5DI 7z0HMcikybhavzM0sglBmqeH1/EvQXn6NsPwFmHN4qryZHzenME+45ytiF0NWS3eC881 V/1vb+DzVKsg+ywADsPv5aEX9ymQ39MGmE2N2t75o2BSG7jvh/fyJwxJJBtrcf8vpZ6B qXTuCE4nTdKaYpynKuwaelgpRzVBQUWRoZlJxHSu8aDWHkO8ARNfVvOgXEoUCGBuTsCk zCfUX3Pu1+s0ul4PYTpjmaH+teIDTght4IrNrfWS1qJpt12DFKN6XbTxxLbu7IfsdRPR OUeg== X-Gm-Message-State: AJaThX4Wd0eKQkC/XuDTrzvSgPmbtWt9qgE+QHOGId6M0QDhB+l0Q55X hXKIlrr7iW3X56OXhBbYV6S/zlhyBe8= X-Received: by 10.223.157.204 with SMTP id q12mr463776wre.241.1510323793786; Fri, 10 Nov 2017 06:23:13 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:23:13 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:27 +0000 Message-Id: <20171110142127.12018-35-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 34/34] Platform/SynQuacerEvalBoard: add eMMC driver stack X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add the drivers required to use the onboard eMMC on the SynQuacer Evaluation Board. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- NOTE: this depends on an upstream EDK2 change that is currently still under discussion Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 1 + Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 8 + Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 7 + Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c | 204 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 12 +- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h | 37 ++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 5 + 7 files changed, 266 insertions(+), 8 deletions(-) -- 2.11.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/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc index cd4eb79b35bf..1a09f727b31f 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -177,6 +177,7 @@ [LibraryClasses.common.DXE_DRIVER] # PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf + NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf [LibraryClasses.common.UEFI_APPLICATION] PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index 4034bcfe82c5..20b719794d06 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -176,6 +176,7 @@ [LibraryClasses.common.DXE_DRIVER] # PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf + NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf [LibraryClasses.common.UEFI_APPLICATION] PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf @@ -529,6 +530,13 @@ [Components.common] MdeModulePkg/Universal/EbcDxe/EbcDxe.inf # + # eMMC support + # + MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf + MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf + MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf + + # # AHCI Support # MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf index 4577bd316a1f..1599f8953008 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf @@ -149,6 +149,13 @@ [FV.FvMain] INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf # + # eMMC support + # + INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf + INF MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf + INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf + + # # AHCI Support # INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c new file mode 100644 index 000000000000..4c7713d78fa3 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c @@ -0,0 +1,204 @@ + /** @file + SynQuacer DXE platform driver - eMMC support + + Copyright (c) 2017, Linaro, Ltd. 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 "PlatformDxe.h" + +// F_SDH30 extended Controller registers +#define F_SDH30_AHB_CONFIG 0x100 +#define F_SDH30_AHB_BIGED BIT6 +#define F_SDH30_BUSLOCK_DMA BIT5 +#define F_SDH30_BUSLOCK_EN BIT4 +#define F_SDH30_SIN BIT3 +#define F_SDH30_AHB_INCR_16 BIT2 +#define F_SDH30_AHB_INCR_8 BIT1 +#define F_SDH30_AHB_INCR_4 BIT0 + +#define F_SDH30_TUNING_SETTING 0x108 +#define F_SDH30_CMD_CHK_DIS BIT16 + +#define F_SDH30_IO_CONTROL2 0x114 +#define F_SDH30_MSEL_O_1_8 BIT18 +#define F_SDH30_CRES_O_DN BIT19 + +#define F_SDH30_ESD_CONTROL 0x124 +#define F_SDH30_EMMC_RST BIT1 +#define F_SDH30_EMMC_HS200 BIT24 +#define F_SDH30_CMD_DAT_DELAY BIT9 + +#define F_SDH30_TUNING_SETTING 0x108 +#define F_SDH30_CMD_CHK_DIS BIT16 + +#define F_SDH30_IO_CONTROL2 0x114 +#define F_SDH30_MSEL_O_1_8 BIT18 +#define F_SDH30_CRES_O_DN BIT19 + +#define F_SDH30_ESD_CONTROL 0x124 +#define F_SDH30_EMMC_RST BIT1 +#define F_SDH30_EMMC_HS200 BIT24 +#define F_SDH30_CMD_DAT_DELAY BIT9 + +#define SD_HC_CLOCK_CTRL 0x2C +#define SYNQUACER_CLOCK_CTRL_VAL 0xBC01 + +#define SD_HC_CAP_SDR104 BIT33 + +#define ESD_CONTROL_RESET_DELAY (20 * 1000) +#define IO_CONTROL2_SETTLE_US 3000 + +STATIC EFI_HANDLE mSdMmcControllerHandle; + +/** + + Override function for SDHCI capability bits + + @param[in] ControllerHandle The EFI_HANDLE of the controller. + @param[in] Slot The 0 based slot index. + @param[in,out] SdMmcHcSlotCapability The SDHCI capability structure. + + @retval EFI_SUCCESS The override function completed successfully. + @retval EFI_NOT_FOUND The specified controller or slot does not exist. + @retval EFI_INVALID_PARAMETER SdMmcHcSlotCapability is NULL + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerSdMmcOverrideCapability ( + IN EFI_HANDLE ControllerHandle, + IN UINT8 Slot, + IN OUT VOID *SdMmcHcSlotCapability + ) +{ + UINT64 *Caps; + + ASSERT (ControllerHandle == mSdMmcControllerHandle); + ASSERT (Slot == 0); + + if (ControllerHandle != mSdMmcControllerHandle || Slot != 0) { + return EFI_NOT_FOUND; + } + + // + // Clear the SDR104 capability bit. This avoids the need for a HS200 tuning + // quirk that is difficult to support using the generic driver. + // + Caps = SdMmcHcSlotCapability; + *Caps &= ~(UINT64)SD_HC_CAP_SDR104; + + return EFI_SUCCESS; +} + +/** + + Override function for SDHCI controller operations + + @param[in] ControllerHandle The EFI_HANDLE of the controller. + @param[in] Slot The 0 based slot index. + @param[in,out] HookType The type of operation and whether the + hook is invoked right before (pre) or + right after (post) + + @retval EFI_SUCCESS The override function completed successfully. + @retval EFI_NOT_FOUND The specified controller or slot does not exist. + @retval EFI_INVALID_PARAMETER HookType is invalid + +**/ +STATIC +EFI_STATUS +EFIAPI +SynQuacerSdMmcInvokeHook ( + IN EFI_HANDLE ControllerHandle, + IN UINT8 Slot, + IN SD_MMC_OVERRIDE_HOOK HookType + ) +{ + ASSERT (ControllerHandle == mSdMmcControllerHandle); + ASSERT (Slot == 0); + + if (ControllerHandle != mSdMmcControllerHandle || Slot != 0) { + return EFI_NOT_FOUND; + } + + switch (HookType) { + case SD_MMC_OVERRIDE_RESET_PRE_HOOK: + // Soft reset does not complete unless the clock is already enabled. + MmioWrite16 (SYNQUACER_EMMC_BASE + SD_HC_CLOCK_CTRL, + SYNQUACER_CLOCK_CTRL_VAL); + break; + + case SD_MMC_OVERRIDE_INIT_HOST_PRE_HOOK: + // init vendor specific regs + MmioAnd16 (SYNQUACER_EMMC_BASE + F_SDH30_AHB_CONFIG, + ~(F_SDH30_AHB_BIGED | F_SDH30_BUSLOCK_EN)); + + MmioOr16 (SYNQUACER_EMMC_BASE + F_SDH30_AHB_CONFIG, + F_SDH30_SIN | F_SDH30_AHB_INCR_16 | F_SDH30_AHB_INCR_8 | + F_SDH30_AHB_INCR_4); + + MmioAnd32 (SYNQUACER_EMMC_BASE + F_SDH30_ESD_CONTROL, ~F_SDH30_EMMC_RST); + MemoryFence (); + gBS->Stall (ESD_CONTROL_RESET_DELAY); + + MmioOr32 (SYNQUACER_EMMC_BASE + F_SDH30_ESD_CONTROL, + F_SDH30_EMMC_RST | F_SDH30_CMD_DAT_DELAY | F_SDH30_EMMC_HS200); + + gBS->Stall (IO_CONTROL2_SETTLE_US); + MmioOr32 (SYNQUACER_EMMC_BASE + F_SDH30_IO_CONTROL2, F_SDH30_CRES_O_DN); + MemoryFence (); + MmioOr32 (SYNQUACER_EMMC_BASE + F_SDH30_IO_CONTROL2, F_SDH30_MSEL_O_1_8); + MemoryFence (); + MmioAnd32 (SYNQUACER_EMMC_BASE + F_SDH30_IO_CONTROL2, ~F_SDH30_CRES_O_DN); + MemoryFence (); + gBS->Stall (IO_CONTROL2_SETTLE_US); + + MmioOr32 (SYNQUACER_EMMC_BASE + F_SDH30_TUNING_SETTING, + F_SDH30_CMD_CHK_DIS); + break; + + default: + break; + } + return EFI_SUCCESS; +} + +STATIC SD_MMC_OVERRIDE mSdMmcOverride = { + EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION, + SynQuacerSdMmcOverrideCapability, + SynQuacerSdMmcInvokeHook, +}; + +EFI_STATUS +EFIAPI +RegisterEmmc ( + VOID + ) +{ + EFI_STATUS Status; + + Status = RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeSdhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + &mSdMmcControllerHandle, + 1, + SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->InstallProtocolInterface (&mSdMmcControllerHandle, + &gEdkiiSdMmcOverrideProtocolGuid, + EFI_NATIVE_INTERFACE, (VOID **)&mSdMmcOverride); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c index 070e6be92edd..c64ccf3b3c30 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -12,14 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include -#include -#include -#include -#include -#include -#include -#include +#include "PlatformDxe.h" STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mNetsecDesc[] = { { @@ -178,5 +171,8 @@ PlatformDxeEntryPoint ( &Handle); ASSERT_EFI_ERROR (Status); + Status = RegisterEmmc (); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h new file mode 100644 index 000000000000..e653d72d537c --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h @@ -0,0 +1,37 @@ +/** @file + SynQuacer DXE platform driver. + + Copyright (c) 2017, Linaro, Ltd. 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. +**/ + +#ifndef __PLATFORM_DXE_H__ +#define __PLATFORM_DXE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +RegisterEmmc ( + VOID + ); + +#endif diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf index 478e0c7d33e9..8af79eeaa4bc 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -23,6 +23,7 @@ [Defines] ENTRY_POINT = PlatformDxeEntryPoint [Sources] + Emmc.c PlatformDxe.c [Packages] @@ -34,10 +35,13 @@ [Packages] Silicon/Socionext/SynQuacer/SynQuacer.dec [LibraryClasses] + BaseLib BaseMemoryLib DebugLib DtPlatformDtbLoaderLib + IoLib MemoryAllocationLib + NonDiscoverableDeviceRegistrationLib UefiBootServicesTableLib UefiDriverEntryPoint @@ -49,6 +53,7 @@ [Guids] [Protocols] gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES + gEdkiiSdMmcOverrideProtocolGuid ## PRODUCES gPcf8563RealTimeClockLibI2cMasterProtolGuid ## PRODUCES [FixedPcd]