Lines Matching refs:p

352 static unsigned int hub6_serial_in(struct uart_port *p, int offset)  in hub6_serial_in()  argument
354 offset = offset << p->regshift; in hub6_serial_in()
355 outb(p->hub6 - 1 + offset, p->iobase); in hub6_serial_in()
356 return inb(p->iobase + 1); in hub6_serial_in()
359 static void hub6_serial_out(struct uart_port *p, int offset, int value) in hub6_serial_out() argument
361 offset = offset << p->regshift; in hub6_serial_out()
362 outb(p->hub6 - 1 + offset, p->iobase); in hub6_serial_out()
363 outb(value, p->iobase + 1); in hub6_serial_out()
366 static unsigned int mem_serial_in(struct uart_port *p, int offset) in mem_serial_in() argument
368 offset = offset << p->regshift; in mem_serial_in()
369 return readb(p->membase + offset); in mem_serial_in()
372 static void mem_serial_out(struct uart_port *p, int offset, int value) in mem_serial_out() argument
374 offset = offset << p->regshift; in mem_serial_out()
375 writeb(value, p->membase + offset); in mem_serial_out()
378 static void mem16_serial_out(struct uart_port *p, int offset, int value) in mem16_serial_out() argument
380 offset = offset << p->regshift; in mem16_serial_out()
381 writew(value, p->membase + offset); in mem16_serial_out()
384 static unsigned int mem16_serial_in(struct uart_port *p, int offset) in mem16_serial_in() argument
386 offset = offset << p->regshift; in mem16_serial_in()
387 return readw(p->membase + offset); in mem16_serial_in()
390 static void mem32_serial_out(struct uart_port *p, int offset, int value) in mem32_serial_out() argument
392 offset = offset << p->regshift; in mem32_serial_out()
393 writel(value, p->membase + offset); in mem32_serial_out()
396 static unsigned int mem32_serial_in(struct uart_port *p, int offset) in mem32_serial_in() argument
398 offset = offset << p->regshift; in mem32_serial_in()
399 return readl(p->membase + offset); in mem32_serial_in()
402 static void mem32be_serial_out(struct uart_port *p, int offset, int value) in mem32be_serial_out() argument
404 offset = offset << p->regshift; in mem32be_serial_out()
405 iowrite32be(value, p->membase + offset); in mem32be_serial_out()
408 static unsigned int mem32be_serial_in(struct uart_port *p, int offset) in mem32be_serial_in() argument
410 offset = offset << p->regshift; in mem32be_serial_in()
411 return ioread32be(p->membase + offset); in mem32be_serial_in()
414 static unsigned int io_serial_in(struct uart_port *p, int offset) in io_serial_in() argument
416 offset = offset << p->regshift; in io_serial_in()
417 return inb(p->iobase + offset); in io_serial_in()
420 static void io_serial_out(struct uart_port *p, int offset, int value) in io_serial_out() argument
422 offset = offset << p->regshift; in io_serial_out()
423 outb(value, p->iobase + offset); in io_serial_out()
428 static void set_io_from_upio(struct uart_port *p) in set_io_from_upio() argument
430 struct uart_8250_port *up = up_to_u8250p(p); in set_io_from_upio()
435 switch (p->iotype) { in set_io_from_upio()
437 p->serial_in = hub6_serial_in; in set_io_from_upio()
438 p->serial_out = hub6_serial_out; in set_io_from_upio()
442 p->serial_in = mem_serial_in; in set_io_from_upio()
443 p->serial_out = mem_serial_out; in set_io_from_upio()
447 p->serial_in = mem16_serial_in; in set_io_from_upio()
448 p->serial_out = mem16_serial_out; in set_io_from_upio()
452 p->serial_in = mem32_serial_in; in set_io_from_upio()
453 p->serial_out = mem32_serial_out; in set_io_from_upio()
457 p->serial_in = mem32be_serial_in; in set_io_from_upio()
458 p->serial_out = mem32be_serial_out; in set_io_from_upio()
462 p->serial_in = io_serial_in; in set_io_from_upio()
463 p->serial_out = io_serial_out; in set_io_from_upio()
467 up->cur_iotype = p->iotype; in set_io_from_upio()
468 p->handle_irq = serial8250_default_handle_irq; in set_io_from_upio()
472 serial_port_out_sync(struct uart_port *p, int offset, int value) in serial_port_out_sync() argument
474 switch (p->iotype) { in serial_port_out_sync()
480 p->serial_out(p, offset, value); in serial_port_out_sync()
481 p->serial_in(p, UART_LCR); /* safe, no side-effects */ in serial_port_out_sync()
484 p->serial_out(p, offset, value); in serial_port_out_sync()
491 static void serial8250_clear_fifos(struct uart_8250_port *p) in serial8250_clear_fifos() argument
493 if (p->capabilities & UART_CAP_FIFO) { in serial8250_clear_fifos()
494 serial_out(p, UART_FCR, UART_FCR_ENABLE_FIFO); in serial8250_clear_fifos()
495 serial_out(p, UART_FCR, UART_FCR_ENABLE_FIFO | in serial8250_clear_fifos()
497 serial_out(p, UART_FCR, 0); in serial8250_clear_fifos()
504 void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p) in serial8250_clear_and_reinit_fifos() argument
506 serial8250_clear_fifos(p); in serial8250_clear_and_reinit_fifos()
507 serial_out(p, UART_FCR, p->fcr); in serial8250_clear_and_reinit_fifos()
511 void serial8250_rpm_get(struct uart_8250_port *p) in serial8250_rpm_get() argument
513 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_get()
515 pm_runtime_get_sync(p->port.dev); in serial8250_rpm_get()
519 void serial8250_rpm_put(struct uart_8250_port *p) in serial8250_rpm_put() argument
521 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_put()
523 pm_runtime_mark_last_busy(p->port.dev); in serial8250_rpm_put()
524 pm_runtime_put_autosuspend(p->port.dev); in serial8250_rpm_put()
548 static int serial8250_em485_init(struct uart_8250_port *p) in serial8250_em485_init() argument
551 lockdep_assert_held_once(&p->port.lock); in serial8250_em485_init()
553 if (p->em485) in serial8250_em485_init()
556 p->em485 = kmalloc(sizeof(struct uart_8250_em485), GFP_ATOMIC); in serial8250_em485_init()
557 if (!p->em485) in serial8250_em485_init()
560 hrtimer_init(&p->em485->stop_tx_timer, CLOCK_MONOTONIC, in serial8250_em485_init()
562 hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC, in serial8250_em485_init()
564 p->em485->stop_tx_timer.function = &serial8250_em485_handle_stop_tx; in serial8250_em485_init()
565 p->em485->start_tx_timer.function = &serial8250_em485_handle_start_tx; in serial8250_em485_init()
566 p->em485->port = p; in serial8250_em485_init()
567 p->em485->active_timer = NULL; in serial8250_em485_init()
568 p->em485->tx_stopped = true; in serial8250_em485_init()
571 if (p->em485->tx_stopped) in serial8250_em485_init()
572 p->rs485_stop_tx(p); in serial8250_em485_init()
590 void serial8250_em485_destroy(struct uart_8250_port *p) in serial8250_em485_destroy() argument
592 if (!p->em485) in serial8250_em485_destroy()
595 hrtimer_cancel(&p->em485->start_tx_timer); in serial8250_em485_destroy()
596 hrtimer_cancel(&p->em485->stop_tx_timer); in serial8250_em485_destroy()
598 kfree(p->em485); in serial8250_em485_destroy()
599 p->em485 = NULL; in serial8250_em485_destroy()
650 void serial8250_rpm_get_tx(struct uart_8250_port *p) in serial8250_rpm_get_tx() argument
654 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_get_tx()
657 rpm_active = xchg(&p->rpm_tx_active, 1); in serial8250_rpm_get_tx()
660 pm_runtime_get_sync(p->port.dev); in serial8250_rpm_get_tx()
664 void serial8250_rpm_put_tx(struct uart_8250_port *p) in serial8250_rpm_put_tx() argument
668 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_put_tx()
671 rpm_active = xchg(&p->rpm_tx_active, 0); in serial8250_rpm_put_tx()
674 pm_runtime_mark_last_busy(p->port.dev); in serial8250_rpm_put_tx()
675 pm_runtime_put_autosuspend(p->port.dev); in serial8250_rpm_put_tx()
684 static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) in serial8250_set_sleep() argument
688 serial8250_rpm_get(p); in serial8250_set_sleep()
690 if (p->capabilities & UART_CAP_SLEEP) { in serial8250_set_sleep()
692 spin_lock_irq(&p->port.lock); in serial8250_set_sleep()
693 if (p->capabilities & UART_CAP_EFR) { in serial8250_set_sleep()
694 lcr = serial_in(p, UART_LCR); in serial8250_set_sleep()
695 efr = serial_in(p, UART_EFR); in serial8250_set_sleep()
696 serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_set_sleep()
697 serial_out(p, UART_EFR, UART_EFR_ECB); in serial8250_set_sleep()
698 serial_out(p, UART_LCR, 0); in serial8250_set_sleep()
700 serial_out(p, UART_IER, sleep ? UART_IERX_SLEEP : 0); in serial8250_set_sleep()
701 if (p->capabilities & UART_CAP_EFR) { in serial8250_set_sleep()
702 serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_set_sleep()
703 serial_out(p, UART_EFR, efr); in serial8250_set_sleep()
704 serial_out(p, UART_LCR, lcr); in serial8250_set_sleep()
706 spin_unlock_irq(&p->port.lock); in serial8250_set_sleep()
709 serial8250_rpm_put(p); in serial8250_set_sleep()
830 static unsigned int autoconfig_read_divisor_id(struct uart_8250_port *p) in autoconfig_read_divisor_id() argument
835 old_lcr = serial_in(p, UART_LCR); in autoconfig_read_divisor_id()
836 serial_out(p, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_read_divisor_id()
837 old_dl = serial_dl_read(p); in autoconfig_read_divisor_id()
838 serial_dl_write(p, 0); in autoconfig_read_divisor_id()
839 id = serial_dl_read(p); in autoconfig_read_divisor_id()
840 serial_dl_write(p, old_dl); in autoconfig_read_divisor_id()
842 serial_out(p, UART_LCR, old_lcr); in autoconfig_read_divisor_id()
1404 void serial8250_em485_stop_tx(struct uart_8250_port *p) in serial8250_em485_stop_tx() argument
1406 unsigned char mcr = serial8250_in_MCR(p); in serial8250_em485_stop_tx()
1409 lockdep_assert_held_once(&p->port.lock); in serial8250_em485_stop_tx()
1411 if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) in serial8250_em485_stop_tx()
1415 serial8250_out_MCR(p, mcr); in serial8250_em485_stop_tx()
1422 if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) { in serial8250_em485_stop_tx()
1423 serial8250_clear_and_reinit_fifos(p); in serial8250_em485_stop_tx()
1425 p->ier |= UART_IER_RLSI | UART_IER_RDI; in serial8250_em485_stop_tx()
1426 serial_port_out(&p->port, UART_IER, p->ier); in serial8250_em485_stop_tx()
1435 struct uart_8250_port *p = em485->port; in serial8250_em485_handle_stop_tx() local
1438 serial8250_rpm_get(p); in serial8250_em485_handle_stop_tx()
1439 spin_lock_irqsave(&p->port.lock, flags); in serial8250_em485_handle_stop_tx()
1441 p->rs485_stop_tx(p); in serial8250_em485_handle_stop_tx()
1445 spin_unlock_irqrestore(&p->port.lock, flags); in serial8250_em485_handle_stop_tx()
1446 serial8250_rpm_put(p); in serial8250_em485_handle_stop_tx()
1456 static void __stop_tx_rs485(struct uart_8250_port *p, u64 stop_delay) in __stop_tx_rs485() argument
1458 struct uart_8250_em485 *em485 = p->em485; in __stop_tx_rs485()
1461 lockdep_assert_held_once(&p->port.lock); in __stop_tx_rs485()
1463 stop_delay += (u64)p->port.rs485.delay_rts_after_send * NSEC_PER_MSEC; in __stop_tx_rs485()
1473 p->rs485_stop_tx(p); in __stop_tx_rs485()
1479 static inline void __stop_tx(struct uart_8250_port *p) in __stop_tx() argument
1481 struct uart_8250_em485 *em485 = p->em485; in __stop_tx()
1484 u16 lsr = serial_lsr_in(p); in __stop_tx()
1498 if (!(p->capabilities & UART_CAP_NOTEMT)) in __stop_tx()
1507 stop_delay = p->port.frame_time + DIV_ROUND_UP(p->port.frame_time, 7); in __stop_tx()
1510 __stop_tx_rs485(p, stop_delay); in __stop_tx()
1513 if (serial8250_clear_THRI(p)) in __stop_tx()
1514 serial8250_rpm_put_tx(p); in __stop_tx()
1624 struct uart_8250_port *p = em485->port; in serial8250_em485_handle_start_tx() local
1627 spin_lock_irqsave(&p->port.lock, flags); in serial8250_em485_handle_start_tx()
1629 __start_tx(&p->port); in serial8250_em485_handle_start_tx()
1632 spin_unlock_irqrestore(&p->port.lock, flags); in serial8250_em485_handle_start_tx()
2947 struct uart_8250_port *p = up_to_u8250p(port); in serial8250_do_pm() local
2949 serial8250_set_sleep(p, state != 0); in serial8250_do_pm()