| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | /* |
| 4 | |
| 5 | * Copyright (c) 2019 MediaTek Inc. |
| 6 | |
| 7 | */ |
| 8 | |
| 9 | #include <linux/clk-provider.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | |
| 12 | #include "clk-mtk.h" |
| 13 | #include "clk-gate.h" |
| 14 | |
| 15 | #include <dt-bindings/clock/mt6890-clk.h> |
| 16 | |
| 17 | #define MT_CLKMGR_MODULE_INIT 0 |
| 18 | |
| 19 | #define MT_CCF_BRINGUP 1 |
| 20 | |
| 21 | #define INV_OFS -1 |
| 22 | |
| 23 | |
| 24 | |
| 25 | static const struct mtk_gate_regs gce_cg_regs = { |
| 26 | .set_ofs = 0xf0, |
| 27 | .clr_ofs = 0xf0, |
| 28 | .sta_ofs = 0xf0, |
| 29 | }; |
| 30 | |
| 31 | #define GATE_GCE(_id, _name, _parent, _shift) { \ |
| 32 | .id = _id, \ |
| 33 | .name = _name, \ |
| 34 | .parent_name = _parent, \ |
| 35 | .regs = &gce_cg_regs, \ |
| 36 | .shift = _shift, \ |
| 37 | .ops = &mtk_clk_gate_ops_no_setclr, \ |
| 38 | } |
| 39 | |
| 40 | static const struct mtk_gate gce_clks[] = { |
| 41 | GATE_GCE(CLK_GCE_0, "gce_0", |
| 42 | "axi_ck"/* parent */, 16), |
| 43 | }; |
| 44 | |
| 45 | static int clk_mt6890_gce_probe(struct platform_device *pdev) |
| 46 | { |
| 47 | struct clk_onecell_data *clk_data; |
| 48 | int r; |
| 49 | struct device_node *node = pdev->dev.of_node; |
| 50 | |
| 51 | #if MT_CCF_BRINGUP |
| 52 | pr_notice("%s init begin\n", __func__); |
| 53 | #endif |
| 54 | |
| 55 | clk_data = mtk_alloc_clk_data(CLK_GCE_NR_CLK); |
| 56 | |
| 57 | mtk_clk_register_gates(node, gce_clks, ARRAY_SIZE(gce_clks), |
| 58 | clk_data); |
| 59 | |
| 60 | r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); |
| 61 | |
| 62 | if (r) |
| 63 | pr_err("%s(): could not register clock provider: %d\n", |
| 64 | __func__, r); |
| 65 | |
| 66 | #if MT_CCF_BRINGUP |
| 67 | pr_notice("%s init end\n", __func__); |
| 68 | #endif |
| 69 | |
| 70 | return r; |
| 71 | } |
| 72 | |
| 73 | static const struct of_device_id of_match_clk_mt6890_gce[] = { |
| 74 | { .compatible = "mediatek,mt6890-gce", }, |
| 75 | {} |
| 76 | }; |
| 77 | |
| 78 | #if MT_CLKMGR_MODULE_INIT |
| 79 | |
| 80 | static struct platform_driver clk_mt6890_gce_drv = { |
| 81 | .probe = clk_mt6890_gce_probe, |
| 82 | .driver = { |
| 83 | .name = "clk-mt6890-gce", |
| 84 | .of_match_table = of_match_clk_mt6890_gce, |
| 85 | }, |
| 86 | }; |
| 87 | |
| 88 | builtin_platform_driver(clk_mt6890_gce_drv); |
| 89 | |
| 90 | #else |
| 91 | |
| 92 | static struct platform_driver clk_mt6890_gce_drv = { |
| 93 | .probe = clk_mt6890_gce_probe, |
| 94 | .driver = { |
| 95 | .name = "clk-mt6890-gce", |
| 96 | .of_match_table = of_match_clk_mt6890_gce, |
| 97 | }, |
| 98 | }; |
| 99 | static int __init clk_mt6890_gce_platform_init(void) |
| 100 | { |
| 101 | return platform_driver_register(&clk_mt6890_gce_drv); |
| 102 | } |
| 103 | arch_initcall(clk_mt6890_gce_platform_init); |
| 104 | |
| 105 | #endif /* MT_CLKMGR_MODULE_INIT */ |