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 E774C2117B571 for ; Fri, 19 Oct 2018 18:58:12 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id o21-v6so26576622lfe.0 for ; Fri, 19 Oct 2018 18:58:12 -0700 (PDT) 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=jyAPmFKZA4RmmEN1rSHrtL0/GyC6u70Y7z9BDTjDJq8=; b=vsq5huCl9snB8psOc1BxPVjcVkF5E3tiUhSlTwVhpKMbykP3Tcxpff46c8eU39F/N0 vBhPiSvUWlhXpoChYXqGK/5SWzKBkBX6lCSQlYCxlxtP9fjNWiWeriG5h9euYbzlDK/x yjCUen5OxTyXMaaUANBLkHfE5bOjVrsYkiLVPsz5BjobiT30KaR2jLegap/b3TFeSdLk TDFl8yq38jsttBAZ8cUWytvFipJ6W6RhGH1JOr8epYf7C2qOFjH85UW/a6w6eGWDSg4c Qg4of3EmbR1Pp1EkyLaGjN2KkA99FnYzcQ3rDgGCaC5raf23MMZMtWTKLBFDF3yAQap8 muTg== 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=jyAPmFKZA4RmmEN1rSHrtL0/GyC6u70Y7z9BDTjDJq8=; b=pjPT6xXaFm9ChWMRx2RJk0ISM5khUAM5N9BQfM6BrrlZPBoBJfRulXnc5+u7GaMfn7 3T6z+d9RwCRxB3I3OOpr7jda6QzMpGSnDurdtFIkf+WrCV4g+q4o0vq+wuJe2RWq+DGe 9pQnr5ie9jFKEcQWpONDldlNxwMq1+Xnb/r6bUkTrI4hb+x3Ymdi9gAWYrP3o5lq46pQ +54+VyuC8PNclBm59iUyQ4N7RmQsVwnPtQ9C1kkbXYr7hAFinp6YuDXwlPd65CkDCz9y C73xvjT1603tKFadlJyDQhCDZWO8Ms4j4FHznnz94ZvqrKXS/0zX5NcV5dOgjHbFhh/U mDGw== X-Gm-Message-State: ABuFfogu4WwnRJrSldEO4/UsA63+lHzk9DflnNkq8l4G0KDDM59DWse9 56LdtROpbRK8cNSRfHgnXO5rgdTk5pg= X-Google-Smtp-Source: ACcGV62Spq4m68IjBjmp6e/iilXo5L+sbHP8yCVbMXXq/kZktK3N6lixk8WJPX2xFAZNWYv2ht7fdw== X-Received: by 2002:a19:4411:: with SMTP id r17-v6mr4734477lfa.87.1540000691023; Fri, 19 Oct 2018 18:58:11 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id p63-v6sm5562777lfg.46.2018.10.19.18.58.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Oct 2018 18:58:10 -0700 (PDT) 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: Sat, 20 Oct 2018 03:57:35 +0200 Message-Id: <1540000661-1956-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540000661-1956-1-git-send-email-mw@semihalf.com> References: <1540000661-1956-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support 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: Sat, 20 Oct 2018 01:58:13 -0000 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 --- 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