0521-clk-bcm2835-Clamp-the-PLL-s-requested-rate-to-the-ha.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 4d372013a839ae71582004fbc1aa1905c73d1497 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Wed, 28 Sep 2016 17:58:52 -0700
  4. Subject: [PATCH] clk: bcm2835: Clamp the PLL's requested rate to the hardware
  5. limits.
  6. Fixes setting low-resolution video modes on HDMI. Now the PLLH_PIX
  7. divider adjusts itself until the PLLH is within bounds.
  8. Signed-off-by: Eric Anholt <eric@anholt.net>
  9. ---
  10. drivers/clk/bcm/clk-bcm2835.c | 11 ++++-------
  11. 1 file changed, 4 insertions(+), 7 deletions(-)
  12. --- a/drivers/clk/bcm/clk-bcm2835.c
  13. +++ b/drivers/clk/bcm/clk-bcm2835.c
  14. @@ -523,8 +523,12 @@ static long bcm2835_pll_rate_from_diviso
  15. static long bcm2835_pll_round_rate(struct clk_hw *hw, unsigned long rate,
  16. unsigned long *parent_rate)
  17. {
  18. + struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  19. + const struct bcm2835_pll_data *data = pll->data;
  20. u32 ndiv, fdiv;
  21. + rate = clamp(rate, data->min_rate, data->max_rate);
  22. +
  23. bcm2835_pll_choose_ndiv_and_fdiv(rate, *parent_rate, &ndiv, &fdiv);
  24. return bcm2835_pll_rate_from_divisors(*parent_rate, ndiv, fdiv, 1);
  25. @@ -633,13 +637,6 @@ static int bcm2835_pll_set_rate(struct c
  26. u32 ana[4];
  27. int i;
  28. - if (rate < data->min_rate || rate > data->max_rate) {
  29. - dev_err(cprman->dev, "%s: rate out of spec: %lu vs (%lu, %lu)\n",
  30. - clk_hw_get_name(hw), rate,
  31. - data->min_rate, data->max_rate);
  32. - return -EINVAL;
  33. - }
  34. -
  35. if (rate > data->max_fb_rate) {
  36. use_fb_prediv = true;
  37. rate /= 2;