-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Kernel: Introduce a new model for writing devicetree drivers #25192
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
👀 pr-needs-review
PR needs review from a maintainer or community member
label
Oct 29, 2024
spholz
force-pushed
the
aarch64-devicetree-drivers
branch
from
October 29, 2024 20:13
1dca154
to
bd5c7d9
Compare
Hendiadyoin1
approved these changes
Oct 30, 2024
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
(am biased though)
nico
approved these changes
Nov 2, 2024
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.
Looks good.
spholz
force-pushed
the
aarch64-devicetree-drivers
branch
from
November 2, 2024 14:47
bd5c7d9
to
7cfa4a1
Compare
This will be needed in the next commit, which moves the driver init functions calling code earlier into the boot process.
Devicetree drivers are created by using the `DEVICETREE_DRIVER` macro. That macro creates a new class deriving from `DeviceTree::Driver` and inserts it into the driver init section. The driver code then has to implement the `probe` member function, which will be called if `DeviceTree::Management` finds a node with a compatible property entry that was in the array passed as the second argument to the `DEVICETREE_DRIVER` macro. The `probe` function then will check if it supports the given node and if so, registers a `DeviceTree::DeviceRecipe` at the appropriate subsystem, which will then create a device from that recipe once it is initialized. The driver can store the necessary info it got from the devicetree, such as the physical address and interrupt numbers, in the capture list of the callback lambda stored in `DeviceRecipe::create_device`. The `DeviceTree::DeviceRecipe`s are necessary, as the `probe` functions might not be able to create an instance of the actual device class, since doing so can depend on some subsystems being initialized first.
spholz
force-pushed
the
aarch64-devicetree-drivers
branch
from
November 2, 2024 15:04
7cfa4a1
to
c1460d3
Compare
This driver doesn't actually get any info (like the physical address) from the devicetree node for now.
This driver doesn't actually get any info (like the physical address) from the devicetree node for now.
spholz
force-pushed
the
aarch64-devicetree-drivers
branch
from
November 2, 2024 17:06
c1460d3
to
87adc01
Compare
github-actions
bot
removed
the
👀 pr-needs-review
PR needs review from a maintainer or community member
label
Nov 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR should make writing devicetree drivers a lot simpler and keep code duplication minimal.
This PR does not depend on #25103. But we will need that PR to actually get the physical addresses from the 'reg' properties.