Skip to content

Commit 4becda2

Browse files
author
Andrea Belano
committed
Add pulp_cluster configuration
1 parent 47baf51 commit 4becda2

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed

neureka/bsp/neureka_bsp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#define neureka_bsp_open neureka_astral_open
1111
#define neureka_bsp_close neureka_astral_close
1212
#define neureka_bsp_event_wait_and_clear neureka_astral_event_wait_and_clear
13+
#elif NNX_NEUREKA_PULP_CLUSTER
14+
#include "neureka_pulp_cluster_bsp.h"
15+
#define neureka_bsp_conf_t neureka_pulp_cluster_conf_t
16+
#define neureka_bsp_open neureka_pulp_cluster_open
17+
#define neureka_bsp_close neureka_pulp_cluster_close
18+
#define neureka_bsp_event_wait_and_clear neureka_pulp_cluster_event_wait_and_clear
1319
#else
1420
#include "neureka_siracusa_bsp.h"
1521
#define neureka_bsp_conf_t neureka_siracusa_conf_t
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_pulp_cluster_bsp.h"
22+
#include "pulp.h"
23+
24+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_BASE_ADDR (ARCHI_CLUSTER_CTRL_ADDR)
25+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_OFFS 0x18
26+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR \
27+
(NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_BASE_ADDR + \
28+
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_OFFS)
29+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN 0x800
30+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL 0x2000
31+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO 0x100
32+
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL 0xff
33+
#define NEUREKA_PULP_CLUSTER_MAX_STALL (8)
34+
#define NEUREKA_PULP_CLUSTER_EVENT (1 << 12)
35+
#define NEUREKA_PULP_CLUSTER_BASE_ADDR (ARCHI_HWCE_ADDR)
36+
37+
void neureka_pulp_cluster_cg_enable() {
38+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |=
39+
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN;
40+
}
41+
42+
void neureka_pulp_cluster_cg_disable() {
43+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &=
44+
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN;
45+
}
46+
47+
void neureka_pulp_cluster_neureka_select() {
48+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |=
49+
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL;
50+
}
51+
52+
void neureka_pulp_cluster_neureka_unselect() {
53+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &=
54+
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL;
55+
}
56+
57+
void neureka_pulp_cluster_hci_setpriority_neureka() {
58+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |=
59+
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO;
60+
}
61+
62+
void neureka_pulp_cluster_hci_setpriority_core() {
63+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &=
64+
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO;
65+
}
66+
67+
void neureka_pulp_cluster_hci_reset_max_stall() {
68+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &=
69+
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL;
70+
}
71+
72+
void neureka_pulp_cluster_hci_set_max_stall(uint32_t max_stall) {
73+
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |=
74+
max_stall & NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL;
75+
}
76+
77+
void neureka_pulp_cluster_open(neureka_pulp_cluster_conf_t *conf) {
78+
neureka_pulp_cluster_cg_enable();
79+
neureka_pulp_cluster_neureka_select();
80+
neureka_pulp_cluster_hci_setpriority_neureka();
81+
neureka_pulp_cluster_hci_set_max_stall(conf->max_stall);
82+
}
83+
84+
void neureka_pulp_cluster_close() {
85+
neureka_pulp_cluster_cg_disable();
86+
neureka_pulp_cluster_neureka_unselect();
87+
neureka_pulp_cluster_hci_reset_max_stall();
88+
neureka_pulp_cluster_hci_setpriority_core();
89+
}
90+
91+
void neureka_pulp_cluster_event_wait_and_clear() {
92+
eu_evt_maskWaitAndClr(NEUREKA_PULP_CLUSTER_EVENT);
93+
}
94+
95+
static const neureka_dev_t neureka_pulp_cluster_dev = {
96+
.hwpe_dev = (struct hwpe_dev_t){
97+
.base_addr = (volatile uint32_t *)NEUREKA_PULP_CLUSTER_BASE_ADDR}};
98+
99+
const neureka_dev_t *neureka_pulp_cluster_get_dev() {
100+
return &neureka_pulp_cluster_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_PULP_CLUSTER_BSP_H__
22+
#define __NEUREKA_PULP_CLUSTER_BSP_H__
23+
24+
#include "neureka.h"
25+
#include <stdint.h>
26+
27+
/**
28+
* neureka_pulp_cluster_setpriority_neureka
29+
*
30+
* Set HCI interconnect bus priority to prioritize neureka.
31+
*/
32+
void neureka_pulp_cluster_hci_setpriority_neureka();
33+
34+
/**
35+
* neureka_pulp_cluster_setpriority_core
36+
*
37+
* Set HCI bus priority to prioritize cores.
38+
*/
39+
void neureka_pulp_cluster_hci_setpriority_core();
40+
41+
/**
42+
* neureka_pulp_cluster_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_pulp_cluster_hci_reset_max_stall();
48+
49+
/**
50+
* neureka_pulp_cluster_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_pulp_cluster_hci_set_max_stall(uint32_t max_stall);
57+
58+
typedef struct neureka_pulp_cluster_conf_t {
59+
int max_stall;
60+
} neureka_pulp_cluster_conf_t;
61+
62+
void neureka_pulp_cluster_open(neureka_pulp_cluster_conf_t *conf);
63+
void neureka_pulp_cluster_close();
64+
void neureka_pulp_cluster_event_wait_and_clear();
65+
const neureka_dev_t *neureka_pulp_cluster_get_dev();
66+
67+
#endif // !__NEUREKA_PULP_CLUSTER_BSP_H__

0 commit comments

Comments
 (0)