-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrea Belano
committed
Dec 10, 2024
1 parent
47baf51
commit 4becda2
Showing
3 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Luka Macan <[email protected]> | ||
* | ||
* Copyright 2023 ETH Zurich and University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "neureka_pulp_cluster_bsp.h" | ||
#include "pulp.h" | ||
|
||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_BASE_ADDR (ARCHI_CLUSTER_CTRL_ADDR) | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_OFFS 0x18 | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR \ | ||
(NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_BASE_ADDR + \ | ||
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_OFFS) | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN 0x800 | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL 0x2000 | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO 0x100 | ||
#define NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL 0xff | ||
#define NEUREKA_PULP_CLUSTER_MAX_STALL (8) | ||
#define NEUREKA_PULP_CLUSTER_EVENT (1 << 12) | ||
#define NEUREKA_PULP_CLUSTER_BASE_ADDR (ARCHI_HWCE_ADDR) | ||
|
||
void neureka_pulp_cluster_cg_enable() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |= | ||
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN; | ||
} | ||
|
||
void neureka_pulp_cluster_cg_disable() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_CG_EN; | ||
} | ||
|
||
void neureka_pulp_cluster_neureka_select() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |= | ||
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL; | ||
} | ||
|
||
void neureka_pulp_cluster_neureka_unselect() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_NEUREKA_SEL; | ||
} | ||
|
||
void neureka_pulp_cluster_hci_setpriority_neureka() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |= | ||
NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO; | ||
} | ||
|
||
void neureka_pulp_cluster_hci_setpriority_core() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO; | ||
} | ||
|
||
void neureka_pulp_cluster_hci_reset_max_stall() { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL; | ||
} | ||
|
||
void neureka_pulp_cluster_hci_set_max_stall(uint32_t max_stall) { | ||
*(volatile uint32_t *)NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_ADDR |= | ||
max_stall & NEUREKA_PULP_CLUSTER_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL; | ||
} | ||
|
||
void neureka_pulp_cluster_open(neureka_pulp_cluster_conf_t *conf) { | ||
neureka_pulp_cluster_cg_enable(); | ||
neureka_pulp_cluster_neureka_select(); | ||
neureka_pulp_cluster_hci_setpriority_neureka(); | ||
neureka_pulp_cluster_hci_set_max_stall(conf->max_stall); | ||
} | ||
|
||
void neureka_pulp_cluster_close() { | ||
neureka_pulp_cluster_cg_disable(); | ||
neureka_pulp_cluster_neureka_unselect(); | ||
neureka_pulp_cluster_hci_reset_max_stall(); | ||
neureka_pulp_cluster_hci_setpriority_core(); | ||
} | ||
|
||
void neureka_pulp_cluster_event_wait_and_clear() { | ||
eu_evt_maskWaitAndClr(NEUREKA_PULP_CLUSTER_EVENT); | ||
} | ||
|
||
static const neureka_dev_t neureka_pulp_cluster_dev = { | ||
.hwpe_dev = (struct hwpe_dev_t){ | ||
.base_addr = (volatile uint32_t *)NEUREKA_PULP_CLUSTER_BASE_ADDR}}; | ||
|
||
const neureka_dev_t *neureka_pulp_cluster_get_dev() { | ||
return &neureka_pulp_cluster_dev; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Luka Macan <[email protected]> | ||
* | ||
* Copyright 2023 ETH Zurich and University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef __NEUREKA_PULP_CLUSTER_BSP_H__ | ||
#define __NEUREKA_PULP_CLUSTER_BSP_H__ | ||
|
||
#include "neureka.h" | ||
#include <stdint.h> | ||
|
||
/** | ||
* neureka_pulp_cluster_setpriority_neureka | ||
* | ||
* Set HCI interconnect bus priority to prioritize neureka. | ||
*/ | ||
void neureka_pulp_cluster_hci_setpriority_neureka(); | ||
|
||
/** | ||
* neureka_pulp_cluster_setpriority_core | ||
* | ||
* Set HCI bus priority to prioritize cores. | ||
*/ | ||
void neureka_pulp_cluster_hci_setpriority_core(); | ||
|
||
/** | ||
* neureka_pulp_cluster_hci_reset_maxstall | ||
* | ||
* Reset the HCI bus maxstall parameter. | ||
* TODO: Check if it disables it also or just resets? | ||
*/ | ||
void neureka_pulp_cluster_hci_reset_max_stall(); | ||
|
||
/** | ||
* neureka_pulp_cluster_hci_set_maxstall | ||
* | ||
* Set the HCI bus maxstall. Maxstall defines how many cycles | ||
* will the HCI bus stall the lower priority master, i.e. neureka or core, | ||
* before letting it do a transaction. | ||
*/ | ||
void neureka_pulp_cluster_hci_set_max_stall(uint32_t max_stall); | ||
|
||
typedef struct neureka_pulp_cluster_conf_t { | ||
int max_stall; | ||
} neureka_pulp_cluster_conf_t; | ||
|
||
void neureka_pulp_cluster_open(neureka_pulp_cluster_conf_t *conf); | ||
void neureka_pulp_cluster_close(); | ||
void neureka_pulp_cluster_event_wait_and_clear(); | ||
const neureka_dev_t *neureka_pulp_cluster_get_dev(); | ||
|
||
#endif // !__NEUREKA_PULP_CLUSTER_BSP_H__ |