[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220914155035.88E45C433C1@smtp.kernel.org>
Date: Wed, 14 Sep 2022 08:50:33 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: Broadcom internal kernel review list
<bcm-kernel-feedback-list@...adcom.com>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...ux.ie>, Emma Anholt <emma@...olt.net>,
Florian Fainelli <f.fainelli@...il.com>,
Maxime Ripard <maxime@...no.tech>,
Maxime Ripard <mripard@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>
Cc: Maxime Ripard <maxime@...no.tech>,
linux-arm-kernel@...ts.infradead.org,
linux-rpi-kernel@...ts.infradead.org,
dri-devel@...ts.freedesktop.org, Dom Cobley <popcornmix@...il.com>,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/7] clk: bcm: rpi: Add a function to retrieve the maximum
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 :/
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)?
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.
> + if (!hw)
> + return 0;
> +
> + data = clk_hw_to_data(hw);
> + rpi = data->rpi;
> + ret = raspberrypi_clock_property(rpi->firmware, data,
> + RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
> + &max_rate);
Powered by blists - more mailing lists