clk-mt6765-cam.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2018 MediaTek Inc.
  4. * Author: Owen Chen <owen.chen@mediatek.com>
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/platform_device.h>
  8. #include "clk-mtk.h"
  9. #include "clk-gate.h"
  10. #include <dt-bindings/clock/mt6765-clk.h>
  11. static const struct mtk_gate_regs cam_cg_regs = {
  12. .set_ofs = 0x4,
  13. .clr_ofs = 0x8,
  14. .sta_ofs = 0x0,
  15. };
  16. #define GATE_CAM(_id, _name, _parent, _shift) { \
  17. .id = _id, \
  18. .name = _name, \
  19. .parent_name = _parent, \
  20. .regs = &cam_cg_regs, \
  21. .shift = _shift, \
  22. .ops = &mtk_clk_gate_ops_setclr, \
  23. }
  24. static const struct mtk_gate cam_clks[] = {
  25. GATE_CAM(CLK_CAM_LARB3, "cam_larb3", "mm_ck", 0),
  26. GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "mm_ck", 1),
  27. GATE_CAM(CLK_CAM, "cam", "mm_ck", 6),
  28. GATE_CAM(CLK_CAMTG, "camtg", "mm_ck", 7),
  29. GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "mm_ck", 8),
  30. GATE_CAM(CLK_CAMSV0, "camsv0", "mm_ck", 9),
  31. GATE_CAM(CLK_CAMSV1, "camsv1", "mm_ck", 10),
  32. GATE_CAM(CLK_CAMSV2, "camsv2", "mm_ck", 11),
  33. GATE_CAM(CLK_CAM_CCU, "cam_ccu", "mm_ck", 12),
  34. };
  35. static int clk_mt6765_cam_probe(struct platform_device *pdev)
  36. {
  37. struct clk_onecell_data *clk_data;
  38. int r;
  39. struct device_node *node = pdev->dev.of_node;
  40. clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
  41. mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks), clk_data);
  42. r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  43. if (r)
  44. pr_err("%s(): could not register clock provider: %d\n",
  45. __func__, r);
  46. return r;
  47. }
  48. static const struct of_device_id of_match_clk_mt6765_cam[] = {
  49. { .compatible = "mediatek,mt6765-camsys", },
  50. {}
  51. };
  52. static struct platform_driver clk_mt6765_cam_drv = {
  53. .probe = clk_mt6765_cam_probe,
  54. .driver = {
  55. .name = "clk-mt6765-cam",
  56. .of_match_table = of_match_clk_mt6765_cam,
  57. },
  58. };
  59. builtin_platform_driver(clk_mt6765_cam_drv);