clk-mt8186-img.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. //
  3. // Copyright (c) 2022 MediaTek Inc.
  4. // Author: Chun-Jie Chen <[email protected]>
  5. #include <linux/clk-provider.h>
  6. #include <linux/platform_device.h>
  7. #include <dt-bindings/clock/mt8186-clk.h>
  8. #include "clk-gate.h"
  9. #include "clk-mtk.h"
  10. static const struct mtk_gate_regs img_cg_regs = {
  11. .set_ofs = 0x4,
  12. .clr_ofs = 0x8,
  13. .sta_ofs = 0x0,
  14. };
  15. #define GATE_IMG(_id, _name, _parent, _shift) \
  16. GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  17. static const struct mtk_gate img1_clks[] = {
  18. GATE_IMG(CLK_IMG1_LARB9_IMG1, "img1_larb9_img1", "top_img1", 0),
  19. GATE_IMG(CLK_IMG1_LARB10_IMG1, "img1_larb10_img1", "top_img1", 1),
  20. GATE_IMG(CLK_IMG1_DIP, "img1_dip", "top_img1", 2),
  21. GATE_IMG(CLK_IMG1_GALS_IMG1, "img1_gals_img1", "top_img1", 12),
  22. };
  23. static const struct mtk_gate img2_clks[] = {
  24. GATE_IMG(CLK_IMG2_LARB9_IMG2, "img2_larb9_img2", "top_img1", 0),
  25. GATE_IMG(CLK_IMG2_LARB10_IMG2, "img2_larb10_img2", "top_img1", 1),
  26. GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "top_img1", 6),
  27. GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "top_img1", 7),
  28. GATE_IMG(CLK_IMG2_MSS, "img2_mss", "top_img1", 8),
  29. GATE_IMG(CLK_IMG2_GALS_IMG2, "img2_gals_img2", "top_img1", 12),
  30. };
  31. static const struct mtk_clk_desc img1_desc = {
  32. .clks = img1_clks,
  33. .num_clks = ARRAY_SIZE(img1_clks),
  34. };
  35. static const struct mtk_clk_desc img2_desc = {
  36. .clks = img2_clks,
  37. .num_clks = ARRAY_SIZE(img2_clks),
  38. };
  39. static const struct of_device_id of_match_clk_mt8186_img[] = {
  40. {
  41. .compatible = "mediatek,mt8186-imgsys1",
  42. .data = &img1_desc,
  43. }, {
  44. .compatible = "mediatek,mt8186-imgsys2",
  45. .data = &img2_desc,
  46. }, {
  47. /* sentinel */
  48. }
  49. };
  50. static struct platform_driver clk_mt8186_img_drv = {
  51. .probe = mtk_clk_simple_probe,
  52. .remove = mtk_clk_simple_remove,
  53. .driver = {
  54. .name = "clk-mt8186-img",
  55. .of_match_table = of_match_clk_mt8186_img,
  56. },
  57. };
  58. builtin_platform_driver(clk_mt8186_img_drv);