-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Lpc 11u6x pinctrl #44843
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
Lpc 11u6x pinctrl #44843
Conversation
|
@mbittan I am unsure if you are still active on Github, but could you test this PR against an LPCxpresso11u68 if possible? The project has a mandate to move from pinmux APIs to Linux style pin control APIs to handle pin selection by the next release, hence these changes. I do not currently have hardware to test on, so I can only verify that this patch builds for the faze and lpcxpresso11u68 targets. If the serial port input/output works correctly, as well as an application using I2C, then this PR likely works fine on hardware. |
I will test this as soon as possible |
mbittan
left a comment
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.
I tested this PR on a lpcxpresso11u68 board: everything is ok except UART which does not work. The changes I suggest fix the issue on both boards.
drivers/serial/uart_lpc11u6x.c
Outdated
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.
clkid must remain to bring the UART controller out of reset
drivers/serial/uart_lpc11u6x.c
Outdated
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.
Same here, clkid is still necessary
drivers/serial/uart_lpc11u6x.c
Outdated
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.
We can't use the instance number for this driver because all the UART controllers of the LPC11U6X are not the same.
This should work:
| PINCTRL_DT_INST_DEFINE(idx); \ | |
| PINCTRL_DT_DEFINE(DT_NODELABEL(uart##idx)); \ |
drivers/serial/uart_lpc11u6x.c
Outdated
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.
The instance number can't be used here either, this should work:
| .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \ | |
| .pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart##idx)), \ |
drivers/serial/uart_lpc11u6x.h
Outdated
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.
This can be removed too
|
@mbittan I've implemented your changes, but when testing using the LPCXpresso11u68 EVK we are not seeing output on the UART4 pins. This issue exists in this PR, and on the |
UART4 should work without any specific configuration. For example, the hello_world sample works correctly on my board (which is an LPCxpressoV2 RevC) with your updated patches and on the main branch. What revision of the board are you using ? How are you testing the UART4 on your board ?
We chose UART4 because it was accessible on the arduino connector, but I agree that it makes more sense to use UART0. Regarding the LPC11U6*-pinctrl.h files, I think it would be better it they were located in the zephyr tree. That would allow the lpc11u6x port to stay independent of the NXP HAL. |
Hi @danieldegrasse. I agree with Maxime that there may be rewards (don't ask me which ones, I'd be embarrassed) to keep the lpc11u6x support standalone (i.e. not dependent on the NXP HAL). It was part of the effort when we wrote this port. I think that the pin muxing is the same for all LPC11U6x SoCs. The only difference is the availability of pins which depends on the package size (48, 64 or 100 pins). So, IMHO, we can have a single pinctrl header file in Zephyr to hold all the definitions. Note that the LPC11U67JBD48-pinctrl.h and LPC11U68JBD100-pinctrl.h files provided by the NXP HAL are identical. And so the LPC11U67JBD48-pinctrl.h file does include definitions for pins that are not available on the 48-pin package... |
|
@mbittan @simonguinot I'll go ahead and move the header in tree. The reason that headers are currently generated per-package is due to the way the generation script used for other LPC parts (such as LPC55s69) works, and you are correct that all the LPC11u6x parts have the same pinmux settings. I am also going to move the default UART port to UART0 as part of this PR (on the LPC11u68 EVK), since that will make it simpler for new Zephyr users to get started with the platform. |
|
@mbittan can we get your feedback on the current state of this PR? I would like to get it ready and merged before the feature freeze on 5/13 |
mbittan
left a comment
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.
Looks good to me
dts/arm/nxp/nxp_lpc11u6x.dtsi
Outdated
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.
why not name this one pinctrl?
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.
The pio0 through pio2 nodes are used by the GPIO driver to determine base addresses for each IOCON port, so the compatible string for the iocon node needs to define the properties for each pio child node. Then, the child pinctrl node has its own properties, and that node has the pincontrol selection defined as children.
I believe if this node was pinctrl then the pio child nodes could not be present, because they do not contain the same properties as pin control groups (which are the children of the pinctrl node) do. Please correct me if that is wrong, because this node being named pinctrl would be cleaner.
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.
If a child has a compatible set, then it can do whatever it wants, see for example STM32/GD32 pinctrl/gpio layout.
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.
Makes sense. The only other hurdle to renaming that pin control node would be that the lpc pin control driver currently relies on the node label iocon being present in the devicetree in order to get the base address of the pin controller. I used the node label directly because like the iMX pin control, there are several different register layouts present across the SOC families with the IOCON peripheral, so there is not one shared DTS compatible string that could be used for all pin control nodes.
So I could either:
- rename the
ioconnode for all devices currently using this pin control driver (and rework the dts binding file (currently the RT600 and all LPC SOCs use this driver) - add a corner case to this driver for the LPC11u6x
personally, I would rather keep the driver and node naming as it currently is designed, but if you feel strongly about this, I can rename the iocon node across the LPC line. I would prefer not to add a corner case for the LPC11u6x, however.
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.
I think it would make more sense to make iocon the pinctrl (following stm32/gd32 layout), but this can be improved later.
simonguinot
left a comment
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.
Hi @danieldegrasse,
Thanks for this PR. It is looking good.
gmarull
left a comment
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.
please update includes, otherwise lgtm
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.
| #include <drivers/pinctrl.h> | |
| #include <zephyr/drivers/pinctrl.h> |
drivers/i2c/i2c_lpc11u6x.h
Outdated
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.
| #include <drivers/pinctrl.h> | |
| #include <zephyr/drivers/pinctrl.h> |
drivers/serial/uart_lpc11u6x.h
Outdated
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.
| #include <drivers/pinctrl.h> | |
| #include <zephyr/drivers/pinctrl.h> |
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.
| #include <devicetree.h> | |
| #include <zephyr/devicetree.h> |
add pin control definitions for LPC11u6x to LPU11u6x pinctrl binding. Signed-off-by: Daniel DeGrasse <[email protected]>
update lpc11u6x dtsi file to include required DTS nodes to support LPC pin control Signed-off-by: Daniel DeGrasse <[email protected]>
add pin control definitions to LPC11u6x soc file, to handle the lack of a HAL for this SOC. Signed-off-by: Daniel DeGrasse <[email protected]>
switch gpio driver to use pio nodes to configure pin control settings, and stop using pinmux driver within gpio driver. Signed-off-by: Daniel DeGrasse <[email protected]>
add pin control header to enable pin control support for lpc11u6x Signed-off-by: Daniel DeGrasse <[email protected]>
Update pin control driver for lpc11u6x. This SOC does not have a HAL, so fsl_clock is not available. It also lacks a slew-rate field in the IOCON register, so this property must be optional. Signed-off-by: Daniel DeGrasse <[email protected]>
add pin control definitions and nodes to faze board, which uses an LPC11u67 SOC. Signed-off-by: Daniel DeGrasse <[email protected]>
Add pin control node definitions to lpcxpresso11u68 board. Signed-off-by: Daniel DeGrasse <[email protected]>
convert lpc11u6x syscon clock driver to pin control, and remove all pinmux usage from driver and syscon dts node. Signed-off-by: Daniel DeGrasse <[email protected]>
Enable pin control for lpc11u6x i2c driver, and remove pinmux usage from board level DTS files. Signed-off-by: Daniel DeGrasse <[email protected]>
Enable pin control api for lpc11u6x serial driver, and remove pinmux api usage. Signed-off-by: Daniel DeGrasse <[email protected]>
Enable pin control for lpc11u6x soc by selecting CONFIG_PINCTRL=y. At this time no drivers are ported. Signed-off-by: Daniel DeGrasse <[email protected]>
UART0 is routed to onboard debugger on LPC11u68 EVK. Change the default console from UART4 to UART0 to enable output on the onboard debugger console. Signed-off-by: Daniel DeGrasse <[email protected]>
c1764c0
|
@gmarull headers should be updated |
Enable pin control on LPC11u6x SOCs. The following boards have been converted:
This PR is dependent on #44842, as the LPC11u6x port configuration registers are not contiguous, so calculating offsets using the port and pin is not possible.