From patchwork Wed Mar 30 07:48:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivamurthy Shastri X-Patchwork-Id: 64640 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2444315lbc; Wed, 30 Mar 2016 00:48:31 -0700 (PDT) X-Received: by 10.98.64.144 with SMTP id f16mr10533146pfd.159.1459324111059; Wed, 30 Mar 2016 00:48:31 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id zo2si4551440pac.221.2016.03.30.00.48.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 00:48:31 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 424D21A1F89; Wed, 30 Mar 2016 00:49:00 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pf0-x231.google.com (mail-pf0-x231.google.com [IPv6:2607:f8b0:400e:c00::231]) (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 725E41A1E3A for ; Wed, 30 Mar 2016 00:48:59 -0700 (PDT) Received: by mail-pf0-x231.google.com with SMTP id 4so35621828pfd.0 for ; Wed, 30 Mar 2016 00:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=p1khPu3kCJJ0mKj+aJY6Xf6vw7WfDltF3RSdGd6OeW4=; b=ZUG8Iu4QqStn7qtfLCVYKwqbjtgKf6gUr7bZ6eQeM0TCAKbLPsAAVvTDlOB2sVvoVa du+Q/5fjnJN5rscybcQDK7adVUZGWb9UpGW4TAndgbqlCjpZdlq4zrX9MBYdBTB54b0M hbmYLtF3aQi6sGpkf6n+txW3kBIvrD9s4UBwQ= 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; bh=p1khPu3kCJJ0mKj+aJY6Xf6vw7WfDltF3RSdGd6OeW4=; b=m3vsMszM/CknhVqX17z2Jlu5DoKavlNBFXEZmGEf2AHlw5VJlGjERwwruSFnJepCM0 SnO/wfYGJTHIvyWzhy/ZSoxR3fRV0uR5T5lfa/th9FuSGAmyFeCezvfMs7idwKJSxjMR tqpFf4ctw2h6jdE7NavrZplccYI77jEPlh7Pa2Lg2Fsn3fKFS+uw8iYtbqBKgznkUnfj BXeNLBu+X5HgY3AwsRnEI5OssJlrhb8lDDb9KuBmxwqlzbm52s4X4Qa9BIMXp6YWlZ8v 5bqvWsqnFwpDJ4Y0R9Vtdx3EZPaTBmIcV0jSlZ+RgukSzuBIFOFTlMQSXpkcS8C9z123 s0Bg== X-Gm-Message-State: AD7BkJJg1lacul4T1yktKULegYGoNe5yEnJ3X/pzVPiDjHSCvxBR3s2YnNPfE9uQj+kQOH1T X-Received: by 10.98.16.210 with SMTP id 79mr10660194pfq.69.1459324109522; Wed, 30 Mar 2016 00:48:29 -0700 (PDT) Received: from localhost.localdomain ([106.51.27.234]) by smtp.gmail.com with ESMTPSA id z13sm3483175pfi.5.2016.03.30.00.48.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 00:48:29 -0700 (PDT) From: Shivamurthy Shastri To: ruiyu.ni@intel.com Date: Wed, 30 Mar 2016 13:18:05 +0530 Message-Id: <1459324085-32475-1-git-send-email-shivamurthy.shastri@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [edk2] [PATCH v2] OptionRomPkg: Ax88772b: Fixing register access issue in Apple Eth Adapter X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: fathi.boudra@linaro.org, edk2-devel@lists.01.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The USB command CMD_RXQTC ("RX Queue Cascade Threshold Control") tries to access the register and is always failing when using the Apple Ethernet adapter. It is fixed by checking flag before sending command. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shivamurthy Shastri --- .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c | 19 ++++++----- .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h | 4 ++- .../Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c | 37 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c index 45ba3e5..e014d52 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c @@ -625,15 +625,18 @@ Ax88772Reset ( if (EFI_ERROR(Status)) goto err; - SetupMsg.RequestType = USB_REQ_TYPE_VENDOR - | USB_TARGET_DEVICE; - SetupMsg.Request = CMD_RXQTC; - SetupMsg.Value = 0x8000; - SetupMsg.Index = 0x8001; - SetupMsg.Length = 0; - Status = Ax88772UsbCommand ( pNicDevice, + if (pNicDevice->Flags != FLAG_TYPE_AX88772) { + SetupMsg.RequestType = USB_REQ_TYPE_VENDOR + | USB_TARGET_DEVICE; + SetupMsg.Request = CMD_RXQTC; + SetupMsg.Value = 0x8000; + SetupMsg.Index = 0x8001; + SetupMsg.Length = 0; + Status = Ax88772UsbCommand ( pNicDevice, &SetupMsg, - NULL ); + NULL ); + } + err: return Status; } diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h index a2109cf..92ac64d 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h @@ -404,7 +404,9 @@ typedef struct { RX_PKT * pFirstFill; UINTN PktCntInQueue; UINT8 * pBulkInBuff; - + + INT32 Flags; + } NIC_DEVICE; #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c index d64bc73..e5bb7e4 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c @@ -124,6 +124,8 @@ DriverStart ( UINTN LengthInBytes; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath = NULL; MAC_ADDR_DEVICE_PATH MacDeviceNode; + EFI_USB_DEVICE_DESCRIPTOR Device; + UINT32 Index; // // Allocate the device structure @@ -178,6 +180,41 @@ DriverStart ( goto EXIT; } + Status = pNicDevice->pUsbIo->UsbGetDeviceDescriptor ( pNicDevice->pUsbIo, &Device ); + if (EFI_ERROR ( Status )) { + gBS->CloseProtocol ( + Controller, + &gEfiUsbIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + gBS->FreePool ( pNicDevice ); + goto EXIT; + } else { + // + // Validate the adapter + // + for (i = 0; ASIX_DONGLES[i].VendorId != 0; i++) { + if (ASIX_DONGLES[i].VendorId == Device.IdVendor && + ASIX_DONGLES[i].ProductId == Device.IdProduct) { + break; + } + } + + if (ASIX_DONGLES[i].VendorId == 0) { + gBS->CloseProtocol ( + Controller, + &gEfiUsbIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + gBS->FreePool ( pNicDevice ); + goto EXIT; + } + + pNicDevice->Flags = ASIX_DONGLES[i].Flags; + } + // // Set Device Path //