[PATCH 4/4] bsps: Update BSPs to use the new PL011 driver

Utkarsh Verma utkarsh at bitbanged.com
Wed Aug 30 04:17:06 UTC 2023


This commit updates the existing BSPs to use the new PL011 driver.
---
 bsps/aarch64/a53/console/console.c            | 15 +++++-----
 bsps/aarch64/a72/console/console.c            | 15 +++++-----
 bsps/aarch64/raspberrypi/console/console.c    | 29 ++++++++-----------
 bsps/arm/raspberrypi/console/console-config.c | 27 ++++++++---------
 .../realview-pbx-a9/console/console-polled.c  |  5 ++--
 .../arm/realview-pbx-a9/include/bsp/console.h |  4 +--
 bsps/arm/xen/console/console.c                | 15 +++++-----
 7 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/bsps/aarch64/a53/console/console.c b/bsps/aarch64/a53/console/console.c
index 1854909c98..4d3adf2a7e 100644
--- a/bsps/aarch64/a53/console/console.c
+++ b/bsps/aarch64/a53/console/console.c
@@ -37,14 +37,15 @@
 #include <rtems/bspIo.h>
 
 #include <bsp.h>
-#include <dev/serial/arm-pl011.h>
+#include <dev/serial/pl011.h>
 #include <bsp/console-termios.h>
 
 #include <bspopts.h>
 
-arm_pl011_context a53_qemu_vpl011_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_A53_QEMU_VPL011_BASE,
+pl011_context a53_qemu_vpl011_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_A53_QEMU_VPL011_BASE,
+  /* FIXME: Add clock speed. Otherwise buadrate intialization will fail */
   .initial_baud = 115200
 };
 
@@ -52,8 +53,8 @@ const console_device console_device_table[] = {
   {
     .device_file = "/dev/ttyS0",
     .probe = console_device_probe_default,
-    .handler = &arm_pl011_fns,
-    .context = &a53_qemu_vpl011_context.base
+    .handler = &pl011_handler,
+    .context = &a53_qemu_vpl011_context.context
   }
 };
 
