clk-mt8183-mfgcfg.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2018 MediaTek Inc.
  4. // Author: Weiyi Lu <weiyi.lu@mediatek.com>
  5. #include <linux/clk-provider.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/pm_runtime.h>
  8. #include "clk-mtk.h"
  9. #include "clk-gate.h"
  10. #include <dt-bindings/clock/mt8183-clk.h>
  11. static const struct mtk_gate_regs mfg_cg_regs = {
  12. .set_ofs = 0x4,
  13. .clr_ofs = 0x8,
  14. .sta_ofs = 0x0,
  15. };
  16. #define GATE_MFG(_id, _name, _parent, _shift) \
  17. GATE_MTK(_id, _name, _parent, &mfg_cg_regs, _shift, \
  18. &mtk_clk_gate_ops_setclr)
  19. static const struct mtk_gate mfg_clks[] = {
  20. GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0)
  21. };
  22. static int clk_mt8183_mfg_probe(struct platform_device *pdev)
  23. {
  24. struct clk_onecell_data *clk_data;
  25. struct device_node *node = pdev->dev.of_node;
  26. pm_runtime_enable(&pdev->dev);
  27. clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK);
  28. mtk_clk_register_gates_with_dev(node, mfg_clks, ARRAY_SIZE(mfg_clks),
  29. clk_data, &pdev->dev);
  30. return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  31. }
  32. static const struct of_device_id of_match_clk_mt8183_mfg[] = {
  33. { .compatible = "mediatek,mt8183-mfgcfg", },
  34. {}
  35. };
  36. static struct platform_driver clk_mt8183_mfg_drv = {
  37. .probe = clk_mt8183_mfg_probe,
  38. .driver = {
  39. .name = "clk-mt8183-mfg",
  40. .of_match_table = of_match_clk_mt8183_mfg,
  41. },
  42. };
  43. builtin_platform_driver(clk_mt8183_mfg_drv);