rpi3: Allow runtime determination of UART base clock rate
authorAndre Przywara <andre.przywara@arm.com>
Sun, 4 Aug 2019 09:46:21 +0000 (10:46 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Wed, 25 Sep 2019 10:45:35 +0000 (11:45 +0100)
At the moment the UART input clock rate is hard coded at compile time.
This works as long as the GPU firmware always sets up the same rate,
which does not seem to be true for the Raspberry Pi 4.

In preparation for being able to change this at runtime, add a base
clock parameter to the console setup function. This is still hardcoded
for the Raspberry Pi 3.

Change-Id: I398bc2f1e9b46f7af9a84cb0b33cbe8e78f2d900
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
plat/rpi/common/include/rpi_shared.h
plat/rpi/common/rpi3_common.c
plat/rpi/rpi3/rpi3_bl1_setup.c
plat/rpi/rpi3/rpi3_bl2_setup.c
plat/rpi/rpi3/rpi3_bl31_setup.c

index 686343892629beda47b5295c423d1839a8f70afe..de83571621ab1445dc921a0fca84baf270c9f44a 100644 (file)
@@ -14,7 +14,7 @@
  ******************************************************************************/
 
 /* Utility functions */
-void rpi3_console_init(void);
+void rpi3_console_init(unsigned int base_clk_rate);
 void rpi3_setup_page_tables(uintptr_t total_base, size_t total_size,
                            uintptr_t code_start, uintptr_t code_limit,
                            uintptr_t rodata_start, uintptr_t rodata_limit
index ab63d98f10fd0cc4ebbf4c01ac6107e76bb10e34..4317b3a26fac3bc9c24a13818630b944c7d03971 100644 (file)
@@ -104,14 +104,14 @@ static const mmap_region_t plat_rpi3_mmap[] = {
  ******************************************************************************/
 static console_16550_t rpi3_console;
 
-void rpi3_console_init(void)
+void rpi3_console_init(unsigned int base_clk_rate)
 {
        int console_scope = CONSOLE_FLAG_BOOT;
 #if RPI3_RUNTIME_UART != -1
        console_scope |= CONSOLE_FLAG_RUNTIME;
 #endif
        int rc = console_16550_register(PLAT_RPI3_UART_BASE,
-                                       PLAT_RPI3_UART_CLK_IN_HZ,
+                                       base_clk_rate,
                                        PLAT_RPI3_UART_BAUDRATE,
                                        &rpi3_console);
        if (rc == 0) {
index 3ac30e0f0bee5c1e95aa7608afe4931182068318..dcce76e47c88b5f8f63eada37326d820f36861d6 100644 (file)
@@ -35,7 +35,7 @@ void bl1_early_platform_setup(void)
                      0x80000000);
 
        /* Initialize the console to provide early debug support */
-       rpi3_console_init();
+       rpi3_console_init(PLAT_RPI3_UART_CLK_IN_HZ);
 
        /* Allow BL1 to see the whole Trusted RAM */
        bl1_tzram_layout.total_base = BL_RAM_BASE;
index 991c0fcb28c5901e8fed0d8cec983ccc65e1843f..44827c63a34649363427637b1d318c29ab727a2d 100644 (file)
@@ -62,7 +62,7 @@ void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
        meminfo_t *mem_layout = (meminfo_t *) arg1;
 
        /* Initialize the console to provide early debug support */
-       rpi3_console_init();
+       rpi3_console_init(PLAT_RPI3_UART_CLK_IN_HZ);
 
        /* Enable arch timer */
        generic_delay_timer_init();
index a9efc52b8231f7b06907750e3cb4795719893604..c16dbffaaf96c8355ff00fefa97e7a9cfef18929 100644 (file)
@@ -60,7 +60,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
 
 {
        /* Initialize the console to provide early debug support */
-       rpi3_console_init();
+       rpi3_console_init(PLAT_RPI3_UART_CLK_IN_HZ);
 
        /*
         * In debug builds, a special value is passed in 'arg1' to verify