Skip to content

Commit 7de6290

Browse files
mripardpopcornmix
authored andcommitted
clk: bcm: rpi: Add a function to retrieve the minimum
The RaspberryPi firmware can be configured by the end user using the config.txt file. Some of these options will affect the kernel capabilities, and we thus need to be able to detect it to operate reliably. One of such parameters is the core_clock parameter that allows users to setup the clocks in a way that is suitable to reach the pixel frequencies required by the 4096x2016 resolution at 60Hz and higher modes. If the user misconfigured it, then those modes will simply not work but are still likely to be picked up by the userspace, which is a poor user-experience. The kernel can't access the config.txt file directly, but one of the effect that parameter has is that the core clock frequency minimum will be raised. Thus we can infer its setup by querying the firmware for that minimum, and if it isn't ignore any of the modes that wouldn't work. We had in the past a discussion for the maximum and it was suggested to create a small, ad-hoc function to query the RaspberryPi firmware for the minimum rate a given clock has, so let's do the same here. Signed-off-by: Maxime Ripard <[email protected]>
1 parent f114ceb commit 7de6290

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,33 @@ unsigned long rpi_firmware_clk_get_max_rate(struct clk *clk)
282282
}
283283
EXPORT_SYMBOL_GPL(rpi_firmware_clk_get_max_rate);
284284

285+
unsigned long rpi_firmware_clk_get_min_rate(struct clk *clk)
286+
{
287+
const struct raspberrypi_clk_data *data;
288+
struct raspberrypi_clk *rpi;
289+
struct clk_hw *hw;
290+
u32 min_rate;
291+
int ret;
292+
293+
if (!clk)
294+
return 0;
295+
296+
hw = __clk_get_hw(clk);
297+
if (!hw)
298+
return 0;
299+
300+
data = clk_hw_to_data(hw);
301+
rpi = data->rpi;
302+
ret = raspberrypi_clock_property(rpi->firmware, data,
303+
RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
304+
&min_rate);
305+
if (ret)
306+
return 0;
307+
308+
return min_rate;
309+
}
310+
EXPORT_SYMBOL_GPL(rpi_firmware_clk_get_min_rate);
311+
285312
static const struct clk_ops raspberrypi_firmware_clk_ops = {
286313
.is_prepared = raspberrypi_fw_is_prepared,
287314
.recalc_rate = raspberrypi_fw_get_rate,

include/soc/bcm2835/raspberrypi-clocks.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55

66
#if IS_ENABLED(CONFIG_CLK_RASPBERRYPI)
77
unsigned long rpi_firmware_clk_get_max_rate(struct clk *clk);
8+
unsigned long rpi_firmware_clk_get_min_rate(struct clk *clk);
89
#else
910
static inline unsigned long rpi_firmware_clk_get_max_rate(struct clk *clk)
1011
{
1112
return ULONG_MAX;
1213
}
14+
15+
static inline unsigned long rpi_firmware_clk_get_min_rate(struct clk *clk)
16+
{
17+
return 0;
18+
}
1319
#endif
1420

1521
#endif /* __SOC_RASPBERRY_CLOCKS_H__ */

0 commit comments

Comments
 (0)