224-v6.3-clk-mediatek-clk-mtk-Add-dummy-clock-ops.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From b8eb1081d267708ba976525a1fe2162901b34f3a Mon Sep 17 00:00:00 2001
  2. From: AngeloGioacchino Del Regno <[email protected]>
  3. Date: Fri, 20 Jan 2023 10:20:37 +0100
  4. Subject: [PATCH] clk: mediatek: clk-mtk: Add dummy clock ops
  5. In order to migrate some (few) old clock drivers to the common
  6. mtk_clk_simple_probe() function, add dummy clock ops to be able
  7. to insert a dummy clock with ID 0 at the beginning of the list.
  8. Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
  9. Reviewed-by: Miles Chen <[email protected]>
  10. Reviewed-by: Chen-Yu Tsai <[email protected]>
  11. Tested-by: Miles Chen <[email protected]>
  12. Link: https://lore.kernel.org/r/[email protected]
  13. Tested-by: Mingming Su <[email protected]>
  14. Signed-off-by: Stephen Boyd <[email protected]>
  15. ---
  16. drivers/clk/mediatek/clk-mtk.c | 16 ++++++++++++++++
  17. drivers/clk/mediatek/clk-mtk.h | 19 +++++++++++++++++++
  18. 2 files changed, 35 insertions(+)
  19. --- a/drivers/clk/mediatek/clk-mtk.c
  20. +++ b/drivers/clk/mediatek/clk-mtk.c
  21. @@ -18,6 +18,22 @@
  22. #include "clk-mtk.h"
  23. #include "clk-gate.h"
  24. +const struct mtk_gate_regs cg_regs_dummy = { 0, 0, 0 };
  25. +EXPORT_SYMBOL_GPL(cg_regs_dummy);
  26. +
  27. +static int mtk_clk_dummy_enable(struct clk_hw *hw)
  28. +{
  29. + return 0;
  30. +}
  31. +
  32. +static void mtk_clk_dummy_disable(struct clk_hw *hw) { }
  33. +
  34. +const struct clk_ops mtk_clk_dummy_ops = {
  35. + .enable = mtk_clk_dummy_enable,
  36. + .disable = mtk_clk_dummy_disable,
  37. +};
  38. +EXPORT_SYMBOL_GPL(mtk_clk_dummy_ops);
  39. +
  40. static void mtk_init_clk_data(struct clk_hw_onecell_data *clk_data,
  41. unsigned int clk_num)
  42. {
  43. --- a/drivers/clk/mediatek/clk-mtk.h
  44. +++ b/drivers/clk/mediatek/clk-mtk.h
  45. @@ -22,6 +22,25 @@
  46. struct platform_device;
  47. +/*
  48. + * We need the clock IDs to start from zero but to maintain devicetree
  49. + * backwards compatibility we can't change bindings to start from zero.
  50. + * Only a few platforms are affected, so we solve issues given by the
  51. + * commonized MTK clocks probe function(s) by adding a dummy clock at
  52. + * the beginning where needed.
  53. + */
  54. +#define CLK_DUMMY 0
  55. +
  56. +extern const struct clk_ops mtk_clk_dummy_ops;
  57. +extern const struct mtk_gate_regs cg_regs_dummy;
  58. +
  59. +#define GATE_DUMMY(_id, _name) { \
  60. + .id = _id, \
  61. + .name = _name, \
  62. + .regs = &cg_regs_dummy, \
  63. + .ops = &mtk_clk_dummy_ops, \
  64. + }
  65. +
  66. struct mtk_fixed_clk {
  67. int id;
  68. const char *name;