blob: 637e2c53fd3c41b16c54c5ad58637eb84fd6d25e [file] [log] [blame]
developer15adbbf2021-05-24 22:20:07 +08001/*
2 * Copyright (c) 2015 MediaTek Inc.
3 * Author: James Liao <jamesjj.liao@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
15#define pr_fmt(fmt) "[clk-bringup] " fmt
16
17#include <linux/clk.h>
18#include <linux/clk-provider.h>
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/of.h>
22#include <linux/of_platform.h>
23
24static const struct of_device_id bring_up_id_table[] = {
25 { .compatible = "mediatek,clk-bring-up",},
26 { .compatible = "mediatek,mt8163-bring-up",},
27 { .compatible = "mediatek,mt8173-bring-up",},
28 { },
29};
30MODULE_DEVICE_TABLE(of, bring_up_id_table);
31
32static int bring_up_probe(struct platform_device *pdev)
33{
developer2cdaeb12022-10-04 20:25:05 +080034 const int NR_CLKS = 400;
developer15adbbf2021-05-24 22:20:07 +080035 char clk_name_buf[16];
36 struct clk *clk;
37 int i, r;
38
39 for (i = 0; i < NR_CLKS; i++) {
40 sprintf(clk_name_buf, "%d", i);
41
42 clk = devm_clk_get(&pdev->dev, clk_name_buf);
43 if (!IS_ERR(clk)) {
44 r = clk_prepare_enable(clk);
45 if (r)
46 pr_debug("clk_prepare_enable(%s): %d\n",
47 __clk_get_name(clk), r);
48 }
49 }
50
51 return 0;
52}
53
54static int bring_up_remove(struct platform_device *pdev)
55{
56 return 0;
57}
58
59static struct platform_driver bring_up = {
60 .probe = bring_up_probe,
61 .remove = bring_up_remove,
62 .driver = {
63 .name = "bring_up",
64 .owner = THIS_MODULE,
65 .of_match_table = bring_up_id_table,
66 },
67};
68
69module_platform_driver(bring_up);