From: Stefan Wahren <stefan.wahren@i2se.com>
To: Maxime Ripard <maxime@cerno.tech>,
Daniel Vetter <daniel@ffwll.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
David Airlie <airlied@linux.ie>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Michael Turquette <mturquette@baylibre.com>,
Scott Branden <sbranden@broadcom.com>,
Stephen Boyd <sboyd@kernel.org>, Emma Anholt <emma@anholt.net>,
Ray Jui <rjui@broadcom.com>, Maxime Ripard <mripard@kernel.org>
Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, Dom Cobley <popcornmix@gmail.com>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 3/7] firmware: raspberrypi: Provide a helper to query a clock max rate
Date: Mon, 10 Oct 2022 18:52:34 +0200 [thread overview]
Message-ID: <dad7dc1b-c94a-4547-260f-5efe50d959e8@i2se.com> (raw)
In-Reply-To: <20220815-rpi-fix-4k-60-v2-3-983276b83f62@cerno.tech>
Hi Maxime,
Am 20.09.22 um 14:50 schrieb Maxime Ripard:
> The firmware allows to query for its clocks the operating range of a
> given clock. We'll need this for some drivers (KMS, in particular) to
> infer the state of some configuration options, so let's create a
> function to do so.
>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
>
> diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
> index b916e1e171f8..c4b9ea70f5a7 100644
> --- a/drivers/firmware/raspberrypi.c
> +++ b/drivers/firmware/raspberrypi.c
> @@ -228,6 +228,21 @@ static void rpi_register_clk_driver(struct device *dev)
> -1, NULL, 0);
> }
>
> +unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, unsigned int id)
> +{
> + struct rpi_firmware_clk_rate_request msg =
> + RPI_FIRMWARE_CLK_RATE_REQUEST(id);
> + int ret;
> +
> + ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
> + &msg, sizeof(msg));
> + if (ret)
> + return 0;
> +
> + return le32_to_cpu(msg.rate);
> +}
> +EXPORT_SYMBOL_GPL(rpi_firmware_clk_get_max_rate);
> +
> static void rpi_firmware_delete(struct kref *kref)
> {
> struct rpi_firmware *fw = container_of(kref, struct rpi_firmware,
> diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
> index 74c7bcc1ac2a..10248c370229 100644
> --- a/include/soc/bcm2835/raspberrypi-firmware.h
> +++ b/include/soc/bcm2835/raspberrypi-firmware.h
> @@ -154,12 +154,32 @@ enum rpi_firmware_clk_id {
> RPI_FIRMWARE_NUM_CLK_ID,
> };
>
> +/**
> + * struct rpi_firmware_clk_rate_request - Firmware Request for a rate
> + * @id: ID of the clock being queried
> + * @rate: Rate in Hertz. Set by the firmware.
> + *
> + * Used by @RPI_FIRMWARE_GET_CLOCK_RATE, @RPI_FIRMWARE_GET_CLOCK_MEASURED,
> + * @RPI_FIRMWARE_GET_MAX_CLOCK_RATE and @RPI_FIRMWARE_GET_MIN_CLOCK_RATE.
> + */
> +struct rpi_firmware_clk_rate_request {
> + __le32 id;
> + __le32 rate;
> +} __packed;
> +
> +#define RPI_FIRMWARE_CLK_RATE_REQUEST(_id) \
> + { \
> + .id = _id, \
> + }
> +
> #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE)
> int rpi_firmware_property(struct rpi_firmware *fw,
> u32 tag, void *data, size_t len);
> int rpi_firmware_property_list(struct rpi_firmware *fw,
> void *data, size_t tag_size);
> void rpi_firmware_put(struct rpi_firmware *fw);
> +unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw,
> + unsigned int id);
> struct device_node *rpi_firmware_find_node(void);
> struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node);
> struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
> @@ -179,6 +199,12 @@ static inline int rpi_firmware_property_list(struct rpi_firmware *fw,
>
> static inline void rpi_firmware_put(struct rpi_firmware *fw) { }
>
> +static inline unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw,
> + unsigned int id)
> +{
> + return UINT_MAX;
In case the driver is disabled the function return UINT_MAX, but in case
the firmware doesn't support RPI_FIRMWARE_GET_MAX_CLOCK_RATE it returns
0. This looks a little bit inconsistent to me.
> +}
> +
> static inline struct device_node *rpi_firmware_find_node(void)
> {
> return NULL;
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-10-10 16:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 12:50 [PATCH v2 0/7] drm/vc4: Fix the core clock behaviour Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 1/7] firmware: raspberrypi: Introduce rpi_firmware_find_node() Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 2/7] firmware: raspberrypi: Move the clock IDs to the firmware header Maxime Ripard
2022-09-20 16:01 ` Stefan Wahren
2022-09-21 9:17 ` Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 3/7] firmware: raspberrypi: Provide a helper to query a clock max rate Maxime Ripard
2022-09-29 0:23 ` Stephen Boyd
2022-10-10 16:52 ` Stefan Wahren [this message]
2022-09-20 12:50 ` [PATCH v2 4/7] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 5/7] drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 6/7] drm/vc4: hdmi: Add more checks for 4k resolutions Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 7/7] drm/vc4: Make sure we don't end up with a core clock too high Maxime Ripard
2022-10-10 11:44 ` [PATCH v2 0/7] drm/vc4: Fix the core clock behaviour Maxime Ripard
2022-10-10 19:07 ` Florian Fainelli
2022-10-13 8:59 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dad7dc1b-c94a-4547-260f-5efe50d959e8@i2se.com \
--to=stefan.wahren@i2se.com \
--cc=airlied@linux.ie \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=maxime@cerno.tech \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=popcornmix@gmail.com \
--cc=rjui@broadcom.com \
--cc=sboyd@kernel.org \
--cc=sbranden@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).