Page MenuHomeFreeBSD

jh7110_gpio: Add StarFive JH7110 GPIO controller driver
ClosedPublic

Authored by jsihv_gmx.com on Dec 13 2023, 4:14 PM.
Tags
None
Referenced Files
F132351198: D43034.id158343.diff
Thu, Oct 16, 3:53 AM
Unknown Object (File)
Wed, Oct 15, 5:46 AM
Unknown Object (File)
Wed, Oct 15, 4:03 AM
Unknown Object (File)
Wed, Oct 15, 1:56 AM
Unknown Object (File)
Sat, Oct 11, 10:52 PM
Unknown Object (File)
Sat, Oct 11, 2:14 PM
Unknown Object (File)
Sat, Oct 11, 2:14 PM
Unknown Object (File)
Sat, Oct 11, 2:14 PM

Details

Summary

JH7110 GPIO driver

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jrtc27 retitled this revision from adding jh7110 gpio to jh7110_gpio: Add StarFive JH7110 GPIO controller driver.Dec 14 2023, 7:11 PM
jrtc27 edited the summary of this revision. (Show Details)

I blew up the previous fix. Now fixing the (style) fix.

This code will be adjusted to support a device tree supplied with U-Boot

Switching to another device tree. Makes no really difference for this file.

Updating clk.h's path which has been changed during this year and adding this file to files.starfive

jsihv_gmx.com changed the visibility from "Public (No Login Required)" to "No One".
jsihv_gmx.com changed the edit policy from "All Users" to "No One".
jsihv_gmx.com edited the summary of this revision. (Show Details)
jsihv_gmx.com changed the visibility from "No One" to "Public (No Login Required)".
jsihv_gmx.com changed the edit policy from "No One" to "All Users".

Revised and expanded version of the driver. Now contains methods getcaps, getname, toggle and pad configuration RW in setflags.

mhorne requested changes to this revision.Jul 11 2025, 7:06 PM
mhorne added subscribers: vexeduxr, mhorne.

Thanks for the update. Despite my many absences in the past, we should be able to move quickly on this and get it merged.

I had some WIP changes of my own on top of your previous version of the patch. Please see here: P663.

Some of the small needed fixes I've noted inline, but there is a larger structural change that is also required. In short, we should follow the common pattern for GPIO drivers by maintaining a cached copy of the pin state in memory as a struct gpio_pin array in the softc (see sc->gpio_pins in my version, or dwgpio.c).

I can quickly combine the two versions myself, if you like. But it is your work, so I would not take the honor. Let me know how you would like to proceed :)

FYI I also have a nearly-finished change implementing the fdt_pinctrl interface. This allows the driver to fetch and apply pre-configured pin state from the device tree. But this is not a blocker and can come later.

sys/riscv/starfive/jh7110_gpio.c
14–19

Please sort alphabetically.

268
281
298
311–312

And you can delete err.

319–330

We should ensure that all controller initialization is complete before possibly attaching child devices.

@vexeduxr did an audit of this recently; does this look right?

This revision now requires changes to proceed.Jul 11 2025, 7:06 PM
sys/riscv/starfive/jh7110_gpio.c
319–330

Looks good!

jsihv_gmx.com marked 7 inline comments as done.

This small update includes the proposed smaller changes.

Your larger proposition looks like a straightforward application of a generic structure from other GPIO drivers, so if you like to add it by yourself, just go ahead. I considered writing just the same thing by myself (mostly after the example of SiFive's gpio driver) but I didn't understand why those data structures would be needed for this particular driver.

This small update includes the proposed smaller changes.

Your larger proposition looks like a straightforward application of a generic structure from other GPIO drivers, so if you like to add it by yourself, just go ahead. I considered writing just the same thing by myself (mostly after the example of SiFive's gpio driver) but I didn't understand why those data structures would be needed for this particular driver.

Thanks. I will incorporate the changes and commit the result!

This revision is now accepted and ready to land.Jul 22 2025, 6:21 PM