Squashed backup commit (no shallow-clone history issues) of xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream commit 9eece662e) plus all fixes applied to get everpal_defconfig building clean against a modern (GCC 15.2.0) toolchain -- see the previous commit message on the lineage-23.2 branch (also in this repo history is not available here since this is a squashed snapshot; full incremental history lives in the local DL380 checkout and the upstream GitHub remote). Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
79 lines
1.9 KiB
C
79 lines
1.9 KiB
C
/*
|
|
* Copyright (c) 2015 MediaTek Inc.
|
|
* Author: James Liao <jamesjj.liao@mediatek.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_platform.h>
|
|
|
|
static const struct of_device_id bring_up_id_table[] = {
|
|
{ .compatible = "mediatek,clk-bring-up",},
|
|
{ .compatible = "mediatek,mt8163-bring-up",},
|
|
{ .compatible = "mediatek,mt8173-bring-up",},
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(of, bring_up_id_table);
|
|
|
|
static int bring_up_probe(struct platform_device *pdev)
|
|
{
|
|
struct clk *clk;
|
|
int clk_con, i;
|
|
int ret = 0;
|
|
|
|
clk_con = of_count_phandle_with_args(pdev->dev.of_node, "clocks",
|
|
"#clock-cells");
|
|
pr_notice("sum: %d\n", clk_con);
|
|
for (i = 0; i < clk_con; i++) {
|
|
clk = of_clk_get(pdev->dev.of_node, i);
|
|
if (IS_ERR(clk)) {
|
|
long ret = PTR_ERR(clk);
|
|
|
|
if (ret == -EPROBE_DEFER)
|
|
pr_notice("clk %d is not ready\n", i);
|
|
else
|
|
pr_notice("get clk %d fail, ret=%d, clk_con=%d\n",
|
|
i, (int)ret, clk_con);
|
|
} else {
|
|
pr_notice("get clk [%d]: %s ok\n", i,
|
|
__clk_get_name(clk));
|
|
ret = clk_prepare_enable(clk);
|
|
if (ret) {
|
|
pr_err("cannot force-on bringup clk node\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
fail:
|
|
return ret;
|
|
}
|
|
|
|
static int bring_up_remove(struct platform_device *pdev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver bring_up = {
|
|
.probe = bring_up_probe,
|
|
.remove = bring_up_remove,
|
|
.driver = {
|
|
.name = "bring_up",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = bring_up_id_table,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(bring_up);
|