Skip to content
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

drivers: Add GPIO driver for BCM2711 (Raspberry Pi 4B) #63323

Merged
merged 6 commits into from
Oct 24, 2023

Conversation

xingrz
Copy link
Member

@xingrz xingrz commented Sep 29, 2023

This PR implements a GPIO driver for the BCM2711 SoC recently introduced in #62320. It also adds an LED node for the rpi_4b board, enabling the blinky sample to work on this board.

Minor adjustments have also been made to the doc and DTS for this SoC/board to facilitate future contributions.

* defconfig is located under `boards/arm64/` instead of `boards/arm/`
* 64-bit mode (`arm_64bit=1`) is required to boot

Signed-off-by: Chen Xingyu <[email protected]>
@zephyrbot zephyrbot added area: GPIO area: Devicetree Binding PR modifies or adds a Device Tree binding area: ARM64 ARM (64-bit) Architecture labels Sep 29, 2023
@xingrz xingrz force-pushed the rpi4b-gpio branch 4 times, most recently from 1021588 to 5007722 Compare September 30, 2023 03:29
@carlocaione carlocaione requested a review from gmarull October 2, 2023 08:08
@xingrz xingrz force-pushed the rpi4b-gpio branch 3 times, most recently from 5b394c9 to b383829 Compare October 3, 2023 13:18
@xingrz xingrz changed the title Add GPIO driver for BCM2711 (Raspberry Pi 4B) drivers: Add GPIO driver for BCM2711 (Raspberry Pi 4B) Oct 3, 2023
Comment on lines 293 to 302
static int uart_bcm2711_controller_init(void)
{
IRQ_CONNECT(DT_IRQN(GPIO_BCM2711_CONTROLLER), DT_IRQ(GPIO_BCM2711_CONTROLLER, priority),
uart_bcm2711_controller_isr, NULL, 0);
irq_enable(DT_IRQN(GPIO_BCM2711_CONTROLLER));

return 0;
}

SYS_INIT(uart_bcm2711_controller_init, PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY);
Copy link
Member

Choose a reason for hiding this comment

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

If I read this correctly, SYS_INIT is not required, just define this function as part of the device definition macro and call it during driver init, there are quite a few examples in tree

Copy link
Member Author

Choose a reason for hiding this comment

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

As I explained in the commit message, the two instances of GPIO devices share the same IRQ. To the best of my knowledge, only one ISR function can be connected to a specific IRQ.

So the idea here is to register a 'shared' ISR function in case either one or both GPIO instances are enabled. This separate SYS_INIT function is responsible for handling the registration job.

Copy link
Member

Choose a reason for hiding this comment

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

Zephyr recently gained support for shared IRQ, please see commit 017cf89.

Copy link
Member Author

@xingrz xingrz Oct 4, 2023

Choose a reason for hiding this comment

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

It's strange that shared IRQ causes the applicaton hangs at *** Booti. I'm investigating the problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@xingrz xingrz requested a review from dcpleung as a code owner October 7, 2023 15:37
@xingrz xingrz changed the title drivers: Add GPIO driver for BCM2711 (Raspberry Pi 4B) drivers: Add L2 intmux and GPIO driver for BCM2711 (Raspberry Pi 4B) Oct 7, 2023
@xingrz xingrz marked this pull request as draft October 8, 2023 14:25
@xingrz xingrz changed the title drivers: Add L2 intmux and GPIO driver for BCM2711 (Raspberry Pi 4B) drivers: Add GPIO driver for BCM2711 (Raspberry Pi 4B) Oct 8, 2023
@xingrz xingrz marked this pull request as ready for review October 8, 2023 16:57
gmarull
gmarull previously approved these changes Oct 9, 2023
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

lgtm, nice to see native drivers. Far easier to read and of higher quality compared to bloated/crappy hal based ones.

@xingrz
Copy link
Member Author

xingrz commented Oct 9, 2023

Just found some issues on tests. I'll update later.

@xingrz xingrz marked this pull request as draft October 9, 2023 16:51
@xingrz xingrz force-pushed the rpi4b-gpio branch 5 times, most recently from 9424d40 to 5fa27b2 Compare October 11, 2023 15:18
@xingrz xingrz marked this pull request as ready for review October 11, 2023 15:56
@xingrz
Copy link
Member Author

xingrz commented Oct 11, 2023

Updated. It's ready now.

Keep aligned with `rpi_pico` board.

Signed-off-by: Chen Xingyu <[email protected]>
No reason to declare it per node, as it is almostly shared by all
peripherals.

Also introduced `DT_FREQ_M` macro for better readability.

Signed-off-by: Chen Xingyu <[email protected]>
The BCM2711 SoC exposes 58 GPIOs. The first 28 (bank 0) are accessible
to users via the 40-pin header, while the others (bank 1) are used for
controlling on-board peripherals.

This also update doc of `rpi_4b` board.

Signed-off-by: Chen Xingyu <[email protected]>
LED_ACT is the green LED at the top left corner of the RPi 4B board.

Signed-off-by: Chen Xingyu <[email protected]>
Rewrote with a more detailed procedure.

Signed-off-by: Chen Xingyu <[email protected]>
@lenghonglin
Copy link
Contributor

LGTM, And Thanks for updateing doc.

@carlocaione carlocaione assigned gmarull and unassigned carlocaione Oct 20, 2023
@carlescufi carlescufi merged commit 03e2b6a into zephyrproject-rtos:main Oct 24, 2023
19 checks passed
@xingrz xingrz deleted the rpi4b-gpio branch October 24, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM64 ARM (64-bit) Architecture area: Devicetree Binding PR modifies or adds a Device Tree binding area: GPIO area: Interrupt Controller
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants