Skip to content

Commit 37a8013

Browse files
Add Astral option to N-EUREKA's BSP
1 parent 99cc182 commit 37a8013

File tree

3 files changed

+175
-1
lines changed

3 files changed

+175
-1
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Luka Macan <[email protected]>
3+
*
4+
* Copyright 2023 ETH Zurich and University of Bologna
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* SPDX-License-Identifier: Apache-2.0
19+
*/
20+
21+
#include "neureka_astral_bsp.h"
22+
#include <pmsis.h>
23+
24+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_BASE_ADDR (0x50200000)
25+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_OFFS 0x18
26+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR \
27+
(NEUREKA_ASTRAL_CLUSTER_CTRL_BASE_ADDR + \
28+
NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_OFFS)
29+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_CG_EN 0x800
30+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL 0x2000
31+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO 0x100
32+
#define NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL 0xff
33+
#define NEUREKA_ASTRAL_MAX_STALL (8)
34+
#define NEUREKA_ASTRAL_EVENT (1 << 12)
35+
#define NEUREKA_ASTRAL_BASE_ADDR (0x50201000)
36+
37+
void neureka_astral_cg_enable() {
38+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR |=
39+
NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_CG_EN;
40+
}
41+
42+
void neureka_astral_cg_disable() {
43+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR &=
44+
~NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_CG_EN;
45+
}
46+
47+
void neureka_astral_neureka_select() {
48+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR |=
49+
NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL;
50+
}
51+
52+
void neureka_astral_neureka_unselect() {
53+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR &=
54+
~NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL;
55+
}
56+
57+
void neureka_astral_hci_setpriority_neureka() {
58+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR |=
59+
NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO;
60+
}
61+
62+
void neureka_astral_hci_setpriority_core() {
63+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR &=
64+
~NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO;
65+
}
66+
67+
void neureka_astral_hci_reset_max_stall() {
68+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR &=
69+
~NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL;
70+
}
71+
72+
void neureka_astral_hci_set_max_stall(uint32_t max_stall) {
73+
*(volatile uint32_t *)NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_ADDR |=
74+
max_stall & NEUREKA_ASTRAL_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL;
75+
}
76+
77+
void neureka_astral_open(neureka_astral_conf_t *conf) {
78+
neureka_astral_cg_enable();
79+
neureka_astral_neureka_select();
80+
neureka_astral_hci_setpriority_neureka();
81+
neureka_astral_hci_set_max_stall(conf->max_stall);
82+
}
83+
84+
void neureka_astral_close() {
85+
neureka_astral_cg_disable();
86+
neureka_astral_neureka_unselect();
87+
neureka_astral_hci_reset_max_stall();
88+
neureka_astral_hci_setpriority_core();
89+
}
90+
91+
void neureka_astral_event_wait_and_clear() {
92+
eu_evt_maskWaitAndClr(NEUREKA_ASTRAL_EVENT);
93+
}
94+
95+
static const neureka_dev_t neureka_astral_dev = {
96+
.hwpe_dev = (struct hwpe_dev_t){
97+
.base_addr = (volatile uint32_t *)NEUREKA_ASTRAL_BASE_ADDR}};
98+
99+
const neureka_dev_t *neureka_astral_get_dev() {
100+
return &neureka_astral_dev;
101+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Luka Macan <[email protected]>
3+
*
4+
* Copyright 2023 ETH Zurich and University of Bologna
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* SPDX-License-Identifier: Apache-2.0
19+
*/
20+
21+
#ifndef __NEUREKA_ASTRAL_BSP_H__
22+
#define __NEUREKA_ASTRAL_BSP_H__
23+
24+
#include "neureka.h"
25+
#include <stdint.h>
26+
27+
/**
28+
* neureka_astral_setpriority_neureka
29+
*
30+
* Set HCI interconnect bus priority to prioritize neureka.
31+
*/
32+
void neureka_astral_hci_setpriority_neureka();
33+
34+
/**
35+
* neureka_astral_setpriority_core
36+
*
37+
* Set HCI bus priority to prioritize cores.
38+
*/
39+
void neureka_astral_hci_setpriority_core();
40+
41+
/**
42+
* neureka_astral_hci_reset_maxstall
43+
*
44+
* Reset the HCI bus maxstall parameter.
45+
* TODO: Check if it disables it also or just resets?
46+
*/
47+
void neureka_astral_hci_reset_max_stall();
48+
49+
/**
50+
* neureka_astral_hci_set_maxstall
51+
*
52+
* Set the HCI bus maxstall. Maxstall defines how many cycles
53+
* will the HCI bus stall the lower priority master, i.e. neureka or core,
54+
* before letting it do a transaction.
55+
*/
56+
void neureka_astral_hci_set_max_stall(uint32_t max_stall);
57+
58+
typedef struct neureka_astral_conf_t {
59+
int max_stall;
60+
} neureka_astral_conf_t;
61+
62+
void neureka_astral_open(neureka_astral_conf_t *conf);
63+
void neureka_astral_close();
64+
void neureka_astral_event_wait_and_clear();
65+
const neureka_dev_t *neureka_astral_get_dev();
66+
67+
#endif // !__NEUREKA_ASTRAL_BSP_H__

neureka/bsp/neureka_bsp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
#define neureka_bsp_open neureka_testbench_open
55
#define neureka_bsp_close neureka_testbench_close
66
#define neureka_bsp_event_wait_and_clear neureka_testbench_event_wait_and_clear
7+
#elif NNX_NEUREKA_ASTRAL
8+
#include "neureka_astral_bsp.h"
9+
#define neureka_bsp_conf_t neureka_astral_conf_t
10+
#define neureka_bsp_open neureka_astral_open
11+
#define neureka_bsp_close neureka_astral_close
12+
#define neureka_bsp_event_wait_and_clear neureka_astral_event_wait_and_clear
713
#else
814
#include "neureka_siracusa_bsp.h"
915
#define neureka_bsp_conf_t neureka_siracusa_conf_t
1016
#define neureka_bsp_open neureka_siracusa_open
1117
#define neureka_bsp_close neureka_siracusa_close
1218
#define neureka_bsp_event_wait_and_clear neureka_siracusa_event_wait_and_clear
13-
#endif
19+
#endif

0 commit comments

Comments
 (0)