Commit a0dae8a6 authored by Wen-chien Jesse Sung's avatar Wen-chien Jesse Sung Committed by Brad Figg

UBUNTU: SAUCE: xr-usb-serial: Driver for Exar USB serial ports

BugLink: https://launchpad.net/bugs/1645591

Import USB UART driver from
https://www.exar.com/design-tools/software-drivers

Product Family: USB UART
Part Numbers:
	XR21V1410, XR21V1412, XR21V1414,
	XR21B1411, XR21B1420, XR21B1422,
	XR21B1424, XR22801, XR22802,
	XR22804
Operating system: Linux 3.6.x and newer
Driver version: 1A
Release date: January 2015
Signed-off-by: default avatarWen-chien Jesse Sung <jesse.sung@canonical.com>
Acked-by: default avatarTim Gardner <tim.gardner@canonical.com>
Acked-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 69010660
......@@ -33,6 +33,10 @@ obj-$(CONFIG_HIO) += hio/
##
##
##
obj-y += xr-usb-serial/
##
##
##
##
##
##
......
obj-m := xr_usb_serial_common.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
EXTRA_CFLAGS := -DDEBUG=0
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty
Exar USB Serial Driver
======================
Version 1A, 1/9/2015
This driver will work with any USB UART function in these Exar devices:
XR21V1410/1412/1414
XR21B1411
XR21B1420/1422/1424
XR22801/802/804
The source code has been tested on various Linux kernels from 3.6.x to 3.17.x.
This may also work with newer kernels as well.
Installation
------------
* Compile and install the common usb serial driver module
# make
# insmod ./xr_usb_serial_common.ko
* Plug the device into the USB host. You should see up to four devices created,
typically /dev/ttyXRUSB[0-3].
Tips for Debugging
------------------
* Check that the USB UART is detected by the system
# lsusb
* Check that the CDC-ACM driver was not installed for the Exar USB UART
# ls /dev/tty*
To remove the CDC-ACM driver and install the driver:
# rmmod cdc-acm
# modprobe -r usbserial
# modprobe usbserial
# insmod ./xr_usb_serial_common.ko
Technical Support
-----------------
Send any technical questions/issues to uarttechsupport@exar.com.
This diff is collapsed.
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* CMSPAR, some architectures can't have space and mark parity.
*/
#ifndef CMSPAR
#define CMSPAR 0
#endif
/*
* Major and minor numbers.
*/
#define XR_USB_SERIAL_TTY_MAJOR 266
#define XR_USB_SERIAL_TTY_MINORS 32
/*
* Requests.
*/
#define USB_RT_XR_USB_SERIAL (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
/*
* Output control lines.
*/
#define XR_USB_SERIAL_CTRL_DTR 0x01
#define XR_USB_SERIAL_CTRL_RTS 0x02
/*
* Input control lines and line errors.
*/
#define XR_USB_SERIAL_CTRL_DCD 0x01
#define XR_USB_SERIAL_CTRL_DSR 0x02
#define XR_USB_SERIAL_CTRL_BRK 0x04
#define XR_USB_SERIAL_CTRL_RI 0x08
#define XR_USB_SERIAL_CTRL_FRAMING 0x10
#define XR_USB_SERIAL_CTRL_PARITY 0x20
#define XR_USB_SERIAL_CTRL_OVERRUN 0x40
/*
* Internal driver structures.
*/
/*
* The only reason to have several buffers is to accommodate assumptions
* in line disciplines. They ask for empty space amount, receive our URB size,
* and proceed to issue several 1-character writes, assuming they will fit.
* The very first write takes a complete URB. Fortunately, this only happens
* when processing onlcr, so we only need 2 buffers. These values must be
* powers of 2.
*/
#define XR_USB_SERIAL_NW 16
#define XR_USB_SERIAL_NR 16
struct xr_usb_serial_wb {
unsigned char *buf;
dma_addr_t dmah;
int len;
int use;
struct urb *urb;
struct xr_usb_serial *instance;
};
struct xr_usb_serial_rb {
int size;
unsigned char *base;
dma_addr_t dma;
int index;
struct xr_usb_serial *instance;
};
struct reg_addr_map {
unsigned int uart_enable_addr;
unsigned int uart_format_addr;
unsigned int uart_flow_addr;
unsigned int uart_loopback_addr;
unsigned int uart_xon_char_addr;
unsigned int uart_xoff_char_addr;
unsigned int uart_gpio_mode_addr;
unsigned int uart_gpio_dir_addr;
unsigned int uart_gpio_set_addr;
unsigned int uart_gpio_clr_addr;
unsigned int uart_gpio_status_addr;
unsigned int tx_break_addr;
unsigned int uart_custom_driver;
unsigned int uart_low_latency;
};
struct xr_usb_serial {
struct usb_device *dev; /* the corresponding usb device */
struct usb_interface *control; /* control interface */
struct usb_interface *data; /* data interface */
struct tty_port port; /* our tty port data */
struct urb *ctrlurb; /* urbs */
u8 *ctrl_buffer; /* buffers of urbs */
dma_addr_t ctrl_dma; /* dma handles of buffers */
u8 *country_codes; /* country codes from device */
unsigned int country_code_size; /* size of this buffer */
unsigned int country_rel_date; /* release date of version */
struct xr_usb_serial_wb wb[XR_USB_SERIAL_NW];
unsigned long read_urbs_free;
struct urb *read_urbs[XR_USB_SERIAL_NR];
struct xr_usb_serial_rb read_buffers[XR_USB_SERIAL_NR];
int rx_buflimit;
int rx_endpoint;
spinlock_t read_lock;
int write_used; /* number of non-empty write buffers */
int transmitting;
spinlock_t write_lock;
struct mutex mutex;
bool disconnected;
struct usb_cdc_line_coding line; /* bits, stop, parity */
struct work_struct work; /* work queue entry for line discipline waking up */
unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
unsigned int ctrlout; /* output control lines (DTR, RTS) */
unsigned int writesize; /* max packet size for the output bulk endpoint */
unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
unsigned int minor; /* xr_usb_serial minor number */
unsigned char clocal; /* termios CLOCAL */
unsigned int ctrl_caps; /* control capabilities from the class specific header */
unsigned int susp_count; /* number of suspended interfaces */
unsigned int combined_interfaces:1; /* control and data collapsed */
unsigned int is_int_ep:1; /* interrupt endpoints contrary to spec used */
unsigned int throttled:1; /* actually throttled */
unsigned int throttle_req:1; /* throttle requested */
u8 bInterval;
struct xr_usb_serial_wb *delayed_wb; /* write queued for a device about to be woken */
unsigned int channel;
unsigned short DeviceVendor;
unsigned short DeviceProduct;
struct reg_addr_map reg_map;
};
#define CDC_DATA_INTERFACE_TYPE 0x0a
/* constants describing various quirks and errors */
#define NO_UNION_NORMAL 1
#define SINGLE_RX_URB 2
#define NO_CAP_LINE 4
#define NOT_A_MODEM 8
#define NO_DATA_INTERFACE 16
#define IGNORE_DEVICE 32
#define UART_ENABLE_TX 1
#define UART_ENABLE_RX 2
#define UART_GPIO_CLR_DTR 0x8
#define UART_GPIO_SET_DTR 0x8
#define UART_GPIO_CLR_RTS 0x20
#define UART_GPIO_SET_RTS 0x20
#define LOOPBACK_ENABLE_TX_RX 1
#define LOOPBACK_ENABLE_RTS_CTS 2
#define LOOPBACK_ENABLE_DTR_DSR 4
#define UART_FLOW_MODE_NONE 0x0
#define UART_FLOW_MODE_HW 0x1
#define UART_FLOW_MODE_SW 0x2
#define UART_GPIO_MODE_SEL_GPIO 0x0
#define UART_GPIO_MODE_SEL_RTS_CTS 0x1
#define XR2280x_FUNC_MGR_OFFSET 0x40
This diff is collapsed.
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/ioctl.h>
#define XR_USB_SERIAL_IOC_MAGIC 'v'
#define XR_USB_SERIAL_GET_REG _IOWR(XR_USB_SERIAL_IOC_MAGIC, 1, int)
#define XR_USB_SERIAL_SET_REG _IOWR(XR_USB_SERIAL_IOC_MAGIC, 2, int)
#define XR_USB_SERIAL_SET_ADDRESS_MATCH _IO(XR_USB_SERIAL_IOC_MAGIC, 3)
#define XR_USB_SERIAL_SET_PRECISE_FLAGS _IO(XR_USB_SERIAL_IOC_MAGIC, 4)
#define XR_USB_SERIAL_TEST_MODE _IO(XR_USB_SERIAL_IOC_MAGIC, 5)
#define XR_USB_SERIAL_LOOPBACK _IO(XR_USB_SERIAL_IOC_MAGIC, 6)
#define VZ_ADDRESS_UNICAST_S 0
#define VZ_ADDRESS_BROADCAST_S 8
#define VZ_ADDRESS_MATCH(U, B) (0x8000000 | ((B) << VZ_ADDRESS_BROADCAST_S) | ((U) << VZ_ADDRESS_UNICAST_S))
#define VZ_ADDRESS_MATCH_DISABLE 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment