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

DTS target integration #1975

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AndrewD
Copy link
Collaborator

@AndrewD AndrewD commented May 30, 2024

This set of changes follows on from #1972, #1973, #1974 and adds a mechanism to specify DTS information for a core from anywhere within litex.

With these changes we can generate a valid DTS for standard litex cores and custom cores without needing to hard code any support into litex_json2dts_linux.py and implements most of the concepts detailed in #1960.

@enjoy-digital any feedback on style or details would be appreciated.

@enjoy-digital
Copy link
Owner

Thanks @AndrewD, I'll have to think about the global approach for this. We also have been thinking with @trabucayre about switching to a python lib ease generation of the dts files, which could also help here.

@AndrewD
Copy link
Collaborator Author

AndrewD commented May 30, 2024

Hi @enjoy-digital,
I didn't find a python lib for dts generation. All I found was libraries to fixup a DTS (a lib from zephyr) and a few others with similar scope.

Ultimately I needed very little that is DTS specific and most was already in json2dit_zephyr so it seemed easiest to follow the pattern and leverage that.

@trabucayre
Copy link
Collaborator

Hi @AndrewD I have tried to use pylibfdt. I'm able to produces a valid dtb/dts but I haven't found how to attach a label for example.

@AndrewD AndrewD force-pushed the dts_target_integration branch from 0390945 to 70b7aed Compare May 30, 2024 23:38
@AndrewD
Copy link
Collaborator Author

AndrewD commented May 31, 2024

@enjoy-digital I've removed the python 3.10 dependency. I did notice that the litex:setup.py specifies python >= 3.7 but the CI build is with 3.9?

@enjoy-digital
Copy link
Owner

Thanks @AndrewD, I'll have a closer look at the changes but haven't had the time to think more about it yet (In the past, I merged some features in the project because I was not able to closely review things and to avoid frustrating developers, but this also created lots of headaches for me later to undo some things or do things differently to allow the project to go further). For this change, I first prefer that we have a clear vision of the direction before we start doing changes.

I would first like to rework the way .dts files are generated (with helper code or a python lib), then think about the mechanism to collect information and generate the .dts information to the .json file and then how to reuse this information to generate the .dts dynamically. If we apply this approach to the peripherals, we should also probably apply it to the CPUs. Let me think about this, discuss with @trabucayre internally and we'll get back to you.

@AndrewD AndrewD force-pushed the dts_target_integration branch from 70b7aed to eb0358e Compare June 17, 2024 23:38
@AndrewD AndrewD force-pushed the dts_target_integration branch from eb0358e to f989254 Compare July 21, 2024 05:19
@AndrewD
Copy link
Collaborator Author

AndrewD commented Jul 21, 2024

@enjoy-digital we are actively using this and have made further refinements for our own usage. I've pushed an update of the current state that has been squashed down to a few commits (without the initial experiments). Do you have any further thoughts yet?

While the impact on Litex is isolated this is now quite solid and could replace most of the hard coded nodes for modules in json2dts_linux: json2dts_zephyr could also leverage this.

@enjoy-digital
Copy link
Owner

Thanks @AndrewD. We haven't yet been able to fully think about the right approach (busy with other things and other tasks we are working on together). We'll definitly spend more time on this in September and will find a solution that will satisfy both of us. Sorry for being slow on this.

Andrew Dennison added 7 commits July 29, 2024 09:17
some dts related constants are invalid names for the
c preprocessor, so need to be excluded from code generation.
Example usage in modules to follow
add_timer() will now generate a dts entry.
spi_mmap will require target integration, for example:

    self.spi_mmap_1 = SPIMMAP(...)
    self.add_dts_node("spi_mmap_1", self.spi_mmap_1)
gpio will require target integration, for example:

    self.gpio = gpio = GPIOTristate(pads = pads)
    self.add_dts_node("gpio", gpio)

NOTE: GPIOIn and GPIOOut will generate DTS compatible with the current
Linux driver, but the existing DTS nodes for litex GPIO depart from
DTS conventions are are worth changing if there are no compatibility
concerns.
Will require target integration
@AndrewD AndrewD force-pushed the dts_target_integration branch from f989254 to 715098f Compare July 28, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants