Lines Matching +full:string +full:- +full:array +full:- +full:property
3 * Copyright 2009-2011 Freescale Semiconductor, Inc.
14 * 1) An early-console (udbg) driver. This provides early console output
22 * 3) A tty driver, which is used to handle user-space input and output. The
46 /* Per-byte channel private data */
62 /* Array of byte channel objects */
84 * 1. The tty layer makes two back-to-back calls to ehv_bc_tty_write()
91 if (!bc->tx_irq_enabled) { in enable_tx_interrupt()
92 enable_irq(bc->tx_irq); in enable_tx_interrupt()
93 bc->tx_irq_enabled = 1; in enable_tx_interrupt()
99 if (bc->tx_irq_enabled) { in disable_tx_interrupt()
100 disable_irq_nosync(bc->tx_irq); in disable_tx_interrupt()
101 bc->tx_irq_enabled = 0; in disable_tx_interrupt()
109 * property in the /chosen node.
121 sprop = of_get_property(np, "stdout-path", NULL); in find_console_handle()
136 * care if it's compatible with "epapr,hv-byte-channel", because that in find_console_handle()
145 pr_warning("ehv-bc: stdout node '%s' does not exist\n", sprop); in find_console_handle()
150 if (!of_device_is_compatible(np, "epapr,hv-byte-channel")) { in find_console_handle()
157 pr_err("ehv-bc: no 'interrupts' property in %s node\n", sprop); in find_console_handle()
163 * The 'hv-handle' property contains the handle for this byte channel. in find_console_handle()
165 iprop = of_get_property(np, "hv-handle", NULL); in find_console_handle()
167 pr_err("ehv-bc: no 'hv-handle' property in %s node\n", in find_console_handle()
168 np->name); in find_console_handle()
238 udbg_printf("ehv-bc: early console using byte channel handle %u\n", in udbg_init_ehv_bc()
265 count -= len; in ehv_bc_console_byte_channel_send()
273 * write a string to the console
275 * This function gets called to write a string from the kernel, typically from
296 if (j >= (EV_BYTE_CHANNEL_MAX_BYTES - 1)) { in ehv_bc_console_write()
309 * for one with ->device and then calls that method. On success, it expects
310 * the passed-in int* to contain the minor number to use.
314 *index = co->index; in ehv_bc_console_device()
337 pr_debug("ehv-bc: stdout is not a byte channel\n"); in ehv_bc_console_init()
338 return -ENODEV; in ehv_bc_console_init()
346 pr_warning("ehv-bc: udbg handle %u is not the stdout handle\n", in ehv_bc_console_init()
357 pr_info("ehv-bc: registered console driver for byte channel %u\n", in ehv_bc_console_init()
374 struct tty_struct *ttys = tty_port_tty_get(&bc->port); in ehv_bc_tty_rx_isr()
388 ev_byte_channel_poll(bc->handle, &rx_count, &tx_count); in ehv_bc_tty_rx_isr()
403 ev_byte_channel_receive(bc->handle, &len, buffer); in ehv_bc_tty_rx_isr()
415 * exit gracefully, but we drop the last 'len - ret' characters in ehv_bc_tty_rx_isr()
421 count -= len; in ehv_bc_tty_rx_isr()
445 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tx_dequeue()
447 CIRC_CNT_TO_END(bc->head, bc->tail, BUF_SIZE), in ehv_bc_tx_dequeue()
450 ret = ev_byte_channel_send(bc->handle, &len, bc->buf + bc->tail); in ehv_bc_tx_dequeue()
454 bc->tail = (bc->tail + len) & (BUF_SIZE - 1); in ehv_bc_tx_dequeue()
456 count = CIRC_CNT(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tx_dequeue()
457 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tx_dequeue()
460 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tx_dequeue()
461 if (CIRC_CNT(bc->head, bc->tail, BUF_SIZE)) in ehv_bc_tx_dequeue()
470 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tx_dequeue()
482 struct tty_struct *ttys = tty_port_tty_get(&bc->port); in ehv_bc_tty_tx_isr()
507 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_write()
513 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tty_write()
514 len = CIRC_SPACE_TO_END(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tty_write()
518 memcpy(bc->buf + bc->head, s, len); in ehv_bc_tty_write()
519 bc->head = (bc->head + len) & (BUF_SIZE - 1); in ehv_bc_tty_write()
521 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tty_write()
526 count -= len; in ehv_bc_tty_write()
537 * why we initialize bc->ttys in ehv_bc_tty_port_activate() instead.
546 struct ehv_bc_data *bc = &bcs[ttys->index]; in ehv_bc_tty_open()
548 if (!bc->dev) in ehv_bc_tty_open()
549 return -ENODEV; in ehv_bc_tty_open()
551 return tty_port_open(&bc->port, ttys, filp); in ehv_bc_tty_open()
561 struct ehv_bc_data *bc = &bcs[ttys->index]; in ehv_bc_tty_close()
563 if (bc->dev) in ehv_bc_tty_close()
564 tty_port_close(&bc->port, ttys, filp); in ehv_bc_tty_close()
576 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_write_room()
580 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tty_write_room()
581 count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tty_write_room()
582 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tty_write_room()
601 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_throttle()
603 disable_irq(bc->rx_irq); in ehv_bc_tty_throttle()
615 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_unthrottle()
620 enable_irq(bc->rx_irq); in ehv_bc_tty_unthrottle()
625 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_hangup()
628 tty_port_hangup(&bc->port); in ehv_bc_tty_hangup()
653 * why we initialize tty_struct-related variables here.
661 ttys->driver_data = bc; in ehv_bc_tty_port_activate()
663 ret = request_irq(bc->rx_irq, ehv_bc_tty_rx_isr, 0, "ehv-bc", bc); in ehv_bc_tty_port_activate()
665 dev_err(bc->dev, "could not request rx irq %u (ret=%i)\n", in ehv_bc_tty_port_activate()
666 bc->rx_irq, ret); in ehv_bc_tty_port_activate()
671 bc->tx_irq_enabled = 1; in ehv_bc_tty_port_activate()
673 ret = request_irq(bc->tx_irq, ehv_bc_tty_tx_isr, 0, "ehv-bc", bc); in ehv_bc_tty_port_activate()
675 dev_err(bc->dev, "could not request tx irq %u (ret=%i)\n", in ehv_bc_tty_port_activate()
676 bc->tx_irq, ret); in ehv_bc_tty_port_activate()
677 free_irq(bc->rx_irq, bc); in ehv_bc_tty_port_activate()
693 free_irq(bc->tx_irq, bc); in ehv_bc_tty_port_shutdown()
694 free_irq(bc->rx_irq, bc); in ehv_bc_tty_port_shutdown()
704 struct device_node *np = pdev->dev.of_node; in ehv_bc_tty_probe()
712 iprop = of_get_property(np, "hv-handle", NULL); in ehv_bc_tty_probe()
714 dev_err(&pdev->dev, "no 'hv-handle' property in %s node\n", in ehv_bc_tty_probe()
715 np->name); in ehv_bc_tty_probe()
716 return -ENODEV; in ehv_bc_tty_probe()
727 bc->handle = handle; in ehv_bc_tty_probe()
728 bc->head = 0; in ehv_bc_tty_probe()
729 bc->tail = 0; in ehv_bc_tty_probe()
730 spin_lock_init(&bc->lock); in ehv_bc_tty_probe()
732 bc->rx_irq = irq_of_parse_and_map(np, 0); in ehv_bc_tty_probe()
733 bc->tx_irq = irq_of_parse_and_map(np, 1); in ehv_bc_tty_probe()
734 if ((bc->rx_irq == NO_IRQ) || (bc->tx_irq == NO_IRQ)) { in ehv_bc_tty_probe()
735 dev_err(&pdev->dev, "no 'interrupts' property in %s node\n", in ehv_bc_tty_probe()
736 np->name); in ehv_bc_tty_probe()
737 ret = -ENODEV; in ehv_bc_tty_probe()
741 bc->dev = tty_register_device(ehv_bc_driver, i, &pdev->dev); in ehv_bc_tty_probe()
742 if (IS_ERR(bc->dev)) { in ehv_bc_tty_probe()
743 ret = PTR_ERR(bc->dev); in ehv_bc_tty_probe()
744 dev_err(&pdev->dev, "could not register tty (ret=%i)\n", ret); in ehv_bc_tty_probe()
748 tty_port_init(&bc->port); in ehv_bc_tty_probe()
749 bc->port.ops = &ehv_bc_tty_port_ops; in ehv_bc_tty_probe()
751 dev_set_drvdata(&pdev->dev, bc); in ehv_bc_tty_probe()
753 dev_info(&pdev->dev, "registered /dev/%s%u for byte channel %u\n", in ehv_bc_tty_probe()
754 ehv_bc_driver->name, i, bc->handle); in ehv_bc_tty_probe()
759 irq_dispose_mapping(bc->tx_irq); in ehv_bc_tty_probe()
760 irq_dispose_mapping(bc->rx_irq); in ehv_bc_tty_probe()
768 struct ehv_bc_data *bc = dev_get_drvdata(&pdev->dev); in ehv_bc_tty_remove()
770 tty_unregister_device(ehv_bc_driver, bc - bcs); in ehv_bc_tty_remove()
772 irq_dispose_mapping(bc->tx_irq); in ehv_bc_tty_remove()
773 irq_dispose_mapping(bc->rx_irq); in ehv_bc_tty_remove()
779 { .compatible = "epapr,hv-byte-channel" },
786 .name = "ehv-bc",
794 * ehv_bc_init - ePAPR hypervisor byte channel driver initialization
807 for_each_compatible_node(np, NULL, "epapr,hv-byte-channel") in ehv_bc_init()
811 return -ENODEV; in ehv_bc_init()
813 /* The array index of an element in bcs[] is the same as the tty index in ehv_bc_init()
815 * array, then you can use pointer math (e.g. "bc - bcs") to get its in ehv_bc_init()
820 return -ENOMEM; in ehv_bc_init()
824 ret = -ENOMEM; in ehv_bc_init()
828 ehv_bc_driver->owner = THIS_MODULE; in ehv_bc_init()
829 ehv_bc_driver->driver_name = "ehv-bc"; in ehv_bc_init()
830 ehv_bc_driver->name = ehv_bc_console.name; in ehv_bc_init()
831 ehv_bc_driver->type = TTY_DRIVER_TYPE_CONSOLE; in ehv_bc_init()
832 ehv_bc_driver->subtype = SYSTEM_TYPE_CONSOLE; in ehv_bc_init()
833 ehv_bc_driver->init_termios = tty_std_termios; in ehv_bc_init()
834 ehv_bc_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in ehv_bc_init()
839 pr_err("ehv-bc: could not register tty driver (ret=%i)\n", ret); in ehv_bc_init()
845 pr_err("ehv-bc: could not register platform driver (ret=%i)\n", in ehv_bc_init()
865 * ehv_bc_exit - ePAPR hypervisor byte channel driver termination