Skip to content

Commit 00a6fa4

Browse files
Farsin-Nasar-MicrochipHardevsinh-Palaniya
authored andcommitted
tests: drivers: pinctrl: mchp: added new test project
Added new test case for pinctrl Added sam_e54 overlay file, testcase.yaml, CMakeLists.txt and prj.conf Signed-off-by: farsin NASAR V A <[email protected]>
1 parent dea3651 commit 00a6fa4

File tree

7 files changed

+159
-0
lines changed

7 files changed

+159
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Microchip Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
7+
project(microchip)
8+
9+
target_sources(app PRIVATE src/main.c ../common/test_device.c)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2025 Microchip Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
mainmenu "pinctrl microchip DT Test"
5+
6+
source "Kconfig.zephyr"
7+
8+
config PINCTRL_TEST_NON_STATIC
9+
bool "Access to pin control configuration"
10+
select PINCTRL_NON_STATIC
11+
help
12+
This option should be selected by unit tests that need to access the pin
13+
control configuration defined in a device driver.
14+
15+
config TEST_PINCTRL_MCHP_SAM
16+
bool "Enable test for MCHP SAM drive strength"
17+
default y if SOC_FAMILY_MICROCHIP_SAM_D5X_E5X
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2025 Microchip Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_TEST_PINCTRL_MCHP_SAM=y
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025 Microchip Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
test_device: test_device@0 {
9+
compatible = "vnd,pinctrl-device";
10+
reg = <0x0 0x1>;
11+
pinctrl-0 = <&test_device_default>;
12+
pinctrl-names = "default";
13+
};
14+
};
15+
16+
&pinctrl {
17+
test_device_default: test_device_default {
18+
/* Note: the groups are just meant for testing if properties and
19+
* pins are parsed correctly, but do not necessarily represent a
20+
* feasible combination
21+
*/
22+
group1 {
23+
pinmux = <PB16C_SERCOM5_PAD0>,
24+
<PB17C_SERCOM5_PAD1>;
25+
};
26+
group2 {
27+
pinmux = <PC4C_SERCOM6_PAD0>;
28+
bias-pull-up;
29+
};
30+
group3 {
31+
pinmux = <PC7C_SERCOM6_PAD3>;
32+
bias-pull-down;
33+
};
34+
group4 {
35+
pinmux = <PC22C_SERCOM1_PAD0>;
36+
input-enable;
37+
output-enable;
38+
};
39+
group5 {
40+
pinmux = <PC23C_SERCOM1_PAD1>;
41+
drive-strength=<1>;
42+
};
43+
};
44+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_PINCTRL_TEST_NON_STATIC=y
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2025 Microchip Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/drivers/pinctrl.h>
8+
#include <zephyr/ztest.h>
9+
10+
/* Pin configuration for test device */
11+
#define TEST_DEVICE DT_NODELABEL(test_device)
12+
PINCTRL_DT_DEV_CONFIG_DECLARE(TEST_DEVICE);
13+
static const struct pinctrl_dev_config *pcfg = PINCTRL_DT_DEV_CONFIG_GET(TEST_DEVICE);
14+
15+
#define MCHP_PINCTRL_FLAG_GET(pincfg, pos) (((pincfg.pinflag) >> pos) & MCHP_PINCTRL_FLAG_MASK)
16+
17+
ZTEST(pinctrl_mchp, test_pullup_pulldown_none)
18+
{
19+
const struct pinctrl_state *scfg;
20+
21+
scfg = &pcfg->states[0];
22+
23+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[0], MCHP_PINCTRL_PULLUP_POS), 0);
24+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[0], MCHP_PINCTRL_PULLDOWN_POS), 0);
25+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[1], MCHP_PINCTRL_PULLUP_POS), 0);
26+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[1], MCHP_PINCTRL_PULLDOWN_POS), 0);
27+
}
28+
29+
ZTEST(pinctrl_mchp, test_pullup)
30+
{
31+
const struct pinctrl_state *scfg;
32+
33+
scfg = &pcfg->states[0];
34+
35+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[2], MCHP_PINCTRL_PULLUP_POS), 1);
36+
}
37+
38+
ZTEST(pinctrl_mchp, test_pulldown)
39+
{
40+
const struct pinctrl_state *scfg;
41+
42+
scfg = &pcfg->states[0];
43+
44+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[3], MCHP_PINCTRL_PULLDOWN_POS), 1);
45+
}
46+
47+
ZTEST(pinctrl_mchp, test_input_output_enable)
48+
{
49+
const struct pinctrl_state *scfg;
50+
51+
scfg = &pcfg->states[0];
52+
53+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[4], MCHP_PINCTRL_INPUTENABLE_POS), 1);
54+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[4], MCHP_PINCTRL_OUTPUTENABLE_POS), 1);
55+
}
56+
57+
#if defined(CONFIG_TEST_PINCTRL_MCHP_SAM)
58+
ZTEST(pinctrl_mchp, test_drive_strength)
59+
{
60+
const struct pinctrl_state *scfg;
61+
62+
scfg = &pcfg->states[0];
63+
64+
zassert_equal(MCHP_PINCTRL_FLAG_GET(scfg->pins[5], MCHP_PINCTRL_DRIVESTRENGTH_POS), 1);
65+
}
66+
#endif
67+
68+
ZTEST(pinctrl_mchp, test_apply_state)
69+
{
70+
int ret;
71+
72+
ret = pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT);
73+
zassert_equal(ret, 0);
74+
}
75+
76+
ZTEST_SUITE(pinctrl_mchp, NULL, NULL, NULL, NULL, NULL);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests:
2+
drivers.pinctrl.microchip:
3+
tags:
4+
- drivers
5+
- pinctrl
6+
platform_allow:
7+
- sam_e54_xpro

0 commit comments

Comments
 (0)