cp210x.c (f6d47fe5921a6d3f5a1a3d0b9a3dd34b8e295722) cp210x.c (ceb4038472a4803e7046ed488b03d11551991514)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
4 *
5 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
6 * Copyright (C) 2010-2021 Johan Hovold (johan@kernel.org)
7 *
8 * Support to set flow control line levels using TIOCMGET and TIOCMSET

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

26#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver"
27
28/*
29 * Function Prototypes
30 */
31static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
32static void cp210x_close(struct usb_serial_port *);
33static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
4 *
5 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
6 * Copyright (C) 2010-2021 Johan Hovold (johan@kernel.org)
7 *
8 * Support to set flow control line levels using TIOCMGET and TIOCMSET

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

26#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver"
27
28/*
29 * Function Prototypes
30 */
31static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
32static void cp210x_close(struct usb_serial_port *);
33static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
34 const struct ktermios *);
34 struct ktermios *);
35static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
35static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
36 const struct ktermios *);
36 struct ktermios*);
37static bool cp210x_tx_empty(struct usb_serial_port *port);
38static int cp210x_tiocmget(struct tty_struct *);
39static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int);
40static int cp210x_tiocmset_port(struct usb_serial_port *port,
41 unsigned int, unsigned int);
42static void cp210x_break_ctl(struct tty_struct *, int);
43static int cp210x_attach(struct usb_serial *);
44static void cp210x_disconnect(struct usb_serial *);

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

125 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */
126 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
127 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
128 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
129 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
130 { USB_DEVICE(0x10C4, 0x83AA) }, /* Mark-10 Digital Force Gauge */
131 { USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
132 { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
37static bool cp210x_tx_empty(struct usb_serial_port *port);
38static int cp210x_tiocmget(struct tty_struct *);
39static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int);
40static int cp210x_tiocmset_port(struct usb_serial_port *port,
41 unsigned int, unsigned int);
42static void cp210x_break_ctl(struct tty_struct *, int);
43static int cp210x_attach(struct usb_serial *);
44static void cp210x_disconnect(struct usb_serial *);

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

125 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */
126 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
127 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
128 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
129 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
130 { USB_DEVICE(0x10C4, 0x83AA) }, /* Mark-10 Digital Force Gauge */
131 { USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
132 { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
133 { USB_DEVICE(0x10C4, 0x8414) }, /* Decagon USB Cable Adapter */
133 { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
134 { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
135 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */
136 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
137 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */
138 { USB_DEVICE(0x10C4, 0x851E) }, /* CESINEL MEDCAL PT Network Analyzer */
139 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */
140 { USB_DEVICE(0x10C4, 0x85B8) }, /* CESINEL ReCon T Energy Logger */

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

1034 * actual = freq / (2 x prescale x div)
1035 *
1036 * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps
1037 * or 1 otherwise.
1038 * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1
1039 * otherwise.
1040 */
1041static void cp210x_change_speed(struct tty_struct *tty,
134 { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
135 { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
136 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */
137 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
138 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */
139 { USB_DEVICE(0x10C4, 0x851E) }, /* CESINEL MEDCAL PT Network Analyzer */
140 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */
141 { USB_DEVICE(0x10C4, 0x85B8) }, /* CESINEL ReCon T Energy Logger */

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

1035 * actual = freq / (2 x prescale x div)
1036 *
1037 * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps
1038 * or 1 otherwise.
1039 * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1
1040 * otherwise.
1041 */
1042static void cp210x_change_speed(struct tty_struct *tty,
1042 struct usb_serial_port *port,
1043 const struct ktermios *old_termios)
1043 struct usb_serial_port *port, struct ktermios *old_termios)
1044{
1045 struct usb_serial *serial = port->serial;
1046 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
1047 u32 baud;
1048
1049 /*
1050 * This maps the requested rate to the actual rate, a valid rate on
1051 * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed].

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

1117 iflag_change = ((a->c_iflag ^ b->c_iflag) & (INPCK | IXON | IXOFF));
1118 cc_change = a->c_cc[VSTART] != b->c_cc[VSTART] ||
1119 a->c_cc[VSTOP] != b->c_cc[VSTOP];
1120
1121 return tty_termios_hw_change(a, b) || iflag_change || cc_change;
1122}
1123
1124static void cp210x_set_flow_control(struct tty_struct *tty,
1044{
1045 struct usb_serial *serial = port->serial;
1046 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
1047 u32 baud;
1048
1049 /*
1050 * This maps the requested rate to the actual rate, a valid rate on
1051 * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed].

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

1117 iflag_change = ((a->c_iflag ^ b->c_iflag) & (INPCK | IXON | IXOFF));
1118 cc_change = a->c_cc[VSTART] != b->c_cc[VSTART] ||
1119 a->c_cc[VSTOP] != b->c_cc[VSTOP];
1120
1121 return tty_termios_hw_change(a, b) || iflag_change || cc_change;
1122}
1123
1124static void cp210x_set_flow_control(struct tty_struct *tty,
1125 struct usb_serial_port *port,
1126 const struct ktermios *old_termios)
1125 struct usb_serial_port *port, struct ktermios *old_termios)
1127{
1128 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial);
1129 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
1130 struct cp210x_special_chars chars;
1131 struct cp210x_flow_ctl flow_ctl;
1132 u32 flow_repl;
1133 u32 ctl_hs;
1134 bool crtscts;

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

1228 goto out_unlock;
1229
1230 port_priv->crtscts = crtscts;
1231out_unlock:
1232 mutex_unlock(&port_priv->mutex);
1233}
1234
1235static void cp210x_set_termios(struct tty_struct *tty,
1126{
1127 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial);
1128 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
1129 struct cp210x_special_chars chars;
1130 struct cp210x_flow_ctl flow_ctl;
1131 u32 flow_repl;
1132 u32 ctl_hs;
1133 bool crtscts;

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

1227 goto out_unlock;
1228
1229 port_priv->crtscts = crtscts;
1230out_unlock:
1231 mutex_unlock(&port_priv->mutex);
1232}
1233
1234static void cp210x_set_termios(struct tty_struct *tty,
1236 struct usb_serial_port *port,
1237 const struct ktermios *old_termios)
1235 struct usb_serial_port *port, struct ktermios *old_termios)
1238{
1239 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial);
1240 u16 bits;
1241 int ret;
1242
1243 if (old_termios && !cp210x_termios_change(&tty->termios, old_termios))
1244 return;
1245

--- 925 unchanged lines hidden ---
1236{
1237 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial);
1238 u16 bits;
1239 int ret;
1240
1241 if (old_termios && !cp210x_termios_change(&tty->termios, old_termios))
1242 return;
1243

--- 925 unchanged lines hidden ---