-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Add iopctl driver for RT 3 digital platforms #81086
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
Closed
lucien-nxp
wants to merge
3
commits into
zephyrproject-rtos:main
from
nxp-upstream:develop/change-pinctrl-model-for-RT3-digital-platforms
Closed
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
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 2024 NXP | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config PINCTRL_NXP_IOPCTL | ||
| bool "IOPCTL Pin controller driver for NXP MCUs" | ||
| default y | ||
| depends on DT_HAS_NXP_RT_IOPCTL_PINCTRL_ENABLED | ||
| help | ||
| Enable pin controller driver for NXP MCUs |
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 |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| # Copyright 2022, NXP | ||
| # Copyright 2022,2024 NXP | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config PINCTRL_NXP_IOCON | ||
| bool "IOCON Pin controller driver for NXP LPC MCUs" | ||
| default y | ||
| depends on DT_HAS_NXP_LPC_IOCON_PINCTRL_ENABLED || \ | ||
| DT_HAS_NXP_LPC11U6X_PINCTRL_ENABLED || \ | ||
| DT_HAS_NXP_RT_IOCON_PINCTRL_ENABLED | ||
| DT_HAS_NXP_LPC11U6X_PINCTRL_ENABLED | ||
| help | ||
| Enable pin controller driver for NXP LPC MCUs |
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,51 @@ | ||
| /* | ||
| * Copyright 2024 NXP | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #define DT_DRV_COMPAT nxp_iopctl | ||
|
|
||
| #include <zephyr/drivers/pinctrl.h> | ||
| #include <zephyr/init.h> | ||
|
|
||
| #define OFFSET(mux) (((mux) & 0xFFF00000) >> 20) | ||
| #define INDEX(mux) (((mux) & 0xF0000) >> 16) | ||
| #define Z_PINCTRL_IOPCTL_PIN_MASK 0xFFF | ||
|
Check notice on line 14 in drivers/pinctrl/pinctrl_iopctl.c
|
||
|
|
||
| /* IOPCTL register addresses. */ | ||
| static uint32_t *iopctl[] = { | ||
| #if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl0))) | ||
| (uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl0)), | ||
| #else | ||
| NULL, | ||
| #endif | ||
| #if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl1))) | ||
| (uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl1)), | ||
| #else | ||
| NULL, | ||
| #endif | ||
| #if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl2))) | ||
| (uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl2)), | ||
| #else | ||
| NULL, | ||
| #endif | ||
| }; | ||
|
|
||
| int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg) | ||
| { | ||
| for (uint8_t i = 0; i < pin_cnt; i++) { | ||
| uint32_t pin_mux = pins[i]; | ||
| uint32_t index = INDEX(pin_mux); | ||
| uint32_t offset = OFFSET(pin_mux); | ||
|
|
||
| if (index < ARRAY_SIZE(iopctl)) { | ||
| /* Set pinmux */ | ||
| *(iopctl[index] + offset) = (pin_mux & Z_PINCTRL_IOPCTL_PIN_MASK); | ||
| } else { | ||
| return -EINVAL; | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
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,12 @@ | ||
| # Copyright 2024 NXP | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| description: IO PAD Controller (IOPCTL) | ||
|
|
||
| compatible: "nxp,iopctl" | ||
|
|
||
| include: base.yaml | ||
|
|
||
| properties: | ||
| reg: | ||
| required: true |
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
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
Oops, something went wrong.
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.
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.
Do we need to have a mask here as well? It seems like we should not be writing all the bits of the pinmux setting, since the upper bits are used for the pin/offset
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.
Yes, I have added code to use masked value to write into iopctl register. Thank you.