clk-mt8183-cam.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "clk-mtk.h"
  8. #include "clk-gate.h"
  9. #include <dt-bindings/clock/mt8183-clk.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, \
  17. &mtk_clk_gate_ops_setclr)
  18. static const struct mtk_gate cam_clks[] = {
  19. GATE_CAM(CLK_CAM_LARB6, "cam_larb6", "cam_sel", 0),
  20. GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "cam_sel", 1),
  21. GATE_CAM(CLK_CAM_LARB3, "cam_larb3", "cam_sel", 2),
  22. GATE_CAM(CLK_CAM_CAM, "cam_cam", "cam_sel", 6),
  23. GATE_CAM(CLK_CAM_CAMTG, "cam_camtg", "cam_sel", 7),
  24. GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "cam_sel", 8),
  25. GATE_CAM(CLK_CAM_CAMSV0, "cam_camsv0", "cam_sel", 9),
  26. GATE_CAM(CLK_CAM_CAMSV1, "cam_camsv1", "cam_sel", 10),
  27. GATE_CAM(CLK_CAM_CAMSV2, "cam_camsv2", "cam_sel", 11),
  28. GATE_CAM(CLK_CAM_CCU, "cam_ccu", "cam_sel", 12),
  29. };
  30. static int clk_mt8183_cam_probe(struct platform_device *pdev)
  31. {
  32. struct clk_onecell_data *clk_data;
  33. struct device_node *node = pdev->dev.of_node;
  34. clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
  35. mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
  36. clk_data);
  37. return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  38. }
  39. static const struct of_device_id of_match_clk_mt8183_cam[] = {
  40. { .compatible = "mediatek,mt8183-camsys", },
  41. {}
  42. };
  43. static struct platform_driver clk_mt8183_cam_drv = {
  44. .probe = clk_mt8183_cam_probe,
  45. .driver = {
  46. .name = "clk-mt8183-cam",
  47. .of_match_table = of_match_clk_mt8183_cam,
  48. },
  49. };
  50. builtin_platform_driver(clk_mt8183_cam_drv);