Skip to content

Commit 07a7e15

Browse files
JDuchniewiczlsf37
authored andcommitted
Add support for rock3b board
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@unsw.edu.au>
1 parent 43e0806 commit 07a7e15

File tree

11 files changed

+126
-133
lines changed

11 files changed

+126
-133
lines changed

libplatsupport/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ elseif(KernelPlatformHifiveP550)
7575
set(LibPlatSupportMach "eswin")
7676
elseif(KernelPlatformBananapiF3)
7777
set(LibPlatSupportMach "spacemit")
78+
elseif(KernelPlatformRockpro64 OR KernelPlatformRock3b)
79+
set(LibPlatSupportMach "rockchip")
7880
elseif(NOT ${KernelArmMach} STREQUAL "")
7981
# falling back to kernel settings is done to keep legacy compatibility
8082
set(LibPlatSupportMach "${KernelArmMach}")
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
#pragma once
7+
8+
#include <platsupport/fdt.h>
9+
#include <platsupport/ltimer.h>
10+
#include <platsupport/timer.h>
11+
12+
typedef struct {
13+
/* set in init */
14+
ps_io_ops_t ops;
15+
ltimer_callback_fn_t user_cb_fn;
16+
void *user_cb_token;
17+
ltimer_event_t user_cb_event; /* are we timeout or timestamp? */
18+
19+
/* set in fdt helper */
20+
volatile struct rk_map *hw;
21+
void *rk_map_base;
22+
pmem_region_t pmem;
23+
ps_irq_t irq;
24+
irq_id_t irq_id;
25+
} rk_t;
26+
27+
typedef struct {
28+
const char *fdt_path;
29+
ltimer_callback_fn_t user_cb_fn;
30+
void *user_cb_token;
31+
ltimer_event_t user_cb_event;
32+
} rk_config_t;
33+
34+
int rk_init(rk_t *rk, ps_io_ops_t ops, rk_config_t config);
35+
int rk_init_secondary(rk_t *rk, rk_t *rkp, ps_io_ops_t ops, rk_config_t config);
36+
int rk_start_timestamp_timer(rk_t *rk);
37+
int rk_stop(rk_t *rk);
38+
uint64_t rk_get_time(rk_t *rk);
39+
int rk_set_timeout(rk_t *rk, uint64_t ns, bool periodic);
40+
void rk_destroy(rk_t *rk);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rockpro64/platsupport/plat/clock.h
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rockpro64/platsupport/plat/i2c.h
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rockpro64/platsupport/plat/serial.h
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright 2025, UNSW
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
#pragma once
7+
8+
#define RK_TIMER_PATH "/rktimer@fe5f0000"

libplatsupport/plat_include/rockpro64/platsupport/plat/timer.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,4 @@
55
*/
66
#pragma once
77

8-
#include <platsupport/fdt.h>
9-
#include <platsupport/ltimer.h>
10-
#include <platsupport/timer.h>
11-
128
#define RK_TIMER_PATH "/rktimer@ff850000"
13-
14-
#define RK_REG_CHOICE 0
15-
#define RK_IRQ_CHOICE 0
16-
17-
static UNUSED timer_properties_t rk_properties = {
18-
.upcounter = true,
19-
.timeouts = true,
20-
.relative_timeouts = true,
21-
.periodic_timeouts = true,
22-
.bit_width = 32,
23-
.irqs = 1
24-
};
25-
26-
struct rk_map {
27-
uint32_t load_count0;
28-
uint32_t load_count1;
29-
uint32_t current_value0;
30-
uint32_t current_value1;
31-
uint32_t load_count2;
32-
uint32_t load_count3;
33-
uint32_t interrupt_status;
34-
uint32_t control_register;
35-
};
36-
37-
typedef struct {
38-
/* set in init */
39-
ps_io_ops_t ops;
40-
ltimer_callback_fn_t user_cb_fn;
41-
void *user_cb_token;
42-
ltimer_event_t user_cb_event; /* what are we being used for? */
43-
44-
/* set in fdt helper */
45-
volatile struct rk_map *hw;
46-
void *rk_map_base;
47-
pmem_region_t pmem;
48-
ps_irq_t irq;
49-
irq_id_t irq_id;
50-
} rk_t;
51-
52-
typedef struct {
53-
const char *fdt_path;
54-
ltimer_callback_fn_t user_cb_fn;
55-
void *user_cb_token;
56-
ltimer_event_t user_cb_event;
57-
} rk_config_t;
58-
59-
int rk_init(rk_t *rk, ps_io_ops_t ops, rk_config_t config);
60-
int rk_init_secondary(rk_t *rk, rk_t *rkp, ps_io_ops_t ops, rk_config_t config);
61-
int rk_start_timestamp_timer(rk_t *rk);
62-
int rk_stop(rk_t *rk);
63-
uint64_t rk_get_time(rk_t *rk);
64-
int rk_set_timeout(rk_t *rk, uint64_t ns, bool periodic);
65-
/* return true if a match is pending */
66-
bool rk_pending_match(rk_t *rk);
67-
void rk_destroy(rk_t *rk);

libplatsupport/src/plat/rockpro64/chardev.c renamed to libplatsupport/src/mach/rockchip/chardev.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ static const int uart2_irqs[] = {UART2_IRQ, -1};
1818
static const int uart3_irqs[] = {UART3_IRQ, -1};
1919
static const int uart4_irqs[] = {UART4_IRQ, -1};
2020

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

30-
3129
static const struct dev_defn dev_defn[] = {
3230
UART_DEFN(1),
3331
UART_DEFN(2),

libplatsupport/src/plat/rockpro64/ltimer.c renamed to libplatsupport/src/mach/rockchip/ltimer.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
* SPDX-License-Identifier: BSD-2-Clause
55
*/
66

7-
/* Implementation of a logical timer for rockpro64
8-
*
9-
* We use the 1 rk for timeouts and 1 for a millisecond tick.
7+
/* Implementation of a logical timer for rk3399 and rk3568 by using 2 physical timer devices, 1 timestamp and 1 timeout.
108
*
119
* The configuration of timers that we use allows us to map only one page in.
1210
*/
1311
#include <platsupport/timer.h>
1412
#include <platsupport/ltimer.h>
1513
#include <platsupport/plat/timer.h>
14+
#include <platsupport/mach/timer.h>
1615
#include <utils/util.h>
1716

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

131130
return 0;
132131
}
133-
134-
/* This function is intended to be deleted,
135-
* this is just left here for now so that stuff can compile */
136-
int ltimer_default_describe(ltimer_t *ltimer, ps_io_ops_t ops)
137-
{
138-
ZF_LOGE("get_(nth/num)_(irqs/pmems) are not valid");
139-
return EINVAL;
140-
}

libplatsupport/src/plat/rockpro64/serial.c renamed to libplatsupport/src/mach/rockchip/serial.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
33
*
44
* SPDX-License-Identifier: BSD-2-Clause
5+
*
6+
* Compatible with rockchip,rk3568-uart, snps,dw-apb-uart.
57
*/
68

79
#include <string.h>

0 commit comments

Comments
 (0)