[haiku-commits] Re: r42860 - haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial

  • From: Siarzhuk Zharski <zharik@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 17 Oct 2011 20:49:23 +0200

Dear Adrien,

Am 16.10.2011 13:46, schrieb pulkomandy@xxxxxxxxxxxxxxxxx:
Add support for Silicon Labs CP210x to usb_serial.
Not completely tested : my device has no control lines wired. RX/TX seems to
work fine, at least.

Inspiration from the Linux driver since there isn't any documentation avilable:
http://lxr.free-electrons.com/source/drivers/usb/serial/cp210x.c

Could you, please look on source of my BeOS usb_serial at http://sis4be.cvs.sourceforge.net/viewvc/sis4be/usb_serial/? It also had support of cp2101 USB-to-UART (silabs.c and silabs.h) and a bit more longer list of supported devices (driver.c lines 90 - 472) I have harvested some years ago. Probably some info can be usefull for you too. ;-)

The switch/case for VID/PID identification is getting quite long. Isn't there a
better way to do it ?

I'm going to explain my solution in upcoming answer to François message in this thread. Please wait a bit.

Added: haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.cpp

May be the CP210x.cpp or SiliconLabs.cpp base name will be more descriptive here?

Added: haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h           
                (rev 0)
+++ haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h   
2011-10-16 11:46:53 UTC (rev 42860)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2011, Adrien Destugues<pulkomandy@xxxxxxxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _USB_SILICON_H_
+#define _USB_SILICON_H_
+
+#include "SerialDevice.h"
+
+class SiliconDevice : public SerialDevice {
+public:
+                                       SiliconDevice(usb_device device, uint16 
vendorID,
+                                               uint16 productID, const char 
*description);
+
+virtual        status_t        AddDevice(const usb_configuration_info *config);
+
+virtual        status_t        ResetDevice();
+
+virtual        status_t        SetLineCoding(usb_cdc_line_coding *coding);
+virtual        status_t        SetControlLineState(uint16 state);
+
+private:
+enum CP210XRequest {
+       ENABLE_UART = 0,
+               /* 1 to enable the UART function, 0 to disable
+                * (some Silicon Labs chips have other functions such as GPIOs) 
*/


What is the reason to put this requests enumeration into private section of the class declaration? Anyway nobody can use it outside implementation of this class. I found a bit more clear way to move it completely into Silicon.cpp where it is only used.

Thank you for taking the time to finalize support of this hardware!


---
Kind Regards,
  S.Zharski


Other related posts: