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);
96 .description = "Connect Tech - WhiteHEAT - (prerenumeration)",
107 .description = "Connect Tech - WhiteHEAT",
147 static int start_command_port(struct usb_serial *serial);
148 static void stop_command_port(struct usb_serial *serial);
175 - hold the reset (by writing to the reset bit of the CPUCS register)
176 - download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
177 - release the reset (by writing to the CPUCS register)
178 - download the WH.HEX file for all addresses greater than 0x1b3f using
179 VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
180 - hold the reset
181 - download the WH.HEX file for all addresses less than 0x1b40 using
183 - release the reset
184 - device renumerated itself and comes up as new device id with all
187 static int whiteheat_firmware_download(struct usb_serial *serial, in whiteheat_firmware_download() argument
188 const struct usb_device_id *id) in whiteheat_firmware_download() argument
192 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw"); in whiteheat_firmware_download()
194 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw"); in whiteheat_firmware_download()
198 return -ENOENT; in whiteheat_firmware_download()
202 static int whiteheat_firmware_attach(struct usb_serial *serial) in whiteheat_firmware_attach() argument
210 * Connect Tech's White Heat serial driver functions
213 static int whiteheat_attach(struct usb_serial *serial) in whiteheat_attach() argument
224 command_port = serial->port[COMMAND_PORT]; in whiteheat_attach()
226 pipe = usb_sndbulkpipe(serial->dev, in whiteheat_attach()
227 command_port->bulk_out_endpointAddress); in whiteheat_attach()
242 usb_clear_halt(serial->dev, pipe); in whiteheat_attach()
243 ret = usb_bulk_msg(serial->dev, pipe, command, 2, in whiteheat_attach()
246 dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", in whiteheat_attach()
247 serial->type->description, ret); in whiteheat_attach()
250 dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", in whiteheat_attach()
251 serial->type->description, alen); in whiteheat_attach()
255 pipe = usb_rcvbulkpipe(serial->dev, in whiteheat_attach()
256 command_port->bulk_in_endpointAddress); in whiteheat_attach()
258 usb_clear_halt(serial->dev, pipe); in whiteheat_attach()
259 ret = usb_bulk_msg(serial->dev, pipe, result, in whiteheat_attach()
262 dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", in whiteheat_attach()
263 serial->type->description, ret); in whiteheat_attach()
266 dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", in whiteheat_attach()
267 serial->type->description, alen); in whiteheat_attach()
270 dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", in whiteheat_attach()
271 serial->type->description, result[0]); in whiteheat_attach()
277 dev_info(&serial->dev->dev, "%s: Firmware v%d.%02d\n", in whiteheat_attach()
278 serial->type->description, in whiteheat_attach()
279 hw_info->sw_major_rev, hw_info->sw_minor_rev); in whiteheat_attach()
286 mutex_init(&command_info->mutex); in whiteheat_attach()
287 command_info->port_running = 0; in whiteheat_attach()
288 init_waitqueue_head(&command_info->wait_command); in whiteheat_attach()
290 command_port->write_urb->complete = command_port_write_callback; in whiteheat_attach()
291 command_port->read_urb->complete = command_port_read_callback; in whiteheat_attach()
299 dev_err(&serial->dev->dev, in whiteheat_attach()
301 serial->type->description); in whiteheat_attach()
302 dev_err(&serial->dev->dev, in whiteheat_attach()
304 serial->type->description); in whiteheat_attach()
305 dev_err(&serial->dev->dev, in whiteheat_attach()
307 serial->type->description); in whiteheat_attach()
310 return -ENODEV; in whiteheat_attach()
317 return -ENOMEM; in whiteheat_attach()
320 static void whiteheat_release(struct usb_serial *serial) in whiteheat_release() argument
325 command_port = serial->port[COMMAND_PORT]; in whiteheat_release()
335 return -ENOMEM; in whiteheat_port_probe()
354 retval = start_command_port(port->serial); in whiteheat_open()
361 stop_command_port(port->serial); in whiteheat_open()
368 stop_command_port(port->serial); in whiteheat_open()
376 usb_clear_halt(port->serial->dev, port->read_urb->pipe); in whiteheat_open()
377 usb_clear_halt(port->serial->dev, port->write_urb->pipe); in whiteheat_open()
382 stop_command_port(port->serial); in whiteheat_open()
397 stop_command_port(port->serial); in whiteheat_close()
402 struct usb_serial_port *port = tty->driver_data; in whiteheat_tiocmget()
407 if (info->mcr & UART_MCR_DTR) in whiteheat_tiocmget()
409 if (info->mcr & UART_MCR_RTS) in whiteheat_tiocmget()
418 struct usb_serial_port *port = tty->driver_data; in whiteheat_tiocmset()
422 info->mcr |= UART_MCR_RTS; in whiteheat_tiocmset()
424 info->mcr |= UART_MCR_DTR; in whiteheat_tiocmset()
427 info->mcr &= ~UART_MCR_RTS; in whiteheat_tiocmset()
429 info->mcr &= ~UART_MCR_DTR; in whiteheat_tiocmset()
431 firm_set_dtr(port, info->mcr & UART_MCR_DTR); in whiteheat_tiocmset()
432 firm_set_rts(port, info->mcr & UART_MCR_RTS); in whiteheat_tiocmset()
439 ss->baud_base = 460800; in whiteheat_get_serial()
452 struct usb_serial_port *port = tty->driver_data; in whiteheat_break_ctl()
463 int status = urb->status; in command_port_write_callback()
466 dev_dbg(&urb->dev->dev, "nonzero urb status: %d\n", status); in command_port_write_callback()
474 struct usb_serial_port *command_port = urb->context; in command_port_read_callback()
476 int status = urb->status; in command_port_read_callback()
477 unsigned char *data = urb->transfer_buffer; in command_port_read_callback()
482 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__); in command_port_read_callback()
485 if (!urb->actual_length) { in command_port_read_callback()
486 dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__); in command_port_read_callback()
490 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status); in command_port_read_callback()
491 if (status != -ENOENT) in command_port_read_callback()
492 command_info->command_finished = WHITEHEAT_CMD_FAILURE; in command_port_read_callback()
493 wake_up(&command_info->wait_command); in command_port_read_callback()
497 usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data); in command_port_read_callback()
500 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; in command_port_read_callback()
501 wake_up(&command_info->wait_command); in command_port_read_callback()
503 command_info->command_finished = WHITEHEAT_CMD_FAILURE; in command_port_read_callback()
504 wake_up(&command_info->wait_command); in command_port_read_callback()
508 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); in command_port_read_callback()
510 (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) { in command_port_read_callback()
511 memcpy(command_info->result_buffer, &data[1], in command_port_read_callback()
512 urb->actual_length - 1); in command_port_read_callback()
513 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; in command_port_read_callback()
514 wake_up(&command_info->wait_command); in command_port_read_callback()
516 dev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__); in command_port_read_callback()
519 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); in command_port_read_callback()
521 dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", in command_port_read_callback()
535 struct device *dev = &port->dev; in firm_send_command()
540 dev_dbg(dev, "%s - command %d\n", __func__, command); in firm_send_command()
542 command_port = port->serial->port[COMMAND_PORT]; in firm_send_command()
545 if (command_port->bulk_out_size < datasize + 1) in firm_send_command()
546 return -EIO; in firm_send_command()
548 mutex_lock(&command_info->mutex); in firm_send_command()
549 command_info->command_finished = false; in firm_send_command()
551 transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; in firm_send_command()
554 command_port->write_urb->transfer_buffer_length = datasize + 1; in firm_send_command()
555 retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); in firm_send_command()
557 dev_dbg(dev, "%s - submit urb failed\n", __func__); in firm_send_command()
562 t = wait_event_timeout(command_info->wait_command, in firm_send_command()
563 (bool)command_info->command_finished, COMMAND_TIMEOUT); in firm_send_command()
565 usb_kill_urb(command_port->write_urb); in firm_send_command()
567 if (command_info->command_finished == false) { in firm_send_command()
568 dev_dbg(dev, "%s - command timed out.\n", __func__); in firm_send_command()
569 retval = -ETIMEDOUT; in firm_send_command()
573 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { in firm_send_command()
574 dev_dbg(dev, "%s - command failed.\n", __func__); in firm_send_command()
575 retval = -EIO; in firm_send_command()
579 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { in firm_send_command()
580 dev_dbg(dev, "%s - command completed.\n", __func__); in firm_send_command()
584 info->mcr = command_info->result_buffer[0]; in firm_send_command()
589 mutex_unlock(&command_info->mutex); in firm_send_command()
598 open_command.port = port->port_number + 1; in firm_open()
608 close_command.port = port->port_number + 1; in firm_close()
616 struct usb_serial_port *port = tty->driver_data; in firm_setup_port()
617 struct device *dev = &port->dev; in firm_setup_port()
619 unsigned int cflag = tty->termios.c_cflag; in firm_setup_port()
622 port_settings.port = port->port_number + 1; in firm_setup_port()
625 dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits); in firm_setup_port()
641 dev_dbg(dev, "%s - parity = %c\n", __func__, port_settings.parity); in firm_setup_port()
648 dev_dbg(dev, "%s - stop bits = %d\n", __func__, port_settings.stop); in firm_setup_port()
656 dev_dbg(dev, "%s - hardware flow control = %s %s %s %s\n", __func__, in firm_setup_port()
667 dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow); in firm_setup_port()
671 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff); in firm_setup_port()
676 dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud); in firm_setup_port()
694 rts_command.port = port->port_number + 1; in firm_set_rts()
705 dtr_command.port = port->port_number + 1; in firm_set_dtr()
716 break_command.port = port->port_number + 1; in firm_set_break()
727 purge_command.port = port->port_number + 1; in firm_purge()
738 get_dr_command.port = port->port_number + 1; in firm_get_dtr_rts()
748 close_command.port = port->port_number + 1; in firm_report_tx_done()
757 static int start_command_port(struct usb_serial *serial) in start_command_port() argument
763 command_port = serial->port[COMMAND_PORT]; in start_command_port()
765 mutex_lock(&command_info->mutex); in start_command_port()
766 if (!command_info->port_running) { in start_command_port()
768 usb_clear_halt(serial->dev, command_port->read_urb->pipe); in start_command_port()
770 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); in start_command_port()
772 dev_err(&serial->dev->dev, in start_command_port()
773 "%s - failed submitting read urb, error %d\n", in start_command_port()
778 command_info->port_running++; in start_command_port()
781 mutex_unlock(&command_info->mutex); in start_command_port()
786 static void stop_command_port(struct usb_serial *serial) in stop_command_port() argument
791 command_port = serial->port[COMMAND_PORT]; in stop_command_port()
793 mutex_lock(&command_info->mutex); in stop_command_port()
794 command_info->port_running--; in stop_command_port()
795 if (!command_info->port_running) in stop_command_port()
796 usb_kill_urb(command_port->read_urb); in stop_command_port()
797 mutex_unlock(&command_info->mutex); in stop_command_port()