From patchwork Fri Feb 23 15:40:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129391 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744694lja; Fri, 23 Feb 2018 07:41:11 -0800 (PST) X-Google-Smtp-Source: AH8x227eDlO7iuHJgWSLBai2a/K1SarZEs0dDFV3zZy+HSzXiqbOfciVyRrcTFcsEs5zhlKh0Uwb X-Received: by 10.99.121.140 with SMTP id u134mr1731020pgc.89.1519400471125; Fri, 23 Feb 2018 07:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400471; cv=none; d=google.com; s=arc-20160816; b=S5zP7eZwPl76q2Odes5wYdtFgoBtxCgLIzOHYrbvos5cAw5xWV7zMkC9xImky79fak OPBJKtn2IC1NU0gp5sp3rYdX/T8vC/28wEVV7LLraw0Lbs8+2qZbFKh3Ulw3UW6GuhS7 YNZjgQ1Jgwwi0M7xYgIgWS6JcSGcc2k5GxQEnYEUJ1e3EZT4NIaPcE9o4XC8i5MUn8IB Ge+Bl64hst+V8OyZ4UEL0J0N39KGh1KN+3bCn2Sx5wWEdENTji8p2tXrUSk85X+9oaTi 4rCdm2h4b0Sq3tpYtgLRBjaswSa8o7ECztSAJt340Nih5LBvlwUtb5J64zfE30u+nRLv qTZg== 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=QbeIuKnSkyuRmCGjx/RGVidZvAo9kZ6fXg/UsjmvOtE=; b=O0LcghhNbHsxvDHEy2syuFzaEl4cbGt5oDqCS+hCvOJp98/KoXyWsP/SqdRTeGI3vf P9L9eVvJBEsQIUgIA2GJq0MhhWnGVVrWrtV17R9QfwjN0mYdDoO4P1seRUI6yh8a6Tmd gAHctoP6O1OwJ43J3WSDrpvt6Ou1cxnBb3hBPn17jRo+EiNFPYmFYKAw+moMo4mK0u3l VoEUw7NDQHtYAwjZOJQu7xuoTBxk7uiyHXsc8fgtI/mBFBzceKBWfqZT3B/5MtLaC1Cc 2fyTWxr62hPnh/nq0Z1NrljLc5l91iecLUruQYyUzwvCKYsd9rDdQXYOk26vOkrwTQ1F fA4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=agAEewbj; 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 q11-v6si1915809pll.379.2018.02.23.07.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:11 -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=agAEewbj; 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 97E1B21FD73D3; Fri, 23 Feb 2018 07:35: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::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 6563C22436956 for ; Fri, 23 Feb 2018 07:35:06 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id z12so14544783wrg.4 for ; Fri, 23 Feb 2018 07:41:08 -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=WP8isaFUCyJo3H6KltEq48RI1meTjpK28QPXUtYoI9Y=; b=agAEewbjfxnMkP255bW3CK7hrRXFPXZV7vtC5D8rI7YZzUg8V1ArVMq/p8y0Behrm9 1RlDVXyz0WwiIlnU+eLWmh5DDvUyM9lJs/ufm72XMuvqTl/CFGHkHfpBUAq2YOPy5nxb pfx9+glswlWq9cG0rzpe1JB0A/t2LeAYkHp4k= 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=WP8isaFUCyJo3H6KltEq48RI1meTjpK28QPXUtYoI9Y=; b=btV+UuCYwr8aSqc7WHlQ302/oGs6XYOkOCFFSgmfh8IuH++U+xTEI+zoaTZWlDlnnS UaxLcghByN8mZslqj1QYJEt7lkyOGzPf6j2eLtC9/FcEqMGsJNnSPN4OxqIP9LH85Hbd hpwhzlcVYDthK8idtPDZsVSup3gIMRSkUQmrIJ4DpDx5uPpH8awjgOkR6opKmbeE3DnS sTt1glZWROJCOYAeOGQwr4adiB84AKA149ZtnpkRofHN5GWZG797cIeEbqWAiKKhzZNB ZfLghvqiXAtG+vU2oQ01IhVBiUnfu6aieBNF9Ah9HgPHiupbMT2EDJ6RBypGLGUNQw1Y D/0A== X-Gm-Message-State: APf1xPC1OviAKRY+Wby49/f9hcQEOLua13R/RyEp7gDNW93YViQkFF2Z 15Lr65VO3bfxR7M5ulbydRQ8vzErXiI= X-Received: by 10.223.160.42 with SMTP id k39mr2236574wrk.138.1519400466562; Fri, 23 Feb 2018 07:41:06 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:05 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:47 +0000 Message-Id: <20180223154052.9828-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Introduce the mezzanine protocol and the 96Boards package defining the PCDs and GUIDs that may be used by implementations of the protocol. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/96Boards.dec | 67 ++++++++++++++++++ Platform/96Boards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++ 2 files changed, 138 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/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec new file mode 100644 index 000000000000..2a063ced9e4a --- /dev/null +++ b/Platform/96Boards/96Boards.dec @@ -0,0 +1,67 @@ +## @file +# +# Copyright (c) 2018, 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 = 96Boards + PACKAGE_GUID = ce4a4683-6e2d-4ec3-bc11-974289a09ab0 + PACKAGE_VERSION = 0.1 + +[Includes] + Include + +[Protocols] + ## Include/Protocol/Mezzanine.h + g96BoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } } + +[Guids] + # PCD scope GUID + g96BoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } } + + # GUIDs to be installed as protocols to identify which controller connects to which bus + g96BoardsI2c0MasterGuid = { 0xba10e402, 0xcfdd, 0x4b87, { 0xbd, 0x02, 0x6e, 0x26, 0x9f, 0x01, 0x94, 0x11 } } + g96BoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } } + g96BoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } } + +[PcdsFixedAtBuild] + # ASCII DT paths to the I2C parent nodes of the 96boards LS connector + g96BoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001 + g96BoardsTokenSpaceGuid.PcdI2c1Parent|""|VOID*|0x00000002 + + # I2C bus frequency in Hertz + g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|0|UINT32|0x00000003 + g96BoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz|0|UINT32|0x00000004 + + # ASCII DT path to the SPI parent node of the 96boards LS connector + g96BoardsTokenSpaceGuid.PcdSpiParent|""|VOID*|0x00000005 + + # ASCII DT path to the GPIO parent node of the 96boards LS connector + g96BoardsTokenSpaceGuid.PcdGpioParent|""|VOID*|0x00000006 + + # Polarity of the 96boards LS connector GPIOs (0 == GPIO_ACTIVE_HIGH, 1 == GPIO_ACTIVE_LOW) + g96BoardsTokenSpaceGuid.PcdGpioPolarity|0|UINT32|0x00000007 + + # Pin numbers of the 96boards LS connector GPIOs + g96BoardsTokenSpaceGuid.PcdGpioPinA|0|UINT32|0x00000010 + g96BoardsTokenSpaceGuid.PcdGpioPinB|0|UINT32|0x00000011 + g96BoardsTokenSpaceGuid.PcdGpioPinC|0|UINT32|0x00000012 + g96BoardsTokenSpaceGuid.PcdGpioPinD|0|UINT32|0x00000013 + g96BoardsTokenSpaceGuid.PcdGpioPinE|0|UINT32|0x00000014 + g96BoardsTokenSpaceGuid.PcdGpioPinF|0|UINT32|0x00000015 + g96BoardsTokenSpaceGuid.PcdGpioPinG|0|UINT32|0x00000016 + g96BoardsTokenSpaceGuid.PcdGpioPinH|0|UINT32|0x00000017 + g96BoardsTokenSpaceGuid.PcdGpioPinI|0|UINT32|0x00000018 + g96BoardsTokenSpaceGuid.PcdGpioPinJ|0|UINT32|0x00000019 + g96BoardsTokenSpaceGuid.PcdGpioPinK|0|UINT32|0x0000001A + g96BoardsTokenSpaceGuid.PcdGpioPinL|0|UINT32|0x0000001B diff --git a/Platform/96Boards/Include/Protocol/Mezzanine.h b/Platform/96Boards/Include/Protocol/Mezzanine.h new file mode 100644 index 000000000000..9847649d2ac3 --- /dev/null +++ b/Platform/96Boards/Include/Protocol/Mezzanine.h @@ -0,0 +1,71 @@ +/** @file + + Copyright (c) 2018, 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 _96BOARDS_MEZZANINE_H_ +#define _96BOARDS_MEZZANINE_H_ + +#include +#include + +#define MEZZANINE_PROTOCOL_GUID \ + { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } } + +typedef struct _MEZZANINE_PROTOCOL MEZZANINE_PROTOCOL; + +/** + Apply the mezzanine's DT overlay + + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance. + @param[in,out] Dtb Pointer to the device tree blob + + @return EFI_SUCCESS Operation succeeded. + @return other An error has occurred. +**/ +typedef +EFI_STATUS +(EFIAPI *APPLY_DEVICE_TREE_OVERLAY) ( + IN MEZZANINE_PROTOCOL *This, + IN OUT VOID *Dtb + ); + +struct _MEZZANINE_PROTOCOL { + // + // Get the device tree overlay for this mezzanine board + // + APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay; + // + // The number of devices on LS connector I2C bus #0 + // + UINT32 I2c0NumDevices; + // + // The number of devices on LS connector I2C bus #1 + // + UINT32 I2c1NumDevices; + // + // Linear array of I2C devices on LS connector bus #0 + // + CONST EFI_I2C_DEVICE *I2c0DeviceArray; + // + // Linear array of I2C devices on LS connector bus #0 + // + CONST EFI_I2C_DEVICE *I2c1DeviceArray; + // + // NULL terminated linked list of SPI devices attached to the LS connector + // + CONST EFI_SPI_PERIPHERAL *SpiDeviceLinkedList; +}; + +extern EFI_GUID g96BoardsMezzanineProtocolGuid; + +#endif // _96BOARDS_MEZZANINE_H_ From patchwork Fri Feb 23 15:40:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129392 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744751lja; Fri, 23 Feb 2018 07:41:13 -0800 (PST) X-Google-Smtp-Source: AH8x227vTulcNaEfzJP4O65mA1HTESBxKs/l38ved1w5gVI/uCAYKcMXxKCvS7r/ZsiyA1YeMAMl X-Received: by 2002:a17:902:8d81:: with SMTP id v1-v6mr2091720plo.430.1519400473560; Fri, 23 Feb 2018 07:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400473; cv=none; d=google.com; s=arc-20160816; b=nDxyX6nveG6MjMSmB02+dThl34zBsrN+N9mpoK95REV8/92EfToYZCMLTh4eDIp2P4 7uwkEp38JmCp1TzpGlLaFE9wjKN9R4td8+3eULsQ0jPZY23mjFNLXhGnNlGZBGt46oOg 8kYa6TKXFDQWFGJicHUNhi5qIH978fDh7pCqDL6L98dFmKOP76I54B01h/YhSJZqzHtd xkoCFLlxec3fNlcIJ7L8qz7pwPFWjC2l5EhDXE4DP0u3pHbOZ8xklwP3tJMs5lNeUcL+ Z0GcbHdmXBmQ89MHivHpnmBbiQJMB4dX7wHF4f2ami5c7Vxc/mlh7rJUHVax9HLNy1iu HGPA== 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=4p01IR51UChvJizG9jWJLCUJMPD9GXyTHQL0BxY7WM8=; b=KLk4CNQvL2lJ2n89rvx5JCZhOrQ1a7x9dXj82P0S/zNf704J+Is3cgsFZ/OmZ1hTbB iiWjjrgiBmxCPySavw/QDrIUlEmotHfK1glFCHeS/mCWYSlArA6uHViULqiW685DzEF6 uhnJS5AhduzCdCjf8UEmO2LxR/pKpiPBfZJ0w844h+M77Amttwoi/Pdx7DfWtFckpx+3 +QmcOOov1DtfFRKlfDp/PIe9T10Zi3zCqvYu23Ag+4Nha6134tJGKom5qh6DBdilJ5xp tCg+dS6vJxBQPTa/sKn+Fe4FsYKov2rnbLDsNioPDCbutl2hIgUizBRb8IYGf1ItXByh ZLUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Rr2x1aN6; 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 k186si1659380pgc.15.2018.02.23.07.41.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:13 -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=Rr2x1aN6; 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 0811721CB2E20; Fri, 23 Feb 2018 07:35: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::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 E1EEA21FD73D5 for ; Fri, 23 Feb 2018 07:35:08 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id t3so5430089wmc.2 for ; Fri, 23 Feb 2018 07:41: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=ezIbCjg3eKOeXdPeiOG39Q3U8uY4SEqaumdSAPCAp5Y=; b=Rr2x1aN6DagSrIcJSeWj/LT2PJ6OwuM2eksB4ACwDdAT3aH4OKGBgFwC182VHlgA94 Xb/qXObOG4zEIToR6z+hl5HugS2SltnBU+CMQ5MhK9YwhmVUdR3Ki12g2y/Pvhe3X5mr vxRdaCRkI6b11iGlKQynxkgIVzPc0IeEimnHU= 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=ezIbCjg3eKOeXdPeiOG39Q3U8uY4SEqaumdSAPCAp5Y=; b=LMUIq/p+d4I1psn9nxZyams+uzlbYsAUWSNpsZPArOfaigbLfm9FE6ADLI9mNatICu 3Mqo0hx2iFkFVSUh1GWhxlugncYVmBhITLE6DE0iBG+fpVod8QtEYq91Ll4hHxcCpsXo 1Fk19JvEaKZWI2AvCg33exaJkwCEK+EJrjHUxyhvkwCaEO9PANrZ4oJaEgckplBgggof e3wOYZX+w24iyii6m7HnkLSexi0EyIghveWccWPMng4IFm12R1hkTjmHXSn479SMKq0m 7xRsZl5PxJ7XPf1HGx1I8lDz0b188gDgM3YUJkWFMsYyBOQMvG2V/YaQV8ujMwrJrBAH Xl0A== X-Gm-Message-State: APf1xPBw9qSExXMjICnHeHCcHn72MkLUASPvbdQRY1tDYiAdKKJoDQgu YpjDmXE2SPk/LXVlXCS7QBpdEvGeoII= X-Received: by 10.28.30.130 with SMTP id e124mr2204734wme.153.1519400468616; Fri, 23 Feb 2018 07:41:08 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:07 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:48 +0000 Message-Id: <20180223154052.9828-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 2/6] Platform/96Boards: introduce I2C driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement a I2C DXE driver that wires up the I2C devices exposed by a 96boards mezzanine into the EDK2 I2C stack. Note that this requires the platform to identify its I2C master implementations using special GUIDs-as-protocols. It also assumes [for now] that I2C buses are not shared between the 96boards connector and other platform peripherals. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c | 206 ++++++++++++++++++++ Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf | 51 +++++ 2 files changed, 257 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/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c new file mode 100644 index 000000000000..79bb9ed5ffee --- /dev/null +++ b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c @@ -0,0 +1,206 @@ +/** @file + + Copyright (c) 2018, 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 + +STATIC MEZZANINE_PROTOCOL *mMezzanine; + +typedef struct { + EFI_I2C_ENUMERATE_PROTOCOL I2cEnumerate; + EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL I2cConfigManagement; + EFI_HANDLE I2cMasterHandle; + UINT32 BusFrequency; + UINTN NumDevices; + CONST EFI_I2C_DEVICE *Devices; +} I2C_BUS; + +STATIC +EFI_STATUS +EFIAPI +I2cEnumerate ( + IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This, + IN OUT CONST EFI_I2C_DEVICE **Device + ) +{ + I2C_BUS *Bus; + + if (Device == NULL) { + return EFI_INVALID_PARAMETER; + } + + Bus = BASE_CR (This, I2C_BUS, I2cEnumerate); + + if (Bus->NumDevices == 0 || + (Bus->NumDevices > 0 && *Device == &Bus->Devices[Bus->NumDevices - 1])) { + *Device = NULL; + } else if (*Device == NULL) { + *Device = &Bus->Devices[0]; + } else if (Bus->NumDevices > 1 && + *Device >= &Bus->Devices[0] && + *Device < &Bus->Devices[Bus->NumDevices - 1]) { + ++*Device; + } else { + return EFI_NO_MAPPING; + } + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +EFIAPI +I2cGetBusFrequency ( + IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This, + IN UINTN I2cBusConfiguration, + OUT UINTN *BusClockHertz + ) +{ + I2C_BUS *Bus; + + if (BusClockHertz == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (I2cBusConfiguration > 0) { + return EFI_NO_MAPPING; + } + + Bus = BASE_CR (This, I2C_BUS, I2cEnumerate); + + *BusClockHertz = Bus->BusFrequency; + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +EFIAPI +EnableI2cBusConfiguration ( + IN CONST EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *This, + IN UINTN I2cBusConfiguration, + IN EFI_EVENT Event OPTIONAL, + IN EFI_STATUS *I2cStatus OPTIONAL + ) +{ + EFI_I2C_MASTER_PROTOCOL *I2cMaster; + EFI_STATUS Status; + UINTN BusClockHertz; + I2C_BUS *Bus; + + if (I2cBusConfiguration > 0) { + return EFI_NO_MAPPING; + } + + Bus = BASE_CR (This, I2C_BUS, I2cConfigManagement); + + Status = gBS->HandleProtocol (Bus->I2cMasterHandle, + &gEfiI2cMasterProtocolGuid, (VOID **)&I2cMaster); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: gBS->HandleProtocol() failed - %r\n", + __FUNCTION__, Status)); + return Status; + } + + BusClockHertz = Bus->BusFrequency; + Status = I2cMaster->SetBusFrequency (I2cMaster, &BusClockHertz); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: I2cMaster->SetBusFrequency() failed - %r\n", + __FUNCTION__, Status)); + return Status; + } + + if (Event != NULL) { + *I2cStatus = EFI_SUCCESS; + gBS->SignalEvent (Event); + } + return EFI_SUCCESS; +} + +STATIC I2C_BUS mI2cBus0 = { + { I2cEnumerate, I2cGetBusFrequency }, + { EnableI2cBusConfiguration }, + NULL, + FixedPcdGet32 (PcdI2c0BusFrequencyHz), + 0, + NULL, +}; + +STATIC I2C_BUS mI2cBus1 = { + { I2cEnumerate, I2cGetBusFrequency }, + { EnableI2cBusConfiguration }, + NULL, + FixedPcdGet32 (PcdI2c1BusFrequencyHz), + 0, + NULL, +}; + +STATIC +VOID +RegisterI2cBus ( + IN EFI_GUID *Guid, + IN I2C_BUS *I2cBus, + IN UINTN NumDevices, + IN CONST EFI_I2C_DEVICE *Devices + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + + BufferSize = sizeof (EFI_HANDLE); + Status = gBS->LocateHandle (ByProtocol, Guid, NULL, &BufferSize, + &I2cBus->I2cMasterHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: gBS->LocateHandle() failed - %r\n", __FUNCTION__, + Status)); + return; + } + + I2cBus->NumDevices = NumDevices; + I2cBus->Devices = Devices; + + Status = gBS->InstallMultipleProtocolInterfaces (&I2cBus->I2cMasterHandle, + &gEfiI2cEnumerateProtocolGuid, + &I2cBus->I2cEnumerate, + &gEfiI2cBusConfigurationManagementProtocolGuid, + &I2cBus->I2cConfigManagement, + NULL); + ASSERT_EFI_ERROR (Status); +} + +EFI_STATUS +EFIAPI +EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, + (VOID **)&mMezzanine); + ASSERT_EFI_ERROR (Status); + + RegisterI2cBus (&g96BoardsI2c0MasterGuid, &mI2cBus0, + mMezzanine->I2c0NumDevices, mMezzanine->I2c0DeviceArray); + RegisterI2cBus (&g96BoardsI2c1MasterGuid, &mI2cBus1, + mMezzanine->I2c1NumDevices, mMezzanine->I2c1DeviceArray); + + return EFI_SUCCESS; +} diff --git a/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf new file mode 100644 index 000000000000..7eb1fc503062 --- /dev/null +++ b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf @@ -0,0 +1,51 @@ +## @file +# +# Copyright (c) 2018, 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 = 96BoardsI2cDxe + FILE_GUID = a59176bc-a151-49c8-b54a-b4ac96f436c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 0.1 + ENTRY_POINT = EntryPoint + +[Sources] + 96BoardsI2cDxe.c + +[Packages] + MdePkg/MdePkg.dec + Platform/96Boards/96Boards.dec + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + g96BoardsMezzanineProtocolGuid ## CONSUMES + gEfiI2cBusConfigurationManagementProtocolGuid ## PRODUCES + gEfiI2cEnumerateProtocolGuid ## PRODUCES + gEfiI2cMasterProtocolGuid ## CONSUMES + +[Guids] + g96BoardsI2c0MasterGuid + g96BoardsI2c1MasterGuid + +[FixedPcd] + g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz + g96BoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz + +[Depex] + g96BoardsMezzanineProtocolGuid AND g96BoardsI2c0MasterGuid OR g96BoardsI2c1MasterGuid From patchwork Fri Feb 23 15:40:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129393 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744798lja; Fri, 23 Feb 2018 07:41:16 -0800 (PST) X-Google-Smtp-Source: AH8x224XtRzKfPFaqAm35bFlNA2fkA9DERJX5dnI3qevWTOIC+eTs3f+ZLGMPtjs9SrupwrlDop/ X-Received: by 10.99.110.201 with SMTP id j192mr1782490pgc.59.1519400476116; Fri, 23 Feb 2018 07:41:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400476; cv=none; d=google.com; s=arc-20160816; b=UGaGveFDTLstP7U8BQ6a504mgZP6Pk0r0L/zbtEgpShvN1nOh8YJlwJz4tVlHfcI47 YsDa4To/o0rgr+PIn8TuFtQmq3DKyp9VD15NB0VOALoFXSDdFzkH8CN5HpzfRfuNm6g9 mtN8POY0hyoUNHQ14nGQbrW451ry8/7WpHhr7KQQl31wE+G2t0nChTUlza/NZKTsRlZM mJIn2VeM0RGzArHQTngEa0WkWyhLHjkOd0aJRXKpBcRVrKG+VzHKo/3eZ6UI7u7S6wG0 dqzBVH/fexRR80EI5C2SoBHWjHD4Yk4DTt2F9p6Z9ULeAE7hiQnZZXm2T2QRJuPFMP0t Ldnw== 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=+cVN9q3Dq9XwVmXRrZRvTG3ARolq3Bx0/iWt3fgrsZU=; b=sgzsqCR0Sei0i0I7b9tSePZizvt+YabTy7ImfAu4rdq8dvWOVLK/jYhhKEAeiY6GUO W0awlMZgv6ms6aJbxUE9wMaCykJXoat6jXoNo4oHMhiBK/ft7hntttpfnQZTumK/tJ7X svcmTonIs7deR7qT+Gi6Cs+OYpsj3d9fxt9QeWp1MICZ1n0wob8SoaSibQOsPdirQ3AB uHa6SLvavImG3w3vl3bNGfQFsxuhiiWIW3YPQa561t4v0DFpZgJ5KL0XQTyzz/3koMyV dU4AGOWKt2O0324UTNg83tkCrijc4G72sJkNYggKRajjR6mP0S4C+qQ2N367H8dC0Ajo jr/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EkswKVmh; 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 c65si1986792pfa.93.2018.02.23.07.41.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41: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=EkswKVmh; 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 74C162034D8C0; Fri, 23 Feb 2018 07:35:13 -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 0B5C222436933 for ; Fri, 23 Feb 2018 07:35:10 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id h21so5436516wmd.1 for ; Fri, 23 Feb 2018 07:41: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=4Rg4HMMBdKtQJNcQPemOPJpIwYs84FKabT7dWWptgZI=; b=EkswKVmhUiZcFmxqEQs356ElpDbSrTPAOA9KksWLv59ePiyzHplaCL0G49RMxPJTWJ q8fLnkpuYrbkwPDSTdPlx/SZFBVAOycLe0KOXMj/cJ98242ydojVY3XBcruNjymZ8d+e dPljmC6Zaxb1m8Dm1YePXi3d+VHLxYzawWERE= 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=4Rg4HMMBdKtQJNcQPemOPJpIwYs84FKabT7dWWptgZI=; b=GbPa89RDpWjZeoF4XP7D1WEXKVeOeS9Hnj2E7rIc3b1QW9z3vQbI3y0UVjAt+r53bv IgRi0qNpL5x7lsA7ZZutSZk9AhcXKaB3bFil2Nao6EjtzHqInBTSqUvGnT7R4J0tLn06 LFoAALQZFFobd93i2JGf9imPdfuvug3RFb3BAk9AgVGozfkCAO5YkAAHvUPjWy070I8P +74kzqHESNahu84FY1BjDxptw5hg5i0zRxAjx3xlCu3DbhKcoxvirZQyfz85AD+B33vc Xqa1/akBdGGtI2xTGhZksPgJq9prnruQM9k/otzI98j8eMRbZ8dcBreKYsf/R0TpnXbE 6+cg== X-Gm-Message-State: APf1xPAWOv9MLCZYMVEWgjNaT3qtRLoM8nNmdITg6jXWaX/qTn9RXIx4 gQXiZsJELV5b8bw6iDvpkBH3Ef9DFmU= X-Received: by 10.28.232.16 with SMTP id f16mr2259139wmh.92.1519400470315; Fri, 23 Feb 2018 07:41:10 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:09 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:49 +0000 Message-Id: <20180223154052.9828-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 3/6] Platform/96Boards: introduce LsConnector protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Introduce a protocol describing the presence of a 96boards low speed (LS) connector, and identifying the type of mezzanine that has been installed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/96Boards.dec | 3 ++ Platform/96Boards/Include/Protocol/LsConnector.h | 35 ++++++++++++++++++++ 2 files changed, 38 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/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec index 2a063ced9e4a..fa8e639b1a11 100644 --- a/Platform/96Boards/96Boards.dec +++ b/Platform/96Boards/96Boards.dec @@ -25,6 +25,9 @@ [Protocols] ## Include/Protocol/Mezzanine.h g96BoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } } + ## Include/Protocol/LsConnector.h + g96BoardsLsConnectorProtocolGuid = { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } } + [Guids] # PCD scope GUID g96BoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } } diff --git a/Platform/96Boards/Include/Protocol/LsConnector.h b/Platform/96Boards/Include/Protocol/LsConnector.h new file mode 100644 index 000000000000..f337cfe0f709 --- /dev/null +++ b/Platform/96Boards/Include/Protocol/LsConnector.h @@ -0,0 +1,35 @@ +/** @file + + Copyright (c) 2018, 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 _LS_CONNECTOR_H_ +#define _LS_CONNECTOR_H_ + +#define LS_CONNECTOR_PROTOCOL_GUID \ + { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } } + +typedef struct _LS_CONNECTOR_PROTOCOL LS_CONNECTOR_PROTOCOL; + +typedef enum { + MezzanineUnknown, + MezzanineSecure96, + MezzanineMax +} MEZZANINE_TYPE; + +struct _LS_CONNECTOR_PROTOCOL { + MEZZANINE_TYPE MezzanineType; +}; + +extern EFI_GUID g96BoardsLsConnectorProtocolGuid; + +#endif // _LS_CONNECTOR_H_ From patchwork Fri Feb 23 15:40:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129394 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744851lja; Fri, 23 Feb 2018 07:41:19 -0800 (PST) X-Google-Smtp-Source: AH8x227s0kPM40GpFmisz7q2xXaUmBDKpzK6OzLDy8NmPklyMoFMXMlCGOUW1ERixTDB+ZuDuSqi X-Received: by 2002:a17:902:6b88:: with SMTP id p8-v6mr2038236plk.261.1519400478868; Fri, 23 Feb 2018 07:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400478; cv=none; d=google.com; s=arc-20160816; b=Z0LY1KuK5m1gsIOWfgRzjx6D0LEHlR29thbGL6Ll9Yrzq8FXPzsKcWLS9u3KpHjW5p 0PfEW2h+inbKfdHoWM/aftLGC2GwUtxTVbSxZul4ZGn/Y8OdhidHV2baO0sewmI241uN Bn0W9DexjzzWGyHwA2tbl1C3+1/fcDVMFGgrCcNlTaSO7w8uNsVxueCx9mu/ahWvq2Rk jEWhnHpR2DiPpNk2/5GLQkvtWkTzV+XLCoZvkB/PaDGpUBjr4eSmyXTmu54YlZ+D69H3 p/BSoE88RHifnM2JFtTL7u5otGWKIKKFlcVWEgpU2wW+c8XFsQxWw0LvbiIoqx1W4YHS cBtw== 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=A9SbvDZoxOg3W4csEPRVhqqO+LP6b/yDHiFcwuaY+4k=; b=rvpW5wLctmxE1xky7oi/p14VCFwM/sLwjwJwhn+M9sF5Oo8tg4qkookOujqVUZUS6M lk23hLS1NCBZnqHV5XYAYuc8dgBAYo+6QJsN6JcwJN/9x93DIxLHj4WSURjYojIwcR3l 4xVDKGaU8xLap+b6LGM6pLdcz63s/s7VjSJTLrM6en/CoQZGBfG/ZKaCkLnbggjyYBt5 UxyphUqg2FcmVImmpQA8iWRuhiOktTiI4pNfB64PRJjld8+EhsnFa+Xvs581WS7Qw9dh 5MVx+x6A+SHju1obiMmWrbPE+8s+lnByxYKrVtyBnzrRHHVyROP1uZwEL6uP/y+VFJhJ Wqag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TORVeix9; 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 c23-v6si1944965pli.308.2018.02.23.07.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41: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=TORVeix9; 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 E5EC0222630AB; Fri, 23 Feb 2018 07:35: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: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 423732034D8C0 for ; Fri, 23 Feb 2018 07:35:12 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id s5so14552238wra.0 for ; Fri, 23 Feb 2018 07:41: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=EoQnLrZ5sqd+Sey47zoEvRscWnmivYpIDjm382xG7Ow=; b=TORVeix9/yDO2qxRO2GpMHsfcrO0i54QEyA2e0KmnXujlEGL5UMCuOCWnM/cA5rJ+7 MJKtYDjCdwizGbFfR6Lbgy+7oiGEjgZToiYSmnVBcsZ7fOahnTuSvEZJOprF32qw5YAI 4a3vPSxK8pwjO963PBc4ysGAxtBmk+VJjCXCI= 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=EoQnLrZ5sqd+Sey47zoEvRscWnmivYpIDjm382xG7Ow=; b=NFo9Il+RaXn2ZTFY6lIvipWqG/ctfqa0K10znvE1K21O54eQMJju7Qx98lXDw4txI6 V6tVHlH9v7h5sIAvd7hQ0RT/rPBNB9PBWFDfSLiajJM0SlQJ1XGuWPZQniZCxV2rEb1Z Kt+Db03zSdSI7Kpesx86jpa7kjZen5ebJzwc/zTvgTUrhnOkDUMIM5VDWcNcR38o9hNd l83Ze+gFZmZczTAFMhzyJJe3NtSV9X5WPyh8H74jQRwvp36oStkuEa6QTZEnC03yft7p jgG5B9Ib5G/XpzNnRRuq/5VV0/sGpIRXoN9w2ERWkIcFcNv4LZsFnNVCEH4GIBT5066v Ox7Q== X-Gm-Message-State: APf1xPDeBEMtwhmrHrAwyPVBOZQ/AwVFFulR0sHBeVCPXrFkereOwWfL BTbM5f6v8NtqZeI3A1VInU+0Q8pKTzU= X-Received: by 10.223.176.86 with SMTP id g22mr1962166wra.11.1519400472353; Fri, 23 Feb 2018 07:41:12 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:11 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:50 +0000 Message-Id: <20180223154052.9828-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 4/6] Platform/96Boards: add a driver for the Secure96 mezzanine board X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add a driver that describes the Secure96 mezzanine board, and exposes both the information required to describe it to the OS using a DT overlay, and to describe it to UEFI itself. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/Secure96Dxe/Secure96.dts | 85 ++++++++ Platform/96Boards/Secure96Dxe/Secure96.h | 26 +++ Platform/96Boards/Secure96Dxe/Secure96Dxe.c | 211 ++++++++++++++++++++ Platform/96Boards/Secure96Dxe/Secure96Dxe.inf | 67 +++++++ 4 files changed, 389 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/96Boards/Secure96Dxe/Secure96.dts b/Platform/96Boards/Secure96Dxe/Secure96.dts new file mode 100644 index 000000000000..b56ce59985cc --- /dev/null +++ b/Platform/96Boards/Secure96Dxe/Secure96.dts @@ -0,0 +1,85 @@ +/** @file + * Copyright (c) 2018, Linaro Limited. All rights reserved. + * + * This program and the accompanying materials are licensed and made + * available under the terms and conditions of the BSD License which + * accompanies this distribution. The full text of the license may be + * found at http://opensource.org/licenses/bsd-license.php + * + * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR + * IMPLIED. + */ + +#include "Secure96.h" + +// +// Define a placeholder value for the GPIO phandle property cells appearing +// in this file. It is up to the driver code to discover the actual phandle +// value from the platform device tree and patch the overlay DTB before it +// can be applied. +// +#define GPIO_PARENT_PLACEHOLDER_PHANDLE 0x0 + +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target-path = "I2C_PARENT_PLACEHOLDER_STRING"; + __overlay__ { + clock-frequency = <100000>; + + ATSHA204A_DT_NODENAME { + compatible = "atmel,atsha204a"; + reg = ; + }; + + ATECC508A_DT_NODENAME { + compatible = "atmel,atecc508a"; + reg = ; + }; + }; + }; + + fragment@1 { + target-path = "SPI_PARENT_PLACEHOLDER_STRING"; + __overlay__ { + INFINEON_SLB9670_DT_NODENAME { + compatible = "infineon,slb9670"; + reg = ; + spi-max-frequency = <22500000>; + }; + }; + }; + + fragment@2 { + target-path = "/"; + __overlay__ { + gpio-leds { + compatible = "gpio-leds"; + + secure96-u1 { + gpios = ; + }; + secure96-u2 { + gpios = ; + }; + secure96-u3 { + gpios = ; + }; + secure96-u4 { + gpios = ; + }; + }; + }; + }; +}; diff --git a/Platform/96Boards/Secure96Dxe/Secure96.h b/Platform/96Boards/Secure96Dxe/Secure96.h new file mode 100644 index 000000000000..84b8aed13d1e --- /dev/null +++ b/Platform/96Boards/Secure96Dxe/Secure96.h @@ -0,0 +1,26 @@ +/** @file + + Copyright (c) 2018, 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 _SECURE96_H_ +#define _SECURE96_H_ + +#define ATSHA204A_SLAVE_ADDRESS 0x60 +#define ATSHA204A_DT_NODENAME atsha204a@60 + +#define ATECC508A_SLAVE_ADDRESS 0x51 +#define ATECC508A_DT_NODENAME atecc508a@51 + +#define INFINEON_SLB9670_SPI_CS 0x0 +#define INFINEON_SLB9670_DT_NODENAME tpm@0 + +#endif // _SECURE96_H_ diff --git a/Platform/96Boards/Secure96Dxe/Secure96Dxe.c b/Platform/96Boards/Secure96Dxe/Secure96Dxe.c new file mode 100644 index 000000000000..6c48d7c0b024 --- /dev/null +++ b/Platform/96Boards/Secure96Dxe/Secure96Dxe.c @@ -0,0 +1,211 @@ +/** @file + 96boards Secure96 mezzanine board DXE driver. + + Copyright (c) 2018, 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 "Secure96.h" + +STATIC CONST UINT32 mI2cAtmelSha204aSlaveAddress[] = { + ATSHA204A_SLAVE_ADDRESS, + + // + // The Atmel AtSha204a has an annoying 'wake' mode where it will only wake + // up if SDA is held low for a certain amount of time. Attempting to access + // a device at address 0x0 at 100 kHz should be sufficient to create this + // wake condition, so add address 0x0 to the slave addresses. + // + 0 +}; + +STATIC CONST EFI_I2C_DEVICE mI2c0Devices[] = { + { + &gAtSha204aI2cDeviceGuid, // DeviceGuid + 0, // DeviceIndex + 0, // HardwareRevision + 0, // I2C bus configuration + ARRAY_SIZE (mI2cAtmelSha204aSlaveAddress), // SlaveAddressCount + mI2cAtmelSha204aSlaveAddress // SlaveAddressArray + } +}; + +STATIC CONST CHAR8 mLedNodes[][46] = { + "/fragment@2/__overlay__/gpio-leds/secure96-u1", + "/fragment@2/__overlay__/gpio-leds/secure96-u2", + "/fragment@2/__overlay__/gpio-leds/secure96-u3", + "/fragment@2/__overlay__/gpio-leds/secure96-u4", +}; + +STATIC +VOID +SetOverlayFragmentTarget ( + VOID *Overlay, + CONST CHAR8 *NodeName, + CONST CHAR8 *Target + ) +{ + INT32 Node; + INT32 Err; + + Node = fdt_path_offset (Overlay, NodeName); + ASSERT (Node > 0); + + Err = fdt_setprop (Overlay, Node, "target-path", Target, + AsciiStrLen (Target) + 1); + if (Err) { + DEBUG ((DEBUG_ERROR, "%a: fdt_setprop() failed - %a\n", + __FUNCTION__, fdt_strerror (Err))); + } +} + +STATIC +VOID +FixupOverlay ( + VOID *Dtb, + VOID *Overlay + ) +{ + INT32 Node; + UINT32 GpioPhandle; + UINTN Idx; + UINT32 *GpioProp; + INT32 Err; + + // + // Set the correct GPIO phandle in the LED nodes + // + Node = fdt_path_offset (Dtb, FixedPcdGetPtr (PcdGpioParent)); + ASSERT (Node > 0); + + GpioPhandle = fdt_get_phandle (Dtb, Node); + if (!GpioPhandle) { + // + // Node has no phandle yet -> create one + // + GpioPhandle = 1 + fdt_get_max_phandle (Dtb); + ASSERT (GpioPhandle >= 1); + + Err = fdt_setprop_u32 (Dtb, Node, "phandle", GpioPhandle); + if (Err) { + DEBUG ((DEBUG_ERROR, + "%a: fdt_setprop_u32(.., .., \"phandle\", 0x%x) failed - %a\n", + __FUNCTION__, GpioPhandle, fdt_strerror (Err))); + } + } + + for (Idx = 0; Idx < ARRAY_SIZE (mLedNodes); Idx++) { + Node = fdt_path_offset (Overlay, mLedNodes[Idx]); + ASSERT (Node > 0); + + GpioProp = fdt_getprop_w (Overlay, Node, "gpios", NULL); + ASSERT (GpioProp != NULL); + + *GpioProp = cpu_to_fdt32 (GpioPhandle); + } + + SetOverlayFragmentTarget (Overlay, "/fragment@0", + FixedPcdGetPtr (PcdI2c0Parent)); + + SetOverlayFragmentTarget (Overlay, "/fragment@1", + FixedPcdGetPtr (PcdSpiParent)); +} + +/** + Apply the mezzanine's DT overlay + + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance. + @param[in,out] Dtb Pointer to the device tree blob + + @return EFI_SUCCESS Operation succeeded. + @return other An error has occurred. +**/ +STATIC +EFI_STATUS +ApplyDeviceTreeOverlay ( + IN MEZZANINE_PROTOCOL *This, + IN OUT VOID *Dtb + ) +{ + VOID *Overlay; + UINTN OverlaySize; + EFI_STATUS Status; + INT32 Err; + + // + // Load the raw overlay DTB image from the raw section of this FFS file. + // + Status = GetSectionFromFv (&gEfiCallerIdGuid, + EFI_SECTION_RAW, 0, &Overlay, &OverlaySize); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + // + // Fix up unresolved references in the overlay. + // + FixupOverlay (Dtb, Overlay); + + // + // Merge the overlay with the DTB + // + Err = fdt_overlay_apply (Dtb, Overlay); + if (Err) { + DEBUG ((DEBUG_ERROR, "%a: fdt_overlay_apply() failed - %a\n", + __FUNCTION__, fdt_strerror (Err))); + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} + +STATIC MEZZANINE_PROTOCOL mMezzanine = { + ApplyDeviceTreeOverlay, + ARRAY_SIZE (mI2c0Devices), + 0, + mI2c0Devices, + NULL, + NULL, +}; + +EFI_STATUS +EFIAPI +Secure96DxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LS_CONNECTOR_PROTOCOL *LsConnector; + + Status = gBS->LocateProtocol (&g96BoardsLsConnectorProtocolGuid, NULL, + (VOID **)&LsConnector); + ASSERT_EFI_ERROR (Status); + + if (LsConnector->MezzanineType != MezzanineSecure96) { + return EFI_NOT_FOUND; + } + + return gBS->InstallProtocolInterface (&ImageHandle, + &g96BoardsMezzanineProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMezzanine); +} diff --git a/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf b/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf new file mode 100644 index 000000000000..72dbf1314c15 --- /dev/null +++ b/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf @@ -0,0 +1,67 @@ +## @file +# +# Copyright (c) 2018, 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 = Secure96Dxe + FILE_GUID = 31519ec4-65f1-4790-b223-aa9330dd75fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = Secure96DxeEntryPoint + +[Sources] + Secure96.dts + Secure96.h + Secure96Dxe.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/96Boards/96Boards.dec + Silicon/Atmel/AtSha204a/AtSha204a.dec + +[LibraryClasses] + BaseLib + DebugLib + DxeServicesLib + FdtLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + g96BoardsLsConnectorProtocolGuid ## CONSUMES + g96BoardsMezzanineProtocolGuid ## PRODUCES + +[Guids] + gAtSha204aI2cDeviceGuid + gFdtTableGuid + +[FixedPcd] + g96BoardsTokenSpaceGuid.PcdGpioParent + g96BoardsTokenSpaceGuid.PcdGpioPinF + g96BoardsTokenSpaceGuid.PcdGpioPinG + g96BoardsTokenSpaceGuid.PcdGpioPinH + g96BoardsTokenSpaceGuid.PcdGpioPinI + g96BoardsTokenSpaceGuid.PcdGpioPolarity + g96BoardsTokenSpaceGuid.PcdI2c0Parent + g96BoardsTokenSpaceGuid.PcdSpiParent + +[Depex] + g96BoardsLsConnectorProtocolGuid + +[BuildOptions] + # dtc emits lots of spurious warnings for overlays + *_*_*_DTC_FLAGS = -q From patchwork Fri Feb 23 15:40:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129395 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744896lja; Fri, 23 Feb 2018 07:41:22 -0800 (PST) X-Google-Smtp-Source: AH8x225QyiQW9HP1z66Jt1ZtVOg8yjpA5YUqxTfbfNw9tfQfMBsyHHQ3/jRxPynsz0YKDJr2a/db X-Received: by 2002:a17:902:bcc6:: with SMTP id o6-v6mr2136423pls.16.1519400481963; Fri, 23 Feb 2018 07:41:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400481; cv=none; d=google.com; s=arc-20160816; b=K1KNGMUpuVntQOx0xCpj6/5xhEgnyQ6H7WEEkpQ5bQwh7OscxWE9X7goQNVI4L+l6z wZ2dpHDRF0Q1LNEROLYKgNnXuS3jMRSv5RPsnPAAwEHTUtaSKywbLzEiBSdCZtruGYAs vaV4dHR6swvhz9uya41w51bPesOkisHo/6I1sS7g965c151HGwoBEntJBrzQQih9QYeW 61owUaB0GBM9Tt29ZcSWZ6Tvit32Xpnpe7NgcKi1NIUYRYBZyaoMaGrxQZlHbpWDkCYz bN+/Mn0SSnxkf8XXg7MJQreQJQZ8aMIMLKKQdj+FoL5oqmpCfwH2xoeVbaDJwvzSEUyQ I2eg== 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=VoqkCkguxWAii4fVIKfjRCBKahHPybtYbz/92XhIPqo=; b=moFBbYY0OQKQ0unBYwIHbINI96Nv0H2tSObaDqKmzNitaMn1UIksUlbziE0HoyV1B1 a3iua+JlliX1+grrzmP2ljEgdbLz2ANMcpakuB0/ds+qP4/gJH+sbWaR0FdbPslLabKc /Km0FaLfX0taS12sY4E88bVpCvmJRuTdzeyts8JnSrOLbUXwffvRSuDhgPTtaUUrs5P3 VrRJRA3zSRl0zJ0MhV4iU6HC8eNivON+3jJwavVsTpZr5TsKZQ991jmV/u+5GoENufyG 0TKBl68AydOs2l8zwiIi/cCPEOlmv5UisDayeDoGY6Svsm1IgtE8JUciXPPKUTQD0g5z Fj8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I6tUtHQI; 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 y6-v6si1911364plk.705.2018.02.23.07.41.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:21 -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=I6tUtHQI; 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 6D43E222630AE; Fri, 23 Feb 2018 07:35: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::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 A8AD321FD73F7 for ; Fri, 23 Feb 2018 07:35:14 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id f14so14515202wre.8 for ; Fri, 23 Feb 2018 07:41:16 -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=gx2TwPY0zoLBprBpvispsMP1S0T3TDTaNNHwcFI4nEs=; b=I6tUtHQIov330G6k6otXmDlo3XBpNJGNDyPPjkrVb0lDWEH7uBytfxxvrVBGGLL7Xx QwiGcpo6gmIOpSADcQQ/OwpM2jB030suP8JIj2oNT2JVaA7XpXPNHd01WwW1KARzYL4p 1sBJmKiqS6T7/r8UqzsmzNVmmeccVHPoJVImk= 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=gx2TwPY0zoLBprBpvispsMP1S0T3TDTaNNHwcFI4nEs=; b=AQEXiHGo1X/W7XgXtzy0aEdqMHkL7x+rYbiXibb3bOV+b4EHILglkXTzdSB4snUx6J N1p/t5v6Jhw1LHmwNobSzGVaP6XnibQyU6NX1Sn2mQIg+fIyTrzXWc6UJP6h8eqgvh1l mqcf3qXxdQljqiBhXPgy5horPiUSoVuYPLWzR23zVnB/sDAc4UN6c5s30G55ICSxZ2Fr 1oTc3Fb+jOOX/Su1v4rXu+cZu1UhGKjxCzKGlS3Y+yQqNt/yDqg8QNdFnvdvz/ejXks2 K6+Spght2L5sw0nIG6rXzbaNasnFHNj3LOwE3ZPH8qIaSS1Gp3ZFQhlNl8Ykuxa66vWR zxRA== X-Gm-Message-State: APf1xPDKDp8Vv7Yh+xVEON7tBhyUaDe1npzQbDeAkksNGgcRbvDsPWKh iYhrnLP88fQFbbZ9IoDTo2rWhqLp3Ko= X-Received: by 10.223.179.211 with SMTP id x19mr2014899wrd.175.1519400474514; Fri, 23 Feb 2018 07:41:14 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:13 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:51 +0000 Message-Id: <20180223154052.9828-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 5/6] Platform/96Boards: add driver for low speed (LS) connector X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This adds a driver that manages the 96Boards LS connector, i.e, it installs a HII page to configure the type of mezzanine that is installed in the slot, and it exposes this information via the LS connector protocol. It is also in charge of applying the overlay to the platform device tree at end of DXE. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/96Boards.dec | 3 + Platform/96Boards/Include/Guid/FormSet.h | 23 ++ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c | 221 ++++++++++++++++++++ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h | 32 +++ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf | 57 +++++ Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni | 27 +++ Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr | 45 ++++ 7 files changed, 408 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/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec index fa8e639b1a11..49641828aa60 100644 --- a/Platform/96Boards/96Boards.dec +++ b/Platform/96Boards/96Boards.dec @@ -37,6 +37,9 @@ [Guids] g96BoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } } g96BoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } } + # GUID for the HII configuration form + g96BoardsFormsetGuid = { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } } + [PcdsFixedAtBuild] # ASCII DT paths to the I2C parent nodes of the 96boards LS connector g96BoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001 diff --git a/Platform/96Boards/Include/Guid/FormSet.h b/Platform/96Boards/Include/Guid/FormSet.h new file mode 100644 index 000000000000..a0475e641d69 --- /dev/null +++ b/Platform/96Boards/Include/Guid/FormSet.h @@ -0,0 +1,23 @@ +/** @file + + Copyright (c) 2018, Linaro Limited. All rights reserved. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __96BOARDS_FORMSET_H__ +#define __96BOARDS_FORMSET_H__ + +#define NINETY_SIX_BOARDS_FORMSET_GUID \ + { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } } + +extern EFI_GUID g96BoardsFormsetGuid; + +#endif // __96BOARDS_FORMSET_H__ diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c new file mode 100644 index 000000000000..f19d95635056 --- /dev/null +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c @@ -0,0 +1,221 @@ +/** @file + + Copyright (c) 2018, 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 + +#include "LsConnectorDxe.h" + +extern UINT8 LsConnectorHiiBin[]; +extern UINT8 LsConnectorDxeStrings[]; + +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} HII_VENDOR_DEVICE_PATH; + +STATIC HII_VENDOR_DEVICE_PATH m96BoardsDxeVendorDevicePath = { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + NINETY_SIX_BOARDS_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8) (END_DEVICE_PATH_LENGTH), + (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +STATIC LS_CONNECTOR_PROTOCOL mLsConnector; +STATIC EFI_EVENT EndOfDxeEvent; + +STATIC +EFI_STATUS +InstallHiiPages ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HANDLE DriverHandle; + + DriverHandle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle, + &gEfiDevicePathProtocolGuid, + &m96BoardsDxeVendorDevicePath, + NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + HiiHandle = HiiAddPackages (&g96BoardsFormsetGuid, + DriverHandle, + LsConnectorDxeStrings, + LsConnectorHiiBin, + NULL); + + if (HiiHandle == NULL) { + gBS->UninstallMultipleProtocolInterfaces (DriverHandle, + &gEfiDevicePathProtocolGuid, + &m96BoardsDxeVendorDevicePath, + NULL); + return EFI_OUT_OF_RESOURCES; + } + return EFI_SUCCESS; +} + +STATIC +VOID +EFIAPI +ApplyDeviceTreeOverlay ( + EFI_EVENT Event, + VOID *Context + ) +{ + VOID *Dtb; + MEZZANINE_PROTOCOL *Mezzanine; + EFI_STATUS Status; + + // + // Find the DTB in the configuration table array. If it isn't there, just + // bail without an error: we may be running on an ACPI platform even if + // this driver does not support it [yet]. + // + Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb); + if (Status == EFI_NOT_FOUND) { + return; + } + ASSERT_EFI_ERROR (Status); + + Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, + (VOID **)&Mezzanine); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__)); + return; + } + + Status = Mezzanine->ApplyDeviceTreeOverlay (Mezzanine, Dtb); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to apply DT overlay - %r\n", __FUNCTION__, + Status)); + } +} + +/** + The entry point for 96BoardsDxe driver. + + @param[in] ImageHandle The image handle of the driver. + @param[in] SystemTable The system table. + + @retval EFI_ALREADY_STARTED The driver already exists in system. + @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of + resources. + @retval EFI_SUCCES All the related protocols are installed on + the driver. + +**/ +EFI_STATUS +EFIAPI +EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + NINETY_SIX_BOARDS_CONFIG_DATA ConfigData; + UINTN BufferSize; + + // + // Get the current config settings from the EFI variable. + // + BufferSize = sizeof (ConfigData); + Status = gRT->GetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME, + &g96BoardsFormsetGuid, NULL, &BufferSize, &ConfigData); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: no config data found\n", __FUNCTION__)); + ConfigData.MezzanineType = MEZZANINE_NONE; + } + + if (!EFI_ERROR (Status) && + ConfigData.MezzanineType >= MEZZANINE_MAX) { + DEBUG ((DEBUG_WARN, + "%a: invalid value for %s, defaulting to MEZZANINE_NONE\n", + __FUNCTION__, NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME)); + ConfigData.MezzanineType = MEZZANINE_NONE; + Status = EFI_INVALID_PARAMETER; // trigger setvar below + } + + // + // Write the newly selected value back to the variable store. + // + if (EFI_ERROR (Status)) { + ZeroMem (&ConfigData.Reserved, sizeof (ConfigData.Reserved)); + Status = gRT->SetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME, + &g96BoardsFormsetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof (ConfigData), &ConfigData); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n", + __FUNCTION__, Status)); + return Status; + } + } + + switch (ConfigData.MezzanineType) { + case MEZZANINE_SECURE96: + mLsConnector.MezzanineType = MezzanineSecure96; + break; + default: + mLsConnector.MezzanineType = MezzanineUnknown; + } + + Status = gBS->InstallProtocolInterface (&ImageHandle, + &g96BoardsLsConnectorProtocolGuid, + EFI_NATIVE_INTERFACE, + &mLsConnector); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + ApplyDeviceTreeOverlay, + NULL, + &gEfiEndOfDxeEventGroupGuid, + &EndOfDxeEvent); + ASSERT_EFI_ERROR (Status); + + return InstallHiiPages (); +} diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h new file mode 100644 index 000000000000..c2a21c52b7a2 --- /dev/null +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h @@ -0,0 +1,32 @@ +/** @file + + Copyright (c) 2018, Linaro Limited. All rights reserved. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __LSCONNECTOR_DXE_H__ +#define __LSCONNECTOR_DXE_H__ + +#include +#include + +#define MEZZANINE_NONE 0x0 +#define MEZZANINE_SECURE96 0x1 +#define MEZZANINE_MAX 0x2 + +#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME L"NinetySixBoardsConfig" + +typedef struct { + UINT8 MezzanineType; + UINT8 Reserved[7]; +} NINETY_SIX_BOARDS_CONFIG_DATA; + +#endif // __LSCONNECTOR_DXE_H__ diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf new file mode 100644 index 000000000000..1bf528ceaa84 --- /dev/null +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf @@ -0,0 +1,57 @@ +## @file +# +# Copyright (c) 2018, 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 = LsConnectorDxe + FILE_GUID = 3f68e889-cb77-4efc-bc84-afa0a64ad26e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = EntryPoint + +[Sources] + LsConnectorDxe.c + LsConnectorDxe.h + LsConnectorHii.vfr + LsConnectorHii.uni + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/96Boards/96Boards.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + HiiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + UefiRuntimeServicesTableLib + +[Protocols] + g96BoardsLsConnectorProtocolGuid ## PRODUCES + g96BoardsMezzanineProtocolGuid ## CONSUMES + +[Guids] + gEfiEndOfDxeEventGroupGuid + gFdtTableGuid + g96BoardsFormsetGuid + +[Depex] + gEfiVariableArchProtocolGuid AND + gEfiVariableWriteArchProtocolGuid diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni new file mode 100644 index 000000000000..23f4c5859207 --- /dev/null +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni @@ -0,0 +1,27 @@ +/** @file + + Copyright (c) 2018, 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. + +**/ + +#langdef en-US "English" + +#string STR_FORM_SET_TITLE #language en-US "96boards Mezzanine options" +#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the installed 96boards mezzanine" + +#string STR_MAIN_FORM_TITLE #language en-US "96boards Mezzanine options" +#string STR_NULL_STRING #language en-US "" + +#string STR_MEZZANINE_SELECT_PROMPT #language en-US "96boards mezzanine" +#string STR_MEZZANINE_SELECT_HELP #language en-US "The type of mezzanine board plugged into the 96boards LS connector" + +#string STR_MEZZANINE_NONE #language en-US "None/Unknown" +#string STR_MEZZANINE_SECURE96 #language en-US "Secure96" diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr new file mode 100644 index 000000000000..c4dd69db8e2f --- /dev/null +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr @@ -0,0 +1,45 @@ +/** @file + + Copyright (c) 2018, 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 "LsConnectorDxe.h" + +#include + +formset + guid = NINETY_SIX_BOARDS_FORMSET_GUID, + title = STRING_TOKEN(STR_FORM_SET_TITLE), + help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP), + classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID, + + efivarstore NINETY_SIX_BOARDS_CONFIG_DATA, + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attributes + name = NinetySixBoardsConfig, + guid = NINETY_SIX_BOARDS_FORMSET_GUID; + + form formid = 0x1000, + title = STRING_TOKEN(STR_MAIN_FORM_TITLE); + + oneof varid = NinetySixBoardsConfig.MezzanineType, + prompt = STRING_TOKEN(STR_MEZZANINE_SELECT_PROMPT), + help = STRING_TOKEN(STR_MEZZANINE_SELECT_HELP), + flags = NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED, + option text = STRING_TOKEN(STR_MEZZANINE_NONE), value = MEZZANINE_NONE, flags = DEFAULT; + option text = STRING_TOKEN(STR_MEZZANINE_SECURE96), value = MEZZANINE_SECURE96, flags = 0; + endoneof; + + subtitle text = STRING_TOKEN(STR_NULL_STRING); + + endform; + +endformset; From patchwork Fri Feb 23 15:40:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 129396 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp744950lja; Fri, 23 Feb 2018 07:41:25 -0800 (PST) X-Google-Smtp-Source: AH8x226O2f7LbKqaVhJKpx4xWkOTpO626Aq7u9qHNjlcKg3/vk3wckwn7lFGctBGg2Ps9jMnOHJ3 X-Received: by 10.98.75.129 with SMTP id d1mr479125pfj.19.1519400485089; Fri, 23 Feb 2018 07:41:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519400485; cv=none; d=google.com; s=arc-20160816; b=ubKPD4GvtW4j+ZLG1yMAzUjwCaK+qMbG4TGr/FM6m3wQNLyHSq4rSAcqb3Nm/oJULU 6xsLbr4Jl+Ypwd4WVCbLdjsEdrrYDI3c0D6xAbUVrajs6W/2fw2CrT1N8j8JvzREUITS KQzUVhOFcTJ8I7LZk37d+QyEOLIB6qVcd5uN9yzIrarKDXkxawpDHKrEE4P1suOzaSjv d6tkYVf8unu0dVv8l971tx9JwC+KISlTmUGE/H1iEsJDRXbZzRC0/52V47OZBVu59p4+ A6XHa/blhhYCvoB8HXwctrTC04rvfj/9YU3d5YyRROFpNP52kJE189om5RDNiAgT+eEG Ekpw== 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=iICDaWhjUyZAsNVikyqdEgZZmn9tV3HR0wOSWcPJniE=; b=zpU5YALua1RE25rC7XeAMvsFdINn1uOQhHRVHTZ1Hbi8pAPEQxz7DTOfbeGFfUJ39/ IP+r6RUkJcj1TX0aeomUYjjn8ZuuI7TtXldYNqzJ9jEeBOLbFh4FHCQ+UYzXvxjDQIRt R2QD/V8KrHVCdfHjbLV/Dflt1o/bOA+kMOXGS1meJ3J1R6JclbAG5Z3e/DIxYFg33bzE NozpviEWx8yRUEsBy6co3R0bgEih50NqLeEUDfnYWvKGRBSNvLIPWHvgbql5C5dg08uI NIInA/SrUjC32cWOBiCK1hfIgUPzuzDsd8haPrjHyAwnwA04Zm3KyA9b24+UY5uANgl9 vasw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Og3rysB8; 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 a8-v6si1940888ple.435.2018.02.23.07.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41: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=Og3rysB8; 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 DDF51222630B5; Fri, 23 Feb 2018 07:35: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: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 3F9D8222630A6 for ; Fri, 23 Feb 2018 07:35:16 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id z9so5336949wmb.3 for ; Fri, 23 Feb 2018 07:41: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=C9h/P1XCDiIkf3xZ0a2iQMrlBqEUmu5dkNvInLrGHM0=; b=Og3rysB8RmKgZ56P/tDHOjpP4dKf3ytXfSeBaSgxJ0kt/akFV0+q5ct2BcPAiqT2F5 M1r8Gj30lBVWjpR+/q+N+HtgLiw3TIasZqNCL9UUnKuiodDfVrRQzjw1f+Xjms61GDAl /mlihm6DvJYSNMjfh91ueHnaDA6FHPni4w9p0= 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=C9h/P1XCDiIkf3xZ0a2iQMrlBqEUmu5dkNvInLrGHM0=; b=S/PGDErFokJwpvurJY4d/2i3FnlloKwbnjm0R99FXaLOAA3Pl7Nj6mJ3ypLD1JHGlf BtNg2f741Axl/t49KJmChg7S8PzLzK5IvhJPxbUpNW/0VPIBinSkFrgzJ9K/quyHCBR5 XaWvWmsKq5fdffNHg2Y51fXqst4+84epv5Pn06aQJnMWO0i6bvp0uryNNDp/GlI28q43 707FN94fQB1NkX12vbKZ7pr+0D302HBjwbk+tjwjxZAu902rFG1j8qDdFnLaCrm3hjQf RK6ScakIP8ERrDpCo0hiISHcq84t3VFJLsx4WSWY/OFJUx5dhQYEo3eM8iCUMGaDktBa 6SBw== X-Gm-Message-State: APf1xPCm7xMtg8rZ/u61CnyClo0H4RkgGxoyq/Q3wdgbgD+2WtcpsNvN 65TR9bs5Vwl2BgCSZB856iUgW2swxvk= X-Received: by 10.28.116.14 with SMTP id p14mr2243500wmc.117.1519400476243; Fri, 23 Feb 2018 07:41:16 -0800 (PST) Received: from localhost.localdomain ([196.90.4.100]) by smtp.gmail.com with ESMTPSA id 188sm2273215wmg.29.2018.02.23.07.41.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:41:15 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 15:40:52 +0000 Message-Id: <20180223154052.9828-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223154052.9828-1-ard.biesheuvel@linaro.org> References: <20180223154052.9828-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 6/6] Platform/Socionext/DeveloperBox: add 96Boards mezzanine support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Wire up the various drivers for the 96Boards LS connector and the optional Secure96 mezzanine board. Note that this includes a [Rule] update that allows .dtb binaries to be bundled with DXE drivers. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 34 ++++++++++++++++++++ Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 10 ++++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 9 ++++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 2 ++ 4 files changed, 55 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 3c109b495fbc..afd0a4f59f00 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -31,6 +31,9 @@ [Defines] [BuildOptions] RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 + # add ample padding to the DTC so we can apply 96boards mezzanine overlays + *_*_*_DTC_FLAGS = -p 1024 + [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 @@ -396,6 +399,28 @@ [PcdsFixedAtBuild.common] !endif gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision|$(BUILD_NUMBER) + # + # 96boards mezzanine support + # + g96BoardsTokenSpaceGuid.PcdI2c0Parent|"/i2c@51210000" + g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|100000 + g96BoardsTokenSpaceGuid.PcdSpiParent|"/spi@54810000" + g96BoardsTokenSpaceGuid.PcdGpioParent|"/gpio@51000000" + g96BoardsTokenSpaceGuid.PcdGpioPolarity|0 + + g96BoardsTokenSpaceGuid.PcdGpioPinA|10 + g96BoardsTokenSpaceGuid.PcdGpioPinB|11 + g96BoardsTokenSpaceGuid.PcdGpioPinC|12 + g96BoardsTokenSpaceGuid.PcdGpioPinD|13 + g96BoardsTokenSpaceGuid.PcdGpioPinE|18 + g96BoardsTokenSpaceGuid.PcdGpioPinF|19 + g96BoardsTokenSpaceGuid.PcdGpioPinG|20 + g96BoardsTokenSpaceGuid.PcdGpioPinH|21 + g96BoardsTokenSpaceGuid.PcdGpioPinI|22 + g96BoardsTokenSpaceGuid.PcdGpioPinJ|23 + g96BoardsTokenSpaceGuid.PcdGpioPinK|24 + g96BoardsTokenSpaceGuid.PcdGpioPinL|25 + [PcdsPatchableInModule] gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 @@ -642,6 +667,15 @@ [Components.common] SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf # + # 96board mezzanine support + # + Platform/96Boards/Secure96Dxe/Secure96Dxe.inf + Silicon/Atmel/AtSha204a/AtSha204aDxe.inf + Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf + Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf + + # # I2C # Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf + MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf index b668f42c7962..130572009fd0 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf @@ -237,9 +237,18 @@ [FV.FvMain] } # + # 96board mezzanine support + # + INF Platform/96Boards/Secure96Dxe/Secure96Dxe.inf + INF Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf + INF Silicon/Atmel/AtSha204a/AtSha204aDxe.inf + INF Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf + + # # I2C # INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf + INF MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf [FV.FVMAIN_COMPACT] FvAlignment = 16 @@ -421,6 +430,7 @@ [Rule.Common.DXE_DRIVER] DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi UI STRING="$(MODULE_NAME)" Optional + RAW BIN Optional |.dtb } [Rule.Common.DXE_RUNTIME_DRIVER] diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c index aab830dc3a5a..8787aa6288a7 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -313,6 +313,15 @@ PlatformDxeEntryPoint ( &Handle); ASSERT_EFI_ERROR (Status); + // + // Install the g96BoardsI2c0MasterGuid GUID onto the same handle, + // identifying I2C #1 on our SoC as I2C #0 on the 96boards low speed connector + // + Status = gBS->InstallProtocolInterface (&Handle, + &g96BoardsI2c0MasterGuid, + EFI_NATIVE_INTERFACE, NULL); + ASSERT_EFI_ERROR (Status); + SmmuEnableCoherentDma (); SetMmioTimerFrequency (); diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf index 49d9deee57ea..fca66799ebcb 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -34,6 +34,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/96Boards/96Boards.dec Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -56,6 +57,7 @@ [LibraryClasses] UefiRuntimeServicesTableLib [Guids] + g96BoardsI2c0MasterGuid gEfiHiiPlatformSetupFormsetGuid gFdtTableGuid gNetsecNonDiscoverableDeviceGuid