Lines Matching +full:force +full:- +full:m1
1 // SPDX-License-Identifier: GPL-2.0+
12 * The F81532/F81534 had 1 control endpoint for setting, 1 endpoint bulk-out
13 * for all serial port TX and 1 endpoint bulk-in for all serial port read in
122 * Bit2-1: Clock source selector
181 /* Pin output value for M2/M1/M0(SD) */
197 usb_get_serial_data(port->serial); in f81534_logic_to_phy_port()
202 if (serial_priv->conf_data[i] & F81534_PORT_UNAVAILABLE) in f81534_logic_to_phy_port()
205 if (port->port_number == count) in f81534_logic_to_phy_port()
211 return -ENODEV; in f81534_logic_to_phy_port()
216 struct usb_interface *interface = serial->interface; in f81534_set_register()
217 struct usb_device *dev = serial->dev; in f81534_set_register()
224 return -ENOMEM; in f81534_set_register()
232 while (count--) { in f81534_set_register()
245 dev_err(&interface->dev, "%s: reg: %x data: %x failed: %d\n", in f81534_set_register()
255 struct usb_interface *interface = serial->interface; in f81534_get_register()
256 struct usb_device *dev = serial->dev; in f81534_get_register()
263 return -ENOMEM; in f81534_get_register()
269 while (count--) { in f81534_get_register()
279 status = -EIO; in f81534_get_register()
284 dev_err(&interface->dev, "%s: reg: %x failed: %d\n", __func__, in f81534_get_register()
331 return f81534_set_register(port->serial, in f81534_set_port_register()
332 reg + port_priv->phy_num * F81534_UART_OFFSET, data); in f81534_set_port_register()
340 return f81534_get_register(port->serial, in f81534_get_port_register()
341 reg + port_priv->phy_num * F81534_UART_OFFSET, data); in f81534_get_port_register()
366 } while (--count); in f81534_wait_for_spi_idle()
369 dev_err(&serial->interface->dev, in f81534_wait_for_spi_idle()
372 return -EIO; in f81534_wait_for_spi_idle()
446 * Dummy code, force IC to generate a read pulse, the in f81534_read_flash()
464 size -= read_size; in f81534_read_flash()
474 int phy_num = port_priv->phy_num; in f81534_prepare_write_buffer()
493 tx_len = kfifo_out_locked(&port->write_fifo, in f81534_prepare_write_buffer()
495 F81534_MAX_TX_SIZE, &port->lock); in f81534_prepare_write_buffer()
508 spin_lock_irqsave(&port->lock, flags); in f81534_submit_writer()
510 if (kfifo_is_empty(&port->write_fifo)) { in f81534_submit_writer()
511 spin_unlock_irqrestore(&port->lock, flags); in f81534_submit_writer()
515 spin_unlock_irqrestore(&port->lock, flags); in f81534_submit_writer()
518 if (!test_and_clear_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty)) in f81534_submit_writer()
521 urb = port->write_urbs[0]; in f81534_submit_writer()
522 f81534_prepare_write_buffer(port, port->bulk_out_buffers[0]); in f81534_submit_writer()
523 urb->transfer_buffer_length = F81534_WRITE_BUFFER_SIZE; in f81534_submit_writer()
527 set_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty); in f81534_submit_writer()
528 dev_err(&port->dev, "%s: submit failed: %d\n", __func__, in f81534_submit_writer()
553 return -EINVAL; in f81534_find_clk()
582 return -EINVAL; in f81534_set_port_config()
584 port_priv->baud_base = baudrate_table[idx]; in f81534_set_port_config()
585 port_priv->shadow_clk &= ~F81534_CLK_MASK; in f81534_set_port_config()
586 port_priv->shadow_clk |= clock_table[idx]; in f81534_set_port_config()
589 port_priv->shadow_clk); in f81534_set_port_config()
591 dev_err(&port->dev, "CLOCK_REG setting failed\n"); in f81534_set_port_config()
602 dev_err(&port->dev, "%s: CONFIG1 setting failed\n", __func__); in f81534_set_port_config()
614 dev_err(&port->dev, "%s: FCR setting failed\n", __func__); in f81534_set_port_config()
618 divisor = f81534_calc_baud_divisor(baudrate, port_priv->baud_base); in f81534_set_port_config()
620 mutex_lock(&port_priv->lcr_mutex); in f81534_set_port_config()
626 dev_err(&port->dev, "%s: set LCR failed\n", __func__); in f81534_set_port_config()
633 dev_err(&port->dev, "%s: set DLAB LSB failed\n", __func__); in f81534_set_port_config()
640 dev_err(&port->dev, "%s: set DLAB MSB failed\n", __func__); in f81534_set_port_config()
644 value = lcr | (port_priv->shadow_lcr & UART_LCR_SBC); in f81534_set_port_config()
648 dev_err(&port->dev, "%s: set LCR failed\n", __func__); in f81534_set_port_config()
652 port_priv->shadow_lcr = value; in f81534_set_port_config()
654 mutex_unlock(&port_priv->lcr_mutex); in f81534_set_port_config()
661 struct usb_serial_port *port = tty->driver_data; in f81534_break_ctl()
665 mutex_lock(&port_priv->lcr_mutex); in f81534_break_ctl()
668 port_priv->shadow_lcr |= UART_LCR_SBC; in f81534_break_ctl()
670 port_priv->shadow_lcr &= ~UART_LCR_SBC; in f81534_break_ctl()
673 port_priv->shadow_lcr); in f81534_break_ctl()
675 dev_err(&port->dev, "set break failed: %d\n", status); in f81534_break_ctl()
677 mutex_unlock(&port_priv->lcr_mutex); in f81534_break_ctl()
692 mutex_lock(&port_priv->mcr_mutex); in f81534_update_mctrl()
698 tmp = UART_MCR_OUT2 | port_priv->shadow_mcr; in f81534_update_mctrl()
714 dev_err(&port->dev, "%s: MCR write failed\n", __func__); in f81534_update_mctrl()
715 mutex_unlock(&port_priv->mcr_mutex); in f81534_update_mctrl()
719 port_priv->shadow_mcr = tmp; in f81534_update_mctrl()
720 mutex_unlock(&port_priv->mcr_mutex); in f81534_update_mctrl()
741 dev_err(&serial->interface->dev, "%s: read failed: %d\n", in f81534_find_config_idx()
822 * 1st is pure USB-to-TTL RS232 IC and designed for 4 ports only, no any
841 struct device *dev = &serial->interface->dev; in f81534_calc_num_ports()
842 int size_bulk_in = usb_endpoint_maxp(epds->bulk_in[0]); in f81534_calc_num_ports()
843 int size_bulk_out = usb_endpoint_maxp(epds->bulk_out[0]); in f81534_calc_num_ports()
852 return -ENODEV; in f81534_calc_num_ports()
855 serial_priv = devm_kzalloc(&serial->interface->dev, in f81534_calc_num_ports()
858 return -ENOMEM; in f81534_calc_num_ports()
861 mutex_init(&serial_priv->urb_mutex); in f81534_calc_num_ports()
864 status = f81534_find_config_idx(serial, &serial_priv->setting_idx); in f81534_calc_num_ports()
866 dev_err(&serial->interface->dev, "%s: find idx failed: %d\n", in f81534_calc_num_ports()
875 if (serial_priv->setting_idx != F81534_CUSTOM_NO_CUSTOM_DATA) { in f81534_calc_num_ports()
879 sizeof(serial_priv->conf_data), in f81534_calc_num_ports()
880 serial_priv->conf_data); in f81534_calc_num_ports()
882 dev_err(&serial->interface->dev, in f81534_calc_num_ports()
888 dev_dbg(&serial->interface->dev, in f81534_calc_num_ports()
890 serial_priv->setting_idx); in f81534_calc_num_ports()
895 sizeof(serial_priv->conf_data), in f81534_calc_num_ports()
896 serial_priv->conf_data); in f81534_calc_num_ports()
898 dev_err(&serial->interface->dev, in f81534_calc_num_ports()
904 dev_dbg(&serial->interface->dev, "%s: read default config\n", in f81534_calc_num_ports()
911 serial_priv->conf_data[i] |= F81534_PORT_UNAVAILABLE; in f81534_calc_num_ports()
913 if (serial_priv->conf_data[i] & F81534_PORT_UNAVAILABLE) in f81534_calc_num_ports()
920 dev_warn(&serial->interface->dev, in f81534_calc_num_ports()
925 /* Assign phy-to-logic mapping */ in f81534_calc_num_ports()
927 if (serial_priv->conf_data[i] & F81534_PORT_UNAVAILABLE) in f81534_calc_num_ports()
930 serial_priv->tty_idx[i] = index++; in f81534_calc_num_ports()
931 dev_dbg(&serial->interface->dev, in f81534_calc_num_ports()
933 serial_priv->tty_idx[i]); in f81534_calc_num_ports()
937 * Setup bulk-out endpoint multiplexing. All ports share the same in f81534_calc_num_ports()
938 * bulk-out endpoint. in f81534_calc_num_ports()
940 BUILD_BUG_ON(ARRAY_SIZE(epds->bulk_out) < F81534_NUM_PORT); in f81534_calc_num_ports()
943 epds->bulk_out[i] = epds->bulk_out[0]; in f81534_calc_num_ports()
945 epds->num_bulk_out = num_port; in f81534_calc_num_ports()
961 else if (old_termios && (old_termios->c_cflag & CBAUD) == B0) in f81534_set_termios()
977 new_lcr |= UART_LCR_WLEN(tty_get_char_size(tty->termios.c_cflag)); in f81534_set_termios()
988 dev_dbg(&port->dev, "%s: baud: %d\n", __func__, baud); in f81534_set_termios()
992 dev_err(&port->dev, "%s: set port config failed: %d\n", in f81534_set_termios()
999 return usb_serial_generic_submit_read_urbs(serial->port[0], flags); in f81534_submit_read_urb()
1012 spin_lock_irqsave(&port_priv->msr_lock, flags); in f81534_msr_changed()
1013 old_msr = port_priv->shadow_msr; in f81534_msr_changed()
1014 port_priv->shadow_msr = msr; in f81534_msr_changed()
1015 spin_unlock_irqrestore(&port_priv->msr_lock, flags); in f81534_msr_changed()
1017 dev_dbg(&port->dev, "%s: MSR from %02x to %02x\n", __func__, old_msr, in f81534_msr_changed()
1022 port->icount.cts++; in f81534_msr_changed()
1024 port->icount.dsr++; in f81534_msr_changed()
1026 port->icount.dcd++; in f81534_msr_changed()
1028 port->icount.rng++; in f81534_msr_changed()
1030 wake_up_interruptible(&port->port.delta_msr_wait); in f81534_msr_changed()
1035 dev_dbg(&port->dev, "%s: DCD Changed: phy_num: %d from %x to %x\n", in f81534_msr_changed()
1036 __func__, port_priv->phy_num, old_msr, msr); in f81534_msr_changed()
1038 tty = tty_port_tty_get(&port->port); in f81534_msr_changed()
1058 /* Force update current state */ in f81534_read_msr()
1059 spin_lock_irqsave(&port_priv->msr_lock, flags); in f81534_read_msr()
1060 port_priv->shadow_msr = msr; in f81534_read_msr()
1061 spin_unlock_irqrestore(&port_priv->msr_lock, flags); in f81534_read_msr()
1069 usb_get_serial_data(port->serial); in f81534_open()
1077 dev_err(&port->dev, "%s: Clear FIFO failed: %d\n", __func__, in f81534_open()
1089 mutex_lock(&serial_priv->urb_mutex); in f81534_open()
1092 if (!serial_priv->opened_port) { in f81534_open()
1093 status = f81534_submit_read_urb(port->serial, GFP_KERNEL); in f81534_open()
1098 serial_priv->opened_port++; in f81534_open()
1101 mutex_unlock(&serial_priv->urb_mutex); in f81534_open()
1103 set_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty); in f81534_open()
1110 usb_get_serial_data(port->serial); in f81534_close()
1111 struct usb_serial_port *port0 = port->serial->port[0]; in f81534_close()
1115 usb_kill_urb(port->write_urbs[0]); in f81534_close()
1117 spin_lock_irqsave(&port->lock, flags); in f81534_close()
1118 kfifo_reset_out(&port->write_fifo); in f81534_close()
1119 spin_unlock_irqrestore(&port->lock, flags); in f81534_close()
1122 mutex_lock(&serial_priv->urb_mutex); in f81534_close()
1123 serial_priv->opened_port--; in f81534_close()
1125 if (!serial_priv->opened_port) { in f81534_close()
1126 for (i = 0; i < ARRAY_SIZE(port0->read_urbs); ++i) in f81534_close()
1127 usb_kill_urb(port0->read_urbs[i]); in f81534_close()
1130 mutex_unlock(&serial_priv->urb_mutex); in f81534_close()
1135 struct usb_serial_port *port = tty->driver_data; in f81534_get_serial_info()
1140 ss->baud_base = port_priv->baud_base; in f81534_get_serial_info()
1168 set_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty); in f81534_process_per_serial_block()
1173 dev_err(&port->dev, "%s: submit failed\n", __func__); in f81534_process_per_serial_block()
1183 dev_err(&port->dev, in f81534_process_per_serial_block()
1193 dev_warn(&port->dev, "%s: unknown token: %02x\n", __func__, in f81534_process_per_serial_block()
1205 port->icount.brk++; in f81534_process_per_serial_block()
1209 port->icount.parity++; in f81534_process_per_serial_block()
1212 port->icount.frame++; in f81534_process_per_serial_block()
1216 port->icount.overrun++; in f81534_process_per_serial_block()
1217 tty_insert_flip_char(&port->port, 0, in f81534_process_per_serial_block()
1221 schedule_work(&port_priv->lsr_work); in f81534_process_per_serial_block()
1224 if (port->sysrq) { in f81534_process_per_serial_block()
1229 tty_insert_flip_char(&port->port, data[i], tty_flag); in f81534_process_per_serial_block()
1232 tty_flip_buffer_push(&port->port); in f81534_process_per_serial_block()
1245 if (!urb->actual_length || in f81534_process_read_urb()
1246 urb->actual_length % F81534_RECEIVE_BLOCK_SIZE) { in f81534_process_read_urb()
1250 port = urb->context; in f81534_process_read_urb()
1251 serial = port->serial; in f81534_process_read_urb()
1252 buf = urb->transfer_buffer; in f81534_process_read_urb()
1255 for (i = 0; i < urb->actual_length; i += F81534_RECEIVE_BLOCK_SIZE) { in f81534_process_read_urb()
1258 dev_err(&port->dev, in f81534_process_read_urb()
1264 tty_port_num = serial_priv->tty_idx[phy_port_num]; in f81534_process_read_urb()
1265 port = serial->port[tty_port_num]; in f81534_process_read_urb()
1267 if (tty_port_initialized(&port->port)) in f81534_process_read_urb()
1274 struct usb_serial_port *port = urb->context; in f81534_write_usb_callback()
1276 switch (urb->status) { in f81534_write_usb_callback()
1279 case -ENOENT: in f81534_write_usb_callback()
1280 case -ECONNRESET: in f81534_write_usb_callback()
1281 case -ESHUTDOWN: in f81534_write_usb_callback()
1282 dev_dbg(&port->dev, "%s - urb stopped: %d\n", in f81534_write_usb_callback()
1283 __func__, urb->status); in f81534_write_usb_callback()
1285 case -EPIPE: in f81534_write_usb_callback()
1286 dev_err(&port->dev, "%s - urb stopped: %d\n", in f81534_write_usb_callback()
1287 __func__, urb->status); in f81534_write_usb_callback()
1290 dev_dbg(&port->dev, "%s - nonzero urb status: %d\n", in f81534_write_usb_callback()
1291 __func__, urb->status); in f81534_write_usb_callback()
1304 port = port_priv->port; in f81534_lsr_worker()
1308 dev_warn(&port->dev, "read LSR failed: %d\n", status); in f81534_lsr_worker()
1322 serial = port->serial; in f81534_set_port_output_pin()
1326 idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num; in f81534_set_port_output_pin()
1327 value = serial_priv->conf_data[idx]; in f81534_set_port_output_pin()
1333 idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num; in f81534_set_port_output_pin()
1334 value = serial_priv->conf_data[idx]; in f81534_set_port_output_pin()
1339 pins = &f81534_port_out_pins[port_priv->phy_num]; in f81534_set_port_output_pin()
1341 for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) { in f81534_set_port_output_pin()
1343 pins->pin[i].reg_addr, pins->pin[i].reg_mask, in f81534_set_port_output_pin()
1344 value & BIT(i) ? pins->pin[i].reg_mask : 0); in f81534_set_port_output_pin()
1349 dev_dbg(&port->dev, "Output pin (M0/M1/M2): %d\n", value); in f81534_set_port_output_pin()
1360 serial_priv = usb_get_serial_data(port->serial); in f81534_port_probe()
1361 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); in f81534_port_probe()
1363 return -ENOMEM; in f81534_port_probe()
1369 port_priv->shadow_clk = F81534_UART_EN | F81534_CLK_TX_DELAY_1BIT; in f81534_port_probe()
1370 spin_lock_init(&port_priv->msr_lock); in f81534_port_probe()
1371 mutex_init(&port_priv->mcr_mutex); in f81534_port_probe()
1372 mutex_init(&port_priv->lcr_mutex); in f81534_port_probe()
1373 INIT_WORK(&port_priv->lsr_work, f81534_lsr_worker); in f81534_port_probe()
1375 /* Assign logic-to-phy mapping */ in f81534_port_probe()
1376 ret = f81534_logic_to_phy_port(port->serial, port); in f81534_port_probe()
1380 port_priv->phy_num = ret; in f81534_port_probe()
1381 port_priv->port = port; in f81534_port_probe()
1383 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, in f81534_port_probe()
1384 port->port_number, port_priv->phy_num); in f81534_port_probe()
1387 * The F81532/534 will hang-up when enable LSR interrupt in IER and in f81534_port_probe()
1390 * bit with bulk-in data in f81534_process_per_serial_block(). in f81534_port_probe()
1397 value = serial_priv->conf_data[port_priv->phy_num]; in f81534_port_probe()
1400 port_priv->shadow_clk |= F81534_CLK_RS485_MODE | in f81534_port_probe()
1402 dev_dbg(&port->dev, "RS485 invert mode\n"); in f81534_port_probe()
1405 port_priv->shadow_clk |= F81534_CLK_RS485_MODE; in f81534_port_probe()
1406 dev_dbg(&port->dev, "RS485 mode\n"); in f81534_port_probe()
1411 dev_dbg(&port->dev, "RS232 mode\n"); in f81534_port_probe()
1422 flush_work(&port_priv->lsr_work); in f81534_port_remove()
1427 struct usb_serial_port *port = tty->driver_data; in f81534_tiocmget()
1439 mutex_lock(&port_priv->mcr_mutex); in f81534_tiocmget()
1440 mcr = port_priv->shadow_mcr; in f81534_tiocmget()
1441 mutex_unlock(&port_priv->mcr_mutex); in f81534_tiocmget()
1456 struct usb_serial_port *port = tty->driver_data; in f81534_tiocmset()
1477 bytes_out = kfifo_in_locked(&port->write_fifo, buf, count, in f81534_write()
1478 &port->lock); in f81534_write()
1482 dev_err(&port->dev, "%s: submit failed\n", __func__); in f81534_write()
1493 return test_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty); in f81534_tx_empty()
1509 mutex_lock(&serial_priv->urb_mutex); in f81534_resume()
1511 if (serial_priv->opened_port) { in f81534_resume()
1514 mutex_unlock(&serial_priv->urb_mutex); in f81534_resume()
1519 mutex_unlock(&serial_priv->urb_mutex); in f81534_resume()
1521 for (i = 0; i < serial->num_ports; i++) { in f81534_resume()
1522 port = serial->port[i]; in f81534_resume()
1523 if (!tty_port_initialized(&port->port)) in f81534_resume()
1528 dev_err(&port->dev, "%s: submit failed\n", __func__); in f81534_resume()
1534 return -EIO; in f81534_resume()