Skip to content

drivers: pwm: siwx91x: Add siwx91x PWM driver #86056

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

Merged
merged 2 commits into from
Mar 15, 2025

Conversation

smalae
Copy link
Collaborator

@smalae smalae commented Feb 20, 2025

Implement PWM driver for siwx91x device

@zephyrbot
Copy link
Collaborator

zephyrbot commented Feb 20, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_silabs zephyrproject-rtos/hal_silabs@2ad0fd7 zephyrproject-rtos/hal_silabs@9d32354 (main) zephyrproject-rtos/[email protected]

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_silabs DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Feb 20, 2025
data->pwm_channel_config[channel].is_polarity_high)) {
return -EINVAL;
}
data->pwm_polarity = flags;
Copy link
Collaborator

Choose a reason for hiding this comment

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

data->pwm_polarity is shared between all the channels but I believe it shouldn't.

BTW, this field is probably redundant with is_polarity_(high|low):

  bool polarity_inverted = (flags == PWM_POLARITY_INVERTED);
  if (data->pwm_channel_config[channel].polarity_inverted != polarity_inverted)) {
        data->pwm_channel_config[channel].polarity_inverted = polarity_inverted;
      	ret = sl_si91x_pwm_set_output_polarity(!polarity_inverted, polarity_inverted);
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed and updated accordingly, but the polarity is the same for all the channels and cannot be independent for each channel (HW limitation). Added a comment for this constraint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am afraid it confuse the user. Don't you think we should check all the enabled active has the same polarity before enabling a new one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I guess all the channels can have the same polarity by removing the flags cell in yaml file and adding the polarity as a new and common attribute for PWM channels in yaml,
silabs,pwm_polarity:
type: int
description: |
Polarity of all the PWM channels
0 - Normal polarity
1 - Inverted polarity
This will allow user to know that all the channels share the same polarity, Your thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then, we check the flags match the DT?

Yes, it's a good idea. I suggest to do the simplest thing. It's fine as soon as the behavior is easy to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, validation of flags is done, and the code is updated accordingly.

@smalae smalae force-pushed the silabs_siwx91x_pwm_driver branch from 719b509 to 731bf46 Compare February 25, 2025 08:43
/* Function to convert prescaler value to a programmable reg value */
static int siwx91x_prescale_convert(uint8_t prescale)
{

Copy link
Collaborator

Choose a reason for hiding this comment

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

This empty line should not be there.

Copy link
Collaborator Author

@smalae smalae Feb 27, 2025

Choose a reason for hiding this comment

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

Removed

data->pwm_channel_config[channel].is_polarity_high)) {
return -EINVAL;
}
data->pwm_polarity = flags;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am afraid it confuse the user. Don't you think we should check all the enabled active has the same polarity before enabling a new one?

@smalae smalae force-pushed the silabs_siwx91x_pwm_driver branch 2 times, most recently from c991b6b to ef0ba91 Compare February 26, 2025 14:33
jhedberg
jhedberg previously approved these changes Mar 13, 2025
@jhedberg jhedberg self-assigned this Mar 13, 2025
@jerome-pouiller
Copy link
Collaborator

@smalae can you rebase your branch and update the reference to hal_silabs?

smalae added 2 commits March 14, 2025 19:22
Change PWM pin function names to align with wiseconnect 3.4.0

Signed-off-by: Sai Santhosh Malae <[email protected]>
Implement PWM driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <[email protected]>
@smalae smalae dismissed stale reviews from jhedberg and jerome-pouiller via 2930a51 March 14, 2025 13:56
@smalae smalae force-pushed the silabs_siwx91x_pwm_driver branch from ef0ba91 to 2930a51 Compare March 14, 2025 13:56
@smalae
Copy link
Collaborator Author

smalae commented Mar 14, 2025

@smalae can you rebase your branch and update the reference to hal_silabs?

Done

@zephyrbot zephyrbot removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 14, 2025
@smalae smalae requested a review from jhedberg March 14, 2025 14:00
@kartben kartben merged commit 935c8e4 into zephyrproject-rtos:main Mar 15, 2025
24 of 25 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.

6 participants