mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
Merge "clk: qcom: clk-dummy: convert into a platform driver"
This commit is contained in:
commit
29300c2af3
2 changed files with 59 additions and 19 deletions
|
|
@ -15,9 +15,10 @@ clk-qcom-y += clk-regmap-mux-div.o
|
|||
clk-qcom-$(CONFIG_KRAIT_CLOCKS) += clk-krait.o
|
||||
clk-qcom-y += clk-hfpll.o
|
||||
clk-qcom-y += reset.o
|
||||
clk-qcom-y += clk-dummy.o clk-debug.o
|
||||
clk-qcom-y += clk-debug.o
|
||||
clk-qcom-y += gdsc-regulator.o
|
||||
clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
|
||||
obj-$(CONFIG_COMMON_CLK_QCOM) += clk-dummy.o
|
||||
|
||||
# Keep alphabetically sorted by config
|
||||
obj-$(CONFIG_APQ_GCC_8084) += gcc-apq8084.o
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
@ -85,7 +87,7 @@ static struct clk *clk_register_dummy(struct device *dev, const char *name,
|
|||
struct clk_init_data init = {};
|
||||
|
||||
/* allocate dummy clock */
|
||||
dummy = kzalloc(sizeof(*dummy), GFP_KERNEL);
|
||||
dummy = devm_kzalloc(dev, sizeof(*dummy), GFP_KERNEL);
|
||||
if (!dummy)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
|
@ -96,17 +98,15 @@ static struct clk *clk_register_dummy(struct device *dev, const char *name,
|
|||
dummy->hw.init = &init;
|
||||
|
||||
/* register the clock */
|
||||
clk = clk_register(dev, &dummy->hw);
|
||||
if (IS_ERR(clk)) {
|
||||
kfree(dummy);
|
||||
clk = devm_clk_register(dev, &dummy->hw);
|
||||
if (IS_ERR(clk))
|
||||
return clk;
|
||||
}
|
||||
|
||||
dummy->reset.of_node = node;
|
||||
dummy->reset.ops = &dummy_reset_ops;
|
||||
dummy->reset.nr_resets = RESET_MAX;
|
||||
|
||||
if (reset_controller_register(&dummy->reset))
|
||||
if (devm_reset_controller_register(dev, &dummy->reset))
|
||||
pr_err("Failed to register reset controller for %s\n", name);
|
||||
else
|
||||
pr_info("Successfully registered dummy reset controller for %s\n",
|
||||
|
|
@ -115,26 +115,65 @@ static struct clk *clk_register_dummy(struct device *dev, const char *name,
|
|||
return clk;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_dummy_clk_setup() - Setup function for simple fixed rate clock
|
||||
*/
|
||||
static void of_dummy_clk_setup(struct device_node *node)
|
||||
static int dummy_clk_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct clk *clk;
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
const char *clk_name = "dummy_clk";
|
||||
struct clk *clk;
|
||||
int ret;
|
||||
|
||||
of_property_read_string(node, "clock-output-names", &clk_name);
|
||||
|
||||
clk = clk_register_dummy(NULL, clk_name, 0, node);
|
||||
clk = clk_register_dummy(&pdev->dev, clk_name, 0, node);
|
||||
if (!IS_ERR(clk)) {
|
||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||
ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
pr_err("Failed to register dummy clock controller for %s\n",
|
||||
clk_name);
|
||||
return;
|
||||
ret = PTR_ERR(clk);
|
||||
pr_err("Failed to register dummy clock controller for %s, ret=%d\n",
|
||||
clk_name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pr_info("Successfully registered dummy clock controller for %s\n",
|
||||
dev_info(&pdev->dev, "Successfully registered dummy clock controller for %s\n",
|
||||
clk_name);
|
||||
return 0;
|
||||
}
|
||||
CLK_OF_DECLARE(dummy_clk, "qcom,dummycc", of_dummy_clk_setup);
|
||||
|
||||
static int dummy_clk_remove(struct platform_device *pdev)
|
||||
{
|
||||
of_clk_del_provider(pdev->dev.of_node);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id dummy_clk_match_table[] = {
|
||||
{ .compatible = "qcom,dummycc" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, dummy_clk_match_table);
|
||||
|
||||
static struct platform_driver dummy_clk_driver = {
|
||||
.probe = dummy_clk_probe,
|
||||
.remove = dummy_clk_remove,
|
||||
.driver = {
|
||||
.name = "clk-dummy",
|
||||
.of_match_table = dummy_clk_match_table,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init dummy_clk_init(void)
|
||||
{
|
||||
return platform_driver_register(&dummy_clk_driver);
|
||||
}
|
||||
arch_initcall(dummy_clk_init);
|
||||
|
||||
static void __exit dummy_clk_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&dummy_clk_driver);
|
||||
}
|
||||
module_exit(dummy_clk_exit);
|
||||
|
||||
MODULE_DESCRIPTION("QTI Dummy Clock Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
|||
Loading…
Reference in a new issue