Page MenuHomeFreeBSD

sifive_prci: Add support for the FU740 PRCI
ClosedPublic

Authored by jrtc27 on Jul 5 2021, 12:01 AM.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

sys/riscv/sifive/sifive_prci.c
229

Where does the bias of 2 come from?

235

From the clock schematic in the fu740 manual, pcieauxclk is not the child of hfpclk, but rather hfclk. I think the distinction would matter if we ever allow setting the pll clock frequency.

359–361

A lot of blank lines here... maybe lose this one?

368

So, is the generic clk_div class insufficient somehow?

sys/riscv/sifive/sifive_prci.c
229

Short answer: I used the Linux driver to infer the meaning of the register, as the manual is rather lacking in detail (though at least it documents this register unlike some of the others which are undocumented yet referred to by the Linux driver...)

The more elaborate answer is you can sort of infer this from the diagram. clktxclk is 0-250MHz and pclk is 0-125MHz, with pclk being clktxclk/N (ignoring buffers). Given the reset value of hfpclk_div is 0, that implies that 0 must mean 2 (as 250/125), and thus all values have an implicit +2 when used.

235

That's a good point, I suspect I just copied this from the divisor clock and failed to notice the subtle difference. Are we fine to assume the name of the clock in the device tree here, or do we need to make it dynamic?..

359–361

This was to mirror the style in prci_clk_pll_recalc, which I quite like as it separates out the MMIO from the normal calculation from the locking.

368

By default the real divisor is used, and you can also set a flag to have it start from 0, but there's no option to have a bias other than 0/1.

sys/riscv/sifive/sifive_prci.c
229

Yikes! Sounds good though :)

235

I think we can it assume it will be static since it appears to be defined in upstream u-boot and Linux as a fixed "hfclk".

500
512

Fix pcieauxclk parent (hfclk, not hfpclk), use explicit != NULL

This revision is now accepted and ready to land.Aug 4 2021, 2:54 PM
This revision was automatically updated to reflect the committed changes.