Changeset 362cf319 in rtems for bsps/arm/raspberrypi/console


Ignore:
Timestamp:
01/04/20 19:50:46 (4 years ago)
Author:
G S Niteesh <gsnb.gn@…>
Branches:
5, master
Children:
5e7b3c65
Parents:
eca25ef
git-author:
G S Niteesh <gsnb.gn@…> (01/04/20 19:50:46)
git-committer:
Christian Mauderer <christian.mauderer@…> (01/07/20 17:21:16)
Message:

bsp/raspberrypi: Updated the console API.

Replaces the legacy termios API with new termios API (#3034)
Replaces the custom PL011 serial driver with RTEMS arm-pl011.
Update #3034

Location:
bsps/arm/raspberrypi/console
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/raspberrypi/console/console-config.c

    reca25ef r362cf319  
    2020
    2121#include <rtems/bspIo.h>
     22#include <rtems/console.h>
     23#include <rtems/sysinit.h>
    2224
    2325#include <libchip/serial.h>
     26#include <libfdt.h>
    2427
    2528#include <bspopts.h>
    26 #include <bsp/irq.h>
    2729#include <bsp/usart.h>
    2830#include <bsp/raspberrypi.h>
    2931#include <bsp/fbcons.h>
     32#include <bsp.h>
     33#include <bsp/arm-pl011.h>
     34#include <bsp/console-termios.h>
     35#include <bsp/fdt.h>
     36#include <bsp/fatal.h>
    3037
    31 console_tbl Console_Configuration_Ports [] = {
    32     {
    33       .sDeviceName = "/dev/ttyS0",
    34       .deviceType = SERIAL_CUSTOM,
    35       .pDeviceFns = &bcm2835_usart_fns,
    36       .deviceProbe = NULL,
    37       .pDeviceFlow = NULL,
    38       .ulCtrlPort1 = BCM2835_UART0_BASE,
    39       .ulCtrlPort2 = 0,
    40       .ulClock = USART0_DEFAULT_BAUD,
    41       .ulIntVector = BCM2835_IRQ_ID_UART
    42     },
    43     {
    44       .sDeviceName ="/dev/fbcons",
    45       .deviceType = SERIAL_CUSTOM,
    46       .pDeviceFns = &fbcons_fns,
    47       .deviceProbe = fbcons_probe,
    48       .pDeviceFlow = NULL,
    49     },
    50 };
    5138
    52 #define PORT_COUNT \
    53   (sizeof(Console_Configuration_Ports) \
    54     / sizeof(Console_Configuration_Ports [0]))
     39#define UART0     "/dev/ttyS0"
     40#define FBCONS    "/dev/fbcons"
    5541
    56 unsigned long Console_Configuration_Count = PORT_COUNT;
     42arm_pl011_context pl011_context;
     43
     44rpi_fb_context fb_context;
     45
     46static void output_char_serial(char c)
     47{
     48  arm_pl011_write_polled(&pl011_context.base, c);
     49}
     50
     51void output_char_fb(char c)
     52{
     53  fbcons_write_polled(&fb_context.base, c);
     54}
     55
     56static void init_ctx_arm_pl011(
     57  const void *fdt,
     58  int node
     59)
     60{
     61  arm_pl011_context *ctx = &pl011_context;
     62  rtems_termios_device_context_initialize(&ctx->base, "UART");
     63  ctx->regs = raspberrypi_get_reg_of_node(fdt, node);
     64}
     65
     66static void register_fb( void )
     67{
     68  if (fbcons_probe(&fb_context.base) == true) {
     69    rtems_termios_device_install(
     70      FBCONS,
     71      &fbcons_fns,
     72      NULL,
     73      &fb_context.base);
     74  }
     75}
     76
     77static void console_select( void )
     78{
     79  const char *opt;
     80
     81  opt = rpi_cmdline_get_arg("--console=");
     82
     83  if ( opt ) {
     84    if ( strncmp( opt, "fbcons", sizeof( "fbcons" ) - 1 ) == 0 ) {
     85      if ( rpi_video_is_initialized() > 0 ) {
     86        BSP_output_char = output_char_fb;
     87        link(FBCONS, CONSOLE_DEVICE_NAME);
     88        return ;
     89      }
     90    }
     91  }
     92  BSP_output_char = output_char_serial;
     93  link(UART0, CONSOLE_DEVICE_NAME);
     94}
     95
     96static void uart_probe(void)
     97{
     98  static bool initialized = false;
     99  const void *fdt;
     100  int node;
     101
     102  if ( initialized ) {
     103    return ;
     104  }
     105
     106  fdt = bsp_fdt_get();
     107  node = fdt_node_offset_by_compatible(fdt, -1, "brcm,bcm2835-pl011");
     108
     109  init_ctx_arm_pl011(fdt, node);
     110
     111  initialized = true;
     112}
    57113
    58114static void output_char(char c)
    59115{
    60   const console_fns *con =
    61     Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
     116  uart_probe();
     117  output_char_serial(c);
     118}
    62119
    63   con->deviceWritePolled((int) Console_Port_Minor, c);
     120rtems_status_code console_initialize(
     121  rtems_device_major_number major,
     122  rtems_device_minor_number minor,
     123  void *arg
     124)
     125{
     126  rtems_termios_initialize();
     127
     128  uart_probe();
     129  rtems_termios_device_install(
     130    UART0,
     131    &arm_pl011_fns,
     132    NULL,
     133    &pl011_context.base
     134  );
     135
     136  register_fb();
     137
     138  console_select();
     139
     140  return RTEMS_SUCCESSFUL;
    64141}
    65142
     
    67144
    68145BSP_polling_getchar_function_type BSP_poll_char = NULL;
     146
     147RTEMS_SYSINIT_ITEM(
     148  uart_probe,
     149  RTEMS_SYSINIT_BSP_START,
     150  RTEMS_SYSINIT_ORDER_LAST
     151);
  • bsps/arm/raspberrypi/console/fbcons.c

    reca25ef r362cf319  
    1919#include <rtems.h>
    2020#include <rtems/libio.h>
     21#include <rtems/termiostypes.h>
    2122
    2223#include <stdlib.h>
     
    3132
    3233/*
    33  *  fbcons_init
    34  *
    35  *  This function initializes the fb console to a quiecsent state.
    36  */
    37 static void fbcons_init( int minor )
    38 {
    39 }
    40 
    41 /*
    4234 *  fbcons_open
    4335 *
     
    4638 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
    4739 */
    48 static int fbcons_open(
    49   int   major,
    50   int   minor,
    51   void *arg
     40static bool fbcons_open(
     41  struct rtems_termios_tty *tty,
     42  rtems_termios_device_context *base,
     43  struct termios *term,
     44  rtems_libio_open_close_args_t *args
    5245)
    5346{
    54   return RTEMS_SUCCESSFUL;
     47  return true;
    5548}
    5649
     
    6053 *  This function shuts down the requested port.
    6154 */
    62 static int fbcons_close(
    63   int   major,
    64   int   minor,
    65   void *arg
     55static void fbcons_close(
     56  struct rtems_termios_tty *tty,
     57  rtems_termios_device_context *base,
     58  rtems_libio_open_close_args_t *args
    6659)
    6760{
    68   return ( RTEMS_SUCCESSFUL );
    6961}
    7062
     
    7466 *  This routine polls out the requested character.
    7567 */
    76 static void fbcons_write_polled(
    77   int  minor,
     68void fbcons_write_polled(
     69  rtems_termios_device_context *base,
    7870  char c
    7971)
     
    9183 *
    9284 */
    93 static ssize_t fbcons_write_support_polled(
    94   int         minor,
     85static void fbcons_write_support_polled(
     86  rtems_termios_device_context *base,
    9587  const char *buf,
    9688  size_t      len
     
    10395   */
    10496  while ( nwrite < len ) {
    105     fbcons_write_polled( minor, *buf++ );
     97    fbcons_write_polled( base, *buf++ );
    10698    nwrite++;
    10799  }
    108 
    109   /*
    110    * return the number of bytes written.
    111    */
    112   return nwrite;
    113100}
    114101
     
    118105 *  Console Termios polling input entry point.
    119106 */
    120 static int fbcons_inbyte_nonblocking_polled( int minor )
     107static int fbcons_inbyte_nonblocking_polled(
     108  rtems_termios_device_context *base
     109)
    121110{
    122111  // if( rtems_kbpoll() ) {
     
    134123 *  port settings.
    135124 */
    136 static int fbcons_set_attributes(
    137   int                   minor,
     125static bool fbcons_set_attributes(
     126  rtems_termios_device_context *base,
    138127  const struct termios *t
    139128)
    140129{
    141   return 0;
     130  return true;
    142131}
    143132
    144 bool fbcons_probe( int minor )
     133bool fbcons_probe(
     134  rtems_termios_device_context *context
     135)
    145136{
    146137  // rtems_status_code status;
     
    164155}
    165156
    166 const console_fns fbcons_fns =
     157const rtems_termios_device_handler fbcons_fns =
    167158{
    168   .deviceProbe = libchip_serial_default_probe,     /* deviceProbe */
    169   .deviceFirstOpen = fbcons_open,                 /* deviceFirstOpen */
    170   .deviceLastClose = fbcons_close,                /* deviceLastClose */
    171   .deviceRead = fbcons_inbyte_nonblocking_polled, /* deviceRead */
    172   .deviceWrite = fbcons_write_support_polled,     /* deviceWrite */
    173   .deviceInitialize = fbcons_init,                /* deviceInitialize */
    174   .deviceWritePolled = fbcons_write_polled,       /* deviceWritePolled */
    175   .deviceSetAttributes = fbcons_set_attributes,   /* deviceSetAttributes */
    176   .deviceOutputUsesInterrupts = FALSE,           /* deviceOutputUsesInterrupts*/
     159  .first_open = fbcons_open,
     160  .last_close = fbcons_close,
     161  .poll_read = fbcons_inbyte_nonblocking_polled,
     162  .write = fbcons_write_support_polled,
     163  .set_attributes = fbcons_set_attributes,
     164  .mode = TERMIOS_POLLED
    177165};
Note: See TracChangeset for help on using the changeset viewer.