@@ -61,7 +62,7 @@ const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
 
 static void output_char( char c )
 {
-  arm_pl011_write_polled(&a53_qemu_vpl011_context.base, c);
+  pl011_write_char_polled(&a53_qemu_vpl011_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/aarch64/a72/console/console.c b/bsps/aarch64/a72/console/console.c
index 08532d68cd..1207802b00 100644
--- a/bsps/aarch64/a72/console/console.c
+++ b/bsps/aarch64/a72/console/console.c
@@ -37,14 +37,15 @@
 #include <rtems/bspIo.h>
 
 #include <bsp.h>
-#include <dev/serial/arm-pl011.h>
+#include <dev/serial/pl011.h>
 #include <bsp/console-termios.h>
 
 #include <bspopts.h>
 
-arm_pl011_context a72_qemu_vpl011_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_A72_QEMU_VPL011_BASE,
+pl011_context a72_qemu_vpl011_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_A72_QEMU_VPL011_BASE,
+  /* FIXME: Add clock speed. Otherwise buadrate intialization will fail */
   .initial_baud = 115200
 };
 
@@ -52,8 +53,8 @@ const console_device console_device_table[] = {
   {
     .device_file = "/dev/ttyS0",
     .probe = console_device_probe_default,
-    .handler = &arm_pl011_fns,
-    .context = &a72_qemu_vpl011_context.base
+    .handler = &pl011_handler,
+    .context = &a72_qemu_vpl011_context.context
   }
 };
 
@@ -61,7 +62,7 @@ const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
 
 static void output_char( char c )
 {
-  arm_pl011_write_polled(&a72_qemu_vpl011_context.base, c);
+  pl011_write_char_polled(&a72_qemu_vpl011_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/aarch64/raspberrypi/console/console.c b/bsps/aarch64/raspberrypi/console/console.c
index 73bb0036ff..54a022be42 100644
--- a/bsps/aarch64/raspberrypi/console/console.c
+++ b/bsps/aarch64/raspberrypi/console/console.c
@@ -34,34 +34,29 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <rtems/bspIo.h>
-
 #include <bsp.h>
-#include <dev/serial/arm-pl011.h>
 #include <bsp/console-termios.h>
-
 #include <bspopts.h>
+#include <dev/serial/pl011.h>
+#include <rtems/bspIo.h>
 
-arm_pl011_context raspberrypi_4_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_RPI4_PL011_BASE,
+pl011_context raspberrypi_4_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_RPI4_PL011_BASE,
+  .clock = 48000000,
   .initial_baud = 115200
 };
 
 const console_device console_device_table[] = {
-  {
-    .device_file = "/dev/ttyS0",
-    .probe = console_device_probe_default,
-    .handler = &arm_pl011_fns,
-    .context = &raspberrypi_4_context.base
-  }
-};
+    {.device_file = "/dev/ttyS0",
+     .probe       = console_device_probe_default,
+     .handler     = &pl011_handler,
+     .context     = &raspberrypi_4_context.context}};
 
 const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
 
-static void output_char( char c )
-{
-  arm_pl011_write_polled(&raspberrypi_4_context.base, c);
+static void output_char(char c) {
+    pl011_write_char_polled(&raspberrypi_4_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/arm/raspberrypi/console/console-config.c b/bsps/arm/raspberrypi/console/console-config.c
index 6b8eb80aa4..26997312a4 100644
--- a/bsps/arm/raspberrypi/console/console-config.c
+++ b/bsps/arm/raspberrypi/console/console-config.c
@@ -25,7 +25,7 @@
 #include <libchip/serial.h>
 #include <libfdt.h>
 #include <libchip/ns16550.h>
-#include <dev/serial/arm-pl011.h>
+#include <dev/serial/pl011.h>
 
 #include <bspopts.h>
 #include <bsp/usart.h>
@@ -46,19 +46,20 @@
 #define MINIUART  "/dev/ttyS0"
 #define FBCONS    "/dev/fbcons"
 
-arm_pl011_context pl011_context;
-ns16550_context mini_uart_context;
+pl011_context uart0;
+/* FIXME: Define clock speed in uart0. Otherwise buadrate intialization will fail */
+ns16550_context uart1;
 
 rpi_fb_context fb_context;
 
 static void output_char_pl011(char c)
 {
-  arm_pl011_write_polled(&pl011_context.base, c);
+  pl011_write_char_polled(&uart0.context, c);
 }
 
 static void output_char_mini_uart(char c)
 {
-  ns16550_polled_putchar(&mini_uart_context.base, c);
+  ns16550_polled_putchar(&uart1.base, c);
 }
 
 void output_char_fb(char c)
@@ -83,9 +84,9 @@ static void init_ctx_arm_pl011(
   int node
 )
 {
-  arm_pl011_context *ctx = &pl011_context;
+  pl011_context *ctx = &uart0;
   rtems_termios_device_context_initialize(&ctx->base, "PL011UART");
-  ctx->regs = raspberrypi_get_reg_of_node(fdt, node);
+  ctx->regs_base = raspberrypi_get_reg_of_node(fdt, node);
 }
 
 static uint32_t calculate_baud_divisor(
@@ -106,8 +107,8 @@ static void init_ctx_mini_uart(
   int len;
   ns16550_context *ctx;
 
-  memset(&mini_uart_context, 0, sizeof(mini_uart_context));
-  ctx = &mini_uart_context;
+  memset(&uart1, 0, sizeof(uart1));
+  ctx = &uart1;
 
   rtems_termios_device_context_initialize(&ctx->base, "MiniUART");
 
@@ -221,16 +222,16 @@ rtems_status_code console_initialize(
   uart_probe();
   rtems_termios_device_install(
     PL011,
-    &arm_pl011_fns,
+    &pl011_handler,
     NULL,
-    &pl011_context.base
+    &uart0.context
   );
 
   rtems_termios_device_install(
     MINIUART,
     &ns16550_handler_polled,
     NULL,
-    &mini_uart_context.base
+    &uart1.base
   );
 
   register_fb();
@@ -248,4 +249,4 @@ RTEMS_SYSINIT_ITEM(
   uart_probe,
   RTEMS_SYSINIT_BSP_START,
   RTEMS_SYSINIT_ORDER_LAST_BUT_5
-);
\ No newline at end of file
+);
diff --git a/bsps/arm/realview-pbx-a9/console/console-polled.c b/bsps/arm/realview-pbx-a9/console/console-polled.c
index fc848d3d20..f71e147dd1 100644
--- a/bsps/arm/realview-pbx-a9/console/console-polled.c
+++ b/bsps/arm/realview-pbx-a9/console/console-polled.c
@@ -32,8 +32,9 @@
 #include <rtems/bspIo.h>
 
 arm_pl011_context rvpbx_pl011_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) 0x10009000,
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = 0x10009000,
+  /* FIXME: Define clock speed here otherwise baudrate configuration will fail */
   .irq = RVPBXA9_IRQ_UART_0,
   .initial_baud = 115200
 };
diff --git a/bsps/arm/realview-pbx-a9/include/bsp/console.h b/bsps/arm/realview-pbx-a9/include/bsp/console.h
index 8f578983c3..b33692856b 100644
--- a/bsps/arm/realview-pbx-a9/include/bsp/console.h
+++ b/bsps/arm/realview-pbx-a9/include/bsp/console.h
@@ -28,13 +28,13 @@
 #ifndef LIBBSP_ARM_REALVIEW_PBX_A9_BSP_CONSOLE_H
 #define LIBBSP_ARM_REALVIEW_PBX_A9_BSP_CONSOLE_H
 
-#include <dev/serial/arm-pl011.h>
+#include <dev/serial/pl011.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-extern arm_pl011_context rvpbx_pl011_context;
+extern pl011_context rvpbx_pl011_context;
 
 bool rvpbx_pl011_probe(rtems_termios_device_context *base);
 
diff --git a/bsps/arm/xen/console/console.c b/bsps/arm/xen/console/console.c
index 05eceae438..d94d4da837 100644
--- a/bsps/arm/xen/console/console.c
+++ b/bsps/arm/xen/console/console.c
@@ -29,15 +29,16 @@
 #include <rtems/bspIo.h>
 
 #include <bsp.h>
-#include <dev/serial/arm-pl011.h>
+#include <dev/serial/pl011.h>
 #include <bsp/console-termios.h>
 #include <bsp/irq-generic.h>
 
 #include <bspopts.h>
 
-arm_pl011_context xen_vpl011_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_XEN_VPL011_BASE,
+pl011_context xen_vpl011_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_XEN_VPL011_BASE,
+  /* FIXME: Define clock speed otherwise baudrate configuration will fail */
   .irq = GUEST_VPL011_SPI,
   .initial_baud = 115200
 };
@@ -46,8 +47,8 @@ const console_device console_device_table[] = {
   {
     .device_file = "/dev/ttyS0",
     .probe = console_device_probe_default,
-    .handler = &arm_pl011_fns,
-    .context = &xen_vpl011_context.base
+    .handler = &pl011_handler,
+    .context = &xen_vpl011_context.context
   }
 };
 
@@ -55,7 +56,7 @@ const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
 
 static void output_char( char c )
 {
-  arm_pl011_write_polled(&xen_vpl011_context.base, c);
+  pl011_write_char_polled(&xen_vpl011_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
-- 
2.41.0



More information about the devel mailing list