Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * USB Empeg empeg-car player driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Copyright (C) 2000, 2001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	    Gary Brubaker (xavyer@ix.netcom.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	Copyright (C) 1999 - 2001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *	    Greg Kroah-Hartman (greg@kroah.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * See Documentation/usb/usb-serial.rst for more information on using this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/tty_driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/tty_flip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/usb/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define DRIVER_DESC "USB Empeg Mark I/II Driver"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define EMPEG_VENDOR_ID			0x084f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define EMPEG_PRODUCT_ID		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /* function prototypes for an empeg-car player */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static int  empeg_startup(struct usb_serial *serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static void empeg_init_termios(struct tty_struct *tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static const struct usb_device_id id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	{ }					/* Terminating entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) MODULE_DEVICE_TABLE(usb, id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static struct usb_serial_driver empeg_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		.owner =	THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		.name =		"empeg",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	.id_table =		id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	.num_ports =		1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	.bulk_out_size =	256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	.throttle =		usb_serial_generic_throttle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	.unthrottle =		usb_serial_generic_unthrottle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	.attach =		empeg_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	.init_termios =		empeg_init_termios,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static struct usb_serial_driver * const serial_drivers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	&empeg_device, NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static int empeg_startup(struct usb_serial *serial)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			serial->dev->actconfig->desc.bConfigurationValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	r = usb_reset_configuration(serial->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	/* continue on with initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static void empeg_init_termios(struct tty_struct *tty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct ktermios *termios = &tty->termios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * The empeg-car player wants these particular tty settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 * You could, for example, change the baud rate, however the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 * player only supports 115200 (currently), so there is really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * no point in support for changes to the tty settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * (at least for now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 * The default requirements for this device are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	termios->c_iflag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		&= ~(IGNBRK	/* disable ignore break */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		| BRKINT	/* disable break causes interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		| PARMRK	/* disable mark parity errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		| ISTRIP	/* disable clear high bit of input characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		| INLCR		/* disable translate NL to CR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		| IGNCR		/* disable ignore CR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		| ICRNL		/* disable translate CR to NL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		| IXON);	/* disable enable XON/XOFF flow control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	termios->c_oflag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		&= ~OPOST;	/* disable postprocess output characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	termios->c_lflag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		&= ~(ECHO	/* disable echo input characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		| ECHONL	/* disable echo new line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		| ICANON	/* disable erase, kill, werase, and rprnt special characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		| ISIG		/* disable interrupt, quit, and suspend special characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		| IEXTEN);	/* disable non-POSIX special characters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	termios->c_cflag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		&= ~(CSIZE	/* no size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		| PARENB	/* disable parity bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		| CBAUD);	/* clear current baud rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	termios->c_cflag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		|= CS8;		/* character size 8 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	tty_encode_baud_rate(tty, 115200, 115200);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) module_usb_serial_driver(serial_drivers, id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) MODULE_AUTHOR(DRIVER_AUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) MODULE_DESCRIPTION(DRIVER_DESC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) MODULE_LICENSE("GPL v2");