Skip to content

Silabs gpio driver #92824

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fimohame
Copy link
Contributor

@fimohame fimohame commented Jul 8, 2025

The commit enables the gpio driver for EFR series 2 devices.

@fimohame fimohame closed this Jul 8, 2025
@fimohame fimohame reopened this Jul 8, 2025
@fimohame fimohame closed this Jul 8, 2025
@fimohame fimohame reopened this Jul 8, 2025
@fimohame fimohame closed this Jul 8, 2025
@fimohame fimohame reopened this Jul 8, 2025
@fimohame fimohame force-pushed the silabs_gpio_driver branch from 74b3e13 to eca5b4b Compare July 8, 2025 10:18
@fimohame fimohame force-pushed the silabs_gpio_driver branch 3 times, most recently from 6c73c92 to e46e7bc Compare July 9, 2025 05:59
@fimohame fimohame requested a review from smalae July 9, 2025 06:04
@fimohame fimohame marked this pull request as ready for review July 10, 2025 08:05
Copy link
Contributor

@Martinhoff-maker Martinhoff-maker left a comment

Choose a reason for hiding this comment

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

I haven't gone through all the gpio_silabs.c files but in general:

  • We need to only use sl_hal_gpio functions. sl_gpio.h is already a driver in the HAL and it initializes things like clocks which we want to handle in the Zephyr driver.

  • We also need to have a new Kconfig symbol in zephyr/modules/hal_silabs/simplicity_sdk like "SILABS_SISDK_GPIO" and make changes to CMakeLists.txt accordingly. You can take inspiration from #92010

  • We should update the dtsi files for all Series 2 boards with this new GPIO driver and create an entry in the migration guide 4.3.

  • Don't forget to add a binding file for the driver.

Copy link
Contributor

@Martinhoff-maker Martinhoff-maker left a comment

Choose a reason for hiding this comment

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

As general comment, as done in gpio_silabs_siwx91x.c, it could be good to have clear device name in general : is it the parent device ( the gpio controller) or the port device rather ? than just having "dev" names everywhere.

Adding PM would be perfect also (might be part of another PR)

@@ -347,7 +347,7 @@
#size-cells = <1>;

gpioa: gpio@5003c000 {
compatible = "silabs,gecko-gpio-port";
compatible = "silabs,gecko-gpio-port","silabs,gpio-port";
Copy link
Contributor

Choose a reason for hiding this comment

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

It can become the fist one compatible driver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

endif()

if(CONFIG_SILABS_SISDK_GPIO)
zephyr_library_sources(
${DRIVER_DIR}/gpio/src/sl_gpio.c
Copy link
Contributor

Choose a reason for hiding this comment

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

is it still needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed.

PRE_KERNEL_1, CONFIG_GPIO_SILABS_COMMON_INIT_PRIORITY, \
&gpio_silabs_common_driver_api);

GPIO_CONTROLLER_INIT(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels not right to have this hardcoded value, we need to rely on device tree node. Have you tried to modify it in order to have the same logic as gpio_silabs_siwx91x.c ? Something like:

#define GPIO_CONTROLLER_INIT(idx)                                                                  \
	...........                                                                                                             \
	DEVICE_DT_INST_DEFINE(..............);                                                                \
	DT_INST_FOREACH_CHILD_STATUS_OKAY(idx, GPIO_PORT_INIT);

DT_INST_FOREACH_STATUS_OKAY(GPIO_CONTROLLER_INIT)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

}
}

static const struct gpio_driver_api gpio_silabs_port_driver_api = {
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use static DEVICE_API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

.manage_callback = gpio_silabs_port_manage_callback,
};

static const struct gpio_driver_api gpio_silabs_common_driver_api = {
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

return 0;
}

static int gpio_silabs_port_toggle_bits(const struct device *dev, uint32_t mask)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use "gpio_port_pins_t" instead of uint32_t as described in "gpio.h"
Same comment for all the other function that use the mask"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

#error GPIO_SILABS_COMMON_INIT_PRIORITY must be less than CONFIG_GPIO_INIT_PRIORITY
#endif

#if DT_NODE_HAS_PROP(id, peripheral_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we simplify this ? did we really used peripheral_id ? or should we make it mandatory ? (open question)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's actually not required

@fimohame fimohame force-pushed the silabs_gpio_driver branch from aedd2cc to 42e464b Compare July 22, 2025 12:55
@@ -253,7 +253,15 @@ zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_EMU ${EMLIB_DIR}/src/em_e
if(CONFIG_SOC_GECKO_GPIO)
zephyr_library_sources(
${EMLIB_DIR}/src/em_gpio.c
${DRIVER_DIR}/gpio/src/sl_gpio.c
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to let this line for compatibility purpose until we removed all the SOC_GECKO symbol from SimplicitySDK CMakeLists

@fimohame fimohame force-pushed the silabs_gpio_driver branch from 42e464b to 042d435 Compare July 22, 2025 15:08

menuconfig GPIO_SILABS
bool "Silabs GPIO driver"
default n
Copy link
Contributor

Choose a reason for hiding this comment

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

I just see it but normally it was set to "y" by default (look at other)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

@fimohame fimohame force-pushed the silabs_gpio_driver branch from 042d435 to e30d249 Compare July 23, 2025 09:21
fimohame added 2 commits July 23, 2025 15:35
Added the gpio driver for EFR series 2 devices.

Signed-off-by: S Mohamed Fiaz <fiaz.mohamed@silabs.com>
Added the xg29_rb4412a.overlay xg29_rb4412a.conf
configuration for GPIO API 1-pin, Basic api,
Hogs test apps.
This overlay and conf defines the configuration
needed to validate the GPIO driver on the
xg29_rb4412a board during test execution.

Signed-off-by: S Mohamed Fiaz <fiaz.mohamed@silabs.com>
@fimohame fimohame force-pushed the silabs_gpio_driver branch from e30d249 to 49ab315 Compare July 23, 2025 10:06
Copy link

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

Successfully merging this pull request may close these issues.

5 participants