002-0022-clk-mediatek-add-CLK_BYPASS_XTAL-flag-to-allow-bypas.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 907d65c5020fefc9944ec57a9e0bd66dc648823e Mon Sep 17 00:00:00 2001
  2. From: Weijie Gao <[email protected]>
  3. Date: Wed, 31 Aug 2022 19:04:59 +0800
  4. Subject: [PATCH 22/32] clk: mediatek: add CLK_BYPASS_XTAL flag to allow
  5. bypassing searching clock parent of xtal clock
  6. The mtk clock framework in u-boot uses array index for searching clock
  7. parent (kernel uses strings for search), so we need to specify a special
  8. clock with ID=0 for CLK_XTAL in u-boot.
  9. In the mt7622/mt7629 clock tree, the clocks with ID=0 never call
  10. mtk_topckgen_get_mux_rate, adn return xtal clock directly. This what we
  11. expected.
  12. However for newer chips, they may have some clocks with ID=0 not
  13. representing the xtal clock and still needs mtk_topckgen_get_mux_rate be
  14. called. Current logic will make entire clock driver not working.
  15. This patch adds a flag to indicate that whether a clock driver needs clocks
  16. with ID=0 to call mtk_topckgen_get_mux_rate.
  17. Reviewed-by: Simon Glass <[email protected]>
  18. Signed-off-by: Weijie Gao <[email protected]>
  19. ---
  20. drivers/clk/mediatek/clk-mtk.c | 4 +++-
  21. drivers/clk/mediatek/clk-mtk.h | 6 ++++++
  22. 2 files changed, 9 insertions(+), 1 deletion(-)
  23. --- a/drivers/clk/mediatek/clk-mtk.c
  24. +++ b/drivers/clk/mediatek/clk-mtk.c
  25. @@ -319,7 +319,9 @@ static ulong mtk_topckgen_get_mux_rate(s
  26. index &= mux->mux_mask << mux->mux_shift;
  27. index = index >> mux->mux_shift;
  28. - if (mux->parent[index])
  29. + if (mux->parent[index] > 0 ||
  30. + (mux->parent[index] == CLK_XTAL &&
  31. + priv->tree->flags & CLK_BYPASS_XTAL))
  32. return mtk_clk_find_parent_rate(clk, mux->parent[index],
  33. NULL);
  34. --- a/drivers/clk/mediatek/clk-mtk.h
  35. +++ b/drivers/clk/mediatek/clk-mtk.h
  36. @@ -11,6 +11,11 @@
  37. #define CLK_XTAL 0
  38. #define MHZ (1000 * 1000)
  39. +/* flags in struct mtk_clk_tree */
  40. +
  41. +/* clk id == 0 doesn't mean it's xtal clk */
  42. +#define CLK_BYPASS_XTAL BIT(0)
  43. +
  44. #define HAVE_RST_BAR BIT(0)
  45. #define CLK_DOMAIN_SCPSYS BIT(0)
  46. #define CLK_MUX_SETCLR_UPD BIT(1)
  47. @@ -197,6 +202,7 @@ struct mtk_clk_tree {
  48. const struct mtk_fixed_clk *fclks;
  49. const struct mtk_fixed_factor *fdivs;
  50. const struct mtk_composite *muxes;
  51. + u32 flags;
  52. };
  53. struct mtk_clk_priv {