clk-rk-composite.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-3-08 GuEe-GUI the first version
  9. */
  10. #include "clk-rk-composite.h"
  11. #include "clk-rk-divider.h"
  12. #include "clk-rk-gate.h"
  13. #include "clk-rk-mux.h"
  14. void rockchip_composite_clk_cell_init(struct rockchip_clk_cell *rk_cell)
  15. {
  16. struct rockchip_composite_clk_cell *composite_cell = cell_to_rockchip_composite_cell(&rk_cell->cell);
  17. rk_cell->cell.ops = &composite_cell->ops;
  18. if (rk_cell->cell.parents_nr > 1)
  19. {
  20. rockchip_mux_clk_cell_init(rk_cell);
  21. composite_cell->ops.get_parent = rockchip_mux_clk_ops.get_parent;
  22. if (!((rk_cell->mux_flags & CLK_MUX_READ_ONLY)))
  23. {
  24. composite_cell->ops.set_parent = rockchip_mux_clk_ops.set_parent;
  25. }
  26. }
  27. if (rk_cell->gate_offset >= 0)
  28. {
  29. composite_cell->ops.enable = rockchip_gate_clk_ops.enable;
  30. composite_cell->ops.disable = rockchip_gate_clk_ops.disable;
  31. composite_cell->ops.is_enabled = rockchip_gate_clk_ops.is_enabled;
  32. }
  33. if (rk_cell->div_width > 0)
  34. {
  35. composite_cell->ops.recalc_rate = clk_divider_ops.recalc_rate;
  36. composite_cell->ops.round_rate = clk_divider_ops.round_rate;
  37. if (!((rk_cell->div_flags & CLK_DIVIDER_READ_ONLY)))
  38. {
  39. composite_cell->ops.set_rate = clk_divider_ops.set_rate;
  40. }
  41. }
  42. }