Skip to content

Commit

Permalink
Add lk2nd,uart device tree property to select UART for console output
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-gh authored and Junak committed Aug 1, 2020
1 parent 2e80115 commit 040361b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
24 changes: 23 additions & 1 deletion app/aboot/lk2nd-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ static bool lk2nd_device_match(const void *fdt, int offset)
val = fdt_getprop(fdt, offset, "lk2nd,match-bootloader", &len);
if (val && len > 0) {
if (!lk2nd_dev.bootloader) {
dprintf(CRITICAL, "Unknown bootloader, cannot match\n");
if (lk2nd_dev.cmdline)
dprintf(CRITICAL, "Unknown bootloader, cannot match\n");
return false;
}

Expand Down Expand Up @@ -129,6 +130,27 @@ void lk2nd_parse_device_node(const void *fdt)
dprintf(CRITICAL, "Device node is missing 'model' property\n");
}


int lk2nd_fdt_parse_early_uart(void)
{
int offset, len;
const uint32_t *val;

void *fdt = (void*) lk_boot_args[2];
if (!fdt || dev_tree_check_header(fdt))
return -1; // Will be reported later again. Hopefully.

offset = lk2nd_find_device_offset(fdt);
if (offset < 0)
return -1;

/* TODO: Change this to use chosen node */
val = fdt_getprop(fdt, offset, "lk2nd,uart", &len);
if (len > 0)
return fdt32_to_cpu(*val);
return -1;
}

void lk2nd_fdt_parse(void)
{
struct board_id board_id;
Expand Down
3 changes: 3 additions & 0 deletions app/aboot/lk2nd-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ struct lk2nd_device {

extern struct lk2nd_device lk2nd_dev;

void lk2nd_fdt_parse(void);
int lk2nd_fdt_parse_early_uart(void);

#endif
7 changes: 6 additions & 1 deletion target/msm8916/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <partition_parser.h>
#include <stdlib.h>
#include <smem.h>
#include <lk2nd-device.h>

#if LONG_PRESS_POWER_ON
#include <shutdown_detect.h>
Expand Down Expand Up @@ -92,7 +93,11 @@ static uint32_t mmc_sdc_pwrctl_irq[] =
void target_early_init(void)
{
#if WITH_DEBUG_UART
uart_dm_init(2, 0, BLSP1_UART1_BASE);
int uart = lk2nd_fdt_parse_early_uart();
if (uart == 1)
uart_dm_init(1, 0, BLSP1_UART0_BASE);
else
uart_dm_init(2, 0, BLSP1_UART1_BASE);
#endif
}

Expand Down

0 comments on commit 040361b

Please sign in to comment.