Changeset 67015b6 in rtems


Ignore:
Timestamp:
Oct 18, 2017, 5:18:57 AM (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6087f33e
Parents:
37eb717
git-author:
Sebastian Huber <sebastian.huber@…> (10/18/17 05:18:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/18/17 05:21:54)
Message:

dev/serial: Lazy update of NS16550 settings

Updates of the line control and baud divisor while transfers are in
progress may lead to unpredictable behaviour on some chips. Perform the
updates only if necessary.

Close #3198.

Location:
c/src/libchip/serial
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/serial/ns16550-context.c

    r37eb717 r67015b6  
    149149
    150150  ulBaudDivisor = NS16550_GetBaudDivisor(ctx, ctx->initial_baud);
     151  ctx->baud_divisor = ulBaudDivisor;
    151152  ucDataByte = SP_LINE_DLAB;
    152153  (*setReg)(pNS16550, NS16550_LINE_CONTROL, ucDataByte);
     
    162163  /* with one stop bit and no parity checking. */
    163164  ucDataByte = EIGHT_BITS;
     165  ctx->line_control = ucDataByte;
    164166  (*setReg)(pNS16550, NS16550_LINE_CONTROL, ucDataByte);
    165167
     
    586588  uint32_t                baud_requested;
    587589  ns16550_set_reg         setReg;
    588   rtems_interrupt_lock_context lock_context;
    589590
    590591  pNS16550 = ctx->port;
     
    643644   */
    644645
    645   rtems_termios_device_lock_acquire(base, &lock_context);
     646  if (ulBaudDivisor != ctx->baud_divisor || ucLineControl != ctx->line_control) {
     647    rtems_interrupt_lock_context lock_context;
     648
     649    ctx->baud_divisor = ulBaudDivisor;
     650    ctx->line_control = ucLineControl;
     651
     652    rtems_termios_device_lock_acquire(base, &lock_context);
    646653
    647654    /*
     
    662669    (*setReg)(pNS16550, NS16550_LINE_CONTROL, ucLineControl );
    663670
    664   rtems_termios_device_lock_release(base, &lock_context);
     671    rtems_termios_device_lock_release(base, &lock_context);
     672  }
    665673
    666674  return true;
  • c/src/libchip/serial/ns16550.h

    r37eb717 r67015b6  
    7171  bool has_fractional_divider_register;
    7272  uint8_t modem_control;
     73  uint8_t line_control;
     74  uint32_t baud_divisor;
    7375  size_t out_total;
    7476  size_t out_remaining;
Note: See TracChangeset for help on using the changeset viewer.