From patchwork Fri Feb 26 16:16:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 63081 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp802336lbc; Fri, 26 Feb 2016 08:17:07 -0800 (PST) X-Received: by 10.67.7.1 with SMTP id cy1mr3197544pad.123.1456503425365; Fri, 26 Feb 2016 08:17:05 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 4si20750097pfo.244.2016.02.26.08.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 08:17:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B77381A1E2D; Fri, 26 Feb 2016 08:17:09 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (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 A27A91A1E23 for ; Fri, 26 Feb 2016 08:17:07 -0800 (PST) Received: by mail-wm0-x234.google.com with SMTP id b205so78211771wmb.1 for ; Fri, 26 Feb 2016 08:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jZmOrbhhqLCqXAHuIzkV7WEQVXgNj/HPEtGgKP4Xt/A=; b=XXmL55vIE+xqHD9Ih13yxHGTk2zhj79dHSwm+4h+ZyIXZ3JFzanxsNkPnFPPtSs2uD tounG9K2kTi9fOs8xD71PE65lCt71ZgXX8+U0nN5UlPubARxRJN67vegmUrpBOFUpCPA EFMa+p2t5N8niPm20a3gkA25moiA5wljhE/dk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jZmOrbhhqLCqXAHuIzkV7WEQVXgNj/HPEtGgKP4Xt/A=; b=FChcO1TYcONmkCOpbYqrSQ3mKkFCePXA6YXffxAkQ8xtdmc3IVy+85bAugkDtvd4rl CEXNDqziWvlD8QInTryJw9Z6YNEg6ZRoFO7D4fpdfeGQIR1y5uh9YDhsjyV+4QdflAEZ 23MQZt43LkeREcZYtnKM8EQQ0EdXvHDKU/85YocrlIS+pvbkM/FzmIP4Ux5ZnHvOdL4Q LsIruRcx6qRz4lpwn9qNzZWMm4uHKv9oy8Imk3+AX6JupV2xr7af5sD/Z8PfUwyQYJWV yj6UJI0BTDfKlOKNKfNlRRtXG+YCNDsQd6suoDkt8QYr/QOSZCBaSfFCEp8EFiuL4rEf S7wg== X-Gm-Message-State: AD7BkJKAy9B/VFm26Nn7+m9aBoRQhfydmcgkswyTW2UkS8XqNlyMgma16Q9HhTpXzNSRO7K+ X-Received: by 10.194.11.67 with SMTP id o3mr2532343wjb.74.1456503421238; Fri, 26 Feb 2016 08:17:01 -0800 (PST) Received: from mohikan.mushroom.smurfnet.nu (cpc92308-cmbg19-2-0-cust814.5-4.cable.virginm.net. [82.24.251.47]) by smtp.gmail.com with ESMTPSA id k8sm13067962wjr.38.2016.02.26.08.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 08:17:00 -0800 (PST) From: Leif Lindholm To: edk2-devel@lists.01.org Date: Fri, 26 Feb 2016 16:16:53 +0000 Message-Id: <1456503415-17029-3-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456503415-17029-1-git-send-email-leif.lindholm@linaro.org> References: <1456503415-17029-1-git-send-email-leif.lindholm@linaro.org> Cc: Haojian Zhuang , Ard Biesheuvel Subject: [edk2] [PATCH 2/4] ArmPlatformPkg: PL061 - only initialize on protocol load X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" For whatever reason, every single operation on the PL061 looked for an "Initialized" flag, and manually called the initialization function if not set. Move this to a single call on protocol installation. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leif Lindholm --- ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c | 40 +++++-------------------- 1 file changed, 7 insertions(+), 33 deletions(-) -- 2.1.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c index 937b725..c8125fd 100644 --- a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c +++ b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c @@ -1,6 +1,7 @@ /** @file * * Copyright (c) 2011, ARM Limited. All rights reserved. +* Copyright (c) 2016, Linaro Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD @@ -27,7 +28,6 @@ #include #include -BOOLEAN mPL061Initialized = FALSE; /** Function implementations @@ -78,8 +78,6 @@ PL061Initialize ( // // Ensure interrupts are disabled //} - mPL061Initialized = TRUE; - EXIT: return Status; } @@ -109,30 +107,19 @@ Get ( OUT UINTN *Value ) { - EFI_STATUS Status = EFI_SUCCESS; - if ( (Value == NULL) || (Gpio > LAST_GPIO_PIN)) { return EFI_INVALID_PARAMETER; } - // Initialize the hardware if not already done - if (!mPL061Initialized) { - Status = PL061Initialize(); - if (EFI_ERROR(Status)) { - goto EXIT; - } - } - if (MmioRead8 (PL061_GPIO_DATA_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) { *Value = 1; } else { *Value = 0; } - EXIT: - return Status; + return EFI_SUCCESS; } /** @@ -169,14 +156,6 @@ Set ( goto EXIT; } - // Initialize the hardware if not already done - if (!mPL061Initialized) { - Status = PL061Initialize(); - if (EFI_ERROR(Status)) { - goto EXIT; - } - } - switch (Mode) { case GPIO_MODE_INPUT: @@ -233,22 +212,12 @@ GetMode ( OUT EMBEDDED_GPIO_MODE *Mode ) { - EFI_STATUS Status; - // Check for errors if ( (Mode == NULL) || (Gpio > LAST_GPIO_PIN)) { return EFI_INVALID_PARAMETER; } - // Initialize the hardware if not already done - if (!mPL061Initialized) { - Status = PL061Initialize(); - if (EFI_ERROR(Status)) { - return Status; - } - } - // Check if it is input or output if (MmioRead8 (PL061_GPIO_DIR_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) { // Pin set to output @@ -329,6 +298,11 @@ PL061InstallProtocol ( // ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEmbeddedGpioProtocolGuid); + Status = PL061Initialize(); + if (EFI_ERROR(Status)) { + return EFI_DEVICE_ERROR; + } + // Install the Embedded GPIO Protocol onto a new handle Handle = NULL; Status = gBS->InstallMultipleProtocolInterfaces(