Hi Stephen, Thanks for reviewing that series On Wed, Sep 14, 2022 at 08:50:33AM -0700, Stephen Boyd wrote: > Quoting Maxime Ripard (2022-08-15 08:31:24) > > @@ -254,6 +255,33 @@ static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw, > > return 0; > > } > > > > +unsigned long rpi_firmware_clk_get_max_rate(struct clk *clk) > > +{ > > + const struct raspberrypi_clk_data *data; > > + struct raspberrypi_clk *rpi; > > + struct clk_hw *hw; > > + u32 max_rate; > > + int ret; > > + > > + if (!clk) > > + return 0; > > + > > + hw = __clk_get_hw(clk); > > Ideally we don't add more users of this API. I should document that :/ What should be the proper way to implement this? > It begs the question though, why do we need this API to take a 'struct > clk'? Can it simply hardcode the data->id value for the clk you care > about and call rpi_firmware_property() directly (or some wrapper of it)? You mean push it down to the consumer? We will have two users of that function eventually. The KMS driver, and the codec driver that isn't upstream yet. AFAIK, both are using a different clock, so we can' really hardcode it, and duplicating it at the consumer level would be weird. > Furthermore, I wonder if even that part needs to be implemented. Why > not make a direct call to rpi_firmware_property() and get the max rate? > All of that can live in the drm driver. Making it a generic API that > takes a 'struct clk' means that it looks like any clk can be passed, > when that isn't true. It would be better to restrict it to the one use > case so that the scope of the problem doesn't grow. I understand that it > duplicates a few lines of code, but that looks like a fair tradeoff vs. > exposing an API that can be used for other clks in the future. So we'll want to have that function shared between the KMS and codec drivers eventually. The clock id used by both drivers is stored in the DT so we would create a function (outside of the clock drivers) that would parse the clocks property, get the ID, and then queries the firmware for it. Would that make sense? Maxime
Attachment:
signature.asc
Description: PGP signature