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 E4BC72110A006 for ; Mon, 18 Jun 2018 15:59:31 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id x13-v6so11720492lff.10 for ; Mon, 18 Jun 2018 15:59:31 -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=48Re+kklzRZO4J3+y1wRUlw4RXxrsc0ZdFtQT+ooXFw=; b=sscSWUVpV/wg7s6W0Mhd8xoolFBvsz7ViYJHD9Rx00Cc7o218wUvU0g3OFZatbDHY8 4G2gylIsyPphNpPrBUW9NOAiv1ptr6s031J18d+bJkBOsBspyjKz3TCIichiG8Do1E0R b+oTqywENSOYGchPucsBx4ASifP0r+6bmJn0D6okm4Mpj27qXT+axtEFyivyumu1GEXz AkOPzXPS5mzQfI0J7Wb/c7M88kTwuREExlNisC3rqbDkNYSsPu+2fueJ81FUf0+hp8ml em3fp4LEGZz8CCjKxHxB3L0F6/QkUSp19izQFQBWV89ErHIfg3OJvGoO8MwUQ2wRQiG/ Ma4g== 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=48Re+kklzRZO4J3+y1wRUlw4RXxrsc0ZdFtQT+ooXFw=; b=LdQXAbHQtpozHDmcBEOTbeKqGWzZkOaZOBi9hzIZt2AbecEXDHKI1fTg1+CB/IACLc rpd581q/jy2GqeMCVs2KlYvEFfek7B13DUC15GSLMcabmITYOXRbRwgCAiGULZgcrgUI JOMPDKi2tnCMKC4+YFObobZNDL9pmR4CQ95R4LOg+vC7R64XrgLFpzJKT77k3gbhwazW /43NjuMT5U/2NDPsUQn0RahVF82PVOMmETgjG7FDgGVvC72ybIIxlXv9p9h0wvA+6smg 1FWxcpeFx3p0bNe13mDf6eRBUFDkeCioUpcNAvvIp17wGgP8xskW5IhIZQBJIhD0sR64 To6Q== X-Gm-Message-State: APt69E2LXPY0Qsvu/HZNEmbN9yr3qJ6VsLMlAbbygvJhQxbSxtk1rk7n VsaLvyTJ9UhiCzQ0rZfeWLGMl2Ko4Ng= X-Google-Smtp-Source: ADUXVKINZzXA9IthBTcsudX0GksLilCmV1eBoXbf/cyFXtK9qbg8u7e5fbaDmd39g+TIZjLFHEa1ng== X-Received: by 2002:a2e:8590:: with SMTP id b16-v6mr9009574lji.131.1529362769950; Mon, 18 Jun 2018 15:59:29 -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 h136-v6sm3020754lfe.23.2018.06.18.15.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jun 2018 15:59:29 -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: Tue, 19 Jun 2018 00:58:43 +0200 Message-Id: <1529362724-9244-25-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529362724-9244-1-git-send-email-mw@semihalf.com> References: <1529362724-9244-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v3 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: Mon, 18 Jun 2018 22:59:32 -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: Leif Lindholm --- Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf | 1 + Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 37 +++++++++----------- 2 files changed, 18 insertions(+), 20 deletions(-) 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 diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index d6f590d..9ec4929 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; EFI_STATUS Status; + UINTN Index; - /* 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; } -- 2.7.4