Lines Matching refs:bc
86 static void enable_tx_interrupt(struct ehv_bc_data *bc) in enable_tx_interrupt() argument
88 if (!bc->tx_irq_enabled) { in enable_tx_interrupt()
89 enable_irq(bc->tx_irq); in enable_tx_interrupt()
90 bc->tx_irq_enabled = 1; in enable_tx_interrupt()
94 static void disable_tx_interrupt(struct ehv_bc_data *bc) in disable_tx_interrupt() argument
96 if (bc->tx_irq_enabled) { in disable_tx_interrupt()
97 disable_irq_nosync(bc->tx_irq); in disable_tx_interrupt()
98 bc->tx_irq_enabled = 0; in disable_tx_interrupt()
349 struct ehv_bc_data *bc = data; in ehv_bc_tty_rx_isr() local
359 ev_byte_channel_poll(bc->handle, &rx_count, &tx_count); in ehv_bc_tty_rx_isr()
360 count = tty_buffer_request_room(&bc->port, rx_count); in ehv_bc_tty_rx_isr()
374 ev_byte_channel_receive(bc->handle, &len, buffer); in ehv_bc_tty_rx_isr()
381 ret = tty_insert_flip_string(&bc->port, buffer, len); in ehv_bc_tty_rx_isr()
396 tty_flip_buffer_push(&bc->port); in ehv_bc_tty_rx_isr()
407 static void ehv_bc_tx_dequeue(struct ehv_bc_data *bc) in ehv_bc_tx_dequeue() argument
414 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tx_dequeue()
416 CIRC_CNT_TO_END(bc->head, bc->tail, BUF_SIZE), in ehv_bc_tx_dequeue()
419 ret = local_ev_byte_channel_send(bc->handle, &len, bc->buf + bc->tail); in ehv_bc_tx_dequeue()
423 bc->tail = (bc->tail + len) & (BUF_SIZE - 1); in ehv_bc_tx_dequeue()
425 count = CIRC_CNT(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tx_dequeue()
426 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tx_dequeue()
429 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tx_dequeue()
430 if (CIRC_CNT(bc->head, bc->tail, BUF_SIZE)) in ehv_bc_tx_dequeue()
436 enable_tx_interrupt(bc); in ehv_bc_tx_dequeue()
438 disable_tx_interrupt(bc); in ehv_bc_tx_dequeue()
439 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tx_dequeue()
450 struct ehv_bc_data *bc = data; in ehv_bc_tty_tx_isr() local
452 ehv_bc_tx_dequeue(bc); in ehv_bc_tty_tx_isr()
453 tty_port_tty_wakeup(&bc->port); in ehv_bc_tty_tx_isr()
472 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_write() local
478 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tty_write()
479 len = CIRC_SPACE_TO_END(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tty_write()
483 memcpy(bc->buf + bc->head, s, len); in ehv_bc_tty_write()
484 bc->head = (bc->head + len) & (BUF_SIZE - 1); in ehv_bc_tty_write()
486 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tty_write()
495 ehv_bc_tx_dequeue(bc); in ehv_bc_tty_write()
511 struct ehv_bc_data *bc = &bcs[ttys->index]; in ehv_bc_tty_open() local
513 if (!bc->dev) in ehv_bc_tty_open()
516 return tty_port_open(&bc->port, ttys, filp); in ehv_bc_tty_open()
526 struct ehv_bc_data *bc = &bcs[ttys->index]; in ehv_bc_tty_close() local
528 if (bc->dev) in ehv_bc_tty_close()
529 tty_port_close(&bc->port, ttys, filp); in ehv_bc_tty_close()
541 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_write_room() local
545 spin_lock_irqsave(&bc->lock, flags); in ehv_bc_tty_write_room()
546 count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE); in ehv_bc_tty_write_room()
547 spin_unlock_irqrestore(&bc->lock, flags); in ehv_bc_tty_write_room()
566 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_throttle() local
568 disable_irq(bc->rx_irq); in ehv_bc_tty_throttle()
580 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_unthrottle() local
585 enable_irq(bc->rx_irq); in ehv_bc_tty_unthrottle()
590 struct ehv_bc_data *bc = ttys->driver_data; in ehv_bc_tty_hangup() local
592 ehv_bc_tx_dequeue(bc); in ehv_bc_tty_hangup()
593 tty_port_hangup(&bc->port); in ehv_bc_tty_hangup()
623 struct ehv_bc_data *bc = container_of(port, struct ehv_bc_data, port); in ehv_bc_tty_port_activate() local
626 ttys->driver_data = bc; in ehv_bc_tty_port_activate()
628 ret = request_irq(bc->rx_irq, ehv_bc_tty_rx_isr, 0, "ehv-bc", bc); in ehv_bc_tty_port_activate()
630 dev_err(bc->dev, "could not request rx irq %u (ret=%i)\n", in ehv_bc_tty_port_activate()
631 bc->rx_irq, ret); in ehv_bc_tty_port_activate()
636 bc->tx_irq_enabled = 1; in ehv_bc_tty_port_activate()
638 ret = request_irq(bc->tx_irq, ehv_bc_tty_tx_isr, 0, "ehv-bc", bc); in ehv_bc_tty_port_activate()
640 dev_err(bc->dev, "could not request tx irq %u (ret=%i)\n", in ehv_bc_tty_port_activate()
641 bc->tx_irq, ret); in ehv_bc_tty_port_activate()
642 free_irq(bc->rx_irq, bc); in ehv_bc_tty_port_activate()
649 disable_tx_interrupt(bc); in ehv_bc_tty_port_activate()
656 struct ehv_bc_data *bc = container_of(port, struct ehv_bc_data, port); in ehv_bc_tty_port_shutdown() local
658 free_irq(bc->tx_irq, bc); in ehv_bc_tty_port_shutdown()
659 free_irq(bc->rx_irq, bc); in ehv_bc_tty_port_shutdown()
670 struct ehv_bc_data *bc; in ehv_bc_tty_probe() local
690 bc = &bcs[i]; in ehv_bc_tty_probe()
692 bc->handle = handle; in ehv_bc_tty_probe()
693 bc->head = 0; in ehv_bc_tty_probe()
694 bc->tail = 0; in ehv_bc_tty_probe()
695 spin_lock_init(&bc->lock); in ehv_bc_tty_probe()
697 bc->rx_irq = irq_of_parse_and_map(np, 0); in ehv_bc_tty_probe()
698 bc->tx_irq = irq_of_parse_and_map(np, 1); in ehv_bc_tty_probe()
699 if ((bc->rx_irq == NO_IRQ) || (bc->tx_irq == NO_IRQ)) { in ehv_bc_tty_probe()
706 tty_port_init(&bc->port); in ehv_bc_tty_probe()
707 bc->port.ops = &ehv_bc_tty_port_ops; in ehv_bc_tty_probe()
709 bc->dev = tty_port_register_device(&bc->port, ehv_bc_driver, i, in ehv_bc_tty_probe()
711 if (IS_ERR(bc->dev)) { in ehv_bc_tty_probe()
712 ret = PTR_ERR(bc->dev); in ehv_bc_tty_probe()
717 dev_set_drvdata(&pdev->dev, bc); in ehv_bc_tty_probe()
720 ehv_bc_driver->name, i, bc->handle); in ehv_bc_tty_probe()
725 tty_port_destroy(&bc->port); in ehv_bc_tty_probe()
726 irq_dispose_mapping(bc->tx_irq); in ehv_bc_tty_probe()
727 irq_dispose_mapping(bc->rx_irq); in ehv_bc_tty_probe()
729 memset(bc, 0, sizeof(struct ehv_bc_data)); in ehv_bc_tty_probe()