Skip to content

Commit

Permalink
elfloader: add support for Jetson Orin
Browse files Browse the repository at this point in the history
This commit also adds support for the tegra194-tcu uart device.

Signed-off-by: Andy Bui <[email protected]>
  • Loading branch information
Andy Bui committed Feb 25, 2024
1 parent 24a7eca commit 9f2a8d0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake-tool/helpers/application_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch)
binary_list
"tx1;hikey;odroidc2;odroidc4;imx8mq-evk;imx8mm-evk;hifive;tqma8xqp1gb;bcm2711;rocketchip"
)
set(efi_list "tk1;rockpro64;quartz64")
set(efi_list "tk1;rockpro64;quartz64;orin")
set(uimage_list "tx2;am335x")
if(
${kernel_platform} IN_LIST efi_list
Expand Down
59 changes: 59 additions & 0 deletions elfloader-tool/src/drivers/uart/tegra-uart.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2023, NIO
*
* SPDX-License-Identifier: GPL-2.0-only
*/

#include <devices_gen.h>
#include <drivers/common.h>
#include <drivers/uart.h>
#include <elfloader_common.h>

#define NUM_BYTES_FIELD_BIT (24U)
#define FLUSH_BIT (26U)
#define INTR_TRIGGER_BIT (31U)
#define UART_REG(mmio, x) ((volatile uint32_t *)(mmio + (x)))

static int tegra_uart_putchar(struct elfloader_device *dev, unsigned int c)
{
uint32_t reg_val;

reg_val = (uint32_t)(1UL << NUM_BYTES_FIELD_BIT);
reg_val |= BIT(INTR_TRIGGER_BIT);
reg_val |= c;

if (c == '\r' || c == '\n') {
reg_val |= BIT(FLUSH_BIT);
}

while (*UART_REG(dev->region_bases[0], 0) & BIT(INTR_TRIGGER_BIT));

*UART_REG(dev->region_bases[0], 0) = reg_val;
return 0;
}

static int tegra_uart_init(struct elfloader_device *dev, UNUSED void *match_data)
{
uart_set_out(dev);
*UART_REG(dev->region_bases[0], 0) = 0;

return 0;
}

static const struct dtb_match_table tegra_uart_matches[] = {
{ .compatible = "nvidia,tegra194-tcu" },
{ .compatible = NULL /* sentinel */ },
};

static const struct elfloader_uart_ops tegra_uart_ops = {
.putc = &tegra_uart_putchar,
};

static const struct elfloader_driver tegra_uart = {
.match_table = tegra_uart_matches,
.type = DRIVER_UART,
.init = &tegra_uart_init,
.ops = &tegra_uart_ops,
};

ELFLOADER_DRIVER(tegra_uart);

0 comments on commit 9f2a8d0

Please sign in to comment.