diff mbox

[edk2,v2] OptionRomPkg: Ax88772b: support for multiple dongles and chips

Message ID 1458745767-22873-1-git-send-email-shivamurthy.shastri@linaro.org
State Accepted
Commit 9a1c4beca0463066660635c2494bb8cf66d4c4bd
Headers show

Commit Message

Shivamurthy Shastri March 23, 2016, 3:09 p.m. UTC
Driver code is modified to support multiple ethernet dongles, which uses
similar ASIX chips. Also, it can be used for multiple ASIX chips with
similar register map.

Enabled support for Apple Ethernet Adapter

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linaro.org>

---
 .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h       | 16 ++++++++---
 .../Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c | 33 +++++++++++++---------
 2 files changed, 32 insertions(+), 17 deletions(-)

-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Shivamurthy Shastri March 30, 2016, 2:15 a.m. UTC | #1
On 23 March 2016 at 20:39, Shivamurthy Shastri <
shivamurthy.shastri@linaro.org> wrote:

> Driver code is modified to support multiple ethernet dongles, which uses
> similar ASIX chips. Also, it can be used for multiple ASIX chips with
> similar register map.
>
> Enabled support for Apple Ethernet Adapter
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linaro.org>
> ---
>  .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h       | 16 ++++++++---
>  .../Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c | 33
> +++++++++++++---------
>  2 files changed, 32 insertions(+), 17 deletions(-)
>
> diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
> b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
> index ab75ec2..286bdab 100644
> --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
> +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
> @@ -141,9 +141,6 @@
>
>  #define DEV_SIGNATURE     SIGNATURE_32 ('A','X','8','8')  ///<  Signature
> of data structures in memory
>
> -#define VENDOR_ID         0x0B95  ///<  Vendor ID for Asix
> -#define PRODUCT_ID        0x772B  ///<  Product ID for the AX88772 USB
> 10/100 Ethernet controller
> -
>  #define RESET_MSEC        1000    ///<  Reset duration
>  #define PHY_RESET_MSEC     500    ///<  PHY reset duration
>
> @@ -297,12 +294,23 @@
>  #define AN_10_HDX                       0x0020  ///<  1 = 10BASE-T support
>  #define AN_CSMA_CD                      0x0001  ///<  1 = IEEE 802.3
> CSMA/CD support
>
> -
> +// asix_flags defines
> +#define FLAG_NONE               0
> +#define FLAG_TYPE_AX88172       BIT0
> +#define FLAG_TYPE_AX88772       BIT1
> +#define FLAG_TYPE_AX88772B      BIT2
> +#define FLAG_EEPROM_MAC         BIT3  // initial mac address in eeprom
>
>
>  //------------------------------------------------------------------------------
>  //  Data Types
>
>  //------------------------------------------------------------------------------
>
> +typedef struct {
> +   UINT16  VendorId;
> +   UINT16  ProductId;
> +   INT32   Flags;
> +}ASIX_DONGLE;
> +
>  /**
>    Ethernet header layout
>
> diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
> b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
> index 3b73040..5aed2ec 100644
> --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
> +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
> @@ -14,6 +14,13 @@
>
>  #include "Ax88772.h"
>
> +ASIX_DONGLE ASIX_DONGLES[] = {
> +  { 0x05AC, 0x1402, FLAG_TYPE_AX88772 }, // Apple USB Ethernet Adapter
> +  // ASIX 88772B
> +  { 0x0B95, 0x772B, FLAG_TYPE_AX88772B | FLAG_EEPROM_MAC },
> +  { 0x0000, 0x0000, FLAG_NONE }   // END - Do not remove
> +};
> +
>  /**
>    Verify the controller type
>
> @@ -36,6 +43,8 @@ DriverSupported (
>    EFI_USB_DEVICE_DESCRIPTOR Device;
>    EFI_USB_IO_PROTOCOL * pUsbIo;
>    EFI_STATUS Status;
> +  UINT32 Index;
> +
>    //
>    //  Connect to the USB stack
>    //
> @@ -60,19 +69,17 @@ DriverSupported (
>      else {
>        //
>        //  Validate the adapter
> -      //
> -      if ( VENDOR_ID == Device.IdVendor ) {
> -
> -        if (PRODUCT_ID == Device.IdProduct) {
> -            DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
> -        }
> -                   else  {
> -                            Status = EFI_UNSUPPORTED;
> -                   }
> -      }
> -           else {
> -                     Status = EFI_UNSUPPORTED;
> -       }
> +      //
> +      for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) {
> +        if (ASIX_DONGLES[Index].VendorId == Device.IdVendor &&
> +            ASIX_DONGLES[Index].ProductId == Device.IdProduct) {
> +              DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
> +              break;
> +        }
> +      }
> +
> +      if (ASIX_DONGLES[Index].VendorId == 0)
> +         Status = EFI_UNSUPPORTED;
>      }
>
>      //
> --
> 1.9.1
>
>
​Hi Ruiyu Ni,

I have changed patch as per your comments.
Please review the patch.

Thanks,
Shiva​
diff mbox

Patch

diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
index ab75ec2..286bdab 100644
--- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
+++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
@@ -141,9 +141,6 @@ 
 
 #define DEV_SIGNATURE     SIGNATURE_32 ('A','X','8','8')  ///<  Signature of data structures in memory
 
-#define VENDOR_ID         0x0B95  ///<  Vendor ID for Asix
-#define PRODUCT_ID        0x772B  ///<  Product ID for the AX88772 USB 10/100 Ethernet controller
-
 #define RESET_MSEC        1000    ///<  Reset duration
 #define PHY_RESET_MSEC     500    ///<  PHY reset duration
 
@@ -297,12 +294,23 @@ 
 #define AN_10_HDX                       0x0020  ///<  1 = 10BASE-T support
 #define AN_CSMA_CD                      0x0001  ///<  1 = IEEE 802.3 CSMA/CD support
 
-
+// asix_flags defines
+#define FLAG_NONE               0
+#define FLAG_TYPE_AX88172       BIT0
+#define FLAG_TYPE_AX88772       BIT1
+#define FLAG_TYPE_AX88772B      BIT2
+#define FLAG_EEPROM_MAC         BIT3  // initial mac address in eeprom
 
 //------------------------------------------------------------------------------
 //  Data Types
 //------------------------------------------------------------------------------
 
+typedef struct {
+   UINT16  VendorId;
+   UINT16  ProductId;
+   INT32   Flags;
+}ASIX_DONGLE;
+
 /**
   Ethernet header layout
 
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
index 3b73040..5aed2ec 100644
--- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
+++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
@@ -14,6 +14,13 @@ 
 
 #include "Ax88772.h"
 
+ASIX_DONGLE ASIX_DONGLES[] = {
+  { 0x05AC, 0x1402, FLAG_TYPE_AX88772 }, // Apple USB Ethernet Adapter
+  // ASIX 88772B
+  { 0x0B95, 0x772B, FLAG_TYPE_AX88772B | FLAG_EEPROM_MAC },
+  { 0x0000, 0x0000, FLAG_NONE }   // END - Do not remove
+};
+
 /**
   Verify the controller type
 
@@ -36,6 +43,8 @@  DriverSupported (
   EFI_USB_DEVICE_DESCRIPTOR Device;
   EFI_USB_IO_PROTOCOL * pUsbIo;
   EFI_STATUS Status;
+  UINT32 Index;
+
   //
   //  Connect to the USB stack
   //
@@ -60,19 +69,17 @@  DriverSupported (
     else {
       //
       //  Validate the adapter
-      //   
-      if ( VENDOR_ID == Device.IdVendor ) {
-
-        if (PRODUCT_ID == Device.IdProduct) {
-            DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
-        }
-		    else  {
-			     Status = EFI_UNSUPPORTED;
-		    }
-      }
-	    else {
-		      Status = EFI_UNSUPPORTED;
-       }   
+      //
+      for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) {
+        if (ASIX_DONGLES[Index].VendorId == Device.IdVendor &&
+            ASIX_DONGLES[Index].ProductId == Device.IdProduct) {
+              DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
+              break;
+        }
+      }
+
+      if (ASIX_DONGLES[Index].VendorId == 0)
+         Status = EFI_UNSUPPORTED;
     }
    
     //