From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4864:20::143; helo=mail-lf1-x143.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) (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 8F8EB2194D3AE for ; Thu, 17 Jan 2019 03:15:51 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id p6so7510746lfc.1 for ; Thu, 17 Jan 2019 03:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oyFXIQ403Am5o83UuQR2JxCeRaYOxsIRM55euEGu6QQ=; b=z86+KhyCMgJwTeA0km0uEiZl6hD40LEj3IRL8Wncj+x1YGH06MkrJ3/ZKCsl1DpQQH HQtM2AcS19QitqD8SSqNydHYecB6O4d7VoCoFAluxMsEuAbLckcBQ+BLUAGLviC6luQs lqIjm3NbV9VSzUcEykjb0OgkdOO1EJTVLTazkhiyQZd3B8b7myb+JgGQ2oO99994yI7a g/FWrNkOHsIBV4sBpvzcts2woQ8g+qAsOv6AL4DmPa/4Urdbzr9Elw3IHQ3NqMvXntyP mNavrpO55AZUTFM1fQaSekxL/DDW05LURM1wSC4ENB8k6wXOFaKmYuio6Edfz6I4Gk65 VT6A== 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=oyFXIQ403Am5o83UuQR2JxCeRaYOxsIRM55euEGu6QQ=; b=EuxO6DQoGr0JZTdXyyc54gJtrsd1aCIqcDIrzXZb7lTwYITpxJbC7D8f8QBHUYjUYL dw86jPISdCPxbMQ3Q7rSHbNb5UiiL8KHDCsuF32neT0Kwz0QQyK9MiODd2jd1i+McoSh 4yM3/C6Bi+8Ongjcca4sJHMnmQRof1VYOhiPiQoHibeqpH4eM/KD5gFXf4y18kAM7Fhp A/UrkcUbfmtKaN8pXqNGCgDzD8ZL2TvzECcfsMcTD07NoBNWDkcNu2BqHo49eGa6g1Pb i2iX0GMsHNinO/DVzeiRr7/61zJKRsYkFW35QtADosJAu9oup3yjVTpVRBsyn3iFBMdF 6i0g== X-Gm-Message-State: AJcUuke3+M+BXMzWHiPSOzpeIiIm9vD136rbggJz3JATzt7W6mNOoA0+ mO+yBP9crUu3MbsvaA6oBC/dgkixNwg= X-Google-Smtp-Source: ALg8bN52uovIVNUxHhIEmITvXSOAqpPtzwxUWyZqICXFV+0FVIVRCPmN1whTEB+xL4EMlzohTKiwww== X-Received: by 2002:a19:f20:: with SMTP id e32mr10159355lfi.51.1547723749268; Thu, 17 Jan 2019 03:15:49 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id d23sm238003lfc.11.2019.01.17.03.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 03:15:48 -0800 (PST) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com Date: Thu, 17 Jan 2019 12:15:15 +0100 Message-Id: <1547723715-4562-13-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547723715-4562-1-git-send-email-mw@semihalf.com> References: <1547723715-4562-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v3 12/12] Marvell/Armada7k8k: Introduce NonDiscoverable device init routines X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2019 11:15:52 -0000 X-List-Received-Date: Thu, 17 Jan 2019 11:15:52 -0000 X-List-Received-Date: Thu, 17 Jan 2019 11:15:52 -0000 X-List-Received-Date: Thu, 17 Jan 2019 11:15:52 -0000 X-List-Received-Date: Thu, 17 Jan 2019 11:15:52 -0000 To abstract the initialization required for non-discoverable devices, which is often platform specific (e.g. enable GPIO-driven power supply), introduce a NonDiscoverableInitLib for use by the NonDiscoverable code, for which each platform can supply its own version. Add XHCI power supply (so called 'VBUS') enabling routines for supported platforms (Armada70x0Db, Armada80x0Db, Armada80x0McBin). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Marvell.dec | 1 + Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc | 1 + Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc | 3 + Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc | 3 + Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc | 3 + Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf | 49 +++++++++ Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf | 50 +++++++++ Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf | 50 +++++++++ Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf | 1 + Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h | 23 +++++ Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h | 28 ++++++ Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h | 20 ++++ Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h | 28 ++++++ Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c | 96 ++++++++++++++++++ Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c | 106 ++++++++++++++++++++ Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c | 71 +++++++++++++ Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c | 13 ++- 17 files changed, 543 insertions(+), 3 deletions(-) create mode 100644 Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf create mode 100644 Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf create mode 100644 Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf create mode 100644 Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h create mode 100644 Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h create mode 100644 Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h create mode 100644 Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h create mode 100644 Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c create mode 100644 Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c create mode 100644 Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvell.dec index ac922a0..c34d783 100644 --- a/Silicon/Marvell/Marvell.dec +++ b/Silicon/Marvell/Marvell.dec @@ -64,6 +64,7 @@ ArmadaIcuLib|Include/Library/ArmadaIcuLib.h ArmadaSoCDescLib|Include/Library/ArmadaSoCDescLib.h MvGpioLib|Include/Library/MvGpioLib.h + NonDiscoverableInitLib|Include/Library/NonDiscoverableInitLib.h SampleAtResetLib|Include/Library/SampleAtResetLib.h [Protocols] diff --git a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc index 5b8f4e9..eafcd6e 100644 --- a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc +++ b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc @@ -37,6 +37,7 @@ ArmPlatformLib|Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLib.inf ComPhyLib|Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf MppLib|Silicon/Marvell/Library/MppLib/MppLib.inf + MvGpioLib|Silicon/Marvell/Library/MvGpioLib/MvGpioLib.inf NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf SampleAtResetLib|Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf UtmiPhyLib|Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc index 31815e4..e8cd177 100644 --- a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc +++ b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc @@ -48,6 +48,9 @@ !include Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc +[LibraryClasses.common] + NonDiscoverableInitLib|Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf + [Components.common] Silicon/Marvell/Armada7k8k/DeviceTree/Armada70x0Db.inf diff --git a/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc b/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc index 42f7bd3..8e8c2ba 100644 --- a/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc +++ b/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc @@ -48,6 +48,9 @@ !include Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc +[LibraryClasses.common] + NonDiscoverableInitLib|Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf + [Components.common] Silicon/Marvell/Armada7k8k/DeviceTree/Armada80x0Db.inf diff --git a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc index 077224d..d080136 100644 --- a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc +++ b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc @@ -49,6 +49,9 @@ !include Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc +[LibraryClasses.common] + NonDiscoverableInitLib|Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf + [Components.common] Silicon/Marvell/Armada7k8k/DeviceTree/Armada80x0McBin.inf diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf new file mode 100644 index 0000000..56c08ec --- /dev/null +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf @@ -0,0 +1,49 @@ +## @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 = Armada70x0DbNonDiscoverableInitLib + FILE_GUID = 151b04bc-9195-4380-b1fa-987130b450f0 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = NonDiscoverableInitLib + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = AARCH64 +# + +[Sources] + NonDiscoverableInitLib.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + DebugLib + IoLib + MvGpioLib + +[Protocols] + gEmbeddedGpioProtocolGuid + +[Depex] + gMarvellPlatformInitCompleteProtocolGuid diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf new file mode 100644 index 0000000..fe21e52 --- /dev/null +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf @@ -0,0 +1,50 @@ +## @file +# +# Copyright (c) 2017, Linaro Ltd. All rights reserved.
+# Copyright (c) 2018, Marvell International 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 = Armada80x0DbNonDiscoverableInitLib + FILE_GUID = 719c91d5-25aa-4366-988a-1642ae3a6734 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = NonDiscoverableInitLib + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = AARCH64 +# + +[Sources] + NonDiscoverableInitLib.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + DebugLib + IoLib + MvGpioLib + +[Protocols] + gEmbeddedGpioProtocolGuid + +[Depex] + gMarvellPlatformInitCompleteProtocolGuid diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf new file mode 100644 index 0000000..60fc9a1 --- /dev/null +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf @@ -0,0 +1,50 @@ +## @file +# +# Copyright (c) 2017, Linaro Ltd. All rights reserved.
+# Copyright (c) 2018, Marvell International 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 = Armada80x0McBinNonDiscoverableInitLib + FILE_GUID = 470963c4-476e-4b85-a7c4-17868177f441 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = NonDiscoverableInitLib + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = AARCH64 +# + +[Sources] + NonDiscoverableInitLib.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + DebugLib + IoLib + MvGpioLib + +[Protocols] + gEmbeddedGpioProtocolGuid + +[Depex] + gMarvellPlatformInitCompleteProtocolGuid diff --git a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf index 98e5b0c..3f9f7bc 100644 --- a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf +++ b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf @@ -50,6 +50,7 @@ [LibraryClasses] NonDiscoverableDeviceRegistrationLib + NonDiscoverableInitLib UefiDriverEntryPoint [Protocols] diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h new file mode 100644 index 0000000..8a0e424 --- /dev/null +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h @@ -0,0 +1,23 @@ +/** +* +* Copyright (c) 2018, Marvell International 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 __NON_DISCOVERABLE_INIT_LIB_H__ +#define __NON_DISCOVERABLE_INIT_LIB_H__ + +#define ARMADA_70x0_DB_IO_EXPANDER0 0 +#define ARMADA_70x0_DB_VBUS0_PIN 0 +#define ARMADA_70x0_DB_VBUS0_LIMIT_PIN 4 +#define ARMADA_70x0_DB_VBUS1_PIN 1 +#define ARMADA_70x0_DB_VBUS1_LIMIT_PIN 5 + +#endif diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h new file mode 100644 index 0000000..64373ff --- /dev/null +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h @@ -0,0 +1,28 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 __NON_DISCOVERABLE_INIT_LIB_H__ +#define __NON_DISCOVERABLE_INIT_LIB_H__ + +#define ARMADA_80x0_DB_IO_EXPANDER0 0 +#define ARMADA_80x0_DB_VBUS0_PIN 0 +#define ARMADA_80x0_DB_VBUS0_LIMIT_PIN 4 +#define ARMADA_80x0_DB_VBUS1_PIN 1 +#define ARMADA_80x0_DB_VBUS1_LIMIT_PIN 5 + +#define ARMADA_80x0_DB_IO_EXPANDER1 1 +#define ARMADA_80x0_DB_VBUS2_PIN 0 +#define ARMADA_80x0_DB_VBUS2_LIMIT_PIN 4 + +#endif diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h new file mode 100644 index 0000000..38e1f20 --- /dev/null +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h @@ -0,0 +1,20 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 __NON_DISCOVERABLE_INIT_LIB_H__ +#define __NON_DISCOVERABLE_INIT_LIB_H__ + +#define ARMADA_80x0_MCBIN_VBUS0_PIN 15 + +#endif diff --git a/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h b/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h new file mode 100644 index 0000000..18de24f --- /dev/null +++ b/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h @@ -0,0 +1,28 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 __NON_DISCOVERABLE_INIT_LIB_H__ +#define __NON_DISCOVERABLE_INIT_LIB_H__ + +#include + +NON_DISCOVERABLE_DEVICE_INIT +EFIAPI +NonDiscoverableDeviceInitializerGet ( + IN NON_DISCOVERABLE_DEVICE_TYPE Type, + IN UINTN Index + ); + +#endif diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c new file mode 100644 index 0000000..d8dba6e --- /dev/null +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c @@ -0,0 +1,96 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 "NonDiscoverableInitLib.h" + +STATIC CONST MV_GPIO_PIN mXhciVbusPins[] = { + { + ARMADA_70x0_DB_IO_EXPANDER0, + ARMADA_70x0_DB_VBUS0_PIN, + TRUE, + }, + { + ARMADA_70x0_DB_IO_EXPANDER0, + ARMADA_70x0_DB_VBUS0_LIMIT_PIN, + TRUE, + }, + { + ARMADA_70x0_DB_IO_EXPANDER0, + ARMADA_70x0_DB_VBUS1_PIN, + TRUE, + }, + { + ARMADA_70x0_DB_IO_EXPANDER0, + ARMADA_70x0_DB_VBUS1_LIMIT_PIN, + TRUE, + }, +}; + +STATIC +EFI_STATUS +EFIAPI +XhciInit ( + IN NON_DISCOVERABLE_DEVICE *This + ) +{ + CONST MV_GPIO_PIN *VbusPin; + EMBEDDED_GPIO_MODE Mode; + EMBEDDED_GPIO_PIN Gpio; + EMBEDDED_GPIO *GpioProtocol; + EFI_STATUS Status; + UINTN Index; + + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__)); + return Status; + } + + VbusPin = mXhciVbusPins; + for (Index = 0; Index < ARRAY_SIZE (mXhciVbusPins); Index++) { + Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0; + Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber); + GpioProtocol->Set (GpioProtocol, Gpio, Mode); + VbusPin++; + } + + return EFI_SUCCESS; +} + +NON_DISCOVERABLE_DEVICE_INIT +EFIAPI +NonDiscoverableDeviceInitializerGet ( + IN NON_DISCOVERABLE_DEVICE_TYPE Type, + IN UINTN Index + ) +{ + if (Type == NonDiscoverableDeviceTypeXhci) { + return XhciInit; + } + + return NULL; +} diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c new file mode 100644 index 0000000..e7a1d1e --- /dev/null +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c @@ -0,0 +1,106 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 "NonDiscoverableInitLib.h" + +STATIC CONST MV_GPIO_PIN mXhciVbusPins[] = { + { + ARMADA_80x0_DB_IO_EXPANDER0, + ARMADA_80x0_DB_VBUS0_PIN, + TRUE, + }, + { + ARMADA_80x0_DB_IO_EXPANDER0, + ARMADA_80x0_DB_VBUS0_LIMIT_PIN, + TRUE, + }, + { + ARMADA_80x0_DB_IO_EXPANDER0, + ARMADA_80x0_DB_VBUS1_PIN, + TRUE, + }, + { + ARMADA_80x0_DB_IO_EXPANDER0, + ARMADA_80x0_DB_VBUS1_LIMIT_PIN, + TRUE, + }, + { + ARMADA_80x0_DB_IO_EXPANDER1, + ARMADA_80x0_DB_VBUS2_PIN, + TRUE, + }, + { + ARMADA_80x0_DB_IO_EXPANDER1, + ARMADA_80x0_DB_VBUS2_LIMIT_PIN, + TRUE, + }, +}; + +STATIC +EFI_STATUS +EFIAPI +XhciInit ( + IN NON_DISCOVERABLE_DEVICE *This + ) +{ + CONST MV_GPIO_PIN *VbusPin; + EMBEDDED_GPIO_MODE Mode; + EMBEDDED_GPIO_PIN Gpio; + EMBEDDED_GPIO *GpioProtocol; + EFI_STATUS Status; + UINTN Index; + + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__)); + return Status; + } + + VbusPin = mXhciVbusPins; + for (Index = 0; Index < ARRAY_SIZE (mXhciVbusPins); Index++) { + Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0; + Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber); + GpioProtocol->Set (GpioProtocol, Gpio, Mode); + VbusPin++; + } + + return EFI_SUCCESS; +} + +NON_DISCOVERABLE_DEVICE_INIT +EFIAPI +NonDiscoverableDeviceInitializerGet ( + IN NON_DISCOVERABLE_DEVICE_TYPE Type, + IN UINTN Index + ) +{ + if (Type == NonDiscoverableDeviceTypeXhci) { + return XhciInit; + } + + return NULL; +} diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c new file mode 100644 index 0000000..d1055cb --- /dev/null +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c @@ -0,0 +1,71 @@ +/** +* +* Copyright (c) 2017, Linaro Ltd. All rights reserved. +* Copyright (c) 2018, Marvell International 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 "NonDiscoverableInitLib.h" + +STATIC CONST MV_GPIO_PIN mXhciVbusPin = { + MV_GPIO_CP0_CONTROLLER1, + ARMADA_80x0_MCBIN_VBUS0_PIN, + TRUE, +}; + +STATIC +EFI_STATUS +EFIAPI +XhciInit ( + IN NON_DISCOVERABLE_DEVICE *This + ) +{ + EMBEDDED_GPIO *GpioProtocol; + EFI_STATUS Status; + + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER, &GpioProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__)); + return Status; + } + + GpioProtocol->Set (GpioProtocol, + GPIO (mXhciVbusPin.ControllerId, mXhciVbusPin.PinNumber), + GPIO_MODE_OUTPUT_1); + + return Status; +} + +NON_DISCOVERABLE_DEVICE_INIT +EFIAPI +NonDiscoverableDeviceInitializerGet ( + IN NON_DISCOVERABLE_DEVICE_TYPE Type, + IN UINTN Index + ) +{ + if (Type == NonDiscoverableDeviceTypeXhci) { + return XhciInit; + } + + return NULL; +} diff --git a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c index 116e9d4..74040b2 100644 --- a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c +++ b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c @@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include @@ -57,7 +58,9 @@ NonDiscoverableInitXhci ( Status = RegisterNonDiscoverableMmioDevice ( NonDiscoverableDeviceTypeXhci, Desc[i].SoC->XhciDmaType, - NULL, + NonDiscoverableDeviceInitializerGet ( + NonDiscoverableDeviceTypeXhci, + i), NULL, 1, Desc[i].SoC->XhciBaseAddress, @@ -86,7 +89,9 @@ NonDiscoverableInitAhci ( Status = RegisterNonDiscoverableMmioDevice ( NonDiscoverableDeviceTypeAhci, Desc[i].SoC->AhciDmaType, - NULL, + NonDiscoverableDeviceInitializerGet ( + NonDiscoverableDeviceTypeAhci, + i), NULL, 1, Desc[i].SoC->AhciBaseAddress, @@ -115,7 +120,9 @@ NonDiscoverableInitSdhci ( Status = RegisterNonDiscoverableMmioDevice ( NonDiscoverableDeviceTypeSdhci, Desc[i].SoC->SdMmcDmaType, - NULL, + NonDiscoverableDeviceInitializerGet ( + NonDiscoverableDeviceTypeSdhci, + i), NULL, 1, Desc[i].SoC->SdMmcBaseAddress, -- 2.7.4