Bug 249384 - Add support for Winbond CDC device in Tenma power supply
Summary: Add support for Winbond CDC device in Tenma power supply
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Hans Petter Selasky
URL:
Keywords:
: 249385 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-09-17 04:56 UTC by darius
Modified: 2020-10-20 08:14 UTC (History)
1 user (show)

See Also:


Attachments
Winbond CDC device ID (805 bytes, patch)
2020-09-17 04:56 UTC, darius
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description darius 2020-09-17 04:56:53 UTC
Created attachment 218017 [details]
Winbond CDC device ID

The Tenma 72-2635 bench top supply has a USB CDC interface with vendor 0x0416 product 0x5011.

With the attached patch I can connect to and control it.

I'm not sure what the name should be though.
Comment 1 Hans Petter Selasky freebsd_committer 2020-09-17 07:43:06 UTC
Could you also dump the USB device descriptor of this device using:

usbconfig -d ugenX.Y dump_device_desc

Thank you!

Patch looks good!

--HPS
Comment 2 darius 2020-09-17 08:02:18 UTC
Hmm I plugged this into a different system (12.0-RELEASE) and it worked out of the box with umodem, so perhaps there is a regression.

Requested output:

ugen0.4: <vendor 0x0416 USB Virtual COM> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0002  <Communication device>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x0416
  idProduct = 0x5011
  bcdDevice = 0x0300
  iManufacturer = 0x0001  <retrieving string failed>
  iProduct = 0x0002  <USB Virtual COM>
  iSerialNumber = 0x0003  <NT2009101400>
  bNumConfigurations = 0x0001
Comment 3 darius 2020-09-17 08:03:57 UTC
Also, I just realised I said I wrote the patch on FreeBSD 12.2-BETA1 but it was actually -CURRENT (20200827 r364846).
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2020-09-17 13:02:48 UTC
*** Bug 249385 has been marked as a duplicate of this bug. ***
Comment 5 darius 2020-09-18 00:01:48 UTC
I've attached a patch for the port.
I also filed a bug upstream (https://gitlab.freedesktop.org/xorg/driver/xf86-video-ast/-/issues/5) and notified ASPEED via email but I have no idea how responsive either of those will be.
Comment 6 darius 2020-09-18 00:02:25 UTC
(In reply to darius from comment #5)
Oops I replied to the wrong bug..
Comment 7 darius 2020-09-18 06:30:28 UTC
I checked again and it works out of the box on 12 but not 13.

When I plug it in under 13 I get the following:
usb_alloc_device: Failure selecting configuration index 0:USB_ERR_IOERROR, port 11, addr 6 (ignored)
ugen0.3: <vendor 0x0416 product 0x5011> at usbus0

If I use usbconfig to set the configuration index it works with the unmodified umodem.ko. Note that I don't see the IO error when running usbconfig, only when I first plug the device in.

ie I guess my patch is not needed but it indicates a regression in the USB stack from 12 to 13.
Comment 8 darius 2020-09-19 03:30:03 UTC
I built from git intending to do a bisect to find the problem but HEAD works:
FreeBSD maarsytest.gsoft.com.au 13.0-CURRENT FreeBSD 13.0-CURRENT #0 e48e67dde88-c271644(master): Fri Sep 18 06:55:14 UTC 2020     radar@maarsytest.gsoft.com.au:/usr/obj/local0/tmp/freebsd/amd64.amd64/sys/GENERIC  amd64
Comment 9 Hans Petter Selasky freebsd_committer 2020-09-19 08:07:51 UTC
> ie I guess my patch is not needed but it indicates a regression in the USB stack from 12 to 13.

There are similar devices which need a small delay before the configuration index can be selected.

Can you try to patch sys/dev/usb/ 's 

usb_error_t
usbd_set_config_index(struct usb_device *udev, uint8_t index)

and just add:

pause("W", hz);

in the beginning?

--HPS
Comment 10 commit-hook freebsd_committer 2020-09-21 18:33:48 UTC
A commit references this bug:

Author: hselasky
Date: Mon Sep 21 18:32:57 UTC 2020
New revision: 365966
URL: https://svnweb.freebsd.org/changeset/base/365966

Log:
  Add support for Winbond USB CDC modem device found in Tenma power supply.

  PR:		249384
  MFC after:	1 week
  Submitted by:	darius@dons.net.au
  Sponsored by:	Mellanox Technologies // NVIDIA Networking

Changes:
  head/sys/dev/usb/serial/umodem.c
  head/sys/dev/usb/usbdevs
Comment 11 commit-hook freebsd_committer 2020-10-20 08:13:03 UTC
A commit references this bug:

Author: hselasky
Date: Tue Oct 20 08:12:35 UTC 2020
New revision: 366874
URL: https://svnweb.freebsd.org/changeset/base/366874

Log:
  MFC r365966:
  Add support for Winbond USB CDC modem device found in Tenma power supply.

  PR:		249384
  Submitted by:	darius@dons.net.au
  Sponsored by:	Mellanox Technologies // NVIDIA Networking

Changes:
_U  stable/12/
  stable/12/sys/dev/usb/serial/umodem.c
  stable/12/sys/dev/usb/usbdevs
Comment 12 commit-hook freebsd_committer 2020-10-20 08:14:05 UTC
A commit references this bug:

Author: hselasky
Date: Tue Oct 20 08:13:15 UTC 2020
New revision: 366875
URL: https://svnweb.freebsd.org/changeset/base/366875

Log:
  MFC r365966:
  Add support for Winbond USB CDC modem device found in Tenma power supply.

  PR:		249384
  Submitted by:	darius@dons.net.au
  Sponsored by:	Mellanox Technologies // NVIDIA Networking

Changes:
_U  stable/11/
  stable/11/sys/dev/usb/serial/umodem.c
  stable/11/sys/dev/usb/usbdevs