Lines Matching +full:port +full:- +full:base

1 // SPDX-License-Identifier: GPL-2.0
19 #include <linux/dma-mapping.h>
37 struct tty_port port; member
39 void __iomem *base; member
57 void __iomem *base = qtty->base; in do_rw_io() local
59 spin_lock_irqsave(&qtty->lock, irq_flags); in do_rw_io()
60 gf_write_ptr((void *)address, base + GOLDFISH_TTY_REG_DATA_PTR, in do_rw_io()
61 base + GOLDFISH_TTY_REG_DATA_PTR_HIGH); in do_rw_io()
62 gf_iowrite32(count, base + GOLDFISH_TTY_REG_DATA_LEN); in do_rw_io()
66 base + GOLDFISH_TTY_REG_CMD); in do_rw_io()
69 base + GOLDFISH_TTY_REG_CMD); in do_rw_io()
71 spin_unlock_irqrestore(&qtty->lock, irq_flags); in do_rw_io()
81 if (qtty->version > 0) { in goldfish_tty_rw()
92 unsigned long avail = next - addr; in goldfish_tty_rw()
98 dma_handle = dma_map_single(qtty->dev, (void *)addr, in goldfish_tty_rw()
101 if (dma_mapping_error(qtty->dev, dma_handle)) { in goldfish_tty_rw()
102 dev_err(qtty->dev, "tty: DMA mapping error.\n"); in goldfish_tty_rw()
111 dma_unmap_single(qtty->dev, dma_handle, avail, dma_dir); in goldfish_tty_rw()
134 void __iomem *base = qtty->base; in goldfish_tty_interrupt() local
138 count = gf_ioread32(base + GOLDFISH_TTY_REG_BYTES_READY); in goldfish_tty_interrupt()
142 count = tty_prepare_flip_string(&qtty->port, &buf, count); in goldfish_tty_interrupt()
146 tty_flip_buffer_push(&qtty->port); in goldfish_tty_interrupt()
150 static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) in goldfish_tty_activate() argument
152 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, in goldfish_tty_activate()
153 port); in goldfish_tty_activate()
154 gf_iowrite32(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_REG_CMD); in goldfish_tty_activate()
158 static void goldfish_tty_shutdown(struct tty_port *port) in goldfish_tty_shutdown() argument
160 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, in goldfish_tty_shutdown()
161 port); in goldfish_tty_shutdown()
162 gf_iowrite32(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_REG_CMD); in goldfish_tty_shutdown()
167 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; in goldfish_tty_open()
168 return tty_port_open(&qtty->port, tty, filp); in goldfish_tty_open()
173 tty_port_close(tty->port, tty, filp); in goldfish_tty_close()
178 tty_port_hangup(tty->port); in goldfish_tty_hangup()
184 goldfish_tty_do_write(tty->index, buf, count); in goldfish_tty_write()
195 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; in goldfish_tty_chars_in_buffer()
196 void __iomem *base = qtty->base; in goldfish_tty_chars_in_buffer() local
197 return gf_ioread32(base + GOLDFISH_TTY_REG_BYTES_READY); in goldfish_tty_chars_in_buffer()
203 goldfish_tty_do_write(co->index, b, count); in goldfish_tty_console_write()
209 *index = c->index; in goldfish_tty_console_device()
215 if ((unsigned)co->index >= goldfish_tty_line_count) in goldfish_tty_console_setup()
216 return -ENODEV; in goldfish_tty_console_setup()
217 if (!goldfish_ttys[co->index].base) in goldfish_tty_console_setup()
218 return -ENODEV; in goldfish_tty_console_setup()
245 ret = -ENOMEM; in goldfish_tty_create_driver()
255 tty->driver_name = "goldfish"; in goldfish_tty_create_driver()
256 tty->name = "ttyGF"; in goldfish_tty_create_driver()
257 tty->type = TTY_DRIVER_TYPE_SERIAL; in goldfish_tty_create_driver()
258 tty->subtype = SERIAL_TYPE_NORMAL; in goldfish_tty_create_driver()
259 tty->init_termios = tty_std_termios; in goldfish_tty_create_driver()
289 int ret = -ENODEV; in goldfish_tty_probe()
292 void __iomem *base; in goldfish_tty_probe() local
299 return -ENOMEM; in goldfish_tty_probe()
302 base = ioremap(r->start, 0x1000); in goldfish_tty_probe()
303 if (!base) { in goldfish_tty_probe()
304 pr_err("goldfish_tty: Unable to ioremap base!\n"); in goldfish_tty_probe()
305 return -ENOMEM; in goldfish_tty_probe()
316 if (pdev->id == PLATFORM_DEVID_NONE) in goldfish_tty_probe()
319 line = pdev->id; in goldfish_tty_probe()
324 ret = -ENOMEM; in goldfish_tty_probe()
336 spin_lock_init(&qtty->lock); in goldfish_tty_probe()
337 tty_port_init(&qtty->port); in goldfish_tty_probe()
338 qtty->port.ops = &goldfish_port_ops; in goldfish_tty_probe()
339 qtty->base = base; in goldfish_tty_probe()
340 qtty->irq = irq; in goldfish_tty_probe()
341 qtty->dev = &pdev->dev; in goldfish_tty_probe()
350 qtty->version = gf_ioread32(base + GOLDFISH_TTY_REG_VERSION); in goldfish_tty_probe()
356 if (qtty->version > 0) { in goldfish_tty_probe()
358 * Initialize dma_mask to 32-bits. in goldfish_tty_probe()
360 if (!pdev->dev.dma_mask) in goldfish_tty_probe()
361 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; in goldfish_tty_probe()
362 ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in goldfish_tty_probe()
364 dev_err(&pdev->dev, "No suitable DMA available.\n"); in goldfish_tty_probe()
369 gf_iowrite32(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_REG_CMD); in goldfish_tty_probe()
378 ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, in goldfish_tty_probe()
379 line, &pdev->dev); in goldfish_tty_probe()
385 strcpy(qtty->console.name, "ttyGF"); in goldfish_tty_probe()
386 qtty->console.write = goldfish_tty_console_write; in goldfish_tty_probe()
387 qtty->console.device = goldfish_tty_console_device; in goldfish_tty_probe()
388 qtty->console.setup = goldfish_tty_console_setup; in goldfish_tty_probe()
389 qtty->console.flags = CON_PRINTBUFFER; in goldfish_tty_probe()
390 qtty->console.index = line; in goldfish_tty_probe()
391 register_console(&qtty->console); in goldfish_tty_probe()
400 tty_port_destroy(&qtty->port); in goldfish_tty_probe()
401 goldfish_tty_current_line_count--; in goldfish_tty_probe()
407 iounmap(base); in goldfish_tty_probe()
417 unregister_console(&qtty->console); in goldfish_tty_remove()
418 tty_unregister_device(goldfish_tty_driver, qtty->console.index); in goldfish_tty_remove()
419 iounmap(qtty->base); in goldfish_tty_remove()
420 qtty->base = NULL; in goldfish_tty_remove()
421 free_irq(qtty->irq, qtty); in goldfish_tty_remove()
422 tty_port_destroy(&qtty->port); in goldfish_tty_remove()
423 goldfish_tty_current_line_count--; in goldfish_tty_remove()
431 static void gf_early_console_putchar(struct uart_port *port, unsigned char ch) in gf_early_console_putchar() argument
433 gf_iowrite32(ch, port->membase); in gf_early_console_putchar()
438 struct earlycon_device *dev = con->data; in gf_early_write()
440 uart_console_write(&dev->port, s, n, gf_early_console_putchar); in gf_early_write()
446 if (!device->port.membase) in gf_earlycon_setup()
447 return -ENODEV; in gf_earlycon_setup()
449 device->con->write = gf_early_write; in gf_earlycon_setup()
453 OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup);
457 { .compatible = "google,goldfish-tty", },