clk-mt6779-ipe.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2019 MediaTek Inc.
  4. * Author: Wendell Lin <wendell.lin@mediatek.com>
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/platform_device.h>
  8. #include <dt-bindings/clock/mt6779-clk.h>
  9. #include "clk-mtk.h"
  10. #include "clk-gate.h"
  11. static const struct mtk_gate_regs ipe_cg_regs = {
  12. .set_ofs = 0x0004,
  13. .clr_ofs = 0x0008,
  14. .sta_ofs = 0x0000,
  15. };
  16. #define GATE_IPE(_id, _name, _parent, _shift) \
  17. GATE_MTK(_id, _name, _parent, &ipe_cg_regs, _shift, \
  18. &mtk_clk_gate_ops_setclr)
  19. static const struct mtk_gate ipe_clks[] = {
  20. GATE_IPE(CLK_IPE_LARB7, "ipe_larb7", "ipe_sel", 0),
  21. GATE_IPE(CLK_IPE_LARB8, "ipe_larb8", "ipe_sel", 1),
  22. GATE_IPE(CLK_IPE_SMI_SUBCOM, "ipe_smi_subcom", "ipe_sel", 2),
  23. GATE_IPE(CLK_IPE_FD, "ipe_fd", "ipe_sel", 3),
  24. GATE_IPE(CLK_IPE_FE, "ipe_fe", "ipe_sel", 4),
  25. GATE_IPE(CLK_IPE_RSC, "ipe_rsc", "ipe_sel", 5),
  26. GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
  27. };
  28. static const struct of_device_id of_match_clk_mt6779_ipe[] = {
  29. { .compatible = "mediatek,mt6779-ipesys", },
  30. {}
  31. };
  32. static int clk_mt6779_ipe_probe(struct platform_device *pdev)
  33. {
  34. struct clk_onecell_data *clk_data;
  35. struct device_node *node = pdev->dev.of_node;
  36. clk_data = mtk_alloc_clk_data(CLK_IPE_NR_CLK);
  37. mtk_clk_register_gates(node, ipe_clks, ARRAY_SIZE(ipe_clks),
  38. clk_data);
  39. return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  40. }
  41. static struct platform_driver clk_mt6779_ipe_drv = {
  42. .probe = clk_mt6779_ipe_probe,
  43. .driver = {
  44. .name = "clk-mt6779-ipe",
  45. .of_match_table = of_match_clk_mt6779_ipe,
  46. },
  47. };
  48. builtin_platform_driver(clk_mt6779_ipe_drv);