-
Notifications
You must be signed in to change notification settings - Fork 7.5k
drivers: misc: ethos_u: Create the ethos_u_common for every vendor #90787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
khoa-nguyen-18
wants to merge
2
commits into
zephyrproject-rtos:main
Choose a base branch
from
renesas:support_ethos_u_common
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+183
−108
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
# Copyright (c) 2025 Renesas Electronics Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menuconfig ETHOS_U | ||
bool "Ethos-U NPU driver" | ||
select ARM_ETHOS_U | ||
help | ||
Enable Ethos-U NPU driver. | ||
|
||
if ETHOS_U | ||
|
||
config ETHOS_U_INIT_PRIORITY | ||
int "Ethos-U init priority" | ||
default KERNEL_INIT_PRIORITY_DEVICE | ||
help | ||
Ethos-U device driver initialization priority. | ||
|
||
module = ETHOS_U | ||
module-str = ethos_u | ||
source "subsys/logging/Kconfig.template.log_config" | ||
|
||
rsource "Kconfig.arm_mps3" | ||
|
||
endif # ETHOS_U |
This file contains hidden or 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,14 @@ | ||
# Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config ETHOS_U_ARM | ||
bool "Arm Ethos-U NPU driver" | ||
default y | ||
depends on DT_HAS_ARM_ETHOS_U_ENABLED | ||
help | ||
Enables Arm Ethos-U NPU driver. | ||
|
||
choice ARM_ETHOS_U_NPU_CONFIG | ||
default ARM_ETHOS_U55_128 | ||
endchoice # ARM_ETHOS_U_NPU_CONFIG |
This file contains hidden or 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 hidden or 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,102 @@ | ||
/* | ||
* SPDX-FileCopyrightText: <text>Copyright 2021-2022, 2024 Arm Limited and/or its | ||
* affiliates <open-source-office@arm.com></text> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "zephyr/sys_clock.h" | ||
#include <zephyr/device.h> | ||
#include <zephyr/devicetree.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/sys/util.h> | ||
|
||
#include <ethosu_driver.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(ethos_u, CONFIG_ETHOS_U_LOG_LEVEL); | ||
|
||
/******************************************************************************* | ||
* Re-implementation/Overrides __((weak)) symbol functions from ethosu_driver.c | ||
* To handle mutex and semaphores | ||
*******************************************************************************/ | ||
|
||
void *ethosu_mutex_create(void) | ||
{ | ||
struct k_mutex *mutex; | ||
|
||
mutex = k_malloc(sizeof(*mutex)); | ||
if (mutex == NULL) { | ||
LOG_ERR("Failed allocate mutex"); | ||
return NULL; | ||
} | ||
|
||
k_mutex_init(mutex); | ||
|
||
return (void *)mutex; | ||
} | ||
|
||
int ethosu_mutex_lock(void *mutex) | ||
{ | ||
int status; | ||
|
||
status = k_mutex_lock((struct k_mutex *)mutex, K_FOREVER); | ||
if (status != 0) { | ||
LOG_ERR("Failed to lock mutex with error - %d", status); | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int ethosu_mutex_unlock(void *mutex) | ||
{ | ||
k_mutex_unlock((struct k_mutex *)mutex); | ||
return 0; | ||
} | ||
|
||
void *ethosu_semaphore_create(void) | ||
{ | ||
struct k_sem *sem; | ||
|
||
sem = k_malloc(sizeof(*sem)); | ||
if (sem == NULL) { | ||
LOG_ERR("Failed to allocate semaphore"); | ||
return NULL; | ||
} | ||
|
||
k_sem_init(sem, 0, 100); | ||
|
||
return (void *)sem; | ||
} | ||
|
||
int ethosu_semaphore_take(void *sem, uint64_t timeout) | ||
{ | ||
int status; | ||
|
||
status = k_sem_take((struct k_sem *)sem, (timeout == ETHOSU_SEMAPHORE_WAIT_FOREVER) | ||
? K_FOREVER | ||
: Z_TIMEOUT_TICKS(timeout)); | ||
|
||
if (status != 0) { | ||
/* The Ethos-U driver expects the semaphore implementation to never fail except for | ||
* when a timeout occurs, and the current ethosu_semaphore_take implementation makes | ||
* no distinction, in terms of return codes, between a timeout and other semaphore | ||
* take failures. Also, note that a timeout is virtually indistinguishable from | ||
* other failures if the driver logging is disabled. Handling errors other than a | ||
* timeout is therefore not covered here and is deferred to the application | ||
* developer if necessary. | ||
*/ | ||
if (status != -EAGAIN) { | ||
LOG_ERR("Failed to take semaphore with error - %d", status); | ||
} | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int ethosu_semaphore_give(void *sem) | ||
{ | ||
k_sem_give((struct k_sem *)sem); | ||
return 0; | ||
} |
This file contains hidden or 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,31 @@ | ||
/* | ||
* SPDX-FileCopyrightText: <text>Copyright 2021-2022, 2024 Arm Limited and/or its | ||
* affiliates <open-source-office@arm.com></text> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_DRIVERS_MISC_ETHOS_U_ETHOS_U_COMMON_H_ | ||
#define ZEPHYR_DRIVERS_MISC_ETHOS_U_ETHOS_U_COMMON_H_ | ||
|
||
#include <ethosu_driver.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
struct ethosu_dts_info { | ||
void *base_addr; | ||
bool secure_enable; | ||
bool privilege_enable; | ||
void (*irq_config)(void); | ||
}; | ||
|
||
struct ethosu_data { | ||
struct ethosu_driver drv; | ||
}; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_DRIVERS_MISC_ETHOS_U_ETHOS_U_COMMON_H_ */ |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this Kconfig is not used