From: Marcin Wojtas <mw@semihalf.com>
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
Subject: [platforms: PATCH 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support
Date: Sat, 20 Oct 2018 03:57:35 +0200 [thread overview]
Message-ID: <1540000661-1956-7-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1540000661-1956-1-git-send-email-mw@semihalf.com>
Introduce new callback that can provide information
about GPIO SoC controllers, as well as on-board
I2C IO expanders. According ArmadaSoCDescLib
ArmadaBoardDescLib routines are used for
obtaining required data.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf | 1 +
Silicon/Marvell/Include/Protocol/BoardDesc.h | 8 ++++
Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 48 ++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
index 41f72d6..0b93948 100644
--- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
+++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
@@ -47,6 +47,7 @@
Silicon/Marvell/Marvell.dec
[LibraryClasses]
+ ArmadaBoardDescLib
ArmadaSoCDescLib
DebugLib
MemoryAllocationLib
diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h b/Silicon/Marvell/Include/Protocol/BoardDesc.h
index 1d57a16..e06d689 100644
--- a/Silicon/Marvell/Include/Protocol/BoardDesc.h
+++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h
@@ -50,6 +50,13 @@ EFI_STATUS
typedef
EFI_STATUS
+(EFIAPI *MV_BOARD_DESC_GPIO_GET) (
+ IN MARVELL_BOARD_DESC_PROTOCOL *This,
+ IN OUT MV_BOARD_GPIO_DESC **GpioDesc
+ );
+
+typedef
+EFI_STATUS
(EFIAPI *MV_BOARD_DESC_I2C_GET) (
IN MARVELL_BOARD_DESC_PROTOCOL *This,
IN OUT MV_BOARD_I2C_DESC **I2cDesc
@@ -106,6 +113,7 @@ VOID
struct _MARVELL_BOARD_DESC_PROTOCOL {
MV_BOARD_DESC_AHCI_GET BoardDescAhciGet;
MV_BOARD_DESC_COMPHY_GET BoardDescComPhyGet;
+ MV_BOARD_DESC_GPIO_GET BoardDescGpioGet;
MV_BOARD_DESC_I2C_GET BoardDescI2cGet;
MV_BOARD_DESC_MDIO_GET BoardDescMdioGet;
MV_BOARD_DESC_PP2_GET BoardDescPp2Get;
diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
index 39dc06c..948a6a0 100644
--- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
+++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
@@ -100,6 +100,53 @@ MvBoardDescComPhyGet (
STATIC
EFI_STATUS
+MvBoardDescGpioGet (
+ IN MARVELL_BOARD_DESC_PROTOCOL *This,
+ IN OUT MV_BOARD_GPIO_DESC **GpioDesc
+ )
+{
+ MV_I2C_IO_EXPANDER_DESC *I2cIoExpanderDesc;
+ UINTN SoCGpioCount, I2cIoExpanderCount;
+ STATIC MV_BOARD_GPIO_DESC *BoardDesc;
+ MV_SOC_GPIO_DESC *SoCDesc;
+ EFI_STATUS Status;
+
+ if (BoardDesc != NULL) {
+ *GpioDesc = BoardDesc;
+ return EFI_SUCCESS;
+ }
+
+ /* Get SoC data about all available GPIO controllers */
+ Status = ArmadaSoCDescGpioGet (&SoCDesc, &SoCGpioCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ /* Get per-board information about all available I2C IO expanders */
+ Status = ArmadaBoardDescGpioGet (&I2cIoExpanderDesc, &I2cIoExpanderCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ /* Allocate and fill board description */
+ BoardDesc = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESC));
+ if (BoardDesc == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ BoardDesc->SoC = SoCDesc;
+ BoardDesc->GpioDevCount = SoCGpioCount;
+ BoardDesc->I2cIoExpanderDesc = I2cIoExpanderDesc;
+ BoardDesc->I2cIoExpanderCount = I2cIoExpanderCount;
+
+ *GpioDesc = BoardDesc;
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
MvBoardDescI2cGet (
IN MARVELL_BOARD_DESC_PROTOCOL *This,
IN OUT MV_BOARD_I2C_DESC **I2cDesc
@@ -556,6 +603,7 @@ MvBoardDescInitProtocol (
{
BoardDescProtocol->BoardDescAhciGet = MvBoardDescAhciGet;
BoardDescProtocol->BoardDescComPhyGet = MvBoardDescComPhyGet;
+ BoardDescProtocol->BoardDescGpioGet = MvBoardDescGpioGet;
BoardDescProtocol->BoardDescI2cGet = MvBoardDescI2cGet;
BoardDescProtocol->BoardDescMdioGet = MvBoardDescMdioGet;
BoardDescProtocol->BoardDescPp2Get = MvBoardDescPp2Get;
--
2.7.4
next prev parent reply other threads:[~2018-10-20 1:58 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-20 1:57 [platforms: PATCH 00/12] Armada7k8k GPIO support Marcin Wojtas
2018-10-20 1:57 ` [platforms: PATCH 01/12] Marvell/Library: ArmadaSoCDescLib: Add GPIO information Marcin Wojtas
2018-11-14 1:10 ` Leif Lindholm
2018-11-14 6:05 ` Marcin Wojtas
2018-11-14 17:33 ` Leif Lindholm
2018-11-21 1:26 ` Marcin Wojtas
2018-11-26 14:49 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 02/12] Marvell/Library: ArmadaBoardDescLib: " Marcin Wojtas
2018-11-14 1:12 ` Leif Lindholm
2018-11-14 6:16 ` Marcin Wojtas
2018-11-14 17:29 ` Leif Lindholm
2018-12-04 15:18 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 03/12] SolidRun/Armada80x0McBin: Introduce board description library Marcin Wojtas
2018-12-04 15:23 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 04/12] Marvell/Armada70x0Db: " Marcin Wojtas
2018-12-04 15:27 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 05/12] Marvell/Armada80x0Db: " Marcin Wojtas
2018-12-04 15:31 ` Leif Lindholm
2018-10-20 1:57 ` Marcin Wojtas [this message]
2018-12-04 15:42 ` [platforms: PATCH 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 07/12] Marvell/Protocol: Introduce MARVELL_GPIO_PROTOCOL Marcin Wojtas
2018-12-04 16:00 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 08/12] Marvell/Drivers: MvGpioDxe: Introduce platform GPIO driver Marcin Wojtas
2018-12-04 16:37 ` Leif Lindholm
2018-12-04 16:40 ` Ard Biesheuvel
2018-12-04 17:19 ` Leif Lindholm
2018-12-04 17:20 ` Ard Biesheuvel
2018-10-20 1:57 ` [platforms: PATCH 09/12] Marvell/Drivers: I2c: Use common header for macros Marcin Wojtas
2018-12-04 16:38 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 10/12] Marvell/Drivers: MvPca95xxDxe: Introduce I2C GPIO driver Marcin Wojtas
2018-12-04 17:02 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 11/12] Marvell/Armada7k8k: Enable GPIO drivers compilation Marcin Wojtas
2018-12-04 17:06 ` Leif Lindholm
2018-10-20 1:57 ` [platforms: PATCH 12/12] Marvell/Armada7k8k: Introduce NonDiscoverable device init routines Marcin Wojtas
2018-12-04 17:16 ` Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1540000661-1956-7-git-send-email-mw@semihalf.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox