-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[TOPIC-GPIO] drivers: gpio_sifive: Update for new GPIO API #19668
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
[TOPIC-GPIO] drivers: gpio_sifive: Update for new GPIO API #19668
Conversation
|
All checks are passing now. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
a064fb7 to
3c75671
Compare
|
@nategraff-sifive |
3c75671 to
693149e
Compare
|
@carlescufi rebased 👍 |
693149e to
9306d93
Compare
|
@mnkp, thanks for your feedback! I've updated the PR based on your suggestions. What do you think of the new configure? I'm setting/clearing all of the bits with the |
mnkp
left a comment
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.
Thanks! LGTM with one remark.
It would be great if you could verify that the driver is passing tests/drivers/gpio/gpio_api_1pin/ testcase. You need to run it on the board which has LED0 defined in the board DTS file.
9306d93 to
fb2acd9
Compare
|
I'm getting some test failures on |
|
One other thing I noticed while running the test is that the LED polarity is inverted from what the test thinks. The LED0 GPIO pin is on the cathode of the LED, so when the GPIO is driven low the LED is turned on. During test_gpio_pin_toggle_visual, the LED is ON when the test says it's OFF. Schematic for the HiFive1 Rev B LEDs (Go to page 3) What are the odds this is the cause of the interrupt failures in the test? |
|
According to the testcase log the interrupts are not triggered at all. Since test for The trace messages printed by the testcase are not very good at the moment since they don't print actual and expected values. I didn't do it explicitly in the testcase hoping that this issue will be solved globally. The assert macros should print actual and expected values automatically, always. Unfortunately, that's not so easy to implement. |
|
To fix the LED polarity you need to add |
|
There is one more issue I overlooked, in the |
|
I will re-review the code when the pending issues are solved. |
|
@nategraff-sifive could you address the remaining issues please? |
|
@carlescufi I'm working on it! |
Thanks Nate. |
fb2acd9 to
1dcb681
Compare
|
It would be probably best if you ask a question on #devicetree channel in Slack. Just to double check, you could run a quick test and modify and verify that after the modification the interrupts are firing correctly. |
|
The devicetree channel is a good idea, I'll ask there. So the PLIC IRQ numbers are actually offset by 12, so the change to IRQ_CONNECT is ...which doesn't work, even though the generated |
|
The weird IRQ numbers are said to be a result of multi-level IRQ handling, so the issue still lies elsewhere. |
|
I found it!
Edit: lots of stuff in the driver suffers from the assumption that gpio_irq_base does what it used to. Anyway, I have some work to do. :) |
|
Nice! Good job! :) But it reminds me that there is one more thing to fix. The |
1dcb681 to
7b7e019
Compare
|
Progress update: I just pushed a new commit with my work so far to update the driver for multi-level interrupts. It still fails all of the interrupt tests in |
|
@nategraff-sifive could you fix the CI issues and reply to @mnkp 's comment above about the interrupt handling? |
7b7e019 to
2927c86
Compare
|
Clearing the pending register before enabling the GPIO interrupt didn't fix it. I'm still digging around. The problem is definitely spurious interrupts, I can confirm that the callbacks are firing too much, not too little. |
|
We rebased the topic-gpio branch against master, so this PR needs to be rebased on the updated topic-gpio branch. |
2927c86 to
b2492b7
Compare
|
Rebased on topic-gpio, still getting some spurious interrupts, still digging. |
Any luck? This is one of the few remaining GPIO drivers that needs to get converted. Thanks. |
|
@galak I have to admit I'm pretty stuck. Is it worth just disabling interrupts for this driver (which I'm pretty sure were already broken) to get the API change merged? |
|
I think that'd be appropriate. We can continue to work on it after everything's merged to master. |
b2492b7 to
ef8ef1f
Compare
Update the Sifive GPIO driver for new API Signed-off-by: Nathaniel Graff <[email protected]>
The interrupt functionality of this driver is incomplete, but for the sake of not slowing down the GPIO API refactor, I'm just returning -ENOTSUP until we can track down the issue. Signed-off-by: Nathaniel Graff <[email protected]>
ef8ef1f to
93d47fb
Compare
|
@nategraff-sifive Have you tried |
mnkp
left a comment
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.
LGTM with a minor comment.
| } | ||
|
|
||
| /* Given gpio_irq_base and the pin number, return the IRQ number for the pin */ | ||
| static inline unsigned int gpio_sifive_pin_irq(unsigned int base_irq, int pin) |
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.
In general we use static inline only for the functions placed in a header. If the function is internal to the source file it's usually better to leave the decision weather to inline a function (or not) to the compiler. If the function is small, used once the compiler will inline a function even without the inline keyword.
| #define DEV_GPIO_DATA(dev) \ | ||
| ((struct gpio_sifive_data *)(dev)->driver_data) | ||
|
|
||
| /* _irq_level and _level2_irq are copied from |
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.
Let's prefix this paragraph with TODO:.
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.
Added
|
Going ahead and merging this and will open some issues for the TODO items. |
Update the SiFive GPIO driver for the new GPIO API, including replacing deprecated flag names, implementing the
port_*API surface, and moving interrupt configuration topin_interrupt_configure.One of the drivers tracked in #18530