Lines Matching +full:serial +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0+
8 * Copyright (C) 1999 - 2001
9 * Greg Kroah-Hartman (greg@kroah.com)
11 * See Documentation/usb/usb-serial.rst for more information on using this
28 #include <linux/serial.h>
29 #include <linux/usb/serial.h>
36 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Stuart MacDonald <stuartm@connecttech.c…
44 ID tables for whiteheat are unusual, because we want to different
47 separate ID tables, and then a third table that combines them
70 static int whiteheat_firmware_download(struct usb_serial *serial,
71 const struct usb_device_id *id);
72 static int whiteheat_firmware_attach(struct usb_serial *serial);
74 /* function prototypes for the Connect Tech WhiteHEAT serial converter */
75 static int whiteheat_attach(struct usb_serial *serial);
76 static void whiteheat_release(struct usb_serial *serial);
97 .description = "Connect Tech - WhiteHEAT - (prerenumeration)",
109 .description = "Connect Tech - WhiteHEAT",
149 static int start_command_port(struct usb_serial *serial);
150 static void stop_command_port(struct usb_serial *serial);
177 - hold the reset (by writing to the reset bit of the CPUCS register)
178 - download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
179 - release the reset (by writing to the CPUCS register)
180 - download the WH.HEX file for all addresses greater than 0x1b3f using
181 VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
182 - hold the reset
183 - download the WH.HEX file for all addresses less than 0x1b40 using
185 - release the reset
186 - device renumerated itself and comes up as new device id with all
189 static int whiteheat_firmware_download(struct usb_serial *serial, in whiteheat_firmware_download() argument
190 const struct usb_device_id *id) in whiteheat_firmware_download() argument
194 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw"); in whiteheat_firmware_download()
196 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw"); in whiteheat_firmware_download()
200 return -ENOENT; in whiteheat_firmware_download()
204 static int whiteheat_firmware_attach(struct usb_serial *serial) in whiteheat_firmware_attach() argument
212 * Connect Tech's White Heat serial driver functions
215 static int whiteheat_attach(struct usb_serial *serial) in whiteheat_attach() argument
226 command_port = serial->port[COMMAND_PORT]; in whiteheat_attach()
228 pipe = usb_sndbulkpipe(serial->dev, in whiteheat_attach()
229 command_port->bulk_out_endpointAddress); in whiteheat_attach()
244 usb_clear_halt(serial->dev, pipe); in whiteheat_attach()
245 ret = usb_bulk_msg(serial->dev, pipe, command, 2, in whiteheat_attach()
248 dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", in whiteheat_attach()
249 serial->type->description, ret); in whiteheat_attach()
252 dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", in whiteheat_attach()
253 serial->type->description, alen); in whiteheat_attach()
257 pipe = usb_rcvbulkpipe(serial->dev, in whiteheat_attach()
258 command_port->bulk_in_endpointAddress); in whiteheat_attach()
260 usb_clear_halt(serial->dev, pipe); in whiteheat_attach()
261 ret = usb_bulk_msg(serial->dev, pipe, result, in whiteheat_attach()
264 dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", in whiteheat_attach()
265 serial->type->description, ret); in whiteheat_attach()
268 dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", in whiteheat_attach()
269 serial->type->description, alen); in whiteheat_attach()
272 dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", in whiteheat_attach()
273 serial->type->description, result[0]); in whiteheat_attach()
279 dev_info(&serial->dev->dev, "%s: Firmware v%d.%02d\n", in whiteheat_attach()
280 serial->type->description, in whiteheat_attach()
281 hw_info->sw_major_rev, hw_info->sw_minor_rev); in whiteheat_attach()
288 mutex_init(&command_info->mutex); in whiteheat_attach()
289 command_info->port_running = 0; in whiteheat_attach()
290 init_waitqueue_head(&command_info->wait_command); in whiteheat_attach()
292 command_port->write_urb->complete = command_port_write_callback; in whiteheat_attach()
293 command_port->read_urb->complete = command_port_read_callback; in whiteheat_attach()
301 dev_err(&serial->dev->dev, in whiteheat_attach()
303 serial->type->description); in whiteheat_attach()
304 dev_err(&serial->dev->dev, in whiteheat_attach()
306 serial->type->description); in whiteheat_attach()
307 dev_err(&serial->dev->dev, in whiteheat_attach()
309 serial->type->description); in whiteheat_attach()
312 return -ENODEV; in whiteheat_attach()
319 return -ENOMEM; in whiteheat_attach()
322 static void whiteheat_release(struct usb_serial *serial) in whiteheat_release() argument
327 command_port = serial->port[COMMAND_PORT]; in whiteheat_release()
337 return -ENOMEM; in whiteheat_port_probe()
356 retval = start_command_port(port->serial); in whiteheat_open()
363 stop_command_port(port->serial); in whiteheat_open()
370 stop_command_port(port->serial); in whiteheat_open()
378 usb_clear_halt(port->serial->dev, port->read_urb->pipe); in whiteheat_open()
379 usb_clear_halt(port->serial->dev, port->write_urb->pipe); in whiteheat_open()
384 stop_command_port(port->serial); in whiteheat_open()
399 stop_command_port(port->serial); in whiteheat_close()
404 struct usb_serial_port *port = tty->driver_data; in whiteheat_tiocmget()
409 if (info->mcr & UART_MCR_DTR) in whiteheat_tiocmget()
411 if (info->mcr & UART_MCR_RTS) in whiteheat_tiocmget()
420 struct usb_serial_port *port = tty->driver_data; in whiteheat_tiocmset()
424 info->mcr |= UART_MCR_RTS; in whiteheat_tiocmset()
426 info->mcr |= UART_MCR_DTR; in whiteheat_tiocmset()
429 info->mcr &= ~UART_MCR_RTS; in whiteheat_tiocmset()
431 info->mcr &= ~UART_MCR_DTR; in whiteheat_tiocmset()
433 firm_set_dtr(port, info->mcr & UART_MCR_DTR); in whiteheat_tiocmset()
434 firm_set_rts(port, info->mcr & UART_MCR_RTS); in whiteheat_tiocmset()
441 ss->baud_base = 460800; in whiteheat_get_serial()
454 struct usb_serial_port *port = tty->driver_data; in whiteheat_break_ctl()
465 int status = urb->status; in command_port_write_callback()
468 dev_dbg(&urb->dev->dev, "nonzero urb status: %d\n", status); in command_port_write_callback()
476 struct usb_serial_port *command_port = urb->context; in command_port_read_callback()
478 int status = urb->status; in command_port_read_callback()
479 unsigned char *data = urb->transfer_buffer; in command_port_read_callback()
484 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__); in command_port_read_callback()
487 if (!urb->actual_length) { in command_port_read_callback()
488 dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__); in command_port_read_callback()
492 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status); in command_port_read_callback()
493 if (status != -ENOENT) in command_port_read_callback()
494 command_info->command_finished = WHITEHEAT_CMD_FAILURE; in command_port_read_callback()
495 wake_up(&command_info->wait_command); in command_port_read_callback()
499 usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data); in command_port_read_callback()
502 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; in command_port_read_callback()
503 wake_up(&command_info->wait_command); in command_port_read_callback()
505 command_info->command_finished = WHITEHEAT_CMD_FAILURE; in command_port_read_callback()
506 wake_up(&command_info->wait_command); in command_port_read_callback()
510 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); in command_port_read_callback()
512 (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) { in command_port_read_callback()
513 memcpy(command_info->result_buffer, &data[1], in command_port_read_callback()
514 urb->actual_length - 1); in command_port_read_callback()
515 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; in command_port_read_callback()
516 wake_up(&command_info->wait_command); in command_port_read_callback()
518 dev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__); in command_port_read_callback()
521 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); in command_port_read_callback()
523 dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", in command_port_read_callback()
537 struct device *dev = &port->dev; in firm_send_command()
542 dev_dbg(dev, "%s - command %d\n", __func__, command); in firm_send_command()
544 command_port = port->serial->port[COMMAND_PORT]; in firm_send_command()
547 if (command_port->bulk_out_size < datasize + 1) in firm_send_command()
548 return -EIO; in firm_send_command()
550 mutex_lock(&command_info->mutex); in firm_send_command()
551 command_info->command_finished = false; in firm_send_command()
553 transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; in firm_send_command()
556 command_port->write_urb->transfer_buffer_length = datasize + 1; in firm_send_command()
557 retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); in firm_send_command()
559 dev_dbg(dev, "%s - submit urb failed\n", __func__); in firm_send_command()
564 t = wait_event_timeout(command_info->wait_command, in firm_send_command()
565 (bool)command_info->command_finished, COMMAND_TIMEOUT); in firm_send_command()
567 usb_kill_urb(command_port->write_urb); in firm_send_command()
569 if (command_info->command_finished == false) { in firm_send_command()
570 dev_dbg(dev, "%s - command timed out.\n", __func__); in firm_send_command()
571 retval = -ETIMEDOUT; in firm_send_command()
575 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { in firm_send_command()
576 dev_dbg(dev, "%s - command failed.\n", __func__); in firm_send_command()
577 retval = -EIO; in firm_send_command()
581 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { in firm_send_command()
582 dev_dbg(dev, "%s - command completed.\n", __func__); in firm_send_command()
586 info->mcr = command_info->result_buffer[0]; in firm_send_command()
591 mutex_unlock(&command_info->mutex); in firm_send_command()
600 open_command.port = port->port_number + 1; in firm_open()
610 close_command.port = port->port_number + 1; in firm_close()
618 struct usb_serial_port *port = tty->driver_data; in firm_setup_port()
619 struct device *dev = &port->dev; in firm_setup_port()
621 unsigned int cflag = tty->termios.c_cflag; in firm_setup_port()
624 port_settings.port = port->port_number + 1; in firm_setup_port()
627 dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits); in firm_setup_port()
643 dev_dbg(dev, "%s - parity = %c\n", __func__, port_settings.parity); in firm_setup_port()
650 dev_dbg(dev, "%s - stop bits = %d\n", __func__, port_settings.stop); in firm_setup_port()
658 dev_dbg(dev, "%s - hardware flow control = %s %s %s %s\n", __func__, in firm_setup_port()
669 dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow); in firm_setup_port()
673 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff); in firm_setup_port()
678 dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud); in firm_setup_port()
696 rts_command.port = port->port_number + 1; in firm_set_rts()
707 dtr_command.port = port->port_number + 1; in firm_set_dtr()
718 break_command.port = port->port_number + 1; in firm_set_break()
729 purge_command.port = port->port_number + 1; in firm_purge()
740 get_dr_command.port = port->port_number + 1; in firm_get_dtr_rts()
750 close_command.port = port->port_number + 1; in firm_report_tx_done()
759 static int start_command_port(struct usb_serial *serial) in start_command_port() argument
765 command_port = serial->port[COMMAND_PORT]; in start_command_port()
767 mutex_lock(&command_info->mutex); in start_command_port()
768 if (!command_info->port_running) { in start_command_port()
770 usb_clear_halt(serial->dev, command_port->read_urb->pipe); in start_command_port()
772 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); in start_command_port()
774 dev_err(&serial->dev->dev, in start_command_port()
775 "%s - failed submitting read urb, error %d\n", in start_command_port()
780 command_info->port_running++; in start_command_port()
783 mutex_unlock(&command_info->mutex); in start_command_port()
788 static void stop_command_port(struct usb_serial *serial) in stop_command_port() argument
793 command_port = serial->port[COMMAND_PORT]; in stop_command_port()
795 mutex_lock(&command_info->mutex); in stop_command_port()
796 command_info->port_running--; in stop_command_port()
797 if (!command_info->port_running) in stop_command_port()
798 usb_kill_urb(command_port->read_urb); in stop_command_port()
799 mutex_unlock(&command_info->mutex); in stop_command_port()