Skip to content
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

drivers: pinctrl: silabs: Add pinctrl driver for digital bus #81865

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

asmellby
Copy link
Contributor

Silicon Labs Series 2 and newer devices do alternate function
configuration fundamentally differently from Series 0 and 1. Pin routing
is done in a centralized fashion in the GPIO peripheral, as opposed to
having ROUTE registers in every peripheral. The concept of alternate
function location numbers also does not exist, functions are directly
assigned to GPIOs by their port and pin number.

This PR adds a new pinctrl driver for devices that use DBUS.
The previous driver hard-codes pin properties such as filter
and pull-up/down in the driver itself, while the new driver leaves this up
to the user as configurable DeviceTree properties. The previous driver has
hard-coded support for UART, SPI and I2C, while the new driver has generic
support for all DBUS signals.

@asmellby
Copy link
Contributor Author

I don't fully understand the scancode failure. Is it triggering on the presence of "CC0" in the files (meaning "compare/capture channel 0", not "creative commons")?

gmarull
gmarull previously approved these changes Nov 25, 2024
Comment on lines 11 to 16
out {
pins = <USART0_TX_PC0>, <USART0_CLK_PC2>;
drive-push-pull;
output-high;
};
in {
Copy link
Member

Choose a reason for hiding this comment

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

nit: use group1, group2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@fabiobaltieri
Copy link
Member

The license check is getting confused by lines such as

#define TIMER0_CC0_PB0   SILABS_DBUS_TIMER0_CC0(1, 0)

the CC0(1,0) specifically triggers a license check

x

ideally we'd fix the script but I don't think it's worth the hassle since the whole purpose of the file is to define those as macros and on future code (the check kicks in on an new file) the code would use TIMER0_CC0_PB0 instead. I suggest merging by skipping the check.

Copy link
Contributor

@jerome-pouiller jerome-pouiller left a comment

Choose a reason for hiding this comment

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

Only cosmetics comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice documentation

#define SILABS_PINCTRL_PERIPH_BASE_MASK 0x3FF00UL
#define SILABS_PINCTRL_HAVE_EN_MASK 0x40000UL
#define SILABS_PINCTRL_EN_BIT_MASK 0xF80000UL
#define SILABS_PINCTRL_ROUTE_MASK 0x1F000000UL
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add the prefix zeros. Thus, the masks are properly aligned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a plan to split series 0/1 and series 2 in two files? Maybe silabs_s2/pinctrl_soc.h could include common/pinctrl_soc_dbus.h and silabs_s[01]/pinctrl_soc.h could include common/pinctrl_soc.h (ditto for soc_gpio.h)? That's said, this can be addressed later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that we should take a holistic look at the common/ directory now that Series 2 is diverging from 0/1. I'll do this in a followup PR.

@asmellby asmellby dismissed stale reviews from jerome-pouiller and gmarull via 6bdf57d November 27, 2024 09:59
@asmellby asmellby force-pushed the feature/dbus-pinctrl branch from e934d80 to 6bdf57d Compare November 27, 2024 09:59
Silicon Labs Series 2 and newer devices do alternate function
configuration fundamentally differently from Series 0 and 1. Pin routing
is done in a centralized fashion in the GPIO peripheral, as opposed to
having ROUTE registers in every peripheral. The concept of alternate
function location numbers also does not exist, functions are directly
assigned to GPIOs by their port and pin number.

This commit adds a new pinctrl driver for devices that use DBUS. It fully
makes use of pinctrl design principles as outlined in the Zephyr
documentation. The previous driver hard-codes pin properties such as filter
and pull-up/down in the driver itself, while the new driver leaves this up
to the user as configurable DeviceTree properties. The previous driver has
hard-coded support for UART, SPI and I2C, while the new driver has generic
support for all DBUS signals.

Signed-off-by: Aksel Skauge Mellbye <[email protected]>
Swap from silabs,gecko-pinctrl to silabs,dbus-pinctrl for all boards
with Series 2 SoCs. Explicitly declare pin properties as part of
pinctrl pinout configuration.

Signed-off-by: Aksel Skauge Mellbye <[email protected]>
The GECKO_PIN() macro does not do anything except pass the
argument through unaltered. It only serves to make DeviceTree
files more verbose. It was inconsistently used, make the .dts
files consistent by never using it.

The DBUS pinctrl driver doesn't use the port or location macros
from the gpio_gecko.h header. The pin number macro is the only
other thing defined in this header. Stop including the header on
Series 2 based boards.

Signed-off-by: Aksel Skauge Mellbye <[email protected]>
Add release note and migration guide for silabs pinctrl driver
for digital bus (dbus).

Signed-off-by: Aksel Skauge Mellbye <[email protected]>
Remove implementation of pin configuration for Series 2 devices.
The silabs,dbus-pinctrl driver should be used instead.

Signed-off-by: Aksel Skauge Mellbye <[email protected]>
@asmellby asmellby force-pushed the feature/dbus-pinctrl branch from 6bdf57d to 72fb120 Compare November 27, 2024 10:45
@asmellby
Copy link
Contributor Author

Rebased on top of main to fix gitlint issue in compliance check.

@nashif nashif merged commit 6d38b24 into zephyrproject-rtos:main Nov 28, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Pinctrl platform: Silabs Silicon Labs Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants