Changeset 362cf319 in rtems for bsps/arm/raspberrypi/console
- Timestamp:
- 01/04/20 19:50:46 (4 years ago)
- 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)
- Location:
- bsps/arm/raspberrypi/console
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bsps/arm/raspberrypi/console/console-config.c
reca25ef r362cf319 20 20 21 21 #include <rtems/bspIo.h> 22 #include <rtems/console.h> 23 #include <rtems/sysinit.h> 22 24 23 25 #include <libchip/serial.h> 26 #include <libfdt.h> 24 27 25 28 #include <bspopts.h> 26 #include <bsp/irq.h>27 29 #include <bsp/usart.h> 28 30 #include <bsp/raspberrypi.h> 29 31 #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> 30 37 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_UART42 },43 {44 .sDeviceName ="/dev/fbcons",45 .deviceType = SERIAL_CUSTOM,46 .pDeviceFns = &fbcons_fns,47 .deviceProbe = fbcons_probe,48 .pDeviceFlow = NULL,49 },50 };51 38 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" 55 41 56 unsigned long Console_Configuration_Count = PORT_COUNT; 42 arm_pl011_context pl011_context; 43 44 rpi_fb_context fb_context; 45 46 static void output_char_serial(char c) 47 { 48 arm_pl011_write_polled(&pl011_context.base, c); 49 } 50 51 void output_char_fb(char c) 52 { 53 fbcons_write_polled(&fb_context.base, c); 54 } 55 56 static 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 66 static 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 77 static 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 96 static 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 } 57 113 58 114 static void output_char(char c) 59 115 { 60 const console_fns *con = 61 Console_Configuration_Ports [Console_Port_Minor].pDeviceFns; 116 uart_probe(); 117 output_char_serial(c); 118 } 62 119 63 con->deviceWritePolled((int) Console_Port_Minor, c); 120 rtems_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; 64 141 } 65 142 … … 67 144 68 145 BSP_polling_getchar_function_type BSP_poll_char = NULL; 146 147 RTEMS_SYSINIT_ITEM( 148 uart_probe, 149 RTEMS_SYSINIT_BSP_START, 150 RTEMS_SYSINIT_ORDER_LAST 151 ); -
bsps/arm/raspberrypi/console/fbcons.c
reca25ef r362cf319 19 19 #include <rtems.h> 20 20 #include <rtems/libio.h> 21 #include <rtems/termiostypes.h> 21 22 22 23 #include <stdlib.h> … … 31 32 32 33 /* 33 * fbcons_init34 *35 * This function initializes the fb console to a quiecsent state.36 */37 static void fbcons_init( int minor )38 {39 }40 41 /*42 34 * fbcons_open 43 35 * … … 46 38 * Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. 47 39 */ 48 static int fbcons_open( 49 int major, 50 int minor, 51 void *arg 40 static 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 52 45 ) 53 46 { 54 return RTEMS_SUCCESSFUL;47 return true; 55 48 } 56 49 … … 60 53 * This function shuts down the requested port. 61 54 */ 62 static intfbcons_close(63 int major,64 int minor,65 void *arg55 static void fbcons_close( 56 struct rtems_termios_tty *tty, 57 rtems_termios_device_context *base, 58 rtems_libio_open_close_args_t *args 66 59 ) 67 60 { 68 return ( RTEMS_SUCCESSFUL );69 61 } 70 62 … … 74 66 * This routine polls out the requested character. 75 67 */ 76 staticvoid fbcons_write_polled(77 int minor,68 void fbcons_write_polled( 69 rtems_termios_device_context *base, 78 70 char c 79 71 ) … … 91 83 * 92 84 */ 93 static ssize_tfbcons_write_support_polled(94 int minor,85 static void fbcons_write_support_polled( 86 rtems_termios_device_context *base, 95 87 const char *buf, 96 88 size_t len … … 103 95 */ 104 96 while ( nwrite < len ) { 105 fbcons_write_polled( minor, *buf++ );97 fbcons_write_polled( base, *buf++ ); 106 98 nwrite++; 107 99 } 108 109 /*110 * return the number of bytes written.111 */112 return nwrite;113 100 } 114 101 … … 118 105 * Console Termios polling input entry point. 119 106 */ 120 static int fbcons_inbyte_nonblocking_polled( int minor ) 107 static int fbcons_inbyte_nonblocking_polled( 108 rtems_termios_device_context *base 109 ) 121 110 { 122 111 // if( rtems_kbpoll() ) { … … 134 123 * port settings. 135 124 */ 136 static intfbcons_set_attributes(137 int minor,125 static bool fbcons_set_attributes( 126 rtems_termios_device_context *base, 138 127 const struct termios *t 139 128 ) 140 129 { 141 return 0;130 return true; 142 131 } 143 132 144 bool fbcons_probe( int minor ) 133 bool fbcons_probe( 134 rtems_termios_device_context *context 135 ) 145 136 { 146 137 // rtems_status_code status; … … 164 155 } 165 156 166 const console_fnsfbcons_fns =157 const rtems_termios_device_handler fbcons_fns = 167 158 { 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 177 165 };
Note: See TracChangeset
for help on using the changeset viewer.