[patch] urtwn(4) 8188eu additions

2015-05-12 Thread Mikhail
Hello, inlined patch is a compilation of fixes which were pushed into
FreeBSD tree after 8188eu driver came in.

It adds four new usbdevs (r270191, r273589, r282120), fixes efuse length
and replaces magic numbers with proper defines (r281918), fixes efuse
access (r281592, r282623), and fixes man typo.

All revisions can be viewed by this url pattern:

https://svnweb.freebsd.org/base?view=revisionrevision=revision

Efuse changes from those revisions are overlapping, patch incorporates
final version.
Index: share/man/man4/urtwn.4
===
RCS file: /cvs/src/share/man/man4/urtwn.4,v
retrieving revision 1.33
diff -u -p -r1.33 urtwn.4
--- share/man/man4/urtwn.4  4 May 2015 14:30:06 -   1.33
+++ share/man/man4/urtwn.4  11 May 2015 12:20:23 -
@@ -28,7 +28,7 @@ The
 driver supports USB 2.0 wireless network devices based on Realtek
 RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU chipsets.
 .Pp
-The RTL8188CUS and RTL8188EUS are a highly integrated 802.11n adapter
+The RTL8188CUS and RTL8188EUS are a highly integrated 802.11n adapters
 that combines a MAC, a 1T1R capable baseband and an RF in a single chip.
 It operates in the 2GHz spectrum only.
 The RTL8188RU is a high-power variant of the RTL8188CUS.
@@ -98,11 +98,14 @@ The following adapters should work:
 .It B-Link BL-LW05-5R
 .It Belkin F7D1102 Surf Wireless Micro
 .It D-Link DWA-121
+.It D-Link DWA-123 rev D1
+.It D-Link DWA-125 rev D1
 .It D-Link DWA-131 rev B
 .It D-Link DWA-133
 .It D-Link DWA-135
 .It Digitus DN-7042
 .It Edimax EW-7811Un
+.It Elecom WDC-150SU2M
 .It EDUP EP-N8508
 .It Full River FR-W100NUL
 .It Hercules Wireless N USB Pico HWNUp-150
Index: sys/dev/usb/if_urtwn.c
===
RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v
retrieving revision 1.46
diff -u -p -r1.46 if_urtwn.c
--- sys/dev/usb/if_urtwn.c  10 May 2015 19:40:56 -  1.46
+++ sys/dev/usb/if_urtwn.c  11 May 2015 12:20:23 -
@@ -126,6 +126,7 @@ static const struct usb_devno urtwn_devs
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CU_0 },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CU_1 },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CU_2 },
+   { USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CU_3 },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CU_COMBO },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188CUS },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188RU },
@@ -143,6 +144,9 @@ static const struct usb_devno urtwn_devs
{ USB_VENDOR_TRENDNET,  USB_PRODUCT_TRENDNET_RTL8192CU },
{ USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RTL8192CU },
/* URTWN_RTL8188E */
+   { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWA123D1 },
+   { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWA125D1 },
+   { USB_VENDOR_ELECOM,USB_PRODUCT_ELECOM_WDC150SU2M },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188ETV },
{ USB_VENDOR_REALTEK,   USB_PRODUCT_REALTEK_RTL8188EU }
 };
@@ -305,7 +309,10 @@ urtwn_attach(struct device *parent, stru
return;
}
 
-   if (uaa-product == USB_PRODUCT_REALTEK_RTL8188EU ||
+   if (uaa-product == USB_PRODUCT_DLINK_DWA123D1 ||
+   uaa-product == USB_PRODUCT_DLINK_DWA125D1 ||
+   uaa-product == USB_PRODUCT_ELECOM_WDC150SU2M ||
+   uaa-product == USB_PRODUCT_REALTEK_RTL8188EU ||
uaa-product == USB_PRODUCT_REALTEK_RTL8188ETV)
sc-chip |= URTWN_CHIP_88E;
 
@@ -922,6 +929,8 @@ urtwn_efuse_read(struct urtwn_softc *sc)
printf(\n);
}
 #endif
+
+   urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
 }
 
 void
@@ -929,6 +938,8 @@ urtwn_efuse_switch_power(struct urtwn_so
 {
uint32_t reg;
 
+   urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
+
reg = urtwn_read_2(sc, R92C_SYS_ISO_CTRL);
if (!(reg  R92C_SYS_ISO_CTRL_PWC_EV12V)) {
urtwn_write_2(sc, R92C_SYS_ISO_CTRL,
@@ -1014,7 +1025,7 @@ urtwn_r88e_read_rom(struct urtwn_softc *
 
/* Read full ROM image. */
memset(sc-r88e_rom, 0xff, sizeof(sc-r88e_rom));
-   while (addr  1024) {
+   while (addr  512) {
reg = urtwn_efuse_read_1(sc, addr);
if (reg == 0xff)
break;
@@ -1040,6 +1051,8 @@ urtwn_r88e_read_rom(struct urtwn_softc *
}
}
 
+   urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
+
addr = 0x10;
for (i = 0; i  6; i++)
sc-cck_tx_pwr[i] = sc-r88e_rom[addr++];
@@ -1178,7 +1191,7 @@ urtwn_r88e_ra_init(struct urtwn_softc *s
reg = RW(reg, R92C_RRSR_RATE_BITMAP, rates);
urtwn_write_4(sc, R92C_RRSR, reg);
 
-   /* 
+   /*
 * Workaround for performance problems with firmware rate adaptation:
 * If 

Re: [patch] urtwn(4) 8188eu additions

2015-05-12 Thread Stuart Henderson
On 2015/05/12 16:35, Mikhail wrote:
 Hello, inlined patch is a compilation of fixes which were pushed into
 FreeBSD tree after 8188eu driver came in.
 
 It adds four new usbdevs (r270191, r273589, r282120), fixes efuse length
 and replaces magic numbers with proper defines (r281918), fixes efuse
 access (r281592, r282623), and fixes man typo.
 
 All revisions can be viewed by this url pattern:
 
 https://svnweb.freebsd.org/base?view=revisionrevision=revision
 
 Efuse changes from those revisions are overlapping, patch incorporates
 final version.

Seems reasonable to me. Minor manpage issue:

 Index: share/man/man4/urtwn.4
 ===
 RCS file: /cvs/src/share/man/man4/urtwn.4,v
 retrieving revision 1.33
 diff -u -p -r1.33 urtwn.4
 --- share/man/man4/urtwn.44 May 2015 14:30:06 -   1.33
 +++ share/man/man4/urtwn.411 May 2015 12:20:23 -
 @@ -28,7 +28,7 @@ The
  driver supports USB 2.0 wireless network devices based on Realtek
  RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU chipsets.
  .Pp
 -The RTL8188CUS and RTL8188EUS are a highly integrated 802.11n adapter
 +The RTL8188CUS and RTL8188EUS are a highly integrated 802.11n adapters
  that combines a MAC, a 1T1R capable baseband and an RF in a single chip.
  It operates in the 2GHz spectrum only.

Should be:

The RTL8188CUS and RTL8188EUS are highly integrated 802.11n adapters
that combine a MAC, a 1T1R capable baseband and an RF in a single chip.
They operate in the 2GHz spectrum only.

Rest is OK with me (though untested as I don't have a urtwn).