Deleted Added
full compact
uchcom.c (184736) uchcom.c (185948)
1/* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */
2
3/*-
4 * Copyright (c) 2007, Takanori Watanabe
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 49 unchanged lines hidden (view full) ---

58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE.
63 */
64
65#include <sys/cdefs.h>
1/* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */
2
3/*-
4 * Copyright (c) 2007, Takanori Watanabe
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 49 unchanged lines hidden (view full) ---

58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE.
63 */
64
65#include <sys/cdefs.h>
66__FBSDID("$FreeBSD: head/sys/dev/usb2/serial/uchcom2.c 184736 2008-11-06 17:26:12Z imp $");
66__FBSDID("$FreeBSD: head/sys/dev/usb2/serial/uchcom2.c 185948 2008-12-11 23:13:02Z thompsa $");
67
68/*
69 * driver for WinChipHead CH341/340, the worst USB-serial chip in the world.
70 */
71
72#include <dev/usb2/include/usb2_devid.h>
73#include <dev/usb2/include/usb2_standard.h>
74#include <dev/usb2/include/usb2_mfunc.h>

--- 116 unchanged lines hidden (view full) ---

191#define NUM_DIVIDERS (sizeof (dividers) / sizeof (dividers[0]))
192
193static const struct usb2_device_id uchcom_devs[] = {
194 {USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)},
195};
196
197/* protypes */
198
67
68/*
69 * driver for WinChipHead CH341/340, the worst USB-serial chip in the world.
70 */
71
72#include <dev/usb2/include/usb2_devid.h>
73#include <dev/usb2/include/usb2_standard.h>
74#include <dev/usb2/include/usb2_mfunc.h>

--- 116 unchanged lines hidden (view full) ---

191#define NUM_DIVIDERS (sizeof (dividers) / sizeof (dividers[0]))
192
193static const struct usb2_device_id uchcom_devs[] = {
194 {USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)},
195};
196
197/* protypes */
198
199static int uchcom_ioctl(struct usb2_com_softc *ucom, uint32_t cmd, caddr_t data, int flag, struct thread *td);
200static int uchcom_pre_param(struct usb2_com_softc *ucom, struct termios *t);
201static void uchcom_cfg_get_status(struct usb2_com_softc *ucom, uint8_t *lsr, uint8_t *msr);
202static void uchcom_cfg_param(struct usb2_com_softc *ucom, struct termios *t);
203static void uchcom_cfg_set_break(struct usb2_com_softc *sc, uint8_t onoff);
204static void uchcom_cfg_set_dtr(struct usb2_com_softc *ucom, uint8_t onoff);
205static void uchcom_cfg_set_rts(struct usb2_com_softc *ucom, uint8_t onoff);
206static void uchcom_start_read(struct usb2_com_softc *ucom);
207static void uchcom_start_write(struct usb2_com_softc *ucom);
208static void uchcom_stop_read(struct usb2_com_softc *ucom);
209static void uchcom_stop_write(struct usb2_com_softc *ucom);
199static int uchcom_ioctl(struct usb2_com_softc *, uint32_t, caddr_t, int,
200 struct thread *);
201static int uchcom_pre_param(struct usb2_com_softc *, struct termios *);
202static void uchcom_cfg_get_status(struct usb2_com_softc *, uint8_t *,
203 uint8_t *);
204static void uchcom_cfg_param(struct usb2_com_softc *, struct termios *);
205static void uchcom_cfg_set_break(struct usb2_com_softc *, uint8_t);
206static void uchcom_cfg_set_dtr(struct usb2_com_softc *, uint8_t);
207static void uchcom_cfg_set_rts(struct usb2_com_softc *, uint8_t);
208static void uchcom_start_read(struct usb2_com_softc *);
209static void uchcom_start_write(struct usb2_com_softc *);
210static void uchcom_stop_read(struct usb2_com_softc *);
211static void uchcom_stop_write(struct usb2_com_softc *);
212static void uchcom_update_version(struct uchcom_softc *);
213static void uchcom_convert_status(struct uchcom_softc *, uint8_t);
214static void uchcom_update_status(struct uchcom_softc *);
215static void uchcom_set_dtrrts(struct uchcom_softc *);
216static int uchcom_calc_divider_settings(struct uchcom_divider *, uint32_t);
217static void uchcom_set_dte_rate(struct uchcom_softc *, uint32_t);
218static void uchcom_set_line_control(struct uchcom_softc *, tcflag_t);
219static void uchcom_clear_chip(struct uchcom_softc *);
220static void uchcom_reset_chip(struct uchcom_softc *);
210
221
211static void uchcom_update_version(struct uchcom_softc *sc);
212static void uchcom_convert_status(struct uchcom_softc *sc, uint8_t cur);
213static void uchcom_update_status(struct uchcom_softc *sc);
214static void uchcom_set_dtrrts(struct uchcom_softc *sc);
215static int uchcom_calc_divider_settings(struct uchcom_divider *dp, uint32_t rate);
216static void uchcom_set_dte_rate(struct uchcom_softc *sc, uint32_t rate);
217static void uchcom_set_line_control(struct uchcom_softc *sc, tcflag_t cflag);
218static void uchcom_clear_chip(struct uchcom_softc *sc);
219static void uchcom_reset_chip(struct uchcom_softc *sc);
220
221static device_probe_t uchcom_probe;
222static device_attach_t uchcom_attach;
223static device_detach_t uchcom_detach;
224
225static usb2_callback_t uchcom_intr_callback;
226static usb2_callback_t uchcom_intr_clear_stall_callback;
227static usb2_callback_t uchcom_write_callback;
228static usb2_callback_t uchcom_write_clear_stall_callback;

--- 809 unchanged lines hidden ---
222static device_probe_t uchcom_probe;
223static device_attach_t uchcom_attach;
224static device_detach_t uchcom_detach;
225
226static usb2_callback_t uchcom_intr_callback;
227static usb2_callback_t uchcom_intr_clear_stall_callback;
228static usb2_callback_t uchcom_write_callback;
229static usb2_callback_t uchcom_write_clear_stall_callback;

--- 809 unchanged lines hidden ---