Skip to content

Conversation

@hakehuang
Copy link
Contributor

@hakehuang hakehuang commented Dec 24, 2021

pinctrl: nxp imxrt1xxx: add pinctrl support

demo on lpuart and i2s driver.

nxp rt1xxx series has different iomuxc so we add sepcial pincontrol bindings definitions.
and for gpr registers sets we rename former pinmux to gpr, and driver can access gpr directly demoed in i2s driver

tested on imxrt1060_evk board with hello_world

add dts binding dedicated for mcux iomuxc settings

Signed-off-by: Hake Huang <[email protected]>
enable pinctrl in i2s and lpuart driver dts

Signed-off-by: Hake Huang <[email protected]>
select pinctrl by default in rt series

Signed-off-by: Hake Huang <[email protected]>
@hakehuang hakehuang changed the title pinctrl: mcux_rt1xxx pinctrl: mcux_rt1xxx: add pinctrl support for rc1xxx series Dec 24, 2021
@hakehuang
Copy link
Contributor Author

below warning in CI is a must for pinctrl

-:698: WARNING:NEW_TYPEDEFS: do not add new typedefs
#698: FILE: include/drivers/pinctrl/pinctrl_soc_mcux_rt_common.h:27:
+typedef struct pinctrl_soc_pin {

- total: 0 errors, 1 warnings, 658 lines checked

@zephyrbot zephyrbot added area: UART Universal Asynchronous Receiver-Transmitter area: Build System labels Jan 4, 2022
@dleach02 dleach02 changed the title pinctrl: mcux_rt1xxx: add pinctrl support for rc1xxx series pinctrl: mcux_rt1xxx: add pinctrl support for rt1xxx series Jan 4, 2022
Copy link
Contributor

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

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

Thanks for getting this implemented @hakehuang! Just a note: I built a version of pinctrl for the RT1xxx based off this PR (here's a link to the fork), that uses pin nodes at the SOC level as opposed to pin groupings defined at the board level. After implementing that method of pinctrl, I think your implementation may be the cleaner method, but I'm interested to hear your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move the inputOnfield parameter in the pinmux property to be a configurable value instead of part of the pin definition? My reasoning here is that the the inputOnfield property is usually given as an argument to IOMUXC_SetPinMux, where as the rest of the constants defined here are not

Copy link
Contributor Author

@hakehuang hakehuang Jan 6, 2022

Choose a reason for hiding this comment

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

looks better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this file necessary?

Copy link
Contributor Author

@hakehuang hakehuang Jan 6, 2022

Choose a reason for hiding this comment

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

yes it is not used, remove

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need address-cells and size-cells? The dts parser was giving me a warning that they were unused

Copy link
Contributor Author

@hakehuang hakehuang Jan 6, 2022

Choose a reason for hiding this comment

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

yes, they are not used for now, remove it

Copy link
Contributor

Choose a reason for hiding this comment

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

These constants are defined in the device files in the HAL, see here

Copy link
Contributor Author

@hakehuang hakehuang Jan 6, 2022

Choose a reason for hiding this comment

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

right, but dts can not include those header file. I can not find a way for it

Copy link
Contributor

Choose a reason for hiding this comment

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

does the DTS use these definitions directly? I thought it pulled from the yaml file for pinctrl, and that these constants would only be used in the C driver file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, dts does not use this, update to use sdk macros.

add pinctrl_soc required headers

Signed-off-by: Hake Huang <[email protected]>
Signed-off-by: Daniel DeGrasse <[email protected]>
add dtsi settings for rt series
dtsi use gpr to replace pinmux
nxp iomuxc has gpr which has more settings than mux and io settings
current solution is to export gpr separately and access then directly

Signed-off-by: Hake Huang <[email protected]>
Signed-off-by: Daniel DeGrasse <[email protected]>
enable pin control in board level

Signed-off-by: Hake Huang <[email protected]>
Signed-off-by: Daniel DeGrasse <[email protected]>
add pinctrl driver for rt1xxx

Signed-off-by: Hake Huang <[email protected]>
enable pinctrl in lpuart

Signed-off-by: Hake Huang <[email protected]>
enable i2s pinctrl

Signed-off-by: Hake Huang <[email protected]>
rename pinmux to gpr
different from pinmux and io settings gpr will do more IO
settings.

Signed-off-by: Hake Huang <[email protected]>
@hakehuang
Copy link
Contributor Author

Thanks for getting this implemented @hakehuang! Just a note: I built a version of pinctrl for the RT1xxx based off this PR (here's a link to the fork), that uses pin nodes at the SOC level as opposed to pin groupings defined at the board level. After implementing that method of pinctrl, I think your implementation may be the cleaner method, but I'm interested to hear your thoughts.

@danieldegrasse , I leave some comments to your commit directly, and I will close this PR, and wait for yours

@hakehuang hakehuang closed this Jan 6, 2022
@danieldegrasse
Copy link
Contributor

@hakehuang To clarify- I think your approach is probably best here, I just wanted to make my change known in case we wanted to go that direction. Do you feel that the other approach would work better for the RT parts? I prefer your approach because it feels like it will lend itself better to auto generation of DTS files

@hakehuang
Copy link
Contributor Author

hakehuang commented Jan 7, 2022

@hakehuang To clarify- I think your approach is probably best here, I just wanted to make my change known in case we wanted to go that direction. Do you feel that the other approach would work better for the RT parts? I prefer your approach because it feels like it will lend itself better to auto generation of DTS files
@danieldegrasse
from the https://docs.zephyrproject.org/latest/guides/pinctrl/index.html , there are two options to support dts, you implement option 2, and I am using option 1.
option 1:
board dts+ board_pinctrl dtsi + soc.h
option 2:
board dts + board pinctrl dtsi + soc dtsi

so the differences are:

  1. whether to generate soc.h(currently I put defines directly into pinctrl dtsi as there is no soc.h in hal for dts_root in our hal) or generate soc dtsi
  2. goup pins maybe make the code easy to maintain

@dleach02, @mmahadevan108 do you have any comments on this?

btw: I add you as code-signer, thanks for the ideas on inoutput, and header

@danieldegrasse
Copy link
Contributor

so the differences are:

  1. whether to generate soc.h(currently I put defines directly into pinctrl dtsi as there is no soc.h in hal for dts_root in our hal) or generate soc dtsi
  2. goup pins maybe make the code easy to maintain

I think that's correct, yeah. The primary differences are that the pins can no longer be grouped by peripheral, and that SOCs will have all pins defined in a dtsi file (as opposed to per board definitions). I agree that grouped pins are a big benefit to your method.

When I set out to implement my method, I felt it would better lend itself to auto generation of board level DTS files, but after comparing each approach I no longer believe that. An auto generation tool would likely be aware of the relevant registers used to configure each pin, but would not be aware of the specific DTS names we used for each pinmux node in my approach.

@hakehuang
Copy link
Contributor Author

When I set out to implement my method, I felt it would better lend itself to auto generation of board level DTS files, but after comparing each approach I no longer believe that. An auto generation tool would likely be aware of the relevant registers used to configure each pin, but would not be aware of the specific DTS names we used for each pinmux node in my approach.

@danieldegrasse so you mean like the IOMUXC_GPIO_AD_B1_09_SAI1_MCLK is not consist over each soc? so the board dts will suffer to re-implement them, and if in this case use a soc.h file would be more concise, as we only need update the board pinctrl.dtsi. am I right?

@danieldegrasse
Copy link
Contributor

@hakehuang Exactly, when moving between SOCs (or implementing a custom board) having all pinmux possibilities defined at the soc level in a dtsi file would simplify hand-coding new board pinctrl dts files.

However, if auto generation of the board level dts files became an option, then your method would work best. The reason I think that is because an autogeneration tool would always be aware of the SOC level registers used for configuring pinctrl, but would not necessarily be aware of the pinctrl node names in Zephyr. If the auto generation tool was made aware of the pinctrl node names defined at the soc level dtsi than my method would also work.

@hakehuang
Copy link
Contributor Author

If the auto generation tool was made aware of the pinctrl node names defined at the soc level dtsi than my method would also work.

@danieldegrasse , you mean IOMUXC_GPIO_AD_B1_09_SAI1_MCLK? this name is generated by the config tools for device header file, I guess those can be aligned in auto tools.

@danieldegrasse
Copy link
Contributor

@hakehuang yeah, values like IOMUXC_GPIO_AD_B1_09_SAI1_MCLK. I guess the core question is this: Are those names defined by SOC data the config tools use, or by the config tools themselves? If the names are defined by SOC data, then I think my approach will work without too much risk, since those names are unlikely to change. Otherwise, I think we should go with your method.

@hakehuang
Copy link
Contributor Author

@hakehuang yeah, values like IOMUXC_GPIO_AD_B1_09_SAI1_MCLK. I guess the core question is this: Are those names defined by SOC data the config tools use, or by the config tools themselves? If the names are defined by SOC data, then I think my approach will work without too much risk, since those names are unlikely to change. Otherwise, I think we should go with your method.

@danieldegrasse those names are defined by config tools usually default value will not change. so I think you method will always work.

@danieldegrasse
Copy link
Contributor

@hakehuang I've been working on this for a few days, and after some discussions with the config tools team I've opened #41810. The main differences are that a header file is used to define the IOMUXC constants for pinmux configuration, and the pinctrl node property names are changed to make future auto generation efforts of the board level DTSI file more viable.

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

Labels

area: API Changes to public APIs area: Boards area: Build System area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: I2S area: UART Universal Asynchronous Receiver-Transmitter platform: NXP NXP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants