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 3598720972843 for ; Sun, 17 Jun 2018 13:12:58 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id o9-v6so21582295lfk.1 for ; Sun, 17 Jun 2018 13:12:58 -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=txjmPRBCWDECdYrUOWxvSUnyTROVyn7Mkw4rN44bmo8=; b=OglvTktCY7aL+w7U6/dykaqkY2YYyWE5rRbRH+kYHCINPzHqkz98pqxhQYeLxZoI3F gvbJ7aqfMmXvwuv08JK7eMX+WfKiV7To2cyzivHZIxiCJKQ2pWN+wpWKRP3KFfGp5Jvf x3lq0dAbdI4ljLPIKceN66qWiO3Z7tQOyk6f8UDWtL7o1cfhrfnoqGIpZo1ff1MhzVPP BsBj8Db2jKzKQygcMpI+0LkWZo6/bswEmqGsf2XiEVLU1pjvIg/F+5NHy6e8OkHBTQHI b/U7yj6p4uBWvmSXt37IA58WKpIfos2Nz3B0KLcKXo9mVLxOaHFJZ48eM0wE6QBNeEL0 96mA== 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=txjmPRBCWDECdYrUOWxvSUnyTROVyn7Mkw4rN44bmo8=; b=KpbiE1aY/jbdnVdUk7Y5JPDxH3+2BAtVd4R1k8+sKuaUm/Y3USY/5tasWdkdkWu3jC USl4RQoMrtLvmbaITfW34S0WiJTqsJBXWQpGaWx0EG3AVmvd5vt7E2mJLPkAAj7zvAgx sh0KaWlSjvtAkVbZj+gwrSaxR5UWSiuU3tNeI26hGcPGUlhGxEm+AIR51/29zRQ7Ce6p YkF4j0LyqH324bYOZqPckxGe5CKVCx85Msn+hZzS/z0/ayQKFKKPZBfChv7RULStUtUv 7Rf/sJ2vba9+2Nuq6dSeWqIPsDRNW+aN+woVOTBIVNEHB81ZzBlP32wR0teLmIdZ77YD nfWw== X-Gm-Message-State: APt69E12I8w6i8+txHAPZvyP+os7Svxj39+nuLxKu9uln1jyEtnpDyUn mCbPi7pR4UkXvluQ9KWhgGBvSUTySOY= X-Google-Smtp-Source: ADUXVKJ1CdFYDSOLrrPCvpGbKtSRvOJNYEyPN3bJcg0w/MZnYGXBV4hFyjTNcaAAk2JbOyY7Qoo2wg== X-Received: by 2002:a2e:1dd9:: with SMTP id w86-v6mr6145252lje.110.1529266376303; Sun, 17 Jun 2018 13:12:56 -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 q75-v6sm387272lfq.47.2018.06.17.13.12.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 13:12:55 -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: Sun, 17 Jun 2018 22:12:04 +0200 Message-Id: <1529266325-18371-25-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529266325-18371-1-git-send-email-mw@semihalf.com> References: <1529266325-18371-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v2 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: Sun, 17 Jun 2018 20:12:58 -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 --- 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