-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: reset: microchip: Add G1 reset driver #97586
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
Merged
jhedberg
merged 3 commits into
zephyrproject-rtos:main
from
Zephyr4Microchip:g1_reset_driver_upstream
Oct 21, 2025
+211
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ flash: 1024 | |
ram: 256 | ||
supported: | ||
- pinctrl | ||
- reset | ||
- shell | ||
- uart | ||
vendor: microchip |
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,9 @@ | ||
# Copyright (c) 2025 Microchip Technology Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config RESET_MCHP_RSTC_G1 | ||
bool "Microchip Reset Controller g1 peripheral driver" | ||
default y | ||
depends on DT_HAS_MICROCHIP_RSTC_G1_RESET_ENABLED | ||
help | ||
Enable RESET driver for Microchip G1. |
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,118 @@ | ||
/* | ||
* Copyright (c) 2025 Microchip Technology Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @file reset_mchp_rstc_g1.c | ||
* @brief Zephyr reset driver for Microchip G1 peripherals | ||
* | ||
* This file implements the driver for the Microchip RSTC g1 reset controller, | ||
* providing APIs to assert, deassert, toggle, and query the status of reset lines. | ||
* | ||
*/ | ||
|
||
#include <zephyr/init.h> | ||
#include <soc.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/drivers/reset.h> | ||
|
||
#define DT_DRV_COMPAT microchip_rstc_g1_reset | ||
|
||
/* Maximum number of reset lines supported by the controller */ | ||
#define MCHP_RST_LINE_MAX 8 | ||
|
||
struct reset_mchp_config { | ||
rstc_registers_t *regs; | ||
}; | ||
|
||
/** | ||
* @brief Get the status of a reset line. | ||
* | ||
* This function checks if the specified reset line is currently asserted. | ||
* | ||
* @param[in] dev Pointer to the device structure for the driver instance. | ||
* @param[in] id Reset line ID (0-7). | ||
* @param[out] status Pointer to a variable to store the status (1 = asserted, 0 = not asserted). | ||
* | ||
* @retval 0 On success. | ||
* @retval -EINVAL If the reset line ID is invalid. | ||
*/ | ||
static int reset_mchp_status(const struct device *dev, uint32_t id, uint8_t *status) | ||
{ | ||
int ret = 0; | ||
uint8_t rcause = 0; | ||
|
||
if (id >= MCHP_RST_LINE_MAX) { | ||
ret = -EINVAL; | ||
} else { | ||
rcause = (((const struct reset_mchp_config *)((dev)->config))->regs)->RSTC_RCAUSE; | ||
*status = (rcause & BIT(id)) ? 1 : 0; | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
/** | ||
* @brief Assert (activate) a reset line. | ||
* | ||
* This function asserts the specified reset line. | ||
* | ||
* @param[in] dev Pointer to the device structure for the driver instance. | ||
* @param[in] id Reset line ID. | ||
* | ||
* @retval -ENOTSUP Operation not supported by hardware. | ||
*/ | ||
static int reset_mchp_line_assert(const struct device *dev, uint32_t id) | ||
{ | ||
return -ENOTSUP; | ||
} | ||
|
||
/** | ||
* @brief Deassert (deactivate) a reset line. | ||
* | ||
* This function deasserts the specified reset line. | ||
* | ||
* @param[in] dev Pointer to the device structure for the driver instance. | ||
* @param[in] id Reset line ID. | ||
* | ||
* @retval -ENOTSUP Operation not supported by hardware. | ||
*/ | ||
static int reset_mchp_line_deassert(const struct device *dev, uint32_t id) | ||
{ | ||
return -ENOTSUP; | ||
} | ||
|
||
/** | ||
* @brief Toggle a reset line (assert then deassert). | ||
* | ||
* This function asserts and then deasserts the specified reset line, with a short delay in between. | ||
* | ||
* @param[in] dev Pointer to the device structure for the driver instance. | ||
* @param[in] id Reset line ID. | ||
* | ||
* @retval -ENOTSUP Operation not supported by hardware. | ||
*/ | ||
static int reset_mchp_line_toggle(const struct device *dev, uint32_t id) | ||
{ | ||
return -ENOTSUP; | ||
} | ||
|
||
static DEVICE_API(reset, reset_mchp_api) = { | ||
.status = reset_mchp_status, | ||
nandojve marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.line_assert = reset_mchp_line_assert, | ||
.line_deassert = reset_mchp_line_deassert, | ||
.line_toggle = reset_mchp_line_toggle, | ||
}; | ||
|
||
/* Configuration instance for the Microchip RSTC g1 reset controller */ | ||
static const struct reset_mchp_config reset_mchp_config = { | ||
.regs = (rstc_registers_t *)DT_INST_REG_ADDR(0), | ||
}; | ||
|
||
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, | ||
"Only one Microchip RSTC g1 instance is supported."); | ||
|
||
DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, &reset_mchp_config, PRE_KERNEL_1, | ||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &reset_mchp_api) |
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,20 @@ | ||
# Copyright (c) 2025 Microchip Technology Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
title: Microchip RSTC Reset driver | ||
|
||
description: | | ||
Microchip RSTC Reset driver bindings. | ||
|
||
Group g1 RSTC Reset driver supports following hardware peripherals: | ||
- module name="RSTC" id="U2239" version="4.0.0" | ||
|
||
include: base.yaml | ||
|
||
compatible: "microchip,rstc-g1-reset" | ||
|
||
properties: | ||
reg: | ||
required: true | ||
description: | | ||
Base address and size of the RSTC register block. |
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,20 @@ | ||
/* | ||
* Copyright (c) 2025 Microchip Technology Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
/** | ||
* @file mchp_reset.h | ||
* @brief Microchip Reset header | ||
* | ||
* This header defines the macros for use with the Microchip reset controller driver. | ||
*/ | ||
|
||
#ifndef INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RESET_H_ | ||
#define INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RESET_H_ | ||
|
||
#if defined(CONFIG_RESET_MCHP_RSTC_G1) | ||
#include "mchp_rstc_g1.h" | ||
#endif | ||
|
||
#endif /* INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RESET_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2025 Microchip Technology Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @file mchp_rstc_g1.h | ||
* @brief Microchip RSTC G1 reset controller header | ||
* | ||
* This header includes the Microchip RSTC G1 macro definitions. | ||
*/ | ||
|
||
#ifndef INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RSTC_G1_H_ | ||
#define INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RSTC_G1_H_ | ||
|
||
/** | ||
* @enum rstc_g1_rcause | ||
* @brief Reset cause flags for Microchip RSTC G1. | ||
* | ||
* This enumeration defines the possible reset causes as indicated by the | ||
* RSTC_RCAUSE register in the Microchip RSTC G1 reset controller. | ||
*/ | ||
enum rstc_g1_rcause { | ||
RSTC_G1_RCAUSE_POR = 0, /* Power-on Reset */ | ||
RSTC_G1_RCAUSE_BOD12 = 1, /* Brown-Out 1.2V Detector Reset */ | ||
RSTC_G1_RCAUSE_BOD33 = 2, /* Brown-Out 3.3V Detector Reset */ | ||
RSTC_G1_RCAUSE_NVM = 3, /* NVM Reset */ | ||
RSTC_G1_RCAUSE_EXT = 4, /* External Reset */ | ||
RSTC_G1_RCAUSE_WDT = 5, /* Watchdog Reset */ | ||
RSTC_G1_RCAUSE_SYST = 6, /* System Reset Request */ | ||
RSTC_G1_RCAUSE_BACKUP = 7 /* Backup Reset */ | ||
}; | ||
|
||
#endif /* INCLUDE_ZEPHYR_DRIVERS_RESET_MCHP_RSTC_G1_H_ */ |
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.
Uh oh!
There was an error while loading. Please reload this page.