File indexing completed on 2025-05-11 08:23:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <rtems/console.h>
0037
0038 #include <libchip/ns16550.h>
0039
0040 #include <bsp.h>
0041 #include <bsp/lpc24xx.h>
0042 #include <bsp/irq.h>
0043 #include <bsp/io.h>
0044 #include <bsp/console-termios.h>
0045
0046 static uint8_t lpc24xx_uart_get_register(uintptr_t addr, uint8_t i)
0047 {
0048 volatile uint32_t *reg = (volatile uint32_t *) addr;
0049
0050 return (uint8_t) reg [i];
0051 }
0052
0053 static void lpc24xx_uart_set_register(uintptr_t addr, uint8_t i, uint8_t val)
0054 {
0055 volatile uint32_t *reg = (volatile uint32_t *) addr;
0056
0057 reg [i] = val;
0058 }
0059
0060 #ifdef LPC24XX_CONFIG_CONSOLE
0061 static ns16550_context lpc24xx_uart_context_0 = {
0062 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
0063 .get_reg = lpc24xx_uart_get_register,
0064 .set_reg = lpc24xx_uart_set_register,
0065 .port = UART0_BASE_ADDR,
0066 .irq = LPC24XX_IRQ_UART_0,
0067 .clock = LPC24XX_PCLK,
0068 .initial_baud = LPC24XX_UART_BAUD,
0069 .has_fractional_divider_register = true
0070 };
0071 #endif
0072
0073 #ifdef LPC24XX_CONFIG_UART_1
0074 static ns16550_context lpc24xx_uart_context_1 = {
0075 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
0076 .get_reg = lpc24xx_uart_get_register,
0077 .set_reg = lpc24xx_uart_set_register,
0078 .port = UART1_BASE_ADDR,
0079 .irq = LPC24XX_IRQ_UART_1,
0080 .clock = LPC24XX_PCLK,
0081 .initial_baud = LPC24XX_UART_BAUD,
0082 .has_fractional_divider_register = true
0083 };
0084 #endif
0085
0086 #ifdef LPC24XX_CONFIG_UART_2
0087 static ns16550_context lpc24xx_uart_context_2 = {
0088 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 2"),
0089 .get_reg = lpc24xx_uart_get_register,
0090 .set_reg = lpc24xx_uart_set_register,
0091 .port = UART2_BASE_ADDR,
0092 .irq = LPC24XX_IRQ_UART_2,
0093 .clock = LPC24XX_PCLK,
0094 .initial_baud = LPC24XX_UART_BAUD,
0095 .has_fractional_divider_register = true
0096 };
0097 #endif
0098
0099 #ifdef LPC24XX_CONFIG_UART_3
0100 static ns16550_context lpc24xx_uart_context_3 = {
0101 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 3"),
0102 .get_reg = lpc24xx_uart_get_register,
0103 .set_reg = lpc24xx_uart_set_register,
0104 .port = UART3_BASE_ADDR,
0105 .irq = LPC24XX_IRQ_UART_3,
0106 .clock = LPC24XX_PCLK,
0107 .initial_baud = LPC24XX_UART_BAUD,
0108 .has_fractional_divider_register = true
0109 };
0110 #endif
0111
0112 const console_device console_device_table[] = {
0113 #ifdef LPC24XX_CONFIG_CONSOLE
0114 {
0115 .device_file = "/dev/ttyS0",
0116 .probe = console_device_probe_default,
0117 .handler = &ns16550_handler_interrupt,
0118 .context = &lpc24xx_uart_context_0.base
0119 },
0120 #endif
0121 #ifdef LPC24XX_CONFIG_UART_1
0122 {
0123 .device_file = "/dev/ttyS1",
0124 .probe = lpc24xx_uart_probe_1,
0125 .handler = &ns16550_handler_interrupt,
0126 .context = &lpc24xx_uart_context_1.base
0127 },
0128 #endif
0129 #ifdef LPC24XX_CONFIG_UART_2
0130 {
0131 .device_file = "/dev/ttyS2",
0132 .probe = lpc24xx_uart_probe_2,
0133 .handler = &ns16550_handler_interrupt,
0134 .context = &lpc24xx_uart_context_2.base
0135 },
0136 #endif
0137 #ifdef LPC24XX_CONFIG_UART_3
0138 {
0139 .device_file = "/dev/ttyS3",
0140 .probe = lpc24xx_uart_probe_3,
0141 .handler = &ns16550_handler_interrupt,
0142 .context = &lpc24xx_uart_context_3.base
0143 },
0144 #endif
0145 };
0146
0147 const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);