Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saimohith-google
Copy link

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.

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]>
Comment on lines +49 to +57
value = sys_read32(config->base);

if (set) {
value |= BIT(id);
} else {
value &= ~BIT(id);
}

sys_write32(value, config->base);
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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);
Copy link
Member

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;
Copy link
Collaborator

@rruuaanng rruuaanng Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*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 = {
Copy link
Collaborator

@rruuaanng rruuaanng Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Collaborator

@rruuaanng rruuaanng Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static uint8_t num_resets = 16;
#define RESET_MAX_NUM 16

It doesn't look like it's changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants