clk-mt8192-img.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. //
  3. // Copyright (c) 2021 MediaTek Inc.
  4. // Author: Chun-Jie Chen <[email protected]>
  5. #include <linux/clk-provider.h>
  6. #include <linux/of_device.h>
  7. #include <linux/platform_device.h>
  8. #include "clk-mtk.h"
  9. #include "clk-gate.h"
  10. #include <dt-bindings/clock/mt8192-clk.h>
  11. static const struct mtk_gate_regs img_cg_regs = {
  12. .set_ofs = 0x4,
  13. .clr_ofs = 0x8,
  14. .sta_ofs = 0x0,
  15. };
  16. #define GATE_IMG(_id, _name, _parent, _shift) \
  17. GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  18. static const struct mtk_gate img_clks[] = {
  19. GATE_IMG(CLK_IMG_LARB9, "img_larb9", "img1_sel", 0),
  20. GATE_IMG(CLK_IMG_LARB10, "img_larb10", "img1_sel", 1),
  21. GATE_IMG(CLK_IMG_DIP, "img_dip", "img1_sel", 2),
  22. GATE_IMG(CLK_IMG_GALS, "img_gals", "img1_sel", 12),
  23. };
  24. static const struct mtk_gate img2_clks[] = {
  25. GATE_IMG(CLK_IMG2_LARB11, "img2_larb11", "img1_sel", 0),
  26. GATE_IMG(CLK_IMG2_LARB12, "img2_larb12", "img1_sel", 1),
  27. GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "img1_sel", 6),
  28. GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "img1_sel", 7),
  29. GATE_IMG(CLK_IMG2_MSS, "img2_mss", "img1_sel", 8),
  30. GATE_IMG(CLK_IMG2_GALS, "img2_gals", "img1_sel", 12),
  31. };
  32. static const struct mtk_clk_desc img_desc = {
  33. .clks = img_clks,
  34. .num_clks = ARRAY_SIZE(img_clks),
  35. };
  36. static const struct mtk_clk_desc img2_desc = {
  37. .clks = img2_clks,
  38. .num_clks = ARRAY_SIZE(img2_clks),
  39. };
  40. static const struct of_device_id of_match_clk_mt8192_img[] = {
  41. {
  42. .compatible = "mediatek,mt8192-imgsys",
  43. .data = &img_desc,
  44. }, {
  45. .compatible = "mediatek,mt8192-imgsys2",
  46. .data = &img2_desc,
  47. }, {
  48. /* sentinel */
  49. }
  50. };
  51. static struct platform_driver clk_mt8192_img_drv = {
  52. .probe = mtk_clk_simple_probe,
  53. .remove = mtk_clk_simple_remove,
  54. .driver = {
  55. .name = "clk-mt8192-img",
  56. .of_match_table = of_match_clk_mt8192_img,
  57. },
  58. };
  59. builtin_platform_driver(clk_mt8192_img_drv);