starfive-tech / opensbi

Other
17 stars 16 forks source link

implement restart in OpenSBI #5

Open pdp7 opened 3 years ago

pdp7 commented 3 years ago

related to u-boot issue https://github.com/starfive-tech/u-boot/issues/8

BeagleV Starlight requires implement restarting PMIC via I2C in OpenSBI so that SBI reset will work. This will allow restart to work in u-boot

lbmeng commented 3 years ago

@avpatel What's your recommendataion? I have a feeling that in the future OpenSBI codes will add lots of platform specific drivers in order to support SBI reset extension.

avpatel commented 3 years ago

I agree that we will have lot of variety in reset mechanism across platforms. I suggest the following strategy to handle diversity.

For generic shutdown/reset mechanism, we can have generic syscon-like drivers similar to linux drivers/power/reset/syscon-reset/poweroff.c (Note: I am not sure about the DT bindings for these generic OpenSBI shutdown/reset drivers. We can come-up with OpenSBI specific DT bindings and document it under OpenSBI docs)

For SOC specific reset, we can have: lib/utils/reset/fdt_reset_<xyz>.c (Note: root DT node compatible string for SOC will be used for probing)

For board specific reset having soc, we can have: lib/utils/reset/fdt_reset_<xyz>_<abc>.c (Note: root DT node compatible string for board will be used for probing)

Long term we can insist platform vendors to re-use OpenSBI generic shutdown/reset drivers as much as possible.

davidlt commented 3 years ago

Here is what we do on FU740/Unmatched: https://github.com/sifive/meta-sifive/tree/2021.05/recipes-bsp/opensbi/files/unmatched

We haven't sent this for upstream review yet (I will look into it).

We use generic and SBI reset extension (but we don't have reset implemented yet, just shutdown). The files should also be renamed from "fu740" to "unmatched" as all this is board specific, not SoC. For the reset to work might also need to talk to PMIC (DA9063 IIRC) via I2C. For shutdown we have GPIO line, which is easier.

avpatel commented 3 years ago

@davidlt yes gpio based poweroff/reset could be another generic driver for OpenSBI. I checked the patches OpenSBI gpio patches and I think with some re-organization we can merge it in OpenSBI.

pdp7 commented 3 years ago

We should be able to leverage the the gpio restart work that SiFive is doing once the 3,000 pieces are made which will have GPIO63 connected to PMIC reset.