Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * USB Cypress M8 driver
0004  *
0005  *  Copyright (C) 2004
0006  *      Lonnie Mendez (dignome@gmail.com)
0007  *  Copyright (C) 2003,2004
0008  *      Neil Whelchel (koyama@firstlight.net)
0009  *
0010  * See Documentation/usb/usb-serial.rst for more information on using this
0011  * driver
0012  *
0013  * See http://geocities.com/i0xox0i for information on this driver and the
0014  * earthmate usb device.
0015  */
0016 
0017 /* Thanks to Neil Whelchel for writing the first cypress m8 implementation
0018    for linux. */
0019 /* Thanks to cypress for providing references for the hid reports. */
0020 /* Thanks to Jiang Zhang for providing links and for general help. */
0021 /* Code originates and was built up from ftdi_sio, belkin, pl2303 and others.*/
0022 
0023 
0024 #include <linux/kernel.h>
0025 #include <linux/errno.h>
0026 #include <linux/slab.h>
0027 #include <linux/tty.h>
0028 #include <linux/tty_driver.h>
0029 #include <linux/tty_flip.h>
0030 #include <linux/module.h>
0031 #include <linux/moduleparam.h>
0032 #include <linux/spinlock.h>
0033 #include <linux/usb.h>
0034 #include <linux/usb/serial.h>
0035 #include <linux/serial.h>
0036 #include <linux/kfifo.h>
0037 #include <linux/delay.h>
0038 #include <linux/uaccess.h>
0039 #include <asm/unaligned.h>
0040 
0041 #include "cypress_m8.h"
0042 
0043 
0044 static bool stats;
0045 static int interval;
0046 static bool unstable_bauds;
0047 
0048 #define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
0049 #define DRIVER_DESC "Cypress USB to Serial Driver"
0050 
0051 /* write buffer size defines */
0052 #define CYPRESS_BUF_SIZE    1024
0053 
0054 static const struct usb_device_id id_table_earthmate[] = {
0055     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
0056     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
0057     { }                     /* Terminating entry */
0058 };
0059 
0060 static const struct usb_device_id id_table_cyphidcomrs232[] = {
0061     { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
0062     { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) },
0063     { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
0064     { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) },
0065     { }                     /* Terminating entry */
0066 };
0067 
0068 static const struct usb_device_id id_table_nokiaca42v2[] = {
0069     { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
0070     { }                     /* Terminating entry */
0071 };
0072 
0073 static const struct usb_device_id id_table_combined[] = {
0074     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
0075     { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
0076     { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
0077     { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) },
0078     { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
0079     { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) },
0080     { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
0081     { }                     /* Terminating entry */
0082 };
0083 
0084 MODULE_DEVICE_TABLE(usb, id_table_combined);
0085 
0086 enum packet_format {
0087     packet_format_1,  /* b0:status, b1:payload count */
0088     packet_format_2   /* b0[7:3]:status, b0[2:0]:payload count */
0089 };
0090 
0091 struct cypress_private {
0092     spinlock_t lock;           /* private lock */
0093     int chiptype;              /* identifier of device, for quirks/etc */
0094     int bytes_in;              /* used for statistics */
0095     int bytes_out;             /* used for statistics */
0096     int cmd_count;             /* used for statistics */
0097     int cmd_ctrl;              /* always set this to 1 before issuing a command */
0098     struct kfifo write_fifo;       /* write fifo */
0099     int write_urb_in_use;          /* write urb in use indicator */
0100     int write_urb_interval;            /* interval to use for write urb */
0101     int read_urb_interval;             /* interval to use for read urb */
0102     int comm_is_ok;                    /* true if communication is (still) ok */
0103     __u8 line_control;         /* holds dtr / rts value */
0104     __u8 current_status;           /* received from last read - info on dsr,cts,cd,ri,etc */
0105     __u8 current_config;           /* stores the current configuration byte */
0106     __u8 rx_flags;             /* throttling - used from whiteheat/ftdi_sio */
0107     enum packet_format pkt_fmt;    /* format to use for packet send / receive */
0108     int get_cfg_unsafe;        /* If true, the CYPRESS_GET_CONFIG is unsafe */
0109     int baud_rate;             /* stores current baud rate in
0110                           integer form */
0111     char prev_status;          /* used for TIOCMIWAIT */
0112 };
0113 
0114 /* function prototypes for the Cypress USB to serial device */
0115 static int  cypress_earthmate_port_probe(struct usb_serial_port *port);
0116 static int  cypress_hidcom_port_probe(struct usb_serial_port *port);
0117 static int  cypress_ca42v2_port_probe(struct usb_serial_port *port);
0118 static void cypress_port_remove(struct usb_serial_port *port);
0119 static int  cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
0120 static void cypress_close(struct usb_serial_port *port);
0121 static void cypress_dtr_rts(struct usb_serial_port *port, int on);
0122 static int  cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
0123             const unsigned char *buf, int count);
0124 static void cypress_send(struct usb_serial_port *port);
0125 static unsigned int cypress_write_room(struct tty_struct *tty);
0126 static void cypress_earthmate_init_termios(struct tty_struct *tty);
0127 static void cypress_set_termios(struct tty_struct *tty,
0128             struct usb_serial_port *port, struct ktermios *old);
0129 static int  cypress_tiocmget(struct tty_struct *tty);
0130 static int  cypress_tiocmset(struct tty_struct *tty,
0131             unsigned int set, unsigned int clear);
0132 static unsigned int cypress_chars_in_buffer(struct tty_struct *tty);
0133 static void cypress_throttle(struct tty_struct *tty);
0134 static void cypress_unthrottle(struct tty_struct *tty);
0135 static void cypress_set_dead(struct usb_serial_port *port);
0136 static void cypress_read_int_callback(struct urb *urb);
0137 static void cypress_write_int_callback(struct urb *urb);
0138 
0139 static struct usb_serial_driver cypress_earthmate_device = {
0140     .driver = {
0141         .owner =        THIS_MODULE,
0142         .name =         "earthmate",
0143     },
0144     .description =          "DeLorme Earthmate USB",
0145     .id_table =         id_table_earthmate,
0146     .num_ports =            1,
0147     .port_probe =           cypress_earthmate_port_probe,
0148     .port_remove =          cypress_port_remove,
0149     .open =             cypress_open,
0150     .close =            cypress_close,
0151     .dtr_rts =          cypress_dtr_rts,
0152     .write =            cypress_write,
0153     .write_room =           cypress_write_room,
0154     .init_termios =         cypress_earthmate_init_termios,
0155     .set_termios =          cypress_set_termios,
0156     .tiocmget =         cypress_tiocmget,
0157     .tiocmset =         cypress_tiocmset,
0158     .tiocmiwait =           usb_serial_generic_tiocmiwait,
0159     .chars_in_buffer =      cypress_chars_in_buffer,
0160     .throttle =         cypress_throttle,
0161     .unthrottle =           cypress_unthrottle,
0162     .read_int_callback =        cypress_read_int_callback,
0163     .write_int_callback =       cypress_write_int_callback,
0164 };
0165 
0166 static struct usb_serial_driver cypress_hidcom_device = {
0167     .driver = {
0168         .owner =        THIS_MODULE,
0169         .name =         "cyphidcom",
0170     },
0171     .description =          "HID->COM RS232 Adapter",
0172     .id_table =         id_table_cyphidcomrs232,
0173     .num_ports =            1,
0174     .port_probe =           cypress_hidcom_port_probe,
0175     .port_remove =          cypress_port_remove,
0176     .open =             cypress_open,
0177     .close =            cypress_close,
0178     .dtr_rts =          cypress_dtr_rts,
0179     .write =            cypress_write,
0180     .write_room =           cypress_write_room,
0181     .set_termios =          cypress_set_termios,
0182     .tiocmget =         cypress_tiocmget,
0183     .tiocmset =         cypress_tiocmset,
0184     .tiocmiwait =           usb_serial_generic_tiocmiwait,
0185     .chars_in_buffer =      cypress_chars_in_buffer,
0186     .throttle =         cypress_throttle,
0187     .unthrottle =           cypress_unthrottle,
0188     .read_int_callback =        cypress_read_int_callback,
0189     .write_int_callback =       cypress_write_int_callback,
0190 };
0191 
0192 static struct usb_serial_driver cypress_ca42v2_device = {
0193     .driver = {
0194         .owner =        THIS_MODULE,
0195         .name =         "nokiaca42v2",
0196     },
0197     .description =          "Nokia CA-42 V2 Adapter",
0198     .id_table =         id_table_nokiaca42v2,
0199     .num_ports =            1,
0200     .port_probe =           cypress_ca42v2_port_probe,
0201     .port_remove =          cypress_port_remove,
0202     .open =             cypress_open,
0203     .close =            cypress_close,
0204     .dtr_rts =          cypress_dtr_rts,
0205     .write =            cypress_write,
0206     .write_room =           cypress_write_room,
0207     .set_termios =          cypress_set_termios,
0208     .tiocmget =         cypress_tiocmget,
0209     .tiocmset =         cypress_tiocmset,
0210     .tiocmiwait =           usb_serial_generic_tiocmiwait,
0211     .chars_in_buffer =      cypress_chars_in_buffer,
0212     .throttle =         cypress_throttle,
0213     .unthrottle =           cypress_unthrottle,
0214     .read_int_callback =        cypress_read_int_callback,
0215     .write_int_callback =       cypress_write_int_callback,
0216 };
0217 
0218 static struct usb_serial_driver * const serial_drivers[] = {
0219     &cypress_earthmate_device, &cypress_hidcom_device,
0220     &cypress_ca42v2_device, NULL
0221 };
0222 
0223 /*****************************************************************************
0224  * Cypress serial helper functions
0225  *****************************************************************************/
0226 
0227 /* FRWD Dongle hidcom needs to skip reset and speed checks */
0228 static inline bool is_frwd(struct usb_device *dev)
0229 {
0230     return ((le16_to_cpu(dev->descriptor.idVendor) == VENDOR_ID_FRWD) &&
0231         (le16_to_cpu(dev->descriptor.idProduct) == PRODUCT_ID_CYPHIDCOM_FRWD));
0232 }
0233 
0234 static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
0235 {
0236     struct cypress_private *priv;
0237     priv = usb_get_serial_port_data(port);
0238 
0239     if (unstable_bauds)
0240         return new_rate;
0241 
0242     /* FRWD Dongle uses 115200 bps */
0243     if (is_frwd(port->serial->dev))
0244         return new_rate;
0245 
0246     /*
0247      * The general purpose firmware for the Cypress M8 allows for
0248      * a maximum speed of 57600bps (I have no idea whether DeLorme
0249      * chose to use the general purpose firmware or not), if you
0250      * need to modify this speed setting for your own project
0251      * please add your own chiptype and modify the code likewise.
0252      * The Cypress HID->COM device will work successfully up to
0253      * 115200bps (but the actual throughput is around 3kBps).
0254      */
0255     if (port->serial->dev->speed == USB_SPEED_LOW) {
0256         /*
0257          * Mike Isely <isely@pobox.com> 2-Feb-2008: The
0258          * Cypress app note that describes this mechanism
0259          * states that the low-speed part can't handle more
0260          * than 800 bytes/sec, in which case 4800 baud is the
0261          * safest speed for a part like that.
0262          */
0263         if (new_rate > 4800) {
0264             dev_dbg(&port->dev,
0265                 "%s - failed setting baud rate, device incapable speed %d\n",
0266                 __func__, new_rate);
0267             return -1;
0268         }
0269     }
0270     switch (priv->chiptype) {
0271     case CT_EARTHMATE:
0272         if (new_rate <= 600) {
0273             /* 300 and 600 baud rates are supported under
0274              * the generic firmware, but are not used with
0275              * NMEA and SiRF protocols */
0276             dev_dbg(&port->dev,
0277                 "%s - failed setting baud rate, unsupported speed of %d on Earthmate GPS\n",
0278                 __func__, new_rate);
0279             return -1;
0280         }
0281         break;
0282     default:
0283         break;
0284     }
0285     return new_rate;
0286 }
0287 
0288 
0289 /* This function can either set or retrieve the current serial line settings */
0290 static int cypress_serial_control(struct tty_struct *tty,
0291     struct usb_serial_port *port, speed_t baud_rate, int data_bits,
0292     int stop_bits, int parity_enable, int parity_type, int reset,
0293     int cypress_request_type)
0294 {
0295     int new_baudrate = 0, retval = 0, tries = 0;
0296     struct cypress_private *priv;
0297     struct device *dev = &port->dev;
0298     u8 *feature_buffer;
0299     const unsigned int feature_len = 5;
0300     unsigned long flags;
0301 
0302     priv = usb_get_serial_port_data(port);
0303 
0304     if (!priv->comm_is_ok)
0305         return -ENODEV;
0306 
0307     feature_buffer = kcalloc(feature_len, sizeof(u8), GFP_KERNEL);
0308     if (!feature_buffer)
0309         return -ENOMEM;
0310 
0311     switch (cypress_request_type) {
0312     case CYPRESS_SET_CONFIG:
0313         /* 0 means 'Hang up' so doesn't change the true bit rate */
0314         new_baudrate = priv->baud_rate;
0315         if (baud_rate && baud_rate != priv->baud_rate) {
0316             dev_dbg(dev, "%s - baud rate is changing\n", __func__);
0317             retval = analyze_baud_rate(port, baud_rate);
0318             if (retval >= 0) {
0319                 new_baudrate = retval;
0320                 dev_dbg(dev, "%s - New baud rate set to %d\n",
0321                     __func__, new_baudrate);
0322             }
0323         }
0324         dev_dbg(dev, "%s - baud rate is being sent as %d\n", __func__,
0325             new_baudrate);
0326 
0327         /* fill the feature_buffer with new configuration */
0328         put_unaligned_le32(new_baudrate, feature_buffer);
0329         feature_buffer[4] |= data_bits - 5;   /* assign data bits in 2 bit space ( max 3 ) */
0330         /* 1 bit gap */
0331         feature_buffer[4] |= (stop_bits << 3);   /* assign stop bits in 1 bit space */
0332         feature_buffer[4] |= (parity_enable << 4);   /* assign parity flag in 1 bit space */
0333         feature_buffer[4] |= (parity_type << 5);   /* assign parity type in 1 bit space */
0334         /* 1 bit gap */
0335         feature_buffer[4] |= (reset << 7);   /* assign reset at end of byte, 1 bit space */
0336 
0337         dev_dbg(dev, "%s - device is being sent this feature report:\n", __func__);
0338         dev_dbg(dev, "%s - %02X - %02X - %02X - %02X - %02X\n", __func__,
0339             feature_buffer[0], feature_buffer[1],
0340             feature_buffer[2], feature_buffer[3],
0341             feature_buffer[4]);
0342 
0343         do {
0344             retval = usb_control_msg(port->serial->dev,
0345                     usb_sndctrlpipe(port->serial->dev, 0),
0346                     HID_REQ_SET_REPORT,
0347                     USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
0348                     0x0300, 0, feature_buffer,
0349                     feature_len, 500);
0350 
0351             if (tries++ >= 3)
0352                 break;
0353 
0354         } while (retval != feature_len &&
0355              retval != -ENODEV);
0356 
0357         if (retval != feature_len) {
0358             dev_err(dev, "%s - failed sending serial line settings - %d\n",
0359                 __func__, retval);
0360             cypress_set_dead(port);
0361         } else {
0362             spin_lock_irqsave(&priv->lock, flags);
0363             priv->baud_rate = new_baudrate;
0364             priv->current_config = feature_buffer[4];
0365             spin_unlock_irqrestore(&priv->lock, flags);
0366             /* If we asked for a speed change encode it */
0367             if (baud_rate)
0368                 tty_encode_baud_rate(tty,
0369                     new_baudrate, new_baudrate);
0370         }
0371     break;
0372     case CYPRESS_GET_CONFIG:
0373         if (priv->get_cfg_unsafe) {
0374             /* Not implemented for this device,
0375                and if we try to do it we're likely
0376                to crash the hardware. */
0377             retval = -ENOTTY;
0378             goto out;
0379         }
0380         dev_dbg(dev, "%s - retrieving serial line settings\n", __func__);
0381         do {
0382             retval = usb_control_msg(port->serial->dev,
0383                     usb_rcvctrlpipe(port->serial->dev, 0),
0384                     HID_REQ_GET_REPORT,
0385                     USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
0386                     0x0300, 0, feature_buffer,
0387                     feature_len, 500);
0388 
0389             if (tries++ >= 3)
0390                 break;
0391         } while (retval != feature_len
0392                         && retval != -ENODEV);
0393 
0394         if (retval != feature_len) {
0395             dev_err(dev, "%s - failed to retrieve serial line settings - %d\n",
0396                 __func__, retval);
0397             cypress_set_dead(port);
0398             goto out;
0399         } else {
0400             spin_lock_irqsave(&priv->lock, flags);
0401             /* store the config in one byte, and later
0402                use bit masks to check values */
0403             priv->current_config = feature_buffer[4];
0404             priv->baud_rate = get_unaligned_le32(feature_buffer);
0405             spin_unlock_irqrestore(&priv->lock, flags);
0406         }
0407     }
0408     spin_lock_irqsave(&priv->lock, flags);
0409     ++priv->cmd_count;
0410     spin_unlock_irqrestore(&priv->lock, flags);
0411 out:
0412     kfree(feature_buffer);
0413     return retval;
0414 } /* cypress_serial_control */
0415 
0416 
0417 static void cypress_set_dead(struct usb_serial_port *port)
0418 {
0419     struct cypress_private *priv = usb_get_serial_port_data(port);
0420     unsigned long flags;
0421 
0422     spin_lock_irqsave(&priv->lock, flags);
0423     if (!priv->comm_is_ok) {
0424         spin_unlock_irqrestore(&priv->lock, flags);
0425         return;
0426     }
0427     priv->comm_is_ok = 0;
0428     spin_unlock_irqrestore(&priv->lock, flags);
0429 
0430     dev_err(&port->dev, "cypress_m8 suspending failing port %d - "
0431         "interval might be too short\n", port->port_number);
0432 }
0433 
0434 
0435 /*****************************************************************************
0436  * Cypress serial driver functions
0437  *****************************************************************************/
0438 
0439 
0440 static int cypress_generic_port_probe(struct usb_serial_port *port)
0441 {
0442     struct usb_serial *serial = port->serial;
0443     struct cypress_private *priv;
0444 
0445     if (!port->interrupt_out_urb || !port->interrupt_in_urb) {
0446         dev_err(&port->dev, "required endpoint is missing\n");
0447         return -ENODEV;
0448     }
0449 
0450     priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
0451     if (!priv)
0452         return -ENOMEM;
0453 
0454     priv->comm_is_ok = !0;
0455     spin_lock_init(&priv->lock);
0456     if (kfifo_alloc(&priv->write_fifo, CYPRESS_BUF_SIZE, GFP_KERNEL)) {
0457         kfree(priv);
0458         return -ENOMEM;
0459     }
0460 
0461     /* Skip reset for FRWD device. It is a workaound:
0462        device hangs if it receives SET_CONFIGURE in Configured
0463        state. */
0464     if (!is_frwd(serial->dev))
0465         usb_reset_configuration(serial->dev);
0466 
0467     priv->cmd_ctrl = 0;
0468     priv->line_control = 0;
0469     priv->rx_flags = 0;
0470     /* Default packet format setting is determined by packet size.
0471        Anything with a size larger then 9 must have a separate
0472        count field since the 3 bit count field is otherwise too
0473        small.  Otherwise we can use the slightly more compact
0474        format.  This is in accordance with the cypress_m8 serial
0475        converter app note. */
0476     if (port->interrupt_out_size > 9)
0477         priv->pkt_fmt = packet_format_1;
0478     else
0479         priv->pkt_fmt = packet_format_2;
0480 
0481     if (interval > 0) {
0482         priv->write_urb_interval = interval;
0483         priv->read_urb_interval = interval;
0484         dev_dbg(&port->dev, "%s - read & write intervals forced to %d\n",
0485             __func__, interval);
0486     } else {
0487         priv->write_urb_interval = port->interrupt_out_urb->interval;
0488         priv->read_urb_interval = port->interrupt_in_urb->interval;
0489         dev_dbg(&port->dev, "%s - intervals: read=%d write=%d\n",
0490             __func__, priv->read_urb_interval,
0491             priv->write_urb_interval);
0492     }
0493     usb_set_serial_port_data(port, priv);
0494 
0495     port->port.drain_delay = 256;
0496 
0497     return 0;
0498 }
0499 
0500 
0501 static int cypress_earthmate_port_probe(struct usb_serial_port *port)
0502 {
0503     struct usb_serial *serial = port->serial;
0504     struct cypress_private *priv;
0505     int ret;
0506 
0507     ret = cypress_generic_port_probe(port);
0508     if (ret) {
0509         dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
0510         return ret;
0511     }
0512 
0513     priv = usb_get_serial_port_data(port);
0514     priv->chiptype = CT_EARTHMATE;
0515     /* All Earthmate devices use the separated-count packet
0516        format!  Idiotic. */
0517     priv->pkt_fmt = packet_format_1;
0518     if (serial->dev->descriptor.idProduct !=
0519                 cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
0520         /* The old original USB Earthmate seemed able to
0521            handle GET_CONFIG requests; everything they've
0522            produced since that time crashes if this command is
0523            attempted :-( */
0524         dev_dbg(&port->dev,
0525             "%s - Marking this device as unsafe for GET_CONFIG commands\n",
0526             __func__);
0527         priv->get_cfg_unsafe = !0;
0528     }
0529 
0530     return 0;
0531 }
0532 
0533 static int cypress_hidcom_port_probe(struct usb_serial_port *port)
0534 {
0535     struct cypress_private *priv;
0536     int ret;
0537 
0538     ret = cypress_generic_port_probe(port);
0539     if (ret) {
0540         dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
0541         return ret;
0542     }
0543 
0544     priv = usb_get_serial_port_data(port);
0545     priv->chiptype = CT_CYPHIDCOM;
0546 
0547     return 0;
0548 }
0549 
0550 static int cypress_ca42v2_port_probe(struct usb_serial_port *port)
0551 {
0552     struct cypress_private *priv;
0553     int ret;
0554 
0555     ret = cypress_generic_port_probe(port);
0556     if (ret) {
0557         dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
0558         return ret;
0559     }
0560 
0561     priv = usb_get_serial_port_data(port);
0562     priv->chiptype = CT_CA42V2;
0563 
0564     return 0;
0565 }
0566 
0567 static void cypress_port_remove(struct usb_serial_port *port)
0568 {
0569     struct cypress_private *priv;
0570 
0571     priv = usb_get_serial_port_data(port);
0572 
0573     kfifo_free(&priv->write_fifo);
0574     kfree(priv);
0575 }
0576 
0577 static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
0578 {
0579     struct cypress_private *priv = usb_get_serial_port_data(port);
0580     struct usb_serial *serial = port->serial;
0581     unsigned long flags;
0582     int result = 0;
0583 
0584     if (!priv->comm_is_ok)
0585         return -EIO;
0586 
0587     /* clear halts before open */
0588     usb_clear_halt(serial->dev, 0x81);
0589     usb_clear_halt(serial->dev, 0x02);
0590 
0591     spin_lock_irqsave(&priv->lock, flags);
0592     /* reset read/write statistics */
0593     priv->bytes_in = 0;
0594     priv->bytes_out = 0;
0595     priv->cmd_count = 0;
0596     priv->rx_flags = 0;
0597     spin_unlock_irqrestore(&priv->lock, flags);
0598 
0599     /* Set termios */
0600     cypress_send(port);
0601 
0602     if (tty)
0603         cypress_set_termios(tty, port, NULL);
0604 
0605     /* setup the port and start reading from the device */
0606     usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
0607         usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
0608         port->interrupt_in_urb->transfer_buffer,
0609         port->interrupt_in_urb->transfer_buffer_length,
0610         cypress_read_int_callback, port, priv->read_urb_interval);
0611     result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
0612 
0613     if (result) {
0614         dev_err(&port->dev,
0615             "%s - failed submitting read urb, error %d\n",
0616                             __func__, result);
0617         cypress_set_dead(port);
0618     }
0619 
0620     return result;
0621 } /* cypress_open */
0622 
0623 static void cypress_dtr_rts(struct usb_serial_port *port, int on)
0624 {
0625     struct cypress_private *priv = usb_get_serial_port_data(port);
0626     /* drop dtr and rts */
0627     spin_lock_irq(&priv->lock);
0628     if (on == 0)
0629         priv->line_control = 0;
0630     else 
0631         priv->line_control = CONTROL_DTR | CONTROL_RTS;
0632     priv->cmd_ctrl = 1;
0633     spin_unlock_irq(&priv->lock);
0634     cypress_write(NULL, port, NULL, 0);
0635 }
0636 
0637 static void cypress_close(struct usb_serial_port *port)
0638 {
0639     struct cypress_private *priv = usb_get_serial_port_data(port);
0640     unsigned long flags;
0641 
0642     spin_lock_irqsave(&priv->lock, flags);
0643     kfifo_reset_out(&priv->write_fifo);
0644     spin_unlock_irqrestore(&priv->lock, flags);
0645 
0646     dev_dbg(&port->dev, "%s - stopping urbs\n", __func__);
0647     usb_kill_urb(port->interrupt_in_urb);
0648     usb_kill_urb(port->interrupt_out_urb);
0649 
0650     if (stats)
0651         dev_info(&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
0652             priv->bytes_in, priv->bytes_out, priv->cmd_count);
0653 } /* cypress_close */
0654 
0655 
0656 static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
0657                     const unsigned char *buf, int count)
0658 {
0659     struct cypress_private *priv = usb_get_serial_port_data(port);
0660 
0661     dev_dbg(&port->dev, "%s - %d bytes\n", __func__, count);
0662 
0663     /* line control commands, which need to be executed immediately,
0664        are not put into the buffer for obvious reasons.
0665      */
0666     if (priv->cmd_ctrl) {
0667         count = 0;
0668         goto finish;
0669     }
0670 
0671     if (!count)
0672         return count;
0673 
0674     count = kfifo_in_locked(&priv->write_fifo, buf, count, &priv->lock);
0675 
0676 finish:
0677     cypress_send(port);
0678 
0679     return count;
0680 } /* cypress_write */
0681 
0682 
0683 static void cypress_send(struct usb_serial_port *port)
0684 {
0685     int count = 0, result, offset, actual_size;
0686     struct cypress_private *priv = usb_get_serial_port_data(port);
0687     struct device *dev = &port->dev;
0688     unsigned long flags;
0689 
0690     if (!priv->comm_is_ok)
0691         return;
0692 
0693     dev_dbg(dev, "%s - interrupt out size is %d\n", __func__,
0694         port->interrupt_out_size);
0695 
0696     spin_lock_irqsave(&priv->lock, flags);
0697     if (priv->write_urb_in_use) {
0698         dev_dbg(dev, "%s - can't write, urb in use\n", __func__);
0699         spin_unlock_irqrestore(&priv->lock, flags);
0700         return;
0701     }
0702     spin_unlock_irqrestore(&priv->lock, flags);
0703 
0704     /* clear buffer */
0705     memset(port->interrupt_out_urb->transfer_buffer, 0,
0706                         port->interrupt_out_size);
0707 
0708     spin_lock_irqsave(&priv->lock, flags);
0709     switch (priv->pkt_fmt) {
0710     default:
0711     case packet_format_1:
0712         /* this is for the CY7C64013... */
0713         offset = 2;
0714         port->interrupt_out_buffer[0] = priv->line_control;
0715         break;
0716     case packet_format_2:
0717         /* this is for the CY7C63743... */
0718         offset = 1;
0719         port->interrupt_out_buffer[0] = priv->line_control;
0720         break;
0721     }
0722 
0723     if (priv->line_control & CONTROL_RESET)
0724         priv->line_control &= ~CONTROL_RESET;
0725 
0726     if (priv->cmd_ctrl) {
0727         priv->cmd_count++;
0728         dev_dbg(dev, "%s - line control command being issued\n", __func__);
0729         spin_unlock_irqrestore(&priv->lock, flags);
0730         goto send;
0731     } else
0732         spin_unlock_irqrestore(&priv->lock, flags);
0733 
0734     count = kfifo_out_locked(&priv->write_fifo,
0735                     &port->interrupt_out_buffer[offset],
0736                     port->interrupt_out_size - offset,
0737                     &priv->lock);
0738     if (count == 0)
0739         return;
0740 
0741     switch (priv->pkt_fmt) {
0742     default:
0743     case packet_format_1:
0744         port->interrupt_out_buffer[1] = count;
0745         break;
0746     case packet_format_2:
0747         port->interrupt_out_buffer[0] |= count;
0748     }
0749 
0750     dev_dbg(dev, "%s - count is %d\n", __func__, count);
0751 
0752 send:
0753     spin_lock_irqsave(&priv->lock, flags);
0754     priv->write_urb_in_use = 1;
0755     spin_unlock_irqrestore(&priv->lock, flags);
0756 
0757     if (priv->cmd_ctrl)
0758         actual_size = 1;
0759     else
0760         actual_size = count +
0761                   (priv->pkt_fmt == packet_format_1 ? 2 : 1);
0762 
0763     usb_serial_debug_data(dev, __func__, port->interrupt_out_size,
0764                   port->interrupt_out_urb->transfer_buffer);
0765 
0766     usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
0767         usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
0768         port->interrupt_out_buffer, actual_size,
0769         cypress_write_int_callback, port, priv->write_urb_interval);
0770     result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
0771     if (result) {
0772         dev_err_console(port,
0773                 "%s - failed submitting write urb, error %d\n",
0774                             __func__, result);
0775         priv->write_urb_in_use = 0;
0776         cypress_set_dead(port);
0777     }
0778 
0779     spin_lock_irqsave(&priv->lock, flags);
0780     if (priv->cmd_ctrl)
0781         priv->cmd_ctrl = 0;
0782 
0783     /* do not count the line control and size bytes */
0784     priv->bytes_out += count;
0785     spin_unlock_irqrestore(&priv->lock, flags);
0786 
0787     usb_serial_port_softint(port);
0788 } /* cypress_send */
0789 
0790 
0791 /* returns how much space is available in the soft buffer */
0792 static unsigned int cypress_write_room(struct tty_struct *tty)
0793 {
0794     struct usb_serial_port *port = tty->driver_data;
0795     struct cypress_private *priv = usb_get_serial_port_data(port);
0796     unsigned int room;
0797     unsigned long flags;
0798 
0799     spin_lock_irqsave(&priv->lock, flags);
0800     room = kfifo_avail(&priv->write_fifo);
0801     spin_unlock_irqrestore(&priv->lock, flags);
0802 
0803     dev_dbg(&port->dev, "%s - returns %u\n", __func__, room);
0804     return room;
0805 }
0806 
0807 
0808 static int cypress_tiocmget(struct tty_struct *tty)
0809 {
0810     struct usb_serial_port *port = tty->driver_data;
0811     struct cypress_private *priv = usb_get_serial_port_data(port);
0812     __u8 status, control;
0813     unsigned int result = 0;
0814     unsigned long flags;
0815 
0816     spin_lock_irqsave(&priv->lock, flags);
0817     control = priv->line_control;
0818     status = priv->current_status;
0819     spin_unlock_irqrestore(&priv->lock, flags);
0820 
0821     result = ((control & CONTROL_DTR)        ? TIOCM_DTR : 0)
0822         | ((control & CONTROL_RTS)       ? TIOCM_RTS : 0)
0823         | ((status & UART_CTS)        ? TIOCM_CTS : 0)
0824         | ((status & UART_DSR)        ? TIOCM_DSR : 0)
0825         | ((status & UART_RI)         ? TIOCM_RI  : 0)
0826         | ((status & UART_CD)         ? TIOCM_CD  : 0);
0827 
0828     dev_dbg(&port->dev, "%s - result = %x\n", __func__, result);
0829 
0830     return result;
0831 }
0832 
0833 
0834 static int cypress_tiocmset(struct tty_struct *tty,
0835                    unsigned int set, unsigned int clear)
0836 {
0837     struct usb_serial_port *port = tty->driver_data;
0838     struct cypress_private *priv = usb_get_serial_port_data(port);
0839     unsigned long flags;
0840 
0841     spin_lock_irqsave(&priv->lock, flags);
0842     if (set & TIOCM_RTS)
0843         priv->line_control |= CONTROL_RTS;
0844     if (set & TIOCM_DTR)
0845         priv->line_control |= CONTROL_DTR;
0846     if (clear & TIOCM_RTS)
0847         priv->line_control &= ~CONTROL_RTS;
0848     if (clear & TIOCM_DTR)
0849         priv->line_control &= ~CONTROL_DTR;
0850     priv->cmd_ctrl = 1;
0851     spin_unlock_irqrestore(&priv->lock, flags);
0852 
0853     return cypress_write(tty, port, NULL, 0);
0854 }
0855 
0856 static void cypress_earthmate_init_termios(struct tty_struct *tty)
0857 {
0858     tty_encode_baud_rate(tty, 4800, 4800);
0859 }
0860 
0861 static void cypress_set_termios(struct tty_struct *tty,
0862     struct usb_serial_port *port, struct ktermios *old_termios)
0863 {
0864     struct cypress_private *priv = usb_get_serial_port_data(port);
0865     struct device *dev = &port->dev;
0866     int data_bits, stop_bits, parity_type, parity_enable;
0867     unsigned int cflag;
0868     unsigned long flags;
0869     __u8 oldlines;
0870     int linechange = 0;
0871 
0872     /* Unsupported features need clearing */
0873     tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS);
0874 
0875     cflag = tty->termios.c_cflag;
0876 
0877     /* set number of data bits, parity, stop bits */
0878     /* when parity is disabled the parity type bit is ignored */
0879 
0880     /* 1 means 2 stop bits, 0 means 1 stop bit */
0881     stop_bits = cflag & CSTOPB ? 1 : 0;
0882 
0883     if (cflag & PARENB) {
0884         parity_enable = 1;
0885         /* 1 means odd parity, 0 means even parity */
0886         parity_type = cflag & PARODD ? 1 : 0;
0887     } else
0888         parity_enable = parity_type = 0;
0889 
0890     data_bits = tty_get_char_size(cflag);
0891 
0892     spin_lock_irqsave(&priv->lock, flags);
0893     oldlines = priv->line_control;
0894     if ((cflag & CBAUD) == B0) {
0895         /* drop dtr and rts */
0896         dev_dbg(dev, "%s - dropping the lines, baud rate 0bps\n", __func__);
0897         priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
0898     } else
0899         priv->line_control = (CONTROL_DTR | CONTROL_RTS);
0900     spin_unlock_irqrestore(&priv->lock, flags);
0901 
0902     dev_dbg(dev, "%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)\n",
0903         __func__, stop_bits, parity_enable, parity_type, data_bits);
0904 
0905     cypress_serial_control(tty, port, tty_get_baud_rate(tty),
0906             data_bits, stop_bits,
0907             parity_enable, parity_type,
0908             0, CYPRESS_SET_CONFIG);
0909 
0910     /* we perform a CYPRESS_GET_CONFIG so that the current settings are
0911      * filled into the private structure this should confirm that all is
0912      * working if it returns what we just set */
0913     cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
0914 
0915     /* Here we can define custom tty settings for devices; the main tty
0916      * termios flag base comes from empeg.c */
0917 
0918     spin_lock_irqsave(&priv->lock, flags);
0919     if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) {
0920         dev_dbg(dev, "Using custom termios settings for a baud rate of 4800bps.\n");
0921         /* define custom termios settings for NMEA protocol */
0922 
0923         tty->termios.c_iflag /* input modes - */
0924             &= ~(IGNBRK  /* disable ignore break */
0925             | BRKINT     /* disable break causes interrupt */
0926             | PARMRK     /* disable mark parity errors */
0927             | ISTRIP     /* disable clear high bit of input char */
0928             | INLCR      /* disable translate NL to CR */
0929             | IGNCR      /* disable ignore CR */
0930             | ICRNL      /* disable translate CR to NL */
0931             | IXON);     /* disable enable XON/XOFF flow control */
0932 
0933         tty->termios.c_oflag /* output modes */
0934             &= ~OPOST;    /* disable postprocess output char */
0935 
0936         tty->termios.c_lflag /* line discipline modes */
0937             &= ~(ECHO     /* disable echo input characters */
0938             | ECHONL      /* disable echo new line */
0939             | ICANON      /* disable erase, kill, werase, and rprnt
0940                      special characters */
0941             | ISIG        /* disable interrupt, quit, and suspend
0942                      special characters */
0943             | IEXTEN);    /* disable non-POSIX special characters */
0944     } /* CT_CYPHIDCOM: Application should handle this for device */
0945 
0946     linechange = (priv->line_control != oldlines);
0947     spin_unlock_irqrestore(&priv->lock, flags);
0948 
0949     /* if necessary, set lines */
0950     if (linechange) {
0951         priv->cmd_ctrl = 1;
0952         cypress_write(tty, port, NULL, 0);
0953     }
0954 } /* cypress_set_termios */
0955 
0956 
0957 /* returns amount of data still left in soft buffer */
0958 static unsigned int cypress_chars_in_buffer(struct tty_struct *tty)
0959 {
0960     struct usb_serial_port *port = tty->driver_data;
0961     struct cypress_private *priv = usb_get_serial_port_data(port);
0962     unsigned int chars;
0963     unsigned long flags;
0964 
0965     spin_lock_irqsave(&priv->lock, flags);
0966     chars = kfifo_len(&priv->write_fifo);
0967     spin_unlock_irqrestore(&priv->lock, flags);
0968 
0969     dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars);
0970     return chars;
0971 }
0972 
0973 
0974 static void cypress_throttle(struct tty_struct *tty)
0975 {
0976     struct usb_serial_port *port = tty->driver_data;
0977     struct cypress_private *priv = usb_get_serial_port_data(port);
0978 
0979     spin_lock_irq(&priv->lock);
0980     priv->rx_flags = THROTTLED;
0981     spin_unlock_irq(&priv->lock);
0982 }
0983 
0984 
0985 static void cypress_unthrottle(struct tty_struct *tty)
0986 {
0987     struct usb_serial_port *port = tty->driver_data;
0988     struct cypress_private *priv = usb_get_serial_port_data(port);
0989     int actually_throttled, result;
0990 
0991     spin_lock_irq(&priv->lock);
0992     actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
0993     priv->rx_flags = 0;
0994     spin_unlock_irq(&priv->lock);
0995 
0996     if (!priv->comm_is_ok)
0997         return;
0998 
0999     if (actually_throttled) {
1000         result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
1001         if (result) {
1002             dev_err(&port->dev, "%s - failed submitting read urb, "
1003                     "error %d\n", __func__, result);
1004             cypress_set_dead(port);
1005         }
1006     }
1007 }
1008 
1009 
1010 static void cypress_read_int_callback(struct urb *urb)
1011 {
1012     struct usb_serial_port *port = urb->context;
1013     struct cypress_private *priv = usb_get_serial_port_data(port);
1014     struct device *dev = &urb->dev->dev;
1015     struct tty_struct *tty;
1016     unsigned char *data = urb->transfer_buffer;
1017     unsigned long flags;
1018     char tty_flag = TTY_NORMAL;
1019     int bytes = 0;
1020     int result;
1021     int i = 0;
1022     int status = urb->status;
1023 
1024     switch (status) {
1025     case 0: /* success */
1026         break;
1027     case -ECONNRESET:
1028     case -ENOENT:
1029     case -ESHUTDOWN:
1030         /* precursor to disconnect so just go away */
1031         return;
1032     case -EPIPE:
1033         /* Can't call usb_clear_halt while in_interrupt */
1034         fallthrough;
1035     default:
1036         /* something ugly is going on... */
1037         dev_err(dev, "%s - unexpected nonzero read status received: %d\n",
1038             __func__, status);
1039         cypress_set_dead(port);
1040         return;
1041     }
1042 
1043     spin_lock_irqsave(&priv->lock, flags);
1044     if (priv->rx_flags & THROTTLED) {
1045         dev_dbg(dev, "%s - now throttling\n", __func__);
1046         priv->rx_flags |= ACTUALLY_THROTTLED;
1047         spin_unlock_irqrestore(&priv->lock, flags);
1048         return;
1049     }
1050     spin_unlock_irqrestore(&priv->lock, flags);
1051 
1052     tty = tty_port_tty_get(&port->port);
1053     if (!tty) {
1054         dev_dbg(dev, "%s - bad tty pointer - exiting\n", __func__);
1055         return;
1056     }
1057 
1058     spin_lock_irqsave(&priv->lock, flags);
1059     result = urb->actual_length;
1060     switch (priv->pkt_fmt) {
1061     default:
1062     case packet_format_1:
1063         /* This is for the CY7C64013... */
1064         priv->current_status = data[0] & 0xF8;
1065         bytes = data[1] + 2;
1066         i = 2;
1067         break;
1068     case packet_format_2:
1069         /* This is for the CY7C63743... */
1070         priv->current_status = data[0] & 0xF8;
1071         bytes = (data[0] & 0x07) + 1;
1072         i = 1;
1073         break;
1074     }
1075     spin_unlock_irqrestore(&priv->lock, flags);
1076     if (result < bytes) {
1077         dev_dbg(dev,
1078             "%s - wrong packet size - received %d bytes but packet said %d bytes\n",
1079             __func__, result, bytes);
1080         goto continue_read;
1081     }
1082 
1083     usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
1084 
1085     spin_lock_irqsave(&priv->lock, flags);
1086     /* check to see if status has changed */
1087     if (priv->current_status != priv->prev_status) {
1088         u8 delta = priv->current_status ^ priv->prev_status;
1089 
1090         if (delta & UART_MSR_MASK) {
1091             if (delta & UART_CTS)
1092                 port->icount.cts++;
1093             if (delta & UART_DSR)
1094                 port->icount.dsr++;
1095             if (delta & UART_RI)
1096                 port->icount.rng++;
1097             if (delta & UART_CD)
1098                 port->icount.dcd++;
1099 
1100             wake_up_interruptible(&port->port.delta_msr_wait);
1101         }
1102 
1103         priv->prev_status = priv->current_status;
1104     }
1105     spin_unlock_irqrestore(&priv->lock, flags);
1106 
1107     /* hangup, as defined in acm.c... this might be a bad place for it
1108      * though */
1109     if (tty && !C_CLOCAL(tty) && !(priv->current_status & UART_CD)) {
1110         dev_dbg(dev, "%s - calling hangup\n", __func__);
1111         tty_hangup(tty);
1112         goto continue_read;
1113     }
1114 
1115     /* There is one error bit... I'm assuming it is a parity error
1116      * indicator as the generic firmware will set this bit to 1 if a
1117      * parity error occurs.
1118      * I can not find reference to any other error events. */
1119     spin_lock_irqsave(&priv->lock, flags);
1120     if (priv->current_status & CYP_ERROR) {
1121         spin_unlock_irqrestore(&priv->lock, flags);
1122         tty_flag = TTY_PARITY;
1123         dev_dbg(dev, "%s - Parity Error detected\n", __func__);
1124     } else
1125         spin_unlock_irqrestore(&priv->lock, flags);
1126 
1127     /* process read if there is data other than line status */
1128     if (bytes > i) {
1129         tty_insert_flip_string_fixed_flag(&port->port, data + i,
1130                 tty_flag, bytes - i);
1131         tty_flip_buffer_push(&port->port);
1132     }
1133 
1134     spin_lock_irqsave(&priv->lock, flags);
1135     /* control and status byte(s) are also counted */
1136     priv->bytes_in += bytes;
1137     spin_unlock_irqrestore(&priv->lock, flags);
1138 
1139 continue_read:
1140     tty_kref_put(tty);
1141 
1142     /* Continue trying to always read */
1143 
1144     if (priv->comm_is_ok) {
1145         usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
1146                 usb_rcvintpipe(port->serial->dev,
1147                     port->interrupt_in_endpointAddress),
1148                 port->interrupt_in_urb->transfer_buffer,
1149                 port->interrupt_in_urb->transfer_buffer_length,
1150                 cypress_read_int_callback, port,
1151                 priv->read_urb_interval);
1152         result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1153         if (result && result != -EPERM) {
1154             dev_err(dev, "%s - failed resubmitting read urb, error %d\n",
1155                 __func__, result);
1156             cypress_set_dead(port);
1157         }
1158     }
1159 } /* cypress_read_int_callback */
1160 
1161 
1162 static void cypress_write_int_callback(struct urb *urb)
1163 {
1164     struct usb_serial_port *port = urb->context;
1165     struct cypress_private *priv = usb_get_serial_port_data(port);
1166     struct device *dev = &urb->dev->dev;
1167     int status = urb->status;
1168 
1169     switch (status) {
1170     case 0:
1171         /* success */
1172         break;
1173     case -ECONNRESET:
1174     case -ENOENT:
1175     case -ESHUTDOWN:
1176         /* this urb is terminated, clean up */
1177         dev_dbg(dev, "%s - urb shutting down with status: %d\n",
1178             __func__, status);
1179         priv->write_urb_in_use = 0;
1180         return;
1181     case -EPIPE:
1182         /* Cannot call usb_clear_halt while in_interrupt */
1183         fallthrough;
1184     default:
1185         dev_err(dev, "%s - unexpected nonzero write status received: %d\n",
1186             __func__, status);
1187         cypress_set_dead(port);
1188         break;
1189     }
1190     priv->write_urb_in_use = 0;
1191 
1192     /* send any buffered data */
1193     cypress_send(port);
1194 }
1195 
1196 module_usb_serial_driver(serial_drivers, id_table_combined);
1197 
1198 MODULE_AUTHOR(DRIVER_AUTHOR);
1199 MODULE_DESCRIPTION(DRIVER_DESC);
1200 MODULE_LICENSE("GPL");
1201 
1202 module_param(stats, bool, 0644);
1203 MODULE_PARM_DESC(stats, "Enable statistics or not");
1204 module_param(interval, int, 0644);
1205 MODULE_PARM_DESC(interval, "Overrides interrupt interval");
1206 module_param(unstable_bauds, bool, 0644);
1207 MODULE_PARM_DESC(unstable_bauds, "Allow unstable baud rates");