Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libplatsupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ elseif(KernelPlatformHifiveP550)
set(LibPlatSupportMach "eswin")
elseif(KernelPlatformBananapiF3)
set(LibPlatSupportMach "spacemit")
elseif(KernelPlatformRockpro64 OR KernelPlatformRock3b)
set(LibPlatSupportMach "rockchip")
elseif(NOT ${KernelArmMach} STREQUAL "")
# falling back to kernel settings is done to keep legacy compatibility
set(LibPlatSupportMach "${KernelArmMach}")
Expand Down
40 changes: 40 additions & 0 deletions libplatsupport/mach_include/rockchip/platsupport/mach/timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once

#include <platsupport/fdt.h>
#include <platsupport/ltimer.h>
#include <platsupport/timer.h>

typedef struct {
/* set in init */
ps_io_ops_t ops;
ltimer_callback_fn_t user_cb_fn;
void *user_cb_token;
ltimer_event_t user_cb_event; /* are we timeout or timestamp? */

/* set in fdt helper */
volatile struct rk_map *hw;
void *rk_map_base;
pmem_region_t pmem;
ps_irq_t irq;
irq_id_t irq_id;
} rk_t;

typedef struct {
const char *fdt_path;
ltimer_callback_fn_t user_cb_fn;
void *user_cb_token;
ltimer_event_t user_cb_event;
} rk_config_t;

int rk_init(rk_t *rk, ps_io_ops_t ops, rk_config_t config);
int rk_init_secondary(rk_t *rk, rk_t *rkp, ps_io_ops_t ops, rk_config_t config);
int rk_start_timestamp_timer(rk_t *rk);
int rk_stop(rk_t *rk);
uint64_t rk_get_time(rk_t *rk);
int rk_set_timeout(rk_t *rk, uint64_t ns, bool periodic);
void rk_destroy(rk_t *rk);
1 change: 1 addition & 0 deletions libplatsupport/plat_include/rk3568/platsupport/plat/i2c.h
8 changes: 8 additions & 0 deletions libplatsupport/plat_include/rk3568/platsupport/plat/timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright 2025, UNSW
*
* SPDX-License-Identifier: BSD-2-Clause
*/
Comment thread
JDuchniewicz marked this conversation as resolved.
#pragma once

#define RK_TIMER_PATH "/rktimer@fe5f0000"
59 changes: 0 additions & 59 deletions libplatsupport/plat_include/rockpro64/platsupport/plat/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,4 @@
*/
#pragma once
Comment thread
JDuchniewicz marked this conversation as resolved.

#include <platsupport/fdt.h>
#include <platsupport/ltimer.h>
#include <platsupport/timer.h>

#define RK_TIMER_PATH "/rktimer@ff850000"

#define RK_REG_CHOICE 0
#define RK_IRQ_CHOICE 0

static UNUSED timer_properties_t rk_properties = {
.upcounter = true,
.timeouts = true,
.relative_timeouts = true,
.periodic_timeouts = true,
.bit_width = 32,
.irqs = 1
};

struct rk_map {
uint32_t load_count0;
uint32_t load_count1;
uint32_t current_value0;
uint32_t current_value1;
uint32_t load_count2;
uint32_t load_count3;
uint32_t interrupt_status;
uint32_t control_register;
};

typedef struct {
/* set in init */
ps_io_ops_t ops;
ltimer_callback_fn_t user_cb_fn;
void *user_cb_token;
ltimer_event_t user_cb_event; /* what are we being used for? */

/* set in fdt helper */
volatile struct rk_map *hw;
void *rk_map_base;
pmem_region_t pmem;
ps_irq_t irq;
irq_id_t irq_id;
} rk_t;

typedef struct {
const char *fdt_path;
ltimer_callback_fn_t user_cb_fn;
void *user_cb_token;
ltimer_event_t user_cb_event;
} rk_config_t;

int rk_init(rk_t *rk, ps_io_ops_t ops, rk_config_t config);
int rk_init_secondary(rk_t *rk, rk_t *rkp, ps_io_ops_t ops, rk_config_t config);
int rk_start_timestamp_timer(rk_t *rk);
int rk_stop(rk_t *rk);
uint64_t rk_get_time(rk_t *rk);
int rk_set_timeout(rk_t *rk, uint64_t ns, bool periodic);
/* return true if a match is pending */
bool rk_pending_match(rk_t *rk);
void rk_destroy(rk_t *rk);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ static const int uart2_irqs[] = {UART2_IRQ, -1};
static const int uart3_irqs[] = {UART3_IRQ, -1};
static const int uart4_irqs[] = {UART4_IRQ, -1};


#define UART_DEFN(devid) { \
.id = RP_UART##devid, \
.paddr = UART##devid##_PADDR, \
Expand All @@ -27,7 +26,6 @@ static const int uart4_irqs[] = {UART4_IRQ, -1};
.init_fn = &uart_init \
}


static const struct dev_defn dev_defn[] = {
UART_DEFN(1),
UART_DEFN(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

/* Implementation of a logical timer for rockpro64
*
* We use the 1 rk for timeouts and 1 for a millisecond tick.
/* Implementation of a logical timer for rk3399 and rk3568 by using 2 physical timer devices, 1 timestamp and 1 timeout.
*
* The configuration of timers that we use allows us to map only one page in.
*/
#include <platsupport/timer.h>
#include <platsupport/ltimer.h>
#include <platsupport/plat/timer.h>
#include <platsupport/mach/timer.h>
#include <utils/util.h>

#include "../../ltimer.h"
Expand Down Expand Up @@ -130,11 +129,3 @@ int ltimer_default_init(ltimer_t *ltimer, ps_io_ops_t ops, ltimer_callback_fn_t

return 0;
}

/* This function is intended to be deleted,
* this is just left here for now so that stuff can compile */
int ltimer_default_describe(ltimer_t *ltimer, ps_io_ops_t ops)
{
ZF_LOGE("get_(nth/num)_(irqs/pmems) are not valid");
return EINVAL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Compatible with rockchip,rk3568-uart, snps,dw-apb-uart.
*/

#include <string.h>
Expand Down
Loading
Loading