15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * USB Empeg empeg-car player driver
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 2000, 2001
61da177e4SLinus Torvalds * Gary Brubaker (xavyer@ix.netcom.com)
71da177e4SLinus Torvalds *
81da177e4SLinus Torvalds * Copyright (C) 1999 - 2001
91da177e4SLinus Torvalds * Greg Kroah-Hartman (greg@kroah.com)
101da177e4SLinus Torvalds *
11*ecefae6dSMauro Carvalho Chehab * See Documentation/usb/usb-serial.rst for more information on using this
1293c46795SAlan Cox * driver
131da177e4SLinus Torvalds */
141da177e4SLinus Torvalds
151da177e4SLinus Torvalds #include <linux/kernel.h>
161da177e4SLinus Torvalds #include <linux/errno.h>
171da177e4SLinus Torvalds #include <linux/slab.h>
181da177e4SLinus Torvalds #include <linux/tty.h>
191da177e4SLinus Torvalds #include <linux/tty_driver.h>
201da177e4SLinus Torvalds #include <linux/tty_flip.h>
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/spinlock.h>
2393c46795SAlan Cox #include <linux/uaccess.h>
241da177e4SLinus Torvalds #include <linux/usb.h>
25a969888cSGreg Kroah-Hartman #include <linux/usb/serial.h>
261da177e4SLinus Torvalds
271da177e4SLinus Torvalds #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
281da177e4SLinus Torvalds #define DRIVER_DESC "USB Empeg Mark I/II Driver"
291da177e4SLinus Torvalds
301da177e4SLinus Torvalds #define EMPEG_VENDOR_ID 0x084f
311da177e4SLinus Torvalds #define EMPEG_PRODUCT_ID 0x0001
321da177e4SLinus Torvalds
331da177e4SLinus Torvalds /* function prototypes for an empeg-car player */
341da177e4SLinus Torvalds static int empeg_startup(struct usb_serial *serial);
35fe1ae7fdSAlan Cox static void empeg_init_termios(struct tty_struct *tty);
361da177e4SLinus Torvalds
377d40d7e8SNémeth Márton static const struct usb_device_id id_table[] = {
381da177e4SLinus Torvalds { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
391da177e4SLinus Torvalds { } /* Terminating entry */
401da177e4SLinus Torvalds };
411da177e4SLinus Torvalds
421da177e4SLinus Torvalds MODULE_DEVICE_TABLE(usb, id_table);
431da177e4SLinus Torvalds
44ea65370dSGreg Kroah-Hartman static struct usb_serial_driver empeg_device = {
4518fcac35SGreg Kroah-Hartman .driver = {
46269bda1cSGreg Kroah-Hartman .name = "empeg",
4718fcac35SGreg Kroah-Hartman },
481da177e4SLinus Torvalds .id_table = id_table,
491da177e4SLinus Torvalds .num_ports = 1,
50695aaae6SJohan Hovold .bulk_out_size = 256,
51695aaae6SJohan Hovold .throttle = usb_serial_generic_throttle,
52695aaae6SJohan Hovold .unthrottle = usb_serial_generic_unthrottle,
531da177e4SLinus Torvalds .attach = empeg_startup,
54fe1ae7fdSAlan Cox .init_termios = empeg_init_termios,
551da177e4SLinus Torvalds };
561da177e4SLinus Torvalds
5797b6b6d2SAlan Stern static struct usb_serial_driver * const serial_drivers[] = {
5897b6b6d2SAlan Stern &empeg_device, NULL
5997b6b6d2SAlan Stern };
6097b6b6d2SAlan Stern
empeg_startup(struct usb_serial * serial)611da177e4SLinus Torvalds static int empeg_startup(struct usb_serial *serial)
621da177e4SLinus Torvalds {
631da177e4SLinus Torvalds int r;
641da177e4SLinus Torvalds
651da177e4SLinus Torvalds if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
66194343d9SGreg Kroah-Hartman dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
671da177e4SLinus Torvalds serial->dev->actconfig->desc.bConfigurationValue);
681da177e4SLinus Torvalds return -ENODEV;
691da177e4SLinus Torvalds }
704e512ab9SGreg Kroah-Hartman
711da177e4SLinus Torvalds r = usb_reset_configuration(serial->dev);
721da177e4SLinus Torvalds
731da177e4SLinus Torvalds /* continue on with initialization */
741da177e4SLinus Torvalds return r;
751da177e4SLinus Torvalds }
761da177e4SLinus Torvalds
empeg_init_termios(struct tty_struct * tty)77fe1ae7fdSAlan Cox static void empeg_init_termios(struct tty_struct *tty)
781da177e4SLinus Torvalds {
79adc8d746SAlan Cox struct ktermios *termios = &tty->termios;
801da177e4SLinus Torvalds
811da177e4SLinus Torvalds /*
821da177e4SLinus Torvalds * The empeg-car player wants these particular tty settings.
831da177e4SLinus Torvalds * You could, for example, change the baud rate, however the
841da177e4SLinus Torvalds * player only supports 115200 (currently), so there is really
851da177e4SLinus Torvalds * no point in support for changes to the tty settings.
861da177e4SLinus Torvalds * (at least for now)
871da177e4SLinus Torvalds *
881da177e4SLinus Torvalds * The default requirements for this device are:
891da177e4SLinus Torvalds */
90998e8638SAlan Cox termios->c_iflag
911da177e4SLinus Torvalds &= ~(IGNBRK /* disable ignore break */
921da177e4SLinus Torvalds | BRKINT /* disable break causes interrupt */
931da177e4SLinus Torvalds | PARMRK /* disable mark parity errors */
941da177e4SLinus Torvalds | ISTRIP /* disable clear high bit of input characters */
951da177e4SLinus Torvalds | INLCR /* disable translate NL to CR */
961da177e4SLinus Torvalds | IGNCR /* disable ignore CR */
971da177e4SLinus Torvalds | ICRNL /* disable translate CR to NL */
981da177e4SLinus Torvalds | IXON); /* disable enable XON/XOFF flow control */
991da177e4SLinus Torvalds
100998e8638SAlan Cox termios->c_oflag
1011da177e4SLinus Torvalds &= ~OPOST; /* disable postprocess output characters */
1021da177e4SLinus Torvalds
103998e8638SAlan Cox termios->c_lflag
1041da177e4SLinus Torvalds &= ~(ECHO /* disable echo input characters */
1051da177e4SLinus Torvalds | ECHONL /* disable echo new line */
1061da177e4SLinus Torvalds | ICANON /* disable erase, kill, werase, and rprnt special characters */
1071da177e4SLinus Torvalds | ISIG /* disable interrupt, quit, and suspend special characters */
1081da177e4SLinus Torvalds | IEXTEN); /* disable non-POSIX special characters */
1091da177e4SLinus Torvalds
110998e8638SAlan Cox termios->c_cflag
1111da177e4SLinus Torvalds &= ~(CSIZE /* no size */
1121da177e4SLinus Torvalds | PARENB /* disable parity bit */
1131da177e4SLinus Torvalds | CBAUD); /* clear current baud rate */
1141da177e4SLinus Torvalds
115998e8638SAlan Cox termios->c_cflag
116998e8638SAlan Cox |= CS8; /* character size 8 bits */
1171da177e4SLinus Torvalds
11895da310eSAlan Cox tty_encode_baud_rate(tty, 115200, 115200);
1191da177e4SLinus Torvalds }
1201da177e4SLinus Torvalds
12168e24113SGreg Kroah-Hartman module_usb_serial_driver(serial_drivers, id_table);
1221da177e4SLinus Torvalds
1231da177e4SLinus Torvalds MODULE_AUTHOR(DRIVER_AUTHOR);
1241da177e4SLinus Torvalds MODULE_DESCRIPTION(DRIVER_DESC);
125627cfa89SJohan Hovold MODULE_LICENSE("GPL v2");
126