clk-mt8186-cam.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 cam_cg_regs = {
  11. .set_ofs = 0x4,
  12. .clr_ofs = 0x8,
  13. .sta_ofs = 0x0,
  14. };
  15. #define GATE_CAM(_id, _name, _parent, _shift) \
  16. GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  17. static const struct mtk_gate cam_clks[] = {
  18. GATE_CAM(CLK_CAM_LARB13, "cam_larb13", "top_cam", 0),
  19. GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "top_cam", 1),
  20. GATE_CAM(CLK_CAM_LARB14, "cam_larb14", "top_cam", 2),
  21. GATE_CAM(CLK_CAM, "cam", "top_cam", 6),
  22. GATE_CAM(CLK_CAMTG, "camtg", "top_cam", 7),
  23. GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "top_cam", 8),
  24. GATE_CAM(CLK_CAMSV1, "camsv1", "top_cam", 10),
  25. GATE_CAM(CLK_CAMSV2, "camsv2", "top_cam", 11),
  26. GATE_CAM(CLK_CAMSV3, "camsv3", "top_cam", 12),
  27. GATE_CAM(CLK_CAM_CCU0, "cam_ccu0", "top_cam", 13),
  28. GATE_CAM(CLK_CAM_CCU1, "cam_ccu1", "top_cam", 14),
  29. GATE_CAM(CLK_CAM_MRAW0, "cam_mraw0", "top_cam", 15),
  30. GATE_CAM(CLK_CAM_FAKE_ENG, "cam_fake_eng", "top_cam", 17),
  31. GATE_CAM(CLK_CAM_CCU_GALS, "cam_ccu_gals", "top_cam", 18),
  32. GATE_CAM(CLK_CAM2MM_GALS, "cam2mm_gals", "top_cam", 19),
  33. };
  34. static const struct mtk_gate cam_rawa_clks[] = {
  35. GATE_CAM(CLK_CAM_RAWA_LARBX_RAWA, "cam_rawa_larbx_rawa", "top_cam", 0),
  36. GATE_CAM(CLK_CAM_RAWA, "cam_rawa", "top_cam", 1),
  37. GATE_CAM(CLK_CAM_RAWA_CAMTG_RAWA, "cam_rawa_camtg_rawa", "top_cam", 2),
  38. };
  39. static const struct mtk_gate cam_rawb_clks[] = {
  40. GATE_CAM(CLK_CAM_RAWB_LARBX_RAWB, "cam_rawb_larbx_rawb", "top_cam", 0),
  41. GATE_CAM(CLK_CAM_RAWB, "cam_rawb", "top_cam", 1),
  42. GATE_CAM(CLK_CAM_RAWB_CAMTG_RAWB, "cam_rawb_camtg_rawb", "top_cam", 2),
  43. };
  44. static const struct mtk_clk_desc cam_desc = {
  45. .clks = cam_clks,
  46. .num_clks = ARRAY_SIZE(cam_clks),
  47. };
  48. static const struct mtk_clk_desc cam_rawa_desc = {
  49. .clks = cam_rawa_clks,
  50. .num_clks = ARRAY_SIZE(cam_rawa_clks),
  51. };
  52. static const struct mtk_clk_desc cam_rawb_desc = {
  53. .clks = cam_rawb_clks,
  54. .num_clks = ARRAY_SIZE(cam_rawb_clks),
  55. };
  56. static const struct of_device_id of_match_clk_mt8186_cam[] = {
  57. {
  58. .compatible = "mediatek,mt8186-camsys",
  59. .data = &cam_desc,
  60. }, {
  61. .compatible = "mediatek,mt8186-camsys_rawa",
  62. .data = &cam_rawa_desc,
  63. }, {
  64. .compatible = "mediatek,mt8186-camsys_rawb",
  65. .data = &cam_rawb_desc,
  66. }, {
  67. /* sentinel */
  68. }
  69. };
  70. static struct platform_driver clk_mt8186_cam_drv = {
  71. .probe = mtk_clk_simple_probe,
  72. .remove = mtk_clk_simple_remove,
  73. .driver = {
  74. .name = "clk-mt8186-cam",
  75. .of_match_table = of_match_clk_mt8186_cam,
  76. },
  77. };
  78. builtin_platform_driver(clk_mt8186_cam_drv);