Lines Matching refs:port

48 static void esp32s3_acm_write(struct uart_port *port, unsigned long reg, u32 v)
50 writel(v, port->membase + reg);
53 static u32 esp32s3_acm_read(struct uart_port *port, unsigned long reg)
55 return readl(port->membase + reg);
58 static u32 esp32s3_acm_tx_fifo_free(struct uart_port *port)
60 u32 status = esp32s3_acm_read(port, USB_SERIAL_JTAG_EP1_CONF_REG);
65 static u32 esp32s3_acm_tx_fifo_cnt(struct uart_port *port)
67 u32 status = esp32s3_acm_read(port, USB_SERIAL_JTAG_IN_EP1_ST_REG);
72 static u32 esp32s3_acm_rx_fifo_cnt(struct uart_port *port)
74 u32 status = esp32s3_acm_read(port, USB_SERIAL_JTAG_OUT_EP1_ST_REG);
80 static unsigned int esp32s3_acm_tx_empty(struct uart_port *port)
82 return esp32s3_acm_tx_fifo_cnt(port) == 0 ? TIOCSER_TEMT : 0;
85 static void esp32s3_acm_set_mctrl(struct uart_port *port, unsigned int mctrl)
89 static unsigned int esp32s3_acm_get_mctrl(struct uart_port *port)
94 static void esp32s3_acm_stop_tx(struct uart_port *port)
98 int_ena = esp32s3_acm_read(port, USB_SERIAL_JTAG_INT_ENA_REG);
100 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_ENA_REG, int_ena);
103 static void esp32s3_acm_rxint(struct uart_port *port)
105 struct tty_port *tty_port = &port->state->port;
106 u32 rx_fifo_cnt = esp32s3_acm_rx_fifo_cnt(port);
113 spin_lock_irqsave(&port->lock, flags);
116 u32 rx = esp32s3_acm_read(port, USB_SERIAL_JTAG_EP1_REG);
118 ++port->icount.rx;
121 spin_unlock_irqrestore(&port->lock, flags);
126 static void esp32s3_acm_push(struct uart_port *port)
128 if (esp32s3_acm_tx_fifo_free(port))
129 esp32s3_acm_write(port, USB_SERIAL_JTAG_EP1_CONF_REG,
133 static void esp32s3_acm_put_char(struct uart_port *port, u8 c)
135 esp32s3_acm_write(port, USB_SERIAL_JTAG_EP1_REG, c);
138 static void esp32s3_acm_put_char_sync(struct uart_port *port, u8 c)
142 while (!esp32s3_acm_tx_fifo_free(port)) {
144 dev_warn(port->dev, "timeout waiting for TX FIFO\n");
149 esp32s3_acm_put_char(port, c);
150 esp32s3_acm_push(port);
153 static void esp32s3_acm_transmit_buffer(struct uart_port *port)
159 if (!esp32s3_acm_tx_fifo_free(port))
162 tx_fifo_used = esp32s3_acm_tx_fifo_cnt(port);
163 pending = uart_port_tx_limited(port, ch,
165 true, esp32s3_acm_put_char(port, ch),
170 int_ena = esp32s3_acm_read(port, USB_SERIAL_JTAG_INT_ENA_REG);
172 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_ENA_REG, int_ena);
174 esp32s3_acm_push(port);
177 static void esp32s3_acm_txint(struct uart_port *port)
179 esp32s3_acm_transmit_buffer(port);
184 struct uart_port *port = dev_id;
187 status = esp32s3_acm_read(port, USB_SERIAL_JTAG_INT_ST_REG);
188 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_CLR_REG, status);
191 esp32s3_acm_rxint(port);
193 esp32s3_acm_txint(port);
198 static void esp32s3_acm_start_tx(struct uart_port *port)
200 esp32s3_acm_transmit_buffer(port);
203 static void esp32s3_acm_stop_rx(struct uart_port *port)
207 int_ena = esp32s3_acm_read(port, USB_SERIAL_JTAG_INT_ENA_REG);
209 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_ENA_REG, int_ena);
212 static int esp32s3_acm_startup(struct uart_port *port)
216 ret = request_irq(port->irq, esp32s3_acm_int, 0, DRIVER_NAME, port);
219 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_ENA_REG,
225 static void esp32s3_acm_shutdown(struct uart_port *port)
227 esp32s3_acm_write(port, USB_SERIAL_JTAG_INT_ENA_REG, 0);
228 free_irq(port->irq, port);
231 static void esp32s3_acm_set_termios(struct uart_port *port,
237 static const char *esp32s3_acm_type(struct uart_port *port)
242 /* configure/auto-configure the port */
243 static void esp32s3_acm_config_port(struct uart_port *port, int flags)
246 port->type = PORT_GENERIC;
250 static void esp32s3_acm_poll_put_char(struct uart_port *port, unsigned char c)
252 esp32s3_acm_put_char_sync(port, c);
255 static int esp32s3_acm_poll_get_char(struct uart_port *port)
257 if (esp32s3_acm_rx_fifo_cnt(port))
258 return esp32s3_acm_read(port, USB_SERIAL_JTAG_EP1_REG);
282 static void esp32s3_acm_string_write(struct uart_port *port, const char *s,
285 uart_console_write(port, s, count, esp32s3_acm_put_char_sync);
291 struct uart_port *port = esp32s3_acm_ports[co->index];
295 if (port->sysrq)
298 locked = spin_trylock_irqsave(&port->lock, flags);
300 spin_lock_irqsave(&port->lock, flags);
302 esp32s3_acm_string_write(port, s, count);
305 spin_unlock_irqrestore(&port->lock, flags);
323 uart_console_write(&dev->port, s, n, esp32s3_acm_put_char_sync);
333 int c = esp32s3_acm_poll_get_char(&dev->port);
346 if (!device->port.membase)
370 struct uart_port *port;
374 port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
375 if (!port)
389 port->line = ret;
395 port->mapbase = res->start;
396 port->membase = devm_ioremap_resource(&pdev->dev, res);
397 if (IS_ERR(port->membase))
398 return PTR_ERR(port->membase);
400 port->dev = &pdev->dev;
401 port->type = PORT_GENERIC;
402 port->iotype = UPIO_MEM;
403 port->irq = platform_get_irq(pdev, 0);
404 port->ops = &esp32s3_acm_pops;
405 port->flags = UPF_BOOT_AUTOCONF;
406 port->has_sysrq = 1;
407 port->fifosize = ESP32S3_ACM_TX_FIFO_SIZE;
409 esp32s3_acm_ports[port->line] = port;
411 platform_set_drvdata(pdev, port);
413 return uart_add_one_port(&esp32s3_acm_reg, port);
418 struct uart_port *port = platform_get_drvdata(pdev);
420 uart_remove_one_port(&esp32s3_acm_reg, port);