xref: /linux/drivers/clk/qcom/kpss-xcc.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
13ddc3564SStephen Boyd // SPDX-License-Identifier: GPL-2.0
23ddc3564SStephen Boyd // Copyright (c) 2018, The Linux Foundation. All rights reserved.
33ddc3564SStephen Boyd 
43ddc3564SStephen Boyd #include <linux/kernel.h>
53ddc3564SStephen Boyd #include <linux/init.h>
63ddc3564SStephen Boyd #include <linux/module.h>
73ddc3564SStephen Boyd #include <linux/platform_device.h>
8409c39ecSRob Herring #include <linux/property.h>
93ddc3564SStephen Boyd #include <linux/err.h>
103ddc3564SStephen Boyd #include <linux/io.h>
113ddc3564SStephen Boyd #include <linux/of.h>
123ddc3564SStephen Boyd #include <linux/clk.h>
133ddc3564SStephen Boyd #include <linux/clk-provider.h>
143ddc3564SStephen Boyd 
15c3db5128SChristian Marangi static const struct clk_parent_data aux_parents[] = {
16c3db5128SChristian Marangi 	{ .fw_name = "pll8_vote", .name = "pll8_vote" },
17c3db5128SChristian Marangi 	{ .fw_name = "pxo", .name = "pxo_board" },
183ddc3564SStephen Boyd };
193ddc3564SStephen Boyd 
20eac03cb0SJonathan Neuschäfer static const u32 aux_parent_map[] = {
213ddc3564SStephen Boyd 	3,
223ddc3564SStephen Boyd 	0,
233ddc3564SStephen Boyd };
243ddc3564SStephen Boyd 
253ddc3564SStephen Boyd static const struct of_device_id kpss_xcc_match_table[] = {
263ddc3564SStephen Boyd 	{ .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
273ddc3564SStephen Boyd 	{ .compatible = "qcom,kpss-gcc" },
283ddc3564SStephen Boyd 	{}
293ddc3564SStephen Boyd };
303ddc3564SStephen Boyd MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
313ddc3564SStephen Boyd 
kpss_xcc_driver_probe(struct platform_device * pdev)323ddc3564SStephen Boyd static int kpss_xcc_driver_probe(struct platform_device *pdev)
333ddc3564SStephen Boyd {
3409be1a39SChristian Marangi 	struct device *dev = &pdev->dev;
353ddc3564SStephen Boyd 	void __iomem *base;
36c3db5128SChristian Marangi 	struct clk_hw *hw;
373ddc3564SStephen Boyd 	const char *name;
383ddc3564SStephen Boyd 
3917c774abSCai Huoqing 	base = devm_platform_ioremap_resource(pdev, 0);
403ddc3564SStephen Boyd 	if (IS_ERR(base))
413ddc3564SStephen Boyd 		return PTR_ERR(base);
423ddc3564SStephen Boyd 
43409c39ecSRob Herring 	if (device_get_match_data(&pdev->dev)) {
4409be1a39SChristian Marangi 		if (of_property_read_string_index(dev->of_node,
453ddc3564SStephen Boyd 						  "clock-output-names",
463ddc3564SStephen Boyd 						  0, &name))
473ddc3564SStephen Boyd 			return -ENODEV;
483ddc3564SStephen Boyd 		base += 0x14;
493ddc3564SStephen Boyd 	} else {
503ddc3564SStephen Boyd 		name = "acpu_l2_aux";
513ddc3564SStephen Boyd 		base += 0x28;
523ddc3564SStephen Boyd 	}
533ddc3564SStephen Boyd 
5409be1a39SChristian Marangi 	hw = devm_clk_hw_register_mux_parent_data_table(dev, name, aux_parents,
55c3db5128SChristian Marangi 							ARRAY_SIZE(aux_parents), 0,
56c3db5128SChristian Marangi 							base, 0, 0x3,
573ddc3564SStephen Boyd 							0, aux_parent_map, NULL);
5809be1a39SChristian Marangi 	if (IS_ERR(hw))
5909be1a39SChristian Marangi 		return PTR_ERR(hw);
603ddc3564SStephen Boyd 
61*9db4585eSChen Ni 	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, hw);
623ddc3564SStephen Boyd }
633ddc3564SStephen Boyd 
643ddc3564SStephen Boyd static struct platform_driver kpss_xcc_driver = {
653ddc3564SStephen Boyd 	.probe = kpss_xcc_driver_probe,
663ddc3564SStephen Boyd 	.driver = {
673ddc3564SStephen Boyd 		.name = "kpss-xcc",
683ddc3564SStephen Boyd 		.of_match_table = kpss_xcc_match_table,
693ddc3564SStephen Boyd 	},
703ddc3564SStephen Boyd };
713ddc3564SStephen Boyd module_platform_driver(kpss_xcc_driver);
723ddc3564SStephen Boyd 
733ddc3564SStephen Boyd MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
743ddc3564SStephen Boyd MODULE_LICENSE("GPL v2");
753ddc3564SStephen Boyd MODULE_ALIAS("platform:kpss-xcc");
76