-
Notifications
You must be signed in to change notification settings - Fork 8.1k
tests: drivers: pinctrl: mchp: add test project #97119
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 1 commit into
zephyrproject-rtos:main
from
Zephyr4Microchip:test_pinctrl_driver_upstream
Oct 21, 2025
+159
−0
Merged
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
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 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
||
project(microchip) | ||
|
||
target_sources(app PRIVATE src/main.c ../common/test_device.c) |
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,17 @@ | ||
# Copyright (c) 2025 Microchip Technology Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
mainmenu "pinctrl microchip DT Test" | ||
|
||
source "Kconfig.zephyr" | ||
|
||
config PINCTRL_TEST_NON_STATIC | ||
bool "Access to pin control configuration" | ||
select PINCTRL_NON_STATIC | ||
help | ||
This option should be selected by unit tests that need to access the pin | ||
control configuration defined in a device driver. | ||
|
||
config TEST_PINCTRL_MCHP_SAM | ||
bool "Enable test for MCHP SAM drive strength" | ||
default y if SOC_FAMILY_MICROCHIP_SAM_D5X_E5X |
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,4 @@ | ||
# Copyright (c) 2025 Microchip Technology Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_TEST_PINCTRL_MCHP_SAM=y |
44 changes: 44 additions & 0 deletions
44
tests/drivers/pinctrl/microchip/boards/sam_e54_xpro.overlay
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,44 @@ | ||
/* | ||
* Copyright (c) 2025 Microchip Technology Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/ { | ||
test_device: test_device@0 { | ||
compatible = "vnd,pinctrl-device"; | ||
reg = <0x0 0x1>; | ||
pinctrl-0 = <&test_device_default>; | ||
pinctrl-names = "default"; | ||
}; | ||
}; | ||
|
||
&pinctrl { | ||
test_device_default: test_device_default { | ||
/* Note: the groups are just meant for testing if properties and | ||
* pins are parsed correctly, but do not necessarily represent a | ||
* feasible combination | ||
*/ | ||
group1 { | ||
pinmux = <PB16C_SERCOM5_PAD0>, | ||
<PB17C_SERCOM5_PAD1>; | ||
}; | ||
group2 { | ||
pinmux = <PC4C_SERCOM6_PAD0>; | ||
bias-pull-up; | ||
}; | ||
group3 { | ||
pinmux = <PC7C_SERCOM6_PAD3>; | ||
bias-pull-down; | ||
}; | ||
group4 { | ||
pinmux = <PC22C_SERCOM1_PAD0>; | ||
input-enable; | ||
output-enable; | ||
}; | ||
group5 { | ||
pinmux = <PC23C_SERCOM1_PAD1>; | ||
drive-strength=<1>; | ||
}; | ||
}; | ||
}; |
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,2 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_PINCTRL_TEST_NON_STATIC=y |
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,76 @@ | ||
/* | ||
* Copyright (c) 2025 Microchip Technology Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/drivers/pinctrl.h> | ||
#include <zephyr/ztest.h> | ||
|
||
/* Pin configuration for test device */ | ||
#define TEST_DEVICE DT_NODELABEL(test_device) | ||
PINCTRL_DT_DEV_CONFIG_DECLARE(TEST_DEVICE); | ||
static const struct pinctrl_dev_config *pcfg = PINCTRL_DT_DEV_CONFIG_GET(TEST_DEVICE); | ||
|
||
#define MCHP_PINCTRL_FLAG_GET(pincfg, pos) (((pincfg.pinflag) >> pos) & MCHP_PINCTRL_FLAG_MASK) | ||
|
||
ZTEST(pinctrl_mchp, test_pullup_pulldown_none) | ||
{ | ||
const struct pinctrl_state *scfg; | ||
|
||
scfg = &pcfg->states[0]; | ||
|
||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[0], MCHP_PINCTRL_PULLUP_POS), 0); | ||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[0], MCHP_PINCTRL_PULLDOWN_POS), 0); | ||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[1], MCHP_PINCTRL_PULLUP_POS), 0); | ||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[1], MCHP_PINCTRL_PULLDOWN_POS), 0); | ||
} | ||
|
||
ZTEST(pinctrl_mchp, test_pullup) | ||
{ | ||
const struct pinctrl_state *scfg; | ||
|
||
scfg = &pcfg->states[0]; | ||
|
||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[2], MCHP_PINCTRL_PULLUP_POS), 1); | ||
} | ||
|
||
ZTEST(pinctrl_mchp, test_pulldown) | ||
{ | ||
const struct pinctrl_state *scfg; | ||
|
||
scfg = &pcfg->states[0]; | ||
|
||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[3], MCHP_PINCTRL_PULLDOWN_POS), 1); | ||
} | ||
|
||
ZTEST(pinctrl_mchp, test_input_output_enable) | ||
{ | ||
const struct pinctrl_state *scfg; | ||
|
||
scfg = &pcfg->states[0]; | ||
|
||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[4], MCHP_PINCTRL_INPUTENABLE_POS), 1); | ||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[4], MCHP_PINCTRL_OUTPUTENABLE_POS), 1); | ||
} | ||
|
||
#if defined(CONFIG_TEST_PINCTRL_MCHP_SAM) | ||
ZTEST(pinctrl_mchp, test_drive_strength) | ||
{ | ||
const struct pinctrl_state *scfg; | ||
|
||
scfg = &pcfg->states[0]; | ||
|
||
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[5], MCHP_PINCTRL_DRIVESTRENGTH_POS), 1); | ||
} | ||
#endif | ||
|
||
ZTEST(pinctrl_mchp, test_apply_state) | ||
{ | ||
int ret; | ||
|
||
ret = pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT); | ||
zassert_equal(ret, 0); | ||
} | ||
|
||
ZTEST_SUITE(pinctrl_mchp, NULL, NULL, NULL, NULL, NULL); |
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,7 @@ | ||
tests: | ||
drivers.pinctrl.microchip: | ||
tags: | ||
- drivers | ||
- pinctrl | ||
platform_allow: | ||
- sam_e54_xpro |
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.