clk-mt6797-venc.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2017 MediaTek Inc.
  3. * Author: Kevin Chen <kevin-cw.chen@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/clk-provider.h>
  15. #include <linux/platform_device.h>
  16. #include "clk-mtk.h"
  17. #include "clk-gate.h"
  18. #include <dt-bindings/clock/mt6797-clk.h>
  19. static const struct mtk_gate_regs venc_cg_regs = {
  20. .set_ofs = 0x0004,
  21. .clr_ofs = 0x0008,
  22. .sta_ofs = 0x0000,
  23. };
  24. #define GATE_VENC(_id, _name, _parent, _shift) { \
  25. .id = _id, \
  26. .name = _name, \
  27. .parent_name = _parent, \
  28. .regs = &venc_cg_regs, \
  29. .shift = _shift, \
  30. .ops = &mtk_clk_gate_ops_setclr_inv, \
  31. }
  32. static const struct mtk_gate venc_clks[] = {
  33. GATE_VENC(CLK_VENC_0, "venc_0", "mm_sel", 0),
  34. GATE_VENC(CLK_VENC_1, "venc_1", "venc_sel", 4),
  35. GATE_VENC(CLK_VENC_2, "venc_2", "venc_sel", 8),
  36. GATE_VENC(CLK_VENC_3, "venc_3", "venc_sel", 12),
  37. };
  38. static const struct of_device_id of_match_clk_mt6797_venc[] = {
  39. { .compatible = "mediatek,mt6797-vencsys", },
  40. {}
  41. };
  42. static int clk_mt6797_venc_probe(struct platform_device *pdev)
  43. {
  44. struct clk_onecell_data *clk_data;
  45. int r;
  46. struct device_node *node = pdev->dev.of_node;
  47. clk_data = mtk_alloc_clk_data(CLK_VENC_NR);
  48. mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
  49. clk_data);
  50. r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  51. if (r)
  52. dev_err(&pdev->dev,
  53. "could not register clock provider: %s: %d\n",
  54. pdev->name, r);
  55. return r;
  56. }
  57. static struct platform_driver clk_mt6797_venc_drv = {
  58. .probe = clk_mt6797_venc_probe,
  59. .driver = {
  60. .name = "clk-mt6797-venc",
  61. .of_match_table = of_match_clk_mt6797_venc,
  62. },
  63. };
  64. builtin_platform_driver(clk_mt6797_venc_drv);