Skip to content

Conversation

Martinhoff-maker
Copy link
Member

@Martinhoff-maker Martinhoff-maker commented Oct 14, 2025

The goal of this PR is to transform the SoC files for the NWP (Network coprocessor) into a driver.

The node for the NWP already exists, but declaring it as a driver allows us to have a device and check device health during initialization and when other components (like WiFi or Bluetooth) need it.
I also renamed the Kconfig option from "CONFIG_WISECONNECT_NETWORK_STACK" to "CONFIG_SILABS_SIWX91X_NWP" to make it more explicit.

Currently, we don't have "default=y" for the Kconfig option because we don't want to boot up the NWP if no component will use it. Components that need it must select this option.

The first commit is quite large, but I couldn't find a way to split it while maintaining successful compilation between individual commits. Any suggestions are welcome.

I will do some cleanup of the siwx91x SoC folder on an upcoming PR.

@Martinhoff-maker Martinhoff-maker force-pushed the siwx91x-nwp-driver branch 2 times, most recently from 6d023f1 to 6064d22 Compare October 14, 2025 15:40
goto out;
}
if (IS_ENABLED(CONFIG_WISECONNECT_NETWORK_STACK)) {
if (IS_ENABLED(CONFIG_SILABS_SIWX91X_NWP)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this could be done in a further PR, but I believe the idea is to move this code in the nwp driver in the PM_ACTIONS.

@Martinhoff-maker
Copy link
Member Author

Will be moved back to the SoC folder but still as a driver. I was not aware that we can have driver outside of the driver folder.

@Martinhoff-maker Martinhoff-maker changed the title drivers: misc: Transform silabs network coprocessor SoC files into a misc driver. soc: silabs: siwx91x: Transform silabs network coprocessor (NWP) SoC files into a driver. Oct 15, 2025
@zephyrbot zephyrbot requested a review from jukkar October 15, 2025 09:53
@hermabe hermabe removed their request for review October 15, 2025 10:28

#define HCI_DEVICE_INIT(inst) \
static struct hci_config hci_config_##inst = { \
.nwp_dev = DEVICE_DT_GET(DT_INST_PARENT(0)) \
Copy link
Member

Choose a reason for hiding this comment

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

For correctness, shouldn't you use inst instead of 0 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

absolutely, that's a miss after some copy/paste.

@Martinhoff-maker
Copy link
Member Author

V2:

  • Rebased with latest upstream commit for the CI problem
  • used inst for nwp_dev init in bt_hci driver

@zephyrbot zephyrbot requested a review from jhedberg October 15, 2025 12:58
jhedberg
jhedberg previously approved these changes Oct 15, 2025
SL_SI91X_EXT_FEAT_XTAL_CLK,
}
};
}};
Copy link
Contributor

Choose a reason for hiding this comment

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

Original indentation was better.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if (memcmp(country_code, region_maps[i].codes[j],
WIFI_COUNTRY_CODE_LEN) == 0) {
if (memcmp(country_code, region_maps[i].codes[j], WIFI_COUNTRY_CODE_LEN) ==
0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Original indentation was better

Copy link
Member Author

Choose a reason for hiding this comment

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

done

"VI", "VN", "VU", "00"
/* Map "00" (world domain) to US region,
* as using the world domain is not recommended
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... maybe we should keep this comment.:

    "SG", "MX", "SV", "TC", "TH", "TT", "US", "UY", "VE", "VI", "VN", "VU",
    /* Map World Domain ("00") to US region */
    "00"

Copy link
Member Author

Choose a reason for hiding this comment

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

done

static const struct siwx91x_nwp_config siwx91x_nwp_config_##inst = { \
.config_irq = silabs_siwx91x_nwp_irq_configure_##inst, \
.power_profile = DT_ENUM_IDX(DT_DRV_INST(inst), power_profile), \
.stack_size = DT_INST_PROP(inst, stack_size)}; \
Copy link
Contributor

Choose a reason for hiding this comment

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

New line before the closing brace.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

static void silabs_siwx91x_nwp_irq_configure_##inst(const struct device *dev) \
{ \
ARG_UNUSED(dev); \
SIWX91X_NWP_IRQ_CONNECT(inst); \
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not inline the SIWX91X_NWP_IRQ_CONNECT macro?

Copy link
Member Author

Choose a reason for hiding this comment

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

no i've done it.

&expected_version.build_num);
&expected_version.rom_id, &expected_version.major, &expected_version.minor,
&expected_version.security_version, &expected_version.patch_num,
&expected_version.customer_id, &expected_version.build_num);
Copy link
Contributor

Choose a reason for hiding this comment

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

Original indentation was not so bad (aren't you the author of the original code BTW?)

Copy link
Member Author

Choose a reason for hiding this comment

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

done (yeah but clang-format didn't like it)

The goal of this patch is to switch from the nwp.c and nwp.h soc files
to the new nwp driver. During this transition, we also renamed
CONFIG_WISECONNECT_NETWORK_STACK to CONFIG_SILABS_SIWX91X_NWP which are
a better naming to let the user knows that the network coprocessor files
will be added to the compilation.

The switch from a soc file to a driver device introduce a notion of nwp
device that allows us to check for good initialization and ressources
allocation.

Before this patch, it is not possible to know if the nwp have booted
successfully or not. We can now check if the device driver is ready
or not before trying to do operation related to the nwp.

Signed-off-by: Martin Hoff <[email protected]>
The bluetooth hci on silabs siwx91x depends on the nwp
(network coprocessor). This patch allows to check for the correct
initialization of the nwp before using bt hci on siwx91x.

Signed-off-by: Martin Hoff <[email protected]>
Copy link

@henrikbrixandersen henrikbrixandersen merged commit ccd505f into zephyrproject-rtos:main Oct 17, 2025
28 checks passed
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.

7 participants