-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
base: main
Are you sure you want to change the base?
Silabs gpio driver #92824
Conversation
74b3e13
to
eca5b4b
Compare
6c73c92
to
e46e7bc
Compare
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 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.
e46e7bc
to
165546d
Compare
165546d
to
aedd2cc
Compare
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.
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)
dts/arm/silabs/xg21/xg21.dtsi
Outdated
@@ -347,7 +347,7 @@ | |||
#size-cells = <1>; | |||
|
|||
gpioa: gpio@5003c000 { | |||
compatible = "silabs,gecko-gpio-port"; | |||
compatible = "silabs,gecko-gpio-port","silabs,gpio-port"; |
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.
It can become the fist one compatible driver
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.
addressed
endif() | ||
|
||
if(CONFIG_SILABS_SISDK_GPIO) | ||
zephyr_library_sources( | ||
${DRIVER_DIR}/gpio/src/sl_gpio.c |
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.
is it still needed ?
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.
addressed.
drivers/gpio/gpio_silabs.c
Outdated
PRE_KERNEL_1, CONFIG_GPIO_SILABS_COMMON_INIT_PRIORITY, \ | ||
&gpio_silabs_common_driver_api); | ||
|
||
GPIO_CONTROLLER_INIT(0) |
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.
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)
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.
addressed
drivers/gpio/gpio_silabs.c
Outdated
} | ||
} | ||
|
||
static const struct gpio_driver_api gpio_silabs_port_driver_api = { |
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.
you should use static DEVICE_API
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.
addressed
drivers/gpio/gpio_silabs.c
Outdated
.manage_callback = gpio_silabs_port_manage_callback, | ||
}; | ||
|
||
static const struct gpio_driver_api gpio_silabs_common_driver_api = { |
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 comment as above
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.
addressed
drivers/gpio/gpio_silabs.c
Outdated
return 0; | ||
} | ||
|
||
static int gpio_silabs_port_toggle_bits(const struct device *dev, uint32_t mask) |
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 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"
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.
addressed
drivers/gpio/gpio_silabs.c
Outdated
#error GPIO_SILABS_COMMON_INIT_PRIORITY must be less than CONFIG_GPIO_INIT_PRIORITY | ||
#endif | ||
|
||
#if DT_NODE_HAS_PROP(id, peripheral_id) |
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.
can't we simplify this ? did we really used peripheral_id ? or should we make it mandatory ? (open question)
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.
It's actually not required
aedd2cc
to
42e464b
Compare
@@ -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 |
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 suggest to let this line for compatibility purpose until we removed all the SOC_GECKO symbol from SimplicitySDK CMakeLists
42e464b
to
042d435
Compare
drivers/gpio/Kconfig.silabs
Outdated
|
||
menuconfig GPIO_SILABS | ||
bool "Silabs GPIO driver" | ||
default n |
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 just see it but normally it was set to "y" by default (look at other)
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.
addressed
042d435
to
e30d249
Compare
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>
e30d249
to
49ab315
Compare
|
The commit enables the gpio driver for EFR series 2 devices.