-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
drivers: reset: Add generic reset MMIO driver #87501
base: main
Are you sure you want to change the base?
Conversation
Introduce a generic reset MMIO driver to be used for devices with a single memory mapped reset bit required to take them out of reset. Signed-off-by: Mohith Potluri <[email protected]>
value = sys_read32(config->base); | ||
|
||
if (set) { | ||
value |= BIT(id); | ||
} else { | ||
value &= ~BIT(id); | ||
} | ||
|
||
sys_write32(value, config->base); |
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.
Should this be under a lock? E.g. a spinlock?
# Copyright (c) 2025 Google, LLC | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: MMIO Reset |
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.
This could use a better description.
|
||
description: MMIO Reset | ||
|
||
compatible: "zephyr,reset-mmio" |
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.
This isn't Zephyr-specific?
required: true | ||
num_resets: | ||
type: int | ||
default: 1 |
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.
Defaults need to be described in the textual description.
value &= ~BIT(id); | ||
} | ||
|
||
sys_write32(value, config->base); |
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.
what about for devices where you need to set and hold and clear the reset line instead of just set and hardware clears
|
||
/* If active low, invert the logic */ | ||
if (config->active_low) { | ||
*status = !*status; |
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.
*status = !*status; | |
*status = !(*status); |
This seems much more relaxed?
return reset_mmio_update(dev, id, !reset_status); | ||
} | ||
|
||
static const struct reset_driver_api reset_mmio_driver_api = { |
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.
static const struct reset_driver_api reset_mmio_driver_api = { | |
static DEVICE_API(reset,reset_mmio_driver_api) = { |
Use DEVICE_API
macro.
|
||
ZTEST_SUITE(reset_mmio_tests, NULL, NULL, NULL, NULL, NULL); | ||
|
||
static uint8_t num_resets = 16; |
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.
static uint8_t num_resets = 16; | |
#define RESET_MAX_NUM 16 |
It doesn't look like it's changed.
Introduce a generic reset MMIO driver to be used for devices with a single memory mapped reset bit required to take them out of reset.