Ignore:
Timestamp:
Mar 9, 2017, 12:23:54 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
dc95663e
Parents:
ce5bcc87
Message:

bsp/tms570: Support printk() early

Allow use of printk() early in the initalization and without a console
driver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/tms570/console/tms570-sci.c

    rce5bcc87 r5ca634e9  
    5959};
    6060
     61void tms570_sci_initialize(tms570_sci_context *ctx)
     62{
     63  uint32_t rx_pin = 1 << 1;
     64  uint32_t tx_pin = 1 << 2;
     65
     66  /* Resec SCI peripheral */
     67  ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 0;
     68  ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 1;
     69
     70  /* Clear all interrupt sources */
     71  ctx->regs->CLEARINT = 0xffffffff;
     72
     73  /* Map all interrupts to SCI INT0 line */
     74  ctx->regs->CLEARINTLVL = 0xffffffff;
     75
     76  ctx->regs->GCR1 = TMS570_SCI_GCR1_TXENA * 0 |
     77                    TMS570_SCI_GCR1_RXENA * 0 |
     78                    TMS570_SCI_GCR1_CONT * 0 | /* continue operation when debugged */
     79                    TMS570_SCI_GCR1_LOOP_BACK * 0 |
     80                    TMS570_SCI_GCR1_POWERDOWN * 0 |
     81                    TMS570_SCI_GCR1_SLEEP * 0 |
     82                    TMS570_SCI_GCR1_SWnRST * 0 | /* reset state */
     83                    TMS570_SCI_GCR1_CLOCK * 1 | /* internal clock */
     84                    TMS570_SCI_GCR1_TIMING_MODE * 1 |
     85                    TMS570_SCI_GCR1_COMM_MODE * 0;
     86
     87  /* Setup connection of SCI peripheral Rx and Tx  pins */
     88  ctx->regs->PIO0 = rx_pin * 1 | tx_pin * 1; /* Rx and Tx pins are not GPIO */
     89  ctx->regs->PIO3 = rx_pin * 0 | tx_pin * 0; /* Default output low  */
     90  ctx->regs->PIO1 = rx_pin * 0 | tx_pin * 0; /* Input when not used by SCI */
     91  ctx->regs->PIO6 = rx_pin * 0 | tx_pin * 0; /* No open drain */
     92  ctx->regs->PIO7 = rx_pin * 0 | tx_pin * 0; /* Pull-up/down enabled */
     93  ctx->regs->PIO8 = rx_pin * 1 | tx_pin * 1; /* Select pull-up */
     94
     95  /* Bring device out of software reset */
     96  ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST;
     97}
     98
    6199/**
    62100 * @brief Serial drivers init function
     
    96134  ) {
    97135    tms570_sci_context *ctx = &driver_context_table[minor];
    98     uint32_t rx_pin = 1 << 1;
    99     uint32_t tx_pin = 1 << 2;
    100 
    101     /* Resec SCI peripheral */
    102     ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 0;
    103     ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 1;
    104 
    105     /* Clear all interrupt sources */
    106     ctx->regs->CLEARINT = 0xffffffff;
    107 
    108     /* Map all interrupts to SCI INT0 line */
    109     ctx->regs->CLEARINTLVL = 0xffffffff;
    110 
    111     ctx->regs->GCR1 = TMS570_SCI_GCR1_TXENA * 0 |
    112                       TMS570_SCI_GCR1_RXENA * 0 |
    113                       TMS570_SCI_GCR1_CONT * 0 | /* continue operation when debugged */
    114                       TMS570_SCI_GCR1_LOOP_BACK * 0 |
    115                       TMS570_SCI_GCR1_POWERDOWN * 0 |
    116                       TMS570_SCI_GCR1_SLEEP * 0 |
    117                       TMS570_SCI_GCR1_SWnRST * 0 | /* reset state */
    118                       TMS570_SCI_GCR1_CLOCK * 1 | /* internal clock */
    119                       TMS570_SCI_GCR1_TIMING_MODE * 1 |
    120                       TMS570_SCI_GCR1_COMM_MODE * 0;
    121 
    122     /* Setup connection of SCI peripheral Rx and Tx  pins */
    123     ctx->regs->PIO0 = rx_pin * 1 | tx_pin * 1; /* Rx and Tx pins are not GPIO */
    124     ctx->regs->PIO3 = rx_pin * 0 | tx_pin * 0; /* Default output low  */
    125     ctx->regs->PIO1 = rx_pin * 0 | tx_pin * 0; /* Input when not used by SCI */
    126     ctx->regs->PIO6 = rx_pin * 0 | tx_pin * 0; /* No open drain */
    127     ctx->regs->PIO7 = rx_pin * 0 | tx_pin * 0; /* Pull-up/down enabled */
    128     ctx->regs->PIO8 = rx_pin * 1 | tx_pin * 1; /* Select pull-up */
    129 
    130     /* Bring device out of software reset */
    131     ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST;
     136
     137    tms570_sci_initialize(ctx);
    132138
    133139    /*
     
    237243 * @retval true peripheral setting is changed
    238244 */
    239 static bool tms570_sci_set_attributes(
     245bool tms570_sci_set_attributes(
    240246  rtems_termios_device_context *base,
    241247  const struct termios *t
Note: See TracChangeset for help on using the changeset viewer.