From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::242; helo=mail-lf0-x242.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C52542112500C for ; Fri, 8 Jun 2018 08:35:13 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id 36-v6so20679489lfr.11 for ; Fri, 08 Jun 2018 08:35:13 -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=pkbl1baEnS4Ft4q4RUz3QrHFCPwP0zkmf08HS3bYnJo=; b=tARhoWiJozZRYFJoICMg1SAG4OTEcgz1ls7tSm3g2bAfW9RbbtkTlQIIy3x3P4bIpo ZN7F/05bL6ELkeZx0h2aGGSqeddWBsrqR8/nSRs/NJYR8fC/+UPDjLm9xf7Scb3YxfO3 W0xk4behElbf9xST95TmGMLZF/o7waiiMBP6qkoVdD0mNBIYtSa4n23xPpwur4KJRiLA kcnEOwakrRx5cYQLLUG+l5cAuYqmDnoLI8sEE4b+bF8sAjUY5CkjygOHUDJHYleXOpxj zJEIElJ5zZ3BI1oegMqSSQlAKzI+ACKfpdVJ25tcQ+bq9Emg2kl2rUx20qjGDcVcS3Kt GsVA== 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=pkbl1baEnS4Ft4q4RUz3QrHFCPwP0zkmf08HS3bYnJo=; b=M8eXuDpN996iavOM5wGopRyqS3GRYQEWA3eh7dbOXB1Itt/FU4MKqO7rWJoGbOHlYg xSpGe5c3K/7pqyCHpjQ0pOusYmaPea1wZ+fJHSx+Y5zXB6F2JFWM85H9+9Sa2kxRQzpu Cv7r1ApG3HXtdVErAbo77OPlXtTNIR8R3IAeXMPLqzCTwvJdoBFLR4tTlekQTqe0HsU8 BDjuObAvKa4BCwX9XkuFGANZj8XgsHoSsLmKsGmfIEgX4aQ/HEWlxvRKM27uzgVnBnu0 e2hvbuxOdzzTb5TAwvZDfTFSFhITJhYNI6fZswJ/tYGGxcMNVFgawW7AfwHcR6o7GXsK kPPg== X-Gm-Message-State: APt69E34WSIRDLgsYXsfxTEMHFABveCG/YLmFq7+EaJHkz7LDW/1CuiH Ak7Gk5IQON1s2BXjuxiy6+fhz+kOpa4= X-Google-Smtp-Source: ADUXVKLsKNvgBOJF6nf0p3Lkkg/iSH0tFOjefBQ3xVWcw+gVjcFJ6TmviRyNS5ZzMc2Iu+/f+hl04w== X-Received: by 2002:a2e:96c6:: with SMTP id d6-v6mr4910117ljj.21.1528472111704; Fri, 08 Jun 2018 08:35: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 v79-v6sm7355396lfd.32.2018.06.08.08.35.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 08:35:11 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jinghua@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com Date: Fri, 8 Jun 2018 17:34:22 +0200 Message-Id: <1528472063-1660-25-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528472063-1660-1-git-send-email-mw@semihalf.com> References: <1528472063-1660-1-git-send-email-mw@semihalf.com> Subject: [platforms PATCH 24/25] Marvell/Drivers: MvI2cDxe: Switch driver to use MARVELL_BOARD_DESC X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 15:35:14 -0000 MvI2cDxe driver used to get Armada7k8k controller description from hardcoded values stored in the header file MvHwDescLib.h. As a result it is very hard to support other Armada SoC families with this driver. This patch updates the driver, so that it can obtain the description from newly introduced MARVELL_BOARD_DESC protocol, and removes the dependency on the hardcoded structures. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Hua Jing --- Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 37 +++++++++----------- Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf | 1 + 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index d6f590d..8694198 100755 --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c @@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ +#include #include #include #include @@ -43,13 +44,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include "MvI2cDxe.h" -DECLARE_A7K8K_I2C_TEMPLATE; - STATIC MV_I2C_BAUD_RATE baud_rate; STATIC MV_I2C_DEVICE_PATH MvI2cDevicePathProtocol = { @@ -174,38 +172,37 @@ MvI2cInitialise ( IN EFI_SYSTEM_TABLE *SystemTable ) { - MVHW_I2C_DESC *Desc = &mA7k8kI2cDescTemplate; - UINT8 *I2cDeviceTable, Index; + MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol; + MV_BOARD_I2C_DESC *Desc; + UINT8 Index; EFI_STATUS Status; - /* Obtain table with enabled I2c devices */ - I2cDeviceTable = (UINT8 *)PcdGetPtr (PcdI2cControllersEnabled); - if (I2cDeviceTable == NULL) { - DEBUG ((DEBUG_ERROR, "Missing PcdI2cControllersEnabled\n")); - return EFI_INVALID_PARAMETER; + /* Obtain list of available controllers */ + Status = gBS->LocateProtocol (&gMarvellBoardDescProtocolGuid, + NULL, + (VOID **)&BoardDescProtocol); + if (EFI_ERROR (Status)) { + return Status; } - if (PcdGetSize (PcdI2cControllersEnabled) > MVHW_MAX_I2C_DEVS) { - DEBUG ((DEBUG_ERROR, "Wrong PcdI2cControllersEnabled format\n")); - return EFI_INVALID_PARAMETER; + Status = BoardDescProtocol->BoardDescI2cGet (BoardDescProtocol, &Desc); + if (EFI_ERROR (Status)) { + return Status; } /* Initialize enabled chips */ - for (Index = 0; Index < PcdGetSize (PcdI2cControllersEnabled); Index++) { - if (!MVHW_DEV_ENABLED (I2c, Index)) { - DEBUG ((DEBUG_ERROR, "Skip I2c chip %d\n", Index)); - continue; - } - + for (Index = 0; Index < Desc->I2cDevCount; Index++) { Status = MvI2cInitialiseController( ImageHandle, SystemTable, - Desc->I2cBaseAddresses[Index] + Desc[Index].SoC->I2cBaseAddress ); if (EFI_ERROR(Status)) return Status; } + BoardDescProtocol->BoardDescFree (Desc); + return EFI_SUCCESS; } diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf index a7cf52e..0eef350 100755 --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf @@ -61,6 +61,7 @@ gEfiDevicePathProtocolGuid gEfiI2cEnumerateProtocolGuid gEfiI2cBusConfigurationManagementProtocolGuid + gMarvellBoardDescProtocolGuid [Pcd] gMarvellTokenSpaceGuid.PcdI2cSlaveAddresses -- 2.7.4