Skip to content

Conversation

@MulinChao
Copy link
Contributor

@MulinChao MulinChao commented May 17, 2022

Config pwm open-drain mode without enabling STORE_REG. This CL
collects all active PWM's base address and related index in an
array. Then, pinctrl driver configs its open-drain mode by
finding the corresponding 'channel' index.

Signed-off-by: Mulin Chao [email protected]

Fixes #45795

@github-actions github-actions bot added area: Devicetree area: Devicetree Binding PR modifies or adds a Device Tree binding labels May 17, 2022
Copy link
Contributor

@keith-zephyr keith-zephyr left a comment

Choose a reason for hiding this comment

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

Because the open-drain support is limited to the PWM channels, I'm good with this approach and I like the saving from disabling CONFIG_PINCTRL_STORE_REG

Copy link
Contributor

Choose a reason for hiding this comment

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

The PWM nodes should set the channel property, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, drive-supported is useless now. Helper macro checks whether channel property exists. If so, the driver will create an item for pwm drive mode configuration automatically.

Copy link
Member

@gmarull gmarull May 17, 2022

Choose a reason for hiding this comment

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

note: channel seems to be computable like this:

channel = (my_pwm_addr - DT_REG_ADDR(DT_NODELABEL(pwm0))) >> 13U;

(should potentially allow you to save some ROM)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a saving ROM usage point of view, adding a new property in DT node has no harm. There are two benefits to add a channel property.

  1. Helper macro will check the peripheral node is pwm device node or not. It prevents the unexpected behavior if users enable open-drain property in the wrong pinctrl node.
  2. Currently, the offset for each pwm module is 0x2000. But I cannot make sure it won't be broken if designers run out of memory space. (For example, the new pwm register address is overlapped within the other existed module.) It happened before.

@MulinChao MulinChao marked this pull request as ready for review May 18, 2022 01:07
@MulinChao
Copy link
Contributor Author

MulinChao commented May 18, 2022

Hi @keith-zephyr and @gmarull, this is the other attempt to config pwm open-drain mode in npcx pinctrl driver. This approach saves more ROM usage. Any comment is appreciated.

Config pwm open-drain mode without enabling STORE_REG. This CL
collects all active PWM's base address and related index in an
array. Then, pinctrl driver configs its open-drain mode by
finding the corresponding 'channel' index.

Signed-off-by: Mulin Chao <[email protected]>
@gmarull gmarull added this to the v3.1.0 milestone May 19, 2022
@gmarull
Copy link
Member

gmarull commented May 19, 2022

@MulinChao since we're in stabilization period for 3.1 and this is resolving an issue, please file a bug report so that it can be merged without the need for an exception.

@MulinChao
Copy link
Contributor Author

@MulinChao since we're in stabilization period for 3.1 and this is resolving an issue, please file a bug report so that it can be merged without the need for an exception.

Hi @gmarull, I have created an issue 45795 for merging this PR during the stabilization period. Thanks for sharing this information.

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

The twister failure looks unrelated; please try rebasing to resolve it.

Please also add "Fixes #45795" to the PR summary to automatically close the bug when the PR gets merged.

@fabiobaltieri
Copy link
Member

Hey I've rerun that step manually and somehow it passed now.

@MulinChao
Copy link
Contributor Author

The twister failure looks unrelated; please try rebasing to resolve it.

Please also add "Fixes #45795" to the PR summary to automatically close the bug when the PR gets merged.

Done. Thanks for reminding.

@carlescufi carlescufi merged commit 0f18c4c into zephyrproject-rtos:main May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

driver: pinctrl: npcx: get build error when apply pinctrl mechanism to a DT node without reg prop.

6 participants